Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
import java.util.Collections;
import org.jlab.clas.tracking.kalmanfilter.AKFitter.HitOnTrack;
import org.jlab.clas.tracking.kalmanfilter.Surface;
import org.jlab.detector.base.DetectorDescriptor;
import org.jlab.detector.base.DetectorType;
import org.jlab.geom.prim.Arc3D;
import org.jlab.geom.prim.Cylindrical3D;
import org.jlab.geom.prim.Plane3D;
import org.jlab.geom.prim.Transformation3D;
import org.jlab.rec.cvt.Geometry;
import org.jlab.rec.cvt.bmt.BMTType;
Expand All @@ -27,10 +27,8 @@ public class Cluster extends ArrayList<Hit> implements Comparable<Cluster> {

private static final long serialVersionUID = 9153980362683755204L;

private DetectorType _Detector; // The detector SVT or BMT
private DetectorDescriptor _Descriptor;
private BMTType _Type; // The detector type for BMT C or Z
private int _Sector; // sector[1...]
private int _Layer; // layer [1,...]
private int _Tlayer; // layer in tracker comprising 6 svt layers and 6 bmt layer [1...12]
private int _Id; // cluster Id
private double _Centroid; // after LC (Lorentz Correction)
Expand Down Expand Up @@ -63,13 +61,47 @@ public class Cluster extends ArrayList<Hit> implements Comparable<Cluster> {
private Vector3D _s; //svt vector perpendicular to cluster pseudo-strip direction in the module plane or bmt vector perpendicular to cluster pseudo-strip in direction tangential to the cluster surface in the middle of the arc
private Vector3D _n; //svt vector normal to the cluster module plane or bmt vector normal to the cluster surface in the middle of the arc
public boolean flagForExclusion = false;


public Cluster(ArrayList<Hit> hits, int id) {
super(hits.size());
this._Id = id;
this._Descriptor = hits.get(0).getDescriptor();
this._Type = hits.get(0).getType();
this._Tlayer = hits.get(0).getLayer();
if(this._Descriptor.getType() == DetectorType.BMT)
this._Tlayer+=6;
this.addAll(hits);
}

public Cluster(int size, Hit hit, int id) {
super(size);
this._Id = id;
this._Descriptor = hit.getDescriptor();
this._Type = hit.getType();
this._Tlayer = hit.getLayer();
if(this._Descriptor.getType() == DetectorType.BMT)
this._Tlayer+=6;
}

public Cluster(int size, DetectorType detector, BMTType type, int sector, int layer, int cid) {
super(size);
this._Descriptor = new DetectorDescriptor();
this._Descriptor.setType(detector);
this._Descriptor.setSector(sector);
this._Descriptor.setLayer(layer);
this._Type = type;
this._Id = cid;
this._Tlayer = layer;
if(detector==DetectorType.BMT)
this._Tlayer+=6;
}

public Cluster(DetectorType detector, BMTType type, int sector, int layer, int cid) {
this._Detector = detector;
this._Descriptor = new DetectorDescriptor();
this._Descriptor.setType(detector);
this._Descriptor.setSector(sector);
this._Descriptor.setLayer(layer);
this._Type = type;
this._Sector = sector;
this._Layer = layer;
this._Id = cid;
this._Tlayer = layer;
if(detector==DetectorType.BMT)
Expand All @@ -84,15 +116,15 @@ public Cluster(DetectorType detector, BMTType type, int sector, int layer, int c
* number.
*/
public Cluster newCluster(Hit hit, int cid) {
return new Cluster(hit.getDetector(), hit.getType(), hit.getSector(), hit.getLayer(), cid);
return new Cluster(0, hit.getDetector(), hit.getType(), hit.getSector(), hit.getLayer(), cid);
}

public DetectorType getDetector() {
return _Detector;
return _Descriptor.getType();
}

public void setDetector(DetectorType _Detector) {
this._Detector = _Detector;
this._Descriptor.setType(_Detector);
}

public BMTType getType() {
Expand All @@ -108,31 +140,31 @@ public void setType(BMTType type) {
* @return the sector of the cluster
*/
public int getSector() {
return _Sector;
return this._Descriptor.getSector();
}

/**
*
* @param _Sector sector of the cluster
*/
public void setSector(int _Sector) {
this._Sector = _Sector;
this._Descriptor.setSector(_Sector);
}

/**
*
* @return the layer of the cluster
*/
public int getLayer() {
return _Layer;
return this._Descriptor.getLayer();
}

/**
*
* @param _Layer the layer of the cluster
*/
public void setLayer(int _Layer) {
this._Layer = _Layer;
this._Descriptor.setLayer(_Layer);
}

/**
Expand Down Expand Up @@ -170,15 +202,15 @@ public void setId(int _Id) {
* @return region (1...4)
*/
public int getRegion() {
return (int) (this._Layer + 1) / 2;
return (int) (this.getLayer() + 1) / 2;
}

/**
*
* @return superlayer 1 or 2 in region (1...4)
*/
public int getRegionSlayer() {
return (this._Layer + 1) % 2 + 1;
return (this.getLayer() + 1) % 2 + 1;
}

/**
Expand Down Expand Up @@ -235,7 +267,6 @@ public void calc_CentroidParams() {
double weightedZ1 = 0; // SVT/BMT strip centroid positions of endpoints
double weightedZ2 = 0; // SVT/BMT strip centroid positions of endpoints
double weightedZC = 0; // BMT strip centroid positions of strip midpoint
double weightedZ0 = 0; // BMT strip centroid positions of strip midpoint with no LC

int nbhits = this.size();
//sort for bmt detector
Expand Down Expand Up @@ -323,7 +354,6 @@ else if (this.getDetector()==DetectorType.BMT) {
weightedZC += strpEn * stCent.z();
weightedX0 += strpEn * stCent0.x();
weightedY0 += strpEn * stCent0.y();
weightedZ0 += strpEn * stCent0.z();
weightedStrp += strpEn * (double) strpNb;
weightedStrp0 += strpEn * (double) strpNb0;

Expand All @@ -341,7 +371,7 @@ else if (this.getDetector()==DetectorType.BMT) {

}
if (totEn == 0) {
System.err.println(" Cluster energy is null .... exit "+this._Detector+" "+this._Type);
System.err.println(" Cluster energy is null .... exit "+this._Descriptor.getType()+" "+this._Type);

return;
}
Expand All @@ -364,7 +394,6 @@ else if (this.getDetector()==DetectorType.BMT) {
weightedZC /= totEn;
weightedX0 /= totEn;
weightedY0 /= totEn;
weightedZ0 /= totEn;
weightedZ /= totEn;
weightedPhi = Math.atan2(weightedYC, weightedXC);
weightedPhi0 = Math.atan2(weightedY0, weightedX0);
Expand Down Expand Up @@ -695,12 +724,12 @@ public Surface measurement() {
Surface surface = null;

if(this.getDetector()==DetectorType.BST) {
Point3D endPt1 = this.getLine().origin();
Point3D endPt2 = this.getLine().end();
//Point3D endPt1 = this.getLine().origin();
//Point3D endPt2 = this.getLine().end();
// org.jlab.clas.tracking.objects.Strip strp = new org.jlab.clas.tracking.objects.Strip(this.getId(), this.getCentroid(),
// endPt1.x(), endPt1.y(), endPt1.z(),
// endPt2.x(), endPt2.y(), endPt2.z());
Plane3D plane = new Plane3D(endPt1, this.getN());
//Plane3D plane = new Plane3D(endPt1, this.getN());
surface = Geometry.getInstance().getSVT().getSurface(this.getLayer(), this.getSector(), this.getId(),
this.getCentroid(), this.getLine());
surface.hemisphere = Math.signum(this.center().y());
Expand Down Expand Up @@ -766,15 +795,13 @@ public int compareTo(Cluster arg) {
double arg_phi = arg.getPhi0();

int CompPhi = this_phi < arg_phi ? -1 : this_phi == arg_phi ? 0 : 1;
int CompLay = this._Layer < arg._Layer ? -1 : this._Layer == arg._Layer ? 0 : 1;
int CompLay = this.getLayer() < arg.getLayer() ? -1 : this.getLayer() == arg.getLayer() ? 0 : 1;
int CompId = this.getSeedStrip().getStrip()< arg.getSeedStrip().getStrip() ? -1 : this.getSeedStrip().getStrip() == arg.getSeedStrip().getStrip() ? 0 : 1;

int return_val1 = ((CompLay == 0) ? CompId : CompLay);
int return_val = ((CompPhi == 0) ? return_val1 : CompPhi);

return return_val;


}

private double PhiInRange(double phi) {
Expand Down Expand Up @@ -836,22 +863,22 @@ public void setN(Vector3D _n) {

public void update(int trackId, HitOnTrack traj) {

Point3D trackPos = new Point3D(traj.x, traj.y, traj.z);
Vector3D trackDir = new Vector3D(traj.px, traj.py, traj.pz).asUnit();
Point3D trackPos = new Point3D(traj.x, traj.y, traj.z);

this.setAssociatedTrackID(trackId);
this.setCentroidResidual(traj.residual);
this.setSeedResidual(trackPos);
this.setTrakInters(trackPos);


if(this.getDetector()==DetectorType.BMT && this.getType()==BMTType.C) {
this.setS(this.getAxis().direction().asUnit());
this.setN(this.getAxis().distance(trackPos).direction().asUnit());
this.setL(this.getS().cross(this.getN()).asUnit());
}
if(this.getDetector()==DetectorType.BMT && this.getType()==BMTType.Z) {
this.setCentroidResidual(traj.residual*this.getTile().baseArc().radius());
if(this.getDetector() == DetectorType.BMT) {
if (this.getType() == BMTType.C) {
this.setS(this.getAxis().direction().asUnit());
this.setN(this.getAxis().distance(trackPos).direction().asUnit());
this.setL(this.getS().cross(this.getN()).asUnit());
}
else if (this.getType() == BMTType.Z) {
this.setCentroidResidual(traj.residual*this.getTile().baseArc().radius());
}
}

for (Hit hit : this) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.jlab.detector.base.DetectorType;
import org.jlab.rec.cvt.hit.Hit;

/**
Expand Down Expand Up @@ -51,7 +50,6 @@ public ArrayList<Cluster> findClusters(List<Hit> hits2) // the number of strips
}

}
int cid = 1; // cluster id, will increment with each new good cluster

// for each layer and sector, a loop over the strips
// is done to define clusters in that module's layer
Expand All @@ -77,10 +75,7 @@ public ArrayList<Cluster> findClusters(List<Hit> hits2) // the number of strips
}

// define new cluster
Cluster this_cluster = new Cluster(hits.get(0).getDetector(), hits.get(0).getType(), hits.get(0).getSector(), l + 1, cid++);
this_cluster.setId(clusters.size() + 1);
// add hits to the cluster
this_cluster.addAll(hits);
Cluster this_cluster = new Cluster(hits, clusters.size()+1);
if(hits.size()>2) {
for(int hi = 1; hi<hits.size()-1; hi++) { //interpolate between neighboring strips
if(hits.get(hi).getStrip().getEdep()<hits.get(hi-1).getStrip().getEdep()
Expand All @@ -89,17 +84,12 @@ public ArrayList<Cluster> findClusters(List<Hit> hits2) // the number of strips
}
}
}
for (Hit h : hits) {
h.setAssociatedClusterID(this_cluster.getId());
//h.newClustering = true; //RDV fix me!
int size = hits.size();
for (int i=0; i<size; i++) {
hits.get(i).setAssociatedClusterID(this_cluster.getId());
}

this_cluster.calc_CentroidParams();
//if(this_cluster.getDetector()==DetectorType.BST) {
// for (Hit h : this_cluster) {
// h.newClustering = false;
// }
//}
Collections.sort(this_cluster);

//make list of clusters
Expand Down
Loading