#include #include #include #include #include #include #include #include using namespace RAT; using namespace RAT::DS; using namespace RAT::Methods; #include using namespace ROOT; #include using namespace std; void SimpleTime::Initialise( const std::string& param ) { if( param=="group" ) fGroup = true; else if( param=="effective" || param=="") fGroup = false; // default else { warn << "SimpleTime: must use group or effective velocity; assuming effective" << newline; fGroup = false; } fBinning = 1; } void SimpleTime::BeginOfRun( DS::Run& ) { fLightPath = DU::Utility::Get()->GetLightPathCalculator(); } void SimpleTime::SetI( const std::string& param, int value) { if( param=="binning" ) fBinning = value; else throw Processor::ParamUnknown( param ); } void SimpleTime::DefaultSeed() { FitVertex vertex; vertex.SetPosition( TVector3( 0.0, 0.0, 0.0 ), false, true ); vertex.SetPositionErrors( ROOT::Math::XYZVectorF(3000.0, 3000.0, 3000.0), false, true ); vertex.SetTime( 230., false, true ); vertex.SetTimeErrors( 100., false, true ); fSeedResult.SetVertex( 0, vertex ); } FitResult SimpleTime::GetBestFit() { fFitResult.Reset(); if( fPMTData.empty() ) return fFitResult; CopySeedToResult(); FitVertex fitVertex = fFitResult.GetVertex( 0 ); TH1D eventTimes( "Temp", "Temp", int(500. / fBinning), 0.0, double( int(500. / fBinning) * fBinning) ); eventTimes.SetDirectory(0); for( vector::const_iterator iPMT = fPMTData.begin(); iPMT != fPMTData.end(); ++iPMT ) { fLightPath.CalcByPosition( fitVertex.GetPosition(), DU::Utility::Get()->GetPMTInfo().GetPosition( iPMT->GetID() ) ); double distInInnerAV = fLightPath.GetDistInInnerAV(); double distInAV = fLightPath.GetDistInAV(); double distInWater = fLightPath.GetDistInWater(); double transitTime; if( fGroup ) transitTime = DU::Utility::Get()->GetGroupVelocity().CalcByDistance( distInInnerAV, distInAV, distInWater ); else transitTime = DU::Utility::Get()->GetEffectiveVelocity().CalcByDistance( distInInnerAV, distInAV, distInWater ); eventTimes.Fill( iPMT->GetTime() - transitTime ); } fitVertex.SetTime( eventTimes.GetXaxis()->GetBinCenter( eventTimes.GetMaximumBin() ) ); fitVertex.SetTimeErrors( eventTimes.GetRMS() / sqrt( eventTimes.GetEntries() ) ); fFitResult.SetVertex( 0, fitVertex ); return fFitResult; }