Skip to content

Commit 9c2042c

Browse files
committed
Removed old T2D database calls and added some checks on NaN and null parameters
1 parent fab8d7b commit 9c2042c

3 files changed

Lines changed: 34 additions & 60 deletions

File tree

reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Hit/HitReader.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ public HitReader(DataEvent event, AlertDCDetector detector, boolean simulation)
2222
public double T2Dfunction(int key, double time){
2323
double[] time2distance = CalibrationConstantsLoader.AHDC_TIME_TO_DISTANCE_WIRE.get(key);
2424
if (time2distance == null){
25-
throw new IllegalStateException("Missing CCDB /calibration/alert/ahdc/time_to_distance for key=" + key + " (check run/variation + key mapping)");
25+
throw new IllegalStateException("Missing CCDB /calibration/alert/ahdc/time_to_distance_wire for key=" + key + " (check run/variation + key mapping)");
26+
}
27+
28+
if (time2distance[7] == 0.0 || time2distance[9] == 0.0){
29+
throw new IllegalStateException("Incorrect table values in CCDB /calibration/alert/ahdc/time_to_distance_wire. t1_width ("+ time2distance[7] +") or t2_width ("+time2distance[9]+") for key: " + key + " must not equal zero. Please check database table issues.");
2630
}
2731

2832
// T2D function consists of three 1st order polynomials (p1, p2, p3) and two transition functions (t1, t2).

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

Lines changed: 29 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ public CalibrationConstantsLoader() {
2525
// Maps for constants from database
2626
// AHDC
2727
public static Map<Integer, double[]> AHDC_TIME_OFFSETS = new HashMap<>(); ///< {t0,dt0,extra1,extra2,chi2ndf}
28-
public static Map<Integer, double[]> AHDC_TIME_TO_DISTANCE = new HashMap<>(); ///< {p0..p5, dp0..dp5, chi2ndf}
2928
public static Map<Integer, double[]> AHDC_TIME_TO_DISTANCE_WIRE = new HashMap<>(); ///< T2D function for every wire
3029
public static Map<Integer, double[]> AHDC_RAW_HIT_CUTS = new HashMap<>(); ///< {t_min,t_max,tot_min,tot_max,adc_min,adc_max,ped_min,ped_max}
3130

@@ -46,7 +45,6 @@ public static synchronized void Load(int runno, ConstantsManager manager) {
4645
if (CSTLOADED) return;
4746

4847
IndexedTable ahdc_timeOffsets = manager.getConstants(runno, "/calibration/alert/ahdc/time_offsets");
49-
IndexedTable ahdc_time2distance = manager.getConstants(runno, "/calibration/alert/ahdc/time_to_distance");
5048
IndexedTable ahdc_time2distanceWire = manager.getConstants(runno, "/calibration/alert/ahdc/time_to_distance_wire");
5149
IndexedTable ahdc_rawHitCuts = manager.getConstants(runno, "/calibration/alert/ahdc/raw_hit_cuts");
5250

@@ -78,65 +76,38 @@ public static synchronized void Load(int runno, ConstantsManager manager) {
7876
double params[] = { t0, dt0, extra1, extra2, chi2ndf };
7977
AHDC_TIME_OFFSETS.put(Integer.valueOf(key), params);
8078
}
81-
82-
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
83-
// AHDC time to distance
84-
// Caution, this table has only one row
85-
// the corresponding identifiers are (sector, layer, component) == (1,1,1)
86-
// but it applies for all AHDC wires !
87-
for (int i = 0; i < ahdc_time2distance.getRowCount(); i++) {
88-
int sector = Integer.parseInt((String) ahdc_time2distance.getValueAt(i, 0));
89-
int layer = Integer.parseInt((String) ahdc_time2distance.getValueAt(i, 1));
90-
int component = Integer.parseInt((String) ahdc_time2distance.getValueAt(i, 2));
91-
92-
double p0 = ahdc_time2distance.getDoubleValue("p0", sector, layer, component);
93-
double p1 = ahdc_time2distance.getDoubleValue("p1", sector, layer, component);
94-
double p2 = ahdc_time2distance.getDoubleValue("p2", sector, layer, component);
95-
double p3 = ahdc_time2distance.getDoubleValue("p3", sector, layer, component);
96-
double p4 = ahdc_time2distance.getDoubleValue("p4", sector, layer, component);
97-
double p5 = ahdc_time2distance.getDoubleValue("p5", sector, layer, component);
98-
double dp0 = ahdc_time2distance.getDoubleValue("dp0", sector, layer, component);
99-
double dp1 = ahdc_time2distance.getDoubleValue("dp1", sector, layer, component);
100-
double dp2 = ahdc_time2distance.getDoubleValue("dp2", sector, layer, component);
101-
double dp3 = ahdc_time2distance.getDoubleValue("dp3", sector, layer, component);
102-
double dp4 = ahdc_time2distance.getDoubleValue("dp4", sector, layer, component);
103-
double dp5 = ahdc_time2distance.getDoubleValue("dp5", sector, layer, component);
104-
double chi2ndf = ahdc_time2distance.getDoubleValue("chi2ndf", sector, layer, component);
105-
106-
int key = sector * 10000 + layer * 100 + component;
107-
double params[] = { p0, p1, p2, p3, p4, p5, dp0, dp1, dp2, dp3, dp4, dp5, chi2ndf };
108-
AHDC_TIME_TO_DISTANCE.put(Integer.valueOf(key), params);
109-
}
11079

11180
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
11281
// AHDC time to distance per wire
113-
// See implimentation and functional form in reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Hit/HitReader.java
114-
for (int i = 0; i < ahdc_time2distanceWire.getRowCount(); i++) {
115-
int sector = Integer.parseInt((String) ahdc_time2distanceWire.getValueAt(i, 0));
116-
int layer = Integer.parseInt((String) ahdc_time2distanceWire.getValueAt(i, 1));
117-
int component = Integer.parseInt((String) ahdc_time2distanceWire.getValueAt(i, 2));
118-
119-
double p1_int = ahdc_time2distanceWire.getDoubleValue("p1_int", sector, layer, component);
120-
double p1_slope = ahdc_time2distanceWire.getDoubleValue("p1_slope", sector, layer, component);
121-
double p2_int = ahdc_time2distanceWire.getDoubleValue("p2_int", sector, layer, component);
122-
double p2_slope = ahdc_time2distanceWire.getDoubleValue("p2_slope", sector, layer, component);
123-
double p3_int = ahdc_time2distanceWire.getDoubleValue("p3_int", sector, layer, component);
124-
double p3_slope = ahdc_time2distanceWire.getDoubleValue("p3_slope", sector, layer, component);
125-
double t1_x0 = ahdc_time2distanceWire.getDoubleValue("t1_x0", sector, layer, component);
126-
double t1_width = ahdc_time2distanceWire.getDoubleValue("t1_width", sector, layer, component);
127-
double t2_x0 = ahdc_time2distanceWire.getDoubleValue("t2_x0", sector, layer, component);
128-
double t2_width = ahdc_time2distanceWire.getDoubleValue("t2_width", sector, layer, component);
129-
double z0 = ahdc_time2distanceWire.getDoubleValue("z0", sector, layer, component);
130-
double z1 = ahdc_time2distanceWire.getDoubleValue("z1", sector, layer, component);
131-
double z2 = ahdc_time2distanceWire.getDoubleValue("z2", sector, layer, component);
132-
double extra1 = ahdc_time2distanceWire.getDoubleValue("extra1", sector, layer, component);
133-
double extra2 = ahdc_time2distanceWire.getDoubleValue("extra2", sector, layer, component);
134-
double chi2ndf = ahdc_time2distanceWire.getDoubleValue("chi2ndf", sector, layer, component);
135-
136-
int key = sector * 10000 + layer * 100 + component;
137-
double params[] = { p1_int, p1_slope, p2_int, p2_slope, p3_int, p3_slope, t1_x0, t1_width, t2_x0, t2_width, z0, z1, z2, extra1, extra2, chi2ndf };
138-
AHDC_TIME_TO_DISTANCE_WIRE.put(Integer.valueOf(key), params);
139-
}
82+
// See implementation and functional form in reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Hit/HitReader.java
83+
if(ahdc_time2distanceWire != null){
84+
for (int i = 0; i < ahdc_time2distanceWire.getRowCount(); i++) {
85+
int sector = Integer.parseInt((String) ahdc_time2distanceWire.getValueAt(i, 0));
86+
int layer = Integer.parseInt((String) ahdc_time2distanceWire.getValueAt(i, 1));
87+
int component = Integer.parseInt((String) ahdc_time2distanceWire.getValueAt(i, 2));
88+
89+
double p1_int = ahdc_time2distanceWire.getDoubleValue("p1_int", sector, layer, component);
90+
double p1_slope = ahdc_time2distanceWire.getDoubleValue("p1_slope", sector, layer, component);
91+
double p2_int = ahdc_time2distanceWire.getDoubleValue("p2_int", sector, layer, component);
92+
double p2_slope = ahdc_time2distanceWire.getDoubleValue("p2_slope", sector, layer, component);
93+
double p3_int = ahdc_time2distanceWire.getDoubleValue("p3_int", sector, layer, component);
94+
double p3_slope = ahdc_time2distanceWire.getDoubleValue("p3_slope", sector, layer, component);
95+
double t1_x0 = ahdc_time2distanceWire.getDoubleValue("t1_x0", sector, layer, component);
96+
double t1_width = ahdc_time2distanceWire.getDoubleValue("t1_width", sector, layer, component);
97+
double t2_x0 = ahdc_time2distanceWire.getDoubleValue("t2_x0", sector, layer, component);
98+
double t2_width = ahdc_time2distanceWire.getDoubleValue("t2_width", sector, layer, component);
99+
double z0 = ahdc_time2distanceWire.getDoubleValue("z0", sector, layer, component);
100+
double z1 = ahdc_time2distanceWire.getDoubleValue("z1", sector, layer, component);
101+
double z2 = ahdc_time2distanceWire.getDoubleValue("z2", sector, layer, component);
102+
double extra1 = ahdc_time2distanceWire.getDoubleValue("extra1", sector, layer, component);
103+
double extra2 = ahdc_time2distanceWire.getDoubleValue("extra2", sector, layer, component);
104+
double chi2ndf = ahdc_time2distanceWire.getDoubleValue("chi2ndf", sector, layer, component);
105+
106+
int key = sector * 10000 + layer * 100 + component;
107+
double params[] = { p1_int, p1_slope, p2_int, p2_slope, p3_int, p3_slope, t1_x0, t1_width, t2_x0, t2_width, z0, z1, z2, extra1, extra2, chi2ndf };
108+
AHDC_TIME_TO_DISTANCE_WIRE.put(Integer.valueOf(key), params);
109+
}
110+
}
140111

141112

142113
////////////////////////////////////////////////////////////////////////////////////////////////////////////////

reconstruction/alert/src/main/java/org/jlab/service/ahdc/AHDCEngine.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ else if (Objects.equals(this.getEngineConfigString("Mode"), ModeTrackFinding.CV_
8787
// Requires calibration constants
8888
String[] alertTables = new String[] {
8989
"/calibration/alert/ahdc/time_offsets",
90-
"/calibration/alert/ahdc/time_to_distance",
9190
"/calibration/alert/ahdc/time_to_distance_wire",
9291
"/calibration/alert/ahdc/raw_hit_cuts",
9392
"/calibration/alert/atof/effective_velocity",

0 commit comments

Comments
 (0)