#include "hadaq/StartProcessor.h" #include "hadaq/definess.h" #include "hadaq/TrbIterator.h" #include "hadaq/TdcIterator.h" const double EPOCHLEN = 5e-9*0x800; ////////////////////////////////////////////////////////////////////////////////////////////// /// constructor hadaq::StartProcessor::StartProcessor() : base::StreamProc("START", 0, false) { mgr()->RegisterProc(this, base::proc_TRBEvent, 0); fEvType = MakeH1("EvType", "Event type", 16, 0, 16, "id"); fEvSize = MakeH1("EvSize", "Event size", 500, 0, 500000, "bytes"); fSubevSize = MakeH1("SubevSize", "Subevent size", 500, 0, 5000, "bytes"); fEpochDiff = MakeH1("EpochDiff", "Difference in epochs", 100, -50, 50, "epoch"); fStartId = 0x8880; fTdcMin = 0x5000; fTdcMax = 0x5010; } ////////////////////////////////////////////////////////////////////////////////////////////// /// destructor hadaq::StartProcessor::~StartProcessor() { } ////////////////////////////////////////////////////////////////////////////////////////////// /// Return time difference between epochs in seconds double hadaq::StartProcessor::EpochTmDiff(unsigned ep1, unsigned ep2) { return EpochDiff(ep1, ep2) * EPOCHLEN; } ////////////////////////////////////////////////////////////////////////////////////////////// /// Scan all messages, find reference signals bool hadaq::StartProcessor::FirstBufferScan(const base::Buffer& buf) { if (buf.null()) return false; hadaq::TrbIterator iter(buf().buf, buf().datalen); // unsigned evcnt = 0; hadaq::TdcMessage calibr; unsigned ncalibr = 20; // position in calibr while (auto ev = iter.nextEvent()) { // evcnt++; DefFillH1(fEvType, (ev->GetId() & 0xf), 1.); DefFillH1(fEvSize, ev->GetPaddedSize(), 1.); while (auto sub = iter.nextSubevent()) { if (sub->GetId() != fStartId) continue; DefFillH1(fSubevSize, sub->GetSize(), 1.); unsigned ix = 0; // cursor unsigned trbSubEvSize = sub->GetSize() / 4 - 4; while (ix < trbSubEvSize) { ///Data(ix++); unsigned datalen = (data >> 16) & 0xFFFF; unsigned dataid = data & 0xFFFF; // ignore HUB HEADER // if (dataid == hubid) continue; bool istdc = (dataid>=fTdcMin) && (dataid45) diff = 45; else if (diff < -45) diff = 45; DefFillH1(fEpochDiff, diff, 1.); } lastepoch = epoch; } } } ix+=datalen; } // while (ix < trbSubEvSize) } // subevents } // events return true; }