#include #include #include #include #include #include #include using namespace RAT; using namespace RAT::Classifiers; using namespace RAT::DS; #include using namespace std; void AlphaClassifierSeeded::BeginOfRun(DS::Run&) { DB *db = DB::Get(); DBLinkPtr dbNAVLink = db->GetLink("CLASSIFIER_ALPHA_SEEDED"); ft1 = dbNAVLink->GetD("t1"); ft2 = dbNAVLink->GetD("t2"); ftmax = dbNAVLink->GetD("tmax"); fLightPath = DU::Utility::Get()->GetLightPathCalculator(); } void AlphaClassifierSeeded::DefaultSeed() { fEventPos = TVector3(); fEventTime = 0.0; } void AlphaClassifierSeeded::SetSeed(const DS::FitResult& seed) { FitVertex seedVertex; try { seedVertex = seed.GetVertex(0); } catch( FitResult::NoVertexError& error ) { return; // Nothing to seed from, strange request } try { fEventPos = seedVertex.GetPosition(); } catch( FitVertex::NoValueError& error ) { /* No data to seed from */ } try { fEventTime = seedVertex.GetTime(); } catch( FitVertex::NoValueError& error ) { /* No data to seed from */ } } DS::ClassifierResult AlphaClassifierSeeded::GetClassification() { fClassifierResult.Reset(); if( fPMTData.empty() ) return fClassifierResult; double peak = 0.0, total = 0.0; for( vector::const_iterator iPMT = fPMTData.begin(); iPMT != fPMTData.end(); ++iPMT ) { const TVector3 pmtPos = DU::Utility::Get()->GetPMTInfo().GetPosition(iPMT->GetID()); const double pmtTime = iPMT->GetTime(); fLightPath.CalcByPosition(fEventPos, pmtPos); double distInInnerAV = fLightPath.GetDistInInnerAV(); double distInAV = fLightPath.GetDistInAV(); double distInWater = fLightPath.GetDistInWater(); const double FlightTime = DU::Utility::Get()->GetEffectiveVelocity().CalcByDistance(distInInnerAV, distInAV, distInWater); const double TimeResid = pmtTime - FlightTime - fEventTime; if ((TimeResid > ft1) && (TimeResid < ft2)) { peak += 1.0; } if ((TimeResid > ft1) && (TimeResid < ftmax)) { total += 1.0; } } double ratio = (peak / total); fClassifierResult.SetClassification( "ratio", ratio ); fClassifierResult.SetValid( true ); return fClassifierResult; }