diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Hit/HitReader.java b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Hit/HitReader.java index ff2b83e5f7..e2953d7857 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Hit/HitReader.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Hit/HitReader.java @@ -1,12 +1,13 @@ package org.jlab.rec.ahdc.Hit; import java.util.ArrayList; +import java.util.List; import org.jlab.io.base.DataBank; import org.jlab.io.base.DataEvent; import org.jlab.detector.banks.RawDataBank; import org.jlab.geom.detector.alert.AHDC.AlertDCDetector; -import org.jlab.rec.alert.constants.CalibrationConstantsLoader; +import org.jlab.utils.groups.IndexedTable; public class HitReader { @@ -14,35 +15,50 @@ public class HitReader { private ArrayList _TrueAHDCHits; private boolean sim = false; - public HitReader(DataEvent event, AlertDCDetector detector, boolean simulation) { + private IndexedTable rawHitCutsTable; + private IndexedTable timeOffsetsTable; + private IndexedTable timeToDistanceWireTable; + private IndexedTable timeOverThresholdTable; + private IndexedTable adcGainsTable; + + public HitReader(DataEvent event, AlertDCDetector detector, boolean simulation, + IndexedTable rawHitCuts, + IndexedTable timeOffsets, + IndexedTable timeToDistanceWire, + IndexedTable timeOverThreshold, + IndexedTable adcGains) { sim = simulation; - fetch_AHDCHits(event, detector); + fetch_AHDCHits(event, detector, rawHitCuts, timeOffsets, timeToDistanceWire, timeOverThreshold, adcGains); if (simulation) fetch_TrueAHDCHits(event); } - public double T2Dfunction(int key, double time){ - double[] time2distance = CalibrationConstantsLoader.AHDC_TIME_TO_DISTANCE_WIRE.get(key); - if (time2distance == null){ - throw new IllegalStateException("Missing CCDB /calibration/alert/ahdc/time_to_distance_wire for key=" + key + " (check run/variation + key mapping)"); - } - - if (time2distance[7] == 0.0 || time2distance[9] == 0.0){ - 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."); - } - + + public double T2Dfunction(int sector, int layer, int wire, double time){ + long hash = timeToDistanceWireTable.getList().getIndexGenerator().hashCode(sector, layer, wire); + List t2d = timeToDistanceWireTable.getDoublesByHash(hash); + // T2D function consists of three 1st order polynomials (p1, p2, p3) and two transition functions (t1, t2). - - double p1 = (time2distance[0] + time2distance[1]*time); - double p2 = (time2distance[2] + time2distance[3]*time); - double p3 = (time2distance[4] + time2distance[5]*time); - - double t1 = 1.0/(1.0 + Math.exp(-(time - time2distance[6])/time2distance[7])); - double t2 = 1.0/(1.0 + Math.exp(-(time - time2distance[8])/time2distance[9])); - - double retval = (p1)*(1.0 - t1) + (t1)*(p2)*(1.0 - t2) + (t2)*(p3); - return retval; + // Column order: p1_int(0), p1_slope(1), p2_int(2), p2_slope(3), p3_int(4), p3_slope(5), + // t1_x0(6), t1_width(7), t2_x0(8), t2_width(9), z0(10), z1(11), z2(12), extra1(13), extra2(14), chi2ndf(15) + + double p1 = (t2d.get(0) + t2d.get(1)*time); + double p2 = (t2d.get(2) + t2d.get(3)*time); + double p3 = (t2d.get(4) + t2d.get(5)*time); + + double t1 = 1.0/(1.0 + Math.exp(-(time - t2d.get(6))/t2d.get(7))); + double t2 = 1.0/(1.0 + Math.exp(-(time - t2d.get(8))/t2d.get(9))); + + return (p1)*(1.0 - t1) + (t1)*(p2)*(1.0 - t2) + (t2)*(p3); } - public final void fetch_AHDCHits(DataEvent event, AlertDCDetector detector) { + public final void fetch_AHDCHits(DataEvent event, AlertDCDetector detector, + IndexedTable rawHitCuts, IndexedTable timeOffsets, + IndexedTable timeToDistanceWire, IndexedTable totCorrTable, + IndexedTable adcGains) { + this.rawHitCutsTable = rawHitCuts; + this.timeOffsetsTable = timeOffsets; + this.timeToDistanceWireTable = timeToDistanceWire; + this.timeOverThresholdTable = totCorrTable; + this.adcGainsTable = adcGains; ArrayList hits = new ArrayList<>(); @@ -63,7 +79,7 @@ public final void fetch_AHDCHits(DataEvent event, AlertDCDetector detector) { for (int i = 0; i < bankDGTZ.rows(); i++) { int id = bankDGTZ.trueIndex(i) + 1; - int number = bankDGTZ.getByte("layer", i); // e.g. 11,12,21,... (this matches CCDB "layer") + int number = bankDGTZ.getByte("layer", i); int layer = number % 10; int superlayer = (number % 100) / 10; int sector = bankDGTZ.getInt("sector", i); @@ -76,103 +92,52 @@ public final void fetch_AHDCHits(DataEvent event, AlertDCDetector detector) { double adcOffset = bankDGTZ.getFloat("ped", i); int wfType = bankDGTZ.getShort("wfType", i); - // CCDB key - int key_value = sector * 10000 + number * 100 + wire; - - // ----------------------------- // Raw hit cuts - // ----------------------------- - // double[] rawHitCuts = CalibrationConstantsLoader.AHDC_RAW_HIT_CUTS.get(key_value); - //if (rawHitCuts == null) continue; - - - double[] rawHitCuts = CalibrationConstantsLoader.AHDC_RAW_HIT_CUTS.get(key_value); - if (rawHitCuts == null) {throw new IllegalStateException("Missing CCDB table /calibration/alert/ahdc/raw_hit_cuts for key=" + key_value+ " (check run/variation + key mapping)"); - } - - double t_min = rawHitCuts[0]; - double t_max = rawHitCuts[1]; - double tot_min = rawHitCuts[2]; - double tot_max = rawHitCuts[3]; - double adc_min = rawHitCuts[4]; - double adc_max = rawHitCuts[5]; - double ped_min = rawHitCuts[6]; - double ped_max = rawHitCuts[7]; - - // ----------------------------- - // Time calibration + t->d - // ----------------------------- - //double[] timeOffsets = CalibrationConstantsLoader.AHDC_TIME_OFFSETS.get(key_value); - //if (timeOffsets == null) continue; - - // double[] timeOffsets = CalibrationConstantsLoader.AHDC_TIME_OFFSETS.get(key_value); - //if (timeOffsets == null) { - //throw new IllegalStateException("Missing AHDC time_offsets for key=" + key_value); - //} - - double[] timeOffsets = CalibrationConstantsLoader.AHDC_TIME_OFFSETS.get(key_value); - - if (timeOffsets == null) { - throw new IllegalStateException("Missing CCDB /calibration/alert/ahdc/time_offsets for key=" + key_value + " (check run/variation + key mapping)"); - } - - - - double t0 = timeOffsets[0]; + double t_min = rawHitCutsTable.getDoubleValue("t_min", sector, number, wire); + double t_max = rawHitCutsTable.getDoubleValue("t_max", sector, number, wire); + double tot_min = rawHitCutsTable.getDoubleValue("tot_min", sector, number, wire); + double tot_max = rawHitCutsTable.getDoubleValue("tot_max", sector, number, wire); + double adc_min = rawHitCutsTable.getDoubleValue("adc_min", sector, number, wire); + double adc_max = rawHitCutsTable.getDoubleValue("adc_max", sector, number, wire); + double ped_min = rawHitCutsTable.getDoubleValue("ped_min", sector, number, wire); + double ped_max = rawHitCutsTable.getDoubleValue("ped_max", sector, number, wire); + + // Time calibration + double t0 = timeOffsetsTable.getDoubleValue("t0", sector, number, wire); double time = leadingEdgeTime - t0 - startTime; - // ----------------------------- - // ToT correction (new CCDB) - // convention: ToT_corr = ToT_raw * totCorr - // ----------------------------- + // ToT correction double totUsed = timeOverThreshold; if (!sim) { - double[] totArr = CalibrationConstantsLoader.AHDC_TIME_OVER_THRESHOLD.get(key_value); - if (totArr != null && totArr.length > 0) { - double totCorr = totArr[0]; - totUsed = timeOverThreshold * totCorr; - } + double totCorr = timeOverThresholdTable.getDoubleValue("totCorr", sector, number, wire); + if (totCorr != 0.0) totUsed = timeOverThreshold * totCorr; } - // ----------------------------- // Hit selection (cuts) - // NOTE: we cut on totUsed (corrected ToT). If you want RAW-ToT cuts, - // replace totUsed with timeOverThreshold in the condition. - // ----------------------------- boolean passCuts = (wfType <= 2) && - (adcRaw >= adc_min) && (adcRaw <= adc_max) && - (time >= t_min) && (time <= t_max) && - (timeOverThreshold >= tot_min) && (timeOverThreshold <= tot_max)&& - //(totUsed >= tot_min) && (totUsed <= tot_max) && - (adcOffset >= ped_min) && (adcOffset <= ped_max); + (adcRaw >= adc_min) && (adcRaw <= adc_max) && + (time >= t_min) && (time <= t_max) && + (timeOverThreshold >= tot_min) && (timeOverThreshold <= tot_max) && + (adcOffset >= ped_min) && (adcOffset <= ped_max); if (!passCuts && !sim) continue; - // ----------------------------- // DOCA from calibrated time - // ----------------------------- - double doca = T2Dfunction(key_value,time); - + double doca = T2Dfunction(sector, number, wire, time); if (time < 0) doca = 0.0; - // ----------------------------- - // ADC gain calibration (new gains schema: gainCorr is index 0) - // convention: ADC_cal = ADC_raw * gainCorr - // ----------------------------- + // ADC gain calibration double adcCal = adcRaw; if (!sim) { - double[] gainArr = CalibrationConstantsLoader.AHDC_ADC_GAINS.get(key_value); - if (gainArr != null && gainArr.length > 0) { - double gainCorr = gainArr[0]; - adcCal = adcRaw * gainCorr; - } + double gainCorr = adcGainsTable.getDoubleValue("gainCorr", sector, number, wire); + if (gainCorr != 0.0) adcCal = adcRaw * gainCorr; } Hit h = new Hit(id, superlayer, layer, wire, doca, adcRaw, time); h.setWirePosition(detector); - h.setADC(adcCal); // place to store calibrated ADC - h.setToT(totUsed); // place to store caibrated ToT + h.setADC(adcCal); + h.setToT(totUsed); hits.add(h); } diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/alert/constants/CalibrationConstantsLoader.java b/reconstruction/alert/src/main/java/org/jlab/rec/alert/constants/CalibrationConstantsLoader.java deleted file mode 100644 index d2238898f4..0000000000 --- a/reconstruction/alert/src/main/java/org/jlab/rec/alert/constants/CalibrationConstantsLoader.java +++ /dev/null @@ -1,308 +0,0 @@ -package org.jlab.rec.alert.constants; - -import org.jlab.detector.calib.utils.ConstantsManager; -import org.jlab.detector.calib.utils.DatabaseConstantProvider; -import org.jlab.utils.groups.IndexedTable; - -import java.util.HashMap; -import java.util.Map; - -/** - * This class loads constants from CCDB - * - * inspired by the one of the BAND subsystem - * - * @author ftouchte - */ -public class CalibrationConstantsLoader { - - public CalibrationConstantsLoader() { - // default ctor - } - - public static boolean CSTLOADED = false; - - // Maps for constants from database - // AHDC - public static Map AHDC_TIME_OFFSETS = new HashMap<>(); ///< {t0,dt0,extra1,extra2,chi2ndf} - public static Map AHDC_TIME_TO_DISTANCE_WIRE = new HashMap<>(); ///< T2D function for every wire - public static Map AHDC_RAW_HIT_CUTS = new HashMap<>(); ///< {t_min,t_max,tot_min,tot_max,adc_min,adc_max,ped_min,ped_max} - - // UPDATED SCHEMA: keys (sector,layer,component), columns: gainCorr,dgainCorr,extra1,extra2,extra3 - public static Map AHDC_ADC_GAINS = new HashMap<>(); ///< {gainCorr, dgainCorr, extra1, extra2, extra3} - - // NEW ToT TABLE: keys (sector,layer,component), columns: totCorr,dtotCorr,extra1,extra2,extra3 - public static Map AHDC_TIME_OVER_THRESHOLD = new HashMap<>(); ///< {totCorr, dtotCorr, extra1, extra2, extra3} - - // ATOF - public static Map ATOF_EFFECTIVE_VELOCITY = new HashMap<>(); ///< {veff,dveff,extra1,extra2} - public static Map ATOF_TIME_WALK = new HashMap<>(); ///< {tw0..tw3, dtw0..dtw3, chi2ndf} - public static Map ATOF_ATTENUATION_LENGTH = new HashMap<>(); ///< {attlen,dattlen,extra1,extra2} - public static Map ATOF_TIME_OFFSETS = new HashMap<>(); ///< {t0,upstream_downstream,wedge_bar,extra1,extra2} - - public static synchronized void Load(int runno, ConstantsManager manager) { - - if (CSTLOADED) return; - - IndexedTable ahdc_timeOffsets = manager.getConstants(runno, "/calibration/alert/ahdc/time_offsets"); - IndexedTable ahdc_time2distanceWire = manager.getConstants(runno, "/calibration/alert/ahdc/time_to_distance_wire"); - IndexedTable ahdc_rawHitCuts = manager.getConstants(runno, "/calibration/alert/ahdc/raw_hit_cuts"); - - // Gains table (UPDATED SCHEMA) - IndexedTable ahdc_adcGains = manager.getConstants(runno, "/calibration/alert/ahdc/gains"); - - // NEW ToT table - IndexedTable ahdc_timeOverThreshold = manager.getConstants(runno, "/calibration/alert/ahdc/time_over_threshold"); - - IndexedTable atof_effectiveVelocity = manager.getConstants(runno, "/calibration/alert/atof/effective_velocity"); - IndexedTable atof_timeWalk = manager.getConstants(runno, "/calibration/alert/atof/time_walk"); - IndexedTable atof_attenuationLength = manager.getConstants(runno, "/calibration/alert/atof/attenuation"); - IndexedTable atof_timeOffsets = manager.getConstants(runno, "/calibration/alert/atof/time_offsets"); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // AHDC time offsets - for (int i = 0; i < ahdc_timeOffsets.getRowCount(); i++) { - int sector = Integer.parseInt((String) ahdc_timeOffsets.getValueAt(i, 0)); - int layer = Integer.parseInt((String) ahdc_timeOffsets.getValueAt(i, 1)); - int component = Integer.parseInt((String) ahdc_timeOffsets.getValueAt(i, 2)); - - double t0 = ahdc_timeOffsets.getDoubleValue("t0", sector, layer, component); - double dt0 = ahdc_timeOffsets.getDoubleValue("dt0", sector, layer, component); - double extra1 = ahdc_timeOffsets.getDoubleValue("extra1", sector, layer, component); - double extra2 = ahdc_timeOffsets.getDoubleValue("extra2", sector, layer, component); - double chi2ndf = ahdc_timeOffsets.getDoubleValue("chi2ndf", sector, layer, component); - - int key = sector * 10000 + layer * 100 + component; - double params[] = { t0, dt0, extra1, extra2, chi2ndf }; - AHDC_TIME_OFFSETS.put(Integer.valueOf(key), params); - } - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // AHDC time to distance per wire - // See implementation and functional form in reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Hit/HitReader.java - if(ahdc_time2distanceWire != null){ - for (int i = 0; i < ahdc_time2distanceWire.getRowCount(); i++) { - int sector = Integer.parseInt((String) ahdc_time2distanceWire.getValueAt(i, 0)); - int layer = Integer.parseInt((String) ahdc_time2distanceWire.getValueAt(i, 1)); - int component = Integer.parseInt((String) ahdc_time2distanceWire.getValueAt(i, 2)); - - double p1_int = ahdc_time2distanceWire.getDoubleValue("p1_int", sector, layer, component); - double p1_slope = ahdc_time2distanceWire.getDoubleValue("p1_slope", sector, layer, component); - double p2_int = ahdc_time2distanceWire.getDoubleValue("p2_int", sector, layer, component); - double p2_slope = ahdc_time2distanceWire.getDoubleValue("p2_slope", sector, layer, component); - double p3_int = ahdc_time2distanceWire.getDoubleValue("p3_int", sector, layer, component); - double p3_slope = ahdc_time2distanceWire.getDoubleValue("p3_slope", sector, layer, component); - double t1_x0 = ahdc_time2distanceWire.getDoubleValue("t1_x0", sector, layer, component); - double t1_width = ahdc_time2distanceWire.getDoubleValue("t1_width", sector, layer, component); - double t2_x0 = ahdc_time2distanceWire.getDoubleValue("t2_x0", sector, layer, component); - double t2_width = ahdc_time2distanceWire.getDoubleValue("t2_width", sector, layer, component); - double z0 = ahdc_time2distanceWire.getDoubleValue("z0", sector, layer, component); - double z1 = ahdc_time2distanceWire.getDoubleValue("z1", sector, layer, component); - double z2 = ahdc_time2distanceWire.getDoubleValue("z2", sector, layer, component); - double extra1 = ahdc_time2distanceWire.getDoubleValue("extra1", sector, layer, component); - double extra2 = ahdc_time2distanceWire.getDoubleValue("extra2", sector, layer, component); - double chi2ndf = ahdc_time2distanceWire.getDoubleValue("chi2ndf", sector, layer, component); - - int key = sector * 10000 + layer * 100 + component; - 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 }; - AHDC_TIME_TO_DISTANCE_WIRE.put(Integer.valueOf(key), params); - } - } - - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // AHDC raw hit cuts - for (int i = 0; i < ahdc_rawHitCuts.getRowCount(); i++) { - int sector = Integer.parseInt((String) ahdc_rawHitCuts.getValueAt(i, 0)); - int layer = Integer.parseInt((String) ahdc_rawHitCuts.getValueAt(i, 1)); - int component = Integer.parseInt((String) ahdc_rawHitCuts.getValueAt(i, 2)); - - double t_min = ahdc_rawHitCuts.getDoubleValue("t_min", sector, layer, component); - double t_max = ahdc_rawHitCuts.getDoubleValue("t_max", sector, layer, component); - double tot_min = ahdc_rawHitCuts.getDoubleValue("tot_min", sector, layer, component); - double tot_max = ahdc_rawHitCuts.getDoubleValue("tot_max", sector, layer, component); - double adc_min = ahdc_rawHitCuts.getDoubleValue("adc_min", sector, layer, component); - double adc_max = ahdc_rawHitCuts.getDoubleValue("adc_max", sector, layer, component); - double ped_min = ahdc_rawHitCuts.getDoubleValue("ped_min", sector, layer, component); - double ped_max = ahdc_rawHitCuts.getDoubleValue("ped_max", sector, layer, component); - - int key = sector * 10000 + layer * 100 + component; - double params[] = { t_min, t_max, tot_min, tot_max, adc_min, adc_max, ped_min, ped_max }; - AHDC_RAW_HIT_CUTS.put(Integer.valueOf(key), params); - } - - - // AHDC ADC gains table - // keys : sector, layer, component - // cols : gainCorr, dgainCorr, extra1, extra2, extra3 - - if (ahdc_adcGains != null) { - for (int i = 0; i < ahdc_adcGains.getRowCount(); i++) { - - int sector = Integer.parseInt((String) ahdc_adcGains.getValueAt(i, 0)); - int layer = Integer.parseInt((String) ahdc_adcGains.getValueAt(i, 1)); - int component = Integer.parseInt((String) ahdc_adcGains.getValueAt(i, 2)); - - double gainCorr = ahdc_adcGains.getDoubleValue("gainCorr", sector, layer, component); - double dgainCorr = ahdc_adcGains.getDoubleValue("dgainCorr", sector, layer, component); - - double extra1 = 0.0, extra2 = 0.0, extra3 = 0.0; - try { extra1 = ahdc_adcGains.getDoubleValue("extra1", sector, layer, component); } catch (Exception e) {} - try { extra2 = ahdc_adcGains.getDoubleValue("extra2", sector, layer, component); } catch (Exception e) {} - try { extra3 = ahdc_adcGains.getDoubleValue("extra3", sector, layer, component); } catch (Exception e) {} - - int key = sector * 10000 + layer * 100 + component; - AHDC_ADC_GAINS.put(key, new double[]{gainCorr, dgainCorr, extra1, extra2, extra3}); - } -} - -/////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// AHDC time_over_threshold (NEW TABLE) -// keys : sector, layer, component -// columns: totCorr, dtotCorr, extra1, extra2, extra3 - -// always clear so behavior is deterministic if Load() is ever called again -AHDC_TIME_OVER_THRESHOLD.clear(); - -// Table may not exist for some runs/variations -> treat as "no correction" -if (ahdc_timeOverThreshold != null) { - - for (int i = 0; i < ahdc_timeOverThreshold.getRowCount(); i++) { - int sector = Integer.parseInt((String) ahdc_timeOverThreshold.getValueAt(i, 0)); - int layer = Integer.parseInt((String) ahdc_timeOverThreshold.getValueAt(i, 1)); - int component = Integer.parseInt((String) ahdc_timeOverThreshold.getValueAt(i, 2)); - - double totCorr = ahdc_timeOverThreshold.getDoubleValue("totCorr", sector, layer, component); - double dtotCorr = ahdc_timeOverThreshold.getDoubleValue("dtotCorr", sector, layer, component); - - double extra1 = 0.0, extra2 = 0.0, extra3 = 0.0; - try { extra1 = ahdc_timeOverThreshold.getDoubleValue("extra1", sector, layer, component); } catch (Exception e) {} - try { extra2 = ahdc_timeOverThreshold.getDoubleValue("extra2", sector, layer, component); } catch (Exception e) {} - try { extra3 = ahdc_timeOverThreshold.getDoubleValue("extra3", sector, layer, component); } catch (Exception e) {} - - int key = sector * 10000 + layer * 100 + component; - double[] params = { totCorr, dtotCorr, extra1, extra2, extra3 }; - AHDC_TIME_OVER_THRESHOLD.put(Integer.valueOf(key), params); - } -} - - - - - - - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // AHDC time_over_threshold (NEW TABLE) - // keys : sector, layer, component - // columns: totCorr, dtotCorr, extra1, extra2, extra3 -// for (int i = 0; i < ahdc_timeOverThreshold.getRowCount(); i++) { -// int sector = Integer.parseInt((String) ahdc_timeOverThreshold.getValueAt(i, 0)); -// int layer = Integer.parseInt((String) ahdc_timeOverThreshold.getValueAt(i, 1)); -// int component = Integer.parseInt((String) ahdc_timeOverThreshold.getValueAt(i, 2)); -// -// double totCorr = ahdc_timeOverThreshold.getDoubleValue("totCorr", sector, layer, component); -// double dtotCorr = ahdc_timeOverThreshold.getDoubleValue("dtotCorr", sector, layer, component); - -// double extra1 = 0.0, extra2 = 0.0, extra3 = 0.0; -// try { extra1 = ahdc_timeOverThreshold.getDoubleValue("extra1", sector, layer, component); } catch (Exception e) {} -//// try { extra2 = ahdc_timeOverThreshold.getDoubleValue("extra2", sector, layer, component); } catch (Exception e) {} -// try { extra3 = ahdc_timeOverThreshold.getDoubleValue("extra3", sector, layer, component); } catch (Exception e) {} - -// int key = sector * 10000 + layer * 100 + component; -// double params[] = { totCorr, dtotCorr, extra1, extra2, extra3 }; -// AHDC_TIME_OVER_THRESHOLD.put(Integer.valueOf(key), params); -// } - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // ATOF effective velocity - for (int i = 0; i < atof_effectiveVelocity.getRowCount(); i++) { - int sector = Integer.parseInt((String) atof_effectiveVelocity.getValueAt(i, 0)); - int layer = Integer.parseInt((String) atof_effectiveVelocity.getValueAt(i, 1)); - int component = Integer.parseInt((String) atof_effectiveVelocity.getValueAt(i, 2)); - - double veff = atof_effectiveVelocity.getDoubleValue("veff", sector, layer, component); - double dveff = atof_effectiveVelocity.getDoubleValue("dveff", sector, layer, component); - double extra1 = atof_effectiveVelocity.getDoubleValue("extra1", sector, layer, component); - double extra2 = atof_effectiveVelocity.getDoubleValue("extra2", sector, layer, component); - - int key = sector * 10000 + layer * 1000 + component * 10; - double params[] = { veff, dveff, extra1, extra2 }; - ATOF_EFFECTIVE_VELOCITY.put(Integer.valueOf(key), params); - } - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // ATOF time walk - for (int i = 0; i < atof_timeWalk.getRowCount(); i++) { - int sector = Integer.parseInt((String) atof_timeWalk.getValueAt(i, 0)); - int layer = Integer.parseInt((String) atof_timeWalk.getValueAt(i, 1)); - int component = Integer.parseInt((String) atof_timeWalk.getValueAt(i, 2)); - int order = Integer.parseInt((String) atof_timeWalk.getValueAt(i, 3)); - - double tw0 = atof_timeWalk.getDoubleValue("tw0", sector, layer, component, order); - double tw1 = atof_timeWalk.getDoubleValue("tw1", sector, layer, component, order); - double tw2 = atof_timeWalk.getDoubleValue("tw2", sector, layer, component, order); - double tw3 = atof_timeWalk.getDoubleValue("tw3", sector, layer, component, order); - double dtw0 = atof_timeWalk.getDoubleValue("dtw0", sector, layer, component, order); - double dtw1 = atof_timeWalk.getDoubleValue("dtw1", sector, layer, component, order); - double dtw2 = atof_timeWalk.getDoubleValue("dtw2", sector, layer, component, order); - double dtw3 = atof_timeWalk.getDoubleValue("dtw3", sector, layer, component, order); - double chi2ndf = atof_timeWalk.getDoubleValue("chi2ndf", sector, layer, component, order); - - int key = sector * 10000 + layer * 1000 + component * 10 + order; - double params[] = { tw0, tw1, tw2, tw3, dtw0, dtw1, dtw2, dtw3, chi2ndf }; - ATOF_TIME_WALK.put(Integer.valueOf(key), params); - } - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // ATOF attenuation length - for (int i = 0; i < atof_attenuationLength.getRowCount(); i++) { - int sector = Integer.parseInt((String) atof_attenuationLength.getValueAt(i, 0)); - int layer = Integer.parseInt((String) atof_attenuationLength.getValueAt(i, 1)); - int component = Integer.parseInt((String) atof_attenuationLength.getValueAt(i, 2)); - - double attlen = atof_attenuationLength.getDoubleValue("attlen", sector, layer, component); - double dattlen = atof_attenuationLength.getDoubleValue("dattlen", sector, layer, component); - double extra1 = atof_attenuationLength.getDoubleValue("extra1", sector, layer, component); - double extra2 = atof_attenuationLength.getDoubleValue("extra2", sector, layer, component); - - int key = sector * 10000 + layer * 1000 + component * 10; - double params[] = { attlen, dattlen, extra1, extra2 }; - ATOF_ATTENUATION_LENGTH.put(Integer.valueOf(key), params); - } - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // ATOF time offsets - for (int i = 0; i < atof_timeOffsets.getRowCount(); i++) { - int sector = Integer.parseInt((String) atof_timeOffsets.getValueAt(i, 0)); - int layer = Integer.parseInt((String) atof_timeOffsets.getValueAt(i, 1)); - int component = Integer.parseInt((String) atof_timeOffsets.getValueAt(i, 2)); - int order = Integer.parseInt((String) atof_timeOffsets.getValueAt(i, 3)); // we have to use it here ! - - double t0 = atof_timeOffsets.getDoubleValue("t0", sector, layer, component, order); - double upstream_downstream = atof_timeOffsets.getDoubleValue("upstream_downstream", sector, layer, component, order); - double wedge_bar = atof_timeOffsets.getDoubleValue("wedge_bar", sector, layer, component, order); - double extra1 = atof_timeOffsets.getDoubleValue("extra1", sector, layer, component, order); - double extra2 = atof_timeOffsets.getDoubleValue("extra2", sector, layer, component, order); - - int key = sector * 10000 + layer * 1000 + component * 10 + order; - double params[] = { t0, upstream_downstream, wedge_bar, extra1, extra2 }; - ATOF_TIME_OFFSETS.put(Integer.valueOf(key), params); - } - - CSTLOADED = true; - } - - private static DatabaseConstantProvider DB; - - public static final DatabaseConstantProvider getDB() { - return DB; - } - - public static final void setDB(DatabaseConstantProvider dB) { - DB = dB; - } - - public static void main(String arg[]) { - } -} 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 81f1d6dc17..c04a4ad4d4 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 @@ -4,7 +4,7 @@ import org.jlab.geom.prim.Point3D; import org.jlab.rec.atof.constants.Parameters; import java.util.logging.Logger; -import org.jlab.rec.alert.constants.CalibrationConstantsLoader; +import org.jlab.utils.groups.IndexedTable; /** * @@ -27,6 +27,7 @@ public class ATOFHit { private boolean isInACluster; private int associatedClusterIndex; int idTDC; + private IndexedTable atofTimeOffsets; public int getSector() { @@ -195,16 +196,11 @@ public final int convertTdcToTime() { //If the startTime has been defined, remove it if(this.startTime!= null) this.time -= this.startTime; - //TODO: When table structure evolves, pay attention to order. - //Key for the current channel - int key = this.sector*10000 + this.layer*1000 + this.component*10 + 0;//this.order; - //Time offsets - double[] timeOffsets = CalibrationConstantsLoader.ATOF_TIME_OFFSETS.get(key); - double t0 = timeOffsets[0]; - - //tud is used to store the bar up - bar down alignment - double tud = timeOffsets[1]; + if (atofTimeOffsets == null) return 0; + int order0 = 0; + double t0 = atofTimeOffsets.getDoubleValue("t0", this.sector, this.layer, this.component, order0); + double tud = atofTimeOffsets.getDoubleValue("upstream_downstream", this.sector, this.layer, this.component, order0); //The rest of the constants are not used for now /*double twb = timeOffsets[2]; double xtra1 = timeOffsets[3]; @@ -403,7 +399,8 @@ public double getPhi() { * @param atof Detector object representing the atof, used to calculate * spatial coordinates. */ - public ATOFHit(int sector, int layer, int component, int order, int tdc, int tot, Float startTime, Detector atof) { + public ATOFHit(int sector, int layer, int component, int order, int tdc, int tot, Float startTime, Detector atof, + IndexedTable atofTimeOffsets) { this.sector = sector; this.layer = layer; this.component = component; @@ -411,6 +408,7 @@ public ATOFHit(int sector, int layer, int component, int order, int tdc, int tot this.tdc = tdc; this.tot = tot; this.startTime = startTime; + this.atofTimeOffsets = atofTimeOffsets; this.isInACluster = false; this.makeType(); 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 eba7640c4b..b60ecbdc2a 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 @@ -3,7 +3,7 @@ import org.jlab.io.base.DataEvent; import org.jlab.io.hipo.HipoDataSource; import org.jlab.rec.atof.constants.Parameters; -import org.jlab.rec.alert.constants.CalibrationConstantsLoader; +import org.jlab.utils.groups.IndexedTable; /** * @@ -106,7 +106,7 @@ public final void computeEnergy() { this.setEnergy(Edep_up + Edep_down); } - public BarHit(ATOFHit hit_down, ATOFHit hit_up) { + public BarHit(ATOFHit hit_down, ATOFHit hit_up, IndexedTable atofEffectiveVelocity) { boolean hits_match = hit_down.matchBar(hit_up); if (!hits_match) { throw new UnsupportedOperationException("Hits do not match \n"); @@ -120,11 +120,9 @@ public BarHit(ATOFHit hit_down, ATOFHit hit_up) { this.setComponent(10); this.setX(hit_up.getX()); this.setY(hit_up.getY()); - + //CCDB readout for the effective velocity - int key = this.getSector()*10000 + this.getLayer()*1000 + this.getComponent()*10; - double[] vEffTable = CalibrationConstantsLoader.ATOF_EFFECTIVE_VELOCITY.get(key); - this.vEff = vEffTable[0]; + this.vEff = atofEffectiveVelocity.getDoubleValue("veff", this.getSector(), this.getLayer(), this.getComponent()); this.computeZ(); this.computeTime(); this.computeEnergy(); 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 1f7c04e901..3970f11139 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.utils.groups.IndexedTable; /** * The {@code HitFinder} class finds hits in the atof. @@ -63,7 +64,9 @@ public void setWedgeHits(ArrayList wedge_hits) { * @param atof the {@link Detector} representing the atof geometry to match * the sector/layer/component to x/y/z. */ - public void findHits(DataEvent event, Detector atof, Float startTime) { + public void findHits(DataEvent event, Detector atof, Float startTime, + IndexedTable atofTimeOffsets, + IndexedTable atofEffectiveVelocity) { //For each event a list of bar hits and a list of wedge hits are filled this.barHits.clear(); this.wedgeHits.clear(); @@ -89,7 +92,7 @@ public void findHits(DataEvent event, Detector atof, Float startTime) { int tot = bank.getInt("ToT", i); //Building a Hit - ATOFHit hit = new ATOFHit(sector, layer, component, order, tdc, tot, startTime, atof); + ATOFHit hit = new ATOFHit(sector, layer, component, order, tdc, tot, startTime, atof, atofTimeOffsets); if (hit.getEnergy() < 0.01) { continue; //energy threshold } @@ -124,7 +127,7 @@ 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 - BarHit this_bar_hit = new BarHit(this_hit_down, this_hit_up); + BarHit this_bar_hit = new BarHit(this_hit_down, this_hit_up, atofEffectiveVelocity); //Only add bar hits for which the time sum is in time if(!this_bar_hit.isInTime()) continue; this.barHits.add(this_bar_hit); diff --git a/reconstruction/alert/src/main/java/org/jlab/service/ahdc/AHDCEngine.java b/reconstruction/alert/src/main/java/org/jlab/service/ahdc/AHDCEngine.java index 839db72e86..8d4252fd28 100644 --- a/reconstruction/alert/src/main/java/org/jlab/service/ahdc/AHDCEngine.java +++ b/reconstruction/alert/src/main/java/org/jlab/service/ahdc/AHDCEngine.java @@ -29,7 +29,7 @@ import org.jlab.detector.calib.utils.DatabaseConstantProvider; import org.jlab.geom.detector.alert.AHDC.AlertDCDetector; import org.jlab.geom.detector.alert.AHDC.AlertDCFactory; -import org.jlab.rec.alert.constants.CalibrationConstantsLoader; +import org.jlab.utils.groups.IndexedTable; import org.jlab.detector.pulse.ModeAHDC; /** AHDCEngine reconstruction service. @@ -56,6 +56,15 @@ public class AHDCEngine extends ReconstructionEngine { private AlertDCDetector factory = null; private ModeAHDC ahdcExtractor = new ModeAHDC(); + // AHDC calibration tables (instance-level, refreshed on run change) + private IndexedTable ahdcTimeOffsets; + private IndexedTable ahdcTimeToDistanceWire; + private IndexedTable ahdcRawHitCuts; + private IndexedTable ahdcAdcGains; + private IndexedTable ahdcTimeOverThreshold; + + int Run = -1; + public AHDCEngine() { super("ALERT", "ouillon", "1.0.1"); } public boolean init(ModeTrackFinding m) { @@ -71,33 +80,18 @@ public boolean init() { if (materialMap == null) materialMap = MaterialMap.generateMaterials(); - if(this.getEngineConfigString("Mode")!=null) { - if (Objects.equals(this.getEngineConfigString("Mode"), ModeTrackFinding.AI_Track_Finding.name())) - modeTrackFinding = ModeTrackFinding.AI_Track_Finding; - else if (Objects.equals(this.getEngineConfigString("Mode"), ModeTrackFinding.CV_Distance.name())) - modeTrackFinding = ModeTrackFinding.CV_Distance; - else if (Objects.equals(this.getEngineConfigString("Mode"), ModeTrackFinding.CV_Hough.name())) - modeTrackFinding = ModeTrackFinding.CV_Hough; - } + String modeConfig = this.getEngineConfigString("Mode"); + if (modeConfig != null) modeTrackFinding = ModeTrackFinding.valueOf(modeConfig); + if (modeTrackFinding == ModeTrackFinding.AI_Track_Finding) modelTrackFinding = new ModelTrackFinding(); - if (modeTrackFinding == ModeTrackFinding.AI_Track_Finding) { - modelTrackFinding = new ModelTrackFinding(); - } + Map tableMap = new HashMap<>(); + tableMap.put("/calibration/alert/ahdc/time_offsets", 3); + tableMap.put("/calibration/alert/ahdc/time_to_distance_wire", 3); + tableMap.put("/calibration/alert/ahdc/raw_hit_cuts", 3); + tableMap.put("/calibration/alert/ahdc/gains", 3); + tableMap.put("/calibration/alert/ahdc/time_over_threshold", 3); - // Requires calibration constants - String[] alertTables = new String[] { - "/calibration/alert/ahdc/time_offsets", - "/calibration/alert/ahdc/time_to_distance_wire", - "/calibration/alert/ahdc/raw_hit_cuts", - "/calibration/alert/atof/effective_velocity", - "/calibration/alert/atof/time_walk", - "/calibration/alert/atof/attenuation", - "/calibration/alert/atof/time_offsets", - "/calibration/alert/ahdc/gains", - "/calibration/alert/ahdc/time_over_threshold" - - }; - requireConstants(Arrays.asList(alertTables)); + requireConstants(tableMap); this.getConstantsManager().setVariation("default"); @@ -106,8 +100,6 @@ else if (Objects.equals(this.getEngineConfigString("Mode"), ModeTrackFinding.CV_ return true; } - int Run = -1; - @Override public boolean processDataEvent(DataEvent event) { @@ -122,19 +114,21 @@ public boolean processDataEvent(DataEvent event) { LOGGER.warning("AHDCEngine: got run <= 0 in RUN::config, skipping event."); return false; } - // Load the constants - //------------------- if(Run != newRun) { - CalibrationConstantsLoader.Load(newRun, this.getConstantsManager()); + ahdcTimeOffsets = this.getConstantsManager().getConstants(newRun, "/calibration/alert/ahdc/time_offsets"); + ahdcTimeToDistanceWire = this.getConstantsManager().getConstants(newRun, "/calibration/alert/ahdc/time_to_distance_wire"); + ahdcRawHitCuts = this.getConstantsManager().getConstants(newRun, "/calibration/alert/ahdc/raw_hit_cuts"); + ahdcAdcGains = this.getConstantsManager().getConstants(newRun, "/calibration/alert/ahdc/gains"); + ahdcTimeOverThreshold = this.getConstantsManager().getConstants(newRun, "/calibration/alert/ahdc/time_over_threshold"); Run = newRun; } } - - if (event.hasBank("AHDC::adc")) { // I) Read raw hits - HitReader hitReader = new HitReader(event, factory, simulation); + HitReader hitReader = new HitReader(event, factory, simulation, + ahdcRawHitCuts, ahdcTimeOffsets, ahdcTimeToDistanceWire, + ahdcTimeOverThreshold, ahdcAdcGains); ArrayList AHDC_Hits = hitReader.get_AHDCHits(); // II) Create PreClusters @@ -251,7 +245,6 @@ else if (modeTrackFinding == ModeTrackFinding.CV_Hough) { all_interclusters.addAll(track.getInterclusters()); } DataBank recoInterClusterBank = writer.fillInterClusterBank(event, all_interclusters); - // DataBank AIPredictionBanks = writer.fillAIPrediction(event, predictions); //event.removeBanks("AHDC::hits","AHDC::preclusters","AHDC::clusters","AHDC::track","AHDC::kftrack","AHDC::mc","AHDC::ai:prediction"); event.appendBank(recoHitsBank); @@ -260,7 +253,6 @@ else if (modeTrackFinding == ModeTrackFinding.CV_Hough) { event.appendBank(recoTracksBank); event.appendBank(recoInterClusterBank); event.appendBank(clustersDocaBank); - // event.appendBank(AIPredictionBanks); if (simulation) { DataBank recoMCBank = writer.fillAHDCMCTrackBank(event); diff --git a/reconstruction/alert/src/main/java/org/jlab/service/alert/ALERTEngine.java b/reconstruction/alert/src/main/java/org/jlab/service/alert/ALERTEngine.java index 5465ec29d8..3b6444e46e 100644 --- a/reconstruction/alert/src/main/java/org/jlab/service/alert/ALERTEngine.java +++ b/reconstruction/alert/src/main/java/org/jlab/service/alert/ALERTEngine.java @@ -6,9 +6,13 @@ import java.util.ArrayList; import java.util.concurrent.atomic.AtomicInteger; +import java.util.HashMap; +import java.util.Map; + import org.jlab.clas.reco.ReconstructionEngine; import org.jlab.clas.swimtools.Swim; import org.jlab.detector.calib.utils.DatabaseConstantProvider; +import org.jlab.utils.groups.IndexedTable; import org.jlab.geom.base.Detector; import org.jlab.geom.detector.alert.ATOF.AlertTOFFactory; import org.jlab.io.base.DataBank; @@ -71,6 +75,9 @@ public class ALERTEngine extends ReconstructionEngine { private ModelTrackMatching modelTrackMatching; private ModelPrePID modelPrePID; + // AHDC calibration table (refreshed on run change) + private IndexedTable ahdcAdcGains; + public void setB(double B) { this.b = B; } @@ -103,6 +110,11 @@ public boolean init() { ATOF = factory.createDetectorCLAS(cp); AHDC = (new AlertDCFactory()).createDetectorCLAS(new DatabaseConstantProvider()); + Map tableMap = new HashMap<>(); + tableMap.put("/calibration/alert/ahdc/gains", 3); + requireConstants(tableMap); + this.getConstantsManager().setVariation("default"); + if(this.getEngineConfigString("Mode")!=null) { //if (Objects.equals(this.getEngineConfigString("Mode"), Mode.AI_Track_Finding.name())) // mode = Mode.AI_Track_Finding; @@ -140,6 +152,7 @@ public boolean processDataEvent(DataEvent event) { if (run.get() == 0 || (run.get() != 0 && run.get() != newRun)) { run.set(newRun); + ahdcAdcGains = this.getConstantsManager().getConstants(newRun, "/calibration/alert/ahdc/gains"); } //Do we need to read the event vx,vy,vz? @@ -190,7 +203,7 @@ public boolean processDataEvent(DataEvent event) { int layer_pred = (int) pred[1]; int wedge_pred = (int) pred[2]; - ATOFHit hit_pred = new ATOFHit(sector_pred, layer_pred, wedge_pred, 0, 0, 0, 0f, ATOF); + ATOFHit hit_pred = new ATOFHit(sector_pred, layer_pred, wedge_pred, 0, 0, 0, 0f, ATOF, null); double pred_x = hit_pred.getX(); double pred_y = hit_pred.getY(); double pred_z = hit_pred.getZ(); @@ -208,7 +221,7 @@ public boolean processDataEvent(DataEvent event) { int sector = bank_ATOFHits.getInt("sector", k); int layer = bank_ATOFHits.getInt("layer", k); - ATOFHit hit = new ATOFHit(sector, layer, component, 0, 0, 0, 0f, ATOF); + ATOFHit hit = new ATOFHit(sector, layer, component, 0, 0, 0, 0f, ATOF, null); double dx = pred_x - hit.getX(); double dy = pred_y - hit.getY(); @@ -346,6 +359,7 @@ public boolean processDataEvent(DataEvent event) { AHDC_hits.add(hit); } } + if (AHDC_hits.isEmpty()) continue; // It can happen that a track has no associated hit, in this case we skip it for the Kalman Filter AHDC_tracks.add(new Track(AHDC_hits)); // Initialise the position and the momentum using the information of the AHDC::track // position : mm diff --git a/reconstruction/alert/src/main/java/org/jlab/service/atof/ATOFEngine.java b/reconstruction/alert/src/main/java/org/jlab/service/atof/ATOFEngine.java index 4b847ff069..7e4974ef3a 100644 --- a/reconstruction/alert/src/main/java/org/jlab/service/atof/ATOFEngine.java +++ b/reconstruction/alert/src/main/java/org/jlab/service/atof/ATOFEngine.java @@ -12,14 +12,13 @@ import org.jlab.detector.calib.utils.DatabaseConstantProvider; import org.jlab.geom.base.Detector; import org.jlab.geom.detector.alert.ATOF.AlertTOFFactory; -import org.jlab.io.hipo.HipoDataSource; import org.jlab.rec.atof.banks.RecoBankWriter; import org.jlab.rec.atof.cluster.ATOFCluster; import org.jlab.rec.atof.cluster.ClusterFinder; import org.jlab.rec.atof.hit.ATOFHit; import org.jlab.rec.atof.hit.BarHit; import org.jlab.rec.atof.hit.HitFinder; -import org.jlab.rec.alert.constants.CalibrationConstantsLoader; +import org.jlab.utils.groups.IndexedTable; /** * Service to return reconstructed ATOF hits and clusters @@ -54,7 +53,13 @@ public Detector getATOF() { } int Run = -1; - + + // ATOF calibration tables (instance-level, refreshed on run change) + private IndexedTable atofEffectiveVelocity; + private IndexedTable atofTimeWalk; + private IndexedTable atofAttenuationLength; + private IndexedTable atofTimeOffsets; + @Override public boolean processDataEvent(DataEvent event) { if (!event.hasBank("RUN::config")) { @@ -80,11 +85,14 @@ public boolean processDataEvent(DataEvent event) { System.err.println("ATOFEngine: got run <= 0 in RUN::config, skipping event."); return false; } - int newRun = runNo; - // Load the constants + int newRun = runNo; if(Run!=newRun) { - CalibrationConstantsLoader.Load(newRun, this.getConstantsManager()); - } + atofEffectiveVelocity = this.getConstantsManager().getConstants(newRun, "/calibration/alert/atof/effective_velocity"); + atofTimeWalk = this.getConstantsManager().getConstants(newRun, "/calibration/alert/atof/time_walk"); + atofAttenuationLength = this.getConstantsManager().getConstants(newRun, "/calibration/alert/atof/attenuation"); + atofTimeOffsets = this.getConstantsManager().getConstants(newRun, "/calibration/alert/atof/time_offsets"); + Run = newRun; + } ////Do we need to read the event vx,vy,vz? ////If not, this part can be moved in the initialization of the engine. @@ -103,7 +111,7 @@ public boolean processDataEvent(DataEvent event) { //Hit finder init HitFinder hitfinder = new HitFinder(); - hitfinder.findHits(event, ATOF, startTime); + hitfinder.findHits(event, ATOF, startTime, atofTimeOffsets, atofEffectiveVelocity); ArrayList WedgeHits = hitfinder.getWedgeHits(); ArrayList BarHits = hitfinder.getBarHits(); //Exit if hit lists are empty @@ -131,26 +139,11 @@ public boolean init() { DatabaseConstantProvider cp = new DatabaseConstantProvider(11, "default"); this.ATOF = factory.createDetectorCLAS(cp); - String[] alertTables = new String[] { - "/calibration/alert/ahdc/time_offsets", - "/calibration/alert/ahdc/time_to_distance", - "/calibration/alert/ahdc/raw_hit_cuts", - "/calibration/alert/atof/effective_velocity", - "/calibration/alert/atof/time_walk", - "/calibration/alert/atof/attenuation", - "/calibration/alert/atof/time_offsets" - }; - Map tableMap = new HashMap<>(); - for (String table : alertTables) { - if (table.equals("/calibration/alert/atof/time_offsets") || - table.equals("/calibration/alert/atof/time_walk")) { - tableMap.put(table, 4); - } else { - tableMap.put(table, 3); - } - } - + tableMap.put("/calibration/alert/atof/effective_velocity", 3); + tableMap.put("/calibration/alert/atof/time_walk", 4); + tableMap.put("/calibration/alert/atof/attenuation", 3); + tableMap.put("/calibration/alert/atof/time_offsets", 4); requireConstants(tableMap); this.getConstantsManager().setVariation("default"); this.registerOutputBank("ATOF::hits", "ATOF::clusters");