From bd5bccc0003c889bb2a05ba7e410edd4df41b8d0 Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Tue, 19 May 2026 14:20:21 -0400 Subject: [PATCH 1/7] switch from lists to sets/maps --- .../detector/decode/DetectorEventDecoder.java | 147 +++++++++++------- 1 file changed, 94 insertions(+), 53 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 ff8df013c1..4d39af5bb6 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,8 +4,10 @@ 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 java.util.stream.Collectors; import org.jlab.detector.banks.RawBank.OrderType; import org.jlab.detector.base.DetectorType; import org.jlab.detector.calib.utils.ConstantsManager; @@ -22,13 +24,12 @@ public class DetectorEventDecoder { ConstantsManager fitterManager = new ConstantsManager(); ConstantsManager scalerManager = new ConstantsManager(); - List tablesTrans = null; - List tablesFitter = null; + HashSet keysFilter; + HashSet keysMicromega; - List keysTrans = null; - List keysFitter = null; - List keysFilter = null; - List keysMicromega= null; + HashMap tableTrans; + HashMap tableFitter; + HashMap tablesFitter; private int runNumber = 10; @@ -71,8 +72,11 @@ public void setVariation(String variation) { public void setRunNumber(int run){ if (run != this.runNumber) { translator = new TranslationTable(); - for (int i=0; i(); + 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; } @@ -91,13 +95,26 @@ public float getRcdbSolenoidScale() { getValue()).floatValue(); } - public final void initDecoderDev(){ - keysTrans = Arrays.asList(new DetectorType[]{ DetectorType.HTCC,DetectorType.BST,DetectorType.RTPC} ); - tablesTrans = Arrays.asList(new String[]{ "/daq/tt/clasdev/htcc","/daq/tt/clasdev/svt","/daq/tt/clasdev/rtpc" }); - keysFitter = Arrays.asList(new DetectorType[]{DetectorType.HTCC}); - tablesFitter = Arrays.asList(new String[]{"/daq/fadc/clasdev/htcc"}); - translationManager.init(tablesTrans); - fitterManager.init(tablesFitter); + public DetectorEventDecoder(){ + this.initDecoder(); + } + + public final void initDecoderDev() { + + keysFilter = new HashSet<>(); + keysMicromega= new HashSet<>(); + tableTrans = new HashMap<>(); + tableFitter = new HashMap<>(); + keysFilter.add(DetectorType.DC); + + tableTrans.put(DetectorType.HTCC, "/daq/tt/clasdev/htcc"); + tableTrans.put(DetectorType.BST, "/daq/tt/clasdev/svt"); + tableTrans.put(DetectorType.RTPC, "/daq/tt/clasdev/rtpc"); + translationManager.init(tableTrans.values().stream().collect(Collectors.toList())); + + tableFitter.put(DetectorType.HTCC, "/daq/fadc/clasdev/htcc"); + 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"})); } @@ -108,35 +125,59 @@ public final void initDecoder() { public final void initDecoder(boolean initializeManagers){ - // Detector translation table - keysTrans = Arrays.asList(new DetectorType[]{DetectorType.FTCAL,DetectorType.FTHODO,DetectorType.FTTRK,DetectorType.LTCC,DetectorType.ECAL,DetectorType.FTOF, - DetectorType.HTCC,DetectorType.DC,DetectorType.CTOF,DetectorType.CND,DetectorType.BST,DetectorType.RF,DetectorType.BMT,DetectorType.FMT, - DetectorType.RICH,DetectorType.HEL,DetectorType.BAND,DetectorType.RTPC, - DetectorType.RASTER,DetectorType.ATOF,DetectorType.AHDC - }); - tablesTrans = Arrays.asList(new String[]{ - "/daq/tt/ftcal","/daq/tt/fthodo","/daq/tt/fttrk","/daq/tt/ltcc", - "/daq/tt/ec","/daq/tt/ftof","/daq/tt/htcc","/daq/tt/dc","/daq/tt/ctof","/daq/tt/cnd","/daq/tt/svt", - "/daq/tt/rf","/daq/tt/bmt","/daq/tt/fmt","/daq/tt/rich2","/daq/tt/hel","/daq/tt/band","/daq/tt/rtpc", - "/daq/tt/raster","/daq/tt/atof","/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" - }); - - // Data filter list - keysFilter = Arrays.asList(new DetectorType[]{DetectorType.DC}); - - keysMicromega = Arrays.asList(new DetectorType[]{DetectorType.BMT,DetectorType.FMT,DetectorType.FTTRK}); + keysFilter = new HashSet<>(); + keysMicromega= new HashSet<>(); + tableTrans = new HashMap<>(); + tableFitter = new HashMap<>(); + keysFilter.add(DetectorType.DC); + + keysMicromega.add(DetectorType.BMT); + keysMicromega.add(DetectorType.FMT); + 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"})); if (initializeManagers) { translationManager.init(tablesTrans); @@ -149,10 +190,11 @@ public final void initDecoder(boolean initializeManagers){ } public void checkTables() { - for (int i=0; i tables = (List)tableTrans.values().stream().collect(Collectors.toList()); + for (int i=0; i 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 (Map.Entry e : tableFitter.entrySet()) { + tables.put(e.getKey(), fitterManager.getConstants(runNumber, e.getValue())); } for(DetectorDataDgtz data : detectorData){ @@ -199,9 +241,8 @@ public void fitPulses(List detectorData){ long hash0 = IndexedTable.DEFAULT_GENERATOR.hashCode(0,0,0); boolean ismm = keysMicromega.contains(data.getDescriptor().getType()); - for (int j=0; j Date: Tue, 19 May 2026 14:43:44 -0400 Subject: [PATCH 2/7] cleanup --- .../detector/decode/DetectorEventDecoder.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 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 4d39af5bb6..8611f155b4 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 @@ -1,7 +1,6 @@ package org.jlab.detector.decode; import java.util.ArrayList; -import java.util.Arrays; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; @@ -105,18 +104,18 @@ public final void initDecoderDev() { keysMicromega= new HashSet<>(); tableTrans = new HashMap<>(); tableFitter = new HashMap<>(); + keysFilter.add(DetectorType.DC); tableTrans.put(DetectorType.HTCC, "/daq/tt/clasdev/htcc"); tableTrans.put(DetectorType.BST, "/daq/tt/clasdev/svt"); tableTrans.put(DetectorType.RTPC, "/daq/tt/clasdev/rtpc"); - translationManager.init(tableTrans.values().stream().collect(Collectors.toList())); tableFitter.put(DetectorType.HTCC, "/daq/fadc/clasdev/htcc"); + + translationManager.init(tableTrans.values().stream().collect(Collectors.toList())); 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("/runcontrol/slm","/runcontrol/hwp","/runcontrol/helicity","/daq/config/scalers/dsc1"); } public final void initDecoder() { @@ -156,7 +155,6 @@ public final void initDecoder(boolean initializeManagers){ 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"); @@ -174,10 +172,10 @@ public final void initDecoder(boolean initializeManagers){ tableFitter.put(DetectorType.BAND, "/daq/fadc/band"); tableFitter.put(DetectorType.RASTER, "/daq/fadc/raster"); tableFitter.put(DetectorType.AHDC, "/daq/fadc/ahdc"); + + translationManager.init(tableTrans.values().stream().collect(Collectors.toList())); 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("/runcontrol/slm","/runcontrol/hwp","/runcontrol/helicity","/daq/config/scalers/dsc1"); if (initializeManagers) { translationManager.init(tablesTrans); From ea0fe6fddea81f5c779b44eee678ca8f5c0f209f Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Fri, 22 May 2026 20:41:52 -0400 Subject: [PATCH 3/7] fix rebase mistake --- .../detector/decode/DetectorEventDecoder.java | 16 +++------------- 1 file changed, 3 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 8611f155b4..250a68b437 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 @@ -94,10 +94,6 @@ public float getRcdbSolenoidScale() { getValue()).floatValue(); } - public DetectorEventDecoder(){ - this.initDecoder(); - } - public final void initDecoderDev() { keysFilter = new HashSet<>(); @@ -173,18 +169,12 @@ public final void initDecoder(boolean initializeManagers){ tableFitter.put(DetectorType.RASTER, "/daq/fadc/raster"); tableFitter.put(DetectorType.AHDC, "/daq/fadc/ahdc"); - translationManager.init(tableTrans.values().stream().collect(Collectors.toList())); - fitterManager.init(tableFitter.values().stream().collect(Collectors.toList())); - scalerManager.init("/runcontrol/slm","/runcontrol/hwp","/runcontrol/helicity","/daq/config/scalers/dsc1"); - if (initializeManagers) { - translationManager.init(tablesTrans); - fitterManager.init(tablesFitter); - scalerManager.init(Arrays.asList(new String[]{"/runcontrol/fcup","/runcontrol/slm","/runcontrol/hwp", - "/runcontrol/helicity","/daq/config/scalers/dsc1"})); + translationManager.init(tableTrans.values().stream().collect(Collectors.toList())); + fitterManager.init(tableFitter.values().stream().collect(Collectors.toList())); + scalerManager.init("/runcontrol/slm","/runcontrol/hwp","/runcontrol/helicity","/daq/config/scalers/dsc1"); checkTables(); } - } public void checkTables() { From b723113dca5ba7d6582bc5767a070d339b49f9b8 Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Fri, 22 May 2026 20:45:26 -0400 Subject: [PATCH 4/7] cleanup --- .../jlab/detector/decode/DetectorEventDecoder.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 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 250a68b437..4cf3259636 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 @@ -214,13 +214,8 @@ public void translate(List detectorData){ public void fitPulses(List detectorData){ - // preload CCDB tables once: - HashMap tables = new HashMap<>(); - for (Map.Entry e : tableFitter.entrySet()) { - tables.put(e.getKey(), fitterManager.getConstants(runNumber, e.getValue())); - } + for (DetectorDataDgtz data : detectorData) { - for(DetectorDataDgtz data : detectorData){ if (data.getADCSize() == 0) continue; int crate = data.getDescriptor().getCrate(); int slot = data.getDescriptor().getSlot(); @@ -229,8 +224,9 @@ public void fitPulses(List detectorData){ long hash0 = IndexedTable.DEFAULT_GENERATOR.hashCode(0,0,0); boolean ismm = keysMicromega.contains(data.getDescriptor().getType()); - for (DetectorType type : tableFitter.keySet()) { - IndexedTable daq = tables.get(type); + for (DetectorType type : tablesFitter.keySet()) { + + IndexedTable daq = tablesFitter.get(type); //custom MM fitter if (ismm && data.getDescriptor().getType() == type) { short adcOffset = (short) daq.getDoubleValueByHash("adc_offset", hash0); From 4d4c50aba9b2be2cb5ca2dce11190d13d220adca Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Wed, 17 Jun 2026 17:31:04 -0400 Subject: [PATCH 5/7] fix ccdb table names --- .../org/jlab/detector/decode/DetectorEventDecoder.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 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 4cf3259636..4c39df058b 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,20 +154,20 @@ public final void initDecoder(boolean initializeManagers){ tableFitter.put(DetectorType.FTCAL, "/daq/fadc/ftcal"); tableFitter.put(DetectorType.FTHODO, "/daq/fadc/fthodo"); - tableFitter.put(DetectorType.FTTRK, "/daq/fadc/fttrk"); + tableFitter.put(DetectorType.FTTRK, "/daq/config/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.BMT, "/daq/config/bmt"); + tableFitter.put(DetectorType.FMT, "/daq/config/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"); + tableFitter.put(DetectorType.AHDC, "/daq/config/ahdc"); if (initializeManagers) { translationManager.init(tableTrans.values().stream().collect(Collectors.toList())); From 95c49f07d376da7b03f52edfefd52cb085b881cc Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Wed, 17 Jun 2026 17:53:02 -0400 Subject: [PATCH 6/7] bugfix --- .../java/org/jlab/detector/decode/DetectorEventDecoder.java | 2 +- 1 file changed, 1 insertion(+), 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 4c39df058b..483464ff2c 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,7 +172,7 @@ public final void initDecoder(boolean initializeManagers){ if (initializeManagers) { translationManager.init(tableTrans.values().stream().collect(Collectors.toList())); fitterManager.init(tableFitter.values().stream().collect(Collectors.toList())); - scalerManager.init("/runcontrol/slm","/runcontrol/hwp","/runcontrol/helicity","/daq/config/scalers/dsc1"); + scalerManager.init("/runcontrol/fcup","/runcontrol/slm","/runcontrol/hwp","/runcontrol/helicity","/daq/config/scalers/dsc1"); checkTables(); } } From 7ab5250d4b3ea112295cd732d87b595f192d3b98 Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Wed, 17 Jun 2026 21:31:30 -0400 Subject: [PATCH 7/7] regularize bookeeping variable names --- .../detector/decode/DetectorEventDecoder.java | 155 +++++++++--------- 1 file changed, 73 insertions(+), 82 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 483464ff2c..100b9111dc 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 @@ -23,20 +23,20 @@ public class DetectorEventDecoder { ConstantsManager fitterManager = new ConstantsManager(); ConstantsManager scalerManager = new ConstantsManager(); - HashSet keysFilter; - HashSet keysMicromega; + private final HashSet filterTypes = new HashSet<>(); + private final HashSet micromegaTypes = new HashSet<>(); - HashMap tableTrans; - HashMap tableFitter; - HashMap tablesFitter; - - private int runNumber = 10; - - private ExtendedFADCFitter extendedFitter = new ExtendedFADCFitter(); - private MVTFitter mvtFitter = new MVTFitter(); + private final HashMap transTableNames = new HashMap<>(); + private final HashMap fitterTableNames = new HashMap<>(); + private final ExtendedFADCFitter extendedFitter = new ExtendedFADCFitter(); + private final MVTFitter mvtFitter = new MVTFitter(); + + private HashMap fitterTables = new HashMap<>(); private TranslationTable translator = new TranslationTable(); + private int runNumber = 10; + public DetectorEventDecoder(boolean development){ if(development==true){ this.initDecoderDev(); @@ -71,11 +71,11 @@ public void setVariation(String variation) { public void setRunNumber(int run){ if (run != this.runNumber) { translator = new TranslationTable(); - 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))); + fitterTables = new HashMap<>(); + for (DetectorType t : transTableNames.keySet()) + translator.add(t, translationManager.getConstants(run, transTableNames.get(t))); + for (DetectorType t: fitterTableNames.keySet()) + fitterTables.put(t, fitterManager.getConstants(run, fitterTableNames.get(t))); } this.runNumber = run; } @@ -96,21 +96,16 @@ public float getRcdbSolenoidScale() { public final void initDecoderDev() { - keysFilter = new HashSet<>(); - keysMicromega= new HashSet<>(); - tableTrans = new HashMap<>(); - tableFitter = new HashMap<>(); - - keysFilter.add(DetectorType.DC); + filterTypes.add(DetectorType.DC); - tableTrans.put(DetectorType.HTCC, "/daq/tt/clasdev/htcc"); - tableTrans.put(DetectorType.BST, "/daq/tt/clasdev/svt"); - tableTrans.put(DetectorType.RTPC, "/daq/tt/clasdev/rtpc"); + transTableNames.put(DetectorType.HTCC, "/daq/tt/clasdev/htcc"); + transTableNames.put(DetectorType.BST, "/daq/tt/clasdev/svt"); + transTableNames.put(DetectorType.RTPC, "/daq/tt/clasdev/rtpc"); - tableFitter.put(DetectorType.HTCC, "/daq/fadc/clasdev/htcc"); + fitterTableNames.put(DetectorType.HTCC, "/daq/fadc/clasdev/htcc"); - translationManager.init(tableTrans.values().stream().collect(Collectors.toList())); - fitterManager.init(tableFitter.values().stream().collect(Collectors.toList())); + translationManager.init(transTableNames.values().stream().collect(Collectors.toList())); + fitterManager.init(fitterTableNames.values().stream().collect(Collectors.toList())); scalerManager.init("/runcontrol/slm","/runcontrol/hwp","/runcontrol/helicity","/daq/config/scalers/dsc1"); } @@ -120,65 +115,61 @@ public final void initDecoder() { public final void initDecoder(boolean initializeManagers){ - keysFilter = new HashSet<>(); - keysMicromega= new HashSet<>(); - tableTrans = new HashMap<>(); - tableFitter = new HashMap<>(); - keysFilter.add(DetectorType.DC); - - keysMicromega.add(DetectorType.BMT); - keysMicromega.add(DetectorType.FMT); - 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"); - - tableFitter.put(DetectorType.FTCAL, "/daq/fadc/ftcal"); - tableFitter.put(DetectorType.FTHODO, "/daq/fadc/fthodo"); - tableFitter.put(DetectorType.FTTRK, "/daq/config/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/config/bmt"); - tableFitter.put(DetectorType.FMT, "/daq/config/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/config/ahdc"); + filterTypes.add(DetectorType.DC); + + micromegaTypes.add(DetectorType.BMT); + micromegaTypes.add(DetectorType.FMT); + micromegaTypes.add(DetectorType.FTTRK); + + transTableNames.put(DetectorType.FTCAL, "/daq/tt/ftcal"); + transTableNames.put(DetectorType.FTHODO, "/daq/tt/fthodo"); + transTableNames.put(DetectorType.FTTRK, "/daq/tt/fttrk"); + transTableNames.put(DetectorType.LTCC, "/daq/tt/ltcc"); + transTableNames.put(DetectorType.ECAL, "/daq/tt/ec"); + transTableNames.put(DetectorType.FTOF, "/daq/tt/ftof"); + transTableNames.put(DetectorType.HTCC, "/daq/tt/htcc"); + transTableNames.put(DetectorType.DC, "/daq/tt/dc"); + transTableNames.put(DetectorType.CTOF, "/daq/tt/ctof"); + transTableNames.put(DetectorType.CND, "/daq/tt/cnd"); + transTableNames.put(DetectorType.BST, "/daq/tt/svt"); + transTableNames.put(DetectorType.RF, "/daq/tt/rf"); + transTableNames.put(DetectorType.BMT, "/daq/tt/bmt"); + transTableNames.put(DetectorType.FMT, "/daq/tt/fmt"); + transTableNames.put(DetectorType.RICH, "/daq/tt/rich2"); + transTableNames.put(DetectorType.HEL, "/daq/tt/hel"); + transTableNames.put(DetectorType.BAND, "/daq/tt/band"); + transTableNames.put(DetectorType.RTPC, "/daq/tt/rtpc"); + transTableNames.put(DetectorType.RASTER, "/daq/tt/raster"); + transTableNames.put(DetectorType.ATOF, "/daq/tt/atof"); + transTableNames.put(DetectorType.AHDC, "/daq/tt/ahdc"); + + fitterTableNames.put(DetectorType.FTCAL, "/daq/fadc/ftcal"); + fitterTableNames.put(DetectorType.FTHODO, "/daq/fadc/fthodo"); + fitterTableNames.put(DetectorType.FTTRK, "/daq/config/fttrk"); + fitterTableNames.put(DetectorType.FTOF, "/daq/fadc/ftof"); + fitterTableNames.put(DetectorType.LTCC, "/daq/fadc/ltcc"); + fitterTableNames.put(DetectorType.ECAL, "/daq/fadc/ec"); + fitterTableNames.put(DetectorType.HTCC, "/daq/fadc/htcc"); + fitterTableNames.put(DetectorType.CTOF, "/daq/fadc/ctof"); + fitterTableNames.put(DetectorType.CND, "/daq/fadc/cnd"); + fitterTableNames.put(DetectorType.BMT, "/daq/config/bmt"); + fitterTableNames.put(DetectorType.FMT, "/daq/config/fmt"); + fitterTableNames.put(DetectorType.HEL, "/daq/fadc/hel"); + fitterTableNames.put(DetectorType.RF, "/daq/fadc/rf"); + fitterTableNames.put(DetectorType.BAND, "/daq/fadc/band"); + fitterTableNames.put(DetectorType.RASTER, "/daq/fadc/raster"); + fitterTableNames.put(DetectorType.AHDC, "/daq/config/ahdc"); if (initializeManagers) { - translationManager.init(tableTrans.values().stream().collect(Collectors.toList())); - fitterManager.init(tableFitter.values().stream().collect(Collectors.toList())); + translationManager.init(transTableNames.values().stream().collect(Collectors.toList())); + fitterManager.init(fitterTableNames.values().stream().collect(Collectors.toList())); scalerManager.init("/runcontrol/fcup","/runcontrol/slm","/runcontrol/hwp","/runcontrol/helicity","/daq/config/scalers/dsc1"); checkTables(); } } public void checkTables() { - List tables = (List)tableTrans.values().stream().collect(Collectors.toList()); + List tables = (List)transTableNames.values().stream().collect(Collectors.toList()); for (int i=0; i detectorData){ 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()); + boolean ismm = micromegaTypes.contains(data.getDescriptor().getType()); - for (DetectorType type : tablesFitter.keySet()) { + for (DetectorType type : fitterTables.keySet()) { - IndexedTable daq = tablesFitter.get(type); + IndexedTable daq = fitterTables.get(type); //custom MM fitter if (ismm && data.getDescriptor().getType() == type) { short adcOffset = (short) daq.getDoubleValueByHash("adc_offset", hash0); @@ -276,7 +267,7 @@ else if(daq.hasEntryByHash(hash)==true){ public void filterTDCs(List detectorData){ int maxMultiplicity = 1; - for(DetectorType type : keysFilter){ + for(DetectorType type : filterTypes){ Map> filteredData = new HashMap<>(); for(DetectorDataDgtz data : detectorData){ if(data.getDescriptor().getType() == type) {