Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -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);
OUTOFTIME (100), // hit excluded during decoding as outside the expected time window
BELOWTHRS (110), // hit excluded during decoding as below threshold
MULTIHIT (120); // hit excluded during decoding as not the first in time
private final int rawOrderId;
private OrderType(int id){ rawOrderId = id; }
public int getTypeId() { return rawOrderId; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ToTs
return this.getDataEntries_57648(crate, node, event);
}
else if(node.getTag()==57636){
// RICH TDC data
return this.getDataEntries_57636(crate, node, event);
Expand Down Expand Up @@ -963,6 +966,53 @@ public List<DetectorDataDgtz> getDataEntries_57622(Integer crate, EvioNode node
return entries;
}

/**
* Bank TAG=57648 used for DC (Drift Chambers) TDC and width values.
* @param crate
* @param node
* @param event
* @return
*/
public List<DetectorDataDgtz> getDataEntries_57648(Integer crate, EvioNode node, EvioDataEvent event){
List<DetectorDataDgtz> entries = new ArrayList<>();
if(node.getTag()==57648){
try {
ByteBuffer compBuffer = node.getByteData(true);
CompositeData compData = new CompositeData(compBuffer.array(),event.getByteOrder());
//List<DataType> cdatatypes = compData.getTypes();
List<Object> 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<nchannels){
Byte channel = (Byte) cdataitems.get(position);
Short tdc = (Short) cdataitems.get(position+1);
Short tot = (Short) cdataitems.get(position+2);
position += 3;
counter++;
DetectorDataDgtz entry = new DetectorDataDgtz(crate,slot,channel);
entry.addTDC(new TDCData(tdc, tot));
entry.setTimeStamp(time);
entries.add(entry);
}
}
} catch (EvioException ex) {
//Logger.getLogger(EvioRawDataSource.class.getName()).log(Level.SEVERE, null, ex);
} catch (IndexOutOfBoundsException ex){
//System.out.println("[ERROR] ----> ERROR DECODING COMPOSITE DATA FOR ONE EVENT");
}

}
return entries;
}

