From eeaebac3be23f9299d8dc65c3580973b747f503a Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Fri, 8 Aug 2025 17:49:14 -0400 Subject: [PATCH 01/22] add access by hash --- .../org/jlab/utils/groups/IndexedList.java | 21 ++++++++++++++++ .../org/jlab/utils/groups/IndexedTable.java | 24 +++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/common-tools/clas-utils/src/main/java/org/jlab/utils/groups/IndexedList.java b/common-tools/clas-utils/src/main/java/org/jlab/utils/groups/IndexedList.java index e899909cbb..400eddf7c1 100644 --- a/common-tools/clas-utils/src/main/java/org/jlab/utils/groups/IndexedList.java +++ b/common-tools/clas-utils/src/main/java/org/jlab/utils/groups/IndexedList.java @@ -115,6 +115,16 @@ public boolean hasItem(int... index) { return this.collection.containsKey(code); } + /** + * Checks whether an item exists for the specified hash code. + * + * @param hash the hash code to look up + * @return true if an item exists at the index; false otherwise + */ + public boolean hasItem(long hash) { + return this.collection.containsKey(hash); + } + /** * Retrieves an item by its index. * @@ -129,6 +139,17 @@ public T getItem(int... index) { return this.collection.get(code); } + /** + * Retrieves an item by its hash. + * + * @param hash the hash to find + * @return the item with the hash, null if not found + */ + public T getItem(long hash){ + if (!this.collection.containsKey(hash)) return null; + return this.collection.get(hash); + } + /** * Clears items from the collection. */ diff --git a/common-tools/clas-utils/src/main/java/org/jlab/utils/groups/IndexedTable.java b/common-tools/clas-utils/src/main/java/org/jlab/utils/groups/IndexedTable.java index b052fda817..17b65d3274 100644 --- a/common-tools/clas-utils/src/main/java/org/jlab/utils/groups/IndexedTable.java +++ b/common-tools/clas-utils/src/main/java/org/jlab/utils/groups/IndexedTable.java @@ -79,6 +79,10 @@ public boolean hasEntry(int... index){ return this.entries.hasItem(index); } + public boolean hasEntry(long hash){ + return this.entries.hasItem(hash); + } + public final void setIndexName(int index, String name){ indexNames.set(index, name); } @@ -127,6 +131,26 @@ public void setDoubleValue(Double value, String item, int... index){ } } + public int getIntValue(String item, long hash) { + if (this.entries.hasItem(hash)) { + if (this.entryMap.containsKey(item)) { + int index = this.entryMap.get(item); + return this.entries.getItem(hash).getValue(index).intValue(); + } + } + return 0; + } + + public double getDoubleValue(String item, long hash) { + if (this.entries.hasItem(hash)) { + if (this.entryMap.containsKey(item)) { + int index = this.entryMap.get(item); + return this.entries.getItem(hash).getValue(index).doubleValue(); + } + } + return 0; + } + public int getIntValue(String item, int... index){ if(this.entries.hasItem(index)==false){ if(DEBUG_MODE>0) System.out.println( "[IndexedTable] ---> error.. entry does not exist"); From 7c5957f0c6a5bc070ffbf0e35036f9b011cfe877 Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Fri, 8 Aug 2025 17:51:06 -0400 Subject: [PATCH 02/22] use hash-based access in decoding --- .../detector/decode/DetectorEventDecoder.java | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 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 6ff468756e..3f8ef95934 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 @@ -10,6 +10,7 @@ import org.jlab.detector.base.DetectorType; import org.jlab.detector.calib.utils.ConstantsManager; import org.jlab.detector.decode.DetectorDataDgtz.ADCData; +import org.jlab.utils.groups.IndexedList.IndexGenerator; import org.jlab.utils.groups.IndexedTable; /** @@ -134,15 +135,16 @@ public void translate(List detectorData){ int crate = data.getDescriptor().getCrate(); int slot = data.getDescriptor().getSlot(); int channel = data.getDescriptor().getChannel(); + long hash = new IndexGenerator().hashCode(crate,slot,channel); for(String table : keysTrans){ IndexedTable tt = translationManager.getConstants(runNumber, table); DetectorType type = DetectorType.getType(table); - if(tt.hasEntry(crate,slot,channel)==true){ - int sector = tt.getIntValue("sector", crate,slot,channel); - int layer = tt.getIntValue("layer", crate,slot,channel); - int component = tt.getIntValue("component", crate,slot,channel); - int order = tt.getIntValue("order", crate,slot,channel); + if(tt.hasEntry(hash)==true){ + int sector = tt.getIntValue("sector", hash); + int layer = tt.getIntValue("layer", hash); + int component = tt.getIntValue("component", hash); + int order = tt.getIntValue("order", hash); data.getDescriptor().setSectorLayerComponent(sector, layer, component); data.getDescriptor().setOrder(order); @@ -164,6 +166,8 @@ public void fitPulses(List detectorData){ int crate = data.getDescriptor().getCrate(); int slot = data.getDescriptor().getSlot(); int channel = data.getDescriptor().getChannel(); + long hash = new IndexGenerator().hashCode(crate,slot,channel); + long hash0 = new IndexGenerator().hashCode(0,0,0); for(String table : keysFitter){ //custom MM fitter if( ( (table.equals("BMT"))&&(data.getDescriptor().getType().getName().equals("BMT")) ) @@ -171,10 +175,10 @@ public void fitPulses(List detectorData){ //|| ( (table.equals("AHDC"))&&(data.getDescriptor().getType().getName().equals("AHDC")) ) || ( (table.equals("FTTRK"))&&(data.getDescriptor().getType().getName().equals("FTTRK")) ) ){ IndexedTable daq = fitterManager.getConstants(runNumber, table); - short adcOffset = (short) daq.getDoubleValue("adc_offset", 0, 0, 0); - double fineTimeStampResolution = (byte) daq.getDoubleValue("dream_clock", 0, 0, 0); - double samplingTime = (byte) daq.getDoubleValue("sampling_time", 0, 0, 0); - int sparseSample = daq.getIntValue("sparse", 0, 0 ,0); + short adcOffset = (short) daq.getDoubleValue("adc_offset", hash0); + double fineTimeStampResolution = (byte) daq.getDoubleValue("dream_clock", hash0); + double samplingTime = (byte) daq.getDoubleValue("sampling_time", hash0); + int sparseSample = daq.getIntValue("sparse", hash0); if (data.getADCSize() > 0) { ADCData adc = data.getADCData(0); mvtFitter.fit(adcOffset, fineTimeStampResolution, samplingTime, adc.getPulseArray(), adc.getTimeStamp(), sparseSample); @@ -187,9 +191,9 @@ public void fitPulses(List detectorData){ IndexedTable daq = fitterManager.getConstants(runNumber, table); DetectorType type = DetectorType.getType(table); if(daq.hasEntry(crate,slot,channel)==true){ - int nsa = daq.getIntValue("nsa", crate,slot,channel); - int nsb = daq.getIntValue("nsb", crate,slot,channel); - int tet = daq.getIntValue("tet", crate,slot,channel); + int nsa = daq.getIntValue("nsa", hash); + int nsb = daq.getIntValue("nsb", hash); + int tet = daq.getIntValue("tet", hash); int ped = 0; if(table.equals("RF")&&data.getDescriptor().getType().getName().equals("RF")) ped = daq.getIntValue("pedestal", crate,slot,channel); if(data.getADCSize()>0){ From ac7d30eab31617c04bd94ff722b7af8506a2fab3 Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Fri, 8 Aug 2025 18:17:56 -0400 Subject: [PATCH 03/22] remove clas6 detectors --- .../src/main/java/org/jlab/detector/base/DetectorType.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorType.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorType.java index a19b4d2933..d56bb7d788 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorType.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorType.java @@ -36,10 +36,7 @@ public enum DetectorType { MAGNETS (101, "MAGNETS"), ECIN (110, "ECIN"), ECOUT (111, "ECOUT"), - ECTOT (112, "ECTOT"), - LAC (113, "LAC"), - SC (114, "SC"), - CC (115, "CC"); + ECTOT (112, "ECTOT"); private final int detectorId; private final String detectorName; From 46adcbb2c44623934b2980a87db7e28df41dccb8 Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Fri, 8 Aug 2025 18:19:34 -0400 Subject: [PATCH 04/22] add docs --- .../java/org/jlab/detector/base/DetectorType.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorType.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorType.java index d56bb7d788..60862ffa7d 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorType.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorType.java @@ -59,7 +59,7 @@ public String getName() { return detectorName; } - /** + /** * Returns the id number of the detector. * @return the id number of the detector */ @@ -67,6 +67,11 @@ public int getDetectorId() { return detectorId; } + /** + * Get type from string name + * @param name + * @return + */ public static DetectorType getType(String name) { name = name.trim(); for(DetectorType id: DetectorType.values()) @@ -74,6 +79,12 @@ public static DetectorType getType(String name) { return id; return UNDEFINED; } + + /** + * Get type from integer id + * @param detId + * @return + */ public static DetectorType getType(Integer detId) { for(DetectorType id: DetectorType.values()) From 46897b72f7751b8c2e23d8179109026a5763cf2d Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Fri, 8 Aug 2025 19:34:47 -0400 Subject: [PATCH 05/22] only if necessary --- .../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 3f8ef95934..07a49e9c0f 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 @@ -139,13 +139,13 @@ public void translate(List detectorData){ for(String table : keysTrans){ IndexedTable tt = translationManager.getConstants(runNumber, table); - DetectorType type = DetectorType.getType(table); if(tt.hasEntry(hash)==true){ int sector = tt.getIntValue("sector", hash); int layer = tt.getIntValue("layer", hash); int component = tt.getIntValue("component", hash); int order = tt.getIntValue("order", hash); + DetectorType type = DetectorType.getType(table); data.getDescriptor().setSectorLayerComponent(sector, layer, component); data.getDescriptor().setOrder(order); data.getDescriptor().setType(type); From eb12e5887dbd220172b3549112617bc1d9003a72 Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Fri, 8 Aug 2025 19:37:10 -0400 Subject: [PATCH 06/22] break loop upon first c/s/c-detector match --- .../java/org/jlab/detector/decode/DetectorEventDecoder.java | 5 +++++ 1 file changed, 5 insertions(+) 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 07a49e9c0f..5220bb14c7 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 @@ -138,7 +138,9 @@ public void translate(List detectorData){ long hash = new IndexGenerator().hashCode(crate,slot,channel); for(String table : keysTrans){ + IndexedTable tt = translationManager.getConstants(runNumber, table); + if(tt.hasEntry(hash)==true){ int sector = tt.getIntValue("sector", hash); int layer = tt.getIntValue("layer", hash); @@ -156,6 +158,9 @@ public void translate(List detectorData){ for(int i = 0; i < data.getTDCSize(); i++) { data.getTDCData(i).setOrder(order); } + + // crate/slot/channel must map to a unique detector: + break; } } } From 4b9c94e390d1f2e56381dfe01aad3f6d37e5036c Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Fri, 8 Aug 2025 19:45:41 -0400 Subject: [PATCH 07/22] use table-name-only initializer --- .../org/jlab/detector/decode/DetectorEventDecoder.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 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 5220bb14c7..d8e8ff05a5 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 @@ -81,8 +81,8 @@ public final void initDecoderDev(){ tablesTrans = Arrays.asList(new String[]{ "/daq/tt/clasdev/htcc","/daq/tt/clasdev/svt","/daq/tt/clasdev/rtpc" }); keysFitter = Arrays.asList(new String[]{"HTCC"}); tablesFitter = Arrays.asList(new String[]{"/daq/fadc/clasdev/htcc"}); - translationManager.init(keysTrans,tablesTrans); - fitterManager.init(keysFitter, tablesFitter); + translationManager.init(tablesTrans); + fitterManager.init(tablesFitter); scalerManager.init(Arrays.asList(new String[]{"/runcontrol/fcup","/runcontrol/slm","/runcontrol/hwp", "/runcontrol/helicity","/daq/config/scalers/dsc1"})); } @@ -101,7 +101,7 @@ public final void initDecoder(){ "/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" }); - translationManager.init(keysTrans,tablesTrans); + translationManager.init(tablesTrans); // ADC waveform fitter translation table keysFitter = Arrays.asList(new String[]{"FTCAL","FTHODO","FTTRK","FTOF","LTCC", @@ -114,7 +114,7 @@ public final void initDecoder(){ "/daq/config/fmt","/daq/fadc/hel","/daq/fadc/rf","/daq/fadc/band","/daq/fadc/raster", "/daq/config/ahdc" }); - fitterManager.init(keysFitter, tablesFitter); + fitterManager.init(tablesFitter); // Data filter list keysFilter = Arrays.asList(new String[]{"DC"}); @@ -138,7 +138,6 @@ public void translate(List detectorData){ long hash = new IndexGenerator().hashCode(crate,slot,channel); for(String table : keysTrans){ - IndexedTable tt = translationManager.getConstants(runNumber, table); if(tt.hasEntry(hash)==true){ From b6ab624fd1ddccce58b6afb7674bbe5e39a15b6e Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Fri, 8 Aug 2025 20:08:04 -0400 Subject: [PATCH 08/22] use DetectorType instead of String, preload tables once --- .../detector/decode/DetectorEventDecoder.java | 83 +++++++++++-------- 1 file changed, 48 insertions(+), 35 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 d8e8ff05a5..2b9436accf 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 @@ -24,10 +24,11 @@ public class DetectorEventDecoder { ConstantsManager scalerManager = new ConstantsManager(); List tablesTrans = null; - List keysTrans = null; List tablesFitter = null; - List keysFitter = null; - List keysFilter = null; + + List keysTrans = null; + List keysFitter = null; + List keysFilter = null; private int runNumber = 10; @@ -77,9 +78,9 @@ public DetectorEventDecoder(){ } public final void initDecoderDev(){ - keysTrans = Arrays.asList(new String[]{ "HTCC","BST","RTPC"} ); + 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 String[]{"HTCC"}); + keysFitter = Arrays.asList(new DetectorType[]{DetectorType.HTCC}); tablesFitter = Arrays.asList(new String[]{"/daq/fadc/clasdev/htcc"}); translationManager.init(tablesTrans); fitterManager.init(tablesFitter); @@ -90,10 +91,10 @@ public final void initDecoderDev(){ public final void initDecoder(){ // Detector translation table - keysTrans = Arrays.asList(new String[]{"FTCAL","FTHODO","FTTRK","LTCC","ECAL","FTOF", - "HTCC","DC","CTOF","CND","BST","RF","BMT","FMT", - "RICH","HEL","BAND","RTPC", - "RASTER","ATOF","AHDC" + 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", @@ -104,10 +105,10 @@ public final void initDecoder(){ translationManager.init(tablesTrans); // ADC waveform fitter translation table - keysFitter = Arrays.asList(new String[]{"FTCAL","FTHODO","FTTRK","FTOF","LTCC", - "ECAL","HTCC","CTOF","CND","BMT", - "FMT","HEL","RF","BAND","RASTER", - "AHDC"}); + 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", @@ -117,7 +118,7 @@ public final void initDecoder(){ fitterManager.init(tablesFitter); // Data filter list - keysFilter = Arrays.asList(new String[]{"DC"}); + keysFilter = Arrays.asList(new DetectorType[]{DetectorType.DC}); scalerManager.init(Arrays.asList(new String[]{"/runcontrol/fcup","/runcontrol/slm","/runcontrol/hwp", "/runcontrol/helicity","/daq/config/scalers/dsc1"})); @@ -130,6 +131,12 @@ public final void initDecoder(){ */ public void translate(List detectorData){ + // preload CCDB tables once: + ArrayList tables = new ArrayList<>(); + for (String name : tablesTrans) { + tables.add(translationManager.getConstants(runNumber, name)); + } + for(DetectorDataDgtz data : detectorData){ int crate = data.getDescriptor().getCrate(); @@ -137,19 +144,19 @@ public void translate(List detectorData){ int channel = data.getDescriptor().getChannel(); long hash = new IndexGenerator().hashCode(crate,slot,channel); - for(String table : keysTrans){ - IndexedTable tt = translationManager.getConstants(runNumber, table); + for (int j=0; j detectorData){ } public void fitPulses(List detectorData){ + + // preload CCDB tables once: + ArrayList tables = new ArrayList<>(); + for (String name : tablesFitter) { + tables.add(fitterManager.getConstants(runNumber, name)); + } + for(DetectorDataDgtz data : detectorData){ int crate = data.getDescriptor().getCrate(); int slot = data.getDescriptor().getSlot(); int channel = data.getDescriptor().getChannel(); long hash = new IndexGenerator().hashCode(crate,slot,channel); long hash0 = new IndexGenerator().hashCode(0,0,0); - for(String table : keysFitter){ + for (int j=0; j detectorData){ adc.setTimeStamp(mvtFitter.timestamp); } } else { - IndexedTable daq = fitterManager.getConstants(runNumber, table); - DetectorType type = DetectorType.getType(table); - if(daq.hasEntry(crate,slot,channel)==true){ + if(daq.hasEntry(hash)==true){ int nsa = daq.getIntValue("nsa", hash); int nsb = daq.getIntValue("nsb", hash); int tet = daq.getIntValue("tet", hash); int ped = 0; - if(table.equals("RF")&&data.getDescriptor().getType().getName().equals("RF")) ped = daq.getIntValue("pedestal", crate,slot,channel); + if(type == DetectorType.RF&&data.getDescriptor().getType().getName().equals("RF")) ped = daq.getIntValue("pedestal", crate,slot,channel); if(data.getADCSize()>0){ for(int i = 0; i < data.getADCSize(); i++){ ADCData adc = data.getADCData(i); @@ -232,10 +245,10 @@ public void fitPulses(List detectorData){ public void filterTDCs(List detectorData){ int maxMultiplicity = 1; - for(String table : keysFilter){ + for(DetectorType type : keysFilter){ Map> filteredData = new HashMap<>(); for(DetectorDataDgtz data : detectorData){ - if(data.getDescriptor().getType()==DetectorType.getType(table)) { + if(data.getDescriptor().getType() == type) { int key = data.getDescriptor().getHashCode(); if(!filteredData.containsKey(key)) filteredData.put(key, new ArrayList<>()); From 71968d5154feb87b993ac897b06f232526757cf9 Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Fri, 8 Aug 2025 20:09:20 -0400 Subject: [PATCH 09/22] remove clas6 detectors --- .../src/main/java/org/jlab/detector/base/DetectorType.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorType.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorType.java index 60862ffa7d..b08b0801ef 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorType.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorType.java @@ -33,10 +33,7 @@ public enum DetectorType { ATOF (25, "ATOF"), RECOIL (26, "RECOIL"), TARGET (100, "TARGET"), - MAGNETS (101, "MAGNETS"), - ECIN (110, "ECIN"), - ECOUT (111, "ECOUT"), - ECTOT (112, "ECTOT"); + MAGNETS (101, "MAGNETS"); private final int detectorId; private final String detectorName; From 9d158c13adeaba49388db515d08c285ab30c09fa Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Fri, 8 Aug 2025 21:31:38 -0400 Subject: [PATCH 10/22] change hash accessor names (workaround long->int... precedence) --- .../detector/decode/DetectorEventDecoder.java | 26 +++++++++---------- .../org/jlab/utils/groups/IndexedList.java | 4 +-- .../org/jlab/utils/groups/IndexedTable.java | 16 ++++++------ 3 files changed, 23 insertions(+), 23 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 2b9436accf..2ea433af7a 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 @@ -148,11 +148,11 @@ public void translate(List detectorData){ IndexedTable table = tables.get(j); - if(table.hasEntry(hash)==true){ - int sector = table.getIntValue("sector", hash); - int layer = table.getIntValue("layer", hash); - int component = table.getIntValue("component", hash); - int order = table.getIntValue("order", hash); + if(table.hasEntryByHash(hash)==true){ + int sector = table.getIntValueByHash("sector", hash); + int layer = table.getIntValueByHash("layer", hash); + int component = table.getIntValueByHash("component", hash); + int order = table.getIntValueByHash("order", hash); data.getDescriptor().setSectorLayerComponent(sector, layer, component); data.getDescriptor().setOrder(order); @@ -194,10 +194,10 @@ public void fitPulses(List detectorData){ || ( (type == DetectorType.FMT)&&(data.getDescriptor().getType().getName().equals("FMT")) ) //|| ( (type == DetectorType.AHDC)&&(data.getDescriptor().getType().getName().equals("AHDC")) ) || ( (type == DetectorType.FTTRK)&&(data.getDescriptor().getType().getName().equals("FTTRK")) ) ){ - short adcOffset = (short) daq.getDoubleValue("adc_offset", hash0); - double fineTimeStampResolution = (byte) daq.getDoubleValue("dream_clock", hash0); - double samplingTime = (byte) daq.getDoubleValue("sampling_time", hash0); - int sparseSample = daq.getIntValue("sparse", hash0); + short adcOffset = (short) daq.getDoubleValueByHash("adc_offset", hash0); + double fineTimeStampResolution = (byte) daq.getDoubleValueByHash("dream_clock", hash0); + double samplingTime = (byte) daq.getDoubleValueByHash("sampling_time", hash0); + int sparseSample = daq.getIntValueByHash("sparse", hash0); if (data.getADCSize() > 0) { ADCData adc = data.getADCData(0); mvtFitter.fit(adcOffset, fineTimeStampResolution, samplingTime, adc.getPulseArray(), adc.getTimeStamp(), sparseSample); @@ -207,10 +207,10 @@ public void fitPulses(List detectorData){ adc.setTimeStamp(mvtFitter.timestamp); } } else { - if(daq.hasEntry(hash)==true){ - int nsa = daq.getIntValue("nsa", hash); - int nsb = daq.getIntValue("nsb", hash); - int tet = daq.getIntValue("tet", hash); + if(daq.hasEntryByHash(hash)==true){ + int nsa = daq.getIntValueByHash("nsa", hash); + int nsb = daq.getIntValueByHash("nsb", hash); + int tet = daq.getIntValueByHash("tet", hash); int ped = 0; if(type == DetectorType.RF&&data.getDescriptor().getType().getName().equals("RF")) ped = daq.getIntValue("pedestal", crate,slot,channel); if(data.getADCSize()>0){ diff --git a/common-tools/clas-utils/src/main/java/org/jlab/utils/groups/IndexedList.java b/common-tools/clas-utils/src/main/java/org/jlab/utils/groups/IndexedList.java index 400eddf7c1..e23f799f83 100644 --- a/common-tools/clas-utils/src/main/java/org/jlab/utils/groups/IndexedList.java +++ b/common-tools/clas-utils/src/main/java/org/jlab/utils/groups/IndexedList.java @@ -121,7 +121,7 @@ public boolean hasItem(int... index) { * @param hash the hash code to look up * @return true if an item exists at the index; false otherwise */ - public boolean hasItem(long hash) { + public boolean hasItemByHash(long hash) { return this.collection.containsKey(hash); } @@ -145,7 +145,7 @@ public T getItem(int... index) { * @param hash the hash to find * @return the item with the hash, null if not found */ - public T getItem(long hash){ + public T getItemByHash(long hash){ if (!this.collection.containsKey(hash)) return null; return this.collection.get(hash); } diff --git a/common-tools/clas-utils/src/main/java/org/jlab/utils/groups/IndexedTable.java b/common-tools/clas-utils/src/main/java/org/jlab/utils/groups/IndexedTable.java index 17b65d3274..616d827ddd 100644 --- a/common-tools/clas-utils/src/main/java/org/jlab/utils/groups/IndexedTable.java +++ b/common-tools/clas-utils/src/main/java/org/jlab/utils/groups/IndexedTable.java @@ -79,8 +79,8 @@ public boolean hasEntry(int... index){ return this.entries.hasItem(index); } - public boolean hasEntry(long hash){ - return this.entries.hasItem(hash); + public boolean hasEntryByHash(long hash){ + return this.entries.hasItemByHash(hash); } public final void setIndexName(int index, String name){ @@ -131,21 +131,21 @@ public void setDoubleValue(Double value, String item, int... index){ } } - public int getIntValue(String item, long hash) { - if (this.entries.hasItem(hash)) { + public int getIntValueByHash(String item, long hash) { + if (this.entries.hasItemByHash(hash)) { if (this.entryMap.containsKey(item)) { int index = this.entryMap.get(item); - return this.entries.getItem(hash).getValue(index).intValue(); + return this.entries.getItemByHash(hash).getValue(index).intValue(); } } return 0; } - public double getDoubleValue(String item, long hash) { - if (this.entries.hasItem(hash)) { + public double getDoubleValueByHash(String item, long hash) { + if (this.entries.hasItemByHash(hash)) { if (this.entryMap.containsKey(item)) { int index = this.entryMap.get(item); - return this.entries.getItem(hash).getValue(index).doubleValue(); + return this.entries.getItemByHash(hash).getValue(index).doubleValue(); } } return 0; From b336964fdf728e30639cdc48778a9f3f40048ff4 Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Thu, 14 Aug 2025 14:28:58 -0400 Subject: [PATCH 11/22] 10k events per decoder test job --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 15cd747565..4fb14a62f0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -128,7 +128,7 @@ jobs: - name: run test run: | xrdcp xroot://sci-xrootd.jlab.org///osgpool/hallb/clas12/validation/clas_005038.evio.00000 . - ./coatjava/bin/decoder -n 100000 -o dog.hipo ./clas_005038.evio.00000 + ./coatjava/bin/decoder -n 10000 -o dog.hipo ./clas_005038.evio.00000 test_coatjava: needs: [ build ] From 4a08909c34f0b2e3b97e486be008a0a9fe8a065a Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Thu, 21 Aug 2025 10:00:52 -0400 Subject: [PATCH 12/22] add a static for speed --- .../src/main/java/org/jlab/utils/groups/IndexedTable.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common-tools/clas-utils/src/main/java/org/jlab/utils/groups/IndexedTable.java b/common-tools/clas-utils/src/main/java/org/jlab/utils/groups/IndexedTable.java index 616d827ddd..d39ef0fb7a 100644 --- a/common-tools/clas-utils/src/main/java/org/jlab/utils/groups/IndexedTable.java +++ b/common-tools/clas-utils/src/main/java/org/jlab/utils/groups/IndexedTable.java @@ -20,6 +20,8 @@ */ public class IndexedTable extends DefaultTableModel { + public static final IndexGenerator DEFAULT_GENERATOR = new IndexGenerator(); + private IndexedList entries = null; private Map entryMap = new LinkedHashMap<>(); private Map entryTypes = new LinkedHashMap<>(); From 6f0fade21e712690fb6a7375daa9202616c325ba Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Thu, 21 Aug 2025 10:01:17 -0400 Subject: [PATCH 13/22] speedup swap table initialization --- .../main/java/org/jlab/detector/swaps/SwapTable.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/swaps/SwapTable.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/swaps/SwapTable.java index d9c76f7e02..71edf4ecb5 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/swaps/SwapTable.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/swaps/SwapTable.java @@ -73,17 +73,18 @@ public SwapTable(IndexedTable fromTrans,IndexedTable toTrans) { for (int row=0; row Date: Thu, 21 Aug 2025 10:01:41 -0400 Subject: [PATCH 14/22] use default (static) generator --- .../jlab/detector/decode/DetectorEventDecoder.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 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 2ea433af7a..72bdfe10fc 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 @@ -10,7 +10,6 @@ import org.jlab.detector.base.DetectorType; import org.jlab.detector.calib.utils.ConstantsManager; import org.jlab.detector.decode.DetectorDataDgtz.ADCData; -import org.jlab.utils.groups.IndexedList.IndexGenerator; import org.jlab.utils.groups.IndexedTable; /** @@ -142,7 +141,7 @@ public void translate(List detectorData){ int crate = data.getDescriptor().getCrate(); int slot = data.getDescriptor().getSlot(); int channel = data.getDescriptor().getChannel(); - long hash = new IndexGenerator().hashCode(crate,slot,channel); + long hash = IndexedTable.DEFAULT_GENERATOR.hashCode(crate,slot,channel); for (int j=0; j detectorData){ int crate = data.getDescriptor().getCrate(); int slot = data.getDescriptor().getSlot(); int channel = data.getDescriptor().getChannel(); - long hash = new IndexGenerator().hashCode(crate,slot,channel); - long hash0 = new IndexGenerator().hashCode(0,0,0); + long hash = IndexedTable.DEFAULT_GENERATOR.hashCode(crate,slot,channel); + long hash0 = IndexedTable.DEFAULT_GENERATOR.hashCode(0,0,0); for (int j=0; j detectorData){ int nsb = daq.getIntValueByHash("nsb", hash); int tet = daq.getIntValueByHash("tet", hash); int ped = 0; - if(type == DetectorType.RF&&data.getDescriptor().getType().getName().equals("RF")) ped = daq.getIntValue("pedestal", crate,slot,channel); + if(type == DetectorType.RF&&data.getDescriptor().getType().getName().equals("RF")) { + ped = daq.getIntValueByHash("pedestal", hash); + } if(data.getADCSize()>0){ for(int i = 0; i < data.getADCSize(); i++){ ADCData adc = data.getADCData(i); From fd279c6eb9b47705202b37d1a33b8e4f96d4bc2d Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Thu, 21 Aug 2025 10:14:25 -0400 Subject: [PATCH 15/22] more less hashing --- .../java/org/jlab/rec/dc/banks/HitReader.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/banks/HitReader.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/banks/HitReader.java index 716a5980f0..eaa35990c4 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/banks/HitReader.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/banks/HitReader.java @@ -13,7 +13,6 @@ import org.jlab.rec.dc.hit.Hit; import org.jlab.rec.dc.timetodistance.TimeToDistanceEstimator; -import org.jlab.clas.swimtools.Swimmer; import org.jlab.detector.banks.RawBank.OrderType; import org.jlab.detector.banks.RawDataBank; import org.jlab.detector.calib.utils.ConstantsManager; @@ -55,8 +54,6 @@ public class HitReader { private List _HBHits; //hit-based tracking hit information private List _TBHits; //time-based tracking hit information - private final double timeBuf = 25.0; - private static final Logger LOGGER = Logger.getLogger(HitReader.class.getName()); public HitReader(Banks names, DCGeant4Factory detector) { @@ -113,9 +110,10 @@ public List get_TBHits() { private int getTIJitter() { int jitter = 0; if (tiTimeStamp>=0 && timejitter!=null) { - double period = timejitter.getDoubleValue("period", 0, 0, 0); - int phase = timejitter.getIntValue("phase", 0, 0, 0); - int cycles = timejitter.getIntValue("cycles", 0, 0, 0); + long hash = IndexedTable.DEFAULT_GENERATOR.hashCode(0,0,0); + double period = timejitter.getDoubleValueByHash("period", hash); + int phase = timejitter.getIntValueByHash("phase", hash); + int cycles = timejitter.getIntValueByHash("cycles", hash); if (cycles > 0) jitter = (int) (period * ((tiTimeStamp + phase) % cycles)); } @@ -149,10 +147,11 @@ private int getDCRBJitter(int sector, int layer, int wire, int order) { int jitter = 0; if(dcrbjitters!=null && reverseTT!=null) { - if(!reverseTT.hasEntry(sector, layer, wire, order)) + long hash = IndexedTable.DEFAULT_GENERATOR.hashCode(sector, layer, wire, order); + if(!reverseTT.hasEntryByHash(hash)) LOGGER.log(Level.SEVERE, "Missing TT entry for slco = " + sector + " " + layer + " " + wire + " " + order); - int crate = reverseTT.getIntValue("crate", sector, layer, wire, order); - int slot = reverseTT.getIntValue("slot", sector, layer, wire, order); + int crate = reverseTT.getIntValueByHash("crate", hash); + int slot = reverseTT.getIntValueByHash("slot", hash); if(!dcrbjitters.hasEntry(crate, slot)) LOGGER.log(Level.SEVERE, "Missing DC::jitter entry for crate/slot = " + crate + "/" + slot); jitter = dcrbjitters.getIntValue("jitter", crate, slot); @@ -208,8 +207,9 @@ public void fetch_DCHits(DataEvent event) { double timeCutMax = 0; int region = ((superlayer + 1) / 2); - timeCutMin = tdccuts.getIntValue("min", 0, region, wire); - timeCutMax = tdccuts.getIntValue("max", 0, region, wire); + long hash = IndexedTable.DEFAULT_GENERATOR.hashCode(0,region,wire); + timeCutMin = tdccuts.getIntValueByHash("min", hash); + timeCutMax = tdccuts.getIntValueByHash("max", hash); boolean passTimingCut = false; From 228dc8b97fe6f462559e26908555d07abd1aee39 Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Thu, 21 Aug 2025 10:19:51 -0400 Subject: [PATCH 16/22] speedup initialization --- .../rec/dc/timetodistance/TableLoader.java | 66 ++++++++++--------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/timetodistance/TableLoader.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/timetodistance/TableLoader.java index 1309a42012..5ba2bdb38d 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/timetodistance/TableLoader.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/timetodistance/TableLoader.java @@ -4,7 +4,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.logging.Level; import java.util.logging.Logger; import org.jlab.detector.base.DetectorType; import org.jlab.detector.base.GeometryFactory; @@ -263,40 +262,43 @@ public static synchronized void getConstants(IndexedTable t2dPressure, IndexedTa for(int s = 0; s<6; s++ ){ // loop over sectors for(int r = 0; r<6; r++ ){ //loop over slys + + long hash = IndexedTable.DEFAULT_GENERATOR.hashCode(s+1,r+1,0); + // Fill constants - FracDmaxAtMinVel[s][r] = t2dPressure.getDoubleValue("c1_a0", s+1,r+1,0) - +t2dPressure.getDoubleValue("c1_a1", s+1,r+1,0)*dp*dpscale; - v0[s][r] = t2dPressure.getDoubleValue("v0_a0", s+1,r+1,0) - +t2dPressure.getDoubleValue("v0_a1", s+1,r+1,0)*dp*dpscale - +t2dPressure.getDoubleValue("v0_a2", s+1,r+1,0)*dp*dp*dp2scale; - vmid[s][r] = t2dPressure.getDoubleValue("vmid_a0", s+1,r+1,0) - +t2dPressure.getDoubleValue("vmid_a1", s+1,r+1,0)*dp*dpscale - +t2dPressure.getDoubleValue("vmid_a2", s+1,r+1,0)*dp*dp*dp2scale; - distbeta[s][r] = t2dPressure.getDoubleValue("distbeta_a0", s+1,r+1,0) - +t2dPressure.getDoubleValue("distbeta_a1", s+1,r+1,0)*dp*dpscale - +t2dPressure.getDoubleValue("distbeta_a2", s+1,r+1,0)*dp*dp*dp2scale; + FracDmaxAtMinVel[s][r] = t2dPressure.getDoubleValueByHash("c1_a0", hash) + +t2dPressure.getDoubleValueByHash("c1_a1", hash)*dp*dpscale; + v0[s][r] = t2dPressure.getDoubleValueByHash("v0_a0", hash) + +t2dPressure.getDoubleValueByHash("v0_a1", hash)*dp*dpscale + +t2dPressure.getDoubleValueByHash("v0_a2", hash)*dp*dp*dp2scale; + vmid[s][r] = t2dPressure.getDoubleValueByHash("vmid_a0", hash) + +t2dPressure.getDoubleValueByHash("vmid_a1", hash)*dp*dpscale + +t2dPressure.getDoubleValueByHash("vmid_a2", hash)*dp*dp*dp2scale; + distbeta[s][r] = t2dPressure.getDoubleValueByHash("distbeta_a0", hash) + +t2dPressure.getDoubleValueByHash("distbeta_a1", hash)*dp*dpscale + +t2dPressure.getDoubleValueByHash("distbeta_a2", hash)*dp*dp*dp2scale; if(r>1 && r<4) { - delta_bfield_coefficient[s][r] = t2dPressure.getDoubleValue("delta_bfield_a0", s+1,r+1,0) - +t2dPressure.getDoubleValue("delta_bfield_a1", s+1,r+1,0)*dp*dpscale - +t2dPressure.getDoubleValue("delta_bfield_a2", s+1,r+1,0)*dp*dp*dp2scale - +t2dPressure.getDoubleValue("delta_bfield_a1", s+1,r+1,0)*dp*dpscale - +t2dPressure.getDoubleValue("delta_bfield_a2", s+1,r+1,0)*dp*dp*dp2scale; - b1[s][r] = t2dPressure.getDoubleValue("b1_a0", s+1,r+1,0) - +t2dPressure.getDoubleValue("b1_a1", s+1,r+1,0)*dp*dpscale - +t2dPressure.getDoubleValue("b1_a2", s+1,r+1,0)*dp*dp*dp2scale; - b2[s][r] = t2dPressure.getDoubleValue("b2_a0", s+1,r+1,0) - +t2dPressure.getDoubleValue("b2_a1", s+1,r+1,0)*dp*dpscale - +t2dPressure.getDoubleValue("b2_a2", s+1,r+1,0)*dp*dp*dp2scale; - b3[s][r] = t2dPressure.getDoubleValue("b3_a0", s+1,r+1,0) - +t2dPressure.getDoubleValue("b3_a1", s+1,r+1,0)*dp*dpscale - +t2dPressure.getDoubleValue("b3_a2", s+1,r+1,0)*dp*dp*dp2scale; - b4[s][r] = t2dPressure.getDoubleValue("b4_a0", s+1,r+1,0) - +t2dPressure.getDoubleValue("b4_a1", s+1,r+1,0)*dp*dpscale - +t2dPressure.getDoubleValue("b4_a2", s+1,r+1,0)*dp*dp*dp2scale; + delta_bfield_coefficient[s][r] = t2dPressure.getDoubleValueByHash("delta_bfield_a0", hash) + +t2dPressure.getDoubleValueByHash("delta_bfield_a1", hash)*dp*dpscale + +t2dPressure.getDoubleValueByHash("delta_bfield_a2", hash)*dp*dp*dp2scale + +t2dPressure.getDoubleValueByHash("delta_bfield_a1", hash)*dp*dpscale + +t2dPressure.getDoubleValueByHash("delta_bfield_a2", hash)*dp*dp*dp2scale; + b1[s][r] = t2dPressure.getDoubleValueByHash("b1_a0", hash) + +t2dPressure.getDoubleValueByHash("b1_a1", hash)*dp*dpscale + +t2dPressure.getDoubleValueByHash("b1_a2", hash)*dp*dp*dp2scale; + b2[s][r] = t2dPressure.getDoubleValueByHash("b2_a0", hash) + +t2dPressure.getDoubleValueByHash("b2_a1", hash)*dp*dpscale + +t2dPressure.getDoubleValueByHash("b2_a2", hash)*dp*dp*dp2scale; + b3[s][r] = t2dPressure.getDoubleValueByHash("b3_a0", hash) + +t2dPressure.getDoubleValueByHash("b3_a1", hash)*dp*dpscale + +t2dPressure.getDoubleValueByHash("b3_a2", hash)*dp*dp*dp2scale; + b4[s][r] = t2dPressure.getDoubleValueByHash("b4_a0", hash) + +t2dPressure.getDoubleValueByHash("b4_a1", hash)*dp*dpscale + +t2dPressure.getDoubleValueByHash("b4_a2", hash)*dp*dp*dp2scale; } - Tmax[s][r] = t2dPressure.getDoubleValue("tmax_a0", s+1,r+1,0) - +t2dPressure.getDoubleValue("tmax_a1", s+1,r+1,0)*dp*dpscale - +t2dPressure.getDoubleValue("tmax_a2", s+1,r+1,0)*dp*dp*dp2scale; + Tmax[s][r] = t2dPressure.getDoubleValueByHash("tmax_a0", hash) + +t2dPressure.getDoubleValueByHash("tmax_a1", hash)*dp*dpscale + +t2dPressure.getDoubleValueByHash("tmax_a2", hash)*dp*dp*dp2scale; } } } From 605f5805c8bcf56fabe067b53d78e9421d5d215a Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Fri, 29 Aug 2025 21:32:08 -0400 Subject: [PATCH 17/22] optimize swap table initialization --- .../java/org/jlab/detector/swaps/SwapTable.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/swaps/SwapTable.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/swaps/SwapTable.java index 71edf4ecb5..3ae52a6f02 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/swaps/SwapTable.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/swaps/SwapTable.java @@ -70,13 +70,14 @@ public SwapTable(IndexedTable fromTrans,IndexedTable toTrans) { this.table = new IndexedTable(VAR_NAMES.length,String.join(":",VAR_NAMES)); - for (int row=0; row Date: Fri, 5 Sep 2025 12:10:09 -0400 Subject: [PATCH 18/22] cleanup --- .../detector/decode/DetectorEventDecoder.java | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 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 72bdfe10fc..160bfbd0d1 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 @@ -136,7 +136,7 @@ public void translate(List detectorData){ tables.add(translationManager.getConstants(runNumber, name)); } - for(DetectorDataDgtz data : detectorData){ + for (DetectorDataDgtz data : detectorData) { int crate = data.getDescriptor().getCrate(); int slot = data.getDescriptor().getSlot(); @@ -145,26 +145,24 @@ public void translate(List detectorData){ for (int j=0; j Date: Fri, 5 Sep 2025 12:23:07 -0400 Subject: [PATCH 19/22] more comments --- .../org/jlab/detector/decode/DetectorEventDecoder.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 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 160bfbd0d1..3d0040a832 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 @@ -130,7 +130,7 @@ public final void initDecoder(){ */ public void translate(List detectorData){ - // preload CCDB tables once: + // Preload CCDB tables: ArrayList tables = new ArrayList<>(); for (String name : tablesTrans) { tables.add(translationManager.getConstants(runNumber, name)); @@ -138,15 +138,18 @@ public void translate(List detectorData){ for (DetectorDataDgtz data : detectorData) { + // Get the hardware indexing for this detector hit: int crate = data.getDescriptor().getCrate(); int slot = data.getDescriptor().getSlot(); int channel = data.getDescriptor().getChannel(); long hash = IndexedTable.DEFAULT_GENERATOR.hashCode(crate,slot,channel); - + + // Try to find it in the translation tables: for (int j=0; j Date: Tue, 9 Sep 2025 11:54:16 -0400 Subject: [PATCH 20/22] check CCDB tanslation tables for crate/slot/channel conflicts --- .../detector/decode/DetectorEventDecoder.java | 10 ++++++++ .../org/jlab/utils/groups/IndexedTable.java | 25 ++++++++++++++++++- 2 files changed, 34 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 3d0040a832..29d7b27450 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 @@ -121,6 +121,16 @@ public final void initDecoder(){ scalerManager.init(Arrays.asList(new String[]{"/runcontrol/fcup","/runcontrol/slm","/runcontrol/hwp", "/runcontrol/helicity","/daq/config/scalers/dsc1"})); + + checkTables(); + } + + public void checkTables() { + for (int i=0; i> constrains = new HashMap<>(); private int DEBUG_MODE = 0; - + public IndexedTable(int indexCount){ entries = new IndexedList<>(indexCount); for(int i = 0; i < indexCount; i++){ @@ -418,4 +418,27 @@ public void setSize(int size){ } } + /** + * @param it table with which to compare + * @return whether the tables have conflicting indices + */ + public boolean conflicts(IndexedTable it) { + if (it.getList().getIndexSize() != this.getList().getIndexSize()) { + System.err.println("[CCDB-TT] Conflict: Not even the same #inidices."); + return false; + } + List conflicts = new ArrayList<>(); + for (Object key : it.getList().getMap().keySet()) { + if (entries.hasItemByHash((long)key)){ + conflicts.add(key); + int[] index = new int[it.getList().getIndexSize()]; + String s = "[CCDB-TT] Index Conflict: "; + for (int i=0; i0?"/":"")+IndexedTable.DEFAULT_GENERATOR.getIndex((long)key, i); + System.err.println(s); + } + } + return !conflicts.isEmpty(); + } + } From e0c099ca090107f13c55388b0b842d6dfd2c634c Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Tue, 9 Sep 2025 12:08:57 -0400 Subject: [PATCH 21/22] add more performant accessors and use them in decoding --- .../jlab/detector/decode/DetectorEventDecoder.java | 8 ++++---- .../java/org/jlab/utils/groups/IndexedTable.java | 12 ++++++++++++ 2 files changed, 16 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 29d7b27450..4f726283a8 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 @@ -162,10 +162,10 @@ public void translate(List detectorData){ // Found it; now set the detector indexing for this hit: if (t.hasEntryByHash(hash)) { - int sector = t.getIntValueByHash("sector", hash); - int layer = t.getIntValueByHash("layer", hash); - int component = t.getIntValueByHash("component", hash); - int order = t.getIntValueByHash("order", hash); + int sector = t.getIntValueByHash(0, hash); + int layer = t.getIntValueByHash(1, hash); + int component = t.getIntValueByHash(2, hash); + int order = t.getIntValueByHash(3, hash); data.getDescriptor().setSectorLayerComponent(sector, layer, component); data.getDescriptor().setOrder(order); diff --git a/common-tools/clas-utils/src/main/java/org/jlab/utils/groups/IndexedTable.java b/common-tools/clas-utils/src/main/java/org/jlab/utils/groups/IndexedTable.java index 1ef8d11d79..e01daaef59 100644 --- a/common-tools/clas-utils/src/main/java/org/jlab/utils/groups/IndexedTable.java +++ b/common-tools/clas-utils/src/main/java/org/jlab/utils/groups/IndexedTable.java @@ -133,6 +133,18 @@ public void setDoubleValue(Double value, String item, int... index){ } } + public int getIntValueByHash(int index, long hash) { + if (this.entries.hasItemByHash(hash)) + return this.entries.getItemByHash(hash).getValue(index).intValue(); + return 0; + } + + public double getDoubleValueByHash(int index, long hash) { + if (this.entries.hasItemByHash(hash)) + return this.entries.getItemByHash(hash).getValue(index).doubleValue(); + return 0; + } + public int getIntValueByHash(String item, long hash) { if (this.entries.hasItemByHash(hash)) { if (this.entryMap.containsKey(item)) { From f5dc95ceba8c51bb899dcc4d80e7b7ad3531e5e6 Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Fri, 12 Sep 2025 20:50:36 -0400 Subject: [PATCH 22/22] remove cp, use cached --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ba3fcd53cf..18a0c92238 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -153,7 +153,6 @@ jobs: run: tar xzvf coatjava.tar.gz - name: run test run: | - xrdcp xroot://sci-xrootd.jlab.org///osgpool/hallb/clas12/validation/clas_005038.evio.00000 . ./coatjava/bin/decoder -n 10000 -o dog.hipo ./clas_005038.evio.00000 test_coatjava: