diff --git a/Trigger/TrigT1/TrigT1NSWSimTools/TrigT1NSWSimTools/MMTriggerTool.h b/Trigger/TrigT1/TrigT1NSWSimTools/TrigT1NSWSimTools/MMTriggerTool.h index 65d4343e703595741d6d713fe1629681fe0ba3d8..dac1c06c65af1c90bc2c84022f0940fd80261829 100644 --- a/Trigger/TrigT1/TrigT1NSWSimTools/TrigT1NSWSimTools/MMTriggerTool.h +++ b/Trigger/TrigT1/TrigT1NSWSimTools/TrigT1NSWSimTools/MMTriggerTool.h @@ -85,10 +85,13 @@ namespace NSWL1 { Gaudi::Property<float> m_dThetaMax {this, "DThetaMax", 0.015, "Maximum dTheta [rad]"}; Gaudi::Property<int> m_dThetaBits {this, "DThetaBits", 5, "Number of dTheta bits"}; - std::shared_ptr<MMT_Parameters> m_par_large; - std::shared_ptr<MMT_Parameters> m_par_small; - const MuonGM::MuonDetectorManager* m_detManager; //!< MuonDetectorManager - const MmIdHelper* m_MmIdHelper; //!< MM offline Id helper + mutable std::shared_ptr<MMT_Parameters> m_par_large ATLAS_THREAD_SAFE{nullptr}; + mutable std::shared_ptr<MMT_Parameters> m_par_small ATLAS_THREAD_SAFE{nullptr}; + mutable std::atomic<bool> m_isInitialized ATLAS_THREAD_SAFE{false}; + mutable std::mutex m_mutex ATLAS_THREAD_SAFE{}; + void fillPointers(const MuonGM::MuonDetectorManager* detManager) const; + SG::ReadCondHandleKey<MuonGM::MuonDetectorManager> m_detManagerKey{this, "MuonManagerKey", "MuonDetectorManager"}; + const MmIdHelper* m_MmIdHelper; //!< MM offline Id helper //Histogram StatusCode book_branches(); //!< book the branches diff --git a/Trigger/TrigT1/TrigT1NSWSimTools/TrigT1NSWSimTools/PadTdsOfflineTool.h b/Trigger/TrigT1/TrigT1NSWSimTools/TrigT1NSWSimTools/PadTdsOfflineTool.h index 60c8d75d43a84a9f53dfc96aed24f51cc0bbc71d..2e15ffdbf3543ee573c704c49ac28f44bcce6624 100644 --- a/Trigger/TrigT1/TrigT1NSWSimTools/TrigT1NSWSimTools/PadTdsOfflineTool.h +++ b/Trigger/TrigT1/TrigT1NSWSimTools/TrigT1NSWSimTools/PadTdsOfflineTool.h @@ -146,7 +146,7 @@ namespace NSWL1 { ServiceHandle<IIncidentSvc> m_incidentSvc{this, "IncidentSvc", "IncidentSvc"}; //!< Athena/Gaudi incident Service ServiceHandle<IAthRNGSvc> m_rndmSvc{this, "RndmSvc", "AthRNGSvc", ""}; //!< Random number generator engine to use ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; - const MuonGM::MuonDetectorManager* m_detManager; //!< MuonDetectorManager + SG::ReadCondHandleKey<MuonGM::MuonDetectorManager> m_detManagerKey{this, "MuonManagerKey", "MuonDetectorManager"}; // properties: container and service names Gaudi::Property<bool> m_isMC {this, "IsMC", true, "This is MC"}; diff --git a/Trigger/TrigT1/TrigT1NSWSimTools/TrigT1NSWSimTools/PadTriggerLogicOfflineTool.h b/Trigger/TrigT1/TrigT1NSWSimTools/TrigT1NSWSimTools/PadTriggerLogicOfflineTool.h index 175ff9bb3fab2a7372207c0cac832a462d4e8171..14aa23d8b37257cda7a864b8d64b4d2922e85336 100644 --- a/Trigger/TrigT1/TrigT1NSWSimTools/TrigT1NSWSimTools/PadTriggerLogicOfflineTool.h +++ b/Trigger/TrigT1/TrigT1NSWSimTools/TrigT1NSWSimTools/PadTriggerLogicOfflineTool.h @@ -92,11 +92,13 @@ namespace NSWL1 { const std::vector<float> m_etaBandsLargeSector; const std::vector<float> m_etaBandsSmallSector; - std::map<IdentifierHash, std::pair<double,double> > m_phiTable; - std::pair<double,double> m_Zratio; + mutable std::map<IdentifierHash, std::pair<double,double> > m_phiTable ATLAS_THREAD_SAFE{}; + mutable std::pair<double,double> m_Zratio ATLAS_THREAD_SAFE{}; + mutable std::atomic<bool> m_isInitialized ATLAS_THREAD_SAFE{false}; + mutable std::mutex m_mutex ATLAS_THREAD_SAFE{}; ServiceHandle<IIncidentSvc> m_incidentSvc{this, "IncidentSvc", "IncidentSvc"}; //!< Athena/Gaudi incident Service - const MuonGM::MuonDetectorManager* m_detManager; //!< MuonDetectorManager + SG::ReadCondHandleKey<MuonGM::MuonDetectorManager> m_detManagerKey{this, "MuonManagerKey", "MuonDetectorManager"}; Gaudi::Property<float> m_PadEfficiency {this, "PadEfficiency", 1.0, "Pad trigger efficiency"}; Gaudi::Property<int> m_phiIdBits {this, "PhiIdBits", 6, "Number of bit to compute Phi-Id of pad triggers"}; @@ -105,7 +107,7 @@ namespace NSWL1 { std::unique_ptr<PadTriggerValidationTree> m_validation_tree; void fillGeometricInformation(PadOfflineData&) const; - void fillPhiTable(); + void fillPhiTable() const; L1TdrStgcTriggerLogic m_tdrLogic; }; } // namespace NSWL1 diff --git a/Trigger/TrigT1/TrigT1NSWSimTools/TrigT1NSWSimTools/PadTriggerLookupTool.h b/Trigger/TrigT1/TrigT1NSWSimTools/TrigT1NSWSimTools/PadTriggerLookupTool.h index 9a49f682542f1078a62bba58de11313cbefc9cd7..2228aba355b439efc07064c78032d3f3a439d761 100644 --- a/Trigger/TrigT1/TrigT1NSWSimTools/TrigT1NSWSimTools/PadTriggerLookupTool.h +++ b/Trigger/TrigT1/TrigT1NSWSimTools/TrigT1NSWSimTools/PadTriggerLookupTool.h @@ -60,7 +60,7 @@ namespace NSWL1 { StatusCode LookupSectorTriggers(const std::vector<std::shared_ptr<PadData>>& pads,int side, int sector, std::vector<std::unique_ptr<PadTrigger>> &triggers); std::vector<std::vector<std::shared_ptr<PadData>>> selectWedgePatterns(const std::vector<std::shared_ptr<PadData>> &pads,int side, int sector,int multiplet) const; - const MuonGM::MuonDetectorManager* m_detManager; + SG::ReadCondHandleKey<MuonGM::MuonDetectorManager> m_detManagerKey{this, "MuonManagerKey", "MuonDetectorManager"}; std::vector<std::shared_ptr<PadOfflineData>> fetchSectorPads(bool isSmall,int side=1,int sector=1);//use sector number as coming ids std::vector<std::shared_ptr<PadOfflineData>> fetchSmallSectorPads(int side=1,int sector=1); diff --git a/Trigger/TrigT1/TrigT1NSWSimTools/TrigT1NSWSimTools/StripClusterTool.h b/Trigger/TrigT1/TrigT1NSWSimTools/TrigT1NSWSimTools/StripClusterTool.h index 6de0486ba602c367081464a29091822bf652a186..ffbf56b7a7cc6d930cb62efa5720db9b91c62c3a 100644 --- a/Trigger/TrigT1/TrigT1NSWSimTools/TrigT1NSWSimTools/StripClusterTool.h +++ b/Trigger/TrigT1/TrigT1NSWSimTools/TrigT1NSWSimTools/StripClusterTool.h @@ -76,7 +76,7 @@ namespace NSWL1 { // needed Servives, Tools and Helpers ServiceHandle< IIncidentSvc > m_incidentSvc{this, "IncidentSvc", "IncidentSvc"}; //!< Athena/Gaudi incident Service - const MuonGM::MuonDetectorManager* m_detManager; //!< MuonDetectorManager + SG::ReadCondHandleKey<MuonGM::MuonDetectorManager> m_detManagerKey{this, "MuonManagerKey", "MuonDetectorManager"}; ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; Gaudi::Property<bool> m_isMC {this, "IsMC", true, "This is MC"}; diff --git a/Trigger/TrigT1/TrigT1NSWSimTools/TrigT1NSWSimTools/StripTdsOfflineTool.h b/Trigger/TrigT1/TrigT1NSWSimTools/TrigT1NSWSimTools/StripTdsOfflineTool.h index 72765b04a9b3156f6c417b02f36c2f54af710a4a..7dc38a736e43bb8e0fc1680a110191556df8738e 100644 --- a/Trigger/TrigT1/TrigT1NSWSimTools/TrigT1NSWSimTools/StripTdsOfflineTool.h +++ b/Trigger/TrigT1/TrigT1NSWSimTools/TrigT1NSWSimTools/StripTdsOfflineTool.h @@ -99,7 +99,7 @@ namespace NSWL1 { // needed Servives, Tools and Helpers ServiceHandle<IIncidentSvc> m_incidentSvc{this, "IncidentSvc", "IncidentSvc"}; //!< Athena/Gaudi incident Service - const MuonGM::MuonDetectorManager* m_detManager; //!< MuonDetectorManager + SG::ReadCondHandleKey<MuonGM::MuonDetectorManager> m_detManagerKey{this, "MuonManagerKey", "MuonDetectorManager"}; ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; // hidden variables diff --git a/Trigger/TrigT1/TrigT1NSWSimTools/src/MMTriggerTool.cxx b/Trigger/TrigT1/TrigT1NSWSimTools/src/MMTriggerTool.cxx index 1400356fc033509d4b50308e4def84e5aa0a9992..3926ffdcfe38d426edfe549875d2acb73588e3fa 100644 --- a/Trigger/TrigT1/TrigT1NSWSimTools/src/MMTriggerTool.cxx +++ b/Trigger/TrigT1/TrigT1NSWSimTools/src/MMTriggerTool.cxx @@ -10,7 +10,6 @@ namespace NSWL1 { MMTriggerTool::MMTriggerTool( const std::string& type, const std::string& name, const IInterface* parent) : AthAlgTool(type,name,parent), - m_detManager(nullptr), m_MmIdHelper(nullptr), m_tree(nullptr) { @@ -55,17 +54,27 @@ namespace NSWL1 { } // retrieve the MuonDetectormanager - ATH_CHECK( detStore()->retrieve( m_detManager ) ); + ATH_CHECK(m_detManagerKey.initialize()); // retrieve the Mm offline Id helper ATH_CHECK( detStore()->retrieve( m_MmIdHelper ) ); - m_par_large = std::make_shared<MMT_Parameters>("xxuvuvxx",'L', m_detManager); - m_par_small = std::make_shared<MMT_Parameters>("xxuvuvxx",'S', m_detManager); - return StatusCode::SUCCESS; } + void MMTriggerTool::fillPointers(const MuonGM::MuonDetectorManager* detManager) const{ + + std::lock_guard guard{m_mutex}; + if (m_isInitialized) { + return; + } + + m_par_large = std::make_shared<MMT_Parameters>("xxuvuvxx",'L', detManager); + m_par_small = std::make_shared<MMT_Parameters>("xxuvuvxx",'S', detManager); + + m_isInitialized=true; + } + StatusCode MMTriggerTool::runTrigger(const EventContext& ctx, Muon::NSW_TrigRawDataContainer* rdo, const bool do_MMDiamonds) const { int event = ctx.eventID().event_number(); @@ -76,11 +85,14 @@ namespace NSWL1 { // Load Variables From Containers into our Data Structures // // // ////////////////////////////////////////////////////////////// + SG::ReadCondHandle<MuonGM::MuonDetectorManager> detManagerHandle{m_detManagerKey, ctx}; + const MuonGM::MuonDetectorManager* detManager = detManagerHandle.cptr(); + if(!m_isInitialized) {fillPointers(detManager);} std::map<std::string, std::shared_ptr<MMT_Parameters> > pars; pars["MML"] = m_par_large; pars["MMS"] = m_par_small; - MMLoadVariables load = MMLoadVariables(m_detManager, m_MmIdHelper); + MMLoadVariables load = MMLoadVariables(detManager, m_MmIdHelper); std::map<std::pair<int, unsigned int>,std::vector<digitWrapper> > entries; std::map<std::pair<int, unsigned int>,std::vector<hitData_entry> > Hits_Data_Set_Time; @@ -119,7 +131,7 @@ namespace NSWL1 { return StatusCode::SUCCESS; } - std::unique_ptr<MMT_Diamond> diamond = std::make_unique<MMT_Diamond>(m_detManager); + std::unique_ptr<MMT_Diamond> diamond = std::make_unique<MMT_Diamond>(detManager); if (do_MMDiamonds) { diamond->setTrapezoidalShape(m_trapShape); diamond->setXthreshold(m_diamXthreshold); @@ -185,7 +197,7 @@ namespace NSWL1 { * Filling hits for each event: a new class, MMT_Hit, is called in * order to use both algorithms witghout interferences */ - diamond->createRoads_fillHits(i-nskip, reco_it->second, m_detManager, pars[station], stationPhi); + diamond->createRoads_fillHits(i-nskip, reco_it->second, detManager, pars[station], stationPhi); if (m_doNtuple) { for(const auto &hit : reco_it->second) { m_trigger_VMM->push_back(hit.VMM_chip); diff --git a/Trigger/TrigT1/TrigT1NSWSimTools/src/PadTdsOfflineTool.cxx b/Trigger/TrigT1/TrigT1NSWSimTools/src/PadTdsOfflineTool.cxx index f1c5a4d8e69df5c711747e804789ca33d2f43538..d71f87913cac72db925a3beb4bc7a29be2fdfd3b 100644 --- a/Trigger/TrigT1/TrigT1NSWSimTools/src/PadTdsOfflineTool.cxx +++ b/Trigger/TrigT1/TrigT1NSWSimTools/src/PadTdsOfflineTool.cxx @@ -30,8 +30,7 @@ namespace NSWL1 { //------------------------------------------------------------------------------ PadTdsOfflineTool::PadTdsOfflineTool( const std::string& type, const std::string& name, const IInterface* parent) : - AthAlgTool(type,name,parent), - m_detManager(0) + AthAlgTool(type,name,parent) { declareInterface<NSWL1::IPadTdsTool>(this); } @@ -77,7 +76,7 @@ namespace NSWL1 { } // retrieve the MuonDetectormanager - ATH_CHECK( detStore()->retrieve( m_detManager ) ); + ATH_CHECK(m_detManagerKey.initialize()); // retrieve the Random Service ATH_CHECK( m_rndmSvc.retrieve() ); @@ -112,12 +111,13 @@ namespace NSWL1 { } //------------------------------------------------------------------------------ StatusCode PadTdsOfflineTool::fill_pad_validation_id ATLAS_NOT_THREAD_SAFE (std::vector< std::vector<std::shared_ptr<PadData>> > &pad_cache) const { + SG::ReadCondHandle<MuonGM::MuonDetectorManager> detManager{m_detManagerKey, Gaudi::Hive::currentContext()}; float bin_offset = +0.; // used to center the bin on the value of the Pad Id for (const std::vector<std::shared_ptr<PadData>>& pad : pad_cache) { m_validation_tree->fill_num_pad_hits(pad.size()); for (const std::shared_ptr<PadData> &pd : pad) { Identifier Id( pd->id() ); - const MuonGM::sTgcReadoutElement* rdoEl = m_detManager->getsTgcReadoutElement(Id); + const MuonGM::sTgcReadoutElement* rdoEl = detManager->getsTgcReadoutElement(Id); const Trk::PlaneSurface &surface = rdoEl->surface(Id); // gathers the readout element associated to this PAD + the PAD Local/Global psoition Amg::Vector2D pad_lpos{Amg::Vector2D::Zero()}; @@ -221,6 +221,7 @@ namespace NSWL1 { } //------------------------------------------------------------------------------ StatusCode PadTdsOfflineTool::fill_pad_cache(std::vector< std::vector<std::shared_ptr<PadData>> > &pad_cache) const { + SG::ReadCondHandle<MuonGM::MuonDetectorManager> detManager{m_detManagerKey, Gaudi::Hive::currentContext()}; SG::ReadHandle<sTgcDigitContainer> digit_container(m_sTgcDigitContainer); if(!digit_container.isValid()){ ATH_MSG_ERROR("could not retrieve the sTGC Digit container: cannot return the STRIP hits"); @@ -249,7 +250,7 @@ namespace NSWL1 { //PadOfflineData* pad = new PadOfflineData(Id, digit->time(), digit->bcTag(), m_sTgcIdHelper); //S.I //std::shared_ptr<PadOfflineData> pad(new PadOfflineData(Id, digit->time(), digit->bcTag(), m_sTgcIdHelper)); - auto pad=std::make_shared<PadOfflineData>(Id, digit->time(), digit->bcTag(), m_detManager); + auto pad=std::make_shared<PadOfflineData>(Id, digit->time(), digit->bcTag(), *detManager); //pad_hits.push_back(PadHits(Id, pad, cache_index(digit))); pad_hits.emplace_back(Id, pad, cache_index(digit));//avoids extra copy //S.I @@ -266,8 +267,9 @@ namespace NSWL1 { } //------------------------------------------------------------------------------ double PadTdsOfflineTool::computeTof(const sTgcDigit* digit) const { + SG::ReadCondHandle<MuonGM::MuonDetectorManager> detManager{m_detManagerKey, Gaudi::Hive::currentContext()}; Identifier Id = digit->identify(); - const MuonGM::sTgcReadoutElement* rdoEl = m_detManager->getsTgcReadoutElement(Id); + const MuonGM::sTgcReadoutElement* rdoEl = detManager->getsTgcReadoutElement(Id); Amg::Vector2D pad_lpos; rdoEl->stripPosition(Id,pad_lpos); Amg::Vector3D pad_gpos; diff --git a/Trigger/TrigT1/TrigT1NSWSimTools/src/PadTriggerLogicOfflineTool.cxx b/Trigger/TrigT1/TrigT1NSWSimTools/src/PadTriggerLogicOfflineTool.cxx index ce571bf275c1e08d0b62820499d66fad96df646f..1a6f598ab9bf1668d0c856665a9872af6f2f48a3 100644 --- a/Trigger/TrigT1/TrigT1NSWSimTools/src/PadTriggerLogicOfflineTool.cxx +++ b/Trigger/TrigT1/TrigT1NSWSimTools/src/PadTriggerLogicOfflineTool.cxx @@ -7,6 +7,7 @@ #include "TrigT1NSWSimTools/PadTriggerLogicOfflineTool.h" #include "MuonAGDDDescription/sTGCDetectorDescription.h" #include "MuonAGDDDescription/sTGCDetectorHelper.h" +#include <mutex> namespace NSWL1 { //------------------------------------------------------------------------------ @@ -14,7 +15,6 @@ PadTriggerLogicOfflineTool::PadTriggerLogicOfflineTool(const std::string& type, AthAlgTool(type,name,parent), m_etaBandsLargeSector(BandsInEtaLargeSector), m_etaBandsSmallSector(BandsInEtaSmallSector), - m_detManager(nullptr), m_tdrLogic() { declareInterface<NSWL1::IPadTriggerLogicTool>(this); @@ -50,9 +50,8 @@ StatusCode PadTriggerLogicOfflineTool::initialize() { } // retrieve the MuonDetectormanager - ATH_CHECK( detStore()->retrieve( m_detManager ) ); + ATH_CHECK(m_detManagerKey.initialize()); - fillPhiTable(); return StatusCode::SUCCESS; } //------------------------------------------------------------------------------ @@ -64,7 +63,8 @@ void PadTriggerLogicOfflineTool::handle(const Incident& inc) { } void PadTriggerLogicOfflineTool::fillGeometricInformation(PadOfflineData& pod) const { - const MuonGM::sTgcReadoutElement* rdoEl = m_detManager->getsTgcReadoutElement(pod.Identity()); + SG::ReadCondHandle<MuonGM::MuonDetectorManager> detManager{m_detManagerKey, Gaudi::Hive::currentContext()}; + const MuonGM::sTgcReadoutElement* rdoEl = detManager->getsTgcReadoutElement(pod.Identity()); const Trk::PlaneSurface &surface = rdoEl->surface(pod.Identity()); std::array<Amg::Vector2D, 4> local_pad_corners{make_array<Amg::Vector2D, 4>(Amg::Vector2D::Zero())}; //From MuonPadDesign... read pad local corners @@ -138,6 +138,7 @@ std::vector<std::unique_ptr<PadTrigger>> PadTriggerLogicOfflineTool::build4of4Si StatusCode PadTriggerLogicOfflineTool::compute_pad_triggers(const std::vector<std::shared_ptr<PadData>>& pads, std::vector<std::unique_ptr<PadTrigger>> &triggers) const { + if(!m_isInitialized) {fillPhiTable();} ATH_MSG_DEBUG(" <N> receiving "<<pads.size()<<" pad data"); ATH_MSG_DEBUG("calling compute_pad_triggers() (pads.size() "<<pads.size()<<")"); for(const auto& pad : pads){ @@ -259,7 +260,8 @@ NSWL1::PadTrigger PadTriggerLogicOfflineTool::convert(const SectorTriggerCandida //************************************************************************************** auto pad0=innertrg.pads().at(0); Identifier idt(pad0->id()); - const Trk::PlaneSurface &surf = m_detManager->getsTgcReadoutElement(idt)->surface(idt); + SG::ReadCondHandle<MuonGM::MuonDetectorManager> detManager{m_detManagerKey, Gaudi::Hive::currentContext()}; + const Trk::PlaneSurface &surf = detManager->getsTgcReadoutElement(idt)->surface(idt); Amg::Vector3D global_trgCoordinates(xcntr,ycntr,zcntr); Amg::Vector2D local_trgCoordinates; surf.globalToLocal(global_trgCoordinates,Amg::Vector3D(),local_trgCoordinates); @@ -341,7 +343,7 @@ NSWL1::PadTrigger PadTriggerLogicOfflineTool::convert(const SectorTriggerCandida for(const auto &p : swt.pads()){ const float padZ=p->m_cornerXyz[0][2]; Identifier Id( p->id()); - const Trk::PlaneSurface &padsurface = m_detManager->getsTgcReadoutElement(Id)->surface(Id); + const Trk::PlaneSurface &padsurface = detManager->getsTgcReadoutElement(Id)->surface(Id); float Phi=p->stationPhiAngle(); //Find the radial boundaries of the band within the sector axis @@ -404,12 +406,13 @@ NSWL1::PadTrigger PadTriggerLogicOfflineTool::convert(const SectorTriggerCandida //Assignment of Phi Id using 6 bits slicing Identifier padIdentifier(pt.m_pads.at(0)->id() ); IdentifierHash moduleHashId; - const IdContext ModuleContext = m_detManager->stgcIdHelper()->module_context(); + const IdContext ModuleContext = detManager->stgcIdHelper()->module_context(); //get the module Identifier using the pad's - m_detManager->stgcIdHelper()->get_hash( padIdentifier, moduleHashId, &ModuleContext ); + detManager->stgcIdHelper()->get_hash( padIdentifier, moduleHashId, &ModuleContext ); float stationPhiMin=0.0; float stationPhiMax=0.0; + if (!m_isInitialized){fillPhiTable();} std::map<IdentifierHash,std::pair<double,double>>::const_iterator itPhi = m_phiTable.find(moduleHashId); if (itPhi != m_phiTable.end()) { stationPhiMin=(*itPhi).second.first; @@ -442,9 +445,14 @@ NSWL1::PadTrigger PadTriggerLogicOfflineTool::convert(const SectorTriggerCandida } // fill the map with the phi ranges - void PadTriggerLogicOfflineTool::fillPhiTable() { - - const sTgcIdHelper* helper = m_detManager->stgcIdHelper(); + void PadTriggerLogicOfflineTool::fillPhiTable() const { + + std::lock_guard guard{m_mutex}; + if (m_isInitialized) { + return; + } + SG::ReadCondHandle<MuonGM::MuonDetectorManager> detManager{m_detManagerKey, Gaudi::Hive::currentContext()}; + const sTgcIdHelper* helper = detManager->stgcIdHelper(); std::vector<Identifier>::const_iterator idfirst = helper->module_begin(); std::vector<Identifier>::const_iterator idlast = helper->module_end(); @@ -458,7 +466,7 @@ NSWL1::PadTrigger PadTriggerLogicOfflineTool::convert(const SectorTriggerCandida helper->get_hash( Id, hashId, &ModuleContext ); - const MuonGM::sTgcReadoutElement* module = m_detManager->getsTgcReadoutElement(Id); + const MuonGM::sTgcReadoutElement* module = detManager->getsTgcReadoutElement(Id); if (!module) continue; int multilayer = helper->multilayer(Id); @@ -495,14 +503,14 @@ NSWL1::PadTrigger PadTriggerLogicOfflineTool::convert(const SectorTriggerCandida if((sector_l=='L' && m_Zratio.first==0) || (sector_l=='S' && m_Zratio.second==0)) { double ratio=1/pos.z(); Id=helper->multilayerID(Id,2); - const MuonGM::sTgcReadoutElement* module2 = m_detManager->getsTgcReadoutElement(Id); + const MuonGM::sTgcReadoutElement* module2 = detManager->getsTgcReadoutElement(Id); Amg::Vector3D pos2 = module2->center(); ratio*=pos2.z(); if(sector_l=='L') m_Zratio.first=ratio; else if(sector_l=='S') m_Zratio.second=ratio; } } - + m_isInitialized = true; } diff --git a/Trigger/TrigT1/TrigT1NSWSimTools/src/PadTriggerLookupTool.cxx b/Trigger/TrigT1/TrigT1NSWSimTools/src/PadTriggerLookupTool.cxx index f2d257d661f9b0340d1520dbfb536c0952e7e773..dfcb6efb0fe6dcaa3c938269f910bff52de190c1 100644 --- a/Trigger/TrigT1/TrigT1NSWSimTools/src/PadTriggerLookupTool.cxx +++ b/Trigger/TrigT1/TrigT1NSWSimTools/src/PadTriggerLookupTool.cxx @@ -28,15 +28,14 @@ namespace NSWL1 { PadTriggerLookupTool::PadTriggerLookupTool(const std::string& type, const std::string& name, const IInterface* parent) : AthAlgTool(type,name,parent), m_etaBandsLargeSector(BandsInEtaLargeSector), - m_etaBandsSmallSector(BandsInEtaSmallSector), - m_detManager(nullptr) { + m_etaBandsSmallSector(BandsInEtaSmallSector){ declareInterface<NSWL1::IPadTriggerLookupTool>(this); } StatusCode PadTriggerLookupTool::initialize() { ATH_MSG_DEBUG( "initializing " << name() ); ATH_MSG_DEBUG( name() << " configuration:"); - ATH_CHECK( detStore()->retrieve( m_detManager )); + ATH_CHECK(m_detManagerKey.initialize()); ATH_CHECK(loadCoincidenceTable("TriggerPatterns.dat") ); if(m_dumpSectorGeometry){ ATH_MSG_DEBUG(" Will dump 3D pad geometry / sector"); @@ -400,6 +399,8 @@ std::vector<std::vector<std::shared_ptr<PadData> >> PadTriggerLookupTool::select */ std::vector<std::shared_ptr<PadOfflineData>> PadTriggerLookupTool::fetchSectorPads(bool isSmall, int SIDE,int SECTOR) { + SG::ReadCondHandle<MuonGM::MuonDetectorManager> detManagerHandle{m_detManagerKey, Gaudi::Hive::currentContext()}; + const MuonGM::MuonDetectorManager* detManager = detManagerHandle.cptr(); std::vector<std::shared_ptr<PadOfflineData>> sectorPads; std::vector<Identifier> padIds; @@ -428,7 +429,7 @@ std::vector<std::vector<std::shared_ptr<PadData> >> PadTriggerLookupTool::select int gasgap=m_idHelperSvc->stgcIdHelper().gasGap(id); int channeltype=m_idHelperSvc->stgcIdHelper().channelType(id); - const MuonGM::sTgcReadoutElement* rdoEl = m_detManager->getsTgcReadoutElement(id); + const MuonGM::sTgcReadoutElement* rdoEl = detManager->getsTgcReadoutElement(id); const MuonGM::MuonPadDesign* mpd=rdoEl->getPadDesign(id); int padEtaMinFromDesign=mpd->padEtaMin; int padEtaMaxFromDesign=mpd->padEtaMax; @@ -441,7 +442,7 @@ std::vector<std::vector<std::shared_ptr<PadData> >> PadTriggerLookupTool::select if( thisEta>nPadRowsFromDesign || thisPhi > nPadCols ) continue; Identifier pid=m_idHelperSvc->stgcIdHelper().padID(id, multilayer, gasgap, channeltype, thisEta, thisPhi); - auto pad=std::make_shared<PadOfflineData>(pid, 0, 0, m_detManager); + auto pad=std::make_shared<PadOfflineData>(pid, 0, 0, detManager); pad->fillGeometricInformation(); sectorPads.push_back(pad); } diff --git a/Trigger/TrigT1/TrigT1NSWSimTools/src/StripClusterTool.cxx b/Trigger/TrigT1/TrigT1NSWSimTools/src/StripClusterTool.cxx index eaa381bd757e482643bde12519ae5660a4104948..b70e17308d9c86d0af49c34855ff84c634b15ad2 100644 --- a/Trigger/TrigT1/TrigT1NSWSimTools/src/StripClusterTool.cxx +++ b/Trigger/TrigT1/TrigT1NSWSimTools/src/StripClusterTool.cxx @@ -10,7 +10,6 @@ namespace NSWL1 { StripClusterTool::StripClusterTool( const std::string& type, const std::string& name, const IInterface* parent) : AthAlgTool(type,name,parent), - m_detManager(nullptr), m_tree(nullptr) { declareInterface<NSWL1::IStripClusterTool>(this); @@ -49,7 +48,7 @@ namespace NSWL1 { } // retrieve the MuonDetectormanager - ATH_CHECK(detStore()->retrieve( m_detManager )); + ATH_CHECK(m_detManagerKey.initialize()); ATH_CHECK(m_idHelperSvc.retrieve()); return StatusCode::SUCCESS; } @@ -195,7 +194,7 @@ namespace NSWL1 { StatusCode StripClusterTool::fill_strip_validation_id(const EventContext& ctx, std::vector<std::unique_ptr<StripClusterData>>& clusters, std::vector<std::shared_ptr<std::vector<std::unique_ptr<StripData> >> > &cluster_cache) const { - + SG::ReadCondHandle<MuonGM::MuonDetectorManager> detManager{m_detManagerKey, ctx}; ATH_MSG_DEBUG("Cluster cache received " << cluster_cache.size()); bool first_strip=true; @@ -236,7 +235,7 @@ namespace NSWL1 { if(m_isMC && first_strip) { first_strip=false; Identifier Id = strip_cl->Identity(); - const MuonGM::sTgcReadoutElement* rdoEl = m_detManager->getsTgcReadoutElement(Id); + const MuonGM::sTgcReadoutElement* rdoEl = detManager->getsTgcReadoutElement(Id); auto it = sdo_container->find(Id); if(it == sdo_container->end()) continue; const MuonSimData strip_sdo = it->second; diff --git a/Trigger/TrigT1/TrigT1NSWSimTools/src/StripTdsOfflineTool.cxx b/Trigger/TrigT1/TrigT1NSWSimTools/src/StripTdsOfflineTool.cxx index cae3c1c21513b7044f2b78ee337148ac42652592..5c1f1b7407b3bab0bb90913aa2e5b9c58fd9fef9 100644 --- a/Trigger/TrigT1/TrigT1NSWSimTools/src/StripTdsOfflineTool.cxx +++ b/Trigger/TrigT1/TrigT1NSWSimTools/src/StripTdsOfflineTool.cxx @@ -27,7 +27,6 @@ namespace NSWL1 { StripTdsOfflineTool::StripTdsOfflineTool( const std::string& type, const std::string& name, const IInterface* parent) : AthAlgTool(type,name,parent), m_incidentSvc("IncidentSvc",name), - m_detManager(nullptr), m_tree(nullptr) { declareInterface<NSWL1::IStripTdsTool>(this); @@ -65,7 +64,7 @@ namespace NSWL1 { ATH_CHECK(this->book_branches()); } } - ATH_CHECK(detStore()->retrieve(m_detManager)); + ATH_CHECK(m_detManagerKey.initialize()); ATH_CHECK(m_idHelperSvc.retrieve()); return StatusCode::SUCCESS; } @@ -183,6 +182,7 @@ namespace NSWL1 { StatusCode StripTdsOfflineTool::fill_strip_cache( const std::vector<std::unique_ptr<PadTrigger>>& padTriggers, std::vector<std::unique_ptr<StripData>> &strip_cache) const { + SG::ReadCondHandle<MuonGM::MuonDetectorManager> detManager{m_detManagerKey, Gaudi::Hive::currentContext()}; ATH_MSG_DEBUG( "fill_strip_cache: start filling the cache for STRIP hits" ); if(m_isMC){ @@ -210,7 +210,7 @@ namespace NSWL1 { for (unsigned int item=0; item<coll->size(); item++) { const sTgcDigit* digit = coll->at(item); Identifier Id = digit->identify(); - const MuonGM::sTgcReadoutElement* rdoEl = m_detManager->getsTgcReadoutElement(Id); + const MuonGM::sTgcReadoutElement* rdoEl = detManager->getsTgcReadoutElement(Id); int channel_type = m_idHelperSvc->stgcIdHelper().channelType(Id); // process only Strip data if (channel_type!=1) continue;