diff --git a/MuonSpectrometer/MuonCnv/MuonMM_CnvTools/src/MmRdoToPrepDataToolCore.cxx b/MuonSpectrometer/MuonCnv/MuonMM_CnvTools/src/MmRdoToPrepDataToolCore.cxx index b385a199b2b567ed2deb92e43db00dbc2a47e679..5d1c17eef6d00a91c6c41dcaa18acab207c67f4d 100644 --- a/MuonSpectrometer/MuonCnv/MuonMM_CnvTools/src/MmRdoToPrepDataToolCore.cxx +++ b/MuonSpectrometer/MuonCnv/MuonMM_CnvTools/src/MmRdoToPrepDataToolCore.cxx @@ -97,6 +97,14 @@ StatusCode Muon::MmRdoToPrepDataToolCore::processCollection(const MM_RawDataColl } + // MuonDetectorManager from the conditions store + SG::ReadCondHandle<MuonGM::MuonDetectorManager> DetectorManagerHandle{m_muDetMgrKey}; + const MuonGM::MuonDetectorManager* MuonDetMgr = DetectorManagerHandle.cptr(); + if(MuonDetMgr==nullptr){ + ATH_MSG_ERROR("Null pointer to the read MuonDetectorManager conditions object"); + return StatusCode::FAILURE; + } + std::vector<MMPrepData> MMprds; // convert the RDO collection to a PRD collection MM_RawDataCollection::const_iterator it = rdoColl->begin(); @@ -119,14 +127,9 @@ StatusCode Muon::MmRdoToPrepDataToolCore::processCollection(const MM_RawDataColl Identifier prdId = m_idHelperSvc->mmIdHelper().channelID(parentID, m_idHelperSvc->mmIdHelper().multilayer(rdoId), m_idHelperSvc->mmIdHelper().gasGap(rdoId),channel); ATH_MSG_DEBUG(" channel RDO " << channel << " channel from rdoID " << m_idHelperSvc->mmIdHelper().channel(rdoId)); rdoList.push_back(prdId); - - // TODO: this needs to be replaced by SG::ReadCondHandle<MuonGM::MuonDetectorManager> - // will do it in a follow-up MR, since for now, we need to get the Run2 detectors running, so skip MicroMegas for now - const MuonGM::MuonDetectorManager* muDetMgrNominal=nullptr; - ATH_CHECK(detStore()->retrieve(muDetMgrNominal)); - + // get the local and global positions - const MuonGM::MMReadoutElement* detEl = muDetMgrNominal->getMMReadoutElement(layid); + const MuonGM::MMReadoutElement* detEl = MuonDetMgr->getMMReadoutElement(layid); Amg::Vector2D localPos; bool getLocalPos = detEl->stripPosition(prdId,localPos); diff --git a/MuonSpectrometer/MuonDetDescr/MuonAGDD/CMakeLists.txt b/MuonSpectrometer/MuonDetDescr/MuonAGDD/CMakeLists.txt index 97a752a13617fa0e04254064b79cf7a13906f005..9a138202eabb737c485cc4a20d7143d9df2c916a 100644 --- a/MuonSpectrometer/MuonDetDescr/MuonAGDD/CMakeLists.txt +++ b/MuonSpectrometer/MuonDetDescr/MuonAGDD/CMakeLists.txt @@ -30,6 +30,7 @@ atlas_depends_on_subdirs( PUBLIC DetectorDescription/GeoModel/GeoModelInterfaces MuonSpectrometer/MuonDetDescr/MuonAGDDBase MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry + MuonSpectrometer/MuonDetDescr/MuonDetDescrUtils ${extra_dep} ) # External dependencies: @@ -41,7 +42,7 @@ atlas_add_component( MuonAGDD src/*.cxx src/components/*.cxx INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${CORAL_INCLUDE_DIRS} - LINK_LIBRARIES ${Boost_LIBRARIES} ${CORAL_LIBRARIES} AGDDControl GaudiKernel StoreGateLib SGtests AGDDKernel AGDDModel MuonAGDDBase MuonReadoutGeometry ${extra_lib} + LINK_LIBRARIES ${Boost_LIBRARIES} ${CORAL_LIBRARIES} AGDDControl GaudiKernel StoreGateLib SGtests AGDDKernel AGDDModel MuonAGDDBase MuonReadoutGeometry MuonDetDescrUtils ${extra_lib} PRIVATE_LINK_LIBRARIES AGDD2GeoSvcLib ) # Install files from the package: diff --git a/MuonSpectrometer/MuonDetDescr/MuonAGDD/src/MuonAGDDToolHelper.cxx b/MuonSpectrometer/MuonDetDescr/MuonAGDD/src/MuonAGDDToolHelper.cxx index 4312348750caffd6a8457aebaba493b3e49a498b..0606e2b108e80435581e7002e78df66ad4a1380b 100644 --- a/MuonSpectrometer/MuonDetDescr/MuonAGDD/src/MuonAGDDToolHelper.cxx +++ b/MuonSpectrometer/MuonDetDescr/MuonAGDD/src/MuonAGDDToolHelper.cxx @@ -38,6 +38,8 @@ #include "MuonAGDDBase/mmSpacer_TechHandler.h" #include "MuonAGDDBase/mm_readoutHandler.h" +#include "MuonDetDescrUtils/BuildNSWReadoutGeometry.h" + #include <TString.h> // for Form #include <fstream> @@ -140,81 +142,29 @@ bool MuonAGDDToolHelper::BuildMScomponents() const if (svcLocator->service("DetectorStore",pDetStore).isFailure()) return false; MuonGM::MuonDetectorManager* muonMgr=nullptr; if (pDetStore->retrieve(muonMgr).isFailure()) return false; - bool readoutGeoDone = BuildReadoutGeometry(muonMgr/*, GetMSdetectors*/); + BuildNSWReadoutGeometry theBuilder = BuildNSWReadoutGeometry(); + bool readoutGeoDone = theBuilder.BuildReadoutGeometry(muonMgr/*, GetMSdetectors*/); if (!readoutGeoDone) return false; return true; } -bool MuonAGDDToolHelper::BuildReadoutGeometry(MuonGM::MuonDetectorManager* mgr/*, std::map<GeoFullPhysVol*, std::string>* vec*/) const -{ - bool geoBuilt = true; - - detectorList& dList=AGDDDetectorStore::GetDetectorStore()->GetDetectorList(); - detectorList::const_iterator it; - for (it=dList.begin(); it!=dList.end(); ++it) - { - std::vector<AGDDDetectorPositioner*>& dPos=((*it).second)->GetDetectorPositioners(); - for (unsigned int i=0;i<dPos.size();i++) - { - std::string chTag = dPos[i]->ID.detectorAddress; - GeoFullPhysVol* vol = dPos[i]->theVolume; - - std::string stName = chTag.substr(0,4); - - int etaIndex = 999; - int phiIndex = 999; - int mLayer = 999; - int iSide = 0; - int iLS = atoi((chTag.substr(3,1)).c_str()); //sTG3 and sMD3 are small chambers for small sectors - if (iLS==3) iLS = 1; // small - else iLS = 0; // large - if (chTag.substr(13,1)=="A") iSide=1; - else if (chTag.substr(13,1)=="C") iSide=-1; - etaIndex = iSide*atoi((chTag.substr(5,1)).c_str()); - phiIndex = atoi((chTag.substr(12,1)).c_str()); - mLayer = atoi((chTag.substr(7,1)).c_str()); - - if (chTag.substr(0,3)=="sMD") - { - MMReadoutElement* re = new MMReadoutElement((GeoVFullPhysVol*)vol, stName, etaIndex, phiIndex, mLayer, false, mgr); - std::string myVolName = (chTag.substr(0,8)).c_str(); - re->initDesign(-999., -999., -999., -999., -999.); - re->fillCache(); - mgr->addMMReadoutElement_withIdFields(re, iLS, etaIndex, phiIndex, mLayer); - re->setDelta(mgr); - } - else if (chTag.substr(0,3)=="sTG") - { - sTgcReadoutElement* re = new sTgcReadoutElement((GeoVFullPhysVol*)vol, stName, etaIndex, phiIndex, mLayer, false, mgr); - std::string myVolName = (chTag.substr(0,8)).c_str(); - re->initDesign(-999., -999., -999., 3.2, -999., 2.7, -999., 2.6); - re->fillCache(); - mgr->addsTgcReadoutElement_withIdFields(re, iLS, etaIndex, phiIndex, mLayer); - re->setDelta(mgr); - } - } - } - return geoBuilt; - -} - void MuonAGDDToolHelper::SetNSWComponents() { - IAGDDtoGeoSvc* agddsvc = nullptr; - if (Gaudi::svcLocator()->service(m_svcName,agddsvc).isFailure()) { + IAGDDtoGeoSvc* agddsvc = nullptr; + if (Gaudi::svcLocator()->service(m_svcName,agddsvc).isFailure()) { throw std::runtime_error(Form("File: %s, Line: %d\nMuonAGDDToolHelper::SetNSWComponents() - Could not retrieve %s from ServiceLocator", __FILE__, __LINE__, m_svcName.c_str())); } - agddsvc->addHandler(new micromegasHandler("micromegas")); - agddsvc->addHandler(new mm_TechHandler("mm_Tech")); - agddsvc->addHandler(new sTGCHandler("sTGC")); - agddsvc->addHandler(new sTGC_readoutHandler("sTGC_readout")); - agddsvc->addHandler(new sTGC_TechHandler("sTGC_Tech")); - agddsvc->addHandler(new mmSpacerHandler("mmSpacer")); - agddsvc->addHandler(new mmSpacer_TechHandler("mmSpacer_Tech")); - agddsvc->addHandler(new mm_readoutHandler("mm_readout")); + agddsvc->addHandler(new micromegasHandler("micromegas")); + agddsvc->addHandler(new mm_TechHandler("mm_Tech")); + agddsvc->addHandler(new sTGCHandler("sTGC")); + agddsvc->addHandler(new sTGC_readoutHandler("sTGC_readout")); + agddsvc->addHandler(new sTGC_TechHandler("sTGC_Tech")); + agddsvc->addHandler(new mmSpacerHandler("mmSpacer")); + agddsvc->addHandler(new mmSpacer_TechHandler("mmSpacer_Tech")); + agddsvc->addHandler(new mm_readoutHandler("mm_readout")); } void MuonAGDDToolHelper::setAGDDtoGeoSvcName(const std::string& name) { m_svcName = name; -} \ No newline at end of file +} diff --git a/MuonSpectrometer/MuonDetDescr/MuonAGDD/src/MuonAGDDToolHelper.h b/MuonSpectrometer/MuonDetDescr/MuonAGDD/src/MuonAGDDToolHelper.h index 7b65dbaea9728ae2936d9608893f72b76f49a4ce..6eb8c90d328710ac2712ea7de87bc9559cccbfec 100644 --- a/MuonSpectrometer/MuonDetDescr/MuonAGDD/src/MuonAGDDToolHelper.h +++ b/MuonSpectrometer/MuonDetDescr/MuonAGDD/src/MuonAGDDToolHelper.h @@ -28,7 +28,6 @@ public: std::string GetAGDD(const bool dumpIt, const std::string& tableName, const std::string& outFileName); bool BuildMScomponents() const; - bool BuildReadoutGeometry(MuonGM::MuonDetectorManager* mgr) const; void setAGDDtoGeoSvcName(const std::string& name); diff --git a/MuonSpectrometer/MuonDetDescr/MuonDetDescrUtils/CMakeLists.txt b/MuonSpectrometer/MuonDetDescr/MuonDetDescrUtils/CMakeLists.txt index 8ba3f4dd3d5e2adace8d4f70446d07c8aecc86e2..95f1d167bdbbe6132c78169741e1c780899dfab5 100644 --- a/MuonSpectrometer/MuonDetDescr/MuonDetDescrUtils/CMakeLists.txt +++ b/MuonSpectrometer/MuonDetDescr/MuonDetDescrUtils/CMakeLists.txt @@ -7,7 +7,10 @@ atlas_subdir( MuonDetDescrUtils ) # Declare the package's dependencies: atlas_depends_on_subdirs( PUBLIC - MuonSpectrometer/MuonStationIndex ) + MuonSpectrometer/MuonStationIndex + PRIVATE + DetectorDescription/AGDD/AGDDKernel + MuonSpectrometer/MuonDetDescr/MuonReadoutGeometry ) # External dependencies: find_package( ROOT COMPONENTS RIO Tree Core MathCore Hist pthread ) @@ -18,7 +21,7 @@ atlas_add_library( MuonDetDescrUtils PUBLIC_HEADERS MuonDetDescrUtils PRIVATE_INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} LINK_LIBRARIES MuonStationIndexLib - PRIVATE_LINK_LIBRARIES ${ROOT_LIBRARIES} ) + PRIVATE_LINK_LIBRARIES ${ROOT_LIBRARIES} AGDDKernel MuonReadoutGeometry ) atlas_add_executable( MuonSectorMappingTest exe/MuonSectorMappingTest.cxx diff --git a/MuonSpectrometer/MuonDetDescr/MuonDetDescrUtils/MuonDetDescrUtils/BuildNSWReadoutGeometry.h b/MuonSpectrometer/MuonDetDescr/MuonDetDescrUtils/MuonDetDescrUtils/BuildNSWReadoutGeometry.h new file mode 100644 index 0000000000000000000000000000000000000000..37353f3e83fd559f07d6a1ff88946a50a692b710 --- /dev/null +++ b/MuonSpectrometer/MuonDetDescr/MuonDetDescrUtils/MuonDetDescrUtils/BuildNSWReadoutGeometry.h @@ -0,0 +1,27 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef MUON_BUILDNSWREADOUTGEOMETRY_H +#define MUON_BUILDNSWREADOUTGEOMETRY_H + +#include <vector> + +namespace MuonGM +{ + class MuonDetectorManager; +} + +class BuildNSWReadoutGeometry +{ +public: + BuildNSWReadoutGeometry(); + + bool BuildReadoutGeometry(MuonGM::MuonDetectorManager* mgr) const; + +private: + + +}; + +#endif diff --git a/MuonSpectrometer/MuonDetDescr/MuonDetDescrUtils/src/BuildNSWReadoutGeometry.cxx b/MuonSpectrometer/MuonDetDescr/MuonDetDescrUtils/src/BuildNSWReadoutGeometry.cxx new file mode 100644 index 0000000000000000000000000000000000000000..dc1648520d8a7895f51ff8275660f5b9d82b89a1 --- /dev/null +++ b/MuonSpectrometer/MuonDetDescr/MuonDetDescrUtils/src/BuildNSWReadoutGeometry.cxx @@ -0,0 +1,72 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +#include "MuonDetDescrUtils/BuildNSWReadoutGeometry.h" + +#include "MuonReadoutGeometry/MMReadoutElement.h" +#include "MuonReadoutGeometry/sTgcReadoutElement.h" + +#include "AGDDKernel/AGDDDetector.h" +#include "AGDDKernel/AGDDDetectorStore.h" + +#include <TString.h> // for Form +#include <fstream> + +using namespace MuonGM; + +BuildNSWReadoutGeometry::BuildNSWReadoutGeometry() +{} + +bool BuildNSWReadoutGeometry::BuildReadoutGeometry(MuonGM::MuonDetectorManager* mgr/*, std::map<GeoFullPhysVol*, std::string>* vec*/) const +{ + bool geoBuilt = true; + + detectorList& dList=AGDDDetectorStore::GetDetectorStore()->GetDetectorList(); + detectorList::const_iterator it; + for (it=dList.begin(); it!=dList.end(); ++it) { + + std::vector<AGDDDetectorPositioner*>& dPos=((*it).second)->GetDetectorPositioners(); + for (unsigned int i=0;i<dPos.size();i++) { + + std::string chTag = dPos[i]->ID.detectorAddress; + GeoFullPhysVol* vol = dPos[i]->theVolume; + + std::string stName = chTag.substr(0,4); + + int etaIndex = 999; + int phiIndex = 999; + int mLayer = 999; + int iSide = 0; + int iLS = atoi((chTag.substr(3,1)).c_str()); //sTG3 and sMD3 are small chambers for small sectors + if (iLS==3) iLS = 1; // small + else iLS = 0; // large + if (chTag.substr(13,1)=="A") iSide=1; + else if (chTag.substr(13,1)=="C") iSide=-1; + etaIndex = iSide*atoi((chTag.substr(5,1)).c_str()); + phiIndex = atoi((chTag.substr(12,1)).c_str()); + mLayer = atoi((chTag.substr(7,1)).c_str()); + + if (chTag.substr(0,3)=="sMD") { + + MMReadoutElement* re = new MMReadoutElement((GeoVFullPhysVol*)vol, stName, etaIndex, phiIndex, mLayer, false, mgr); + std::string myVolName = (chTag.substr(0,8)).c_str(); + re->initDesign(-999., -999., -999., -999., -999.); + re->fillCache(); + mgr->addMMReadoutElement_withIdFields(re, iLS, etaIndex, phiIndex, mLayer); + re->setDelta(mgr); + } + else if (chTag.substr(0,3)=="sTG") { + + sTgcReadoutElement* re = new sTgcReadoutElement((GeoVFullPhysVol*)vol, stName, etaIndex, phiIndex, mLayer, false, mgr); + std::string myVolName = (chTag.substr(0,8)).c_str(); + re->initDesign(-999., -999., -999., 3.2, -999., 2.7, -999., 2.6); + re->fillCache(); + mgr->addsTgcReadoutElement_withIdFields(re, iLS, etaIndex, phiIndex, mLayer); + re->setDelta(mgr); + } + } + } + return geoBuilt; + +} diff --git a/MuonSpectrometer/MuonGeoModel/src/MuonDetectorCondAlg.cxx b/MuonSpectrometer/MuonGeoModel/src/MuonDetectorCondAlg.cxx index 2ba1565873d0e82c5822f7f75b1ca238749c8b48..e250f0ccb68931ff04b0665fb79a8d648126678d 100755 --- a/MuonSpectrometer/MuonGeoModel/src/MuonDetectorCondAlg.cxx +++ b/MuonSpectrometer/MuonGeoModel/src/MuonDetectorCondAlg.cxx @@ -5,6 +5,7 @@ #include "MuonGeoModel/MuonDetectorCondAlg.h" #include "MuonGeoModel/MuonDetectorFactory001.h" #include "MuonGeoModel/MuonDetectorTool.h" +#include "MuonDetDescrUtils/BuildNSWReadoutGeometry.h" #include "AthenaPoolUtilities/CondAttrListCollection.h" @@ -83,6 +84,16 @@ StatusCode MuonDetectorCondAlg::execute() std::unique_ptr<MuonGM::MuonDetectorManager> MuonMgrData (theFactory.getDetectorManager()); + // ======================= + // Add NSW to the MuonDetectorManager by calling BuildReadoutGeometry from MuonAGDDToolHelper + // ======================= + if (MuonMgrData->mmIdHelper() && MuonMgrData->stgcIdHelper()) { + BuildNSWReadoutGeometry theBuilder = BuildNSWReadoutGeometry(); + if (!theBuilder.BuildReadoutGeometry(MuonMgrData.get())) { + ATH_MSG_FATAL("unable to add NSW ReadoutGeometry in the MuonDetectorManager in conditions store"); + } + } + // ======================= // Update CSC Internal Alignment if requested // ======================= @@ -148,4 +159,3 @@ StatusCode MuonDetectorCondAlg::finalize() ATH_MSG_DEBUG( "finalize " << name() ); return StatusCode::SUCCESS; } -