Skip to content
Merged
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 @@ -2,6 +2,7 @@

import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
Expand All @@ -10,7 +11,6 @@
import org.jlab.coda.jevio.DataType;
import org.jlab.coda.jevio.EvioException;
import org.jlab.coda.jevio.EvioNode;
import org.jlab.detector.base.DetectorType;
import org.jlab.detector.decode.DetectorDataDgtz.ADCData;
import org.jlab.detector.decode.DetectorDataDgtz.HelicityDecoderData;
import org.jlab.detector.decode.DetectorDataDgtz.SCALERData;
Expand All @@ -37,12 +37,14 @@ public class CodaEventDecoder {
private int timeStampErrors = 0;
private long triggerBits = 0;
private byte helicityLevel3 = HelicityBit.UDF.value();
private List<Integer> triggerWords = new ArrayList<>();
private final List<Integer> triggerWords = new ArrayList<>();
JsonObject epicsData = new JsonObject();

private final long timeStampTolerance = 0L;
private int tiMaster = -1;


// FIXME: move this to CCDB, e.g., meanwhile cannot reuse ROC id
private static final List<Integer> PCIE_ROCS = Arrays.asList(new Integer[]{78});

public CodaEventDecoder(){

}
Expand All @@ -66,7 +68,6 @@ public List<DetectorDataDgtz> getDataEntries(EvioDataEvent event){
// 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<DetectorDataDgtz> rawEntries = new ArrayList<DetectorDataDgtz>();
List<EvioTreeBranch> branches = this.getEventBranches(event);
this.setTimeStamp(event);
Expand All @@ -86,7 +87,6 @@ public List<DetectorDataDgtz> getDataEntries(EvioDataEvent event){
this.getDataEntries_EPICS(event);
this.getDataEntries_HelicityDecoder(event);


return rawEntries;
}

Expand Down Expand Up @@ -142,18 +142,22 @@ else if(tiEntries.size()>1) {
// check sychronization
boolean tiSync=true;
int i0 = -1;
// set reference timestamp from first entry which is not the tiMaster
// set reference timestamp from first entry which is not the tiMaster nor PCIE:
for(int i=0; i<tiEntries.size(); i++) {
if(tiEntries.get(i).getDescriptor().getCrate()!=this.tiMaster) {
i0 = i;
break;
if(tiEntries.get(i).getDescriptor().getCrate() != this.tiMaster) {
if (!PCIE_ROCS.contains(tiEntries.get(i).getDescriptor().getCrate())) {
i0 = i;
break;
}
}
}
for(int i=0; i<tiEntries.size(); i++) {
long deltaTS = this.timeStampTolerance;
long deltaTS = 0;
long offsetT = 0;
if( tiEntries.get(i).getDescriptor().getType() == DetectorType.ATOF) offsetT = 5;
if(tiEntries.get(i).getDescriptor().getCrate()==this.tiMaster) deltaTS = deltaTS + 1; // add 1 click tolerance for tiMaster
// Allow/require 5-click offset for PCIE ROCs:
if( PCIE_ROCS.contains(tiEntries.get(i).getDescriptor().getCrate() )) offsetT = 5;
// Add 1-click tolerance for "TI master" (FIXME: this should be an offset too(?)):
if(tiEntries.get(i).getDescriptor().getCrate()==this.tiMaster) deltaTS = deltaTS + 1;
if(Math.abs(tiEntries.get(i).getTimeStamp()-offsetT-tiEntries.get(i0).getTimeStamp())>deltaTS) {
tiSync=false;
if(this.timeStampErrors<100) {
Expand Down