#include #include #include #include namespace RAT { //CoincProc::CoincProc() : Processor("CoincProc"), fTimeStart(0), fTimeWindow(0), fLowWindow(0), fNhitFirst(0), fNhitSecond(0), fNhitFirstMax(9999), fNhitSecondMax(9999), fNCoincFound(0), fNfirstFound(0), fNsecondFound(0), fMode(3) { } CoincProc::CoincProc() : Processor("CoincProc"), fTimeStart(0), fTimeWindow(0), fLowWindow(0), fNhitFirst(0), fNhitSecond(0), fNhitFirstMax(9999), fNhitSecondMax(9999), fMode(3) { } CoincProc::~CoincProc(){ } void CoincProc::SetD( const std::string& param, const double value ) { //std::cout<<" setting "< 0) fTimeWindow = value; else throw ParamInvalid( param, "time interval must be > 0 [and in micro-seconds]" ); } else if( param == "LowWindow" ){ if (value >= 0) fLowWindow = value; else throw ParamInvalid( param, "minimum time interval must be >= 0 [and in micro-seconds]" ); } else throw ParamUnknown( param ); } void CoincProc::SetI( const std::string& param, const int value ) { //std::cout<<" setting "<= 0) fNhitFirst = value; else throw ParamInvalid( param, "(cleaned) Nhit threshold for 1st event must be >= 0" ); } else if( param == "NhitSecond" ){ if (value >= 0) fNhitSecond = value; else throw ParamInvalid( param, "(cleaned) Nhit threshold for 2nd event must be >= 0" ); } else if( param == "NhitFirstMax" ){ if (value > 0) fNhitFirstMax = value; else fNhitFirstMax = 9999; } else if( param == "NhitSecondMax" ){ if (value >= 0) fNhitSecondMax = value; else fNhitSecondMax = 9999; } else if( param == "SelectionMode" ){ if (value > 0 && value < 4) fMode = value; else throw ParamInvalid( param, "Coincidence Selection Mode is (1) only Prompt event, (2) only Delayed event (3) Prompt and Delayed events" ); } else throw ParamUnknown( param ); } Processor::Result CoincProc::DSEvent(DS::Run&, DS::Entry& ds) { bool keep = false; if( ds.GetEVCount() < 1 ) return Processor::OKFALSE; for( size_t iEV = 0; iEV < ds.GetEVCount(); iEV++ ){ //note this is thought for Data (EVCount==1); will be different in coincidence simulation (EVCount>1) RAT::DS::EV evs = ds.GetEV( iEV ); double thisTime = (evs.GetUniversalTime().GetDays()*86400. + evs.GetUniversalTime().GetSeconds())*1.e6+evs.GetUniversalTime().GetNanoSeconds()*1.e-3; if(evs.GetNhitsCleaned() >= fNhitSecond && evs.GetNhitsCleaned() < fNhitSecondMax) //keep only coincidences above a lower threshold and up to some nhit value (by default 9999) { //fNsecondFound++; //can choose both the maximum time for a coincidence and a minimum to cut retriggers if (fTimeStart>0 && thisTime-fTimeStart > fLowWindow && thisTime-fTimeStart < fTimeWindow) { //if(fNCoincFound%1000==0) //std::cout<<"Found "<= fNhitFirst && evs.GetNhitsCleaned() < fNhitFirstMax) //keep only coincidences above a high threshold and up to some nhit value (by default 9999) { //fNfirstFound++; fTimeStart = thisTime; //update search window for this prompt if( fMode == 1 || fMode == 3) keep = true; //keep candidates for Prompt event in Coincidence //If it is to run as a fourth processing stage, and this event is already reconstructed, change to mode 2} }//close if }//close for //two separate conditions (for first and second threshold)//-- if (keep) return Processor::OKTRUE; return Processor::OKFALSE;//if none of the conditions return FALSE }//end processor }//namespace