From d5e8f9b6202a4791df55c7760727f8269485a2b3 Mon Sep 17 00:00:00 2001 From: Veronique Ziegler Date: Fri, 8 Dec 2017 14:45:13 -0500 Subject: [PATCH] Correct associated track IDs for matched hits --- .../org/jlab/rec/tof/banks/ctof/HitReader.java | 7 ++++--- .../org/jlab/rec/tof/banks/ctof/TrackReader.java | 14 ++++++++++++-- .../org/jlab/rec/tof/banks/ftof/HitReader.java | 7 ++++--- .../org/jlab/rec/tof/banks/ftof/TrackReader.java | 9 +++++++++ .../main/java/org/jlab/rec/tof/hit/ctof/Hit.java | 3 +-- .../java/org/jlab/service/ctof/CTOFEngine.java | 4 ++-- .../java/org/jlab/service/ftof/FTOFEngine.java | 4 ++-- 7 files changed, 34 insertions(+), 14 deletions(-) diff --git a/reconstruction/tof/src/main/java/org/jlab/rec/tof/banks/ctof/HitReader.java b/reconstruction/tof/src/main/java/org/jlab/rec/tof/banks/ctof/HitReader.java index 6bfb1780a1..d775cd53a2 100644 --- a/reconstruction/tof/src/main/java/org/jlab/rec/tof/banks/ctof/HitReader.java +++ b/reconstruction/tof/src/main/java/org/jlab/rec/tof/banks/ctof/HitReader.java @@ -45,7 +45,7 @@ public void set_CTOFHits(List _Hits) { * @param geometry the CTOF geometry from package */ public void fetch_Hits(DataEvent event, CTOFGeant4Factory geometry, - List trks, double[] paths, + List trks, double[] paths, int[] ids, IndexedTable constants0, IndexedTable constants1, IndexedTable constants2, @@ -115,7 +115,7 @@ public void fetch_Hits(DataEvent event, CTOFGeant4Factory geometry, // add this hit hits.add(hit); } - List updated_hits = matchHitsToCVTTrk(hits, geometry, trks, paths); + List updated_hits = matchHitsToCVTTrk(hits, geometry, trks, paths, ids); ArrayList> DetHits = new ArrayList>(); for (int j = 0; j < 3; j++) { @@ -194,7 +194,7 @@ private int passADC(int aDC) { return pass; } - private List matchHitsToCVTTrk(List CTOFhits, CTOFGeant4Factory ctofDetector, List trks, double[] paths) { + private List matchHitsToCVTTrk(List CTOFhits, CTOFGeant4Factory ctofDetector, List trks, double[] paths, int[] ids) { if (trks == null || trks.size() == 0) { return CTOFhits; // no hits were matched with DC tracks } @@ -249,6 +249,7 @@ private List matchHitsToCVTTrk(List CTOFhits, CTOFGeant4Factory ctofDe double barOrigToTrkPos = origPaddleLine.distance(trkPosinMidlBar); // local y: hit.set_yTrk(barOrigToTrkPos - Lov2); + hit._AssociatedTrkId = ids[i]; //--------------------------------------- hitList.add(hit); } diff --git a/reconstruction/tof/src/main/java/org/jlab/rec/tof/banks/ctof/TrackReader.java b/reconstruction/tof/src/main/java/org/jlab/rec/tof/banks/ctof/TrackReader.java index 2d08f6843a..39b9a885a0 100644 --- a/reconstruction/tof/src/main/java/org/jlab/rec/tof/banks/ctof/TrackReader.java +++ b/reconstruction/tof/src/main/java/org/jlab/rec/tof/banks/ctof/TrackReader.java @@ -22,7 +22,16 @@ public TrackReader() { private List _TrkLines; private double[] _Paths; + private int[] _TrkId; + public int[] getTrkId() { + return _TrkId; + } + + public void setTrkId(int[] _TrkId) { + this._TrkId = _TrkId; + } + public List get_TrkLines() { return _TrkLines; } @@ -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 @@ -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); @@ -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); } diff --git a/reconstruction/tof/src/main/java/org/jlab/rec/tof/banks/ftof/HitReader.java b/reconstruction/tof/src/main/java/org/jlab/rec/tof/banks/ftof/HitReader.java index 417df16d21..a45926bd3d 100644 --- a/reconstruction/tof/src/main/java/org/jlab/rec/tof/banks/ftof/HitReader.java +++ b/reconstruction/tof/src/main/java/org/jlab/rec/tof/banks/ftof/HitReader.java @@ -62,7 +62,7 @@ public void set_FTOF2Hits(List _FTOF2Hits) { * @param geometry the FTOF geometry from package */ public void fetch_Hits(DataEvent event, FTOFGeant4Factory geometry, - List trks, double[] paths, + List trks, double[] paths, int[] ids, IndexedTable constants0, IndexedTable constants1, IndexedTable constants2, @@ -157,7 +157,7 @@ public void fetch_Hits(DataEvent event, FTOFGeant4Factory geometry, // add this hit hits.add(hit); } - List updated_hits = matchHitsToDCTrk(hits, geometry, trks, paths); + List updated_hits = matchHitsToDCTrk(hits, geometry, trks, paths, ids); ArrayList> DetHits = new ArrayList>(); for (int j = 0; j < 3; j++) { @@ -301,7 +301,7 @@ private int passADC(int aDC) { } private List matchHitsToDCTrk(List FTOFhits, - FTOFGeant4Factory ftofDetector, List trks, double[] paths) { + FTOFGeant4Factory ftofDetector, List trks, double[] paths, int[] ids) { if (trks == null || trks.size() == 0) { return FTOFhits; // no hits were matched with DC tracks } @@ -378,6 +378,7 @@ private List matchHitsToDCTrk(List FTOFhits, .distance(trkPosinMidlBar); // local y: hit.set_yTrk(barOrigToTrkPos - Lov2); + hit._AssociatedTrkId=ids[i]; // --------------------------------------- hitList.add(hit); // add this hit to the output list diff --git a/reconstruction/tof/src/main/java/org/jlab/rec/tof/banks/ftof/TrackReader.java b/reconstruction/tof/src/main/java/org/jlab/rec/tof/banks/ftof/TrackReader.java index ebd6207915..b11abdf48e 100644 --- a/reconstruction/tof/src/main/java/org/jlab/rec/tof/banks/ftof/TrackReader.java +++ b/reconstruction/tof/src/main/java/org/jlab/rec/tof/banks/ftof/TrackReader.java @@ -22,7 +22,15 @@ public TrackReader() { private List _TrkLines; private double[] _Paths; + private int[] _TrkId; + public int[] getTrkId() { + return _TrkId; + } + + public void setTrkId(int[] _TrkId) { + this._TrkId = _TrkId; + } public List get_TrkLines() { return _TrkLines; } @@ -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); } } diff --git a/reconstruction/tof/src/main/java/org/jlab/rec/tof/hit/ctof/Hit.java b/reconstruction/tof/src/main/java/org/jlab/rec/tof/hit/ctof/Hit.java index 50b299fb05..a23a43f0f6 100644 --- a/reconstruction/tof/src/main/java/org/jlab/rec/tof/hit/ctof/Hit.java +++ b/reconstruction/tof/src/main/java/org/jlab/rec/tof/hit/ctof/Hit.java @@ -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; @@ -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; diff --git a/reconstruction/tof/src/main/java/org/jlab/service/ctof/CTOFEngine.java b/reconstruction/tof/src/main/java/org/jlab/service/ctof/CTOFEngine.java index a21d50bbc6..fbe5c0254d 100644 --- a/reconstruction/tof/src/main/java/org/jlab/service/ctof/CTOFEngine.java +++ b/reconstruction/tof/src/main/java/org/jlab/service/ctof/CTOFEngine.java @@ -90,12 +90,12 @@ public boolean processDataEvent(DataEvent event) { trkRead.fetch_Trks(event); List trkLines = trkRead.get_TrkLines(); double[] paths = trkRead.get_Paths(); - + int[] ids = trkRead.getTrkId(); List hits = new ArrayList(); // all hits List clusters = new ArrayList(); // 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"), diff --git a/reconstruction/tof/src/main/java/org/jlab/service/ftof/FTOFEngine.java b/reconstruction/tof/src/main/java/org/jlab/service/ftof/FTOFEngine.java index ddc8b573e3..32e10ccb3f 100644 --- a/reconstruction/tof/src/main/java/org/jlab/service/ftof/FTOFEngine.java +++ b/reconstruction/tof/src/main/java/org/jlab/service/ftof/FTOFEngine.java @@ -121,12 +121,12 @@ public boolean processDataEvent(DataEvent event) { trkRead.fetch_Trks(event); List trkLines = trkRead.get_TrkLines(); double[] paths = trkRead.get_Paths(); - + int[] ids = trkRead.getTrkId(); List hits = new ArrayList(); // all hits List clusters = new ArrayList(); // 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"),