#include using namespace std; #include #include #include using namespace RAT; using namespace RAT::Classifiers; using namespace std; void AlphaClassifierUnseeded::BeginOfRun(DS::Run&) { DB *db = DB::Get(); DBLinkPtr dbNAVLink = db->GetLink("CLASSIFIER_ALPHA_UNSEEDED"); fTailFraction = dbNAVLink->GetD("tail_fraction"); fpmtMin = dbNAVLink->GetD("pmt_Min"); fpmtMax = dbNAVLink->GetD("pmt_Max"); } DS::ClassifierResult AlphaClassifierUnseeded::GetClassification() { fClassifierResult.Reset(); if( fPMTData.empty() ) return fClassifierResult; double tail = 0.0, total = 0.0, lowlimit = 1000.0, highlimit = 0.0; vector times (fPMTData.size(), 0.0); for (size_t j = 0; j < fPMTData.size(); j++) { FitterPMT pmt = fPMTData[j]; double pmtTime = pmt.GetTime(); times[j] = pmtTime; if ((pmtTime < lowlimit) && (pmtTime > fpmtMin)) { lowlimit = pmtTime; } if ((pmtTime > highlimit) && (pmtTime < fpmtMax)) { highlimit = pmtTime; } } double range = (highlimit - lowlimit); double tailstart = (highlimit - (fTailFraction * range)); for (size_t k = 0; k < fPMTData.size(); k++) { if ((times[k] >= tailstart) && (times[k] < highlimit)) { tail += 1.0; } if ((times[k] >= lowlimit) && (times[k] < highlimit)) { total += 1.0; } } double ratio = (tail / total); times.clear(); fClassifierResult.SetClassification( "ratio", ratio ); fClassifierResult.SetValid( true ); return fClassifierResult; }