#include #include #include #include using namespace std; namespace RAT { void CrateIsotropy::BeginOfRun(DS::Run&) { fLClean = DB::Get()->GetLink("DATACLEANING",fName); fCrateFrac = fLClean->GetD("crate_frac"); fCardFrac = fLClean->GetD("card_frac"); fChanFrac = fLClean->GetD("chan_frac"); } Processor::Result CrateIsotropy::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 CrateIsotropy::Event(DS::Entry&, DS::EV& ev) { vector crate_count(19,0); vector card_count(16); vector chan_count(32); int pmtid,crate,card,channel,count; fPassFlag = true; // should pass orphans and zero hit events if (ev.GetUncalPMTs().GetCount() == 0){ // || ev.IsOrphan() UpdateMask(ev); return fPassFlag ? OKFALSE : OKTRUE; } count = ev.GetUncalPMTs().GetCount(); for (int ipmt=0;ipmt fCrateFrac){ // now we need to loop over the pmts again and check the // adjacent cards and channels for crate isotropy for (int i=0;i<16;i++) card_count[i] = 0; for (int i=0;i<32;i++) chan_count[i] = 0; for (int ipmt=0;ipmt fCardFrac) fPassFlag = false; for (int ichan=0;ichan<32;ichan++) if ((chan_count[ichan]+chan_count[(ichan+1)%32])/crate_count[icrate] > fChanFrac) fPassFlag = false; } // end if crate fails cratefrac } // end loop over crates // now update the mask UpdateMask(ev); return fPassFlag ? OKFALSE : OKTRUE; } } // namespace RAT