From 7a6d90c0f7847a31269f9295774ddf48b9fd91f7 Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Fri, 17 Apr 2026 18:26:42 -0400 Subject: [PATCH 1/8] only once --- .../java/org/jlab/detector/decode/DetectorEventDecoder.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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..5f2a12f162 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 @@ -177,13 +177,14 @@ public void fitPulses(List detectorData){ tables.add(fitterManager.getConstants(runNumber, name)); } + 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; j Date: Fri, 17 Apr 2026 18:29:38 -0400 Subject: [PATCH 2/8] improve variable names --- .../detector/decode/DetectorEventDecoder.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) 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 5f2a12f162..a2da189e04 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 @@ -188,14 +188,14 @@ public void fitPulses(List detectorData){ boolean ismm = keysMicromega.contains(data.getDescriptor().getType()); for (int j=0; j detectorData){ // first one wins: break; } - else if(daq.hasEntryByHash(hash)==true){ - int nsa = daq.getIntValueByHash("nsa", hash); - int nsb = daq.getIntValueByHash("nsb", hash); - int tet = daq.getIntValueByHash("tet", hash); + else if(daqTable.hasEntryByHash(hash)==true){ + int nsa = daqTable.getIntValueByHash("nsa", hash); + int nsb = daqTable.getIntValueByHash("nsb", hash); + int tet = daqTable.getIntValueByHash("tet", hash); int ped = 0; - if(data.getDescriptor().getType() == DetectorType.RF && type == DetectorType.RF) { - ped = daq.getIntValueByHash("pedestal", hash); + if(data.getDescriptor().getType() == DetectorType.RF && tableType == DetectorType.RF) { + ped = daqTable.getIntValueByHash("pedestal", hash); } for(int i = 0; i < data.getADCSize(); i++){ ADCData adc = data.getADCData(i); From 5b210b11e4110364a4e74e8c0c4ac6c1541f8907 Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Fri, 17 Apr 2026 18:46:25 -0400 Subject: [PATCH 3/8] optimize fadc pulse table/detector lookup --- .../detector/decode/DetectorEventDecoder.java | 54 +++++++++---------- 1 file changed, 26 insertions(+), 28 deletions(-) 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 a2da189e04..39b6135b8f 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 @@ -169,7 +169,7 @@ public void translate(List detectorData){ } } - public void fitPulses(List detectorData){ + public void fitPulses(List detectorData) { // preload CCDB tables once: ArrayList tables = new ArrayList<>(); @@ -179,41 +179,41 @@ public void fitPulses(List detectorData){ final long hash0 = IndexedTable.DEFAULT_GENERATOR.hashCode(0,0,0); - for(DetectorDataDgtz data : detectorData){ + 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); - boolean ismm = keysMicromega.contains(data.getDescriptor().getType()); - - for (int j=0; j0){ try { @@ -230,8 +230,6 @@ else if(daqTable.hasEntryByHash(hash)==true){ } data.getADCData(i).setADC(nsa, nsb); } - // first one wins: - break; } } } From 85d7375e6dcf4e94bff8c6934feaa3e8e1e03bd4 Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Fri, 17 Apr 2026 18:59:59 -0400 Subject: [PATCH 4/8] cleanup, in prep for faster lookup --- .../jlab/detector/decode/DetectorEventDecoder.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) 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 39b6135b8f..55c1e4a69d 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 @@ -172,9 +172,9 @@ public void translate(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 (int i=0; i detectorData) { int channel = data.getDescriptor().getChannel(); DetectorType type = data.getDescriptor().getType(); - int idx = keysFitter.indexOf(type); - if (idx < 0) continue; - IndexedTable daqTable = tables.get(idx); + if (!keysFitter.contains(type)) continue; + IndexedTable daqTable = tables.get(type); if (keysMicromega.contains(type)) { short adcOffset = (short) daqTable.getDoubleValueByHash("adc_offset", hash0); From e8cf46ab36df31cf4c430d1407092b974e1bc903 Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Fri, 17 Apr 2026 19:35:00 -0400 Subject: [PATCH 5/8] switch to HashSets --- .../detector/decode/DetectorEventDecoder.java | 133 +++++++++--------- 1 file changed, 70 insertions(+), 63 deletions(-) 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 55c1e4a69d..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"); + + 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); - // 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}); + 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) { // preload CCDB tables once: HashMap tables = new HashMap<>(); - for (int i=0; i detectorData) { int channel = data.getDescriptor().getChannel(); DetectorType type = data.getDescriptor().getType(); - if (!keysFitter.contains(type)) continue; + if (!translations.containsKey(type)) continue; + IndexedTable daqTable = tables.get(type); if (keysMicromega.contains(type)) { From 17750fa767cebc779bb44cf4d613f8c093315700 Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Fri, 17 Apr 2026 19:58:51 -0400 Subject: [PATCH 6/8] bugfix --- .../jlab/detector/decode/DetectorEventDecoder.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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 285be05bae..c7cb9d195e 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 @@ -7,6 +7,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import org.jlab.detector.banks.RawBank.OrderType; import org.jlab.detector.base.DetectorType; import org.jlab.detector.calib.utils.ConstantsManager; @@ -131,9 +132,9 @@ public final void initDecoder(){ keysMicromega.add(DetectorType.FMT); keysMicromega.add(DetectorType.FTTRK); - translationManager.init((List)translations.values()); + translationManager.init(translations.values().stream().collect(Collectors.toList())); - fitterManager.init((List)fitters.values()); + fitterManager.init(fitters.values().stream().collect(Collectors.toList())); scalerManager.init(Arrays.asList(new String[]{"/runcontrol/fcup","/runcontrol/slm","/runcontrol/hwp", "/runcontrol/helicity","/daq/config/scalers/dsc1"})); @@ -141,7 +142,7 @@ public final void initDecoder(){ } public void checkTables() { - List tables = (List)translations.values(); + List tables = (List)translations.values().stream().collect(Collectors.toList()); for (int i=0; i detectorData) { // preload CCDB tables once: HashMap tables = new HashMap<>(); - for (DetectorType t : translations.keySet()) { - tables.put(t, fitterManager.getConstants(runNumber, translations.get(t))); + for (DetectorType t : fitters.keySet()) { + tables.put(t, fitterManager.getConstants(runNumber, fitters.get(t))); } final long hash0 = IndexedTable.DEFAULT_GENERATOR.hashCode(0,0,0); @@ -193,7 +194,7 @@ public void fitPulses(List detectorData) { int channel = data.getDescriptor().getChannel(); DetectorType type = data.getDescriptor().getType(); - if (!translations.containsKey(type)) continue; + if (!fitters.containsKey(type)) continue; IndexedTable daqTable = tables.get(type); From 64e26b05abf2d6219673e2203cad269c12b249ab Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Fri, 17 Apr 2026 21:20:31 -0400 Subject: [PATCH 7/8] cleanup --- .../detector/decode/DetectorEventDecoder.java | 137 +++++++++--------- 1 file changed, 67 insertions(+), 70 deletions(-) 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 c7cb9d195e..3eaa07994d 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 @@ -26,16 +26,18 @@ public class DetectorEventDecoder { HashSet keysFilter; HashSet keysMicromega; - HashMap translations; - HashMap fitters; - - private int runNumber = 10; - private ExtendedFADCFitter extendedFitter = new ExtendedFADCFitter(); - private MVTFitter mvtFitter = new MVTFitter(); + HashMap tableTrans; + HashMap tableFitter; + + HashMap tablesFitter; + TranslationTable translator; - private TranslationTable translator = new TranslationTable(); + ExtendedFADCFitter extendedFitter = new ExtendedFADCFitter(); + MVTFitter mvtFitter = new MVTFitter(); + int runNumber = 10; + public DetectorEventDecoder(boolean development){ this.initDecoder(); } @@ -55,9 +57,11 @@ public void setVariation(String variation) { public void setRunNumber(int run){ if (run != this.runNumber) { translator = new TranslationTable(); - for (DetectorType t : translations.keySet()) { - translator.add(t, translationManager.getConstants(run, translations.get(t))); - } + tablesFitter = new HashMap<>(); + for (DetectorType t : tableTrans.keySet()) + translator.add(t, translationManager.getConstants(run, tableTrans.get(t))); + for (DetectorType t: tableFitter.keySet()) + tablesFitter.put(t, fitterManager.getConstants(run, tableFitter.get(t))); } this.runNumber = run; } @@ -84,65 +88,64 @@ public final void initDecoder(){ keysFilter = new HashSet<>(); 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"); - - 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"); - + tableTrans = new HashMap<>(); + tableFitter = new HashMap<>(); + keysFilter.add(DetectorType.DC); keysMicromega.add(DetectorType.BMT); keysMicromega.add(DetectorType.FMT); - keysMicromega.add(DetectorType.FTTRK); - - translationManager.init(translations.values().stream().collect(Collectors.toList())); - - fitterManager.init(fitters.values().stream().collect(Collectors.toList())); + keysMicromega.add(DetectorType.FTTRK); + + tableTrans.put(DetectorType.FTCAL, "/daq/tt/ftcal"); + tableTrans.put(DetectorType.FTHODO, "/daq/tt/fthodo"); + tableTrans.put(DetectorType.FTTRK, "/daq/tt/fttrk"); + tableTrans.put(DetectorType.LTCC, "/daq/tt/ltcc"); + tableTrans.put(DetectorType.ECAL, "/daq/tt/ec"); + tableTrans.put(DetectorType.FTOF, "/daq/tt/ftof"); + tableTrans.put(DetectorType.HTCC, "/daq/tt/htcc"); + tableTrans.put(DetectorType.DC, "/daq/tt/dc"); + tableTrans.put(DetectorType.CTOF, "/daq/tt/ctof"); + tableTrans.put(DetectorType.CND, "/daq/tt/cnd"); + tableTrans.put(DetectorType.BST, "/daq/tt/svt"); + tableTrans.put(DetectorType.RF, "/daq/tt/rf"); + tableTrans.put(DetectorType.BMT, "/daq/tt/bmt"); + tableTrans.put(DetectorType.FMT, "/daq/tt/fmt"); + tableTrans.put(DetectorType.RICH, "/daq/tt/rich2"); + tableTrans.put(DetectorType.HEL, "/daq/tt/hel"); + tableTrans.put(DetectorType.BAND, "/daq/tt/band"); + tableTrans.put(DetectorType.RTPC, "/daq/tt/rtpc"); + tableTrans.put(DetectorType.RASTER, "/daq/tt/raster"); + tableTrans.put(DetectorType.ATOF, "/daq/tt/atof"); + tableTrans.put(DetectorType.AHDC, "/daq/tt/ahdc"); + translationManager.init(tableTrans.values().stream().collect(Collectors.toList())); + + tableFitter.put(DetectorType.FTCAL, "/daq/fadc/ftcal"); + tableFitter.put(DetectorType.FTHODO, "/daq/fadc/fthodo"); + tableFitter.put(DetectorType.FTTRK, "/daq/fadc/fttrk"); + tableFitter.put(DetectorType.FTOF, "/daq/fadc/ftof"); + tableFitter.put(DetectorType.LTCC, "/daq/fadc/ltcc"); + tableFitter.put(DetectorType.ECAL, "/daq/fadc/ec"); + tableFitter.put(DetectorType.HTCC, "/daq/fadc/htcc"); + tableFitter.put(DetectorType.CTOF, "/daq/fadc/ctof"); + tableFitter.put(DetectorType.CND, "/daq/fadc/cnd"); + tableFitter.put(DetectorType.BMT, "/daq/fadc/bmt"); + tableFitter.put(DetectorType.FMT, "/daq/fadc/fmt"); + tableFitter.put(DetectorType.HEL, "/daq/fadc/hel"); + tableFitter.put(DetectorType.RF, "/daq/fadc/rf"); + tableFitter.put(DetectorType.BAND, "/daq/fadc/band"); + tableFitter.put(DetectorType.RASTER, "/daq/fadc/raster"); + tableFitter.put(DetectorType.AHDC, "/daq/fadc/ahdc"); + fitterManager.init(tableFitter.values().stream().collect(Collectors.toList())); + + scalerManager.init(Arrays.asList(new String[]{"/runcontrol/fcup", + "/runcontrol/slm","/runcontrol/hwp","/runcontrol/helicity","/daq/config/scalers/dsc1"})); - scalerManager.init(Arrays.asList(new String[]{"/runcontrol/fcup","/runcontrol/slm","/runcontrol/hwp", - "/runcontrol/helicity","/daq/config/scalers/dsc1"})); checkTables(); } - public void checkTables() { - List tables = (List)translations.values().stream().collect(Collectors.toList()); + void checkTables() { + List tables = (List)tableTrans.values().stream().collect(Collectors.toList()); for (int i=0; i detectorData){ public void fitPulses(List detectorData) { - // preload CCDB tables once: - HashMap tables = new HashMap<>(); - for (DetectorType t : fitters.keySet()) { - tables.put(t, fitterManager.getConstants(runNumber, fitters.get(t))); - } - final long hash0 = IndexedTable.DEFAULT_GENERATOR.hashCode(0,0,0); for (DetectorDataDgtz data : detectorData) { @@ -194,9 +191,9 @@ public void fitPulses(List detectorData) { int channel = data.getDescriptor().getChannel(); DetectorType type = data.getDescriptor().getType(); - if (!fitters.containsKey(type)) continue; + if (!tableFitter.containsKey(type)) continue; - IndexedTable daqTable = tables.get(type); + IndexedTable daqTable = tablesFitter.get(type); if (keysMicromega.contains(type)) { short adcOffset = (short) daqTable.getDoubleValueByHash("adc_offset", hash0); @@ -242,7 +239,7 @@ public void fitPulses(List detectorData) { } } - public void filterTDCs(List detectorData){ + void filterTDCs(List detectorData){ int maxMultiplicity = 1; for(DetectorType type : keysFilter){ Map> filteredData = new HashMap<>(); From a475f7989e4b6fdc4dfa6aa5feccf5a9d540a827 Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Fri, 17 Apr 2026 21:35:19 -0400 Subject: [PATCH 8/8] cleanup --- .../detector/decode/DetectorEventDecoder.java | 34 ++++++++++++------- 1 file changed, 21 insertions(+), 13 deletions(-) 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 3eaa07994d..3fb4c7eb75 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 @@ -154,8 +154,9 @@ void checkTables() { } /** - * applies translation table to the digitized data to translate - * crate,slot channel to sector layer component. + * Apply CCDB /daq/tt translation tables to the digitized data to translate + * crate/slot/channel to sector/layer/component/order. + * * @param detectorData */ public void translate(List detectorData){ @@ -179,6 +180,11 @@ public void translate(List detectorData){ } } + /** + * Use CCDB /daq/fadc tables to convert waveforms to pulses. + * + * @param detectorData + */ public void fitPulses(List detectorData) { final long hash0 = IndexedTable.DEFAULT_GENERATOR.hashCode(0,0,0); @@ -186,15 +192,12 @@ public void fitPulses(List detectorData) { for (DetectorDataDgtz data : detectorData) { if (data.getADCSize() == 0) continue; - int crate = data.getDescriptor().getCrate(); - int slot = data.getDescriptor().getSlot(); - int channel = data.getDescriptor().getChannel(); - DetectorType type = data.getDescriptor().getType(); - if (!tableFitter.containsKey(type)) continue; - + DetectorType type = data.getDescriptor().getType(); + if (!tablesFitter.containsKey(type)) continue; IndexedTable daqTable = tablesFitter.get(type); - + + // For MM, assume crate/slot/channel=0/0/0 for table lookup: if (keysMicromega.contains(type)) { short adcOffset = (short) daqTable.getDoubleValueByHash("adc_offset", hash0); double fineTimeStampResolution = (byte) daqTable.getDoubleValueByHash("dream_clock", hash0); @@ -207,9 +210,14 @@ public void fitPulses(List detectorData) { adc.setIntegral((int) (mvtFitter.integral)); adc.setTimeStamp(mvtFitter.timestamp); } + + // Otherwise, use crate/slot/channel to find the table entry: else { - long hash = IndexedTable.DEFAULT_GENERATOR.hashCode(crate,slot,channel); - if (daqTable.hasEntryByHash(hash)==true){ + long hash = IndexedTable.DEFAULT_GENERATOR.hashCode( + data.getDescriptor().getCrate(), + data.getDescriptor().getSlot(), + data.getDescriptor().getChannel()); + if (daqTable.hasEntryByHash(hash)) { int nsa = daqTable.getIntValueByHash("nsa", hash); int nsb = daqTable.getIntValueByHash("nsb", hash); int tet = daqTable.getIntValueByHash("tet", hash); @@ -223,8 +231,8 @@ public void fitPulses(List detectorData) { try { extendedFitter.fit(nsa, nsb, tet, ped, adc.getPulseArray()); } catch (Exception e) { - System.out.println(">>>> error : fitting pulse " - + crate + " / " + slot + " / " + channel); + System.err.println(">>>> error : fitting pulse "+data.getDescriptor().getCrate()+ + " / "+data.getDescriptor().getSlot()+" / "+data.getDescriptor().getChannel()); } int adc_corrected = extendedFitter.adc + extendedFitter.ped*(nsa+nsb); adc.setHeight((short) this.extendedFitter.pulsePeakValue);