From 1e7722f9fffe7cee05db98d85a36b4cd0f9e422f Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Tue, 13 Jan 2026 15:37:21 -0500 Subject: [PATCH 1/8] reduce string comparisons, cleanup --- .../detector/decode/DetectorEventDecoder.java | 83 +++++++++---------- 1 file changed, 40 insertions(+), 43 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 4f726283a8..0fc6fdfbaf 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 @@ -28,6 +28,7 @@ public class DetectorEventDecoder { List keysTrans = null; List keysFitter = null; List keysFilter = null; + List keysMicromega= null; private int runNumber = 10; @@ -121,7 +122,9 @@ public final void initDecoder(){ 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(); } @@ -191,70 +194,64 @@ 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(); 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 0) { - ADCData adc = data.getADCData(0); - mvtFitter.fit(adcOffset, fineTimeStampResolution, samplingTime, adc.getPulseArray(), adc.getTimeStamp(), sparseSample); - adc.setHeight((short) (mvtFitter.adcMax)); - adc.setTime((int) (mvtFitter.timeMax)); - adc.setIntegral((int) (mvtFitter.integral)); - adc.setTimeStamp(mvtFitter.timestamp); + ADCData adc = data.getADCData(0); + mvtFitter.fit(adcOffset, fineTimeStampResolution, samplingTime, adc.getPulseArray(), adc.getTimeStamp(), sparseSample); + adc.setHeight((short) (mvtFitter.adcMax)); + adc.setTime((int) (mvtFitter.timeMax)); + adc.setIntegral((int) (mvtFitter.integral)); + adc.setTimeStamp(mvtFitter.timestamp); + // 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); + int ped = 0; + if(data.getDescriptor().getType() == DetectorType.RF && type == DetectorType.RF) { + ped = daq.getIntValueByHash("pedestal", hash); } - } else { - 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.getIntValueByHash("pedestal", hash); - } - if(data.getADCSize()>0){ - for(int i = 0; i < data.getADCSize(); i++){ - ADCData adc = data.getADCData(i); - if(adc.getPulseSize()>0){ - try { - extendedFitter.fit(nsa, nsb, tet, ped, adc.getPulseArray()); - } catch (Exception e) { - System.out.println(">>>> error : fitting pulse " - + crate + " / " + slot + " / " + channel); - } - int adc_corrected = extendedFitter.adc + extendedFitter.ped*(nsa+nsb); - adc.setHeight((short) this.extendedFitter.pulsePeakValue); - adc.setIntegral(adc_corrected); - adc.setTimeWord(this.extendedFitter.t0); - adc.setPedestal((short) this.extendedFitter.ped); - } - } - } - if(data.getADCSize()>0){ - for(int i = 0; i < data.getADCSize(); i++){ - data.getADCData(i).setADC(nsa, nsb); + for(int i = 0; i < data.getADCSize(); i++){ + ADCData adc = data.getADCData(i); + if(adc.getPulseSize()>0){ + try { + extendedFitter.fit(nsa, nsb, tet, ped, adc.getPulseArray()); + } catch (Exception e) { + System.out.println(">>>> error : fitting pulse " + + crate + " / " + slot + " / " + channel); } + int adc_corrected = extendedFitter.adc + extendedFitter.ped*(nsa+nsb); + adc.setHeight((short) this.extendedFitter.pulsePeakValue); + adc.setIntegral(adc_corrected); + adc.setTimeWord(this.extendedFitter.t0); + adc.setPedestal((short) this.extendedFitter.ped); } + data.getADCData(i).setADC(nsa, nsb); } + // first one wins: + break; } } } } - public void filterTDCs(List detectorData){ int maxMultiplicity = 1; for(DetectorType type : keysFilter){ From 8c3208b0c316c3c3109ea39c7e0c1ba6cce0741d Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Tue, 13 Jan 2026 15:33:04 -0500 Subject: [PATCH 2/8] cache evio branches, cleanup --- .../jlab/detector/decode/CodaDecoders.java | 922 +++++++++++ .../detector/decode/CodaEventDecoder.java | 1430 +++-------------- 2 files changed, 1158 insertions(+), 1194 deletions(-) create mode 100644 common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CodaDecoders.java diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CodaDecoders.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CodaDecoders.java new file mode 100644 index 0000000000..9a46c55844 --- /dev/null +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CodaDecoders.java @@ -0,0 +1,922 @@ +package org.jlab.detector.decode; + +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.jlab.coda.jevio.CompositeData; +import org.jlab.coda.jevio.DataType; +import org.jlab.coda.jevio.EvioException; +import org.jlab.coda.jevio.EvioNode; +import org.jlab.detector.decode.DetectorDataDgtz.ADCData; +import org.jlab.detector.decode.DetectorDataDgtz.TDCData; +import org.jlab.io.evio.EvioDataEvent; +import org.jlab.io.evio.EvioTreeBranch; +import org.jlab.utils.data.DataUtils; + +/** + * All static methods from CodaEventDecoder. + * + * @author baltzell + */ +public class CodaDecoders { + + /** + * Returns an array of the branches in the event. + * @param event + * @return + */ + public static List getEventBranches(EvioDataEvent event){ + ArrayList branches = new ArrayList<>(); + try { + List eventNodes = event.getStructureHandler().getNodes(); + if (eventNodes==null) { + return branches; + } + for (EvioNode node : eventNodes){ + EvioTreeBranch eBranch = new EvioTreeBranch(node.getTag(),node.getNum()); + List childNodes = node.getChildNodes(); + if (childNodes!=null){ + for (EvioNode child : childNodes){ + eBranch.addNode(child); + } + branches.add(eBranch); + } + } + } catch (EvioException ex) { + Logger.getLogger(CodaEventDecoder.class.getName()).log(Level.SEVERE, null, ex); + } + return branches; + } + + public static void printByteBuffer(ByteBuffer buffer, int max, int columns){ + int n = max; + if(buffer.capacity() + * + * c "slot number" + * m "number of channels fired" + * c "channel number" + * m "number of shorts in packed array" + * s "packed fadc data" + * + * + */ + public static void decodeComposite(ByteBuffer buffer, int offset, List ctypes, List citems){ + int position = offset; + int length = buffer.capacity(); + try { + while(position<(length-3)){ + Short slot = (short) (0x00FF&(buffer.get(position))); + position++; + citems.add(slot); + ctypes.add(DataType.SHORT16); + Short counter = (short) (0x00FF&(buffer.get(position))); + citems.add(counter); + ctypes.add(DataType.NVALUE); + position++; + + for(int i = 0; i < counter; i++){ + Short channel = (short) (0x00FF&(buffer.get(position))); + position++; + citems.add(channel); + ctypes.add(DataType.SHORT16); + Short ndata = (short) (0x00FF&(buffer.get(position))); + position++; + citems.add(ndata); + ctypes.add(DataType.NVALUE); + for(int b = 0; b < ndata; b++){ + Short data = buffer.getShort(position); + position+=2; + citems.add(data); + ctypes.add(DataType.SHORT16); + } + } + } + } catch (Exception e){ + System.out.println("Exception : Length = " + length + " position = " + position); + } + } + + /** + * SVT decoding + * @param crate + * @param node + * @param event + * @return + */ + public static ArrayList getDataEntries_57617(Integer crate, EvioNode node, EvioDataEvent event){ + + ArrayList rawdata = new ArrayList<>(); + + if(node.getTag()==57617){ + try { + ByteBuffer compBuffer = node.getByteData(true); + CompositeData compData = new CompositeData(compBuffer.array(),event.getByteOrder()); + List cdataitems = compData.getItems(); + int totalSize = cdataitems.size(); + int position = 0; + while( (position + 4) < totalSize){ + Byte slot = (Byte) cdataitems.get(position); + //Integer trig = (Integer) cdataitems.get(position+1); + Long time = (Long) cdataitems.get(position+2); + Integer nchannels = (Integer) cdataitems.get(position+3); + int counter = 0; + position = position + 4; + while(counter ERROR DECODING COMPOSITE DATA FOR ONE EVENT"); + } + } + return rawdata; + } + + /** + * Bank TAG=57657 used for ATOF PETIROC TDC values + * @param crate + * @param node + * @param event + * @return + * + * + * + * c "slot number" + * i "trigger number" + * l "time stamp" + * N "number of channels fired" + * c "channel number" + * i "tdc value" + * i "width value" + * + * + */ + public static List getDataEntries_57657(Integer crate, EvioNode node, EvioDataEvent event) { + + ArrayList entries = new ArrayList<>(); + + if(node.getTag()==57657){ + try { + //System.err.println("Decoding ATOF PETIROC event!"); + ByteBuffer compBuffer = node.getByteData(true); + CompositeData compData = new CompositeData(compBuffer.array(),event.getByteOrder()); + + List cdatatypes = compData.getTypes(); + List cdataitems = compData.getItems(); + + if(cdatatypes.get(3) != DataType.NVALUE){ + System.err.println("[EvioRawDataSource] ** error ** corrupted " + + " bank. tag = " + node.getTag() + " num = " + node.getNum()); + return null; + } + + int position = 0; + while(position -> "bank" DetectorDataDgtz -> "tdc" TDCData + // there is a redundancy in timestamp: the same value is stored in TDCData and the DetectorDataDgz + // + bank.setTimeStamp(time_stamp); + bank.setTrigger(trig_num);; + TDCData tdc_data = new TDCData(tdc, tot); + tdc_data.setTimeStamp(time_stamp).setOrder(counter); + bank.addTDC(tdc_data); + entries.add(bank); + position += 3; // channel,tdc,tot + counter++; + //System.err.println("event: " + bank.toString()); + } + } + + return entries; + } catch (EvioException ex) { + Logger.getLogger(CodaEventDecoder.class.getName()).log(Level.SEVERE, null, ex); + } + } + return entries; + } + + /** + * Bank TAG=57636 used for RICH TDC values + * @param crate + * @param node + * @param event + * @return + */ + public static List getDataEntries_57636(Integer crate, EvioNode node, EvioDataEvent event){ + + ArrayList entries = new ArrayList<>(); + + if(node.getTag()==57636){ + try { + + ByteBuffer compBuffer = node.getByteData(true); + CompositeData compData = new CompositeData(compBuffer.array(),event.getByteOrder()); + + List cdatatypes = compData.getTypes(); + List cdataitems = compData.getItems(); + + if(cdatatypes.get(3) != DataType.NVALUE){ + System.err.println("[EvioRawDataSource] ** error ** corrupted " + + " bank. tag = " + node.getTag() + " num = " + node.getNum()); + return null; + } + + int position = 0; + while(position>15)&0x1; + int tdc = rawtdc&0x7FFF; + + DetectorDataDgtz bank = new DetectorDataDgtz(crate,slot.intValue(),2*(fiber*192+channel)+edge); + bank.addTDC(new TDCData(tdc)); + + entries.add(bank); + position += 3; + counter++; + } + } + + return entries; + } catch (EvioException ex) { + Logger.getLogger(CodaEventDecoder.class.getName()).log(Level.SEVERE, null, ex); + } + } + return entries; + } + + /** + * Bank TAG=57648 used for DC (Drift Chambers) TDC and ToT values. + * @param crate + * @param node + * @param event + * @return + */ + public static List getDataEntries_57648(Integer crate, EvioNode node, EvioDataEvent event){ + List entries = new ArrayList<>(); + if(node.getTag()==57648){ + try { + ByteBuffer compBuffer = node.getByteData(true); + CompositeData compData = new CompositeData(compBuffer.array(),event.getByteOrder()); + //List cdatatypes = compData.getTypes(); + List cdataitems = compData.getItems(); + + int totalSize = cdataitems.size(); + int position = 0; + while( (position + 4) < totalSize){ + Byte slot = (Byte) cdataitems.get(position); + //Integer trig = (Integer) cdataitems.get(position+1); + Long time = (Long) cdataitems.get(position+2); + Integer nchannels = (Integer) cdataitems.get(position+3); + int counter = 0; + position = position + 4; + while(counter getDataEntries_57622(Integer crate, EvioNode node, EvioDataEvent event){ + List entries = new ArrayList<>(); + if(node.getTag()==57622){ + try { + ByteBuffer compBuffer = node.getByteData(true); + CompositeData compData = new CompositeData(compBuffer.array(),event.getByteOrder()); + //List cdatatypes = compData.getTypes(); + List cdataitems = compData.getItems(); + + int totalSize = cdataitems.size(); + int position = 0; + while( (position + 4) < totalSize){ + Byte slot = (Byte) cdataitems.get(position); + //Integer trig = (Integer) cdataitems.get(position+1); + Long time = (Long) cdataitems.get(position+2); + Integer nchannels = (Integer) cdataitems.get(position+3); + int counter = 0; + position = position + 4; + while(counter +//             +//                  c     "slot number" (8bit) +//                  i     "trigger number" (32bit) +//                  l     "time stamp" (64bit) +//                  N     "number of channels fired" (32bit) +//                  c     "channel number" (8bit) +//                  N     "number of pulses" (32bit) +//                  s     "tdc value" (16bit) +//                  i     "adc value" (32bit) +//             +//       + public static List getDataEntries_57603(Integer crate, EvioNode node, EvioDataEvent event){ + List entries = new ArrayList<>(); + if(node.getTag()==57603){ + try { + ByteBuffer compBuffer = node.getByteData(true); + CompositeData compData = new CompositeData(compBuffer.array(),event.getByteOrder()); + + List cdatatypes = compData.getTypes(); + List cdataitems = compData.getItems(); + + if(cdatatypes.get(3) != DataType.NVALUE){ + System.err.println("[EvioRawDataSource] ** error ** corrupted " + + " bank. tag = " + node.getTag() + " num = " + node.getNum()); + return null; + } + + int position = 0; + while((position+4) getDataEntries_57602(Integer crate, EvioNode node, EvioDataEvent event){ + List entries = new ArrayList<>(); + if(node.getTag()==57602){ + try { + ByteBuffer compBuffer = node.getByteData(true); + CompositeData compData = new CompositeData(compBuffer.array(),event.getByteOrder()); + + List cdatatypes = compData.getTypes(); + List cdataitems = compData.getItems(); + + if(cdatatypes.get(3) != DataType.NVALUE){ + System.err.println("[EvioRawDataSource] ** error ** corrupted " + + " bank. tag = " + node.getTag() + " num = " + node.getNum()); + return null; + } + + int position = 0; + while((position+4) getDataEntries_57641(Integer crate, EvioNode node, EvioDataEvent event){ + // Micromegas packed data + // ---------------------- + + ArrayList entries = new ArrayList<>(); + if(node.getTag()==57641){ + try { + ByteBuffer compBuffer = node.getByteData(true); + CompositeData compData = new CompositeData(compBuffer.array(),event.getByteOrder()); + + List cdatatypes = compData.getTypes(); + List cdataitems = compData.getItems(); + + int jdata = 0; // item counter + for( int i = 0 ; i < cdatatypes.size(); ) { // loop over data types + + Byte SLOT = (Byte)cdataitems.get( jdata++ ); i++; + Integer EV_ID = (Integer)cdataitems.get( jdata++ ); i++; + Long TIMESTAMP = (Long)cdataitems.get( jdata++ ); i++; + Short nChannels = (Short)cdataitems.get( jdata++ ); i++; + + for( int ch=0; ch>4)<<8; + } + } + i++; + + ADCData adcData = new ADCData(); + adcData.setTimeStamp(TIMESTAMP); + adcData.setPulse(samples); + adcData.setTime(firstChannel); + bank.addADC(adcData); + + entries.add(bank); + } + } // end loop on channels + } // end loop on data types + return entries; + + } catch (EvioException ex) { + Logger.getLogger(CodaEventDecoder.class.getName()).log(Level.SEVERE, null, ex); + } + } + return entries; + } + + /** + * Decoding MicroMegas Packed Data + * @param crate + * @param node + * @param event + * @return + */ + public static List getDataEntries_57640(Integer crate, EvioNode node, EvioDataEvent event){ + // Micromegas packed data + // ---------------------- + + ArrayList entries = new ArrayList<>(); + if(node.getTag()==57640){ + try { + ByteBuffer compBuffer = node.getByteData(true); + CompositeData compData = new CompositeData(compBuffer.array(),event.getByteOrder()); + + List cdatatypes = compData.getTypes(); + List cdataitems = compData.getItems(); + + int jdata = 0; // item counter + for( int i = 0 ; i < cdatatypes.size(); ) { // loop over data types + + Byte CRATE = (Byte)cdataitems.get( jdata++ ); i++; + Integer EV_ID = (Integer)cdataitems.get( jdata++ ); i++; + Long TIMESTAMP = (Long)cdataitems.get( jdata++ ); i++; + Short nChannels = (Short)cdataitems.get( jdata++ ); i++; + + for( int ch=0; ch>4)<<8; + } + + } + i++; + + ADCData adcData = new ADCData(); + adcData.setTimeStamp(TIMESTAMP); + adcData.setPulse(samples); + bank.addADC(adcData); + entries.add(bank); + } // end loop on channels + } // end loop on data types + return entries; + + } catch (EvioException ex) { + Logger.getLogger(CodaEventDecoder.class.getName()).log(Level.SEVERE, null, ex); + } + } + return entries; + } + + public static List getDataEntries_57627(Integer crate, EvioNode node, EvioDataEvent event){ + + ArrayList entries = new ArrayList<>(); + + if(node.getTag()==57627){ + try { + + ByteBuffer compBuffer = node.getByteData(true); + CompositeData compData = new CompositeData(compBuffer.array(),event.getByteOrder()); + + List cdatatypes = compData.getTypes(); + List cdataitems = compData.getItems(); + + if(cdatatypes.get(3) != DataType.NVALUE){ + System.err.println("[EvioRawDataSource] ** error ** corrupted " + + " bank. tag = " + node.getTag() + " num = " + node.getNum()); + return null; + } + + int position = 0; + + while(position getDataEntries_57638(Integer crate, EvioNode node, EvioDataEvent event){ + List entries = new ArrayList<>(); + if(node.getTag()==57638){ + ByteBuffer compBuffer = node.getByteData(true); + List cdatatypes = new ArrayList<>(); + List cdataitems = new ArrayList<>(); + decodeComposite(compBuffer, 24, cdatatypes, cdataitems); + + int position = 0; + + while(position18) entries.add(data); + } + } + } + return entries; + } + + /** + * decoding bank in Mode 1 - full ADC pulse. + * @param crate + * @param node + * @param event + * @return + */ + public static List getDataEntries_57601(Integer crate, EvioNode node, EvioDataEvent event){ + + ArrayList entries = new ArrayList<>(); + + if(node.getTag()==57601){ + try { + + ByteBuffer compBuffer = node.getByteData(true); + CompositeData compData = new CompositeData(compBuffer.array(),event.getByteOrder()); + + List cdatatypes = compData.getTypes(); + List cdataitems = compData.getItems(); + + if(cdatatypes.get(3) != DataType.NVALUE){ + System.err.println("[EvioRawDataSource] ** error ** corrupted " + + " bank. tag = " + node.getTag() + " num = " + node.getNum()); + return null; + } + + int position = 0; + + while(position>>> EVENT SIZE EXCEEDS 600 kB"); - // return new ArrayList(); - //} - - // zero out the trigger bits, but let the others properties inherit - // from the previous event, in the case where there's no HEAD bank: - this.setTriggerBits(0); - List rawEntries = new ArrayList<>(); - List branches = this.getEventBranches(event); - this.setTimeStamp(event); - for(EvioTreeBranch branch : branches){ - List list = this.getDataEntries(event,branch.getTag()); - if(list != null){ - rawEntries.addAll(list); - } - } - List tdcEntries = this.getDataEntries_TDC(event); - rawEntries.addAll(tdcEntries); - List vtpEntries = this.getDataEntries_VTP(event); - rawEntries.addAll(vtpEntries); - List scalerEntries = this.getDataEntries_Scalers(event); - rawEntries.addAll(scalerEntries); - - this.getDataEntries_EPICS(event); - - return rawEntries; - } + public CodaEventDecoder(){} public JsonObject getEpicsData(){ return this.epicsData; @@ -97,17 +50,6 @@ public List getTriggerWords(){ return this.triggerWords; } - private void printByteBuffer(ByteBuffer buffer, int max, int columns){ - int n = max; - if(buffer.capacity() tiEntries = this.getDataEntries_TI(event); - - if(tiEntries.size()==1) { - ts = tiEntries.get(0).getTimeStamp(); - } - else if(tiEntries.size()>1) { - // check sychronization - boolean tiSync=true; - int i0 = -1; - // set reference timestamp from first entry which is not the tiMaster nor PCIE: - for(int i=0; ideltaTS) { - tiSync=false; - if(this.timeStampErrors<100) { - System.err.println("WARNING: mismatch in TI time stamps: crate " - + tiEntries.get(i).getDescriptor().getCrate() + " reports " - + tiEntries.get(i).getTimeStamp() + " instead of the " + tiEntries.get(i0).getTimeStamp() - + " from crate " + tiEntries.get(i0).getDescriptor().getCrate()); - } - else if(this.timeStampErrors==100) { - System.err.println("WARNING: reached the maximum number of timeStamp errors (100), supressing future warnings."); - } - this.timeStampErrors++; - } - } - if(tiSync) ts = tiEntries.get(i0).getTimeStamp(); - } - this.timeStamp = ts ; - } - - public long getTriggerBits() { - return triggerBits; - } - - public void setTriggerBits(long triggerBits) { - this.triggerBits = triggerBits; - } - - public List getADCEntries(EvioDataEvent event){ - List entries = new ArrayList<>(); - List branches = this.getEventBranches(event); - for(EvioTreeBranch branch : branches){ - List list = this.getADCEntries(event,branch.getTag()); - if(list != null){ - entries.addAll(list); - } - } - return entries; - } - - public List getADCEntries(EvioDataEvent event, int crate){ - List entries = new ArrayList<>(); - - List branches = this.getEventBranches(event); - EvioTreeBranch cbranch = this.getEventBranch(branches, crate); - - if(cbranch == null ) return null; - - for(EvioNode node : cbranch.getNodes()){ - if(node.getTag()==57638){ - return this.getDataEntries_57638(crate, node, event); - } - } - - return entries; - } - - public List getADCEntries(EvioDataEvent event, int crate, int tagid){ - - List adc = new ArrayList<>(); - List branches = this.getEventBranches(event); - - EvioTreeBranch cbranch = this.getEventBranch(branches, crate); - if(cbranch == null ) return null; - - for(EvioNode node : cbranch.getNodes()){ - if(node.getTag()==tagid){ - // This is regular integrated pulse mode, used for FTOF - // FTCAL and EC/PCAL - return this.getADCEntries_Tag(crate, node, event,tagid); - } - } - return adc; - } - - /** - * returns list of decoded data in the event for given crate. - * @param event - * @param crate - * @return - */ - public List getDataEntries(EvioDataEvent event, int crate){ - - List branches = this.getEventBranches(event); - List bankEntries = new ArrayList<>(); - - EvioTreeBranch cbranch = this.getEventBranch(branches, crate); - if(cbranch == null ) return null; - - for (EvioNode node : cbranch.getNodes()) { - if (node.getTag() == 57615) { - // This is regular integrated pulse mode, used for FTOF - // FTCAL and EC/PCAL - this.tiMaster = crate; - this.readHeaderBank(crate, node, event); - } - } - for(EvioNode node : cbranch.getNodes()){ - - if(node.getTag()==57617){ - // This is regular integrated pulse mode, used for FTOF - // FTCAL and EC/PCAL - return this.getDataEntries_57617(crate, node, event); - } - else if(node.getTag()==57603){ - // This is regular integrated pulse mode, used for streaming - return this.getDataEntries_57603(crate, node, event); - } - else if(node.getTag()==57602){ - // This is regular integrated pulse mode, used for FTOF - // FTCAL and EC/PCAL - return this.getDataEntries_57602(crate, node, event); - } - else if(node.getTag()==57601){ - // This is regular integrated pulse mode, used for FTOF - // FTCAL and EC/PCAL - return this.getDataEntries_57601(crate, node, event); - } - else if(node.getTag()==57627){ - // This is regular integrated pulse mode, used for MM - return this.getDataEntries_57627(crate, node, event); - } - else if(node.getTag()==57640){ - // This is bit-packed pulse mode, used for MM - return this.getDataEntries_57640(crate, node, event); - } - else if(node.getTag()==57622){ - // This is regular DCRB bank with TDCs only - return this.getDataEntries_57622(crate, node, event); - } - else if(node.getTag()==57648){ - // This is DCRB bank with TDCs and widths - return this.getDataEntries_57648(crate, node, event); - } - else if(node.getTag()==57636){ - // RICH TDC data - return this.getDataEntries_57636(crate, node, event); - } else if (node.getTag() == 57657) { - // ATOF Petiroc TDC data - return this.getDataEntries_57657(crate, node, event); - } else if (node.getTag() == 57641) { - // RTPC data decoding - return this.getDataEntries_57641(crate, node, event); - } - } - return bankEntries; - } - - /** - * Returns an array of the branches in the event. - * @param event - * @return - */ - public List getEventBranches(EvioDataEvent event){ - ArrayList branches = new ArrayList<>(); - try { - - List eventNodes = event.getStructureHandler().getNodes(); - if(eventNodes==null){ - return branches; - } - - for(EvioNode node : eventNodes){ - EvioTreeBranch eBranch = new EvioTreeBranch(node.getTag(),node.getNum()); - List childNodes = node.getChildNodes(); - if(childNodes!=null){ - for(EvioNode child : childNodes){ - eBranch.addNode(child); - } - branches.add(eBranch); - } - } - - } catch (EvioException ex) { - Logger.getLogger(CodaEventDecoder.class.getName()).log(Level.SEVERE, null, ex); - } - return branches; - } - /** - * returns branch with with given tag - * @param branches - * @param tag - * @return - */ - public EvioTreeBranch getEventBranch(List branches, int tag){ - for(EvioTreeBranch branch : branches){ - if(branch.getTag()==tag) return branch; - } - return null; - } - - public void readHeaderBank(Integer crate, EvioNode node, EvioDataEvent event){ - - if(node.getDataTypeObj()==DataType.INT32||node.getDataTypeObj()==DataType.UINT32){ - try { - int[] intData = ByteDataTransformer.toIntArray(node.getStructureBuffer(true)); - this.runNumber = intData[3]; - this.eventNumber = intData[4]; - if(intData[5]!=0) this.unixTime = intData[5]; - this.helicityLevel3=HelicityBit.DNE.value(); - if(intData.length>7) { - if ( (intData[7] & 0x1) == 0) { - this.helicityLevel3=HelicityBit.UDF.value(); - } - else if ((intData[7]>>1 & 0x1) == 0) { - this.helicityLevel3=HelicityBit.MINUS.value(); - } - else { - this.helicityLevel3=HelicityBit.PLUS.value(); - } - } - } catch (Exception e) { - this.runNumber = 10; - this.eventNumber = 1; - } - } else { - System.out.println("[error] can not read header bank"); - } - } - - /** - * SVT decoding - * @param crate - * @param node - * @param event - * @return - */ - public ArrayList getDataEntries_57617(Integer crate, EvioNode node, EvioDataEvent event){ - - ArrayList rawdata = new ArrayList<>(); - - if(node.getTag()==57617){ - try { - ByteBuffer compBuffer = node.getByteData(true); - CompositeData compData = new CompositeData(compBuffer.array(),event.getByteOrder()); - List cdataitems = compData.getItems(); - int totalSize = cdataitems.size(); - int position = 0; - while( (position + 4) < totalSize){ - Byte slot = (Byte) cdataitems.get(position); - //Integer trig = (Integer) cdataitems.get(position+1); - Long time = (Long) cdataitems.get(position+2); - Integer nchannels = (Integer) cdataitems.get(position+3); - int counter = 0; - position = position + 4; - while(counter ERROR DECODING COMPOSITE DATA FOR ONE EVENT"); - } - } - return rawdata; - } - - public List getADCEntries_Tag(Integer crate, EvioNode node, EvioDataEvent event, int tagid){ - List entries = new ArrayList<>(); - if(node.getTag()==tagid){ - try { - - ByteBuffer compBuffer = node.getByteData(true); - CompositeData compData = new CompositeData(compBuffer.array(),event.getByteOrder()); - - List cdatatypes = compData.getTypes(); - List cdataitems = compData.getItems(); - - if(cdatatypes.get(3) != DataType.NVALUE){ - System.err.println("[EvioRawDataSource] ** error ** corrupted " - + " bank. tag = " + node.getTag() + " num = " + node.getNum()); - return null; - } - - int position = 0; - - while(position - * - * c "slot number" - * m "number of channels fired" - * c "channel number" - * m "number of shorts in packed array" - * s "packed fadc data" - * - * - */ - public void decodeComposite(ByteBuffer buffer, int offset, List ctypes, List citems){ - int position = offset; - int length = buffer.capacity(); - try { - while(position<(length-3)){ - Short slot = (short) (0x00FF&(buffer.get(position))); - position++; - citems.add(slot); - ctypes.add(DataType.SHORT16); - Short counter = (short) (0x00FF&(buffer.get(position))); - citems.add(counter); - ctypes.add(DataType.NVALUE); - position++; - - for(int i = 0; i < counter; i++){ - Short channel = (short) (0x00FF&(buffer.get(position))); - position++; - citems.add(channel); - ctypes.add(DataType.SHORT16); - Short ndata = (short) (0x00FF&(buffer.get(position))); - position++; - citems.add(ndata); - ctypes.add(DataType.NVALUE); - for(int b = 0; b < ndata; b++){ - Short data = buffer.getShort(position); - position+=2; - citems.add(data); - ctypes.add(DataType.SHORT16); - } - } - } - } catch (Exception e){ - System.out.println("Exception : Length = " + length + " position = " + position); - } - } - - public List getDataEntries_57638(Integer crate, EvioNode node, EvioDataEvent event){ - List entries = new ArrayList<>(); - if(node.getTag()==57638){ - ByteBuffer compBuffer = node.getByteData(true); - List cdatatypes = new ArrayList<>(); - List cdataitems = new ArrayList<>(); - this.decodeComposite(compBuffer, 24, cdatatypes, cdataitems); - - int position = 0; - - while(position18) entries.add(data); - } - } - } - return entries; - } - - /** - * decoding bank in Mode 1 - full ADC pulse. - * @param crate - * @param node - * @param event - * @return - */ - public List getDataEntries_57601(Integer crate, EvioNode node, EvioDataEvent event){ - - ArrayList entries = new ArrayList<>(); - - if(node.getTag()==57601){ - try { - - ByteBuffer compBuffer = node.getByteData(true); - CompositeData compData = new CompositeData(compBuffer.array(),event.getByteOrder()); - - List cdatatypes = compData.getTypes(); - List cdataitems = compData.getItems(); - - if(cdatatypes.get(3) != DataType.NVALUE){ - System.err.println("[EvioRawDataSource] ** error ** corrupted " - + " bank. tag = " + node.getTag() + " num = " + node.getNum()); - return null; - } - - int position = 0; - - while(position -//             -//                  c     "slot number" (8bit) -//                  i     "trigger number" (32bit) -//                  l     "time stamp" (64bit) -//                  N     "number of channels fired" (32bit) -//                  c     "channel number" (8bit) -//                  N     "number of pulses" (32bit) -//                  s     "tdc value" (16bit) -//                  i     "adc value" (32bit) -//             -//       - public List getDataEntries_57603(Integer crate, EvioNode node, EvioDataEvent event){ - List entries = new ArrayList<>(); - if(node.getTag()==57603){ - try { - ByteBuffer compBuffer = node.getByteData(true); - CompositeData compData = new CompositeData(compBuffer.array(),event.getByteOrder()); - - List cdatatypes = compData.getTypes(); - List cdataitems = compData.getItems(); - - if(cdatatypes.get(3) != DataType.NVALUE){ - System.err.println("[EvioRawDataSource] ** error ** corrupted " - + " bank. tag = " + node.getTag() + " num = " + node.getNum()); - return null; - } - - int position = 0; - while((position+4) getDataEntries_57622(Integer crate, EvioNode node, EvioDataEvent event){ - List entries = new ArrayList<>(); - if(node.getTag()==57622){ - try { - ByteBuffer compBuffer = node.getByteData(true); - CompositeData compData = new CompositeData(compBuffer.array(),event.getByteOrder()); - //List cdatatypes = compData.getTypes(); - List cdataitems = compData.getItems(); - - int totalSize = cdataitems.size(); - int position = 0; - while( (position + 4) < totalSize){ - Byte slot = (Byte) cdataitems.get(position); - //Integer trig = (Integer) cdataitems.get(position+1); - Long time = (Long) cdataitems.get(position+2); - Integer nchannels = (Integer) cdataitems.get(position+3); - int counter = 0; - position = position + 4; - while(counter(); + for (EvioTreeBranch branch : CodaDecoders.getEventBranches(event)) + if (!branchMap.containsKey(branch.getTag())) + branchMap.put(branch.getTag(), branch); } /** - * Bank TAG=57648 used for DC (Drift Chambers) TDC and ToT values. - * @param crate - * @param node + * returns detector digitized data entries from the event. + * all branches are analyzed and different types of digitized data + * is created for each type of ADC and TDC data. * @param event * @return */ - public List getDataEntries_57648(Integer crate, EvioNode node, EvioDataEvent event){ - List entries = new ArrayList<>(); - if(node.getTag()==57648){ - try { - ByteBuffer compBuffer = node.getByteData(true); - CompositeData compData = new CompositeData(compBuffer.array(),event.getByteOrder()); - //List cdatatypes = compData.getTypes(); - List cdataitems = compData.getItems(); + public List getDataEntries(EvioDataEvent event){ - int totalSize = cdataitems.size(); - int position = 0; - while( (position + 4) < totalSize){ - Byte slot = (Byte) cdataitems.get(position); - //Integer trig = (Integer) cdataitems.get(position+1); - Long time = (Long) cdataitems.get(position+2); - Integer nchannels = (Integer) cdataitems.get(position+3); - int counter = 0; - position = position + 4; - while(counter600*1024){ + // System.out.println("error: >>>> EVENT SIZE EXCEEDS 600 kB"); + // return new ArrayList(); + //} + + // zero out the trigger bits, but let the others properties inherit + // from the previous event, in the case where there's no HEAD bank: + this.setTriggerBits(0); + List rawEntries = new ArrayList<>(); + this.setTimeStamp(event); + for(EvioTreeBranch branch : branchMap.values()){ + List list = this.getDataEntries(event,branch.getTag()); + if(list != null){ + rawEntries.addAll(list); } - } - return entries; + List tdcEntries = this.getDataEntries_TDC(event); + rawEntries.addAll(tdcEntries); + List vtpEntries = this.getDataEntries_VTP(event); + rawEntries.addAll(vtpEntries); + List scalerEntries = this.getDataEntries_Scalers(event); + rawEntries.addAll(scalerEntries); + + this.getDataEntries_EPICS(event); + + return rawEntries; } /** - * Bank TAG=57636 used for RICH TDC values - * @param crate - * @param node + * returns list of decoded data in the event for given crate. * @param event + * @param crate * @return */ - public List getDataEntries_57636(Integer crate, EvioNode node, EvioDataEvent event){ - - ArrayList entries = new ArrayList<>(); - - if(node.getTag()==57636){ - try { - - ByteBuffer compBuffer = node.getByteData(true); - CompositeData compData = new CompositeData(compBuffer.array(),event.getByteOrder()); - - List cdatatypes = compData.getTypes(); - List cdataitems = compData.getItems(); - - if(cdatatypes.get(3) != DataType.NVALUE){ - System.err.println("[EvioRawDataSource] ** error ** corrupted " - + " bank. tag = " + node.getTag() + " num = " + node.getNum()); - return null; - } - - int position = 0; - while(position getDataEntries(EvioDataEvent event, int crate){ + List bankEntries = new ArrayList<>(); + EvioTreeBranch cbranch = branchMap.getOrDefault(crate, null); + if(cbranch == null ) return null; + for (EvioNode node : cbranch.getNodes()) { + if (node.getTag() == 57615) { + this.tiMaster = crate; + this.readHeaderBank(crate, node, event); + } + } + for(EvioNode node : cbranch.getNodes()){ + switch (node.getTag()) { + case 57617: + // This is regular integrated pulse mode, used for FTOF/FTCAL/ECAL + return CodaDecoders.getDataEntries_57617(crate, node, event); + case 57603: + // This is regular integrated pulse mode, used for streaming + return CodaDecoders.getDataEntries_57603(crate, node, event); + case 57602: + // This is regular integrated pulse mode, used for FTOF/FTCAL/ECAL + return CodaDecoders.getDataEntries_57602(crate, node, event); + case 57601: + // This is regular integrated pulse mode, used for FTOF/FTCAL/ECAL + return CodaDecoders.getDataEntries_57601(crate, node, event); + case 57627: + // This is regular integrated pulse mode, used for MM + return CodaDecoders.getDataEntries_57627(crate, node, event); + case 57640: + // This is bit-packed pulse mode, used for MM + return CodaDecoders.getDataEntries_57640(crate, node, event); + case 57622: + // This is regular DCRB bank with TDCs only + return CodaDecoders.getDataEntries_57622(crate, node, event); + case 57648: + // This is DCRB bank with TDCs and widths + return CodaDecoders.getDataEntries_57648(crate, node, event); + case 57636: + // RICH TDC data + return CodaDecoders.getDataEntries_57636(crate, node, event); + case 57657: + // ATOF Petiroc TDC data + return CodaDecoders.getDataEntries_57657(crate, node, event); + case 57641: + // RTPC data decoding + return CodaDecoders.getDataEntries_57641(crate, node, event); + default: + break; + } + } + return bankEntries; + } - while(counter>15)&0x1; - int tdc = rawtdc&0x7FFF; + private void setTimeStamp(EvioDataEvent event) { - DetectorDataDgtz bank = new DetectorDataDgtz(crate,slot.intValue(),2*(fiber*192+channel)+edge); - bank.addTDC(new TDCData(tdc)); + long ts = -1; - entries.add(bank); - position += 3; - counter++; + List tiEntries = this.getDataEntries_TI(event); + + if(tiEntries.size()==1) { + ts = tiEntries.get(0).getTimeStamp(); + } + else if(tiEntries.size()>1) { + // check sychronization + boolean tiSync=true; + int i0 = -1; + // set reference timestamp from first entry which is not the tiMaster nor PCIE: + for(int i=0; ideltaTS) { + tiSync=false; + if(this.timeStampErrors<100) { + System.err.println("WARNING: mismatch in TI time stamps: crate " + + tiEntries.get(i).getDescriptor().getCrate() + " reports " + + tiEntries.get(i).getTimeStamp() + " instead of the " + tiEntries.get(i0).getTimeStamp() + + " from crate " + tiEntries.get(i0).getDescriptor().getCrate()); } + else if(this.timeStampErrors==100) { + System.err.println("WARNING: reached the maximum number of timeStamp errors (100), supressing future warnings."); + } + this.timeStampErrors++; } - - return entries; - } catch (EvioException ex) { - Logger.getLogger(CodaEventDecoder.class.getName()).log(Level.SEVERE, null, ex); } + if(tiSync) ts = tiEntries.get(i0).getTimeStamp(); } - return entries; + this.timeStamp = ts ; } - /** - * Bank TAG=57657 used for ATOF PETIROC TDC values - * @param crate - * @param node - * @param event - * @return - * - * - * - * c "slot number" - * i "trigger number" - * l "time stamp" - * N "number of channels fired" - * c "channel number" - * i "tdc value" - * i "width value" - * - * - */ - public List getDataEntries_57657(Integer crate, EvioNode node, EvioDataEvent event){ + private void readHeaderBank(Integer crate, EvioNode node, EvioDataEvent event){ - ArrayList entries = new ArrayList<>(); - - if(node.getTag()==57657){ + if(node.getDataTypeObj()==DataType.INT32||node.getDataTypeObj()==DataType.UINT32){ try { - //System.err.println("Decoding ATOF PETIROC event!"); - ByteBuffer compBuffer = node.getByteData(true); - CompositeData compData = new CompositeData(compBuffer.array(),event.getByteOrder()); - - List cdatatypes = compData.getTypes(); - List cdataitems = compData.getItems(); - - if(cdatatypes.get(3) != DataType.NVALUE){ - System.err.println("[EvioRawDataSource] ** error ** corrupted " - + " bank. tag = " + node.getTag() + " num = " + node.getNum()); - return null; - } - - int position = 0; - while(position -> "bank" DetectorDataDgtz -> "tdc" TDCData - // there is a redundancy in timestamp: the same value is stored in TDCData and the DetectorDataDgz - // - bank.setTimeStamp(time_stamp); - bank.setTrigger(trig_num);; - TDCData tdc_data = new TDCData(tdc, tot); - tdc_data.setTimeStamp(time_stamp).setOrder(counter); - bank.addTDC(tdc_data); - entries.add(bank); - position += 3; // channel,tdc,tot - counter++; - //System.err.println("event: " + bank.toString()); + int[] intData = ByteDataTransformer.toIntArray(node.getStructureBuffer(true)); + this.runNumber = intData[3]; + this.eventNumber = intData[4]; + if(intData[5]!=0) this.unixTime = intData[5]; + this.helicityLevel3=HelicityBit.DNE.value(); + if(intData.length>7) { + if ( (intData[7] & 0x1) == 0) { + this.helicityLevel3=HelicityBit.UDF.value(); + } + else if ((intData[7]>>1 & 0x1) == 0) { + this.helicityLevel3=HelicityBit.MINUS.value(); + } + else { + this.helicityLevel3=HelicityBit.PLUS.value(); } } - - return entries; - } catch (EvioException ex) { - Logger.getLogger(CodaEventDecoder.class.getName()).log(Level.SEVERE, null, ex); + } catch (Exception e) { + this.runNumber = 10; + this.eventNumber = 1; } + } else { + System.out.println("[error] can not read header bank"); } - return entries; } - - - public void getDataEntries_EPICS(EvioDataEvent event){ + private void getDataEntries_EPICS(EvioDataEvent event){ epicsData = new JsonObject(); - List branches = this.getEventBranches(event); - for(EvioTreeBranch branch : branches){ + for(EvioTreeBranch branch : branchMap.values()){ for(EvioNode node : branch.getNodes()){ if(node.getTag()==57620) { byte[] stringData = ByteDataTransformer.toByteArray(node.getStructureBuffer(true)); @@ -1260,8 +295,7 @@ public void getDataEntries_EPICS(EvioDataEvent event){ public HelicityDecoderData getDataEntries_HelicityDecoder(EvioDataEvent event){ HelicityDecoderData data = null; - List branches = this.getEventBranches(event); - for(EvioTreeBranch branch : branches){ + for(EvioTreeBranch branch : branchMap.values()){ for(EvioNode node : branch.getNodes()){ if(node.getTag()==57651) { @@ -1338,13 +372,11 @@ public HelicityDecoderData getDataEntries_HelicityDecoder(EvioDataEvent event){ return data; } - public List getDataEntries_Scalers(EvioDataEvent event){ + private List getDataEntries_Scalers(EvioDataEvent event){ List scalerEntries = new ArrayList<>(); - List branches = this.getEventBranches(event); - for(EvioTreeBranch branch : branches){ - int crate = branch.getTag(); - for(EvioNode node : branch.getNodes()){ + for(int crate : branchMap.keySet()) { + for(EvioNode node : branchMap.get(crate).getNodes()){ if(node.getTag()==57637 || node.getTag()==57621){ int num = node.getNum(); int[] intData = ByteDataTransformer.toIntArray(node.getStructureBuffer(true)); @@ -1418,13 +450,53 @@ else if(node.getTag()==57621 && loop>=5) { return scalerEntries; } - public List getDataEntries_VTP(EvioDataEvent event){ + /** + * decoding bank that contains TI time stamp. + * @param event + * @return + */ + private List getDataEntries_TI(EvioDataEvent event){ + + List tiEntries = new ArrayList<>(); + for(int crate : branchMap.keySet()) { + for(EvioNode node : branchMap.get(crate).getNodes()){ + if(node.getTag()==57610){ + long[] longData = ByteDataTransformer.toLongArray(node.getStructureBuffer(true)); + int[] intData = ByteDataTransformer.toIntArray(node.getStructureBuffer(true)); + long tStamp = longData[2]&0x0000ffffffffffffL; + + // Below is endian swap if needed + //long ntStamp = (((long)(intData[5]&0x0000ffffL))<<32) | (intData[4]&0xffffffffL); + //System.out.println(longData[2]+" "+tStamp+" "+crate+" "+node.getDataLength()); + + DetectorDataDgtz entry = new DetectorDataDgtz(crate,0,0); + entry.setTimeStamp(tStamp); + if(node.getDataLength()==4) tiEntries.add(entry); + else if(node.getDataLength()==5) { // trigger supervisor crate + this.setTriggerBits(intData[6]); + } + else if(node.getDataLength()==6) { // New format Dec 1 2017 (run 1701) + this.setTriggerBits(intData[6]<<16|intData[7]); + } + else if(node.getDataLength()==7) { // New format Dec 1 2017 (run 1701) + long word = (( (long) intData[7])<<32) | (intData[6]&0xffffffffL); + this.setTriggerBits(word); + this.triggerWords.clear(); + for(int i=6; i<=8; i++) { + this.triggerWords.add(intData[i]); + } + } + } + } + } + + return tiEntries; + } + private List getDataEntries_VTP(EvioDataEvent event){ List vtpEntries = new ArrayList<>(); - List branches = this.getEventBranches(event); - for(EvioTreeBranch branch : branches){ - int crate = branch.getTag(); - for(EvioNode node : branch.getNodes()){ + for(int crate : branchMap.keySet()) { + for(EvioNode node : branchMap.get(crate).getNodes()){ if(node.getTag()==57634){ int[] intData = ByteDataTransformer.toIntArray(node.getStructureBuffer(true)); for(int loop = 0; loop < intData.length; loop++){ @@ -1438,21 +510,17 @@ public List getDataEntries_VTP(EvioDataEvent event){ } return vtpEntries; } + /** * reads the TDC values from the bank with tag = 57607, decodes * them and returns a list of digitized detector object. * @param event * @return */ - public List getDataEntries_TDC(EvioDataEvent event){ - + private List getDataEntries_TDC(EvioDataEvent event){ List tdcEntries = new ArrayList<>(); - List branches = this.getEventBranches(event); - - for(EvioTreeBranch branch : branches){ - int crate = branch.getTag(); - EvioTreeBranch cbranch = this.getEventBranch(branches, branch.getTag()); - for(EvioNode node : cbranch.getNodes()){ + for(int crate : branchMap.keySet()) { + for(EvioNode node : branchMap.get(crate).getNodes()){ if(node.getTag()==57607){ int[] intData = ByteDataTransformer.toIntArray(node.getStructureBuffer(true)); for(int loop = 2; loop < intData.length; loop++){ @@ -1470,51 +538,25 @@ public List getDataEntries_TDC(EvioDataEvent event){ return tdcEntries; } + public List getADCEntries(EvioDataEvent event){ + List entries = new ArrayList<>(); + for(EvioTreeBranch branch : branchMap.values()){ + List list = this.getADCEntries(event,branch.getTag()); + if (list != null) entries.addAll(list); + } + return entries; + } - /** - * decoding bank that contains TI time stamp. - * @param event - * @return - */ - public List getDataEntries_TI(EvioDataEvent event){ - - List tiEntries = new ArrayList<>(); - List branches = this.getEventBranches(event); - for(EvioTreeBranch branch : branches){ - int crate = branch.getTag(); - EvioTreeBranch cbranch = this.getEventBranch(branches, branch.getTag()); - for(EvioNode node : cbranch.getNodes()){ - if(node.getTag()==57610){ - long[] longData = ByteDataTransformer.toLongArray(node.getStructureBuffer(true)); - int[] intData = ByteDataTransformer.toIntArray(node.getStructureBuffer(true)); - long tStamp = longData[2]&0x0000ffffffffffffL; - - // Below is endian swap if needed - //long ntStamp = (((long)(intData[5]&0x0000ffffL))<<32) | (intData[4]&0xffffffffL); - //System.out.println(longData[2]+" "+tStamp+" "+crate+" "+node.getDataLength()); - - DetectorDataDgtz entry = new DetectorDataDgtz(crate,0,0); - entry.setTimeStamp(tStamp); - if(node.getDataLength()==4) tiEntries.add(entry); - else if(node.getDataLength()==5) { // trigger supervisor crate - this.setTriggerBits(intData[6]); - } - else if(node.getDataLength()==6) { // New format Dec 1 2017 (run 1701) - this.setTriggerBits(intData[6]<<16|intData[7]); - } - else if(node.getDataLength()==7) { // New format Dec 1 2017 (run 1701) - long word = (( (long) intData[7])<<32) | (intData[6]&0xffffffffL); - this.setTriggerBits(word); - this.triggerWords.clear(); - for(int i=6; i<=8; i++) { - this.triggerWords.add(intData[i]); - } - } - } + private List getADCEntries(EvioDataEvent event, int crate){ + List entries = new ArrayList<>(); + EvioTreeBranch cbranch = branchMap.getOrDefault(crate, null); + if(cbranch == null ) return null; + for(EvioNode node : cbranch.getNodes()){ + if(node.getTag()==57638){ + return CodaDecoders.getDataEntries_57638(crate, node, event); } } - - return tiEntries; + return entries; } public static void main(String[] args){ From abb90b5ef5d462a22257502b8155acc55ba200e8 Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Tue, 13 Jan 2026 15:28:12 -0500 Subject: [PATCH 3/8] use global /daq/tt translation table --- .../detector/decode/DetectorEventDecoder.java | 52 +++++++------------ 1 file changed, 18 insertions(+), 34 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 0fc6fdfbaf..84ec0a6cf4 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 @@ -35,6 +35,8 @@ public class DetectorEventDecoder { private ExtendedFADCFitter extendedFitter = new ExtendedFADCFitter(); private MVTFitter mvtFitter = new MVTFitter(); + private TranslationTable translator = new TranslationTable(); + public DetectorEventDecoder(boolean development){ if(development==true){ this.initDecoderDev(); @@ -56,6 +58,11 @@ public void setVariation(String variation) { } public void setRunNumber(int run){ + if (run != this.runNumber) { + translator = new TranslationTable(); + for (int i=0; i detectorData){ - // Preload CCDB tables: - ArrayList tables = new ArrayList<>(); - for (String name : tablesTrans) { - tables.add(translationManager.getConstants(runNumber, name)); - } - - 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 x = translator.getIntegersByHash(hash); - for(int i = 0; i < data.getADCSize(); i++) data.getADCData(i).setOrder(order); - for(int i = 0; i < data.getTDCSize(); i++) data.getTDCData(i).setOrder(order); - - // Assume there's only one instance of this crate/slot/channel - // in all translation tables, and we found it, so stop: - break; - } + // Set the translated detector indexing: + d.getDescriptor().setSectorLayerComponentOrderType(x.get(0),x.get(1),x.get(2),x.get(3),x.get(4)); + for (int i=0; i Date: Wed, 28 Jan 2026 20:57:40 -0500 Subject: [PATCH 4/8] add gold tests --- libexec/diffgold | 13 +++++++++++++ libexec/rungold | 18 ++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100755 libexec/diffgold create mode 100755 libexec/rungold diff --git a/libexec/diffgold b/libexec/diffgold new file mode 100755 index 0000000000..bd2928304d --- /dev/null +++ b/libexec/diffgold @@ -0,0 +1,13 @@ +#!/bin/bash + +a=development +b=redecodering2 + +for x in $a/*.hipo +do + y=$b/$(basename $x) + stub=$(basename $x) + stub=${stub%%.*} + hipo-diff -q 1 -s 0,1,2 -n 1000 $x $y > $stub.log +done + diff --git a/libexec/rungold b/libexec/rungold new file mode 100755 index 0000000000..1c95cf67ea --- /dev/null +++ b/libexec/rungold @@ -0,0 +1,18 @@ +#!/bin/bash + +csv=gold.csv +cache=~/pin-gold.txt +IFS=$'\n' + +for x in $(tail -n +2 $csv) +do + x=${x//[[:space:]]/} + run=${x##*,} + period=${x%%,*} + stub=${period}_${run} + data=$(grep ${run} $cache | grep 1$) + decoder4u -n 10000 -o $stub.hipo $data >& $stub.log & +done + +wait + From fddc847349487309f419fb807ef53524c1da7462 Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Wed, 28 Jan 2026 21:21:53 -0500 Subject: [PATCH 5/8] parrallelize --- libexec/diffgold | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libexec/diffgold b/libexec/diffgold index bd2928304d..7157d76903 100755 --- a/libexec/diffgold +++ b/libexec/diffgold @@ -8,6 +8,8 @@ do y=$b/$(basename $x) stub=$(basename $x) stub=${stub%%.*} - hipo-diff -q 1 -s 0,1,2 -n 1000 $x $y > $stub.log + hipo-diff -q 1 -s 0,1,2 -n 1000 $x $y >& $stub.log & done +wait + From efaccc0a8347a27e278d125547b1d751ac70f442 Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Mon, 2 Feb 2026 18:25:13 -0500 Subject: [PATCH 6/8] cleanup --- libexec/pin-gold.txt | 160 +++++++++++++++++++++++++++++++++++++++++++ libexec/rungold | 5 +- 2 files changed, 163 insertions(+), 2 deletions(-) create mode 100644 libexec/pin-gold.txt diff --git a/libexec/pin-gold.txt b/libexec/pin-gold.txt new file mode 100644 index 0000000000..d6e655c24a --- /dev/null +++ b/libexec/pin-gold.txt @@ -0,0 +1,160 @@ +/cache/clas12/rg-a/data/clas_004013.evio.0 +/cache/clas12/rg-a/data/clas_004013.evio.1 +/cache/clas12/rg-a/data/clas_004013.evio.2 +/cache/clas12/rg-a/data/clas_004013.evio.3 +/cache/clas12/rg-a/data/clas_004013.evio.4 +/cache/clas12/rg-a/data/clas_004013.evio.5 +/cache/clas12/rg-a/data/clas_004013.evio.6 +/cache/clas12/rg-a/data/clas_004013.evio.7 +/cache/clas12/rg-a/data/clas_004013.evio.8 +/cache/clas12/rg-a/data/clas_004013.evio.9 +/cache/clas12/rg-a/data/clas_005038/clas_005038.evio.00000 +/cache/clas12/rg-a/data/clas_005038/clas_005038.evio.00001 +/cache/clas12/rg-a/data/clas_005038/clas_005038.evio.00002 +/cache/clas12/rg-a/data/clas_005038/clas_005038.evio.00003 +/cache/clas12/rg-a/data/clas_005038/clas_005038.evio.00004 +/cache/clas12/rg-a/data/clas_005038/clas_005038.evio.00005 +/cache/clas12/rg-a/data/clas_005038/clas_005038.evio.00006 +/cache/clas12/rg-a/data/clas_005038/clas_005038.evio.00007 +/cache/clas12/rg-a/data/clas_005038/clas_005038.evio.00008 +/cache/clas12/rg-a/data/clas_005038/clas_005038.evio.00009 +/cache/clas12/rg-a/data/clas_006666/clas_006666.evio.00000 +/cache/clas12/rg-a/data/clas_006666/clas_006666.evio.00001 +/cache/clas12/rg-a/data/clas_006666/clas_006666.evio.00002 +/cache/clas12/rg-a/data/clas_006666/clas_006666.evio.00003 +/cache/clas12/rg-a/data/clas_006666/clas_006666.evio.00004 +/cache/clas12/rg-a/data/clas_006666/clas_006666.evio.00005 +/cache/clas12/rg-a/data/clas_006666/clas_006666.evio.00006 +/cache/clas12/rg-a/data/clas_006666/clas_006666.evio.00007 +/cache/clas12/rg-a/data/clas_006666/clas_006666.evio.00008 +/cache/clas12/rg-a/data/clas_006666/clas_006666.evio.00009 +/cache/clas12/rg-b/data/clas_011567/clas_011567.evio.00000 +/cache/clas12/rg-b/data/clas_011567/clas_011567.evio.00001 +/cache/clas12/rg-b/data/clas_011567/clas_011567.evio.00002 +/cache/clas12/rg-b/data/clas_011567/clas_011567.evio.00003 +/cache/clas12/rg-b/data/clas_011567/clas_011567.evio.00004 +/cache/clas12/rg-b/data/clas_011567/clas_011567.evio.00005 +/cache/clas12/rg-b/data/clas_011567/clas_011567.evio.00006 +/cache/clas12/rg-b/data/clas_011567/clas_011567.evio.00007 +/cache/clas12/rg-b/data/clas_011567/clas_011567.evio.00008 +/cache/clas12/rg-b/data/clas_011567/clas_011567.evio.00009 +/cache/clas12/rg-c/data/clas_016600/clas_016600.evio.00000 +/cache/clas12/rg-c/data/clas_016600/clas_016600.evio.00001 +/cache/clas12/rg-c/data/clas_016600/clas_016600.evio.00002 +/cache/clas12/rg-c/data/clas_016600/clas_016600.evio.00003 +/cache/clas12/rg-c/data/clas_016600/clas_016600.evio.00004 +/cache/clas12/rg-c/data/clas_016600/clas_016600.evio.00005 +/cache/clas12/rg-c/data/clas_016600/clas_016600.evio.00006 +/cache/clas12/rg-c/data/clas_016600/clas_016600.evio.00007 +/cache/clas12/rg-c/data/clas_016600/clas_016600.evio.00008 +/cache/clas12/rg-c/data/clas_016600/clas_016600.evio.00009 +/cache/clas12/rg-c/data/clas_017407/clas_017407.evio.00000 +/cache/clas12/rg-c/data/clas_017407/clas_017407.evio.00001 +/cache/clas12/rg-c/data/clas_017407/clas_017407.evio.00002 +/cache/clas12/rg-c/data/clas_017407/clas_017407.evio.00003 +/cache/clas12/rg-c/data/clas_017407/clas_017407.evio.00004 +/cache/clas12/rg-c/data/clas_017407/clas_017407.evio.00005 +/cache/clas12/rg-c/data/clas_017407/clas_017407.evio.00006 +/cache/clas12/rg-c/data/clas_017407/clas_017407.evio.00007 +/cache/clas12/rg-c/data/clas_017407/clas_017407.evio.00008 +/cache/clas12/rg-c/data/clas_017407/clas_017407.evio.00009 +/cache/clas12/rg-c/data/clas_017800/clas_017800.evio.00000 +/cache/clas12/rg-c/data/clas_017800/clas_017800.evio.00001 +/cache/clas12/rg-c/data/clas_017800/clas_017800.evio.00002 +/cache/clas12/rg-c/data/clas_017800/clas_017800.evio.00003 +/cache/clas12/rg-c/data/clas_017800/clas_017800.evio.00004 +/cache/clas12/rg-c/data/clas_017800/clas_017800.evio.00005 +/cache/clas12/rg-c/data/clas_017800/clas_017800.evio.00006 +/cache/clas12/rg-c/data/clas_017800/clas_017800.evio.00007 +/cache/clas12/rg-c/data/clas_017800/clas_017800.evio.00008 +/cache/clas12/rg-c/data/clas_017800/clas_017800.evio.00009 +/cache/clas12/rg-d/data/clas_018779/clas_018779.evio.00000 +/cache/clas12/rg-d/data/clas_018779/clas_018779.evio.00001 +/cache/clas12/rg-d/data/clas_018779/clas_018779.evio.00002 +/cache/clas12/rg-d/data/clas_018779/clas_018779.evio.00003 +/cache/clas12/rg-d/data/clas_018779/clas_018779.evio.00004 +/cache/clas12/rg-d/data/clas_018779/clas_018779.evio.00005 +/cache/clas12/rg-d/data/clas_018779/clas_018779.evio.00006 +/cache/clas12/rg-d/data/clas_018779/clas_018779.evio.00007 +/cache/clas12/rg-d/data/clas_018779/clas_018779.evio.00008 +/cache/clas12/rg-d/data/clas_018779/clas_018779.evio.00009 +/cache/clas12/rg-e/data/clas_020522/clas_020522.evio.00000 +/cache/clas12/rg-e/data/clas_020522/clas_020522.evio.00001 +/cache/clas12/rg-e/data/clas_020522/clas_020522.evio.00002 +/cache/clas12/rg-e/data/clas_020522/clas_020522.evio.00003 +/cache/clas12/rg-e/data/clas_020522/clas_020522.evio.00004 +/cache/clas12/rg-e/data/clas_020522/clas_020522.evio.00005 +/cache/clas12/rg-e/data/clas_020522/clas_020522.evio.00006 +/cache/clas12/rg-e/data/clas_020522/clas_020522.evio.00007 +/cache/clas12/rg-e/data/clas_020522/clas_020522.evio.00008 +/cache/clas12/rg-e/data/clas_020522/clas_020522.evio.00009 +/cache/clas12/rg-f/data/clas_012933/clas_012933.evio.00000 +/cache/clas12/rg-f/data/clas_012933/clas_012933.evio.00000 +/cache/clas12/rg-f/data/clas_012933/clas_012933.evio.00001 +/cache/clas12/rg-f/data/clas_012933/clas_012933.evio.00001 +/cache/clas12/rg-f/data/clas_012933/clas_012933.evio.00002 +/cache/clas12/rg-f/data/clas_012933/clas_012933.evio.00002 +/cache/clas12/rg-f/data/clas_012933/clas_012933.evio.00003 +/cache/clas12/rg-f/data/clas_012933/clas_012933.evio.00003 +/cache/clas12/rg-f/data/clas_012933/clas_012933.evio.00004 +/cache/clas12/rg-f/data/clas_012933/clas_012933.evio.00004 +/cache/clas12/rg-f/data/clas_012933/clas_012933.evio.00005 +/cache/clas12/rg-f/data/clas_012933/clas_012933.evio.00005 +/cache/clas12/rg-f/data/clas_012933/clas_012933.evio.00006 +/cache/clas12/rg-f/data/clas_012933/clas_012933.evio.00006 +/cache/clas12/rg-f/data/clas_012933/clas_012933.evio.00007 +/cache/clas12/rg-f/data/clas_012933/clas_012933.evio.00007 +/cache/clas12/rg-f/data/clas_012933/clas_012933.evio.00008 +/cache/clas12/rg-f/data/clas_012933/clas_012933.evio.00008 +/cache/clas12/rg-f/data/clas_012933/clas_012933.evio.00009 +/cache/clas12/rg-f/data/clas_012933/clas_012933.evio.00009 +/cache/clas12/rg-k/data/clas_005700/clas_005700.evio.00000 +/cache/clas12/rg-k/data/clas_005700/clas_005700.evio.00001 +/cache/clas12/rg-k/data/clas_005700/clas_005700.evio.00002 +/cache/clas12/rg-k/data/clas_005700/clas_005700.evio.00003 +/cache/clas12/rg-k/data/clas_005700/clas_005700.evio.00004 +/cache/clas12/rg-k/data/clas_005700/clas_005700.evio.00005 +/cache/clas12/rg-k/data/clas_005700/clas_005700.evio.00006 +/cache/clas12/rg-k/data/clas_005700/clas_005700.evio.00007 +/cache/clas12/rg-k/data/clas_005700/clas_005700.evio.00008 +/cache/clas12/rg-k/data/clas_005700/clas_005700.evio.00009 +/cache/clas12/rg-k/data/clas_019877/clas_019877.evio.00000 +/cache/clas12/rg-k/data/clas_019877/clas_019877.evio.00001 +/cache/clas12/rg-k/data/clas_019877/clas_019877.evio.00002 +/cache/clas12/rg-k/data/clas_019877/clas_019877.evio.00003 +/cache/clas12/rg-k/data/clas_019877/clas_019877.evio.00004 +/cache/clas12/rg-k/data/clas_019877/clas_019877.evio.00005 +/cache/clas12/rg-k/data/clas_019877/clas_019877.evio.00006 +/cache/clas12/rg-k/data/clas_019877/clas_019877.evio.00007 +/cache/clas12/rg-k/data/clas_019877/clas_019877.evio.00008 +/cache/clas12/rg-k/data/clas_019877/clas_019877.evio.00009 +/cache/clas12/rg-l/data/clas_023050/clas_023050.evio.00000 +/cache/clas12/rg-l/data/clas_023050/clas_023050.evio.00001 +/cache/clas12/rg-l/data/clas_023050/clas_023050.evio.00002 +/cache/clas12/rg-l/data/clas_023050/clas_023050.evio.00003 +/cache/clas12/rg-l/data/clas_023050/clas_023050.evio.00004 +/cache/clas12/rg-l/data/clas_023050/clas_023050.evio.00005 +/cache/clas12/rg-l/data/clas_023050/clas_023050.evio.00006 +/cache/clas12/rg-l/data/clas_023050/clas_023050.evio.00007 +/cache/clas12/rg-l/data/clas_023050/clas_023050.evio.00008 +/cache/clas12/rg-l/data/clas_023050/clas_023050.evio.00009 +/cache/clas12/rg-m/data/clas_pin_015833/clas_pin_015833.evio.00000 +/cache/clas12/rg-m/data/clas_pin_015833/clas_pin_015833.evio.00001 +/cache/clas12/rg-m/data/clas_pin_015833/clas_pin_015833.evio.00002 +/cache/clas12/rg-m/data/clas_pin_015833/clas_pin_015833.evio.00003 +/cache/clas12/rg-m/data/clas_pin_015833/clas_pin_015833.evio.00004 +/cache/clas12/rg-m/data/clas_pin_015833/clas_pin_015833.evio.00005 +/cache/clas12/rg-m/data/clas_pin_015833/clas_pin_015833.evio.00006 +/cache/clas12/rg-m/data/clas_pin_015833/clas_pin_015833.evio.00007 +/cache/clas12/rg-m/data/clas_pin_015833/clas_pin_015833.evio.00008 +/cache/clas12/rg-m/data/clas_pin_015833/clas_pin_015833.evio.00009 +/cache/clas12/rg-b/data/clas_006302/clas_006302.evio.00000 +/cache/clas12/rg-b/data/clas_006302/clas_006302.evio.00001 +/cache/clas12/rg-b/data/clas_006302/clas_006302.evio.00002 +/cache/clas12/rg-b/data/clas_006302/clas_006302.evio.00003 +/cache/clas12/rg-b/data/clas_006302/clas_006302.evio.00004 +/cache/clas12/rg-b/data/clas_006302/clas_006302.evio.00005 +/cache/clas12/rg-b/data/clas_006302/clas_006302.evio.00006 +/cache/clas12/rg-b/data/clas_006302/clas_006302.evio.00007 +/cache/clas12/rg-b/data/clas_006302/clas_006302.evio.00008 +/cache/clas12/rg-b/data/clas_006302/clas_006302.evio.00009 diff --git a/libexec/rungold b/libexec/rungold index 1c95cf67ea..0708533e3e 100755 --- a/libexec/rungold +++ b/libexec/rungold @@ -1,7 +1,8 @@ #!/bin/bash +exe=decoder4u -n 10000 csv=gold.csv -cache=~/pin-gold.txt +cache=$(cd $(dirname ${BASH_SOURCE[0]}) &> /dev/null && pwd)/pin-gold.txt IFS=$'\n' for x in $(tail -n +2 $csv) @@ -11,7 +12,7 @@ do period=${x%%,*} stub=${period}_${run} data=$(grep ${run} $cache | grep 1$) - decoder4u -n 10000 -o $stub.hipo $data >& $stub.log & + $exe -o $stub.hipo $data >& $stub.log & done wait From 75c341890edbe5119979364e5bdcb45a0d7af85f Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Mon, 2 Feb 2026 19:28:47 -0500 Subject: [PATCH 7/8] check for recon-util in $PATH --- libexec/profile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libexec/profile b/libexec/profile index fefe609977..4085e05b72 100755 --- a/libexec/profile +++ b/libexec/profile @@ -27,6 +27,9 @@ stub=${stub%%.*} which asprof >& /dev/null [ "$?" -ne 0 ] && echo 'ERROR: asprof is not in $PATH.' && exit 9 +which recon-util >& /dev/null +[ "$?" -ne 0 ] && echo 'ERROR: recon-util is not in $PATH.' && exit 9 + recon-util -y $yaml -n $nevents -o pro_$stub.hipo -i $data >& pro_$stub.log & pid_bash=$! From eba4d52957a9a95f60bc174a39a3b60c5d665b19 Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Mon, 2 Feb 2026 21:07:37 -0500 Subject: [PATCH 8/8] add flexibility --- libexec/profile | 53 ++++++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/libexec/profile b/libexec/profile index 4085e05b72..50d659278c 100755 --- a/libexec/profile +++ b/libexec/profile @@ -1,36 +1,42 @@ #!/bin/bash -set -e - -# configure: -event=cpu #nativemem +event=cpu format=flat -nevents=1000 seconds=12 -yaml=etc/services/data-ai-uber.yml -while getopts y:n:f:e:s:h opt +usage="Usage: profile [-h] [-s seconds] [-w seconds] [-e event] [-f format] [--] executable args" +usage2="Usage: profile [-h] [-s seconds] [-w seconds] [-e cpu|alloc|nativemem|lock|cache-misses] [-f flat|traces|collapsed|flamegraph|tree|jfr|otlp] [--] executable args" + +while getopts s:f:e:o:w:h opt do case $opt in s) seconds=$OPTARG ;; - y) yaml=$OPTARG ;; - n) nevents=$OPTARG ;; f) format=$OPTARG ;; e) event=$OPTARG ;; - h) echo "\nUsage: profile [-y YAML] [-n #] [-e EVENT] datafile" && exit 0 ;; + o) stub=$OPTARG ;; + w) warmup=$OPTARG ;; + h) echo $usage2 && exit 0 ;; + --) break ;; + \?) echo $usage && exit 1 ;; +# :) echo $usage && exit 2 ;; esac done + shift $((OPTIND-1)) -data=$1 -stub=$(basename $data) -stub=${stub%%.*} +executable=$1 +arguments=${@:2} which asprof >& /dev/null -[ "$?" -ne 0 ] && echo 'ERROR: asprof is not in $PATH.' && exit 9 +[ "$?" -ne 0 ] && echo 'ERROR: asprof is not in $PATH.' && exit 3 + +which $executable >& /dev/null +[ "$?" -ne 0 ] && echo "ERROR: $executable is not in \$PATH." && exit 4 + +echo "Running asprof on '$executable $arguments' ..." + +set -e -which recon-util >& /dev/null -[ "$?" -ne 0 ] && echo 'ERROR: recon-util is not in $PATH.' && exit 9 +$executable $arguments >& asprof_$stub.log -recon-util -y $yaml -n $nevents -o pro_$stub.hipo -i $data >& pro_$stub.log & pid_bash=$! echo PID1=$pid_bash @@ -41,14 +47,15 @@ echo PID2=$pid_java ps waux && ps -p $pid_java -echo "Waiting for 60 seconds of CoatJava warmup ..." -for x in $(seq 60); do let y=60-$x && echo -e -n "\r$y ..." && sleep 1; done +echo "Waiting for $warmup seconds of warmup ..." +for x in $(seq $warmup); do let y=$warmup-$x && echo -e -n "\r$y ..." && sleep 1; done -tail -n 42 pro_$stub.log +# This 42 is probably for recon-util: +tail -n 42 asprof_$stub.log -asprof --title "Coatjava - asprof - $event" -e $event \ - -d $seconds -o $format -f pro_${format}_${event}_$stub $pid_java +asprof --title "Coatjava:asprof:$executable:$event" -e $event \ + -d $seconds -o $format -f asprof_${format}_${event}_$stub $pid_java kill -9 $pid_java -rm -f pro_$stub.hipo +rm -f asprof_$stub.hipo