Skip to content
Closed
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
58 changes: 32 additions & 26 deletions reconstruction/cvt/src/main/java/org/jlab/rec/cvt/hit/Hit.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.jlab.rec.cvt.hit;

import org.jlab.detector.base.DetectorDescriptor;
import org.jlab.detector.base.DetectorType;
import org.jlab.geom.prim.Line3D;
import org.jlab.geom.prim.Point3D;
Expand All @@ -16,12 +17,8 @@ public class Hit implements Comparable<Hit> {
// class implements Comparable interface to allow for sorting a collection of hits by wire number values

private int _Id; // Hit Id

private DetectorType _Detector; // the detector SVT or BMT
private DetectorDescriptor _Descriptor;
private BMTType _Type; // for the BMT, either C or Z

private int _Sector; // sector[1...24] for SVT, [1..3] for BMT
private int _Layer; // layer [1,...]
private Strip _Strip; // Strip object

private double _docaToTrk; // 3-D distance of closest approach of the helix to the wire
Expand All @@ -35,29 +32,38 @@ public class Hit implements Comparable<Hit> {
public int MCstatus = -1;
public boolean isCorrupted;

// constructor
public Hit(DetectorType detector, BMTType type, int sector, int layer, Strip strip) {
this._Detector = detector; // 0 = SVT, 1 = BMT
this._Type = type; // set according to BMTType
this._Sector = sector;
this._Layer = layer;
public Hit(DetectorDescriptor descriptor, BMTType type, Strip strip) {
this._Descriptor = descriptor;
this._Type = type;
this._Strip = strip;

}

public Hit(DetectorType detector, BMTType type, int sector, int layer, Strip strip) {
this._Descriptor = new DetectorDescriptor();
this._Descriptor.setType(detector);
this._Descriptor.setSector(sector);
this._Descriptor.setLayer(layer);
this._Type = type;
this._Strip = strip;
}

public DetectorDescriptor getDescriptor() {
return _Descriptor;
}

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

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

public BMTType getType() {
return _Type;
}

public void setType(BMTType type) {
public final void setType(BMTType type) {
this._Type = type;
}

Expand All @@ -66,40 +72,40 @@ public void setType(BMTType type) {
* @return the sector (1...24)
*/
public int getSector() {
return _Sector;
return _Descriptor.getSector();
}

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

/**
*
* @return the layer (1...8)
*/
public int getLayer() {
return _Layer;
return _Descriptor.getLayer();
}

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

public Strip getStrip() {
return _Strip;
}

public void setStrip(Strip _Strip) {
public final void setStrip(Strip _Strip) {
this._Strip = _Strip;
}

Expand All @@ -116,7 +122,7 @@ public int getId() {
*
* @param _Id
*/
public void setId(int _Id) {
public final void setId(int _Id) {
this._Id = _Id;
}

Expand All @@ -125,15 +131,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
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -62,7 +61,6 @@ public class Track extends Trajectory implements Comparable<Track> {
private int secondaryNDF; // for track with no beamSpot information
private int _status = 0;


public Track(Helix helix) {
super(helix);
if (helix != null) {
Expand Down Expand Up @@ -97,7 +95,6 @@ public Track(Seed seed, KFitter kf) {
this.setStatus(-1);
}
}


public Track(Seed seed, KFitter kf, int pid) {
this(seed, kf);
Expand Down Expand Up @@ -162,23 +159,23 @@ public Helix getSecondaryHelix() {
return secondaryHelix;
}

public void setSecondaryHelix(Helix secondaryHelix) {
public final void setSecondaryHelix(Helix secondaryHelix) {
this.secondaryHelix = secondaryHelix;
}

public double getSecondaryChi2() {
return secondaryChi2;
}

public void setSecondaryChi2(double secondaryChi2) {
public final void setSecondaryChi2(double secondaryChi2) {
this.secondaryChi2 = secondaryChi2;
}

public int getSecondaryNDF() {
return secondaryNDF;
}

public void setSecondaryNDF(int secondaryNDF) {
public final void setSecondaryNDF(int secondaryNDF) {
this.secondaryNDF = secondaryNDF;
}

Expand All @@ -205,8 +202,7 @@ public final void setPXYZ() {
calcPt = 100;
setQ(1);
}
double calcPz = 0;
calcPz = calcPt * helix.getTanDip();
double calcPz = calcPt * helix.getTanDip();
double calcP = Math.sqrt(calcPt * calcPt + calcPz * calcPz);
setPt(calcPt);
setPz(calcPz);
Expand All @@ -217,6 +213,8 @@ public final void setPXYZ() {
/**
* Updates the crosses positions based on trajectories or helix
* @param trackId
* @param xb
* @param yb
*/
public void update_Crosses(int trackId, double xb, double yb) {
for (int i = 0; i < this.size(); i++) {
Expand Down Expand Up @@ -288,12 +286,7 @@ public boolean equals(Object obj) {
if (getClass() != obj.getClass()) {
return false;
}
Track other = (Track) obj;
if (this.getId() != other.getId()) {
return false;
}

return true;
return this.getId() == ((Track)obj).getId();
}

@Override
Expand Down Expand Up @@ -328,9 +321,9 @@ else if(this.getChi2() > Constants.CHI2CUT * (this.getNDF() + 5))
return false;
if(this.getNDF() < Constants.NDFCUT)
return false;
if(this.getHelix().radius() < Constants.getInstance().getRCUT())
if(this.getHelix().radius() < Constants.getRCUT())
return false;
if(Math.abs(Geometry.getInstance().getTargetZOffset()-this.getHelix().getZ0()) > Geometry.getInstance().getTargetHalfLength()+Constants.getInstance().getZRANGE())
if(Math.abs(Geometry.getInstance().getTargetZOffset()-this.getHelix().getZ0()) > Geometry.getInstance().getTargetHalfLength()+Constants.getZRANGE())
return false;
else
return true;
Expand Down Expand Up @@ -396,7 +389,7 @@ public int getPID() {
return _PID;
}

public void setPID(int _PID) {
public final void setPID(int _PID) {
this._PID = _PID;
}

Expand Down Expand Up @@ -445,13 +438,14 @@ public final void setKFTrajectories(Map<Integer, HitOnTrack> trajectory) {
public int getStatus() {
return _status;
}
public void setStatus(int passKFFlag) {
public final void setStatus(int passKFFlag) {
//for status word:
int nSVT = 0;
int nBMTZ = 0;
int nBMTC = 0;
// fills the list of cross ids for crosses belonging to that reconstructed track
for (int j = 0; j < this.size(); j++) {
int size = this.size();
for (int j = 0; j < size; j++) {
// counter to get status word
if (this.get(j).getDetector() == DetectorType.BST) {
nSVT++;
Expand Down Expand Up @@ -565,7 +559,8 @@ else if(MLayer.getDetectorType(index) == DetectorType.BMT) {

private static int[] getTrackKey(Track track) {
int[] cids = new int[9];
for (int i = 0; i < track.size(); i++) {
int size = track.size();
for (int i = 0; i < size; i++) {
Cross c = track.get(i);
if(c.getDetector()==DetectorType.BST) {
cids[c.getRegion()-1] = c.getId();
Expand Down Expand Up @@ -593,23 +588,25 @@ public static void removeOverlappingTracks(List<Track> tracks) {
return;
Map<Integer, Track> map = new HashMap<>();
Map<Integer, Track> selectedTracks = new HashMap<>();
for (int i = 0; i < tracks.size(); i++) {
final int size = tracks.size();
for (int i = 0; i < size; i++) {
Track t1 = tracks.get(i);
t1.setTempId(i+1);
map.put(i+1, t1);
}
for (int i = 0; i < tracks.size(); i++) {
for (int i = 0; i < size; i++) {
Track t1 = tracks.get(i);
int[] cids = getTrackKey(t1);
for (int j = 0;j < tracks.size(); j++) {
boolean ov = false;
if(i==j) continue;
Track t2 = tracks.get(j);
int[] cids2 = getTrackKey(t2);
for(int k = 0; k<9; k++) {
for(int k = 0; k < 9; k++) {
if(cids[k]!=-1) {
if(cids[k]==cids2[k]) {
ov=true;
break;
}
}
}
Expand All @@ -618,7 +615,7 @@ public static void removeOverlappingTracks(List<Track> tracks) {
}
}
}
for (int i = 0; i < tracks.size(); i++) {
for (int i = 0; i < size; i++) {
List<Track> ovlTracks = new ArrayList<>();
Track t1 = tracks.get(i);
ovlTracks.add(t1);
Expand All @@ -638,9 +635,10 @@ public static void removeOverlappingTracks(List<Track> tracks) {
}

public static void checkForOverlaps(List<Track> tracks, String msg) {
for (int i = 0; i < tracks.size(); i++) {
int size = tracks.size();
for (int i = 0; i < size; i++) {
Track t1 = tracks.get(i);
for(int j=0; j<tracks.size(); j++ ) {
for(int j=0; j<size; j++ ) {
Track t2 = tracks.get(j);
if(i!=j && t1.overlapWith(t2)) {
System.out.println(msg + " " + "overlap");
Expand All @@ -649,7 +647,6 @@ public static void checkForOverlaps(List<Track> tracks, String msg) {
}
}


@Override
public String toString() {
String str = String.format("Track id=%d, q=%d, p=%.3f GeV pt=%.3f GeV, d0=%.3f deg, phi=%.3f deg, z0=%.3f deg, tandip=%.3f deg, NDF=%d, chi2=%.3f, seed method=%d, KF iterations=%d, status=%d\n",
Expand All @@ -661,8 +658,4 @@ public String toString() {
return str;
}





}