#include #include #include #include using namespace RAT; using namespace RAT::Classifiers; using namespace RAT::DS; using namespace std; void IBDClassifierUnseeded::BeginOfRun(DS::Run&) { DB* db = DB::Get(); DBLinkPtr dbLink = db->GetLink("CLASSIFIER_IBD"); // Get the time window fTimeWindow = RAT::DS::UniversalTime(0.0,0.0, dbLink->GetD("time_window")); } DS::ClassifierResult IBDClassifierUnseeded::GetClassification() { // Reset the result from the previous event fClassifierResult.Reset(); // No result if no PMTs if(fPMTData.empty()) return fClassifierResult; // Variable storing the classifier results int nuCandidates = 0; // Get the triggered time of this event RAT::DS::UniversalTime currentEventTime = fEvent->GetUniversalTime(); // If false, this is the first event (array is only empty for first event) if (!fEventTimes.empty()) { // This is not the first event // Get the time difference to the previous event RAT::DS::UniversalTime timeDifference = currentEventTime - fPreviousEventTime; // Shift them by the time to this event transform(fEventTimes.begin(), fEventTimes.end(), fEventTimes.begin(), bind2nd(plus(), UTtoNanoSeconds(timeDifference))); // Now remove any that are outside the time window fEventTimes.erase(remove_if(fEventTimes.begin(), fEventTimes.end(), bind2nd(greater(), UTtoNanoSeconds(fTimeWindow))), fEventTimes.end()); // The number left are the candidate neutrinos nuCandidates = fEventTimes.size(); // Now add this event to the array fEventTimes.push_back(0.); // Time difference between this event and itself is 0. ns } else { // This is the first event, initialize everything fEventTimes.push_back(0.); } // Set the previous event time to the current event time fPreviousEventTime = currentEventTime; // Set the results fClassifierResult.SetClassification("neutrino_candidates", double(nuCandidates)); fClassifierResult.SetValid(true); return fClassifierResult; } double IBDClassifierUnseeded::UTtoNanoSeconds(RAT::DS::UniversalTime time) { // Convert from universal time to number of nanaseconds return time.GetDays()*24.*3600.*1.e9 + time.GetSeconds()*1.e9 + time.GetNanoSeconds(); }