Skip to content

Commit b983f83

Browse files
ftouchtetongtongcao
authored andcommitted
Load raw hit cuts for ahdc from ccdb (#572)
- load raw hit cuts from ccdb - update the key value of the atof ccdb
1 parent 3f2af17 commit b983f83

File tree

3 files changed

+51
-9
lines changed

3 files changed

+51
-9
lines changed

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,22 @@ public final void fetch_AHDCHits(DataEvent event, AlertDCDetector detector) {
3838
double adc = bankDGTZ.getInt("ADC", i);
3939
double leadingEdgeTime = bankDGTZ.getFloat("leadingEdgeTime", i);
4040
double timeOverThreshold = bankDGTZ.getFloat("timeOverThreshold", i);
41-
// Temporary cuts
42-
if ((adc >= 50) && (leadingEdgeTime >= 8*50.0) && (leadingEdgeTime <= 16*50.0) && (timeOverThreshold >= 6*50.0) && (timeOverThreshold <= 14*50.0)) {
43-
// use calibration constants
44-
int key_value = sector*10000 + number*100 + wire;
41+
double adcOffset = bankDGTZ.getShort("ped", i);
42+
// Retrieve raw hit cuts from CCDB
43+
int key_value = sector*10000 + number*100 + wire;
44+
double[] rawHitCuts = CalibrationConstantsLoader.AHDC_RAW_HIT_CUTS.get( key_value );
45+
double t_min = rawHitCuts[0];
46+
double t_max = rawHitCuts[1];
47+
double tot_min = rawHitCuts[2];
48+
double tot_max = rawHitCuts[3];
49+
double adc_min = rawHitCuts[4];
50+
double adc_max = rawHitCuts[5];
51+
double ped_min = rawHitCuts[6];
52+
double ped_max = rawHitCuts[7];
53+
//System.out.println("t_min : " + t_min + " t_max : " + t_max + " tot_min : " + tot_min + " tot_max : " + tot_max + " adc_min : " + adc_min + " adc_max : " + adc_max + " ped_min : " + ped_min + " ped_max : " + ped_max);
54+
// Apply these cuts
55+
if ((adc >= adc_min) && (adc <= adc_max) && (leadingEdgeTime >= t_min) && (leadingEdgeTime <= t_max) && (timeOverThreshold >= tot_min) && (timeOverThreshold <= tot_max) && (adcOffset >= ped_min) && (adcOffset <= ped_max)) {
56+
// Retrieve others CCDB
4557
double[] timeOffsets = CalibrationConstantsLoader.AHDC_TIME_OFFSETS.get( key_value );
4658
double[] time2distance = CalibrationConstantsLoader.AHDC_TIME_TO_DISTANCE.get( 10101 ); // the time to distance table has only one row ! (10101 is its only key)
4759
double t0 = timeOffsets[0];

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

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public CalibrationConstantsLoader() {
2828
// AHDC
2929
public static Map<Integer, double[]> AHDC_TIME_OFFSETS = new HashMap<Integer,double[]>(); ///< AHDC Parameters for timing offsets
3030
public static Map<Integer, double[]> AHDC_TIME_TO_DISTANCE = new HashMap<Integer,double[]>(); ///< AHDC Parameters for time to distance
31+
public static Map<Integer, double[]> AHDC_RAW_HIT_CUTS = new HashMap<Integer,double[]>(); ///< AHDC Parameters for raw hit cuts
3132

3233
// ATOF
3334
public static Map<Integer, double[]> ATOF_EFFECTIVE_VELOCITY = new HashMap<Integer,double[]>(); ///< ATOF Parameters for effective velocity
@@ -42,6 +43,7 @@ public static synchronized void Load(int runno, String var, ConstantsManager man
4243

4344
IndexedTable ahdc_timeOffsets = manager.getConstants(runno, "/calibration/alert/ahdc/time_offsets");
4445
IndexedTable ahdc_time2distance = manager.getConstants(runno, "/calibration/alert/ahdc/time_to_distance");
46+
IndexedTable ahdc_rawHitCuts = manager.getConstants(runno, "/calibration/alert/ahdc/raw_hit_cuts");
4547
IndexedTable atof_effectiveVelocity = manager.getConstants(runno, "/calibration/alert/atof/effective_velocity");
4648
IndexedTable atof_timeWalk = manager.getConstants(runno, "/calibration/alert/atof/time_walk");
4749
IndexedTable atof_attenuationLength = manager.getConstants(runno, "/calibration/alert/atof/attenuation");
@@ -95,6 +97,27 @@ public static synchronized void Load(int runno, String var, ConstantsManager man
9597
//System.out.println("p0 : " + p0 + " p1 : " + p1 + " p2 : " + p2 + " p3 : " + p3 + " p4 : " + p4 + " p5 : " + p5);
9698
}
9799

100+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
101+
// AHDC raw hit cuts
102+
for( int i = 0; i < ahdc_rawHitCuts.getRowCount(); i++){
103+
int sector = Integer.parseInt((String)ahdc_rawHitCuts.getValueAt(i, 0));
104+
int layer = Integer.parseInt((String)ahdc_rawHitCuts.getValueAt(i, 1));
105+
int component = Integer.parseInt((String)ahdc_rawHitCuts.getValueAt(i, 2));
106+
double t_min = ahdc_rawHitCuts.getDoubleValue("t_min", sector, layer, component);
107+
double t_max = ahdc_rawHitCuts.getDoubleValue("t_max", sector, layer, component);
108+
double tot_min = ahdc_rawHitCuts.getDoubleValue("tot_min", sector, layer, component);
109+
double tot_max = ahdc_rawHitCuts.getDoubleValue("tot_max", sector, layer, component);
110+
double adc_min = ahdc_rawHitCuts.getDoubleValue("adc_min", sector, layer, component);
111+
double adc_max = ahdc_rawHitCuts.getDoubleValue("adc_max", sector, layer, component);
112+
double ped_min = ahdc_rawHitCuts.getDoubleValue("ped_min", sector, layer, component);
113+
double ped_max = ahdc_rawHitCuts.getDoubleValue("ped_max", sector, layer, component);
114+
// Put in map
115+
int key = sector*10000 + layer*100 + component;
116+
double params[] = {t_min, t_max, tot_min, tot_max, adc_min, adc_max, ped_min, ped_max};
117+
AHDC_RAW_HIT_CUTS.put(Integer.valueOf(key), params);
118+
//System.out.println("t_min : " + t_min + " t_max : " + t_max + " tot_min : " + tot_min + " tot_max : " + tot_max + " adc_min : " + adc_min + " adc_max : " + adc_max + " ped_min : " + ped_min + " ped_max : " + ped_max);
119+
}
120+
98121
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
99122
// ATOF effective velocity
100123
for( int i = 0; i < atof_effectiveVelocity.getRowCount(); i++){
@@ -106,9 +129,10 @@ public static synchronized void Load(int runno, String var, ConstantsManager man
106129
double extra1 = atof_effectiveVelocity.getDoubleValue("extra1", sector, layer, component);
107130
double extra2 = atof_effectiveVelocity.getDoubleValue("extra2", sector, layer, component);
108131
// Put in map
109-
int key = sector*10000 + layer*100 + component;
132+
int key = sector*10000 + layer*1000 + component*10;
110133
double params[] = {veff, dveff, extra1, extra2};
111134
ATOF_EFFECTIVE_VELOCITY.put(Integer.valueOf(key), params);
135+
//System.out.println("veff : " + veff + " dveff : " + dveff + " extra1 : " + extra1 + " extra2 : " + extra2);
112136
}
113137

114138
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -117,6 +141,7 @@ public static synchronized void Load(int runno, String var, ConstantsManager man
117141
int sector = Integer.parseInt((String)atof_timeWalk.getValueAt(i, 0));
118142
int layer = Integer.parseInt((String)atof_timeWalk.getValueAt(i, 1));
119143
int component = Integer.parseInt((String)atof_timeWalk.getValueAt(i, 2));
144+
int order = Integer.parseInt((String)atof_timeWalk.getValueAt(i, 3));
120145
double tw0 = atof_timeWalk.getDoubleValue("tw0", sector, layer, component);
121146
double tw1 = atof_timeWalk.getDoubleValue("tw1", sector, layer, component);
122147
double tw2 = atof_timeWalk.getDoubleValue("tw2", sector, layer, component);
@@ -127,9 +152,10 @@ public static synchronized void Load(int runno, String var, ConstantsManager man
127152
double dtw3 = atof_timeWalk.getDoubleValue("dtw3", sector, layer, component);
128153
double chi2ndf = atof_timeWalk.getDoubleValue("chi2ndf", sector, layer, component);
129154
// Put in map
130-
int key = sector*10000 + layer*100 + component;
155+
int key = sector*10000 + layer*1000 + component*10 + order;
131156
double params[] = {tw0, tw1, tw2, tw3, dtw0, dtw1, dtw2, dtw3, chi2ndf};
132157
ATOF_TIME_WALK.put(Integer.valueOf(key), params);
158+
//System.out.println("tw0 : " + tw0 + " tw1 : " + tw1 + " tw2 : " + tw2 + " tw3 : " + tw3 + " ...");
133159
}
134160

135161
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -143,9 +169,10 @@ public static synchronized void Load(int runno, String var, ConstantsManager man
143169
double extra1 = atof_attenuationLength.getDoubleValue("extra1", sector, layer, component);
144170
double extra2 = atof_attenuationLength.getDoubleValue("extra2", sector, layer, component);
145171
// Put in map
146-
int key = sector*10000 + layer*100 + component;
172+
int key = sector*10000 + layer*1000 + component*10;
147173
double params[] = {attlen, dattlen, extra1, extra2};
148174
ATOF_ATTENUATION_LENGTH.put(Integer.valueOf(key), params);
175+
//System.out.println("attlen : " + attlen + " dattlen : " + dattlen + " extra1 : " +extra1 + " extra2 : " + extra2 + " ...");
149176
}
150177

151178
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -154,15 +181,17 @@ public static synchronized void Load(int runno, String var, ConstantsManager man
154181
int sector = Integer.parseInt((String)atof_timeOffsets.getValueAt(i, 0));
155182
int layer = Integer.parseInt((String)atof_timeOffsets.getValueAt(i, 1));
156183
int component = Integer.parseInt((String)atof_timeOffsets.getValueAt(i, 2));
184+
int order = Integer.parseInt((String)atof_timeOffsets.getValueAt(i, 3)); // we have to use it here !
157185
double t0 = atof_timeOffsets.getDoubleValue("t0", sector, layer, component);
158186
double upstream_downstream = atof_timeOffsets.getDoubleValue("upstream_downstream", sector, layer, component);
159187
double wedge_bar = atof_timeOffsets.getDoubleValue("wedge_bar", sector, layer, component);
160188
double extra1 = atof_timeOffsets.getDoubleValue("extra1", sector, layer, component);
161189
double extra2 = atof_timeOffsets.getDoubleValue("extra2", sector, layer, component);
162190
// Put in map
163-
int key = sector*10000 + layer*100 + component;
191+
int key = sector*10000 + layer*1000 + component*10 + order;
164192
double params[] = {t0, upstream_downstream, wedge_bar, extra1, extra2};
165193
ATOF_TIME_OFFSETS.put(Integer.valueOf(key), params);
194+
//System.out.println("t0 : " + t0 + " up_down : " + upstream_downstream + " wedge_bar : " + wedge_bar + " ...");
166195
}
167196

168197

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,9 @@ public boolean init() {
9393

9494
// Requires calibration constants
9595
String[] alertTables = new String[] {
96-
"/calibration/alert/ahdc/time_offsets",
96+
"/calibration/alert/ahdc/time_offsets",
9797
"/calibration/alert/ahdc/time_to_distance",
98+
"/calibration/alert/ahdc/raw_hit_cuts",
9899
"/calibration/alert/atof/effective_velocity",
99100
"/calibration/alert/atof/time_walk",
100101
"/calibration/alert/atof/attenuation",

0 commit comments

Comments
 (0)