/**
* Bank TAG=57636 used for RICH TDC values
* @param crate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.ArrayList;
import java.util.List;
import org.jlab.detector.banks.RawBank.OrderType;
import org.jlab.detector.base.DetectorDescriptor;
import org.jlab.detector.base.DetectorType;
import org.jlab.detector.helicity.HelicityBit;
Expand Down Expand Up @@ -333,17 +334,20 @@ public static class TDCData implements Comparable<TDCData>{
private int tdcOrder = 0; // Used for sorting
private int tdcTime = 0;
private int tdcToT = 0; // Time over threshold
private OrderType tdcType = OrderType.NOMINAL;

public TDCData() {}
public TDCData(int time) { this.tdcTime = time;}
public TDCData(int time, int ToT) { this.tdcTime = time; this.tdcToT = ToT;}
public int getTime() { return this.tdcTime;}
public int getToT() { return this.tdcToT;}
public int getOrder() { return tdcOrder;}
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 setType(OrderType type) { tdcType = type; return this;}

@Override
public String toString(){
return String.format("TDC (%d) : %5d : %5d", getOrder(),getTime(),getToT());
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -15,12 +20,15 @@ public class DetectorEventDecoder {

ConstantsManager translationManager = new ConstantsManager();
ConstantsManager fitterManager = new ConstantsManager();
ConstantsManager filterManager = new ConstantsManager();
ConstantsManager scalerManager = new ConstantsManager();

List<String> tablesTrans = null;
List<String> keysTrans = null;
List<String> tablesFitter = null;
List<String> keysFitter = null;
List<String> tablesFilter = null;
List<String> keysFilter = null;

private int runNumber = 10;

Expand All @@ -38,12 +46,14 @@ public DetectorEventDecoder(boolean development){
public void setTimestamp(String timestamp) {
translationManager.setTimeStamp(timestamp);
fitterManager.setTimeStamp(timestamp);
filterManager.setTimeStamp(timestamp);
scalerManager.setTimeStamp(timestamp);
}

public void setVariation(String variation) {
translationManager.setVariation(variation);
fitterManager.setVariation(variation);
filterManager.setVariation(variation);
scalerManager.setVariation(variation);
}

Expand Down Expand Up @@ -109,6 +119,11 @@ public final void initDecoder(){
});
fitterManager.init(keysFitter, tablesFitter);

// Data filter table
keysFilter = Arrays.asList(new String[]{"DC"});
tablesFilter = Arrays.asList(new String[]{"/test/dc/tdc"});
filterManager.init(keysFilter, tablesFilter);

scalerManager.init(Arrays.asList(new String[]{"/runcontrol/fcup","/runcontrol/slm","/runcontrol/hwp",
"/runcontrol/helicity","/daq/config/scalers/dsc1"}));
}
Expand Down Expand Up @@ -211,4 +226,59 @@ public void fitPulses(List<DetectorDataDgtz> detectorData){
}
}
}


public void filterTDCs(List<DetectorDataDgtz> detectorData){
for(String table : keysFilter){
Map<Integer,List<DetectorDataDgtz>> filteredData = new HashMap<>();
IndexedTable filter = filterManager.getConstants(runNumber, table);
for(DetectorDataDgtz data : detectorData){
if(data.getDescriptor().getType()==DetectorType.getType(table)) {
int sector = data.getDescriptor().getSector();
int layer = data.getDescriptor().getLayer();
int comp = data.getDescriptor().getComponent();
int order = data.getDescriptor().getOrder();
int min = filter.getIntValue("minimum", sector, layer, 1);
int max = filter.getIntValue("maximum", sector, layer, 1);
int trs = filter.getIntValue("threshold", sector, layer, 1);
if(data.getTDCData(0).getTime()<min || data.getTDCData(0).getTime()>max)
data.getTDCData(0).setType(OrderType.OUTOFTIME);
if( data.getTDCData(0).getToT()<trs)
data.getTDCData(0).setType(OrderType.BELOWTHRS);
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());
int sector = filteredData.get(key).get(0).getDescriptor().getSector();
int layer = filteredData.get(key).get(0).getDescriptor().getLayer();
int comp = filteredData.get(key).get(0).getDescriptor().getComponent();
int order = filteredData.get(key).get(0).getDescriptor().getOrder();
int mult = filter.getIntValue("multiplicity", sector, layer, 1);
if(filteredData.get(key).size()>mult)
for(int i=mult; i<filteredData.get(key).size(); i++)
if(filteredData.get(key).get(i).getTDCData(0).getType()==OrderType.NOMINAL)
filteredData.get(key).get(i).getTDCData(0).setType(OrderType.MULTIHIT);
}
}
}

class TDCComparator implements Comparator<DetectorDataDgtz> {

// override the compare() method
public int compare(DetectorDataDgtz s1, DetectorDataDgtz s2)
{
if(s1.getTDCSize()>0 && s2.getTDCSize()>0)
return s1.getTDCData(0).getTime()<s2.getTDCData(0).getTime() ? -1 : 1;
else if(s1.getTDCSize()>0)
return 1;
else if(s2.getTDCSize()>0)
return -1;
else
return 0;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,12 @@ public EngineData configure(EngineData ed) {
LOGGER.log(Level.INFO,"--- engine configuration is called " + this.getDescription());
try {
if (this.getEngineConfigString("rawBankGroup")!=null) {
this.rawBankOrders = RawBank.getFilterGroup(this.getEngineConfigString("rawBankGroup"));
if(this.getEngineConfigString("rawBankGroup").contains(",")) {
this.rawBankOrders = RawBank.createFilterGroup(this.getEngineConfigString("rawBankGroup").replace(" ","").split(","));
}
else {
this.rawBankOrders = RawBank.getFilterGroup(this.getEngineConfigString("rawBankGroup"));
}
}
if (this.getEngineConfigString("dropBanks")!=null &&
this.getEngineConfigString("dropBanks").equals("true")) {
Expand Down
3 changes: 2 additions & 1 deletion etc/bankdefs/hipo4/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,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"}
]
},
{
Expand Down
Loading