diff --git a/Database/AthenaPOOL/AthenaPoolUtilities/AthenaPoolUtilities/CondAttrListCollection.h b/Database/AthenaPOOL/AthenaPoolUtilities/AthenaPoolUtilities/CondAttrListCollection.h index 5558558793716912ab6e67602cfd0938cdf1e26e..35fb3bf3620dcc98a3ebc26651f1ce7b66fc6642 100644 --- a/Database/AthenaPOOL/AthenaPoolUtilities/AthenaPoolUtilities/CondAttrListCollection.h +++ b/Database/AthenaPOOL/AthenaPoolUtilities/AthenaPoolUtilities/CondAttrListCollection.h @@ -14,7 +14,7 @@ */ #ifndef DBDATAOBJECTS_CONDATTRLISTCOLLECTION_H -# define DBDATAOBJECTS_CONDATTRLISTCOLLECTION_H +#define DBDATAOBJECTS_CONDATTRLISTCOLLECTION_H //<<<<<< INCLUDES >>>>>> diff --git a/DetectorDescription/DetDescrCond/DetDescrConditions/DetDescrConditions/AlignableTransformContainer.h b/DetectorDescription/DetDescrCond/DetDescrConditions/DetDescrConditions/AlignableTransformContainer.h index 2a479f590bae0cc8994d817ea30850ac54ec811b..bbba585a6b01c17911734dc3c56712acaafa5a4f 100755 --- a/DetectorDescription/DetDescrCond/DetDescrConditions/DetDescrConditions/AlignableTransformContainer.h +++ b/DetectorDescription/DetDescrCond/DetDescrConditions/DetDescrConditions/AlignableTransformContainer.h @@ -10,11 +10,13 @@ // Richard Hawkings, 31/8/05 #include "AthenaKernel/CLASS_DEF.h" +#include "AthenaKernel/CondCont.h" #include "AthenaPoolUtilities/CondMultChanCollection.h" #include "DetDescrConditions/AlignableTransform.h" typedef CondMultChanCollection<AlignableTransform> AlignableTransformContainer; CLASS_DEF( AlignableTransformContainer , 1170039409 , 1 ) +CONDCONT_DEF( AlignableTransformContainer , 1141302089 ); #endif // DETDESCRCOND_ALIGNTRKCONTAINER_H diff --git a/InnerDetector/InDetConditions/InDetCondFolders/python/InDetAlignFolders.py b/InnerDetector/InDetConditions/InDetCondFolders/python/InDetAlignFolders.py index 31a88aa02c8cece2a27de87f1cb3a70fa920efba..248f630518b4f802928df25db4f90d97bc4a6372 100644 --- a/InnerDetector/InDetConditions/InDetCondFolders/python/InDetAlignFolders.py +++ b/InnerDetector/InDetConditions/InDetCondFolders/python/InDetAlignFolders.py @@ -42,13 +42,30 @@ try: except ImportError: pass if useDynamicAlignFolders: - conddb.addFolderSplitOnline("INDET","/Indet/Onl/AlignL1/ID","/Indet/AlignL1/ID") + conddb.addFolderSplitOnline("INDET","/Indet/Onl/AlignL1/ID","/Indet/AlignL1/ID",className="CondAttrListCollection") conddb.addFolderSplitOnline("INDET","/Indet/Onl/AlignL2/PIX","/Indet/AlignL2/PIX") - conddb.addFolderSplitOnline("INDET","/Indet/Onl/AlignL2/SCT","/Indet/AlignL2/SCT") - conddb.addFolderSplitOnline("INDET","/Indet/Onl/AlignL3","/Indet/AlignL3") + conddb.addFolderSplitOnline("INDET","/Indet/Onl/AlignL2/SCT","/Indet/AlignL2/SCT",className="CondAttrListCollection") + conddb.addFolderSplitOnline("INDET","/Indet/Onl/AlignL3","/Indet/AlignL3",className="AlignableTransformContainer") conddb.addFolderSplitOnline("TRT","/TRT/Onl/AlignL1/TRT","/TRT/AlignL1/TRT") conddb.addFolderSplitOnline("TRT","/TRT/Onl/AlignL2","/TRT/AlignL2") else: - conddb.addFolderSplitOnline("INDET","/Indet/Onl/Align","/Indet/Align") + if DetFlags.simulate.any_on(): + # Simulation does not use condition algorithms for alignment + conddb.addFolderSplitOnline("INDET","/Indet/Onl/Align","/Indet/Align") + else: + conddb.addFolderSplitOnline("INDET","/Indet/Onl/Align","/Indet/Align",className="AlignableTransformContainer") conddb.addFolderSplitOnline("TRT","/TRT/Onl/Align","/TRT/Align") + +# Condition algorithms for ID alignment only for non-simulation jobs +if not DetFlags.simulate.any_on(): + from AthenaCommon.AlgSequence import AthSequencer + condSeq = AthSequencer("AthCondSeq") + if not hasattr(condSeq, "SCT_AlignCondAlg"): + from SCT_ConditionsAlgorithms.SCT_ConditionsAlgorithmsConf import SCT_AlignCondAlg + condSeq += SCT_AlignCondAlg(name = "SCT_AlignCondAlg", + UseDynamicAlignFolders = useDynamicAlignFolders) + if not hasattr(condSeq, "SCT_DetectorElementCondAlg"): + from SCT_ConditionsAlgorithms.SCT_ConditionsAlgorithmsConf import SCT_DetectorElementCondAlg + condSeq += SCT_DetectorElementCondAlg(name = "SCT_DetectorElementCondAlg") + del useDynamicAlignFolders #tidy up diff --git a/InnerDetector/InDetConditions/SCT_ConditionsAlgorithms/CMakeLists.txt b/InnerDetector/InDetConditions/SCT_ConditionsAlgorithms/CMakeLists.txt index 369c884186f1c82d0ea7fa1b7bc8411c2078fa39..5b54b12a75c895c8b6e2ee76ff7b70acf5c8109a 100644 --- a/InnerDetector/InDetConditions/SCT_ConditionsAlgorithms/CMakeLists.txt +++ b/InnerDetector/InDetConditions/SCT_ConditionsAlgorithms/CMakeLists.txt @@ -12,6 +12,8 @@ atlas_depends_on_subdirs( PUBLIC Control/StoreGate Database/AthenaPOOL/AthenaPoolUtilities DetectorDescription/Identifier + DetectorDescription/DetDescrCond/DetDescrConditions + DetectorDescription/GeoModel/GeoModelUtilities GaudiKernel InnerDetector/InDetConditions/InDetConditionsSummaryService InnerDetector/InDetConditions/SCT_ConditionsData @@ -31,6 +33,6 @@ atlas_add_component( SCT_ConditionsAlgorithms src/*.cxx src/components/*.cxx INCLUDE_DIRS ${Boost_INCLUDE_DIRS} - LINK_LIBRARIES ${Boost_LIBRARIES} AthenaBaseComps AthenaKernel StoreGateLib SGtests Identifier GaudiKernel SCT_ConditionsData SCT_CablingLib EventInfo xAODEventInfo AthenaPoolUtilities InDetIdentifier InDetReadoutGeometry SCT_ConditionsToolsLib ) + LINK_LIBRARIES ${Boost_LIBRARIES} AthenaBaseComps AthenaKernel StoreGateLib SGtests Identifier DetDescrConditions GeoModelUtilities GaudiKernel SCT_ConditionsData SCT_CablingLib EventInfo xAODEventInfo AthenaPoolUtilities InDetIdentifier InDetReadoutGeometry SCT_ConditionsToolsLib ) # Install files from the package: diff --git a/InnerDetector/InDetConditions/SCT_ConditionsAlgorithms/src/SCT_AlignCondAlg.cxx b/InnerDetector/InDetConditions/SCT_ConditionsAlgorithms/src/SCT_AlignCondAlg.cxx new file mode 100644 index 0000000000000000000000000000000000000000..4e8c88ae74fac7b01db85da120ad87617d40195e --- /dev/null +++ b/InnerDetector/InDetConditions/SCT_ConditionsAlgorithms/src/SCT_AlignCondAlg.cxx @@ -0,0 +1,164 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +*/ + +#include "SCT_AlignCondAlg.h" + +#include <memory> + +#include "InDetReadoutGeometry/SCT_DetectorManager.h" +#include "InDetReadoutGeometry/SiDetectorElement.h" + +SCT_AlignCondAlg::SCT_AlignCondAlg(const std::string& name, ISvcLocator* pSvcLocator) + : ::AthAlgorithm(name, pSvcLocator) + , m_writeKey{"SCTAlignmentStore", "SCTAlignmentStore"} + , m_condSvc{"CondSvc", name} + , m_detManager{nullptr} +{ + declareProperty("WriteKey", m_writeKey); +} + +StatusCode SCT_AlignCondAlg::initialize() +{ + ATH_MSG_DEBUG("initialize " << name()); + + // CondSvc + ATH_CHECK(m_condSvc.retrieve()); + + // Read Handles + if (not m_useDynamicAlignFolders) { // Static + ATH_CHECK(m_readKeyStatic.initialize()); + } else { // Dynamic + ATH_CHECK(m_readKeyDynamicL1.initialize()); + ATH_CHECK(m_readKeyDynamicL2.initialize()); + ATH_CHECK(m_readKeyDynamicL3.initialize()); + } + // Write Handles + ATH_CHECK(m_writeKey.initialize()); + + // Register write handle + ATH_CHECK(m_condSvc->regHandle(this, m_writeKey)); + + ATH_CHECK(detStore()->retrieve(m_detManager, "SCT")); + + return StatusCode::SUCCESS; +} + +StatusCode SCT_AlignCondAlg::execute() +{ + ATH_MSG_DEBUG("execute " << name()); + + // ____________ Construct Write Cond Handle and check its validity ____________ + SG::WriteCondHandle<GeoAlignmentStore> writeHandle{m_writeKey}; + + // Do we have a valid Write Cond Handle for current time? + if (writeHandle.isValid()) { + ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid." + << ". In theory this should not be called, but may happen" + << " if multiple concurrent events are being processed out of order."); + return StatusCode::SUCCESS; + } + + // Get SiDetectorElements + const InDetDD::SiDetectorElementCollection* oldColl{m_detManager->getDetectorElementCollection()}; + if (oldColl==nullptr) { + ATH_MSG_ERROR("Null pointer is returned by getDetectorElementCollection()"); + return StatusCode::FAILURE; + } + + // ____________ Construct new Write Cond Object ____________ + std::unique_ptr<GeoAlignmentStore> writeCdo{std::make_unique<GeoAlignmentStore>()}; + EventIDRange rangeW; + + if (not m_useDynamicAlignFolders) { // Static + // ____________ Get Read Cond Object ____________ + SG::ReadCondHandle<AlignableTransformContainer> readHandleStatic{m_readKeyStatic}; + const AlignableTransformContainer* readCdoStatic{*readHandleStatic}; + if (readCdoStatic==nullptr) { + ATH_MSG_ERROR("Null pointer to the read conditions object of " << m_readKeyStatic.key()); + return StatusCode::FAILURE; + } + // ____________ Apply alignments to SCT GeoModel ____________ + // Construct Container for read CDO. + InDetDD::RawAlignmentObjects readCdoContainerStatic; + readCdoContainerStatic.emplace(m_readKeyStatic.key(), readCdoStatic); + ATH_CHECK(m_detManager->align(readCdoContainerStatic, writeCdo.get())); + + // Define validity of the output cond object and record it + if (not readHandleStatic.range(rangeW)) { + ATH_MSG_ERROR("Failed to retrieve validity range for " << readHandleStatic.key()); + return StatusCode::FAILURE; + } + } else { // Dynamic + // ____________ Get Read Cond Object ____________ + SG::ReadCondHandle<CondAttrListCollection> readHandleDynamicL1{m_readKeyDynamicL1}; + const CondAttrListCollection* readCdoDynamicL1{*readHandleDynamicL1}; + if (readCdoDynamicL1==nullptr) { + ATH_MSG_ERROR("Null pointer to the read conditions object of " << m_readKeyDynamicL1.key()); + return StatusCode::FAILURE; + } + SG::ReadCondHandle<CondAttrListCollection> readHandleDynamicL2{m_readKeyDynamicL2}; + const CondAttrListCollection* readCdoDynamicL2{*readHandleDynamicL2}; + if (readCdoDynamicL2==nullptr) { + ATH_MSG_ERROR("Null pointer to the read conditions object of " << readHandleDynamicL2.key()); + return StatusCode::FAILURE; + } + SG::ReadCondHandle<AlignableTransformContainer> readHandleDynamicL3{m_readKeyDynamicL3}; + const AlignableTransformContainer* readCdoDynamicL3{*readHandleDynamicL3}; + if (readCdoDynamicL3==nullptr) { + ATH_MSG_ERROR("Null pointer to the read conditions object of " << readHandleDynamicL3.key()); + return StatusCode::FAILURE; + } + // ____________ Apply alignments to SCT GeoModel ____________ + // Construct Container for read CDO-s. + InDetDD::RawAlignmentObjects readCdoContainerDynamicL1; + readCdoContainerDynamicL1.emplace(m_readKeyDynamicL1.key(), readCdoDynamicL1); + ATH_CHECK(m_detManager->align(readCdoContainerDynamicL1, writeCdo.get())); + InDetDD::RawAlignmentObjects readCdoContainerDynamicL2; + readCdoContainerDynamicL2.emplace(m_readKeyDynamicL2.key(), readCdoDynamicL2); + ATH_CHECK(m_detManager->align(readCdoContainerDynamicL2, writeCdo.get())); + InDetDD::RawAlignmentObjects readCdoContainerDynamicL3; + readCdoContainerDynamicL3.emplace(m_readKeyDynamicL3.key(), readCdoDynamicL3); + ATH_CHECK(m_detManager->align(readCdoContainerDynamicL3, writeCdo.get())); + + // Define validity of the output cond object and record it + EventIDRange rangeWL1; + if (not readHandleDynamicL1.range(rangeWL1)) { + ATH_MSG_ERROR("Failed to retrieve validity range for " << readHandleDynamicL1.key()); + return StatusCode::FAILURE; + } + EventIDRange rangeWL2; + if (not readHandleDynamicL2.range(rangeWL2)) { + ATH_MSG_ERROR("Failed to retrieve validity range for " << readHandleDynamicL2.key()); + return StatusCode::FAILURE; + } + EventIDRange rangeWL3; + if (not readHandleDynamicL3.range(rangeWL3)) { + ATH_MSG_ERROR("Failed to retrieve validity range for " << readHandleDynamicL3.key()); + return StatusCode::FAILURE; + } + rangeW = EventIDRange::intersect(rangeWL1, rangeWL2, rangeWL3); + } + + // Set (default) absolute transforms in alignment store by calling them. + for (const InDetDD::SiDetectorElement* oldEl: *oldColl) { + oldEl->getMaterialGeom()->getAbsoluteTransform(writeCdo.get()); + oldEl->getMaterialGeom()->getDefAbsoluteTransform(writeCdo.get()); + } + + if (writeHandle.record(rangeW, std::move(writeCdo)).isFailure()) { + ATH_MSG_ERROR("Could not record GeoAlignmentStore " << writeHandle.key() + << " with EventRange " << rangeW + << " into Conditions Store"); + return StatusCode::FAILURE; + } + ATH_MSG_INFO("recorded new CDO " << writeHandle.key() << " with range " << rangeW << " into Conditions Store"); + + return StatusCode::SUCCESS; +} + +StatusCode SCT_AlignCondAlg::finalize() +{ + ATH_MSG_DEBUG("finalize " << name()); + return StatusCode::SUCCESS; +} diff --git a/InnerDetector/InDetConditions/SCT_ConditionsAlgorithms/src/SCT_AlignCondAlg.h b/InnerDetector/InDetConditions/SCT_ConditionsAlgorithms/src/SCT_AlignCondAlg.h new file mode 100644 index 0000000000000000000000000000000000000000..f222a292abbd96e920e222228507f87cc4162132 --- /dev/null +++ b/InnerDetector/InDetConditions/SCT_ConditionsAlgorithms/src/SCT_AlignCondAlg.h @@ -0,0 +1,44 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef SCT_CONDITIONSALGORITHMS_SCT_ALIGNCONDALG_H +#define SCT_CONDITIONSALGORITHMS_SCT_ALIGNCONDALG_H + +#include "AthenaBaseComps/AthAlgorithm.h" +#include "StoreGate/ReadCondHandleKey.h" +#include "StoreGate/WriteCondHandleKey.h" + +#include "GaudiKernel/ICondSvc.h" + +#include "DetDescrConditions/AlignableTransformContainer.h" +#include "AthenaPoolUtilities/CondAttrListCollection.h" +#include "GeoModelUtilities/GeoAlignmentStore.h" + +namespace InDetDD { + class SCT_DetectorManager; +} + +class SCT_AlignCondAlg : public AthAlgorithm +{ + public: + SCT_AlignCondAlg(const std::string& name, ISvcLocator* pSvcLocator); + virtual ~SCT_AlignCondAlg() override = default; + + virtual StatusCode initialize() override; + virtual StatusCode execute() override; + virtual StatusCode finalize() override; + + private: + BooleanProperty m_useDynamicAlignFolders{this, "UseDynamicAlignFolders", false, "Flag of dynamic or static ID alignment folders"}; + SG::ReadCondHandleKey<AlignableTransformContainer> m_readKeyStatic{this, "ReadKeyStatic", "/Indet/Align", "Key for the static alignment folder"}; + SG::ReadCondHandleKey<CondAttrListCollection> m_readKeyDynamicL1{this, "ReadKeyDynamicL1", "/Indet/AlignL1/ID", "Key for the dynamic L1 alignment folder"}; + SG::ReadCondHandleKey<CondAttrListCollection> m_readKeyDynamicL2{this, "ReadKeyDynamicL2", "/Indet/AlignL2/SCT", "Key for the dynamic L2 alignment folder"}; + SG::ReadCondHandleKey<AlignableTransformContainer> m_readKeyDynamicL3{this, "ReadKeyDynamicL3", "/Indet/AlignL3", "Key for the dynamic L3 alignment folder"}; + SG::WriteCondHandleKey<GeoAlignmentStore> m_writeKey; + + ServiceHandle<ICondSvc> m_condSvc; + const InDetDD::SCT_DetectorManager* m_detManager; +}; + +#endif // SCT_CONDITIONSALGORITHMS_SCT_ALIGNCONDALG_H diff --git a/InnerDetector/InDetConditions/SCT_ConditionsAlgorithms/src/SCT_DetectorElementCondAlg.cxx b/InnerDetector/InDetConditions/SCT_ConditionsAlgorithms/src/SCT_DetectorElementCondAlg.cxx new file mode 100644 index 0000000000000000000000000000000000000000..7d57a8a915b2367ab0ae8277311292ddf5b6ca31 --- /dev/null +++ b/InnerDetector/InDetConditions/SCT_ConditionsAlgorithms/src/SCT_DetectorElementCondAlg.cxx @@ -0,0 +1,144 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +*/ + +#include "SCT_DetectorElementCondAlg.h" + +#include <memory> +#include <map> + +#include "InDetReadoutGeometry/SCT_DetectorManager.h" +#include "InDetReadoutGeometry/SiCommonItems.h" +#include "InDetReadoutGeometry/SiDetectorElement.h" + +SCT_DetectorElementCondAlg::SCT_DetectorElementCondAlg(const std::string& name, ISvcLocator* pSvcLocator) + : ::AthAlgorithm(name, pSvcLocator) + , m_readKey{"SCTAlignmentStore", "SCTAlignmentStore"} + , m_condSvc{"CondSvc", name} + , m_detManager{nullptr} + , m_commonItems{nullptr} +{ + declareProperty("ReadKey", m_readKey); +} + +StatusCode SCT_DetectorElementCondAlg::initialize() +{ + ATH_MSG_DEBUG("initialize " << name()); + + // Read Handle + ATH_CHECK(m_readKey.initialize()); + + // Write Handle + ATH_CHECK(m_writeKey.initialize()); + // CondSvc + ATH_CHECK(m_condSvc.retrieve()); + // Register write handle + ATH_CHECK(m_condSvc->regHandle(this, m_writeKey)); + + ATH_CHECK(detStore()->retrieve(m_detManager, "SCT")); + + return StatusCode::SUCCESS; +} + +StatusCode SCT_DetectorElementCondAlg::execute() +{ + ATH_MSG_DEBUG("execute " << name()); + + // ____________ Construct Write Cond Handle and check its validity ____________ + SG::WriteCondHandle<InDetDD::SiDetectorElementCollection> writeHandle{m_writeKey}; + + // Do we have a valid Write Cond Handle for current time? + if (writeHandle.isValid()) { + ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid." + << ". In theory this should not be called, but may happen" + << " if multiple concurrent events are being processed out of order."); + return StatusCode::SUCCESS; + } + + const InDetDD::SiDetectorElementCollection* oldColl{m_detManager->getDetectorElementCollection()}; + if (oldColl==nullptr) { + ATH_MSG_ERROR("Null pointer is returned by getDetectorElementCollection()"); + return StatusCode::FAILURE; + } + + // ____________ Construct new Write Cond Object ____________ + std::unique_ptr<InDetDD::SiDetectorElementCollection> writeCdo{std::make_unique<InDetDD::SiDetectorElementCollection>()}; + EventIDRange rangeW; + + // ____________ Get Read Cond Object ____________ + SG::ReadCondHandle<GeoAlignmentStore> readHandle{m_readKey}; + const GeoAlignmentStore* readCdo{*readHandle}; + if (readCdo==nullptr) { + ATH_MSG_ERROR("Null pointer to the read conditions object of " << m_readKey.key()); + return StatusCode::FAILURE; + } + + // Define validity of the output cond object and record it + if (not readHandle.range(rangeW)) { + ATH_MSG_ERROR("Failed to retrieve validity range for " << readHandle.key()); + return StatusCode::FAILURE; + } + + // ____________ Update writeCdo using readCdo ____________ + std::map<const InDetDD::SiDetectorElement*, const InDetDD::SiDetectorElement*> oldToNewMap; + oldToNewMap[nullptr] = nullptr; + writeCdo->resize(oldColl->size(), nullptr); + InDetDD::SiDetectorElementCollection::iterator newEl{writeCdo->begin()}; + for (const InDetDD::SiDetectorElement* oldEl: *oldColl) { + // At the first time access, SiCommonItems are prepared using the first old element + if (m_commonItems==nullptr) { + const InDetDD::SiCommonItems* oldCommonItems{oldEl->getCommonItems()}; + m_commonItems = new InDetDD::SiCommonItems(oldCommonItems->getIdHelper()); + m_commonItems->setSolenoidFrame(oldCommonItems->solenoidFrame()); + // SiLorentzAngleSvc is not set. + } + + *newEl = new InDetDD::SiDetectorElement(oldEl->identify(), + &(oldEl->design()), + oldEl->GeoVDetectorElement::getMaterialGeom(), + m_commonItems, + readCdo); + oldToNewMap[oldEl] = *newEl; + newEl++; + } + + // Set neighbours and other side + InDetDD::SiDetectorElementCollection::const_iterator oldIt{oldColl->begin()}; + for (InDetDD::SiDetectorElement* newEl: *writeCdo) { + if (oldToNewMap[(*oldIt)]!=newEl) { + ATH_MSG_ERROR("Old and new elements are not synchronized!"); + } + newEl->setNextInEta(oldToNewMap[(*oldIt)->nextInEta()]); + newEl->setPrevInEta(oldToNewMap[(*oldIt)->prevInEta()]); + newEl->setNextInPhi(oldToNewMap[(*oldIt)->nextInPhi()]); + newEl->setPrevInPhi(oldToNewMap[(*oldIt)->prevInPhi()]); + newEl->setOtherSide(oldToNewMap[(*oldIt)->otherSide()]); + oldIt++; + } + + // Apply alignment using readCdo passed to SiDetectorElement + for (InDetDD::SiDetectorElement* newEl: *writeCdo) { + newEl->updateCache(); + } + + // Record WriteCondHandle + const std::size_t size{writeCdo->size()}; + if (writeHandle.record(rangeW, std::move(writeCdo)).isFailure()) { + ATH_MSG_ERROR("Could not record " << writeHandle.key() + << " with EventRange " << rangeW + << " into Conditions Store"); + return StatusCode::FAILURE; + } + ATH_MSG_INFO("recorded new CDO " << writeHandle.key() << " with range " << rangeW << " with size of " << size << " into Conditions Store"); + + return StatusCode::SUCCESS; +} + +StatusCode SCT_DetectorElementCondAlg::finalize() +{ + ATH_MSG_DEBUG("finalize " << name()); + + delete m_commonItems; + + return StatusCode::SUCCESS; +} diff --git a/InnerDetector/InDetConditions/SCT_ConditionsAlgorithms/src/SCT_DetectorElementCondAlg.h b/InnerDetector/InDetConditions/SCT_ConditionsAlgorithms/src/SCT_DetectorElementCondAlg.h new file mode 100644 index 0000000000000000000000000000000000000000..32dae576a0b9fc51e630a876afd4772d1527acf9 --- /dev/null +++ b/InnerDetector/InDetConditions/SCT_ConditionsAlgorithms/src/SCT_DetectorElementCondAlg.h @@ -0,0 +1,41 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef SCT_CONDITIONSALGORITHMS_SCT_DETECTORELEMENTCONDALG_H +#define SCT_CONDITIONSALGORITHMS_SCT_DETECTORELEMENTCONDALG_H + +#include "AthenaBaseComps/AthAlgorithm.h" +#include "StoreGate/ReadCondHandleKey.h" +#include "StoreGate/WriteCondHandleKey.h" + +#include "GaudiKernel/ICondSvc.h" + +#include "GeoModelUtilities/GeoAlignmentStore.h" +#include "InDetReadoutGeometry/SiDetectorElementCollection.h" + +namespace InDetDD { + class SCT_DetectorManager; + class SiCommonItems; +} + +class SCT_DetectorElementCondAlg : public AthAlgorithm +{ + public: + SCT_DetectorElementCondAlg(const std::string& name, ISvcLocator* pSvcLocator); + virtual ~SCT_DetectorElementCondAlg() override = default; + + virtual StatusCode initialize() override; + virtual StatusCode execute() override; + virtual StatusCode finalize() override; + + private: + SG::ReadCondHandleKey<GeoAlignmentStore> m_readKey; + SG::WriteCondHandleKey<InDetDD::SiDetectorElementCollection> m_writeKey{this, "WriteKey", "SCT_DetectorElementCollection", "Key of output SiDetectorElementCollection for SCT"}; + + ServiceHandle<ICondSvc> m_condSvc; + const InDetDD::SCT_DetectorManager* m_detManager; + InDetDD::SiCommonItems* m_commonItems; +}; + +#endif // SCT_CONDITIONSALGORITHMS_SCT_DETECTORELEMENTCONDALG_H diff --git a/InnerDetector/InDetConditions/SCT_ConditionsAlgorithms/src/components/SCT_ConditionsAlgorithms_entries.cxx b/InnerDetector/InDetConditions/SCT_ConditionsAlgorithms/src/components/SCT_ConditionsAlgorithms_entries.cxx index 5568eb77490afbe015cb1be8776830898d1f1c1b..842b5421258342bfb78ce7ff2c62d075d17dadd2 100644 --- a/InnerDetector/InDetConditions/SCT_ConditionsAlgorithms/src/components/SCT_ConditionsAlgorithms_entries.cxx +++ b/InnerDetector/InDetConditions/SCT_ConditionsAlgorithms/src/components/SCT_ConditionsAlgorithms_entries.cxx @@ -1,3 +1,4 @@ +#include "../SCT_AlignCondAlg.h" #include "../SCT_ConditionsParameterCondAlg.h" #include "../SCT_ConditionsParameterTestAlg.h" #include "../SCT_ConditionsSummaryTestAlg.h" @@ -7,6 +8,7 @@ #include "../SCT_DCSConditionsStatCondAlg.h" #include "../SCT_DCSConditionsTempCondAlg.h" #include "../SCT_DCSConditionsTestAlg.h" +#include "../SCT_DetectorElementCondAlg.h" #include "../SCT_LinkMaskingCondAlg.h" #include "../SCT_LinkMaskingTestAlg.h" #include "../SCT_MajorityCondAlg.h" @@ -32,6 +34,7 @@ #include "../SCT_TdaqEnabledCondAlg.h" #include "../SCT_TdaqEnabledTestAlg.h" +DECLARE_COMPONENT( SCT_AlignCondAlg ) DECLARE_COMPONENT( SCT_ConditionsParameterCondAlg ) DECLARE_COMPONENT( SCT_ConditionsParameterTestAlg ) DECLARE_COMPONENT( SCT_ConditionsSummaryTestAlg ) @@ -41,6 +44,7 @@ DECLARE_COMPONENT( SCT_DCSConditionsHVCondAlg ) DECLARE_COMPONENT( SCT_DCSConditionsStatCondAlg ) DECLARE_COMPONENT( SCT_DCSConditionsTempCondAlg ) DECLARE_COMPONENT( SCT_DCSConditionsTestAlg ) +DECLARE_COMPONENT( SCT_DetectorElementCondAlg ) DECLARE_COMPONENT( SCT_LinkMaskingCondAlg ) DECLARE_COMPONENT( SCT_LinkMaskingTestAlg ) DECLARE_COMPONENT( SCT_MajorityCondAlg ) diff --git a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/CMakeLists.txt b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/CMakeLists.txt index 2c1c703a70607382e3eb36a8bdb18664f39436b6..96c7467661441dcc8457bba688d32697eb6919b9 100644 --- a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/CMakeLists.txt +++ b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/CMakeLists.txt @@ -14,6 +14,7 @@ atlas_depends_on_subdirs( PUBLIC Control/StoreGate DetectorDescription/AtlasDetDescr DetectorDescription/GeoModel/GeoModelKernel + DetectorDescription/GeoModel/GeoModelUtilities DetectorDescription/GeoPrimitives DetectorDescription/Identifier GaudiKernel @@ -38,6 +39,6 @@ atlas_add_library( InDetReadoutGeometry PUBLIC_HEADERS InDetReadoutGeometry INCLUDE_DIRS ${CLHEP_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIRS} DEFINITIONS ${CLHEP_DEFINITIONS} - LINK_LIBRARIES ${CLHEP_LIBRARIES} ${EIGEN_LIBRARIES} AthenaKernel SGTools AtlasDetDescr GeoModelKernel GeoPrimitives Identifier GaudiKernel InDetCondServices InDetIdentifier TrkDetElementBase TrkSurfaces TrkEventPrimitives StoreGateLib SGtests AthenaBaseComps - PRIVATE_LINK_LIBRARIES AthenaPoolUtilities DetDescrConditions IdDictDetDescr TRT_ConditionsData ) + LINK_LIBRARIES ${CLHEP_LIBRARIES} ${EIGEN_LIBRARIES} AthenaKernel SGTools AtlasDetDescr GeoModelKernel GeoModelUtilities GeoPrimitives Identifier GaudiKernel InDetCondServices InDetIdentifier TrkDetElementBase TrkSurfaces TrkEventPrimitives StoreGateLib SGtests AthenaBaseComps DetDescrConditions + PRIVATE_LINK_LIBRARIES AthenaPoolUtilities IdDictDetDescr TRT_ConditionsData ) diff --git a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/InDetDetectorManager.h b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/InDetDetectorManager.h index 397ddb21c8105236b6e2a14ad7848c1bf51a7370..f78d94baa0d455936d47161fd77409228fecc842 100755 --- a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/InDetDetectorManager.h +++ b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/InDetDetectorManager.h @@ -24,17 +24,24 @@ // IOV SVC for alignment: #include "AthenaKernel/IIOVSvc.h" +#include "DetDescrConditions/AlignableTransformContainer.h" + class StoreGateSvc; class AlignableTransform; class Identifier; class AtlasDetectorID; +class GeoVAlignmentStore; +class CondAttrListCollection; #include <string> #include <map> #include <set> +#include <list> namespace InDetDD { + typedef std::map<std::string, const void*> RawAlignmentObjects; + /** @class InDetDetectorManager Virtual base class for all ID detector managers. @@ -72,7 +79,10 @@ namespace InDetDD { void addSpecialFolder(const std::string & key); void addGlobalFolder(const std::string & key); void addAlignFolderType(const AlignFolderType alignfolder); + StatusCode align( IOVSVC_CALLBACK_ARGS ) const; + + StatusCode align(const RawAlignmentObjects& alignObjects, GeoVAlignmentStore* alignStore) const; /** Invalidate cache for all detector elements */ virtual void invalidateAll() const = 0; @@ -85,11 +95,11 @@ namespace InDetDD { /** Declaring the Message method for further use */ MsgStream& msg (MSG::Level lvl) const { return m_msg.get() << lvl; } - + /** Declaring the Method providing Verbosity Level */ bool msgLvl (MSG::Level lvl) const { return m_msg.get().level() <= lvl; } - AlignFolderType m_alignfoldertype; + AlignFolderType m_alignfoldertype; protected: StoreGateSvc * m_detStore; @@ -119,13 +129,13 @@ namespace InDetDD { class AlignInfo { private: - AlignFolderType m_aligntype; + AlignFolderType m_aligntype; public: AlignInfo(): m_aligntype(InDetDD::none) {}; AlignInfo(AlignFolderType alignfolder): m_aligntype(alignfolder) {}; - AlignFolderType AlignFolder() const {return m_aligntype;} - bool isValidAlign() const {return (m_aligntype != InDetDD::none);} + AlignFolderType AlignFolder() const {return m_aligntype;} + bool isValidAlign() const {return (m_aligntype != InDetDD::none);} }; @@ -138,24 +148,31 @@ namespace InDetDD { /** Process the alignment container, calls processKey */ bool processAlignmentContainer(const std::string & key) const; - + bool processAlignmentContainer(const AlignableTransformContainer* container, GeoVAlignmentStore* alignStore) const; + /** Called by processAlignmentContainer, applies only one key on the transform Collections */ bool processKey(const std::string key, - const AlignableTransform* transformCollection) const; + const AlignableTransform* transformCollection, + GeoVAlignmentStore* alignStore=nullptr) const; /** Set method applying the delta transform (in global or local frame) onto the geoModel transform : CLHEP <--> Amg interface */ virtual bool setAlignableTransformDelta(int level, - const Identifier & id, - const Amg::Transform3D & delta, - FrameType frame) const = 0; + const Identifier & id, + const Amg::Transform3D & delta, + FrameType frame, + GeoVAlignmentStore* alignStore=nullptr) const = 0; virtual bool processSpecialAlignment(const std::string & key, InDetDD::AlignFolderType alignfolder) const; - bool processGlobalAlignmentContainer(const std::string & key) const; + bool processGlobalAlignmentContainer(const std::string & key, + const CondAttrListCollection* obj=nullptr, + GeoVAlignmentStore* alignStore=nullptr) const; - virtual bool processGlobalAlignment(const std::string & key, int level, FrameType frame) const; + virtual bool processGlobalAlignment(const std::string & key, int level, FrameType frame, + const CondAttrListCollection* obj=nullptr, + GeoVAlignmentStore* alignStore=nullptr) const; virtual const AtlasDetectorID* getIdHelper() const = 0; diff --git a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/PixelDetectorManager.h b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/PixelDetectorManager.h index c16bc3cc391d25a860c97c2288226a9678af2269..655bf65c5520a103d767bf7b56c1b5969df3a134 100755 --- a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/PixelDetectorManager.h +++ b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/PixelDetectorManager.h @@ -27,6 +27,8 @@ class IdentifierHash; class GeoAlignableTransform; class GeoVFullPhysVol; class GeoVPhysVol; +class GeoVAlignmentStore; +class CondAttrListCollection; namespace InDetDD { @@ -74,7 +76,18 @@ namespace InDetDD { int layer_wheel, int phi_module, int eta_module) const; - + + /** access to individual elements using Identifier using SiDetectorElementCollection */ + virtual const SiDetectorElement* getDetectorElement(const Identifier &id, const SiDetectorElementCollection* coll) const; + /** access to individual elements using IdentiferHash using SiDetectorElementCollection */ + virtual const SiDetectorElement* getDetectorElement(const IdentifierHash &idHash, const SiDetectorElementCollection* coll) const; + /** access to individual elements : via element identification using SiDetectorElementCollection */ + const SiDetectorElement* getDetectorElement(int barrel_endcap, + int layer_wheel, + int phi_module, + int eta_module, + const SiDetectorElementCollection* coll) const; + /** access to whole collection via Iterators */ virtual const SiDetectorElementCollection * getDetectorElementCollection() const; virtual SiDetectorElementCollection::const_iterator getDetectorElementBegin() const; @@ -128,7 +141,9 @@ namespace InDetDD { bool processSpecialAlignment(const std::string &, InDetDD::AlignFolderType) const; /** Process new global DB folders for L1 and L2 **/ - bool processGlobalAlignment(const std::string &, int level, FrameType frame) const; + bool processGlobalAlignment(const std::string &, int level, FrameType frame, + const CondAttrListCollection* obj, + GeoVAlignmentStore* alignStore) const; private: @@ -136,9 +151,10 @@ namespace InDetDD { it translates into the LocalDelta or GlobalDelta function of SiDetectorManager */ virtual bool setAlignableTransformDelta(int level, - const Identifier & id, - const Amg::Transform3D & delta, - FrameType frame) const; + const Identifier & id, + const Amg::Transform3D & delta, + FrameType frame, + GeoVAlignmentStore* alignStore) const; /** prevent copy and assignment */ diff --git a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/SCT_DetectorManager.h b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/SCT_DetectorManager.h index cc3aaa508860b7739cba633b724e3c4df68704f1..d1b678c967f6a82260311ea85141b8fa3c0e211d 100755 --- a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/SCT_DetectorManager.h +++ b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/SCT_DetectorManager.h @@ -27,6 +27,8 @@ class IdentifierHash; class GeoAlignableTransform; class GeoVFullPhysVol; class GeoVPhysVol; +class GeoVAlignmentStore; +class CondAttrListCollection; namespace InDetDD { @@ -73,6 +75,16 @@ namespace InDetDD { /** access to individual elements via module numbering schema */ SiDetectorElement * getDetectorElement(int barrel_endcap, int layer_wheel, int phi_module, int eta_module, int side) const; + /** access to individual elements using Identifier using SiDetectorElementCollection */ + virtual const SiDetectorElement* getDetectorElement(const Identifier &id, const SiDetectorElementCollection* coll) const; + + /** access to individual elements using IdentiferHash using SiDetectorElementCollection */ + virtual const SiDetectorElement* getDetectorElement(const IdentifierHash &idHash, const SiDetectorElementCollection* coll) const; + + /** access to individual elements via module numbering schema using IdentiferHash using SiDetectorElementCollection */ + const SiDetectorElement* getDetectorElement(int barrel_endcap, int layer_wheel, int phi_module, int eta_module, int side, + const SiDetectorElementCollection* coll) const; + /** access to whole collectiom via iterators */ virtual const SiDetectorElementCollection * getDetectorElementCollection() const; virtual SiDetectorElementCollection::const_iterator getDetectorElementBegin() const; @@ -109,16 +121,19 @@ namespace InDetDD { const SCT_ModuleSideDesign * getSCT_Design(int i) const; /** Process new global DB folders for L1 and L2 **/ - bool processGlobalAlignment(const std::string &, int level, FrameType frame) const; + bool processGlobalAlignment(const std::string &, int level, FrameType frame, + const CondAttrListCollection* obj, + GeoVAlignmentStore* alignStore) const; private: /** implements the main alignment update for delta transforms in different frames, it translates into the LocalDelta or GlobalDelta function of SiDetectorManager */ virtual bool setAlignableTransformDelta(int level, - const Identifier & id, - const Amg::Transform3D & delta, - FrameType frame) const; + const Identifier & id, + const Amg::Transform3D & delta, + FrameType frame, + GeoVAlignmentStore* alignStore) const; /** Prevent copy and assignment */ const SCT_DetectorManager & operator=(const SCT_DetectorManager &right); diff --git a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/SiDetectorElement.h b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/SiDetectorElement.h index 8bf282a7dbc4cf8b3d92e52a21a4804e421c716c..8f967fbfaae480960b8e3b68d0ebcc100772613c 100755 --- a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/SiDetectorElement.h +++ b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/SiDetectorElement.h @@ -27,6 +27,7 @@ class AtlasDetectorID; class GeoVFullPhysVol; +class GeoAlignmentStore; namespace Trk{ class Surface; @@ -110,9 +111,10 @@ namespace InDetDD { /// Constructor: SiDetectorElement(const Identifier &id, - const SiDetectorDesign *design, - const GeoVFullPhysVol *geophysvol, - SiCommonItems * commonItems); + const SiDetectorDesign *design, + const GeoVFullPhysVol *geophysvol, + SiCommonItems * commonItems, + const GeoAlignmentStore* geoAlignStore=nullptr); /// Destructor: virtual ~SiDetectorElement(); @@ -567,6 +569,8 @@ namespace InDetDD { void setOtherSide(const SiDetectorElement *); // For SCT only //@} + + const SiCommonItems* getCommonItems() const; /////////////////////////////////////////////////////////////////// // Private methods: @@ -679,6 +683,7 @@ namespace InDetDD { mutable Trk::Surface * m_surface; mutable std::vector<const Trk::Surface*> m_surfaces; + const GeoAlignmentStore* m_geoAlignStore; }; /////////////////////////////////////////////////////////////////// @@ -931,6 +936,11 @@ namespace InDetDD { { m_otherSide = element; } + + inline const SiCommonItems* SiDetectorElement::getCommonItems() const + { + return m_commonItems; + } inline bool SiDetectorElement::swapPhiReadoutDirection() const { diff --git a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/SiDetectorElementCollection.h b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/SiDetectorElementCollection.h index a4fbe702d932e408e0a5c05c4b4a49fe9f1a9c0f..7ebd98063ee5c7d7201880c130741e79c1a966a3 100755 --- a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/SiDetectorElementCollection.h +++ b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/SiDetectorElementCollection.h @@ -30,4 +30,9 @@ namespace InDetDD { } // namespace InDetDD +#include "AthenaKernel/CLASS_DEF.h" +CLASS_DEF( InDetDD::SiDetectorElementCollection , 1330395642 , 1 ) +#include "AthenaKernel/CondCont.h" +CONDCONT_DEF( InDetDD::SiDetectorElementCollection, 1098715294 ); + #endif // INDETREADOUTGEOMETRY_SIDETECTORELEMENTCOLLECTION_H diff --git a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/SiDetectorManager.h b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/SiDetectorManager.h index abd135a68115b8379b63fd7cd494c87f39cb4c20..6e62f0908fb4049d4e9037ae904de4787726ae4b 100755 --- a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/SiDetectorManager.h +++ b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/SiDetectorManager.h @@ -30,6 +30,7 @@ class Identifier; class IdentifierHash; class AtlasDetectorID; class GeoAlignableTransform; +class GeoVAlignmentStore; namespace InDetDD { @@ -74,6 +75,10 @@ class SiNumerology; virtual SiDetectorElement * getDetectorElement(const Identifier &id) const = 0; virtual SiDetectorElement * getDetectorElement(const IdentifierHash &idHash) const = 0; + /** access to individual elements using Identifier or IdentiferHash using SiDetectorElementCollection */ + virtual const SiDetectorElement* getDetectorElement(const Identifier &id, const SiDetectorElementCollection* coll) const = 0; + virtual const SiDetectorElement* getDetectorElement(const IdentifierHash &idHash, const SiDetectorElementCollection* coll) const = 0; + /** access to whole collectiom */ virtual const SiDetectorElementCollection * getDetectorElementCollection() const = 0; virtual SiDetectorElementCollection::const_iterator getDetectorElementBegin() const = 0; @@ -105,12 +110,14 @@ class SiNumerology; /** Helper method to set delta transform from a global delta - Amg interface*/ bool setAlignableTransformGlobalDelta(ExtendedAlignableTransform * extXF, - const Amg::Transform3D & delta) const; + const Amg::Transform3D & delta, + GeoVAlignmentStore* alignStore=nullptr) const; /** Helper method to set delta transform from a local delta - Amg interface */ bool setAlignableTransformLocalDelta(ExtendedAlignableTransform * extXF, - const Amg::Transform3D & localToGlobalXF, - const Amg::Transform3D & delta) const; + const Amg::Transform3D & localToGlobalXF, + const Amg::Transform3D & delta, + GeoVAlignmentStore* alignStore=nullptr) const; /** Access to module design */ void addDesign(const SiDetectorDesign *); @@ -128,9 +135,10 @@ class SiNumerology; /** This method is called by the InDetDetectorManager */ virtual bool setAlignableTransformDelta(int level, - const Identifier & id, - const Amg::Transform3D & delta, - FrameType frame) const = 0; + const Identifier & id, + const Amg::Transform3D & delta, + FrameType frame, + GeoVAlignmentStore* alignStore) const = 0; diff --git a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/TRT_DetectorManager.h b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/TRT_DetectorManager.h index d31695354171f014e3e76bd89b0d5ae37b9a2c97..c4615b1dbc2d3c13bcf86034c3142dda4ff338dc 100755 --- a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/TRT_DetectorManager.h +++ b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/TRT_DetectorManager.h @@ -32,7 +32,9 @@ class Identifier; class GeoAlignableTransform; +class GeoVAlignmentStore; class StoreGateSvc; +class CondAttrListCollection; namespace InDetDD { @@ -187,14 +189,16 @@ namespace InDetDD { /** Set alignable transforms: Amg based */ virtual bool setAlignableTransformDelta(int level, - const Identifier & id, - const Amg::Transform3D & delta, - FrameType frame) const; + const Identifier & id, + const Amg::Transform3D & delta, + FrameType frame, + GeoVAlignmentStore* alignStore) const; /** Set alignable transforms: Amg based */ bool setAlignableTransformAnyFrameDelta(ExtendedAlignableTransform * extXF, - const Amg::Transform3D & delta, - FrameType frame) const; + const Amg::Transform3D & delta, + FrameType frame, + GeoVAlignmentStore* alignStore) const; /** Invalidate cache for all detector elements */ @@ -211,7 +215,9 @@ namespace InDetDD { StatusCode alignmentCallback( IOVSVC_CALLBACK_ARGS ); /** Process new global DB folders for L1 and L2 **/ - bool processGlobalAlignment(const std::string &, int level, FrameType frame) const; + bool processGlobalAlignment(const std::string &, int level, FrameType frame, + const CondAttrListCollection* obj, + GeoVAlignmentStore* alignStore) const; private: diff --git a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/InDetDetectorManager.cxx b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/InDetDetectorManager.cxx index 6c89d191abebdfdc0cbd97154e315bc9d7fd1de0..8cc33a73c7bc93244a97ca90759ce3968df164f8 100755 --- a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/InDetDetectorManager.cxx +++ b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/InDetDetectorManager.cxx @@ -6,10 +6,11 @@ #include "InDetReadoutGeometry/InDetDetectorManager.h" #include "StoreGate/StoreGateSvc.h" -#include "DetDescrConditions/AlignableTransformContainer.h" #include "DetDescrConditions/AlignableTransform.h" #include "AtlasDetDescr/AtlasDetectorID.h" #include "GeoPrimitives/CLHEPtoEigenConverter.h" +#include "AthenaPoolUtilities/CondAttrListCollection.h" +#include "AthenaBaseComps/AthMsgStreamMacros.h" namespace InDetDD { @@ -52,13 +53,11 @@ namespace InDetDD void InDetDetectorManager::addChannel(const std::string & key, int level, FrameType frame) { - //if (msgLvl(MSG::DEBUG)) { - std::string frameStr = "other"; - if (frame == InDetDD::global) frameStr = "global"; - if (frame == InDetDD::local) frameStr = "local"; - msg(MSG::INFO) << "Registering alignment channel with key " << key << ", level " << level - << ", with frame " << frameStr << "." <<endmsg; - //} + std::string frameStr = "other"; + if (frame == InDetDD::global) frameStr = "global"; + if (frame == InDetDD::local) frameStr = "local"; + ATH_MSG_INFO("Registering alignment channel with key " << key << ", level " << level + << ", with frame " << frameStr << "."); m_keys[key] = LevelInfo(level, frame); } @@ -94,14 +93,15 @@ namespace InDetDD StatusCode InDetDetectorManager::align( IOVSVC_CALLBACK_ARGS_P(I,keys) ) const { + (void) I; // avoid warning about unused parameter - if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "AlignmentCallback called " << endmsg; + ATH_MSG_DEBUG("AlignmentCallback called "); if (!getIdHelper()) return StatusCode::SUCCESS; bool alignmentChange = false; - const AlignInfo &aligninfo = AlignInfo(m_alignfoldertype); + const AlignInfo &aligninfo = AlignInfo(m_alignfoldertype); // If dummy arguments if (keys.empty()) { @@ -111,13 +111,14 @@ namespace InDetDD for (std::set<std::string>::const_iterator iterFolders = m_globalFolders.begin(); iterFolders != m_globalFolders.end(); ++iterFolders) { + try { bool status = processGlobalAlignmentContainer(*iterFolders); alignmentChange = (alignmentChange || status); } catch(std::runtime_error& err) { // keys are empty when running simualtion. It is normal for detector specific aligments not to exist. - msg(MSG::FATAL) << err.what() << endmsg; - return StatusCode::FAILURE; + ATH_MSG_FATAL(err.what()); + return StatusCode::FAILURE; } } @@ -125,13 +126,14 @@ namespace InDetDD for (std::set<std::string>::const_iterator iterFolders = m_folders.begin(); iterFolders != m_folders.end(); ++iterFolders) { + try { bool status = processAlignmentContainer(*iterFolders); alignmentChange = (alignmentChange || status); } catch(std::runtime_error& err) { // alignments should always exist so we return fatal if we could not process the alignment for this key - msg(MSG::FATAL) << err.what() << endmsg; + ATH_MSG_FATAL(err.what()); return StatusCode::FAILURE; } } @@ -140,11 +142,11 @@ namespace InDetDD iterFolders != m_specialFolders.end(); ++iterFolders) { try { - bool status = processSpecialAlignment(*iterFolders, aligninfo.AlignFolder()); + bool status = processSpecialAlignment(*iterFolders, aligninfo.AlignFolder()); alignmentChange = (alignmentChange || status); } catch(std::runtime_error& err) { // keys are empty when running simualtion. It is normal for detector specific aligments not to exist. - if (msgLvl(MSG::INFO)) msg(MSG::INFO) << err.what() << endmsg; + ATH_MSG_INFO(err.what()); // We continue as detector specific aligments don't always exist. } } @@ -155,9 +157,9 @@ namespace InDetDD const std::string & key = *itr; - if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " Processing call back key " << key << endmsg; + ATH_MSG_DEBUG(" Processing call back key " << key); - if ( m_globalFolders.find(key) != m_globalFolders.end() ) { + if ( m_globalFolders.find(key) != m_globalFolders.end() ) { try { // New global alignemnts @@ -165,11 +167,11 @@ namespace InDetDD alignmentChange = (alignmentChange || status); } catch(std::runtime_error& err) { // alignments should always exist so we return fatal if we could not process the alignment for this key - msg(MSG::FATAL) << err.what() << endmsg; + ATH_MSG_FATAL(err.what()); return StatusCode::FAILURE; } - } else if ( m_folders.find(key) != m_folders.end() ) { + } else if ( m_folders.find(key) != m_folders.end() ) { try { // Regular alignemnts @@ -177,25 +179,25 @@ namespace InDetDD alignmentChange = (alignmentChange || status); } catch(std::runtime_error& err) { // alignments should always exist so we return fatal if we could not process the alignment for this key - msg(MSG::FATAL) << err.what() << endmsg; + ATH_MSG_FATAL(err.what()); return StatusCode::FAILURE; } } else if ( m_specialFolders.find(key) != m_specialFolders.end() ) { try { // Detector specific alignments - bool status = processSpecialAlignment(key, aligninfo.AlignFolder()); + bool status = processSpecialAlignment(key, aligninfo.AlignFolder()); alignmentChange = (alignmentChange || status); } catch(std::runtime_error& err) { // Should always exist if the folder was requested so we return fatal if we could not process the alignment for this key - msg(MSG::FATAL) << err.what() << endmsg; + ATH_MSG_FATAL(err.what()); return StatusCode::FAILURE; } } else { // Should not be any other keys specified in call back. - msg(MSG::ERROR) << "Unrecognized key in call back." << endmsg; - return StatusCode::SUCCESS; + ATH_MSG_ERROR("Unrecognized key in call back."); + return StatusCode::RECOVERABLE; } } } @@ -208,96 +210,183 @@ namespace InDetDD return StatusCode::SUCCESS; } + StatusCode InDetDetectorManager::align(const RawAlignmentObjects& alignObjects, GeoVAlignmentStore* alignStore) const + { + + ATH_MSG_DEBUG("align() called from an alignment CondAlg"); + if (!getIdHelper()) return StatusCode::SUCCESS; // To Do: is it really a success? + + bool alignmentChange = false; + // const AlignInfo &aligninfo = AlignInfo(m_alignfoldertype); + + for(const auto& alignObj : alignObjects) { + const std::string& key = alignObj.first; + + ATH_MSG_DEBUG(" Processing folder " << key); + + if(m_globalFolders.find(key)!=m_globalFolders.end()) { + try { + // New global alignemnts + const CondAttrListCollection* obj = static_cast<const CondAttrListCollection*>(alignObj.second); + bool status = processGlobalAlignmentContainer(key,obj,alignStore); + alignmentChange = (alignmentChange || status); + } catch(std::runtime_error& err) { + // alignments should always exist so we return fatal if we could not process the alignment for this key + ATH_MSG_FATAL(err.what()); + return StatusCode::FAILURE; + } + } + else if(m_folders.find(key)!=m_folders.end()) { + try { + // Regular alignemnts + const AlignableTransformContainer* container = static_cast<const AlignableTransformContainer*>(alignObj.second); + bool status = processAlignmentContainer(container,alignStore); + alignmentChange = (alignmentChange || status); + } catch(std::runtime_error& err) { + // alignments should always exist so we return fatal if we could not process the alignment for this key + ATH_MSG_FATAL(err.what()); + return StatusCode::FAILURE; + } + } + else if(m_specialFolders.find(key)!=m_specialFolders.end()) { + // To Do: do we really need this? + + /* + try { + // Detector specific alignments + bool status = processSpecialAlignment(key, aligninfo.AlignFolder(),alignStore); + alignmentChange = (alignmentChange || status); + } + catch(std::runtime_error& err) { + // Should always exist if the folder was requested so we return fatal if we could not process the alignment for this key + ATH_MSG_FATAL(err.what()); + return StatusCode::FAILURE; + } + */ + } + else { + // Should not be any other keys specified in call back. + ATH_MSG_ERROR("Unrecognized folder name."); + return StatusCode::RECOVERABLE; + } + } + // To Do: custom caching is not going to work in MT + /* + if(alignmentChange) invalidateAll(); + */ + + return StatusCode::SUCCESS; + } bool InDetDetectorManager::processAlignmentContainer(const std::string & key) const { bool alignmentChange = false; - if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "Dealing with key as container" << endmsg; + ATH_MSG_DEBUG("Dealing with key as container"); const AlignableTransformContainer* container; if (StatusCode::SUCCESS!=m_detStore->retrieve(container, key)) { - msg(MSG::ERROR) << "Cannot find AlignableTransformContainer for key " - << key << " - no misalignment" << endmsg; + ATH_MSG_ERROR("Cannot find AlignableTransformContainer for key " + << key << " - no misalignment"); // This should not occur in normal situations so we force job to abort. throw std::runtime_error("Unable to apply Inner Detector alignments"); } // Check if container is empty - this can occur if it is an invalid IOV. if (container->empty()) { - msg(MSG::ERROR) << "AlignableTransformContainer for key " - << key << " is empty. Probably due to out of range IOV" << endmsg; + ATH_MSG_ERROR("AlignableTransformContainer for key " + << key << " is empty. Probably due to out of range IOV"); // This should not occur in normal situations so we force job to abort. throw std::runtime_error("Unable to apply Inner Detector alignments."); } // loop over all the AlignableTransform objects in the collection for (DataVector<AlignableTransform>::const_iterator pat=container->begin(); pat!=container->end();++pat) { - + bool status = processKey((*pat)->tag(),*pat); alignmentChange = (alignmentChange || status); } return alignmentChange; } - bool InDetDetectorManager::processKey(const std::string key, const AlignableTransform* transformCollection) const + bool InDetDetectorManager::processAlignmentContainer(const AlignableTransformContainer* container, GeoVAlignmentStore* alignStore) const + { + bool alignmentChange = false; + + // Check if container is empty - this can occur if it is an invalid IOV. + if (container->empty()) { + ATH_MSG_ERROR("AlignableTransformContainer " + << " is empty. Probably due to out of range IOV"); // To Do: add key to this printout for making it more informative + // This should not occur in normal situations so we force job to abort. + throw std::runtime_error("Unable to apply Inner Detector alignments."); + } + // loop over all the AlignableTransform objects in the collection + bool isFirstL3SCTECA9 = true; + for (DataVector<AlignableTransform>::const_iterator pat=container->begin(); + pat!=container->end();++pat) { + // /Indet/AlignL3/SCTEA9 appear repeatedly in tags of the /Indet/AlignL3 folder + if ((*pat)->tag()=="/Indet/AlignL3/SCTEA9") { + if (not isFirstL3SCTECA9) continue; + else isFirstL3SCTECA9 = false; + } + bool status = processKey((*pat)->tag(),*pat,alignStore); + alignmentChange = (alignmentChange || status); + } + return alignmentChange; + } + + bool InDetDetectorManager::processKey(const std::string key, + const AlignableTransform* transformCollection, + GeoVAlignmentStore* alignStore) const { bool alignmentChange = false; // From the key determine what level in hierarchy we are dealing with. // returns -1 if unrecognized. const LevelInfo & levelInfo = getLevel(key); - if (msgLvl(MSG::DEBUG)) { - if (levelInfo.isValid()) { - if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "Processing channel: " << key << endmsg; - } else { - msg(MSG::DEBUG) << "Channel " << key << " not registered in this manager" << endmsg; - } + if (levelInfo.isValid()) { + ATH_MSG_VERBOSE("Processing channel: " << key); + } else { + ATH_MSG_DEBUG("Channel " << key << " not registered in this manager"); } // return silently if unrecognised - this can happen in container mode // when a single container holds transforms for both pixel and SCT if (!levelInfo.isValid() ) return false; - //Loop over the effected nodes. for (AlignableTransform::AlignTransMem_citr trans_iter = transformCollection->begin(); - trans_iter != transformCollection->end(); - ++trans_iter) { - if (msgLvl(MSG::DEBUG)) { - msg(MSG::DEBUG) << "Get alignment for identifier " - << getIdHelper()->show_to_string(trans_iter->identify()) - << " at level " << levelInfo.level() << endmsg; + trans_iter != transformCollection->end(); + ++trans_iter) { + ATH_MSG_DEBUG( "Get alignment for identifier " + << getIdHelper()->show_to_string(trans_iter->identify()) + << " at level " << levelInfo.level()); - } // The delta in the conditions DB is not necessarily the same as what is needed in the // alignable transform. At the moment we support global frame, local frame or an alternative frame // The setAlignableTransformDelta method takes care of this correction - this is CLHEP <--> Amg interfaced bool status = setAlignableTransformDelta(levelInfo.level(), trans_iter->identify(), - Amg::CLHEPTransformToEigen(trans_iter->transform()), - levelInfo.frame()); + Amg::CLHEPTransformToEigen(trans_iter->transform()), + levelInfo.frame(), + alignStore); alignmentChange = (alignmentChange || status); if (!status) { if (!identifierBelongs(trans_iter->identify())) { // Its probably OK. Eg /Indet/Align/ID contains alse pixel and sct ids. - if (msgLvl(MSG::DEBUG)) { - msg(MSG::DEBUG) << "Cannot set AlignableTransform for identifier." - << " Probably OK if its /Indet/Align/ID folder. " - << getIdHelper()->show_to_string(trans_iter->identify()) - << " at level " << levelInfo.level() << endmsg; - } + ATH_MSG_DEBUG("Cannot set AlignableTransform for identifier." + << " Probably OK if its /Indet/Align/ID folder. " + << getIdHelper()->show_to_string(trans_iter->identify()) + << " at level " << levelInfo.level()); } else { if (m_suppressWarnings) { - if (msgLvl(MSG::DEBUG)) { - msg(MSG::DEBUG) << "WARNING: Cannot set AlignableTransform for identifier " - << getIdHelper()->show_to_string(trans_iter->identify()) - << " at level " << levelInfo.level() << endmsg; - } + ATH_MSG_DEBUG("WARNING: Cannot set AlignableTransform for identifier " + << getIdHelper()->show_to_string(trans_iter->identify()) + << " at level " << levelInfo.level()); } else { - msg(MSG::WARNING) << "Cannot set AlignableTransform for identifier " - << getIdHelper()->show_to_string(trans_iter->identify()) - << " at level " << levelInfo.level() << endmsg; - msg(MSG::WARNING) << "Subsequent WARNINGS will be printed at DEBUG level." << endmsg; + ATH_MSG_WARNING("Cannot set AlignableTransform for identifier " + << getIdHelper()->show_to_string(trans_iter->identify()) + << " at level " << levelInfo.level()); + ATH_MSG_WARNING("Subsequent WARNINGS will be printed at DEBUG level."); m_suppressWarnings = true; } } @@ -307,27 +396,27 @@ namespace InDetDD } // We provide a default implementation of any detector specific alignment. - bool InDetDetectorManager::processGlobalAlignmentContainer(const std::string & key) const + bool InDetDetectorManager::processGlobalAlignmentContainer(const std::string & key, + const CondAttrListCollection* obj, + GeoVAlignmentStore* alignStore) const { bool alignmentChange = false; - msg(MSG::DEBUG) << "processing GlobalAlignmentContainer with key: " << key << endmsg; + ATH_MSG_DEBUG("processing GlobalAlignmentContainer with key: " << key); // From the key determine what level in hierarchy we are dealing with. // returns -1 if unrecognized. const LevelInfo & levelInfo = getLevel(key); - if (msgLvl(MSG::DEBUG)) { - if (levelInfo.isValid()) { - if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "Processing channel: " << key << endmsg; - } else { - msg(MSG::DEBUG) << "Channel " << key << " not registered in this manager" << endmsg; - } + if (levelInfo.isValid()) { + ATH_MSG_VERBOSE("Processing channel: " << key); + } else { + ATH_MSG_DEBUG("Channel " << key << " not registered in this manager"); } // return silently if unrecognised - this can happen in container mode // when a single container holds transforms for both pixel and SCT if (!levelInfo.isValid() ) return false; // Within detector specific code - bool status = processGlobalAlignment(key, levelInfo.level(), levelInfo.frame()); + bool status = processGlobalAlignment(key, levelInfo.level(), levelInfo.frame(), obj, alignStore); alignmentChange = (alignmentChange || status); @@ -336,7 +425,8 @@ namespace InDetDD } // We provide a default implementation of any detector specific alignment. - bool InDetDetectorManager::processGlobalAlignment(const std::string &, int /*level*/, FrameType /*frame*/) const + bool InDetDetectorManager::processGlobalAlignment(const std::string &, int /*level*/, FrameType /*frame*/, + const CondAttrListCollection* /*obj*/, GeoVAlignmentStore* /*alignStore*/) const { return false; } diff --git a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/PixelDetectorManager.cxx b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/PixelDetectorManager.cxx index b12ff1f183900ff583e5d012c34fb22951287203..4cadd37353f5e801572360ea27f3fa3baf9e8d2a 100755 --- a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/PixelDetectorManager.cxx +++ b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/PixelDetectorManager.cxx @@ -117,11 +117,28 @@ namespace InDetDD { return m_elementCollection[idHash]; } + const SiDetectorElement* PixelDetectorManager::getDetectorElement(const Identifier &id, + const SiDetectorElementCollection* /*coll*/) const + { + return getDetectorElement(id); + } + + const SiDetectorElement* PixelDetectorManager::getDetectorElement(const IdentifierHash &idHash, + const SiDetectorElementCollection* /*coll*/) const + { + return getDetectorElement(idHash); + } + SiDetectorElement* PixelDetectorManager::getDetectorElement(int barrel_endcap, int layer_wheel, int phi_module, int eta_module) const { return getDetectorElement(m_idHelper->wafer_id(barrel_endcap, layer_wheel, phi_module, eta_module)); } + const SiDetectorElement* PixelDetectorManager::getDetectorElement(int barrel_endcap, int layer_wheel, int phi_module, int eta_module, + const SiDetectorElementCollection* /*coll*/) const + { + return getDetectorElement(barrel_endcap, layer_wheel, phi_module, eta_module); + } const SiDetectorElementCollection* PixelDetectorManager::getDetectorElementCollection() const { @@ -205,9 +222,10 @@ namespace InDetDD { bool PixelDetectorManager::setAlignableTransformDelta(int level, - const Identifier & id, - const Amg::Transform3D & delta, - FrameType frame) const + const Identifier & id, + const Amg::Transform3D & delta, + FrameType frame, + GeoVAlignmentStore* /*alignStore*/) const { if (level == 0) { // At the element level - local shift @@ -443,9 +461,10 @@ namespace InDetDD { // Set the new transform; Will replace existing one with updated transform bool status = setAlignableTransformDelta(0, - trans_iter->identify(), - Amg::CLHEPTransformToEigen(newtrans), - InDetDD::local); + trans_iter->identify(), + Amg::CLHEPTransformToEigen(newtrans), + InDetDD::local, + nullptr); if (!status) { if (msgLvl(MSG::DEBUG)) { @@ -464,7 +483,7 @@ namespace InDetDD { } // New global alignment folders - bool PixelDetectorManager::processGlobalAlignment(const std::string & key, int level, FrameType frame) const + bool PixelDetectorManager::processGlobalAlignment(const std::string & key, int level, FrameType frame, const CondAttrListCollection* /*obj*/, GeoVAlignmentStore* alignStore) const { bool alignmentChange = false; @@ -520,7 +539,8 @@ namespace InDetDD { bool status = setAlignableTransformDelta(level, ident, newtrans, - frame); + frame, + alignStore); if (!status) { if (msgLvl(MSG::DEBUG)) { diff --git a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/SCT_DetectorManager.cxx b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/SCT_DetectorManager.cxx index e57bed11c4c5c9e76e49138dd2955b352f9b96f8..d663737522c05f4025ff00251c4667a4fe70341f 100755 --- a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/SCT_DetectorManager.cxx +++ b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/SCT_DetectorManager.cxx @@ -2,23 +2,22 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ -//#include "DetDescrConditions/AlignableTransformContainer.h" -//#include "DetDescrConditions/AlignableTransform.h" -#include "AthenaPoolUtilities/CondAttrListCollection.h" - #include "InDetReadoutGeometry/SCT_DetectorManager.h" -#include "InDetIdentifier/SCT_ID.h" + +#include "AthenaBaseComps/AthMsgStreamMacros.h" +#include "AthenaPoolUtilities/CondAttrListCollection.h" +#include "GeoPrimitives/CLHEPtoEigenConverter.h" #include "Identifier/Identifier.h" #include "Identifier/IdentifierHash.h" +#include "InDetIdentifier/SCT_ID.h" #include "InDetReadoutGeometry/SiDetectorElementCollection.h" #include "InDetReadoutGeometry/SiDetectorElement.h" #include "InDetReadoutGeometry/ExtendedAlignableTransform.h" #include "InDetReadoutGeometry/SCT_ModuleSideDesign.h" #include "StoreGate/StoreGateSvc.h" -#include "GeoPrimitives/CLHEPtoEigenConverter.h" - #include <iostream> + namespace InDetDD { const int FIRST_HIGHER_LEVEL = 2; @@ -32,8 +31,8 @@ namespace InDetDD { // Initialized the Identifier helper. // StatusCode sc = detStore->retrieve(m_idHelper, "SCT_ID"); - if (sc.isFailure() ) { - msg(MSG::ERROR) << "Could not retrieve SCT id helper" << endmsg; + if (sc.isFailure()) { + ATH_MSG_ERROR("Could not retrieve SCT id helper"); } // Initialize the collections. if (m_idHelper) { @@ -60,8 +59,8 @@ namespace InDetDD { for (size_t j=0; j < m_higherAlignableTransforms.size(); j++){ AlignableTransformMap::iterator iterMap; for (iterMap = m_higherAlignableTransforms[j].begin(); - iterMap != m_higherAlignableTransforms[j].end(); - ++iterMap) { + iterMap != m_higherAlignableTransforms[j].end(); + ++iterMap) { delete iterMap->second; } } @@ -115,6 +114,33 @@ namespace InDetDD { return getDetectorElement(m_idHelper->wafer_id(barrel_endcap, layer_wheel, phi_module, eta_module, side)); } + const SiDetectorElement* SCT_DetectorManager::getDetectorElement(const Identifier &id, const SiDetectorElementCollection* coll) const + { + if (coll) { + Identifier waferId = m_idHelper->wafer_id(id); + IdentifierHash idHash = m_idHelper->wafer_hash(waferId); + if (idHash.is_valid()) { + return (*coll)[idHash]; + } else { + return nullptr; + } + } + return getDetectorElement(id); + } + + const SiDetectorElement* SCT_DetectorManager::getDetectorElement(const IdentifierHash &idHash, const SiDetectorElementCollection* coll) const + { + if (coll) { + return (*coll)[idHash]; + } + return getDetectorElement(idHash); + } + + const SiDetectorElement* SCT_DetectorManager::getDetectorElement(int barrel_endcap, int layer_wheel, int phi_module, int eta_module, int side, + const SiDetectorElementCollection* coll) const + { + return getDetectorElement(m_idHelper->wafer_id(barrel_endcap, layer_wheel, phi_module, eta_module, side), coll); + } const SiDetectorElementCollection* SCT_DetectorManager::getDetectorElementCollection() const { @@ -181,9 +207,10 @@ namespace InDetDD { bool SCT_DetectorManager::setAlignableTransformDelta(int level, - const Identifier & id, - const Amg::Transform3D & delta, - FrameType frame) const + const Identifier & id, + const Amg::Transform3D & delta, + FrameType frame, + GeoVAlignmentStore* alignStore) const { if (level == 0) { // 0 - At the element level @@ -194,7 +221,7 @@ namespace InDetDD { if (frame == InDetDD::global) { // global shift // Its a global transform - return setAlignableTransformGlobalDelta(m_alignableTransforms[idHash], delta); + return setAlignableTransformGlobalDelta(m_alignableTransforms[idHash], delta, alignStore); } else if (frame == InDetDD::local) { // local shift @@ -205,16 +232,16 @@ namespace InDetDD { // Its a local transform //See header file for definition of m_isLogical if( m_isLogical ){ - //Ensure cache is up to date and use the alignment corrected local to global transform - element->updateCache(); - return setAlignableTransformLocalDelta(m_alignableTransforms[idHash], element->transform(), delta); + //Ensure cache is up to date and use the alignment corrected local to global transform + element->updateCache(); + return setAlignableTransformLocalDelta(m_alignableTransforms[idHash], element->transform(), delta, alignStore); } else - //Use default local to global transform - return setAlignableTransformLocalDelta(m_alignableTransforms[idHash], element->defTransform(), delta); + //Use default local to global transform + return setAlignableTransformLocalDelta(m_alignableTransforms[idHash], element->defTransform(), delta, alignStore); } else { // other not supported - msg(MSG::WARNING) << "Frames other than global or local are not supported." << endmsg; + ATH_MSG_WARNING("Frames other than global or local are not supported."); return false; } @@ -227,13 +254,13 @@ namespace InDetDD { int idModuleHash = idHash / 2; if (idHash%2) { - msg(MSG::WARNING) << "Side 1 wafer id used for module id" << endmsg; + ATH_MSG_WARNING("Side 1 wafer id used for module id"); return false; } if (frame == InDetDD::global) { // global shift // Its a global transform - return setAlignableTransformGlobalDelta(m_moduleAlignableTransforms[idModuleHash], delta); + return setAlignableTransformGlobalDelta(m_moduleAlignableTransforms[idModuleHash], delta, alignStore); } else if (frame == InDetDD::local) { // local shift const SiDetectorElement * element = m_elementCollection[idHash]; if (!element) return false; @@ -241,23 +268,23 @@ namespace InDetDD { // Its a local transform //See header file for definition of m_isLogical if( m_isLogical ){ - //Ensure cache is up to date and use the alignment corrected local to global transform - element->updateCache(); - return setAlignableTransformLocalDelta(m_moduleAlignableTransforms[idModuleHash], element->moduleTransform(), delta); + //Ensure cache is up to date and use the alignment corrected local to global transform + element->updateCache(); + return setAlignableTransformLocalDelta(m_moduleAlignableTransforms[idModuleHash], element->moduleTransform(), delta, alignStore); } else - //Use default local to global transform - return setAlignableTransformLocalDelta(m_moduleAlignableTransforms[idModuleHash],element->defModuleTransform(), delta); + //Use default local to global transform + return setAlignableTransformLocalDelta(m_moduleAlignableTransforms[idModuleHash],element->defModuleTransform(), delta, alignStore); } else { // other not supported - msg(MSG::WARNING) << "Frames other than global or local are not supported." << endmsg; + ATH_MSG_WARNING("Frames other than global or local are not supported."); return false; } } else { // higher level if (frame != InDetDD::global) { - msg(MSG::WARNING) << "Non global shift at higher levels is not supported." << endmsg; + ATH_MSG_WARNING("Non global shift at higher levels is not supported."); return false; } @@ -270,22 +297,21 @@ namespace InDetDD { if (iter == m_higherAlignableTransforms[index].end()) return false; // Its a global transform - return setAlignableTransformGlobalDelta(iter->second, delta); + return setAlignableTransformGlobalDelta(iter->second, delta, alignStore); } } void SCT_DetectorManager::addAlignableTransform (int level, - const Identifier & id, - GeoAlignableTransform *transform, - const GeoVPhysVol * child) + const Identifier & id, + GeoAlignableTransform *transform, + const GeoVPhysVol * child) { if (m_idHelper) { const GeoVFullPhysVol * childFPV = dynamic_cast<const GeoVFullPhysVol *>(child); if (!childFPV) { - msg(MSG::ERROR) << "Child of alignable transform is not a full physical volume" - << endmsg; + ATH_MSG_ERROR("Child of alignable transform is not a full physical volume"); } else { addAlignableTransform (level, id, transform, childFPV); } @@ -293,9 +319,9 @@ namespace InDetDD { } void SCT_DetectorManager::addAlignableTransform (int level, - const Identifier & id, - GeoAlignableTransform *transform, - const GeoVFullPhysVol * child) + const Identifier & id, + GeoAlignableTransform *transform, + const GeoVFullPhysVol * child) { if (m_idHelper) { if (level == 0) { @@ -322,7 +348,7 @@ namespace InDetDD { } bool - SCT_DetectorManager::identifierBelongs(const Identifier & id) const + SCT_DetectorManager::identifierBelongs(const Identifier & id) const { return getIdHelper()->is_sct(id); } @@ -334,72 +360,68 @@ namespace InDetDD { } // New global alignment folders - bool SCT_DetectorManager::processGlobalAlignment(const std::string & key, int level, FrameType frame) const + bool SCT_DetectorManager::processGlobalAlignment(const std::string & key, int level, FrameType frame, + const CondAttrListCollection* obj, GeoVAlignmentStore* alignStore) const { + ATH_MSG_INFO("Processing new global alignment containers with key " << key << " in the " << frame << " frame at level "); - bool alignmentChange = false; - - if(msgLvl(MSG::INFO)) - msg(MSG::INFO) << "Processing new global alignment containers with key " << key << " in the " << frame << " frame at level " << level << endmsg; + const CondAttrListCollection* atrlistcol=obj; + if(atrlistcol==nullptr and m_detStore->retrieve(atrlistcol,key)!=StatusCode::SUCCESS) { + ATH_MSG_INFO("Cannot find new global align Container for key " + << key << " - no new global alignment "); + return false; + } + bool alignmentChange = false; Identifier ident=Identifier(); - const CondAttrListCollection* atrlistcol=0; - if (StatusCode::SUCCESS==m_detStore->retrieve(atrlistcol,key)) { - // loop over objects in collection - for (CondAttrListCollection::const_iterator citr=atrlistcol->begin(); citr!=atrlistcol->end();++citr) { - const coral::AttributeList& atrlist=citr->second; - // SCT manager, therefore ignore all that is not a SCT Identifier - if (atrlist["det"].data<int>()!=2) continue; - - ident = getIdHelper()->wafer_id(atrlist["bec"].data<int>(), - atrlist["layer"].data<int>(), - atrlist["ring"].data<int>(), - atrlist["sector"].data<int>(), - 0); // The last is the module side which is at this ident-level always the 0-side - - // construct new transform - // Order of rotations is defined as around z, then y, then x. - Amg::Translation3D newtranslation(atrlist["Tx"].data<float>(),atrlist["Ty"].data<float>(),atrlist["Tz"].data<float>()); - Amg::Transform3D newtrans = newtranslation * Amg::RotationMatrix3D::Identity(); - newtrans *= Amg::AngleAxis3D(atrlist["Rz"].data<float>()*CLHEP::mrad, Amg::Vector3D(0.,0.,1.)); - newtrans *= Amg::AngleAxis3D(atrlist["Ry"].data<float>()*CLHEP::mrad, Amg::Vector3D(0.,1.,0.)); - newtrans *= Amg::AngleAxis3D(atrlist["Rx"].data<float>()*CLHEP::mrad, Amg::Vector3D(1.,0.,0.)); - - msg(MSG::DEBUG) << "New global DB -- channel: " << citr->first - << " ,det: " << atrlist["det"].data<int>() - << " ,bec: " << atrlist["bec"].data<int>() - << " ,layer: " << atrlist["layer"].data<int>() - << " ,ring: " << atrlist["ring"].data<int>() - << " ,sector: " << atrlist["sector"].data<int>() - << " ,Tx: " << atrlist["Tx"].data<float>() - << " ,Ty: " << atrlist["Ty"].data<float>() - << " ,Tz: " << atrlist["Tz"].data<float>() - << " ,Rx: " << atrlist["Rx"].data<float>() - << " ,Ry: " << atrlist["Ry"].data<float>() - << " ,Rz: " << atrlist["Rz"].data<float>() << endmsg; - - // Set the new transform; Will replace existing one with updated transform - bool status = setAlignableTransformDelta(level, - ident, - newtrans, - frame); - - if (!status) { - if (msgLvl(MSG::DEBUG)) { - msg(MSG::DEBUG) << "Cannot set AlignableTransform for identifier." - << getIdHelper()->show_to_string(ident) - << " at level " << level << " for new global DB " << endmsg; - } - } - - alignmentChange = (alignmentChange || status); + + // loop over objects in collection + for (CondAttrListCollection::const_iterator citr=atrlistcol->begin(); citr!=atrlistcol->end();++citr) { + const coral::AttributeList& atrlist=citr->second; + // SCT manager, therefore ignore all that is not a SCT Identifier + if (atrlist["det"].data<int>()!=2) continue; + + ident = getIdHelper()->wafer_id(atrlist["bec"].data<int>(), + atrlist["layer"].data<int>(), + atrlist["ring"].data<int>(), + atrlist["sector"].data<int>(), + 0); // The last is the module side which is at this ident-level always the 0-side + + // construct new transform + // Order of rotations is defined as around z, then y, then x. + Amg::Translation3D newtranslation(atrlist["Tx"].data<float>(),atrlist["Ty"].data<float>(),atrlist["Tz"].data<float>()); + Amg::Transform3D newtrans = newtranslation * Amg::RotationMatrix3D::Identity(); + newtrans *= Amg::AngleAxis3D(atrlist["Rz"].data<float>()*CLHEP::mrad, Amg::Vector3D(0.,0.,1.)); + newtrans *= Amg::AngleAxis3D(atrlist["Ry"].data<float>()*CLHEP::mrad, Amg::Vector3D(0.,1.,0.)); + newtrans *= Amg::AngleAxis3D(atrlist["Rx"].data<float>()*CLHEP::mrad, Amg::Vector3D(1.,0.,0.)); + + ATH_MSG_DEBUG("New global DB -- channel: " << citr->first + << " ,det: " << atrlist["det"].data<int>() + << " ,bec: " << atrlist["bec"].data<int>() + << " ,layer: " << atrlist["layer"].data<int>() + << " ,ring: " << atrlist["ring"].data<int>() + << " ,sector: " << atrlist["sector"].data<int>() + << " ,Tx: " << atrlist["Tx"].data<float>() + << " ,Ty: " << atrlist["Ty"].data<float>() + << " ,Tz: " << atrlist["Tz"].data<float>() + << " ,Rx: " << atrlist["Rx"].data<float>() + << " ,Ry: " << atrlist["Ry"].data<float>() + << " ,Rz: " << atrlist["Rz"].data<float>()); + + // Set the new transform; Will replace existing one with updated transform + bool status = setAlignableTransformDelta(level, + ident, + newtrans, + frame, + alignStore); + + if (!status) { + ATH_MSG_DEBUG("Cannot set AlignableTransform for identifier." + << getIdHelper()->show_to_string(ident) + << " at level " << level << " for new global DB "); } - } - else { - if (msgLvl(MSG::INFO)) - msg(MSG::INFO) << "Cannot find new global align Container for key " - << key << " - no new global alignment " << endmsg; - return alignmentChange; + + alignmentChange = (alignmentChange || status); } return alignmentChange; } diff --git a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/SiDetectorElement.cxx b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/SiDetectorElement.cxx index 9200e00d3b865d3feb58abca5422540544aeca6a..8da438e4cd624faaa95433a9e46e0e4edc5ebef6 100755 --- a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/SiDetectorElement.cxx +++ b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/SiDetectorElement.cxx @@ -15,6 +15,7 @@ #include "InDetIdentifier/SCT_ID.h" #include "GeoModelKernel/GeoVFullPhysVol.h" +#include "GeoModelUtilities/GeoAlignmentStore.h" #include "AtlasDetDescr/AtlasDetectorID.h" #include "CLHEP/Geometry/Point3D.h" @@ -46,9 +47,10 @@ using Trk::distDepth; // Constructor with parameters: SiDetectorElement::SiDetectorElement(const Identifier &id, - const SiDetectorDesign *design, - const GeoVFullPhysVol *geophysvol, - SiCommonItems * commonItems) : + const SiDetectorDesign *design, + const GeoVFullPhysVol *geophysvol, + SiCommonItems * commonItems, + const GeoAlignmentStore* geoAlignStore) : TrkDetElementBase(geophysvol), m_id(id), m_design(design), @@ -65,7 +67,8 @@ SiDetectorElement::SiDetectorElement(const Identifier &id, m_tanLorentzAnglePhi(0), m_tanLorentzAngleEta(0), m_lorentzCorrection(0), - m_surface(0) + m_surface(0), + m_geoAlignStore(geoAlignStore) { //The following are fixes for coverity bug 11955, uninitialized scalars: const bool boolDefault(true); @@ -390,6 +393,10 @@ SiDetectorElement::updateConditionsCache() const const HepGeom::Transform3D & SiDetectorElement::transformHit() const { + if (m_geoAlignStore) { + const HepGeom::Transform3D* ptrXf = m_geoAlignStore->getAbsPosition(getMaterialGeom()); + if(ptrXf) return *ptrXf; + } return getMaterialGeom()->getAbsoluteTransform(); } @@ -410,16 +417,21 @@ SiDetectorElement::transformCLHEP() const return m_transformCLHEP; } + const HepGeom::Transform3D SiDetectorElement::defTransformCLHEP() const { + if (m_geoAlignStore) { + const HepGeom::Transform3D* ptrXf = m_geoAlignStore->getDefAbsPosition(getMaterialGeom()); + if(ptrXf) return *ptrXf * recoToHitTransform(); + } return getMaterialGeom()->getDefAbsoluteTransform() * recoToHitTransform(); } const Amg::Transform3D SiDetectorElement::defTransform() const { - HepGeom::Transform3D tmpTransform = getMaterialGeom()->getDefAbsoluteTransform() * recoToHitTransform(); + HepGeom::Transform3D tmpTransform = defTransformCLHEP(); return Amg::CLHEPTransformToEigen(tmpTransform); } diff --git a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/SiDetectorManager.cxx b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/SiDetectorManager.cxx index 847ace84ed86443e1dc6492bd620cf4e0a000089..4b7980893c116430cb99289de7c93f1509eaa4d7 100755 --- a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/SiDetectorManager.cxx +++ b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/SiDetectorManager.cxx @@ -60,7 +60,8 @@ namespace InDetDD bool SiDetectorManager::setAlignableTransformLocalDelta(ExtendedAlignableTransform * extXF, const Amg::Transform3D & localToGlobalXF, - const Amg::Transform3D & delta) const + const Amg::Transform3D & delta, + GeoVAlignmentStore* alignStore) const { // ATTENTION -------------------------------------------------------- (A.S.) // CLHEP < -- > AMG interface method @@ -90,7 +91,7 @@ namespace InDetDD HepGeom::Transform3D correctedDelta = transform.inverse()*localToGlobalXFCLHEP // (A*B*C).inverse() * T * Amg::EigenTransformToCLHEP(delta) // l * localToGlobalXFCLHEP.inverse() * transform; // T.inverse() * (A*B*C) - extXF->alignableTransform()->setDelta(correctedDelta); + extXF->alignableTransform()->setDelta(correctedDelta, alignStore); return true; } else { return false; @@ -98,7 +99,8 @@ namespace InDetDD } bool SiDetectorManager::setAlignableTransformGlobalDelta(ExtendedAlignableTransform * extXF, - const Amg::Transform3D& delta) const { + const Amg::Transform3D& delta, + GeoVAlignmentStore* alignStore) const { // ATTENTION -------------------------------------------------------- (A.S.) // CLHEP < -- > AMG interface method @@ -122,7 +124,7 @@ namespace InDetDD if (child && extXF->alignableTransform()) { // do the calculation in CLHEP const HepGeom::Transform3D& transform = child->getDefAbsoluteTransform(); - extXF->alignableTransform()->setDelta(transform.inverse() * Amg::EigenTransformToCLHEP(delta) * transform); + extXF->alignableTransform()->setDelta(transform.inverse() * Amg::EigenTransformToCLHEP(delta) * transform, alignStore); return true; } else { return false; diff --git a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/TRT_DetectorManager.cxx b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/TRT_DetectorManager.cxx index 0f0ced4adfd3afdb9d603127a90d9ec5d41fd645..ee177c8e70332dd8275c3edef84932b0be2cba35 100755 --- a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/TRT_DetectorManager.cxx +++ b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/TRT_DetectorManager.cxx @@ -444,7 +444,8 @@ namespace InDetDD { bool TRT_DetectorManager::setAlignableTransformDelta(int level, const Identifier & id, const Amg::Transform3D & delta, - FrameType frame) const + FrameType frame, + GeoVAlignmentStore* alignStore) const { if (level == 0) { // Nothing implemented. Reserved in case we want alignable straws @@ -459,14 +460,15 @@ namespace InDetDD { iter = m_alignableTransforms[index].find(id); if (iter == m_alignableTransforms[index].end()) return false; - return setAlignableTransformAnyFrameDelta(iter->second, delta, frame); + return setAlignableTransformAnyFrameDelta(iter->second, delta, frame, alignStore); } } bool TRT_DetectorManager::setAlignableTransformAnyFrameDelta(ExtendedAlignableTransform * extXF, const Amg::Transform3D & delta, - FrameType frame) const + FrameType frame, + GeoVAlignmentStore* /*alignStore*/) const { //--------------------- // For Local: @@ -644,7 +646,8 @@ namespace InDetDD { } // New global alignment filders - bool TRT_DetectorManager::processGlobalAlignment(const std::string & key, int level, FrameType frame) const + bool TRT_DetectorManager::processGlobalAlignment(const std::string & key, int level, FrameType frame, + const CondAttrListCollection* /*obj*/, GeoVAlignmentStore* alignStore) const { bool alignmentChange = false; @@ -684,7 +687,8 @@ namespace InDetDD { bool status = setAlignableTransformDelta(level, ident, Amg::CLHEPTransformToEigen(newtransform), - frame); + frame, + alignStore); if (!status) { if (msgLvl(MSG::DEBUG)) { diff --git a/InnerDetector/InDetExample/InDetDetDescrExample/src/TestTRT_Alignment.cxx b/InnerDetector/InDetExample/InDetDetDescrExample/src/TestTRT_Alignment.cxx index f54a69312b2acb3af3f4f2c4bd0245d4f3ae1940..7389d13a7da4f92f1b15c836da56e18b3610d89e 100755 --- a/InnerDetector/InDetExample/InDetDetDescrExample/src/TestTRT_Alignment.cxx +++ b/InnerDetector/InDetExample/InDetDetDescrExample/src/TestTRT_Alignment.cxx @@ -147,7 +147,7 @@ TestTRT_Alignment::addShiftModule(int bec, int phiMod, int layer, const Amg::Tra void TestTRT_Alignment::addShift(int level, const Identifier & id, const Amg::Transform3D & transform) { - m_manager->setAlignableTransformDelta(level, id, transform, InDetDD::other); + m_manager->setAlignableTransformDelta(level, id, transform, InDetDD::other, nullptr); }