#include #include #include #include #include #include #include using namespace RAT; using namespace RAT::Classifiers; using namespace RAT::DS; #include using namespace std; void XSite::Initialise( const std::string& param) { //fIndex is material fIndex = param; } void XSite::BeginOfRun( DS::Run& ) { DB *db = DB::Get(); string index; if( fIndex.empty() ) { try{ index = db->GetLink("GEO","inner_av")->GetS("material"); } catch(DBNotFoundError & ){ try{ // If we are in a partial-fill geometry, use the upper // material index = db->GetLink("GEO","inner_av")->GetS("material_top"); } catch(DBNotFoundError & ) { Log::Die("XSite: inner_av material and material_top " "undefined. Try something like:\n" "/rat/db/set GEO[inner_av] material " "\"te_diol_dda_0p5_labppo_scintillator_bisMSB_Jan2018\" or " "/rat/db/set GEO[inner_av] material_top " "\"te_diol_dda_0p5_labppo_scintillator_bisMSB_Jan2018\""); } } } else { index = fIndex; } DBLinkPtr dbXSiteLink; try{ (dbXSiteLink = db->GetLink("CLASSIFIER_XSite",index))->GetS("index"); } catch(DBNotFoundError & ){ warn << "Warning : XSite::BeginOfRun: No full (XSite) definition for " + index + " using defaults instead.\n"; dbXSiteLink = db->GetLink("CLASSIFIER_XSite"); } fLowerTimeLimit = dbXSiteLink->GetD("t1"); fUpperTimeLimit = dbXSiteLink->GetD("t2"); fSignal = dbXSiteLink->GetDArray( "sPDF_S" ); fBKG = dbXSiteLink->GetDArray( "bPDF_B" ); fLightPath = DU::Utility::Get()->GetLightPathCalculator(); } void XSite::DefaultSeed() { fEventPos = TVector3(); fEventTime = 0.0; fSeedVertex.SetPosition( fEventPos, false, true ); fSeedVertex.SetTime( fEventTime, false, true ); } void XSite::SetSeed( const DS::FitResult& seed ) { try { fSeedVertex = seed.GetVertex(0); } catch( FitResult::NoVertexError& error ) { // Nothing to seed from, strange request return; } try { fEventPos = fSeedVertex.GetPosition(); } catch( FitVertex::NoValueError& error ) { /* No data to seed from */ } try { fEventTime = fSeedVertex.GetTime(); } catch( FitVertex::NoValueError& error ) { /* No data to seed from */ } } DS::ClassifierResult XSite::GetClassification() { fClassifierResult.Reset(); if( fPMTData.empty() ) return fClassifierResult; SelectPMTData( fSeedVertex ); const DU::PMTInfo& pmtInfo = DU::Utility::Get()->GetPMTInfo(); double logl = 0.; for( vector::const_iterator iPMT = fSelectedPMTData.begin(); iPMT != fSelectedPMTData.end(); ++iPMT ) { const TVector3 pmtPos = pmtInfo.GetPosition( iPMT->GetID() ); fLightPath.CalcByPosition(fEventPos, pmtPos); double distInInnerAV = fLightPath.GetDistInInnerAV(); double distInAV = fLightPath.GetDistInAV(); double distInWater = fLightPath.GetDistInWater(); const double transitTime = DU::Utility::Get()->GetEffectiveVelocity().CalcByDistance( distInInnerAV, distInAV, distInWater ); const double corTime = iPMT->GetTime() - transitTime - fEventTime; if( corTime < fUpperTimeLimit && corTime > fLowerTimeLimit ) { double v = fSignal[int(corTime-fLowerTimeLimit)]/fBKG[int(corTime-fLowerTimeLimit)]; logl += log(v); } } fClassifierResult.SetClassification( "XSite", logl ); fClassifierResult.SetValid( true ); return fClassifierResult; }