Skip to content

Commit 26a9d53

Browse files
N-Plxtongtongcao
authored andcommitted
feat: add a flag to be read from yaml to choose if the start time is … (#848)
1 parent 8eb48de commit 26a9d53

File tree

3 files changed

+24
-14
lines changed

3 files changed

+24
-14
lines changed

reconstruction/alert/src/main/java/org/jlab/rec/constants/CalibrationConstantsLoader.java renamed to reconstruction/alert/src/main/java/org/jlab/rec/alert/constants/CalibrationConstantsLoader.java

File renamed without changes.

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
@@ -63,7 +63,7 @@ public void setWedgeHits(ArrayList<ATOFHit> wedge_hits) {
6363
* @param atof the {@link Detector} representing the atof geometry to match
6464
* the sector/layer/component to x/y/z.
6565
*/
66-
public void findHits(DataEvent event, Detector atof) {
66+
public void findHits(DataEvent event, Detector atof, float startTime) {
6767
//For each event a list of bar hits and a list of wedge hits are filled
6868
this.barHits.clear();
6969
this.wedgeHits.clear();
@@ -72,7 +72,6 @@ public void findHits(DataEvent event, Detector atof) {
7272
//Check that the event start time is defined are done in the engine
7373
//if (event.hasBank("REC::Event") &&
7474
// event.getBank("REC::Event").getFloat("startTime", 0)!=-1000)
75-
float startTime = event.getBank("REC::Event").getFloat("startTime", 0);
7675

7776
int nt = bank.rows(); // number of hits
7877
//Hits in the bar downstream and upstream will be matched

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

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package org.jlab.service.atof;
22

33
import java.util.ArrayList;
4-
import java.util.Arrays;
54
import java.util.HashMap;
65
import java.util.Map;
6+
import java.util.logging.Logger;
77

88
import org.jlab.clas.reco.ReconstructionEngine;
99
import org.jlab.io.base.DataBank;
@@ -38,6 +38,8 @@ public ATOFEngine() {
3838

3939
private Detector ATOF;
4040
private double b; //Magnetic field
41+
private boolean useStartTime = true;
42+
static final Logger LOGGER = Logger.getLogger(ATOFEngine.class.getName());
4143

4244
public void setB(double B) {
4345
this.b = B;
@@ -56,15 +58,20 @@ public Detector getATOF() {
5658

5759
@Override
5860
public boolean processDataEvent(DataEvent event) {
59-
6061
if (!event.hasBank("RUN::config")) {
6162
return true;
6263
}
63-
64-
//This assumes the FD reconstruction produced an event with good startTime
65-
//All start time handling could be moved as an EB-type step later
66-
if (!event.hasBank("REC::Event") || event.getBank("REC::Event").getFloat("startTime", 0)==-1000) {
67-
return true;
64+
float startTime = 0;
65+
if(useStartTime)
66+
{
67+
//This assumes the FD reconstruction produced an event with good startTime
68+
//All start time handling could be moved as an EB-type step later
69+
if (!event.hasBank("REC::Event")) {
70+
LOGGER.severe("REC::Event bank could not be read in ATOF engine while requestign starttime");
71+
return true;
72+
}
73+
//Deal with FT TODO : if(event.getBank("REC::Event").getFloat("startTime", 0)==-1000)
74+
else startTime = event.getBank("REC::Event").getFloat("startTime", 0);
6875
}
6976

7077
DataBank bank = event.getBank("RUN::config");
@@ -98,7 +105,7 @@ public boolean processDataEvent(DataEvent event) {
98105
// Why do we have to "find" hits?
99106
//Hit finder init
100107
HitFinder hitfinder = new HitFinder();
101-
hitfinder.findHits(event, ATOF);
108+
hitfinder.findHits(event, ATOF, startTime);
102109

103110
ArrayList<ATOFHit> WedgeHits = hitfinder.getWedgeHits();
104111
ArrayList<BarHit> BarHits = hitfinder.getBarHits();
@@ -149,15 +156,19 @@ public boolean init() {
149156
}
150157

151158
requireConstants(tableMap);
152-
153159
this.getConstantsManager().setVariation("default");
154-
155160
this.registerOutputBank("ATOF::hits", "ATOF::clusters");
156-
161+
String useStartTimeString = "UseStartTime";
162+
if(this.getEngineConfigString(useStartTimeString)!=null) {
163+
if ("true".equals(this.getEngineConfigString(useStartTimeString)))
164+
this.useStartTime = true;
165+
else if ("false".equals(this.getEngineConfigString(useStartTimeString)))
166+
this.useStartTime = false;
167+
else {LOGGER.severe("Invalid option parsed for ATOF UseStartTime"); return false;}
168+
}
157169
return true;
158170
}
159171

160172
public static void main(String arg[]) {
161-
162173
}
163174
}

0 commit comments

Comments
 (0)