diff --git a/src/libraries/PID/DBeamKLong_factory.cc b/src/libraries/PID/DBeamKLong_factory.cc index caac8cbd9a..d8cb43e2e4 100644 --- a/src/libraries/PID/DBeamKLong_factory.cc +++ b/src/libraries/PID/DBeamKLong_factory.cc @@ -9,8 +9,11 @@ using namespace std; #include "DBeamKLong_factory.h" +#include + #include "HDGEOMETRY/DGeometry.h" #include "DANA/DEvent.h" +#include "TDirectory.h" #include "DVertex.h" #include "particleType.h" @@ -27,6 +30,25 @@ void DBeamKLong_factory::Init(void) auto app = GetApplication(); app->SetDefaultParameter("BEAM:ENABLE_KLONG_BEAM_RECON", dEnableKLongBeamRecon); + auto root_lock = app->GetService(); + root_lock->RootWriteLock(); + { + TDirectory* locSavedDir = gDirectory; + gDirectory->cd("/"); + TDirectory* locIndependentDir = gDirectory->GetDirectory("Independent"); + if(locIndependentDir == nullptr) + locIndependentDir = gDirectory->mkdir("Independent"); + locIndependentDir->cd(); + TDirectory* locDiagDir = gDirectory->GetDirectory("BeamKLongFactory"); + if(locDiagDir == nullptr) + locDiagDir = gDirectory->mkdir("BeamKLongFactory"); + locDiagDir->cd(); + + if(dHistBeamBetaFactoryPreCut == nullptr) + dHistBeamBetaFactoryPreCut = new TH1I("BeamBeta_PreCut_DBeamKLongFactory", "DBeamKLong factory #beta (pre-cut from DVertex:KLong z,t);#beta;events", 800, -0.1, 1.5); + locSavedDir->cd(); + } + root_lock->RootUnLock(); } //------------------ @@ -64,6 +86,15 @@ void DBeamKLong_factory::Process(const std::shared_ptr& event) double KL_distance = ( locVertex->dSpacetimeVertex.Z() - dTargetCenterZ ) + ( 24. * 100. ); double KL_propagation_time = locVertex->dSpacetimeVertex.T() + (24.*100. - dTargetCenterZ) / c; // t=0 is at z=0 double beta = (KL_distance / KL_propagation_time) / c; + + if(std::isfinite(beta) && (dHistBeamBetaFactoryPreCut != nullptr)) + { + DEvent::GetLockService(event)->RootWriteLock(); + { + dHistBeamBetaFactoryPreCut->Fill(beta); + } + DEvent::GetLockService(event)->RootUnLock(); + } // cout << locVertex->dSpacetimeVertex.Z() << " " << dTargetCenterZ // << KL_distance << " " << KL_propagation_time << " " << beta << endl; @@ -74,7 +105,7 @@ void DBeamKLong_factory::Process(const std::shared_ptr& event) // should make some cut based on the beam period... but for now, cut out events that are obviously too slow if(locVertex->dSpacetimeVertex.T() > 250.) return; - + // cout << "in DBeamKLong_factory::evnt() ..." << endl; // cout << KL_distance << " " << locVertex->dSpacetimeVertex.Z() << " " << dTargetCenterZ << endl; // cout << KL_propagation_time << " " << beta << endl; diff --git a/src/libraries/PID/DBeamKLong_factory.h b/src/libraries/PID/DBeamKLong_factory.h index 9e481ba51b..15e53c2bf0 100644 --- a/src/libraries/PID/DBeamKLong_factory.h +++ b/src/libraries/PID/DBeamKLong_factory.h @@ -9,6 +9,7 @@ #include #include #include "DResourcePool.h" +#include "TH1I.h" class DBeamKLong_factory : public JFactoryT { @@ -40,6 +41,7 @@ class DBeamKLong_factory : public JFactoryT bool dEnableKLongBeamRecon; double dTargetCenterZ; + TH1I* dHistBeamBetaFactoryPreCut = nullptr; //RESOURCE POOL