#include #include #include #include #include using namespace std; namespace RAT { void ITCTimeSpreadCut::BeginOfRun(DS::Run&) { fLClean = DB::Get()->GetLink("DATACLEANING",fName); fWindowSize = fLClean->GetD("window_size"); fWindowStep = fLClean->GetD("window_step"); fRatioCut = fLClean->GetD("ratio_cut"); } Processor::Result ITCTimeSpreadCut::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 ITCTimeSpreadCut::Event(DS::Entry&, DS::EV& ev) { vector pmt_times; fPassFlag = true; double min_time,max_time; int max_count = -1; for (size_t ipmt=0;ipmt 1){ int imid = (ilow + ihigh) / 2; if (itime == pmt_times[imid]){ ilow = imid-1; ihigh = ilow; }else if (itime > pmt_times[imid]){ ilow = imid; }else{ ihigh = imid; } } i_win_low = ilow; // again binary search for top position of window ilow = 0; ihigh = npmt; while((ihigh-ilow) > 1){ int imid = (ilow + ihigh) / 2; if (((itime + fWindowSize) >= pmt_times[imid]) && ((itime + fWindowSize) <= (pmt_times[imid] + fWindowStep))){ ilow = imid-1; ihigh = ilow; }else if ((itime + fWindowSize) < pmt_times[imid]){ ihigh = imid; }else{ ilow = imid; } } i_win_high = ilow; if ((i_win_high - i_win_low) > max_count) max_count = (i_win_high-i_win_low); itime += fWindowStep; } // end while itime <= max_time-win_size+win_step } // end if/else hits are all in one window double max_ratio = (double) max_count / (double) pmt_times.size(); if (max_ratio < fRatioCut) fPassFlag = false; UpdateMask(ev); return fPassFlag ? OKFALSE : OKTRUE; } } // namespace RAT