From 880b9f0e27a4f86f5fee716cd28f9df629388790 Mon Sep 17 00:00:00 2001 From: N-Plx Date: Fri, 12 Dec 2025 18:44:46 -0600 Subject: [PATCH 1/2] feat: adding cut on bar time sum for events for which the start time is defined --- .../java/org/jlab/rec/atof/hit/ATOFHit.java | 4 ++++ .../java/org/jlab/rec/atof/hit/HitFinder.java | 17 ++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/ATOFHit.java b/reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/ATOFHit.java index 895faeb015..43e97be033 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/ATOFHit.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/ATOFHit.java @@ -79,6 +79,10 @@ public void setTot(int tot) { public double getTime() { return time; } + + public double getStartTime() { + return this.startTime; + } public void setTime(double time) { this.time = time; diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/HitFinder.java b/reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/HitFinder.java index 20e1864234..c0b2a0830f 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/HitFinder.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/HitFinder.java @@ -5,6 +5,7 @@ import org.jlab.geom.base.Detector; import org.jlab.io.base.DataBank; import org.jlab.io.base.DataEvent; +import org.jlab.rec.alert.constants.CalibrationConstantsLoader; /** * The {@code HitFinder} class finds hits in the atof. @@ -124,12 +125,18 @@ public void findHits(DataEvent event, Detector atof, float startTime) { //Matching the hits: if same module and different order, they make up a bar hit if (this_hit_up.matchBar(this_hit_down)) { //Bar hits are matched to ahdc tracks and listed - if (countMatches > 0) { - //If the up hit was already involved in a match, do not make an additionnal match - //Chosing to ignore double matches for now because it happened for <1% of events in cosmic runs - continue; - } BarHit this_bar_hit = new BarHit(this_hit_down, this_hit_up); + int key = this_hit_up.getSector()*10000 + this_hit_up.getLayer()*1000 + this_hit_up.getComponent()*10;//Order does not matter (t0 computed from time sum) + double[] timeOffsets = CalibrationConstantsLoader.ATOF_TIME_OFFSETS.get(key); + double meanTime = timeOffsets[0]; + double sigmaTime = Math.abs(timeOffsets[3]); + //Cuts for bar time sum are derived correcting with FD electrons + //So we need to move the cut to be centered at the same startTime for FT electron events + //For now, we will just keep all FT electron events even if out of time + if(this_hit_up.getStartTime()!=-1000 && this_hit_up.getStartTime()!=0){ + if(2*this_bar_hit.getTime() > meanTime + 5*sigmaTime) continue; + if(2*this_bar_hit.getTime() < meanTime - 3*sigmaTime) continue; + } this.barHits.add(this_bar_hit); countMatches++; } From 448975afbfd1c6dcde1b630853a142778cc7f07d Mon Sep 17 00:00:00 2001 From: N-Plx Date: Mon, 15 Dec 2025 12:37:42 +0100 Subject: [PATCH 2/2] feat: changing cut to fixed 40ns around bar time sum mean --- .../java/org/jlab/rec/atof/hit/ATOFHit.java | 10 +++++++-- .../java/org/jlab/rec/atof/hit/BarHit.java | 21 +++++++++++++++++++ .../java/org/jlab/rec/atof/hit/HitFinder.java | 13 ++---------- 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/ATOFHit.java b/reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/ATOFHit.java index 43e97be033..95a4d52584 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/ATOFHit.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/ATOFHit.java @@ -26,7 +26,9 @@ public class ATOFHit { private String type; private boolean isInACluster; private int associatedClusterIndex; + private double meanTimeAligned; int idTDC; + public int getSector() { return sector; @@ -83,6 +85,10 @@ public double getTime() { public double getStartTime() { return this.startTime; } + + public double getMeanTimeAligned(){ + return this.meanTimeAligned; + } public void setTime(double time) { this.time = time; @@ -202,12 +208,12 @@ public final int convertTdcToTime() { //Time offsets double[] timeOffsets = CalibrationConstantsLoader.ATOF_TIME_OFFSETS.get(key); double[] timeOffsetsRef = CalibrationConstantsLoader.ATOF_TIME_OFFSETS.get(referenceModuleKey); - + this.meanTimeAligned = timeOffsetsRef[0]; //The names below correspond to the CCDB entries //They will most probably evolve //For now let's say t0 is used to store the bar-to-bar and wedge-to-wedge alignments double t0 = timeOffsets[0]; - double tChannelToChannelPhiAlignment = (t0 - timeOffsetsRef[0]); + double tChannelToChannelPhiAlignment = (t0 - this.meanTimeAligned); if(this.type=="bar up" || this.type=="bar down") //bar alignment is done with the sum of the two times tChannelToChannelPhiAlignment=tChannelToChannelPhiAlignment/2.; diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/BarHit.java b/reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/BarHit.java index fd46440c27..39bc582078 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/BarHit.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/BarHit.java @@ -21,6 +21,27 @@ public class BarHit extends ATOFHit { public ATOFHit getHitUp() { return hitUp; } + + /** + * Computes bar time sum and check if it is around + * the value the hits were aligned to. For now, + * 40ns cut. When calibrations are final, it should + * be refined to reflect the resolution. + * + */ + public boolean isInTime() { + double timeShift = 0; + //For FT electron for which the startTime is set at -1000 + //We need to shift where the cut is applied + if(this.hitUp.getStartTime()<0) timeShift = 2180; + if(Math.abs( + this.hitUp.getTime()+this.hitDown.getTime() + -timeShift + -this.hitUp.getMeanTimeAligned()) + <40) + return true; + return false; + } public void setHitUp(ATOFHit hit_up) { this.hitUp = hit_up; diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/HitFinder.java b/reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/HitFinder.java index c0b2a0830f..a4db3aa43e 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/HitFinder.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/HitFinder.java @@ -126,17 +126,8 @@ public void findHits(DataEvent event, Detector atof, float startTime) { if (this_hit_up.matchBar(this_hit_down)) { //Bar hits are matched to ahdc tracks and listed BarHit this_bar_hit = new BarHit(this_hit_down, this_hit_up); - int key = this_hit_up.getSector()*10000 + this_hit_up.getLayer()*1000 + this_hit_up.getComponent()*10;//Order does not matter (t0 computed from time sum) - double[] timeOffsets = CalibrationConstantsLoader.ATOF_TIME_OFFSETS.get(key); - double meanTime = timeOffsets[0]; - double sigmaTime = Math.abs(timeOffsets[3]); - //Cuts for bar time sum are derived correcting with FD electrons - //So we need to move the cut to be centered at the same startTime for FT electron events - //For now, we will just keep all FT electron events even if out of time - if(this_hit_up.getStartTime()!=-1000 && this_hit_up.getStartTime()!=0){ - if(2*this_bar_hit.getTime() > meanTime + 5*sigmaTime) continue; - if(2*this_bar_hit.getTime() < meanTime - 3*sigmaTime) continue; - } + //Only add bar hits for which the time sum is in time + if(!this_bar_hit.isInTime()) continue; this.barHits.add(this_bar_hit); countMatches++; }