Skip to content
This repository has been archived by the owner on May 18, 2023. It is now read-only.

Commit

Permalink
Correct associated track IDs for matched hits
Browse files Browse the repository at this point in the history
  • Loading branch information
zieglerv committed Dec 8, 2017
1 parent 10da987 commit d5e8f9b
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void set_CTOFHits(List<Hit> _Hits) {
* @param geometry the CTOF geometry from package
*/
public void fetch_Hits(DataEvent event, CTOFGeant4Factory geometry,
List<Line3d> trks, double[] paths,
List<Line3d> trks, double[] paths, int[] ids,
IndexedTable constants0,
IndexedTable constants1,
IndexedTable constants2,
Expand Down Expand Up @@ -115,7 +115,7 @@ public void fetch_Hits(DataEvent event, CTOFGeant4Factory geometry,
// add this hit
hits.add(hit);
}
List<Hit> updated_hits = matchHitsToCVTTrk(hits, geometry, trks, paths);
List<Hit> updated_hits = matchHitsToCVTTrk(hits, geometry, trks, paths, ids);

ArrayList<ArrayList<Hit>> DetHits = new ArrayList<ArrayList<Hit>>();
for (int j = 0; j < 3; j++) {
Expand Down Expand Up @@ -194,7 +194,7 @@ private int passADC(int aDC) {
return pass;
}

private List<Hit> matchHitsToCVTTrk(List<Hit> CTOFhits, CTOFGeant4Factory ctofDetector, List<Line3d> trks, double[] paths) {
private List<Hit> matchHitsToCVTTrk(List<Hit> CTOFhits, CTOFGeant4Factory ctofDetector, List<Line3d> trks, double[] paths, int[] ids) {
if (trks == null || trks.size() == 0) {
return CTOFhits; // no hits were matched with DC tracks
}
Expand Down Expand Up @@ -249,6 +249,7 @@ private List<Hit> matchHitsToCVTTrk(List<Hit> CTOFhits, CTOFGeant4Factory ctofDe
double barOrigToTrkPos = origPaddleLine.distance(trkPosinMidlBar);
// local y:
hit.set_yTrk(barOrigToTrkPos - Lov2);
hit._AssociatedTrkId = ids[i];
//---------------------------------------
hitList.add(hit);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,16 @@ public TrackReader() {

private List<Line3d> _TrkLines;
private double[] _Paths;
private int[] _TrkId;

public int[] getTrkId() {
return _TrkId;
}

public void setTrkId(int[] _TrkId) {
this._TrkId = _TrkId;
}

public List<Line3d> get_TrkLines() {
return _TrkLines;
}
Expand Down Expand Up @@ -51,7 +60,7 @@ public void fetch_Trks(DataEvent event) {

DataBank bank = event.getBank("CVTRec::Tracks");
int rows = bank.rows();

int[] ids = new int[rows];
double[] x = new double[rows]; // cross x-position in the lab at
// the CTOF face
double[] y = new double[rows]; // cross y-position in the lab at
Expand All @@ -77,7 +86,7 @@ public void fetch_Trks(DataEvent event) {
double[] paths = new double[rows];

for (int i = 0; i < rows; i++) {

ids[i] = bank.getShort("ID", i);
x[i] = bank.getFloat("c_x", i);
y[i] = bank.getFloat("c_y", i);
z[i] = bank.getFloat("c_z", i);
Expand All @@ -96,6 +105,7 @@ public void fetch_Trks(DataEvent event) {
}

// fill the list of TOF hits
this.setTrkId(ids);
this.set_TrkLines(trkLines);
this.set_Paths(paths);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void set_FTOF2Hits(List<Hit> _FTOF2Hits) {
* @param geometry the FTOF geometry from package
*/
public void fetch_Hits(DataEvent event, FTOFGeant4Factory geometry,
List<Line3d> trks, double[] paths,
List<Line3d> trks, double[] paths, int[] ids,
IndexedTable constants0,
IndexedTable constants1,
IndexedTable constants2,
Expand Down Expand Up @@ -157,7 +157,7 @@ public void fetch_Hits(DataEvent event, FTOFGeant4Factory geometry,
// add this hit
hits.add(hit);
}
List<Hit> updated_hits = matchHitsToDCTrk(hits, geometry, trks, paths);
List<Hit> updated_hits = matchHitsToDCTrk(hits, geometry, trks, paths, ids);

ArrayList<ArrayList<Hit>> DetHits = new ArrayList<ArrayList<Hit>>();
for (int j = 0; j < 3; j++) {
Expand Down Expand Up @@ -301,7 +301,7 @@ private int passADC(int aDC) {
}

private List<Hit> matchHitsToDCTrk(List<Hit> FTOFhits,
FTOFGeant4Factory ftofDetector, List<Line3d> trks, double[] paths) {
FTOFGeant4Factory ftofDetector, List<Line3d> trks, double[] paths, int[] ids) {
if (trks == null || trks.size() == 0) {
return FTOFhits; // no hits were matched with DC tracks
}
Expand Down Expand Up @@ -378,6 +378,7 @@ private List<Hit> matchHitsToDCTrk(List<Hit> FTOFhits,
.distance(trkPosinMidlBar);
// local y:
hit.set_yTrk(barOrigToTrkPos - Lov2);
hit._AssociatedTrkId=ids[i];
// ---------------------------------------
hitList.add(hit); // add this hit to the output list

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,15 @@ public TrackReader() {

private List<Line3d> _TrkLines;
private double[] _Paths;
private int[] _TrkId;

public int[] getTrkId() {
return _TrkId;
}

public void setTrkId(int[] _TrkId) {
this._TrkId = _TrkId;
}
public List<Line3d> get_TrkLines() {
return _TrkLines;
}
Expand Down Expand Up @@ -95,6 +103,7 @@ public void fetch_Trks(DataEvent event) {
// fill the list of TOF hits
this.set_TrkLines(trkLines);
this.set_Paths(paths);
this.setTrkId(tid);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import java.io.FileNotFoundException;
import java.text.DecimalFormat;
import java.util.List;

import org.jlab.detector.geant4.v2.CTOFGeant4Factory;
import org.jlab.detector.hits.CTOFDetHit;
Expand Down Expand Up @@ -38,7 +37,7 @@ public Hit(int id, int panel, int sector, int paddle, int aDCU, int tDCU,
// FTOF hit counter
private Line3d _matchedTrack;

public short _AssociatedTrkId;
public int _AssociatedTrkId = -1;

public Line3D get_paddleLine() {
return _paddleLine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ public boolean processDataEvent(DataEvent event) {
trkRead.fetch_Trks(event);
List<Line3d> trkLines = trkRead.get_TrkLines();
double[] paths = trkRead.get_Paths();

int[] ids = trkRead.getTrkId();
List<Hit> hits = new ArrayList<Hit>(); // all hits
List<Cluster> clusters = new ArrayList<Cluster>(); // all clusters
// read in the hits for CTOF
HitReader hitRead = new HitReader();
hitRead.fetch_Hits(event, geometry, trkLines, paths,
hitRead.fetch_Hits(event, geometry, trkLines, paths, ids,
this.getConstantsManager().getConstants(newRun, "/calibration/ctof/attenuation"),
this.getConstantsManager().getConstants(newRun, "/calibration/ctof/effective_velocity"),
this.getConstantsManager().getConstants(newRun, "/calibration/ctof/time_offsets"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ public boolean processDataEvent(DataEvent event) {
trkRead.fetch_Trks(event);
List<Line3d> trkLines = trkRead.get_TrkLines();
double[] paths = trkRead.get_Paths();

int[] ids = trkRead.getTrkId();
List<Hit> hits = new ArrayList<Hit>(); // all hits
List<Cluster> clusters = new ArrayList<Cluster>(); // all clusters
// read in the hits for FTOF
HitReader hitRead = new HitReader();
hitRead.fetch_Hits(event, geometry, trkLines, paths,
hitRead.fetch_Hits(event, geometry, trkLines, paths, ids,
this.getConstantsManager().getConstants(newRun, "/calibration/ftof/attenuation"),
this.getConstantsManager().getConstants(newRun, "/calibration/ftof/effective_velocity"),
this.getConstantsManager().getConstants(newRun, "/calibration/ftof/time_offsets"),
Expand Down

0 comments on commit d5e8f9b

Please sign in to comment.