diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DetectorEventDecoder.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DetectorEventDecoder.java index 84ec0a6cf4..285be05bae 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DetectorEventDecoder.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DetectorEventDecoder.java @@ -4,6 +4,7 @@ import java.util.Arrays; import java.util.Comparator; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import org.jlab.detector.banks.RawBank.OrderType; @@ -22,14 +23,11 @@ public class DetectorEventDecoder { ConstantsManager fitterManager = new ConstantsManager(); ConstantsManager scalerManager = new ConstantsManager(); - List tablesTrans = null; - List tablesFitter = null; - - List keysTrans = null; - List keysFitter = null; - List keysFilter = null; - List keysMicromega= null; - + HashSet keysFilter; + HashSet keysMicromega; + HashMap translations; + HashMap fitters; + private int runNumber = 10; private ExtendedFADCFitter extendedFitter = new ExtendedFADCFitter(); @@ -38,11 +36,7 @@ public class DetectorEventDecoder { private TranslationTable translator = new TranslationTable(); public DetectorEventDecoder(boolean development){ - if(development==true){ - this.initDecoderDev(); - } else { - this.initDecoder(); - } + this.initDecoder(); } public void setTimestamp(String timestamp) { @@ -60,8 +54,9 @@ public void setVariation(String variation) { public void setRunNumber(int run){ if (run != this.runNumber) { translator = new TranslationTable(); - for (int i=0; i(); + keysMicromega= new HashSet<>(); + translations = new HashMap<>(); + fitters = new HashMap<>(); + + translations.put(DetectorType.FTCAL, "/daq/tt/ftcal"); + translations.put(DetectorType.FTHODO, "/daq/tt/fthodo"); + translations.put(DetectorType.FTTRK, "/daq/tt/fttrk"); + translations.put(DetectorType.LTCC, "/daq/tt/ltcc"); + translations.put(DetectorType.ECAL, "/daq/tt/ec"); + translations.put(DetectorType.FTOF, "/daq/tt/ftof"); + translations.put(DetectorType.HTCC, "/daq/tt/htcc"); + translations.put(DetectorType.DC, "/daq/tt/dc"); + translations.put(DetectorType.CTOF, "/daq/tt/ctof"); + translations.put(DetectorType.CND, "/daq/tt/cnd"); + translations.put(DetectorType.BST, "/daq/tt/svt"); + translations.put(DetectorType.RF, "/daq/tt/rf"); + translations.put(DetectorType.BMT, "/daq/tt/bmt"); + translations.put(DetectorType.FMT, "/daq/tt/fmt"); + translations.put(DetectorType.RICH, "/daq/tt/rich2"); + translations.put(DetectorType.HEL, "/daq/tt/hel"); + translations.put(DetectorType.BAND, "/daq/tt/band"); + translations.put(DetectorType.RTPC, "/daq/tt/rtpc"); + translations.put(DetectorType.RASTER, "/daq/tt/raster"); + translations.put(DetectorType.ATOF, "/daq/tt/atof"); + translations.put(DetectorType.AHDC, "/daq/tt/ahdc"); - // ADC waveform fitter translation table - keysFitter = Arrays.asList(new DetectorType[]{DetectorType.FTCAL,DetectorType.FTHODO,DetectorType.FTTRK,DetectorType.FTOF,DetectorType.LTCC, - DetectorType.ECAL,DetectorType.HTCC,DetectorType.CTOF,DetectorType.CND,DetectorType.BMT, - DetectorType.FMT,DetectorType.HEL,DetectorType.RF,DetectorType.BAND,DetectorType.RASTER, - DetectorType.AHDC}); - tablesFitter = Arrays.asList(new String[]{ - "/daq/fadc/ftcal","/daq/fadc/fthodo","/daq/config/fttrk","/daq/fadc/ftof","/daq/fadc/ltcc", - "/daq/fadc/ec", "/daq/fadc/htcc","/daq/fadc/ctof","/daq/fadc/cnd","/daq/config/bmt", - "/daq/config/fmt","/daq/fadc/hel","/daq/fadc/rf","/daq/fadc/band","/daq/fadc/raster", - "/daq/config/ahdc" - }); - fitterManager.init(tablesFitter); - - // Data filter list - keysFilter = Arrays.asList(new DetectorType[]{DetectorType.DC}); + fitters.put(DetectorType.FTCAL, "/daq/fadc/ftcal"); + fitters.put(DetectorType.FTHODO, "/daq/fadc/fthodo"); + fitters.put(DetectorType.FTTRK, "/daq/fadc/fttrk"); + fitters.put(DetectorType.FTOF, "/daq/fadc/ftof"); + fitters.put(DetectorType.LTCC, "/daq/fadc/ltcc"); + fitters.put(DetectorType.ECAL, "/daq/fadc/ec"); + fitters.put(DetectorType.HTCC, "/daq/fadc/htcc"); + fitters.put(DetectorType.CTOF, "/daq/fadc/ctof"); + fitters.put(DetectorType.CND, "/daq/fadc/cnd"); + fitters.put(DetectorType.BMT, "/daq/fadc/bmt"); + fitters.put(DetectorType.FMT, "/daq/fadc/fmt"); + fitters.put(DetectorType.HEL, "/daq/fadc/hel"); + fitters.put(DetectorType.RF, "/daq/fadc/rf"); + fitters.put(DetectorType.BAND, "/daq/fadc/band"); + fitters.put(DetectorType.RASTER, "/daq/fadc/raster"); + fitters.put(DetectorType.AHDC, "/daq/fadc/ahdc"); + + keysFilter.add(DetectorType.DC); + + keysMicromega.add(DetectorType.BMT); + keysMicromega.add(DetectorType.FMT); + keysMicromega.add(DetectorType.FTTRK); + + translationManager.init((List)translations.values()); + + fitterManager.init((List)fitters.values()); scalerManager.init(Arrays.asList(new String[]{"/runcontrol/fcup","/runcontrol/slm","/runcontrol/hwp", "/runcontrol/helicity","/daq/config/scalers/dsc1"})); - - keysMicromega = Arrays.asList(new DetectorType[]{DetectorType.BMT,DetectorType.FMT,DetectorType.FTTRK}); - checkTables(); } public void checkTables() { - for (int i=0; i tables = (List)translations.values(); + for (int i=0; i detectorData){ } } - public void fitPulses(List detectorData){ + public void fitPulses(List detectorData) { // preload CCDB tables once: - ArrayList tables = new ArrayList<>(); - for (String name : tablesFitter) { - tables.add(fitterManager.getConstants(runNumber, name)); + HashMap tables = new HashMap<>(); + for (DetectorType t : translations.keySet()) { + tables.put(t, fitterManager.getConstants(runNumber, translations.get(t))); } - for(DetectorDataDgtz data : detectorData){ + final long hash0 = IndexedTable.DEFAULT_GENERATOR.hashCode(0,0,0); + + for (DetectorDataDgtz data : detectorData) { + if (data.getADCSize() == 0) continue; int crate = data.getDescriptor().getCrate(); int slot = data.getDescriptor().getSlot(); int channel = data.getDescriptor().getChannel(); - long hash = IndexedTable.DEFAULT_GENERATOR.hashCode(crate,slot,channel); - long hash0 = IndexedTable.DEFAULT_GENERATOR.hashCode(0,0,0); - boolean ismm = keysMicromega.contains(data.getDescriptor().getType()); - - for (int j=0; j0){ try { @@ -229,8 +236,6 @@ else if(daq.hasEntryByHash(hash)==true){ } data.getADCData(i).setADC(nsa, nsb); } - // first one wins: - break; } } }