Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
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; }
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 widths
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 @@ -954,9 +957,56 @@ public List<DetectorDataDgtz> 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<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(CodaEventDecoder.class.getName()).log(Level.SEVERE, null, ex);
} catch (IndexOutOfBoundsException ex){
Logger.getLogger(CodaEventDecoder.class.getName()).log(Level.SEVERE, null, ex);
}

}
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 @@ -335,10 +336,11 @@ public int compareTo(ADCData o) {
*/
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 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;}
Expand All @@ -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(){
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 @@ -21,6 +26,7 @@ public class DetectorEventDecoder {
List<String> keysTrans = null;
List<String> tablesFitter = null;
List<String> keysFitter = null;
List<String> keysFilter = null;

private int runNumber = 10;

Expand Down Expand Up @@ -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"}));
}
Expand Down Expand Up @@ -211,4 +220,42 @@ public void fitPulses(List<DetectorDataDgtz> detectorData){
}
}
}


public void filterTDCs(List<DetectorDataDgtz> detectorData){
int maxMultiplicity = 1;
for(String table : keysFilter){
Map<Integer,List<DetectorDataDgtz>> 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<filteredData.get(key).size(); i++)
filteredData.get(key).get(i).getTDCData(0).setType(OrderType.DECREMOVED);
}
}
}

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;
}
}
}
3 changes: 2 additions & 1 deletion etc/bankdefs/hipo4/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
]
},
{
Expand Down