#include #include using namespace RAT; using namespace RAT::Classifiers; #include using namespace ROOT; #include using namespace std; void PreTriggerHits::BeginOfRun( DS::Run& ) { DBLinkPtr daqDB= DB::Get()->GetLink("DAQ"); fGTValid = daqDB->GetD( "triggergate" ); fPostTriggerGate = daqDB->GetD( "gtriggerdelay" ) + daqDB->GetD( "triggerfecdelay" ); fPreTriggerGap = 30.0; } DS::ClassifierResult PreTriggerHits::GetClassification() { fClassifierResult.Reset(); if( fPMTData.empty() ) return fClassifierResult; // First produce a histogram of the hit times with 5ns bins const int nBins = 100; const double startBin = 0.0; const double endBin = 500.0; TH1D timeHist( "time", "time", nBins, startBin, endBin ); timeHist.SetDirectory(0); // Memory manage myself for( vector::const_iterator iPMT = fPMTData.begin(); iPMT != fPMTData.end(); ++iPMT ) timeHist.Fill( iPMT->GetTime() ); const double windowUpper = fGTValid - fPostTriggerGate - fPreTriggerGap + 100.0; // 100.0ns as times are relative to a 500ns window fClassifierResult.SetClassification( "preTriggerHits", timeHist.Integral( timeHist.GetXaxis()->FindBin( 0.0 ), timeHist.GetXaxis()->FindBin( windowUpper ) ) ); fClassifierResult.SetValid( true ); return fClassifierResult; }