diff --git a/Generators/BeamHaloGenerator/BeamHaloGenerator/BeamHaloGeneratorAlg.h b/Generators/BeamHaloGenerator/BeamHaloGenerator/BeamHaloGeneratorAlg.h index 6997583d552dd403d1128d46b513a69808030f5d..d21274bc628f6f09788710f6c00a16c8217d4bdb 100644 --- a/Generators/BeamHaloGenerator/BeamHaloGenerator/BeamHaloGeneratorAlg.h +++ b/Generators/BeamHaloGenerator/BeamHaloGenerator/BeamHaloGeneratorAlg.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration */ #ifndef BEAMHALOGENERATORALG_H @@ -72,7 +72,7 @@ private: BooleanProperty m_doMonitoringPlots{this, "doMonitoringPlots", false}; /** A pointer to the THist service for validation plots. */ - ITHistSvc *m_tHistSvc{}; + ServiceHandle<ITHistSvc> m_tHistSvc{this, "THistSvc", "THistSvc"}; /** Name of the random number stream */ StringProperty m_randomStream{this, "randomStream", "BeamHalo"}; diff --git a/Generators/BeamHaloGenerator/src/BeamHaloGeneratorAlg.cxx b/Generators/BeamHaloGenerator/src/BeamHaloGeneratorAlg.cxx index 6a38173a8e5db62a8231efa201c8eddc60e18759..23b53c4ddb9df3baf3eb924e3310f9e09dcd993a 100644 --- a/Generators/BeamHaloGenerator/src/BeamHaloGeneratorAlg.cxx +++ b/Generators/BeamHaloGenerator/src/BeamHaloGeneratorAlg.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration */ #include "BeamHaloGenerator/BeamHaloGeneratorAlg.h" @@ -58,11 +58,7 @@ StatusCode BeamHaloGeneratorAlg::genInitialize() { // Retrieve pointer to THistSvc if monitoring plots are requested /// @todo Use ServiceHandle system instead if(m_doMonitoringPlots) { - StatusCode sc = service("THistSvc", m_tHistSvc); - if (sc.isFailure() || !m_tHistSvc) { - ATH_MSG_FATAL("Unable to locate Service THistSvc"); - return sc; - } + ATH_CHECK(m_tHistSvc.retrieve()); // Create log10 bins for x-axis of E plots. const Int_t nbins_E = 60; @@ -94,21 +90,21 @@ StatusCode BeamHaloGeneratorAlg::genInitialize() { m_validationPlots[SP_PZ_MUONS] = new TH1F("scoringPlanePz_muons",";p_{z} [GeV];Particles/[GeV]",350,0., 3500.); m_validationPlots[SP_PT_MUONS] = new TH1F("scoringPlanePt_muons",";p_{T} [GeV];Particles/[GeV]",500,0., 50.); - if((sc = m_tHistSvc->regHist("/BeamHalo/primaryR", m_validationPlots[PRI_R])) == StatusCode::FAILURE) return sc; - if((sc = m_tHistSvc->regHist("/BeamHalo/primaryZ", m_validationPlots[PRI_Z])) == StatusCode::FAILURE) return sc; - if((sc = m_tHistSvc->regHist("/BeamHalo/primaryZ_TCT", m_validationPlots[PRI_Z_TCT])) == StatusCode::FAILURE) return sc; - if((sc = m_tHistSvc->regHist("/BeamHalo/scoringPlaneR_all", m_validationPlots[SP_R_ALL])) == StatusCode::FAILURE) return sc; - if((sc = m_tHistSvc->regHist("/BeamHalo/scoringPlaneE_all", m_validationPlots[SP_E_ALL])) == StatusCode::FAILURE) return sc; - if((sc = m_tHistSvc->regHist("/BeamHalo/scoringPlanePz_all", m_validationPlots[SP_PZ_ALL])) == StatusCode::FAILURE) return sc; - if((sc = m_tHistSvc->regHist("/BeamHalo/scoringPlanePt_all", m_validationPlots[SP_PT_ALL])) == StatusCode::FAILURE) return sc; - if((sc = m_tHistSvc->regHist("/BeamHalo/scoringPlaneR_protons", m_validationPlots[SP_R_PROTONS])) == StatusCode::FAILURE) return sc; - if((sc = m_tHistSvc->regHist("/BeamHalo/scoringPlaneE_protons", m_validationPlots[SP_E_PROTONS])) == StatusCode::FAILURE) return sc; - if((sc = m_tHistSvc->regHist("/BeamHalo/scoringPlanePz_protons", m_validationPlots[SP_PZ_PROTONS])) == StatusCode::FAILURE) return sc; - if((sc = m_tHistSvc->regHist("/BeamHalo/scoringPlanePt_protons", m_validationPlots[SP_PT_PROTONS])) == StatusCode::FAILURE) return sc; - if((sc = m_tHistSvc->regHist("/BeamHalo/scoringPlaneR_muons", m_validationPlots[SP_R_MUONS])) == StatusCode::FAILURE) return sc; - if((sc = m_tHistSvc->regHist("/BeamHalo/scoringPlaneE_muons", m_validationPlots[SP_E_MUONS])) == StatusCode::FAILURE) return sc; - if((sc = m_tHistSvc->regHist("/BeamHalo/scoringPlanePz_muons", m_validationPlots[SP_PZ_MUONS])) == StatusCode::FAILURE) return sc; - if((sc = m_tHistSvc->regHist("/BeamHalo/scoringPlanePt_muons", m_validationPlots[SP_PT_MUONS])) == StatusCode::FAILURE) return sc; + ATH_CHECK(m_tHistSvc->regHist("/BeamHalo/primaryR", m_validationPlots[PRI_R])); + ATH_CHECK(m_tHistSvc->regHist("/BeamHalo/primaryZ", m_validationPlots[PRI_Z])); + ATH_CHECK(m_tHistSvc->regHist("/BeamHalo/primaryZ_TCT", m_validationPlots[PRI_Z_TCT])); + ATH_CHECK(m_tHistSvc->regHist("/BeamHalo/scoringPlaneR_all", m_validationPlots[SP_R_ALL])); + ATH_CHECK(m_tHistSvc->regHist("/BeamHalo/scoringPlaneE_all", m_validationPlots[SP_E_ALL])); + ATH_CHECK(m_tHistSvc->regHist("/BeamHalo/scoringPlanePz_all", m_validationPlots[SP_PZ_ALL])); + ATH_CHECK(m_tHistSvc->regHist("/BeamHalo/scoringPlanePt_all", m_validationPlots[SP_PT_ALL])); + ATH_CHECK(m_tHistSvc->regHist("/BeamHalo/scoringPlaneR_protons", m_validationPlots[SP_R_PROTONS])); + ATH_CHECK(m_tHistSvc->regHist("/BeamHalo/scoringPlaneE_protons", m_validationPlots[SP_E_PROTONS])); + ATH_CHECK(m_tHistSvc->regHist("/BeamHalo/scoringPlanePz_protons", m_validationPlots[SP_PZ_PROTONS])); + ATH_CHECK(m_tHistSvc->regHist("/BeamHalo/scoringPlanePt_protons", m_validationPlots[SP_PT_PROTONS])); + ATH_CHECK(m_tHistSvc->regHist("/BeamHalo/scoringPlaneR_muons", m_validationPlots[SP_R_MUONS])); + ATH_CHECK(m_tHistSvc->regHist("/BeamHalo/scoringPlaneE_muons", m_validationPlots[SP_E_MUONS])); + ATH_CHECK(m_tHistSvc->regHist("/BeamHalo/scoringPlanePz_muons", m_validationPlots[SP_PZ_MUONS])); + ATH_CHECK(m_tHistSvc->regHist("/BeamHalo/scoringPlanePt_muons", m_validationPlots[SP_PT_MUONS])); } // Check the input type string diff --git a/Generators/FlowAfterburner/FlowAfterburner/CheckFlow.h b/Generators/FlowAfterburner/FlowAfterburner/CheckFlow.h index 32d42bcf8646b21ab5ec48908f435f77bb7eff5d..1f419b4d402cf2446d722fd48ff43c3a77b70785 100644 --- a/Generators/FlowAfterburner/FlowAfterburner/CheckFlow.h +++ b/Generators/FlowAfterburner/FlowAfterburner/CheckFlow.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration */ // File: Generators/FlowAfterburnber/CheckFlow.h @@ -17,6 +17,7 @@ #include <math.h> #include "AthenaBaseComps/AthAlgorithm.h" #include "FlowAfterburner/GenAccessIO.h" +#include "GeneratorObjects/HijingEventParams.h" #include "GaudiKernel/ITHistSvc.h" #include "TH1.h" @@ -34,31 +35,32 @@ public: StatusCode finalize(); private: - std::string m_key; - bool m_produceHistogram; + //Declare the algorithm's properties + StringProperty m_key{this, "McEventKey", "FLOW_EVENT"}; + BooleanProperty m_produceHistogram{this, "HistogramFlag", true}; - double m_bcut_min; - double m_bcut_max; - double m_ptcut_min; - double m_ptcut_max; - double m_rapcut_min; - double m_rapcut_max; + DoubleProperty m_bcut_min{this, "ImpactCutMin", 0.}; + DoubleProperty m_bcut_max{this, "ImpactCutMax", 99.}; + DoubleProperty m_ptcut_min{this, "PtCutMin", 0.}; + DoubleProperty m_ptcut_max{this, "PtCutMax", 999999.}; + DoubleProperty m_rapcut_min{this, "RapidityCutMin", 0.}; + DoubleProperty m_rapcut_max{this, "RapidityCutMax", 5.5}; //Histograms, used if m_produceHistogram is true = 1 - TH1F* m_hgenerated; - TH1F* m_b; - TH1F* m_phi; - TH1F* m_phiR; - TH1F* m_phi_vs_phiR; - TH2F* m_phiv1reco_vs_phiR; - TH2F* m_phiv2reco_vs_phiR; - TH1F* m_phi_vs_phiR_etap; - TH1F* m_phi_vs_phiR_etan; - TH3F* m_v2betapth; - TH3F* m_ebetapth; + TH1F* m_hgenerated{}; + TH1F* m_b{}; + TH1F* m_phi{}; + TH1F* m_phiR{}; + TH1F* m_phi_vs_phiR{}; + TH2F* m_phiv1reco_vs_phiR{}; + TH2F* m_phiv2reco_vs_phiR{}; + TH1F* m_phi_vs_phiR_etap{}; + TH1F* m_phi_vs_phiR_etan{}; + TH3F* m_v2betapth{}; + TH3F* m_ebetapth{}; - StoreGateSvc* m_sgSvc; - TruthHelper::GenAccessIO* m_tesIO; + SG::ReadHandleKey<HijingEventParams> m_hijingKey{this, "HijingEventParmsKey","Hijing_event_params"}; + TruthHelper::GenAccessIO* m_tesIO{}; }; #endif diff --git a/Generators/FlowAfterburner/FlowAfterburner/CheckFlow_New.h b/Generators/FlowAfterburner/FlowAfterburner/CheckFlow_New.h index 748a05cf93f045e634757e22ac0082a6e55ff6fd..edb36faa26d0769701d2fd2d1b323c8fe3a81b37 100644 --- a/Generators/FlowAfterburner/FlowAfterburner/CheckFlow_New.h +++ b/Generators/FlowAfterburner/FlowAfterburner/CheckFlow_New.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration */ // File: Generators/FlowAfterburnber/CheckFlow.h @@ -17,6 +17,7 @@ #include <math.h> #include "AthenaBaseComps/AthAlgorithm.h" #include "FlowAfterburner/GenAccessIO.h" +#include "GeneratorObjects/HijingEventParams.h" #include "GaudiKernel/ITHistSvc.h" #include "TH1.h" @@ -34,15 +35,16 @@ public: StatusCode finalize(); private: - std::string m_key; - bool m_produceHistogram; + //Declare the algorithm's properties + StringProperty m_key{this, "McEventKey", "FLOW_EVENT"}; + BooleanProperty m_produceHistogram{this, "HistogramFlag", true}; - double m_bcut_min; - double m_bcut_max; - double m_ptcut_min; - double m_ptcut_max; - double m_rapcut_min; - double m_rapcut_max; + DoubleProperty m_bcut_min{this, "ImpactCutMin", 0.}; + DoubleProperty m_bcut_max{this, "ImpactCutMax", 99.}; + DoubleProperty m_ptcut_min{this, "PtCutMin", 0.}; + DoubleProperty m_ptcut_max{this, "PtCutMax", 999999.}; + DoubleProperty m_rapcut_min{this, "RapidityCutMin", 0.}; + DoubleProperty m_rapcut_max{this, "RapidityCutMax", 5.5}; enum{ n_ptbin=16, @@ -64,11 +66,10 @@ private: TProfile *m_profile_pt_dep_reco [6][n_etabin]; TProfile *m_profile_eta_dep_reco[6][n_ptbin ]; - TProfile *m_profile_resolution; + TProfile *m_profile_resolution{}; - StoreGateSvc* m_sgSvc; - ITHistSvc* m_thistSvc; - TruthHelper::GenAccessIO* m_tesIO; + SG::ReadHandleKey<HijingEventParams> m_hijingKey{this, "HijingEventParmsKey","Hijing_event_params"}; + TruthHelper::GenAccessIO* m_tesIO{}; }; #endif diff --git a/Generators/FlowAfterburner/src/CheckFlow.cxx b/Generators/FlowAfterburner/src/CheckFlow.cxx index 05d4c88500d22ad365edf490379fadc253b3e952..5ee58031bc7ebf3ac9be6eec006fed197b7bbc62 100644 --- a/Generators/FlowAfterburner/src/CheckFlow.cxx +++ b/Generators/FlowAfterburner/src/CheckFlow.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration */ // File: Generators/FlowAfterburnber/CheckFlow.h @@ -27,41 +27,15 @@ typedef std::vector<HepMC::ConstGenParticlePtr> MCparticleCollection ; CheckFlow::CheckFlow(const std::string& name, ISvcLocator* pSvcLocator) : - AthAlgorithm(name, pSvcLocator), - m_hgenerated ( NULL ), - m_b ( NULL ), - m_phi ( NULL ), - m_phiR ( NULL ), - m_phi_vs_phiR ( NULL ), - m_phiv1reco_vs_phiR ( NULL ), - m_phiv2reco_vs_phiR ( NULL ), - m_phi_vs_phiR_etap ( NULL ), - m_phi_vs_phiR_etan ( NULL ), - m_v2betapth ( NULL ), - m_ebetapth ( NULL ), - m_sgSvc ( NULL ), - m_tesIO ( NULL ) + AthAlgorithm(name, pSvcLocator) { - //Declare the algorithm's properties - declareProperty("McEventKey", m_key="FLOW_EVENT"); - declareProperty("HistogramFlag", m_produceHistogram = true ); - declareProperty("ImpactCutMin", m_bcut_min = 0 ); - declareProperty("ImpactCutMax", m_bcut_max = 99 ); - declareProperty("PtCutMin", m_ptcut_min = 0 ); - declareProperty("PtCutMax", m_ptcut_max = 999999 ); - declareProperty("RapidityCutMin", m_rapcut_min = 0 ); - declareProperty("RapidityCutMax", m_rapcut_max = 5.5 ); } StatusCode CheckFlow::initialize(){ - StatusCode result = StatusCode::SUCCESS; - msg(MSG::INFO) << ">>> CheckFlow from Initialize" << endmsg; - StatusCode sc = service("StoreGateSvc", m_sgSvc); - if (sc.isFailure()) { - msg(MSG::ERROR) << "Could not find StoreGateSvc" << endmsg; - return sc; - } + ATH_CHECK(m_hijingKey.initialize()); + + ATH_MSG_INFO(">>> CheckFlow from Initialize"); m_hgenerated = new TH1F("ngen","Generated",100,0,100000); m_b = new TH1F("b","Impact parameter",35,0.,35.0); @@ -85,9 +59,9 @@ StatusCode CheckFlow::initialize(){ "Tracks vs b, eta, pt", 20,0,20, 30,-7.5,7.5, 25,0,5000); - ITHistSvc *rootHistSvc; - if (!service("THistSvc", rootHistSvc, true).isSuccess()) { - msg(MSG::ERROR) << "Unable to locate THistSvc" << endmsg; + SmartIF<ITHistSvc> rootHistSvc{Gaudi::svcLocator()->service("THistSvc")}; + if (!rootHistSvc) { + ATH_MSG_ERROR( "Unable to locate THistSvc" ); return StatusCode::FAILURE; } @@ -152,7 +126,7 @@ StatusCode CheckFlow::initialize(){ m_tesIO = new TruthHelper::GenAccessIO(); - return result; + return StatusCode::SUCCESS; } StatusCode CheckFlow::execute() { @@ -161,24 +135,7 @@ StatusCode CheckFlow::execute() { // // Event parameters // - - - -//--------------------------------------------------------------------------------------------------- - const HijingEventParams *hijing_pars; - //HijingEventParams *hijing_pars; -//--------------------------------------------------------------------------------------------------- - - - - - - - if ( m_sgSvc->retrieve(hijing_pars, "Hijing_event_params").isFailure() ) { - msg(MSG::ERROR) << "Could not retrieve Hijing_event_params" - << endmsg; - return StatusCode::FAILURE; - } + SG::ReadHandle<HijingEventParams> hijing_pars{m_hijingKey}; float b = hijing_pars->get_b(); float phiR = hijing_pars->get_bphi(); diff --git a/Generators/FlowAfterburner/src/CheckFlow_New.cxx b/Generators/FlowAfterburner/src/CheckFlow_New.cxx index e747f56f1276cbba4f99939e326718eb59a1c5a2..368d76bcb5b709e5d4d00348b7ad01a8a0bedafd 100644 --- a/Generators/FlowAfterburner/src/CheckFlow_New.cxx +++ b/Generators/FlowAfterburner/src/CheckFlow_New.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration */ // File: Generators/FlowAfterburnber/CheckFlow_New.h @@ -35,22 +35,6 @@ CheckFlow_New::CheckFlow_New(const std::string& name, ISvcLocator* pSvcLocator) : AthAlgorithm(name, pSvcLocator) { - //Declare the algorithm's properties - declareProperty("McEventKey", m_key="FLOW_EVENT"); - declareProperty("HistogramFlag", m_produceHistogram = true ); - declareProperty("ImpactCutMin", m_bcut_min = 0 ); - declareProperty("ImpactCutMax", m_bcut_max = 99 ); - declareProperty("PtCutMin", m_ptcut_min = 0 ); - declareProperty("PtCutMax", m_ptcut_max = 999999 ); - declareProperty("RapidityCutMin", m_rapcut_min = 0 ); - declareProperty("RapidityCutMax", m_rapcut_max = 5.5 ); - - m_profile_resolution=0; - - m_sgSvc = 0; - m_tesIO = 0; - m_thistSvc = 0; - for ( int i = 0; i< 6; i++ ){ m_hist_Psi_n_true[i] = 0; m_hist_Psi_n_reco[i] = 0; @@ -63,33 +47,21 @@ CheckFlow_New::CheckFlow_New(const std::string& name, ISvcLocator* pSvcLocator) m_hist_psi_corr_true[i] = 0; m_hist_psi_corr_reco[i] = 0; } - - } - - - StatusCode CheckFlow_New::initialize(){ - StatusCode result = StatusCode::SUCCESS; - - msg(MSG::INFO) << ">>> CheckFlow_New from Initialize" << endmsg; + ATH_CHECK(m_hijingKey.initialize()); + + ATH_MSG_INFO(">>> CheckFlow_New from Initialize"); float pt_binvals[n_ptbin+1]={0.0,0.25,0.5,1.0,1.5,2.0,2.5,3.0,3.5,4.0,6.0,8.0,12.0,16.0,20.0,30.0,40.0}; float eta_bin_max = 4.0; - StatusCode sc = service("StoreGateSvc", m_sgSvc); - if (sc.isFailure()) { - msg(MSG::ERROR) << "Could not find StoreGateSvc" << endmsg; - return sc; - } - - - ITHistSvc *rootHistSvc; - if (!service("THistSvc", rootHistSvc, true).isSuccess()) { - msg(MSG::ERROR) << "Unable to locate THistSvc" << endmsg; + SmartIF<ITHistSvc> rootHistSvc{Gaudi::svcLocator()->service("THistSvc")}; + if (!rootHistSvc) { + ATH_MSG_ERROR( "Unable to locate THistSvc" ); return StatusCode::FAILURE; } @@ -232,7 +204,7 @@ StatusCode CheckFlow_New::initialize(){ msg(MSG::DEBUG) << "Histograms have been booked " << endmsg; m_tesIO = new TruthHelper::GenAccessIO(); - return result; + return StatusCode::SUCCESS; } @@ -243,14 +215,7 @@ StatusCode CheckFlow_New::execute() { float pt_binvals[n_ptbin+1]={0.0,0.25,0.5,1.0,1.5,2.0,2.5,3.0,3.5,4.0,6.0,8.0,12.0,16.0,20.0,30.0,40.0}; float eta_bin_max = 4.0; - const HijingEventParams *hijing_pars; - - - if ( m_sgSvc->retrieve(hijing_pars, "Hijing_event_params").isFailure() ) { - msg(MSG::ERROR) << "Could not retrieve Hijing_event_params"<< endmsg; - return StatusCode::FAILURE; - } - + SG::ReadHandle<HijingEventParams> hijing_pars{m_hijingKey}; float b = hijing_pars->get_b(); float Psi_n[6],Psi_n_reco[6]; float Psi_n_reco_pos[6],Psi_n_reco_neg[6];