Skip to content

Commit f9027cf

Browse files
authored
Updating how time offsets are applied, dealing with different start times (#1074)
1 parent 2e24914 commit f9027cf

5 files changed

Lines changed: 38 additions & 52 deletions

File tree

reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/ATOFHit.java

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,11 @@ public class ATOFHit {
2121

2222
private int sector, layer, component, order;
2323
private int tdc, tot;
24-
private float startTime;
24+
private Float startTime;
2525
private double time, energy, x, y, z;
2626
private String type;
2727
private boolean isInACluster;
2828
private int associatedClusterIndex;
29-
private double meanTimeAligned;
3029
int idTDC;
3130

3231

@@ -82,13 +81,9 @@ public double getTime() {
8281
return time;
8382
}
8483

85-
public double getStartTime() {
84+
public Float getStartTime() {
8685
return this.startTime;
8786
}
88-
89-
public double getMeanTimeAligned(){
90-
return this.meanTimeAligned;
91-
}
9287

9388
public void setTime(double time) {
9489
this.time = time;
@@ -195,27 +190,18 @@ public final String makeType() {
195190
* unsupported.
196191
*/
197192
public final int convertTdcToTime() {
198-
199193
//Converting tdc to ns, event start time correction
200-
this.time = Parameters.TDC2TIME*this.tdc - this.startTime;
194+
this.time = Parameters.TDC2TIME*this.tdc;
195+
//If the startTime has been defined, remove it
196+
if(this.startTime!= null) this.time -= this.startTime;
201197

202198
//TODO: When table structure evolves, pay attention to order.
203199
//Key for the current channel
204200
int key = this.sector*10000 + this.layer*1000 + this.component*10 + 0;//this.order;
205-
//Key for the reference channel over which all the others sharing the same z are aligned
206-
int referenceModuleKey = this.component*10;
207201

208202
//Time offsets
209203
double[] timeOffsets = CalibrationConstantsLoader.ATOF_TIME_OFFSETS.get(key);
210-
double[] timeOffsetsRef = CalibrationConstantsLoader.ATOF_TIME_OFFSETS.get(referenceModuleKey);
211-
this.meanTimeAligned = timeOffsetsRef[0];
212-
//The names below correspond to the CCDB entries
213-
//They will most probably evolve
214-
//For now let's say t0 is used to store the bar-to-bar and wedge-to-wedge alignments
215204
double t0 = timeOffsets[0];
216-
double tChannelToChannelPhiAlignment = (t0 - this.meanTimeAligned);
217-
if(this.type=="bar up" || this.type=="bar down") //bar alignment is done with the sum of the two times
218-
tChannelToChannelPhiAlignment=tChannelToChannelPhiAlignment/2.;
219205

220206
//tud is used to store the bar up - bar down alignment
221207
double tud = timeOffsets[1];
@@ -237,8 +223,6 @@ public final int convertTdcToTime() {
237223
double dtw3 = timeWalks[7];
238224
double chi2ndf = timeWalks[8];*/
239225

240-
//Veff corrections TO BE IMPLEMENTED
241-
242226
double veff, distance_to_sipm, timeOffset;
243227
if (null == this.type) {
244228
LOGGER.finest("Null hit type, cannot convert tdc to time.");
@@ -249,19 +233,20 @@ public final int convertTdcToTime() {
249233
veff = Parameters.VEFF;
250234
//Wedge hits are placed at the center of wedges and sipm at their top
251235
distance_to_sipm = Parameters.WEDGE_THICKNESS / 2.;
252-
timeOffset = - tChannelToChannelPhiAlignment;
236+
timeOffset = - t0;
253237
}
254238
case "bar up" -> {
255239
veff = Parameters.VEFF;
256240
//The distance will be computed at barhit level when z information is available
257241
distance_to_sipm = 0;
258-
timeOffset = - tud/2. - tChannelToChannelPhiAlignment;
242+
//t0 for bars is the sum of up+down channels->need 1/2
243+
timeOffset = - tud/2. - t0/2;
259244
}
260245
case "bar down" -> {
261246
veff = Parameters.VEFF;
262247
//The distance will be computed at barhit level when z information is available
263248
distance_to_sipm = 0;
264-
timeOffset = + tud/2. - tChannelToChannelPhiAlignment;
249+
timeOffset = + tud/2. - t0/2;
265250
}
266251
case "bar" -> {
267252
LOGGER.finest("Bar hit type, cannot convert tdc to time.");
@@ -418,7 +403,7 @@ public double getPhi() {
418403
* @param atof Detector object representing the atof, used to calculate
419404
* spatial coordinates.
420405
*/
421-
public ATOFHit(int sector, int layer, int component, int order, int tdc, int tot, float startTime, Detector atof) {
406+
public ATOFHit(int sector, int layer, int component, int order, int tdc, int tot, Float startTime, Detector atof) {
422407
this.sector = sector;
423408
this.layer = layer;
424409
this.component = component;

reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/BarHit.java

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.jlab.rec.atof.hit;
22

3+
import org.jlab.io.base.DataEvent;
4+
import org.jlab.io.hipo.HipoDataSource;
35
import org.jlab.rec.atof.constants.Parameters;
46
import org.jlab.rec.alert.constants.CalibrationConstantsLoader;
57

@@ -30,15 +32,19 @@ public ATOFHit getHitUp() {
3032
*
3133
*/
3234
public boolean isInTime() {
35+
//Undefined start time is when useStartTime option is false in the yaml
36+
//for example for usage with simulations
37+
//-> we keep all the hits
38+
if(this.hitUp.getStartTime() == null) return true;
3339
double timeShift = 0;
40+
//TO DO: make this more robust
3441
//For FT electron for which the startTime is set at -1000
3542
//We need to shift where the cut is applied
43+
//2180 = 2*1090 = 1000+90 for FD start time around 90ns
44+
//if the data start time is not around 90, this will be a problem
3645
if(this.hitUp.getStartTime()<0) timeShift = 2180;
37-
if(Math.abs(
38-
this.hitUp.getTime()+this.hitDown.getTime()
39-
-timeShift
40-
-this.hitUp.getMeanTimeAligned())
41-
<40)
46+
if(Math.abs(this.hitUp.getTime()+this.hitDown.getTime()
47+
-timeShift)<40)
4248
return true;
4349
return false;
4450
}
@@ -70,17 +76,19 @@ public final void computeZ() {
7076
*
7177
*/
7278
public final void computeTime() {
73-
//We pick the most energetic signal as the timing signal
74-
double time_at_sipm, distance_to_sipm;
75-
if(this.hitDown.getEnergy() > this.hitUp.getEnergy()) {
76-
time_at_sipm = this.hitDown.getTime();
77-
distance_to_sipm = Parameters.LENGTH_ATOF/2. - this.getZ();
78-
}
79-
else {
80-
time_at_sipm = this.hitUp.getTime();
81-
distance_to_sipm = Parameters.LENGTH_ATOF/2. + this.getZ();
82-
}
83-
this.setTime(time_at_sipm - distance_to_sipm/this.vEff);
79+
//Select the most energetic hit as the timing reference
80+
final boolean useDownstream = hitDown.getEnergy() > hitUp.getEnergy();
81+
final double sipmTime = useDownstream ? hitDown.getTime() : hitUp.getTime();
82+
//veff correction
83+
//t0 has already been removed.
84+
//distance to SiPM is L/2+-z, part of it is absorbed into the t0 as:
85+
//t0 = 2*offset+L/veff
86+
//t_hit = t_u/d - 2*offset/2 -/+ tud/2 - 1/veff(L/2 -/+ z)
87+
//t_hit = t_u/d - (t0)/2 -/+ tud/2 +/- z/veff
88+
//Only the z part remains
89+
final double zDirection = useDownstream ? +this.getZ() : -this.getZ();
90+
final double correctedTime = sipmTime + zDirection / vEff;
91+
this.setTime(correctedTime);
8492
}
8593

8694
/**

reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/HitFinder.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import org.jlab.geom.base.Detector;
66
import org.jlab.io.base.DataBank;
77
import org.jlab.io.base.DataEvent;
8-
import org.jlab.rec.alert.constants.CalibrationConstantsLoader;
98

109
/**
1110
* The {@code HitFinder} class finds hits in the atof.
@@ -64,7 +63,7 @@ public void setWedgeHits(ArrayList<ATOFHit> wedge_hits) {
6463
* @param atof the {@link Detector} representing the atof geometry to match
6564
* the sector/layer/component to x/y/z.
6665
*/
67-
public void findHits(DataEvent event, Detector atof, float startTime) {
66+
public void findHits(DataEvent event, Detector atof, Float startTime) {
6867
//For each event a list of bar hits and a list of wedge hits are filled
6968
this.barHits.clear();
7069
this.wedgeHits.clear();

reconstruction/alert/src/main/java/org/jlab/service/alert/ALERTEngine.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public boolean processDataEvent(DataEvent event) {
175175
int layer_pred = (int) pred[1];
176176
int wedge_pred = (int) pred[2];
177177

178-
ATOFHit hit_pred = new ATOFHit(sector_pred, layer_pred, wedge_pred, 0, 0, 0, 0, ATOF);
178+
ATOFHit hit_pred = new ATOFHit(sector_pred, layer_pred, wedge_pred, 0, 0, 0, 0f, ATOF);
179179
double pred_x = hit_pred.getX();
180180
double pred_y = hit_pred.getY();
181181
double pred_z = hit_pred.getZ();
@@ -193,7 +193,7 @@ public boolean processDataEvent(DataEvent event) {
193193
int sector = bank.getInt("sector", k);
194194
int layer = bank.getInt("layer", k);
195195

196-
ATOFHit hit = new ATOFHit(sector, layer, component, 0, 0, 0, 0, ATOF);
196+
ATOFHit hit = new ATOFHit(sector, layer, component, 0, 0, 0, 0f, ATOF);
197197

198198
double dx = pred_x - hit.getX();
199199
double dy = pred_y - hit.getY();
@@ -212,9 +212,6 @@ public boolean processDataEvent(DataEvent event) {
212212
} catch (Exception ex) {
213213
System.out.println("Exception in ALERTEngine processDataEvent: " + ex); // TODO: proper logging
214214
}
215-
216-
217-
218215
}
219216
return true;
220217
}

reconstruction/alert/src/main/java/org/jlab/service/atof/ATOFEngine.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public boolean processDataEvent(DataEvent event) {
6060
if (!event.hasBank("RUN::config")) {
6161
return true;
6262
}
63-
float startTime = 0;
63+
Float startTime = null;
6464
if(useStartTime)
6565
{
6666
//This assumes the FD reconstruction produced an event with good startTime
@@ -101,14 +101,11 @@ public boolean processDataEvent(DataEvent event) {
101101
//projector.projectTracks(event);
102102
//rbc.appendMatchBanks(event, projector.getProjections());
103103

104-
// Why do we have to "find" hits?
105104
//Hit finder init
106105
HitFinder hitfinder = new HitFinder();
107106
hitfinder.findHits(event, ATOF, startTime);
108-
109107
ArrayList<ATOFHit> WedgeHits = hitfinder.getWedgeHits();
110108
ArrayList<BarHit> BarHits = hitfinder.getBarHits();
111-
112109
//Exit if hit lists are empty
113110
if (WedgeHits.isEmpty() && BarHits.isEmpty()) {
114111
// System.out.println("No hits : ");

0 commit comments

Comments
 (0)