Skip to content

Commit ed6fb2b

Browse files
new DCRB firmware (#509)
* implemented decoding of new DCRB banks with ToT and order labeling of DC hit to use the first in time * removed anused code * printingg exception from DC banks decoding --------- Co-authored-by: Nathan Baltzell <baltzell@gmx.com>
1 parent e5ce2ab commit ed6fb2b

6 files changed

Lines changed: 117 additions & 12 deletions

File tree

common-tools/clas-detector/src/main/java/org/jlab/detector/banks/RawBank.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ public static enum OrderType {
7474
BGADDED_NOISE1 ( 70), // background hits retained by level-1 denoising
7575
BGADDED_NOISE2 ( 80), // background hits retained by level-2 denoising
7676
BGADDED_NOISE3 ( 90), // background hits retained by level-3 denoising
77-
USER1 (100),
78-
USER2 (110),
79-
USER3 (120);
77+
DECREMOVED (100), // hits removed during decoding
78+
USER1 (110),
79+
USER2 (120);
8080
private final int rawOrderId;
8181
private OrderType(int id){ rawOrderId = id; }
8282
public int getTypeId() { return rawOrderId; }

common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CLASDecoder4.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ public void initEvent(DataEvent event){
139139

140140
detectorDecoder.translate(dataList);
141141
detectorDecoder.fitPulses(dataList);
142+
detectorDecoder.filterTDCs(dataList);
142143
if(this.decoderDebugMode>0){
143144
System.out.println("\n>>>>>>>>> TRANSLATED data");
144145
for(DetectorDataDgtz data : dataList){
@@ -308,8 +309,10 @@ public Bank getDataBankTDC(String name, DetectorType type){
308309
tdcBANK.putByte("sector", i, (byte) tdcDGTZ.get(i).getDescriptor().getSector());
309310
tdcBANK.putByte("layer", i, (byte) tdcDGTZ.get(i).getDescriptor().getLayer());
310311
tdcBANK.putShort("component", i, (short) tdcDGTZ.get(i).getDescriptor().getComponent());
311-
tdcBANK.putByte("order", i, (byte) tdcDGTZ.get(i).getDescriptor().getOrder());
312+
tdcBANK.putByte("order", i, (byte) (tdcDGTZ.get(i).getDescriptor().getOrder()+tdcDGTZ.get(i).getTDCData(0).getType().getTypeId()));
312313
tdcBANK.putInt("TDC", i, tdcDGTZ.get(i).getTDCData(0).getTime());
314+
if(name == "DC::tdc")
315+
tdcBANK.putShort("ToT", i, (short) tdcDGTZ.get(i).getTDCData(0).getToT());
313316
}
314317
return tdcBANK;
315318
}

common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CodaEventDecoder.java

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,13 @@ else if(node.getTag()==57640){
280280
return this.getDataEntries_57640(crate, node, event);
281281
}
282282
else if(node.getTag()==57622){
283-
// This is regular integrated pulse mode, used for FTOF
284-
// FTCAL and EC/PCAL
283+
// This is regular DCRB bank with TDCs only
285284
return this.getDataEntries_57622(crate, node, event);
286285
}
286+
else if(node.getTag()==57648){
287+
// This is DCRB bank with TDCs and widths
288+
return this.getDataEntries_57648(crate, node, event);
289+
}
287290
else if(node.getTag()==57636){
288291
// RICH TDC data
289292
return this.getDataEntries_57636(crate, node, event);
@@ -954,9 +957,56 @@ public List<DetectorDataDgtz> getDataEntries_57622(Integer crate, EvioNode node
954957
}
955958
}
956959
} catch (EvioException ex) {
957-
//Logger.getLogger(EvioRawDataSource.class.getName()).log(Level.SEVERE, null, ex);
960+
Logger.getLogger(CodaEventDecoder.class.getName()).log(Level.SEVERE, null, ex);
958961
} catch (IndexOutOfBoundsException ex){
959-
//System.out.println("[ERROR] ----> ERROR DECODING COMPOSITE DATA FOR ONE EVENT");
962+
Logger.getLogger(CodaEventDecoder.class.getName()).log(Level.SEVERE, null, ex);
963+
}
964+
965+
}
966+
return entries;
967+
}
968+
969+
/**
970+
* Bank TAG=57648 used for DC (Drift Chambers) TDC and ToT values.
971+
* @param crate
972+
* @param node
973+
* @param event
974+
* @return
975+
*/
976+
public List<DetectorDataDgtz> getDataEntries_57648(Integer crate, EvioNode node, EvioDataEvent event){
977+
List<DetectorDataDgtz> entries = new ArrayList<>();
978+
if(node.getTag()==57648){
979+
try {
980+
ByteBuffer compBuffer = node.getByteData(true);
981+
CompositeData compData = new CompositeData(compBuffer.array(),event.getByteOrder());
982+
//List<DataType> cdatatypes = compData.getTypes();
983+
List<Object> cdataitems = compData.getItems();
984+
985+
int totalSize = cdataitems.size();
986+
int position = 0;
987+
while( (position + 4) < totalSize){
988+
Byte slot = (Byte) cdataitems.get(position);
989+
//Integer trig = (Integer) cdataitems.get(position+1);
990+
Long time = (Long) cdataitems.get(position+2);
991+
Integer nchannels = (Integer) cdataitems.get(position+3);
992+
int counter = 0;
993+
position = position + 4;
994+
while(counter<nchannels){
995+
Byte channel = (Byte) cdataitems.get(position);
996+
Short tdc = (Short) cdataitems.get(position+1);
997+
Short tot = (Short) cdataitems.get(position+2);
998+
position += 3;
999+
counter++;
1000+
DetectorDataDgtz entry = new DetectorDataDgtz(crate,slot,channel);
1001+
entry.addTDC(new TDCData(tdc, tot));
1002+
entry.setTimeStamp(time);
1003+
entries.add(entry);
1004+
}
1005+
}
1006+
} catch (EvioException ex) {
1007+
Logger.getLogger(CodaEventDecoder.class.getName()).log(Level.SEVERE, null, ex);
1008+
} catch (IndexOutOfBoundsException ex){
1009+
Logger.getLogger(CodaEventDecoder.class.getName()).log(Level.SEVERE, null, ex);
9601010
}
9611011

9621012
}

common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DetectorDataDgtz.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.util.ArrayList;
44
import java.util.List;
5+
import org.jlab.detector.banks.RawBank.OrderType;
56
import org.jlab.detector.base.DetectorDescriptor;
67
import org.jlab.detector.base.DetectorType;
78
import org.jlab.detector.helicity.HelicityBit;
@@ -335,10 +336,11 @@ public int compareTo(ADCData o) {
335336
*/
336337
public static class TDCData implements Comparable<TDCData>{
337338

338-
private int tdcOrder = 0; // Used for sorting
339-
private int tdcTime = 0;
340-
private int tdcToT = 0; // Time over threshold
339+
private int tdcOrder = 0; // Used for sorting
340+
private int tdcTime = 0;
341+
private int tdcToT = 0; // Time over threshold
341342
private Long timeStamp = 0L;
343+
private OrderType tdcType = OrderType.NOMINAL;
342344

343345
public TDCData() {}
344346
public TDCData(int time) { this.tdcTime = time;}
@@ -347,10 +349,12 @@ public TDCData() {}
347349
public int getToT() { return this.tdcToT;}
348350
public int getOrder() { return tdcOrder;}
349351
public long getTimeStamp(){ return this.timeStamp; }
352+
public OrderType getType() { return tdcType;}
350353
public TDCData setOrder(int order) { tdcOrder = order;return this;}
351354
public TDCData setTime(short time) { tdcTime = time;return this;}
352355
public TDCData setToT(short ToT) { tdcToT = ToT;return this;}
353356
public TDCData setTimeStamp(long time){ timeStamp = time;return this; }
357+
public TDCData setType(OrderType type) { tdcType = type; return this;}
354358

355359
@Override
356360
public String toString(){

common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DetectorEventDecoder.java

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
package org.jlab.detector.decode;
22

3+
import java.util.ArrayList;
34
import java.util.Arrays;
5+
import java.util.Comparator;
6+
import java.util.HashMap;
47
import java.util.List;
8+
import java.util.Map;
9+
import org.jlab.detector.banks.RawBank.OrderType;
510
import org.jlab.detector.base.DetectorType;
611
import org.jlab.detector.calib.utils.ConstantsManager;
712
import org.jlab.detector.decode.DetectorDataDgtz.ADCData;
@@ -21,6 +26,7 @@ public class DetectorEventDecoder {
2126
List<String> keysTrans = null;
2227
List<String> tablesFitter = null;
2328
List<String> keysFitter = null;
29+
List<String> keysFilter = null;
2430

2531
private int runNumber = 10;
2632

@@ -109,6 +115,9 @@ public final void initDecoder(){
109115
});
110116
fitterManager.init(keysFitter, tablesFitter);
111117

118+
// Data filter list
119+
keysFilter = Arrays.asList(new String[]{"DC"});
120+
112121
scalerManager.init(Arrays.asList(new String[]{"/runcontrol/fcup","/runcontrol/slm","/runcontrol/hwp",
113122
"/runcontrol/helicity","/daq/config/scalers/dsc1"}));
114123
}
@@ -211,4 +220,42 @@ public void fitPulses(List<DetectorDataDgtz> detectorData){
211220
}
212221
}
213222
}
223+
224+
225+
public void filterTDCs(List<DetectorDataDgtz> detectorData){
226+
int maxMultiplicity = 1;
227+
for(String table : keysFilter){
228+
Map<Integer,List<DetectorDataDgtz>> filteredData = new HashMap<>();
229+
for(DetectorDataDgtz data : detectorData){
230+
if(data.getDescriptor().getType()==DetectorType.getType(table)) {
231+
int key = data.getDescriptor().getHashCode();
232+
if(!filteredData.containsKey(key))
233+
filteredData.put(key, new ArrayList<>());
234+
filteredData.get(key).add(data);
235+
}
236+
}
237+
for(int key : filteredData.keySet()) {
238+
filteredData.get(key).sort(new TDCComparator());
239+
if(filteredData.get(key).size()>maxMultiplicity)
240+
for(int i=maxMultiplicity; i<filteredData.get(key).size(); i++)
241+
filteredData.get(key).get(i).getTDCData(0).setType(OrderType.DECREMOVED);
242+
}
243+
}
244+
}
245+
246+
class TDCComparator implements Comparator<DetectorDataDgtz> {
247+
248+
// override the compare() method
249+
public int compare(DetectorDataDgtz s1, DetectorDataDgtz s2)
250+
{
251+
if(s1.getTDCSize()>0 && s2.getTDCSize()>0)
252+
return s1.getTDCData(0).getTime()<s2.getTDCData(0).getTime() ? -1 : 1;
253+
else if(s1.getTDCSize()>0)
254+
return 1;
255+
else if(s2.getTDCSize()>0)
256+
return -1;
257+
else
258+
return 0;
259+
}
260+
}
214261
}

etc/bankdefs/hipo4/data.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@
212212
{ "name":"layer" , "type":"B", "info":"layer (1..36)"},
213213
{ "name":"component" , "type":"S", "info":"wire number (1..112)"},
214214
{ "name":"order" , "type":"B", "info":"order: 2 - TDCL , 3 - TDCR"},
215-
{ "name":"TDC" , "type":"I", "info":"TDC value"}
215+
{ "name":"TDC" , "type":"I", "info":"TDC value"},
216+
{ "name":"ToT" , "type":"S", "info":"Time Over Threshold"}
216217
]
217218
},
218219
{

0 commit comments

Comments
 (0)