#include #include #include #include using namespace std; namespace RAT { void EmptyCrate::BeginOfRun(DS::Run&){ fLClean = DB::Get()->GetLink("DATACLEANING",fName); fEmptyCrateNHit = fLClean->GetI("minimum_nhit"); fEmptyCrateNum = fLClean->GetI("num_empty_crates"); } Processor::Result EmptyCrate::DSEvent(DS::Run&, DS::Entry& ds){ bool pass = true; // If any triggered event fails, they all fail for( size_t iEvent = 0; iEvent < ds.GetEVCount(); iEvent++ ) if( Event(ds, ds.GetEV(iEvent)) != OKTRUE ) pass = false; return pass ? OKTRUE : OKFALSE; } Processor::Result EmptyCrate::Event(DS::Entry&, DS::EV& ev){ vector crate_count(19,0); fPassFlag = true; // Skip orphans if(ev.GetTrigType() == 0){ UpdateMask(ev); return fPassFlag ? OKFALSE : OKTRUE; } // If number of PMTs hit is low we will have many empty // crates, so limit this cut to very high nhit events int nhit = ev.GetUncalPMTs().GetCount(); if(nhit < fEmptyCrateNHit){ UpdateMask(ev); return fPassFlag ? OKFALSE : OKTRUE; } // Count the number of crates with hits in them int hit_crates = 0; for(int iPMT = 0; iPMT < nhit; iPMT++){ int crate = ev.GetUncalPMTs().GetPMT(iPMT).GetCrate(); if(crate_count[crate] == 0){ hit_crates+=1; crate_count[crate] = 1; } } // If the number of crates with hits is less than // some number then cut the event. In other words, // if there are a bunch of empty crates than this // was likely a dry end breakdown. if(hit_crates < fEmptyCrateNum){ fPassFlag = false; UpdateMask(ev); return fPassFlag ? OKFALSE : OKTRUE; } UpdateMask(ev); return fPassFlag ? OKFALSE : OKTRUE; } } // namespace RAT