#include #include namespace RAT { void MissedCountBurstCut::BeginOfRun(DS::Run&){ DBLinkPtr fBurst = DB::Get()->GetLink("MISSED_COUNT_BURST"); fTimeCut = fBurst->GetD("time_cut"); fTimeZero = 0; fGTIDs.resize(0); try{ DBLinkPtr fMissedCountBurst = DB::Get()->GetLink("MISSED_BURST"); fGTIDs = fMissedCountBurst->GetIArray("missed_counts_burst_gtid"); } catch(DBNotFoundError &e){ warn << "MissedCountsBurst::BeginOfRun: Cound not find burst ratdb file." << newline; } } Processor::Result MissedCountBurstCut::DSEvent(DS::Run&, DS::Entry& ds){ bool pass = true; // If any triggered event fails, they all fail for(size_t iEV = 0; iEV < ds.GetEVCount(); iEV++){ if(Event(ds, ds.GetEV(iEV)) != OKTRUE){ pass = false; } } return pass ? OKTRUE : OKFALSE; } Processor::Result MissedCountBurstCut::Event(DS::Entry&, DS::EV& ev){ fPassFlag = true; if(fGTIDs.size() == 0){ UpdateMask(ev); return fPassFlag ? OKTRUE : OKFALSE; } if(ev.GetTrigType() == 0){ UpdateMask(ev); return fPassFlag ? OKTRUE : OKFALSE; } int gtid = ev.GetGTID(); ULong64_t clock50 = ev.GetClockCount50(); // Check whether the GTID is at the start of a // missed count burst for(size_t i = 0; i < fGTIDs.size(); i++){ if(gtid == fGTIDs[i]){ fTimeZero = clock50; break; } } // Cut any events within the time window for the burst if(fTimeZero != 0){ double dt = (clock50 - fTimeZero)*20; if(dt < fTimeCut){ fPassFlag = false; UpdateMask(ev); return fPassFlag ? OKTRUE : OKFALSE; } } UpdateMask(ev); return fPassFlag ? OKTRUE : OKFALSE; } }