diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/banks/RawBank.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/banks/RawBank.java index fffc360b58..19482d6005 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/banks/RawBank.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/banks/RawBank.java @@ -74,9 +74,9 @@ public static enum OrderType { BGADDED_NOISE1 ( 70), // background hits retained by level-1 denoising BGADDED_NOISE2 ( 80), // background hits retained by level-2 denoising BGADDED_NOISE3 ( 90), // background hits retained by level-3 denoising - USER1 (100), - USER2 (110), - USER3 (120); + DECREMOVED (100), // hits removed during decoding + USER1 (110), + USER2 (120); private final int rawOrderId; private OrderType(int id){ rawOrderId = id; } public int getTypeId() { return rawOrderId; } diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CLASDecoder4.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CLASDecoder4.java index b78ca63d31..9db665354f 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CLASDecoder4.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CLASDecoder4.java @@ -139,6 +139,7 @@ public void initEvent(DataEvent event){ detectorDecoder.translate(dataList); detectorDecoder.fitPulses(dataList); + detectorDecoder.filterTDCs(dataList); if(this.decoderDebugMode>0){ System.out.println("\n>>>>>>>>> TRANSLATED data"); for(DetectorDataDgtz data : dataList){ @@ -308,8 +309,10 @@ public Bank getDataBankTDC(String name, DetectorType type){ tdcBANK.putByte("sector", i, (byte) tdcDGTZ.get(i).getDescriptor().getSector()); tdcBANK.putByte("layer", i, (byte) tdcDGTZ.get(i).getDescriptor().getLayer()); tdcBANK.putShort("component", i, (short) tdcDGTZ.get(i).getDescriptor().getComponent()); - tdcBANK.putByte("order", i, (byte) tdcDGTZ.get(i).getDescriptor().getOrder()); + tdcBANK.putByte("order", i, (byte) (tdcDGTZ.get(i).getDescriptor().getOrder()+tdcDGTZ.get(i).getTDCData(0).getType().getTypeId())); tdcBANK.putInt("TDC", i, tdcDGTZ.get(i).getTDCData(0).getTime()); + if(name == "DC::tdc") + tdcBANK.putShort("ToT", i, (short) tdcDGTZ.get(i).getTDCData(0).getToT()); } return tdcBANK; } diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CodaEventDecoder.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CodaEventDecoder.java index 7b5dfd7069..c8c01bde21 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CodaEventDecoder.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CodaEventDecoder.java @@ -280,10 +280,13 @@ else if(node.getTag()==57640){ return this.getDataEntries_57640(crate, node, event); } else if(node.getTag()==57622){ - // This is regular integrated pulse mode, used for FTOF - // FTCAL and EC/PCAL + // 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); @@ -954,9 +957,56 @@ public List getDataEntries_57622(Integer crate, EvioNode node } } } catch (EvioException ex) { - //Logger.getLogger(EvioRawDataSource.class.getName()).log(Level.SEVERE, null, ex); + Logger.getLogger(CodaEventDecoder.class.getName()).log(Level.SEVERE, null, ex); } catch (IndexOutOfBoundsException ex){ - //System.out.println("[ERROR] ----> ERROR DECODING COMPOSITE DATA FOR ONE EVENT"); + 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 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{ - private int tdcOrder = 0; // Used for sorting - private int tdcTime = 0; - private int tdcToT = 0; // Time over threshold + private int tdcOrder = 0; // Used for sorting + private int tdcTime = 0; + private int tdcToT = 0; // Time over threshold private Long timeStamp = 0L; + private OrderType tdcType = OrderType.NOMINAL; public TDCData() {} public TDCData(int time) { this.tdcTime = time;} @@ -347,10 +349,12 @@ public TDCData() {} public int getToT() { return this.tdcToT;} public int getOrder() { return tdcOrder;} public long getTimeStamp(){ return this.timeStamp; } + public OrderType getType() { return tdcType;} public TDCData setOrder(int order) { tdcOrder = order;return this;} public TDCData setTime(short time) { tdcTime = time;return this;} public TDCData setToT(short ToT) { tdcToT = ToT;return this;} public TDCData setTimeStamp(long time){ timeStamp = time;return this; } + public TDCData setType(OrderType type) { tdcType = type; return this;} @Override public String toString(){ 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 09a4ad7bf5..d99b4544c7 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DetectorEventDecoder.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DetectorEventDecoder.java @@ -1,7 +1,12 @@ package org.jlab.detector.decode; +import java.util.ArrayList; import java.util.Arrays; +import java.util.Comparator; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import org.jlab.detector.banks.RawBank.OrderType; import org.jlab.detector.base.DetectorType; import org.jlab.detector.calib.utils.ConstantsManager; import org.jlab.detector.decode.DetectorDataDgtz.ADCData; @@ -21,6 +26,7 @@ public class DetectorEventDecoder { List keysTrans = null; List tablesFitter = null; List keysFitter = null; + List keysFilter = null; private int runNumber = 10; @@ -109,6 +115,9 @@ public final void initDecoder(){ }); fitterManager.init(keysFitter, tablesFitter); + // Data filter list + keysFilter = Arrays.asList(new String[]{"DC"}); + scalerManager.init(Arrays.asList(new String[]{"/runcontrol/fcup","/runcontrol/slm","/runcontrol/hwp", "/runcontrol/helicity","/daq/config/scalers/dsc1"})); } @@ -211,4 +220,42 @@ public void fitPulses(List detectorData){ } } } + + + public void filterTDCs(List detectorData){ + int maxMultiplicity = 1; + for(String table : keysFilter){ + Map> filteredData = new HashMap<>(); + for(DetectorDataDgtz data : detectorData){ + if(data.getDescriptor().getType()==DetectorType.getType(table)) { + int key = data.getDescriptor().getHashCode(); + if(!filteredData.containsKey(key)) + filteredData.put(key, new ArrayList<>()); + filteredData.get(key).add(data); + } + } + for(int key : filteredData.keySet()) { + filteredData.get(key).sort(new TDCComparator()); + if(filteredData.get(key).size()>maxMultiplicity) + for(int i=maxMultiplicity; i { + + // override the compare() method + public int compare(DetectorDataDgtz s1, DetectorDataDgtz s2) + { + if(s1.getTDCSize()>0 && s2.getTDCSize()>0) + return s1.getTDCData(0).getTime()0) + return 1; + else if(s2.getTDCSize()>0) + return -1; + else + return 0; + } + } } diff --git a/etc/bankdefs/hipo4/data.json b/etc/bankdefs/hipo4/data.json index 07367082d8..9f42279e5d 100644 --- a/etc/bankdefs/hipo4/data.json +++ b/etc/bankdefs/hipo4/data.json @@ -212,7 +212,8 @@ { "name":"layer" , "type":"B", "info":"layer (1..36)"}, { "name":"component" , "type":"S", "info":"wire number (1..112)"}, { "name":"order" , "type":"B", "info":"order: 2 - TDCL , 3 - TDCR"}, - { "name":"TDC" , "type":"I", "info":"TDC value"} + { "name":"TDC" , "type":"I", "info":"TDC value"}, + { "name":"ToT" , "type":"S", "info":"Time Over Threshold"} ] }, {