diff --git a/InnerDetector/InDetAlignAlgs/InDetAlignGenAlgs/InDetAlignGenAlgs/CreateMisalignAlg.h b/InnerDetector/InDetAlignAlgs/InDetAlignGenAlgs/InDetAlignGenAlgs/CreateMisalignAlg.h index fa557709325821ce67b5e2651b7ee4fb957f5d59..a1b26e495740d05e12897ffa89a2628683bedf2c 100644 --- a/InnerDetector/InDetAlignAlgs/InDetAlignGenAlgs/InDetAlignGenAlgs/CreateMisalignAlg.h +++ b/InnerDetector/InDetAlignAlgs/InDetAlignGenAlgs/InDetAlignGenAlgs/CreateMisalignAlg.h @@ -30,6 +30,7 @@ #include "InDetAlignGenTools/IInDetAlignDBTool.h" #include "TRT_ConditionsServices/ITRT_AlignDbSvc.h" #include "InDetReadoutGeometry/SiDetectorElementCollection.h" +#include "InDetReadoutGeometry/TRT_DetElementContainer.h" #include "StoreGate/ReadCondHandleKey.h" //Forward declaration @@ -41,10 +42,6 @@ class PixelID; class SCT_ID; class TRT_ID; -namespace InDetDD { -class TRT_DetectorManager; -} - namespace InDetAlignment { class CreateMisalignAlg : public AthAlgorithm { @@ -70,13 +67,12 @@ private: const SCT_ID *m_sctIdHelper; const TRT_ID *m_trtIdHelper; - const InDetDD::TRT_DetectorManager *m_TRT_Manager; - ToolHandle< IInDetAlignDBTool > m_IDAlignDBTool; ServiceHandle<ITRT_AlignDbSvc> m_trtaligndbservice; SG::ReadCondHandleKey<InDetDD::SiDetectorElementCollection> m_pixelDetEleCollKey{this, "PixelDetEleCollKey", "PixelDetectorElementCollection", "Key of SiDetectorElementCollection for Pixel"}; SG::ReadCondHandleKey<InDetDD::SiDetectorElementCollection> m_SCTDetEleCollKey{this, "SCTDetEleCollKey", "SCT_DetectorElementCollection", "Key of SiDetectorElementCollection for SCT"}; + SG::ReadCondHandleKey<InDetDD::TRT_DetElementContainer> m_trtDetEleCollKey{this, "TRTDetEleCollKey", "TRT_DetElementContainer", "Key of TRT_DetElementContainer for TRT"}; // algorithm parameters, possible to declare at runtime std::string m_asciiFileNameBase; ///< filename basis for ASCII files with alignment constants diff --git a/InnerDetector/InDetAlignAlgs/InDetAlignGenAlgs/InDetAlignGenAlgs/InDetAlignCog.h b/InnerDetector/InDetAlignAlgs/InDetAlignGenAlgs/InDetAlignGenAlgs/InDetAlignCog.h index fbc11d5bd0fb840ade8d9d82f66cf766aa61b2e4..847fb902b696bc046f7107beb0d01d3186931f95 100644 --- a/InnerDetector/InDetAlignAlgs/InDetAlignGenAlgs/InDetAlignGenAlgs/InDetAlignCog.h +++ b/InnerDetector/InDetAlignAlgs/InDetAlignGenAlgs/InDetAlignGenAlgs/InDetAlignCog.h @@ -24,6 +24,7 @@ #include <EventPrimitives/EventPrimitives.h> #include "InDetReadoutGeometry/SiDetectorElementCollection.h" +#include "InDetReadoutGeometry/TRT_DetElementContainer.h" #include "StoreGate/ReadCondHandleKey.h" class PixelID; @@ -32,7 +33,7 @@ class TRT_ID; class ITRT_AlignDbSvc; namespace InDetDD { - class TRT_DetectorManager; + class TRT_BaseElement; class SiDetectorElement; } @@ -66,7 +67,7 @@ class InDetAlignCog : public AthAlgorithm { StatusCode getSiElements(const InDetDD::SiDetectorElementCollection*,const bool, InDetAlignCog::Params_t ¶ms); - StatusCode getTRT_Elements(const bool, InDetAlignCog::Params_t ¶ms); + StatusCode getTRT_Elements(const InDetDD::TRT_DetElementCollection*,const bool, InDetAlignCog::Params_t ¶ms); StatusCode shiftIDbyCog(); StatusCode addL1(); @@ -87,9 +88,6 @@ class InDetAlignCog : public AthAlgorithm { private: - - // managers - const InDetDD::TRT_DetectorManager *m_TRT_Manager; // helpers const PixelID *m_pixid; @@ -105,6 +103,7 @@ class InDetAlignCog : public AthAlgorithm { SG::ReadCondHandleKey<InDetDD::SiDetectorElementCollection> m_pixelDetEleCollKey{this, "PixelDetEleCollKey", "PixelDetectorElementCollection", "Key of SiDetectorElementCollection for Pixel"}; SG::ReadCondHandleKey<InDetDD::SiDetectorElementCollection> m_SCTDetEleCollKey{this, "SCTDetEleCollKey", "SCT_DetectorElementCollection", "Key of SiDetectorElementCollection for SCT"}; + SG::ReadCondHandleKey<InDetDD::TRT_DetElementContainer> m_trtDetEleContKey{this, "TRTDetEleContKey", "TRT_DetElementContainer", "Key of TRT_DetElementContainer for TRT"}; // Select which detectors will be considered for cog calculation int m_det; //!< Pixel=1, SCT=2, Pixel+SCT=12, TRT=3, all (silicon and TRT)=99 diff --git a/InnerDetector/InDetAlignAlgs/InDetAlignGenAlgs/src/CreateMisalignAlg.cxx b/InnerDetector/InDetAlignAlgs/InDetAlignGenAlgs/src/CreateMisalignAlg.cxx index bfd3bdf3c58aefd125bca5858da620ac8692d7dd..41f2b79d6d94a9da4c4c5442a520ffd80adba3a8 100644 --- a/InnerDetector/InDetAlignAlgs/InDetAlignGenAlgs/src/CreateMisalignAlg.cxx +++ b/InnerDetector/InDetAlignAlgs/InDetAlignGenAlgs/src/CreateMisalignAlg.cxx @@ -26,9 +26,9 @@ #include "InDetIdentifier/PixelID.h" #include "InDetIdentifier/SCT_ID.h" #include "InDetIdentifier/TRT_ID.h" -#include "InDetReadoutGeometry/TRT_DetectorManager.h" #include "InDetReadoutGeometry/SiDetectorElement.h" #include "InDetReadoutGeometry/TRT_DetElementCollection.h" +#include "InDetReadoutGeometry/TRT_BaseElement.h" #include "DetDescrConditions/AlignableTransform.h" #include "StoreGate/ReadCondHandleKey.h" @@ -51,7 +51,6 @@ namespace InDetAlignment m_pixelIdHelper(nullptr), m_sctIdHelper(nullptr), m_trtIdHelper(nullptr), - m_TRT_Manager(nullptr), m_IDAlignDBTool("InDetAlignDBTool"), m_trtaligndbservice("TRT_AlignDbSvc",name), m_asciiFileNameBase("MisalignmentSet"), @@ -127,9 +126,8 @@ namespace InDetAlignment // TRT ATH_CHECK(detStore()->retrieve(m_trtIdHelper, "TRT_ID")); ATH_CHECK(detStore()->retrieve(m_idHelper, "AtlasID")); - // TRT manager - ATH_CHECK(detStore()->retrieve(m_TRT_Manager, "TRT")); // ReadCondHandleKey + ATH_CHECK(m_trtDetEleCollKey.initialize()); ATH_CHECK(m_pixelDetEleCollKey.initialize()); ATH_CHECK(m_SCTDetEleCollKey.initialize()); // Retrieve the Histo Service @@ -360,13 +358,21 @@ namespace InDetAlignment //TODO: writing into the Identifier tree is undone for TRT (AthenaHashedID and HumanReadableID) std::map< Identifier, std::vector<double> > trtModulesWithCOG; + + // TRT_DetElementContainer->TRT_DetElementCollection for TRT + SG::ReadCondHandle<InDetDD::TRT_DetElementContainer> trtDetEleHandle(m_trtDetEleCollKey); + const InDetDD::TRT_DetElementCollection* elements(trtDetEleHandle->getElements()); + if (not trtDetEleHandle.isValid() or elements==nullptr) { + ATH_MSG_FATAL(m_trtDetEleCollKey.fullKey() << " is not available."); + return; + } InDetDD::TRT_DetElementCollection::const_iterator iter; //step through all detector elements (=strawlayers) and accumulate strawcenters per // element (with DB granularity, i.e. phi sectors in endcap, bi-modules in barrel) - for (iter=m_TRT_Manager->getDetectorElementBegin(); iter!= m_TRT_Manager->getDetectorElementEnd(); ++iter) { - const Identifier TRTID_orig = (*iter)->identify(); + for (const InDetDD::TRT_BaseElement *element: *elements) { + const Identifier TRTID_orig = element->identify(); const Identifier TRTID = reduceTRTID(TRTID_orig); if (trtModulesWithCOG.find(TRTID) == trtModulesWithCOG.end()) { @@ -378,9 +384,9 @@ namespace InDetAlignment // msg(MSG::DEBUG) << "center of module: " << module_center.rho()/CLHEP::cm << ";" << module_center.phi() << ";" << module_center.z()/CLHEP::cm << endmsg; // msg(MSG::DEBUG) << "center of reduced module: " << module_center_reduced.rho()/CLHEP::cm << ";" << module_center_reduced.phi() << ";" << module_center_reduced.z()/CLHEP::cm << endmsg; - unsigned int nStraws = (*iter)->nStraws(); + unsigned int nStraws = element->nStraws(); for (unsigned int l = 0; l<nStraws; l++) { - const Amg::Vector3D strawcenter = (*iter)->strawCenter(l); + const Amg::Vector3D strawcenter = element->strawCenter(l); trtModulesWithCOG[TRTID].at(0) += strawcenter.x(); /*sumx*/ trtModulesWithCOG[TRTID].at(1) += strawcenter.y(); /*sumy*/ trtModulesWithCOG[TRTID].at(2) += strawcenter.z(); /*sumz*/ @@ -515,7 +521,7 @@ namespace InDetAlignment } else if (m_idHelper->is_sct(ModuleID)) { const IdentifierHash SCT_ModuleHash = m_sctIdHelper->wafer_hash(ModuleID); SiModule = sctElements->getDetectorElement(SCT_ModuleHash); - //module = SiModule; + //module = SiModule;OB } else if (m_idHelper->is_trt(ModuleID)) { //module = m_TRT_Manager->getElement(ModuleID); //const InDetDD::TRT_BaseElement *p_TRT_Module = m_TRT_Manager->getElement(iter->second.moduleID()); diff --git a/InnerDetector/InDetAlignAlgs/InDetAlignGenAlgs/src/InDetAlignCog.cxx b/InnerDetector/InDetAlignAlgs/InDetAlignGenAlgs/src/InDetAlignCog.cxx index e6541db30466325f32c9f7b94463e8ddd2da4988..13a94fe9e0b35a9b98cad78f5eb530a6baa18969 100644 --- a/InnerDetector/InDetAlignAlgs/InDetAlignGenAlgs/src/InDetAlignCog.cxx +++ b/InnerDetector/InDetAlignAlgs/InDetAlignGenAlgs/src/InDetAlignCog.cxx @@ -82,7 +82,6 @@ static const double onemrad = 0.001; InDetAlignCog::InDetAlignCog(const std::string& name, ISvcLocator* pSvcLocator) : AthAlgorithm(name, pSvcLocator), - m_TRT_Manager(0), m_pixid(0), m_sctid(0), m_trtid(0), @@ -201,9 +200,7 @@ StatusCode InDetAlignCog::initialize(){ // get SCT helper ATH_CHECK( detStore()->retrieve(m_sctid)); - // get TRT manager and helper - ATH_CHECK( detStore()->retrieve(m_TRT_Manager, "TRT")); - + // get TRT helper ATH_CHECK( detStore()->retrieve(m_trtid)); // Get InDetAlignDBTool @@ -214,6 +211,7 @@ StatusCode InDetAlignCog::initialize(){ ATH_CHECK( m_TRTAlignDbTool.retrieve() ); // ReadCondHandleKey + ATH_CHECK(m_trtDetEleContKey.initialize(m_det==99 || m_det==3)); ATH_CHECK(m_pixelDetEleCollKey.initialize(m_det==99 || m_det==1 || m_det==12)); ATH_CHECK(m_SCTDetEleCollKey.initialize(m_det==99 || m_det==2 || m_det==12)); @@ -249,6 +247,16 @@ StatusCode InDetAlignCog::execute() { } } + const InDetDD::TRT_DetElementCollection* trtElements(nullptr); + if (m_det==99 || m_det==3) { + SG::ReadCondHandle<InDetDD::TRT_DetElementContainer> trtDetEleHandle(m_trtDetEleContKey); + trtElements = trtDetEleHandle->getElements(); + if (not trtDetEleHandle.isValid() or trtElements==nullptr) { + ATH_MSG_FATAL(m_trtDetEleContKey.fullKey() << " is not available."); + return StatusCode::FAILURE; + } + } + if (m_firstEvent) { m_firstEvent = false; m_counter = 0; @@ -271,7 +279,7 @@ StatusCode InDetAlignCog::execute() { //StatusCode sc; if(m_det==99 || m_det==1 || m_det==12) ATH_CHECK( getSiElements(pixelElements,false,params) ); if(m_det==99 || m_det==2 || m_det==12) ATH_CHECK( getSiElements(sctElements,false,params) ); - if(m_det==99 || m_det==3) ATH_CHECK( getTRT_Elements(false, params) ); + if(m_det==99 || m_det==3) ATH_CHECK( getTRT_Elements(trtElements,false, params) ); //if(sc.isFailure()) // ATH_MSG_ERROR( "Problem getting elements from managers" ); if( !m_useChi2 ) { @@ -333,7 +341,7 @@ StatusCode InDetAlignCog::execute() { // second loop to compute residual transform after substracting cog if(m_det==99 || m_det==1 || m_det==12) ATH_CHECK( getSiElements(pixelElements,true, params) ); if(m_det==99 || m_det==2 || m_det==12) ATH_CHECK( getSiElements(sctElements,true, params) ); - if(m_det==99 || m_det==3) ATH_CHECK( getTRT_Elements(true, params) ); + if(m_det==99 || m_det==3) ATH_CHECK( getTRT_Elements(trtElements,true, params) ); // if(sc.isFailure()) // ATH_MSG_ERROR( "Problem getting elements from managers" ); if( !m_useChi2 ) { @@ -571,28 +579,27 @@ StatusCode InDetAlignCog::getSiElements(const InDetDD::SiDetectorElementCollecti // // The 'level-1' transform is a transform per module. //=================================================== -StatusCode InDetAlignCog::getTRT_Elements(bool cog_already_calculated, InDetAlignCog::Params_t ¶ms){ +StatusCode InDetAlignCog::getTRT_Elements(const InDetDD::TRT_DetElementCollection *elements,bool cog_already_calculated, InDetAlignCog::Params_t ¶ms){ ATH_MSG_DEBUG( "in getTRT_Elements " ); - TRT_ID::const_id_iterator moduleIter; - for(moduleIter=m_trtid->module_begin(); moduleIter!=m_trtid->module_end(); moduleIter++){ - Identifier id = *moduleIter; - - int bec = m_trtid->barrel_ec(id); - int phi_module = m_trtid->phi_module(id); - int layer_wheel = m_trtid->layer_or_wheel(id); - int straw_layer = m_trtid->straw_layer(id); - // perform selections - if(m_TRT_bec!=99 && bec!=m_TRT_bec) continue; - if(m_TRT_layer!=99 && layer_wheel!=m_TRT_layer) continue; - - // Skip A Side of - if(bec == 1) continue; + for (const InDetDD::TRT_BaseElement *element: *elements) { + // @TODO can element be null ? + if (element) { + Identifier id = element->identify(); - const InDetDD::TRT_BaseElement *element = m_TRT_Manager->getElement(id); + int bec = m_trtid->barrel_ec(id); + int phi_module = m_trtid->phi_module(id); + int layer_wheel = m_trtid->layer_or_wheel(id); + int straw_layer = m_trtid->straw_layer(id); - if(element){ + // perform selections + if(m_TRT_bec!=99 && bec!=m_TRT_bec) continue; + if(m_TRT_layer!=99 && layer_wheel!=m_TRT_layer) continue; + + // Skip A Side of + if(bec == 1) continue; + ATH_MSG_VERBOSE(std::setw(4) << m_counter << " Module " << m_trtid->show_to_string(id) ); diff --git a/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/TRTAlignCondAlg.cxx b/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/TRTAlignCondAlg.cxx index d00d7a84738326bc731abd2b5cdfaa2473d84a3b..6c3d80fe3a54612a9cb87869e6c12fb683427b89 100644 --- a/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/TRTAlignCondAlg.cxx +++ b/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/TRTAlignCondAlg.cxx @@ -1,26 +1,21 @@ /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ + +#include "TrkSurfaces/Surface.h" +// Gaudi +#include "GaudiKernel/MsgStream.h" + #include "TRTAlignCondAlg.h" #include "InDetReadoutGeometry/TRT_DetectorManager.h" TRTAlignCondAlg::TRTAlignCondAlg(const std::string& name , ISvcLocator* pSvcLocator ) : ::AthAlgorithm(name,pSvcLocator) - , m_readKeyDynamicGlobal("/TRT/AlignL1/TRT") - , m_readKeyDynamicRegular("/TRT/AlignL2") - , m_readKeyRegular("/TRT/Align") - , m_writeKey("TRTAlignmentStore","TRTAlignmentStore") , m_condSvc("CondSvc",name) , m_detManager(nullptr) - , m_useDynamicFolders(false) { - declareProperty("ReadKeyDynamicGlobal",m_readKeyDynamicGlobal); - declareProperty("ReadKeyDynamicRegular",m_readKeyDynamicRegular); - declareProperty("ReadKeyRegular",m_readKeyRegular); - declareProperty("WriteKey",m_writeKey); - declareProperty("UseDynamicFolders",m_useDynamicFolders); } TRTAlignCondAlg::~TRTAlignCondAlg() @@ -34,23 +29,24 @@ StatusCode TRTAlignCondAlg::initialize() // CondSvc ATH_CHECK( m_condSvc.retrieve() ); - // Read Condition Handles - if(m_useDynamicFolders) { - ATH_CHECK( m_readKeyDynamicGlobal.initialize() ); - ATH_CHECK( m_readKeyDynamicRegular.initialize() ); - m_readKeyRegular = std::string(""); - } + // Read Condition Handles initialize + ATH_CHECK( m_readKeyRegular.initialize(!m_useDynamicFolders.value()) ); + ATH_CHECK( m_readKeyDynamicGlobal.initialize(m_useDynamicFolders.value()) ); + ATH_CHECK( m_readKeyDynamicRegular.initialize(m_useDynamicFolders.value()) ); - else { - m_readKeyDynamicGlobal = std::string(""); - m_readKeyDynamicRegular = std::string(""); - ATH_CHECK( m_readKeyRegular.initialize() ); + // Write condition handles initialize + ATH_CHECK( m_writeKeyAlignStore.initialize() ); + ATH_CHECK( m_writeKeyDetElCont.initialize() ); + + // Register write handle + if (m_condSvc->regHandle(this, m_writeKeyAlignStore).isFailure()) { + ATH_MSG_ERROR("unable to register WriteCondHandle " << m_writeKeyAlignStore.fullKey() << " with CondSvc"); + return StatusCode::FAILURE; } - ATH_CHECK( m_writeKey.initialize() ); // Register write handle - if (m_condSvc->regHandle(this, m_writeKey).isFailure()) { - ATH_MSG_ERROR("unable to register WriteCondHandle " << m_writeKey.fullKey() << " with CondSvc"); + if (m_condSvc->regHandle(this, m_writeKeyDetElCont).isFailure()) { + ATH_MSG_ERROR("unable to register WriteCondHandle " << m_writeKeyDetElCont.fullKey() << " with CondSvc"); return StatusCode::FAILURE; } @@ -63,17 +59,23 @@ StatusCode TRTAlignCondAlg::execute() { ATH_MSG_DEBUG("execute " << name()); - // ____________ Construct Write Cond Handle and check its validity ____________ - SG::WriteCondHandle<GeoAlignmentStore> writeHandle{m_writeKey}; + // ____________ Construct Write Cond Handles and check their validity ____________ + SG::WriteCondHandle<GeoAlignmentStore> writeHandle{m_writeKeyAlignStore}; + SG::WriteCondHandle<InDetDD::TRT_DetElementContainer> writeHandleDetElCont{m_writeKeyDetElCont}; + + if (writeHandleDetElCont.isValid()) { + ATH_MSG_DEBUG("CondHandle " << writeHandleDetElCont.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; + } - // Do we have a valid Write Cond Handle for current time? if(writeHandle.isValid()) { // in theory this should never be called in MT //writeHandle.updateStore(); 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; } @@ -85,6 +87,12 @@ StatusCode TRTAlignCondAlg::execute() // Container for passing read CDO-s over to the Detector Manager InDetDD::RawAlignmentObjects readCdoContainer; + const InDetDD::TRT_DetElementCollection* unAlignedColl{m_detManager->getDetectorElementCollection()}; + if (unAlignedColl==nullptr) { + ATH_MSG_FATAL("Null pointer is returned by getDetectorElementCollection()"); + return StatusCode::FAILURE; + } + if(m_useDynamicFolders) { // 1. Dynamic folders @@ -150,10 +158,101 @@ StatusCode TRTAlignCondAlg::execute() // ____________ Apply alignments to TRT GeoModel ____________ if(m_detManager->align(readCdoContainer,writeCdo).isFailure()) { ATH_MSG_ERROR("Failed to apply alignments to TRT"); - delete writeCdo; + //delete writeCdo; return StatusCode::FAILURE; } + + const InDetDD::TRT_DetElementCollection* alignedColl{m_detManager->getDetectorElementCollection()}; + if (alignedColl==nullptr) { + ATH_MSG_FATAL("Null pointer is returned by getDetectorElementCollection()"); + return StatusCode::FAILURE; + } + + // ____________ Construct new Write Cond Object ____________ + std::unique_ptr<InDetDD::TRT_DetElementContainer> writeCdoDetElCont{std::make_unique<InDetDD::TRT_DetElementContainer>()}; + + // ____________ Update writeCdo using readCdo ____________ + std::map<const InDetDD::TRT_BaseElement*, const InDetDD::TRT_BaseElement*> oldToNewMap; + std::map<const InDetDD::TRT_BaseElement*, const InDetDD::TRT_EndcapElement*> oldToOldECMap; + std::map<const InDetDD::TRT_BaseElement*, const InDetDD::TRT_BarrelElement*> oldToOldBAMap; + + + oldToNewMap[nullptr] = nullptr; + oldToOldECMap[nullptr] = nullptr; + oldToOldBAMap[nullptr] = nullptr; + + InDetDD::TRT_DetElementCollection* newDetElColl=new InDetDD::TRT_DetElementCollection(); + + newDetElColl->resize(alignedColl->size(), nullptr); + + //Will create a new aligned detector element collection + InDetDD::TRT_DetElementCollection::iterator newEl{newDetElColl->begin()}; + for (const InDetDD::TRT_BaseElement* oldEl: *alignedColl) { + + InDetDD::TRT_BaseElement::Type type = oldEl->type(); + + if(type == InDetDD::TRT_BaseElement::ENDCAP) + { + const InDetDD::TRT_EndcapElement* oldEl_Endcap = dynamic_cast<const InDetDD::TRT_EndcapElement*>(oldEl); + //New encap element with new alignment created based on old element + *newEl = new InDetDD::TRT_EndcapElement(*oldEl_Endcap,writeCdo); + oldToNewMap[oldEl]= *newEl; + oldToOldECMap[oldEl]= oldEl_Endcap; + + }else if(type == InDetDD::TRT_BaseElement::BARREL){ + const InDetDD::TRT_BarrelElement* oldEl_Barrel = dynamic_cast<const InDetDD::TRT_BarrelElement*>(oldEl); + //New barrel element with new alignment created based on old element + *newEl = new InDetDD::TRT_BarrelElement(*oldEl_Barrel,writeCdo); + oldToNewMap[oldEl]= *newEl; + oldToOldBAMap[oldEl]= oldEl_Barrel; + + }else{ + ATH_MSG_FATAL("Unknown TRT detector element found"); + return StatusCode::FAILURE; + } + newEl++; + } + + //Set detector elements links + InDetDD::TRT_DetElementCollection::const_iterator oldIt{alignedColl->begin()}; + for (InDetDD::TRT_BaseElement* newEl: *newDetElColl) { + if (oldToNewMap[(*oldIt)]!=newEl) { + ATH_MSG_ERROR("Old and new elements are not synchronized!"); + } + InDetDD::TRT_BaseElement::Type type = newEl->type(); + if(type == InDetDD::TRT_BaseElement::ENDCAP){ + InDetDD::TRT_EndcapElement* newEl_Endcap = dynamic_cast<InDetDD::TRT_EndcapElement*>(newEl); + newEl_Endcap->setNextInZ(oldToOldECMap[(*oldIt)]->nextInZ()); + newEl_Endcap->setPreviousInZ(oldToOldECMap[(*oldIt)]->previousInZ()); + newEl = newEl_Endcap; + }else if(type == InDetDD::TRT_BaseElement::BARREL){ + InDetDD::TRT_BarrelElement* newEl_Barrel = dynamic_cast<InDetDD::TRT_BarrelElement*>(newEl); + newEl_Barrel->setNextInR(oldToOldBAMap[(*oldIt)]->nextInR()); + newEl_Barrel->setPreviousInR(oldToOldBAMap[(*oldIt)]->previousInR()); + newEl_Barrel->setNextInPhi(oldToOldBAMap[(*oldIt)]->nextInPhi()); + newEl_Barrel->setPreviousInPhi(oldToOldBAMap[(*oldIt)]->previousInPhi()); + newEl = newEl_Barrel; + } + oldIt++; + } + + // Update all detector elements caches and add aligned det elements to the corresponding array based on their type + for (InDetDD::TRT_BaseElement* newEl: *newDetElColl) { + newEl->updateAllCaches(); + InDetDD::TRT_BaseElement::Type type = newEl->type(); + if(type == InDetDD::TRT_BaseElement::ENDCAP){ + InDetDD::TRT_EndcapElement* newEl_Endcap = dynamic_cast<InDetDD::TRT_EndcapElement*>(newEl); + writeCdoDetElCont->addEndcapElement(newEl_Endcap); + }else if(type == InDetDD::TRT_BaseElement::BARREL){ + InDetDD::TRT_BarrelElement* newEl_Barrel = dynamic_cast<InDetDD::TRT_BarrelElement*>(newEl); + writeCdoDetElCont->addBarrelElement(newEl_Barrel); + } + } + + writeCdoDetElCont->setDetElementCollection(newDetElColl); + writeCdoDetElCont->setNumerology(m_detManager->getNumerology()); + // Record the resulting CDO if(writeHandle.record(rangeW,writeCdo).isFailure()) { ATH_MSG_ERROR("Could not record GeoAlignmentStore " << writeHandle.key() @@ -164,6 +263,17 @@ StatusCode TRTAlignCondAlg::execute() } ATH_MSG_INFO("recorded new CDO " << writeHandle.key() << " with range " << rangeW << " into Conditions Store"); + // Record WriteCondHandle (size is meaning less here?) + const std::size_t size{newDetElColl->size()}; + + if (writeHandleDetElCont.record(rangeW, std::move(writeCdoDetElCont)).isFailure()) { + ATH_MSG_FATAL("Could not record " << writeHandleDetElCont.key() + << " with EventRange " << rangeW + << " into Conditions Store"); + return StatusCode::FAILURE; + } + ATH_MSG_INFO("recorded new CDO " << writeHandleDetElCont.key() << " with range " << rangeW << " with size of " << size << " into Conditions Store"); + return StatusCode::SUCCESS; } diff --git a/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/TRTAlignCondAlg.h b/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/TRTAlignCondAlg.h index 9826d845d160189ae77bce9c03c1c0a8f0647c8d..1cdf690634765ca2e36d0a5e9c65779b80c8632f 100644 --- a/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/TRTAlignCondAlg.h +++ b/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/TRTAlignCondAlg.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef TRTCONDITIONSALGS_TRTALIGNCONDALG_H @@ -8,13 +8,15 @@ #include "AthenaBaseComps/AthAlgorithm.h" #include "StoreGate/ReadCondHandleKey.h" #include "StoreGate/WriteCondHandleKey.h" - +#include "InDetReadoutGeometry/TRT_DetElementCollection.h" +#include "InDetReadoutGeometry/TRT_DetElementContainer.h" #include "GaudiKernel/ICondSvc.h" #include "AthenaPoolUtilities/CondAttrListCollection.h" #include "DetDescrConditions/AlignableTransformContainer.h" #include "GeoModelUtilities/GeoAlignmentStore.h" + namespace InDetDD { class TRT_DetectorManager; } @@ -30,15 +32,17 @@ class TRTAlignCondAlg : public AthAlgorithm virtual StatusCode finalize() override; private: - SG::ReadCondHandleKey<CondAttrListCollection> m_readKeyDynamicGlobal; - SG::ReadCondHandleKey<AlignableTransformContainer> m_readKeyDynamicRegular; - SG::ReadCondHandleKey<AlignableTransformContainer> m_readKeyRegular; - SG::WriteCondHandleKey<GeoAlignmentStore> m_writeKey; + SG::ReadCondHandleKey<CondAttrListCollection> m_readKeyDynamicGlobal{this, "ReadKeyDynamicGlobal","/TRT/AlignL1/TRT","Read handle for global alignment conditions"}; + SG::ReadCondHandleKey<AlignableTransformContainer> m_readKeyDynamicRegular{this, "ReadKeyDynamicRegular","/TRT/AlignL2","Read handle for Dynamic Alignable transform containers"}; + SG::ReadCondHandleKey<AlignableTransformContainer> m_readKeyRegular{this, "ReadKeyRegular","/TRT/Align","Read handle for Static Alignable transform containers"}; + SG::WriteCondHandleKey<GeoAlignmentStore> m_writeKeyAlignStore{this,"WriteKeyAlignStore","GeoAlignmentStore","Write handle key to store GeoAlignmentStore constants"}; + SG::WriteCondHandleKey<InDetDD::TRT_DetElementContainer> m_writeKeyDetElCont{this, "WriteKeyDetElCont", "TRT_DetElementContainer", "Key of output to store detector element structures for TRT"}; ServiceHandle<ICondSvc> m_condSvc; const InDetDD::TRT_DetectorManager* m_detManager; - bool m_useDynamicFolders; + //bool m_useDynamicFolders; + Gaudi::Property<bool> m_useDynamicFolders{ this, "UseDynamicFolders", false, "Turn on-off use of Dynamic folders" }; }; #endif diff --git a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/TRT_BarrelElement.h b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/TRT_BarrelElement.h index 4ef4b18957f6870fa662ac312d9bd4887b962c0f..724d56d3fe426377cf0bba1e9c9ed06669f776dc 100755 --- a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/TRT_BarrelElement.h +++ b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/TRT_BarrelElement.h @@ -53,7 +53,11 @@ namespace InDetDD { unsigned int phiIndex, unsigned int strawLayIndex, const TRT_ID * idHelper, - const TRT_Conditions * conditions); + const TRT_Conditions * conditions, + const GeoAlignmentStore* geoAlignStore=nullptr); + + + TRT_BarrelElement(const TRT_BarrelElement &right, const GeoAlignmentStore* geoAlignStore); /** Destructor: */ virtual ~TRT_BarrelElement(); diff --git a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/TRT_BaseElement.h b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/TRT_BaseElement.h index 9212062630613c8552fe009f8fa0b90245ef0665..386ea063b097a9fe2759cf7f335605f9f04806df 100755 --- a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/TRT_BaseElement.h +++ b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/TRT_BaseElement.h @@ -34,6 +34,7 @@ namespace Trk { class TRT_ID; +class GeoAlignmentStore; namespace InDetDD { @@ -59,11 +60,13 @@ namespace InDetDD { enum Type {BARREL, ENDCAP}; /** Constructor: */ - TRT_BaseElement(const GeoVFullPhysVol *volume, const Identifier& id, const TRT_ID* idHelper, const TRT_Conditions* conditions); + TRT_BaseElement(const GeoVFullPhysVol *volume, const Identifier& id, const TRT_ID* idHelper, const TRT_Conditions* conditions, const GeoAlignmentStore* geoAlignStore=nullptr); + + TRT_BaseElement(const TRT_BaseElement&right, const GeoAlignmentStore* geoAlignStore); /** Destructor: */ virtual ~TRT_BaseElement(); - + /** Type information: returns BARREL or ENDCAP */ virtual TRT_BaseElement::Type type() const = 0; @@ -230,8 +233,8 @@ namespace InDetDD { const TRT_Conditions* m_conditions; // Amg cache for the straw surfaces - mutable std::atomic<std::vector<Trk::StraightLineSurface*>*> m_strawSurfaces; - mutable std::atomic<std::vector<SurfaceCache*>*> m_strawSurfacesCache; + mutable std::atomic<std::vector<Trk::StraightLineSurface*>*> m_strawSurfaces{}; + mutable std::atomic<std::vector<SurfaceCache*>*> m_strawSurfacesCache{}; //!< helper element surface for the cache CxxUtils::CachedUniquePtr<SurfaceCache> m_surfaceCache; @@ -240,6 +243,9 @@ namespace InDetDD { mutable std::vector<const Trk::Surface*> m_surfaces ATLAS_THREAD_SAFE; // Guarded by m_mutex mutable std::mutex m_mutex; + + const GeoAlignmentStore* m_geoAlignStore{}; + }; } diff --git a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/TRT_DetElementCollection.h b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/TRT_DetElementCollection.h index c85a8381727930d91b301807fc2b844e086dfeb4..008a8761d2913539af99247111b50cec822b9930 100755 --- a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/TRT_DetElementCollection.h +++ b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/TRT_DetElementCollection.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -13,16 +13,29 @@ #define INDETREADOUTGEOMETRY_TRT_DETELEMENTCOLLECTION_H #include <vector> +#include "InDetIdentifier/TRT_ID.h" + +class IdentifierHash; +class Identifier; namespace InDetDD { -class TRT_BaseElement; + class TRT_BaseElement; + + /// Class to hold collection of TRT detector elements. -/// Class to hold collection of TRT detector elements. + class TRT_DetElementCollection : public std::vector<TRT_BaseElement *> + { + public: -class TRT_DetElementCollection : public std::vector<const TRT_BaseElement *> -{}; + const TRT_BaseElement* getDetectorElement(IdentifierHash& hash) const; + }; } // namespace InDetDD +#include "AthenaKernel/CLASS_DEF.h" +CLASS_DEF( InDetDD::TRT_DetElementCollection , 1136885219, 1 ) +#include "AthenaKernel/CondCont.h" +CONDCONT_DEF( InDetDD::TRT_DetElementCollection, 1334649756 ); + #endif // INDETREADOUTGEOMETRY_TRT_DETELEMENTCOLLECTION_H diff --git a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/TRT_DetElementContainer.h b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/TRT_DetElementContainer.h new file mode 100755 index 0000000000000000000000000000000000000000..bf4a2dbe8c1802f47c53ea7e73dc80ccaddaa627 --- /dev/null +++ b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/TRT_DetElementContainer.h @@ -0,0 +1,73 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef INDETREADOUTGEOMETRY_TRT_DETELEMENTCONTAINER_H +#define INDETREADOUTGEOMETRY_TRT_DETELEMENTCONTAINER_H + +#include "TRT_DetElementCollection.h" +#include "TRT_Numerology.h" + +#include <vector> + +namespace InDetDD { + +class TRT_BaseElement; +class TRT_BarrelElement; +class TRT_EndcapElement; +class TRT_Numerology; + +/// Class to hold different TRT detector elements structures. + +class TRT_DetElementContainer{ + + public: + + TRT_DetElementContainer(); + ~TRT_DetElementContainer(); + + void setDetElementCollection(TRT_DetElementCollection* mytrtcoll); + + void setNumerology(const TRT_Numerology* mynum); + + void addBarrelElement(TRT_BarrelElement *element); + + void addEndcapElement(TRT_EndcapElement *element); + + const TRT_DetElementCollection* getElements() const; + + const TRT_Numerology* getTRTNumerology() const; + + const TRT_EndcapElement *getEndcapDetElement(unsigned int positive, + unsigned int wheelIndex, + unsigned int strawLayerIndex, + unsigned int phiIndex) const; + const TRT_BarrelElement *getBarrelDetElement(unsigned int positive, + unsigned int moduleIndex, + unsigned int phiIndex, + unsigned int strawLayerIndex) const; + + private: + + TRT_DetElementCollection* m_trtcoll; + const TRT_Numerology *m_trtnum; + + enum {NMODMAX=3}; + enum {NWHEELMAX=18}; + enum {NPHIMAX=32}; + enum {NSTRAWLAYMAXBR=30}; + enum {NSTRAWLAYMAXEC=16}; + + TRT_BarrelElement *m_baArray[2][NMODMAX][NPHIMAX][NSTRAWLAYMAXBR]; + TRT_EndcapElement *m_ecArray[2][NWHEELMAX][NSTRAWLAYMAXEC][NPHIMAX]; + +}; + +} // namespace InDetDD + +#include "AthenaKernel/CLASS_DEF.h" +CLASS_DEF( InDetDD::TRT_DetElementContainer , 1164489788, 1 ) +#include "AthenaKernel/CondCont.h" +CONDCONT_DEF( InDetDD::TRT_DetElementContainer, 1178261225 ); + +#endif // INDETREADOUTGEOMETRY_TRT_DETELEMENTCONTAINER_H diff --git a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/TRT_EndcapElement.h b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/TRT_EndcapElement.h index 351c969d8a2e300a8e9e536350ccaa854aabf597..81b1904e280a51a266fb2472c3f8f9bef73c1d05 100755 --- a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/TRT_EndcapElement.h +++ b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/TRT_EndcapElement.h @@ -52,7 +52,10 @@ namespace InDetDD { unsigned int strawLayIndex, unsigned int phiIndex, const TRT_ID * idHelper, - const TRT_Conditions * conditions); + const TRT_Conditions * conditions, + const GeoAlignmentStore* geoAlignStore=nullptr); + + TRT_EndcapElement(const TRT_EndcapElement &right, const GeoAlignmentStore* geoAlignStore); /** Destructor: */ virtual ~TRT_EndcapElement(); diff --git a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/TRT_BarrelElement.cxx b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/TRT_BarrelElement.cxx index 7d0888801822a75295b82cf9fe4d34085c1ec1b5..cebad27b5d2fa74c4e888c43fa20f2b5c75aa53a 100755 --- a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/TRT_BarrelElement.cxx +++ b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/TRT_BarrelElement.cxx @@ -17,6 +17,9 @@ #include "GeoPrimitives/CLHEPtoEigenConverter.h" +#include "GeoModelUtilities/GeoAlignmentStore.h" + + namespace InDetDD { TRT_BarrelElement::TRT_BarrelElement(const GeoVFullPhysVol *volume, @@ -26,26 +29,39 @@ TRT_BarrelElement::TRT_BarrelElement(const GeoVFullPhysVol *volume, unsigned int phiIndex, unsigned int strawLayIndex, const TRT_ID * idHelper, - const TRT_Conditions * conditions) + const TRT_Conditions * conditions, + const GeoAlignmentStore* geoAlignStore) : TRT_BaseElement(volume, idHelper->layer_id((isPositive ? 1:-1), phiIndex, modIndex, strawLayIndex), - idHelper, conditions), + idHelper, conditions, geoAlignStore), m_code(isPositive,modIndex,phiIndex,strawLayIndex), m_descriptor(descriptor), m_nextInPhi(NULL), m_previousInPhi(NULL), m_nextInR(NULL), m_previousInR(NULL) + { } + TRT_BarrelElement::TRT_BarrelElement(const TRT_BarrelElement &right, const GeoAlignmentStore* geoAlignStore) : + TRT_BaseElement(right,geoAlignStore) +{ + m_code = right.m_code; + m_descriptor = right.m_descriptor; + m_nextInPhi = right.m_nextInPhi; + m_previousInPhi = right.m_previousInPhi; + m_nextInR = right.m_nextInR; + m_previousInR = right.m_previousInR; + } + + TRT_BarrelElement::~TRT_BarrelElement() { } - const TRT_BarrelConditions * TRT_BarrelElement::getConditionsData() const { return NULL; diff --git a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/TRT_BaseElement.cxx b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/TRT_BaseElement.cxx index 433d1a346138745c30349ad33eb438564d9995e7..2fc40de7ef35e60b99c0d705f8f8d007cb3780e8 100755 --- a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/TRT_BaseElement.cxx +++ b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/TRT_BaseElement.cxx @@ -9,9 +9,11 @@ #include "CLHEP/Geometry/Transform3D.h" #include "CLHEP/Geometry/Point3D.h" #include "CLHEP/Geometry/Vector3D.h" +#include "GeoModelUtilities/GeoAlignmentStore.h" #include "GeoPrimitives/CLHEPtoEigenConverter.h" #include "InDetIdentifier/TRT_ID.h" +#include "GeoModelUtilities/GeoAlignmentStore.h" #include "TrkSurfaces/StraightLineSurface.h" #include "TrkSurfaces/Surface.h" @@ -21,7 +23,7 @@ namespace InDetDD { - TRT_BaseElement::TRT_BaseElement(const GeoVFullPhysVol *volume, const Identifier & id, const TRT_ID * idHelper, const TRT_Conditions * conditions) : + TRT_BaseElement::TRT_BaseElement(const GeoVFullPhysVol *volume, const Identifier & id, const TRT_ID * idHelper, const TRT_Conditions * conditions, const GeoAlignmentStore* geoAlignStore) : Trk::TrkDetElementBase(volume), m_id(id), m_idHelper(idHelper), @@ -31,11 +33,22 @@ namespace InDetDD { m_surfaceCache{}, m_surface{}, m_surfaces{}, - m_mutex{} + m_mutex{}, + m_geoAlignStore(geoAlignStore) { m_idHash = m_idHelper->straw_layer_hash(id); } + TRT_BaseElement::TRT_BaseElement(const TRT_BaseElement&right, const GeoAlignmentStore* geoAlignmentStore): + Trk::TrkDetElementBase(right.getMaterialGeom()), + m_geoAlignStore(geoAlignmentStore) + { + m_id = right.m_id; + m_idHash = right.m_idHash; + m_idHelper = right.m_idHelper; + m_conditions = right.m_conditions; + } + Identifier TRT_BaseElement::identify() const { return m_id; @@ -298,9 +311,9 @@ namespace InDetDD { // invalidates the cache, surface object can still live // for all straws - if (m_strawSurfacesCache) { + if (m_strawSurfacesCache.load()!=nullptr) { for (size_t i=0; i<m_strawSurfacesCache.load()->size(); i++) { - delete (*m_strawSurfacesCache)[i]; + delete (*m_strawSurfacesCache)[i]; (*m_strawSurfacesCache)[i] = 0; } } diff --git a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/TRT_DetElementCollection.cxx b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/TRT_DetElementCollection.cxx new file mode 100644 index 0000000000000000000000000000000000000000..b930bef65575290891dd86e5f835163b3666047c --- /dev/null +++ b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/TRT_DetElementCollection.cxx @@ -0,0 +1,15 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "InDetReadoutGeometry/TRT_DetElementCollection.h" + +#include "InDetReadoutGeometry/TRT_BaseElement.h" +#include "Identifier/IdentifierHash.h" + +const InDetDD::TRT_BaseElement* +InDetDD::TRT_DetElementCollection::getDetectorElement(IdentifierHash& hash) const { + unsigned int value{hash.value()}; + if (this->size()<=value) return nullptr; + return (*this)[value]; +} diff --git a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/TRT_DetElementContainer.cxx b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/TRT_DetElementContainer.cxx new file mode 100644 index 0000000000000000000000000000000000000000..780add1d322cd90d45971f552aa42275860e9382 --- /dev/null +++ b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/TRT_DetElementContainer.cxx @@ -0,0 +1,104 @@ + +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "InDetReadoutGeometry/TRT_DetElementContainer.h" +#include "InDetReadoutGeometry/TRT_BarrelElement.h" +#include "InDetReadoutGeometry/TRT_EndcapElement.h" + +namespace InDetDD{ + + TRT_DetElementContainer::TRT_DetElementContainer(): + m_trtcoll(nullptr), + m_trtnum(nullptr) + { + + for (unsigned int ec=0;ec<2;ec++) { + for (unsigned int mod=0;mod<NMODMAX;mod++) { + for (unsigned int phi=0; phi<NPHIMAX;phi++) { + for (unsigned int sLay=0;sLay<NSTRAWLAYMAXBR;sLay++) { + m_baArray[ec][mod][phi][sLay]=nullptr; + } + } + } + } + for (unsigned int ec=0;ec<2;ec++) { + for (unsigned int whe=0;whe<NWHEELMAX;whe++) { + for (unsigned int sLay=0;sLay<NSTRAWLAYMAXEC;sLay++) { + for(unsigned int phi=0;phi<NPHIMAX;phi++) { + m_ecArray[ec][whe][sLay][phi]=nullptr; + } + } + } + } + } + + + TRT_DetElementContainer::~TRT_DetElementContainer() + { + } + + + void TRT_DetElementContainer::setDetElementCollection(TRT_DetElementCollection* mytrtcoll) { + m_trtcoll=mytrtcoll; + } + + void TRT_DetElementContainer::setNumerology(const TRT_Numerology* mynum) { + m_trtnum=mynum; + } + + const TRT_DetElementCollection* TRT_DetElementContainer::getElements() const + { + return m_trtcoll; + } + + const TRT_Numerology* TRT_DetElementContainer::getTRTNumerology() const + { + return m_trtnum; + } + + const TRT_BarrelElement* TRT_DetElementContainer::getBarrelDetElement(unsigned int positive, + unsigned int moduleIndex, + unsigned int phiIndex, + unsigned int strawLayerIndex) const { + if ( positive >= 2 || moduleIndex >= NMODMAX + || phiIndex>=NPHIMAX || strawLayerIndex >= NSTRAWLAYMAXBR) return nullptr; + + return m_baArray[positive][moduleIndex][phiIndex][strawLayerIndex]; + } + + const TRT_EndcapElement* TRT_DetElementContainer::getEndcapDetElement(unsigned int positive, + unsigned int wheelIndex, + unsigned int strawLayerIndex, + unsigned int phiIndex) const { + + if ( positive >= 2 || wheelIndex >= NWHEELMAX + || phiIndex>=NPHIMAX || strawLayerIndex >= NSTRAWLAYMAXEC) return nullptr; + + return m_ecArray[positive][wheelIndex][strawLayerIndex][phiIndex]; + } + + void TRT_DetElementContainer::addBarrelElement(TRT_BarrelElement *barrel) + { + + m_baArray + [barrel->getCode().isPosZ()] + [barrel->getCode().getModuleIndex()] + [barrel->getCode().getPhiIndex()] + [barrel->getCode().getStrawLayerIndex()] + =barrel; + } + + void TRT_DetElementContainer::addEndcapElement(TRT_EndcapElement *endcap) + { + + m_ecArray + [endcap->getCode().isPosZ()] + [endcap->getCode().getWheelIndex()] + [endcap->getCode().getStrawLayerIndex()] + [endcap->getCode().getPhiIndex()] + =endcap; + } + +} diff --git a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/TRT_EndcapElement.cxx b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/TRT_EndcapElement.cxx index 41f325ffb090a9f6bf0eb452301b4ea93b75190c..ddbf79c0a716ee73b3f1e2b58695f16b3f120dbb 100755 --- a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/TRT_EndcapElement.cxx +++ b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/TRT_EndcapElement.cxx @@ -14,6 +14,7 @@ #include "GeoModelKernel/GeoDefinitions.h" #include "CLHEP/Geometry/Transform3D.h" +#include "GeoModelUtilities/GeoAlignmentStore.h" #include "TrkSurfaces/DiscBounds.h" #include "TrkSurfaces/DiscSurface.h" @@ -21,6 +22,8 @@ #include "TRT_ConditionsData/ExpandedIdentifier.h" #include "TRT_ConditionsData/StrawDxContainer.h" +#include "GeoModelUtilities/GeoAlignmentStore.h" + namespace InDetDD { @@ -31,10 +34,11 @@ namespace InDetDD { unsigned int strawLayIndex, unsigned int phiIndex, const TRT_ID * idHelper, - const TRT_Conditions * conditions) : + const TRT_Conditions * conditions, + const GeoAlignmentStore* geoAlignStore) : TRT_BaseElement(volume, idHelper->layer_id((isPositive ? 2:-2), phiIndex, wheelIndex, strawLayIndex), - idHelper, conditions), + idHelper, conditions, geoAlignStore), m_code(isPositive,wheelIndex,strawLayIndex,phiIndex), m_descriptor(descriptor), m_nextInZ(NULL), @@ -42,10 +46,17 @@ namespace InDetDD { { } + TRT_EndcapElement::TRT_EndcapElement(const TRT_EndcapElement &right, const GeoAlignmentStore* geoAlignStore) : + TRT_BaseElement(right,geoAlignStore) + { + m_code = right.m_code; + m_descriptor = right.m_descriptor; + m_nextInZ = right.m_nextInZ; + m_previousInZ = right.m_previousInZ; + } TRT_EndcapElement::~TRT_EndcapElement() - { - } + {} unsigned int TRT_EndcapElement::nStraws() const { diff --git a/InnerDetector/InDetExample/InDetRecExample/share/ConfiguredInDetPreProcessingTRT.py b/InnerDetector/InDetExample/InDetRecExample/share/ConfiguredInDetPreProcessingTRT.py index 291c6a5369e459bacc47a85f3768f9936a5b2752..ecd487bb3c9167eb8afe97caa8464058341f10bc 100644 --- a/InnerDetector/InDetExample/InDetRecExample/share/ConfiguredInDetPreProcessingTRT.py +++ b/InnerDetector/InDetExample/InDetRecExample/share/ConfiguredInDetPreProcessingTRT.py @@ -128,7 +128,6 @@ class ConfiguredInDetPreProcessingTRT: InDetTRT_DriftCircleTool = InDet__TRT_DriftCircleTool(name = prefix+"DriftCircleTool", TRTDriftFunctionTool = InDetTRT_DriftFunctionTool, - TrtDescrManageLocation = InDetKeys.TRT_Manager(), ConditionsSummaryTool = InDetTRTStrawStatusSummaryTool, UseConditionsStatus = True, UseConditionsHTStatus = True, diff --git a/InnerDetector/InDetRecTools/TRT_DetElementsRoadTool_xk/TRT_DetElementsRoadTool_xk/TRT_DetElementsRoadMaker_xk.h b/InnerDetector/InDetRecTools/TRT_DetElementsRoadTool_xk/TRT_DetElementsRoadTool_xk/TRT_DetElementsRoadMaker_xk.h index 8911f8844e61f2e1e8a18a92d83f2a03de92205f..82c1ed2d52ecbda67ba99bb392ba1b09428ff2b7 100755 --- a/InnerDetector/InDetRecTools/TRT_DetElementsRoadTool_xk/TRT_DetElementsRoadTool_xk/TRT_DetElementsRoadMaker_xk.h +++ b/InnerDetector/InDetRecTools/TRT_DetElementsRoadTool_xk/TRT_DetElementsRoadTool_xk/TRT_DetElementsRoadMaker_xk.h @@ -131,7 +131,9 @@ namespace InDet { Trk::CylinderBounds getBound(const Trk::TrackParameters&) const; MsgStream& dumpConditions(MsgStream & out) const; + MsgStream& dumpEvent (MsgStream & out, int size_road) const; + }; } // end of name space diff --git a/InnerDetector/InDetRecTools/TRT_DriftCircleOnTrackTool/src/TRT_DriftCircleOnTrackRecalibrateTool.cxx b/InnerDetector/InDetRecTools/TRT_DriftCircleOnTrackTool/src/TRT_DriftCircleOnTrackRecalibrateTool.cxx index 5d5e1db671d464c1bc31cff012aa7dd05778b149..6c667c6cccf16a6b50778069e3891405e324383e 100755 --- a/InnerDetector/InDetRecTools/TRT_DriftCircleOnTrackTool/src/TRT_DriftCircleOnTrackRecalibrateTool.cxx +++ b/InnerDetector/InDetRecTools/TRT_DriftCircleOnTrackTool/src/TRT_DriftCircleOnTrackRecalibrateTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -15,7 +15,7 @@ #include "InDetRIO_OnTrack/TRT_DriftCircleOnTrack.h" #include "TrkEventPrimitives/LocalParameters.h" #include "TRT_DriftFunctionTool/ITRT_DriftFunctionTool.h" -#include "InDetReadoutGeometry/TRT_DetectorManager.h" +#include "InDetReadoutGeometry/TRT_EndcapElement.h" #include "TrkRIO_OnTrack/check_cast.h" diff --git a/InnerDetector/InDetRecTools/TRT_DriftCircleOnTrackTool/src/TRT_DriftCircleOnTrackTool.cxx b/InnerDetector/InDetRecTools/TRT_DriftCircleOnTrackTool/src/TRT_DriftCircleOnTrackTool.cxx index 4f888f63829e91ddbfc9c24cf9a9e896c12246d0..3deca13a64afeafe6e2786999be1288cf75384af 100755 --- a/InnerDetector/InDetRecTools/TRT_DriftCircleOnTrackTool/src/TRT_DriftCircleOnTrackTool.cxx +++ b/InnerDetector/InDetRecTools/TRT_DriftCircleOnTrackTool/src/TRT_DriftCircleOnTrackTool.cxx @@ -13,7 +13,7 @@ /////////////////////////////////////////////////////////////////// #include "TRT_DriftCircleOnTrackTool/TRT_DriftCircleOnTrackTool.h" -#include "InDetReadoutGeometry/TRT_DetectorManager.h" +#include "InDetReadoutGeometry/TRT_EndcapElement.h" #include "TrkEventPrimitives/LocalParameters.h" #include "TrkRIO_OnTrack/check_cast.h" diff --git a/InnerDetector/InDetRecTools/TRT_DriftCircleTool/TRT_DriftCircleTool/TRT_DriftCircleTool.h b/InnerDetector/InDetRecTools/TRT_DriftCircleTool/TRT_DriftCircleTool/TRT_DriftCircleTool.h index f1a63aba74375b560334049f8db94b202ecaed2e..79ddf3b9caf5559251633577011e4a3b23143164 100755 --- a/InnerDetector/InDetRecTools/TRT_DriftCircleTool/TRT_DriftCircleTool/TRT_DriftCircleTool.h +++ b/InnerDetector/InDetRecTools/TRT_DriftCircleTool/TRT_DriftCircleTool/TRT_DriftCircleTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -23,9 +23,11 @@ #include "GaudiKernel/ToolHandle.h" #include "GaudiKernel/ServiceHandle.h" #include "TRT_ConditionsServices/ITRT_StrawStatusSummaryTool.h" +#include "InDetReadoutGeometry/TRT_DetElementContainer.h" #include "StoreGate/ReadHandleKey.h" #include "xAODEventInfo/EventInfo.h" + class ITRT_StrawSummaryTool; class ITRT_DriftFunctionTool; class IInDetConditionsSvc; @@ -33,9 +35,6 @@ class TRT_ID; class TRT_RDORawData; class TRT_DriftCircleCollection; class TRT_DriftCircle; -namespace InDetDD { - class TRT_DetectorManager; -} namespace InDet { @@ -76,6 +75,7 @@ public: // Private data: /////////////////////////////////////////////////////////////////// SG::ReadHandleKey<xAOD::EventInfo> m_eventInfoKey {this,"xAODEventInfoKey","EventInfo","RHK to retrieve xAOD::EventInfo" }; //!< key to retrieve eventinfo + SG::ReadCondHandleKey<InDetDD::TRT_DetElementContainer> m_trtDetEleContKey{this, "TRTDetEleContKey", "TRT_DetElementContainer", "Key of TRT_DetElementContainer for TRT"}; ToolHandle< ITRT_DriftFunctionTool > m_driftFunctionTool; //!< DriftFunctionTool ToolHandle<ITRT_StrawStatusSummaryTool> m_ConditionsSummary; //!< The ConditionsSummaryTool // ServiceHandle<ITRT_ConditionsSvc> m_ConditionsSummary; //!< The ConditionsSummaryTool @@ -84,8 +84,6 @@ public: bool m_useConditionsHTStatus; //!< Shall the ConditionsSummaryTool be used for HT to find argon straws? bool m_useToTCorrection; //!< Shall the Time over Threshold correction be used? bool m_useHTCorrection; //!< Shall the High Threshold correction be used? - std::string m_trt_mgr_location ; //!< Manager name - const InDetDD::TRT_DetectorManager * m_trt_mgr ; //!< Manager handle const TRT_ID * m_trtid ; //!< ID helper bool m_reject_if_first_bit; //!< If true, reject this DC if first bit high bool m_reject_if_first_bit_argon; //!< If true, reject this DC if first bit high diff --git a/InnerDetector/InDetRecTools/TRT_DriftCircleTool/TRT_DriftCircleTool/TRT_DriftCircleToolCosmics.h b/InnerDetector/InDetRecTools/TRT_DriftCircleTool/TRT_DriftCircleTool/TRT_DriftCircleToolCosmics.h index e0afd13d4de03ec4a7df9e1b0f17c00d6511ea3f..219ff72e8e8e00efd4dbd826527c9893d9fa7cec 100755 --- a/InnerDetector/InDetRecTools/TRT_DriftCircleTool/TRT_DriftCircleTool/TRT_DriftCircleToolCosmics.h +++ b/InnerDetector/InDetRecTools/TRT_DriftCircleTool/TRT_DriftCircleTool/TRT_DriftCircleToolCosmics.h @@ -23,6 +23,7 @@ #include "GaudiKernel/ToolHandle.h" #include "GaudiKernel/ServiceHandle.h" #include "TRT_ConditionsServices/ITRT_StrawStatusSummaryTool.h" +#include "InDetReadoutGeometry/TRT_DetElementContainer.h" #include "CommissionEvent/ComTime.h" #include "StoreGate/ReadHandleKey.h" @@ -32,9 +33,6 @@ class TRT_ID; class TRT_RDORawData; class TRT_DriftCircleCollection; class TRT_DriftCircle; -namespace InDetDD { - class TRT_DetectorManager; -} namespace InDet { @@ -73,15 +71,13 @@ public: // Private data: /////////////////////////////////////////////////////////////////// SG::ReadHandleKey<ComTime> m_evtPhaseKey {this,"TRT_Phase","TRT_Phase","RHK to retrieve TRT Phase"}; - + SG::ReadCondHandleKey<InDetDD::TRT_DetElementContainer> m_trtDetEleContKey{this, "TRTDetEleContKey", "TRT_DetElementContainer", "Key of TRT_DetElementContainer for TRT"}; ToolHandle< ITRT_DriftFunctionTool > m_driftFunctionTool; //!< DriftFunctionTool ToolHandle<ITRT_StrawStatusSummaryTool> m_ConditionsSummary; //!< The ConditionsSummaryTool bool m_useConditionsStatus; //!< SHall the ConditionsSummaryTool be used? bool m_useConditionsHTStatus; //!< Shall the ConditionsSummaryTool be used for HT to find argon straws? - std::string m_trt_mgr_location ; //!< Manager name - const InDetDD::TRT_DetectorManager * m_trt_mgr ; //!< Manager handle const TRT_ID * m_trtid ; //!< TRT id helper handle float m_global_offset ; //!< Global offset to TRT Phase to make TRT Calibration happy ... bool m_useToTCorrection; //!< Shall the Time over Threshold correction be used? diff --git a/InnerDetector/InDetRecTools/TRT_DriftCircleTool/src/TRT_DriftCircleTool.cxx b/InnerDetector/InDetRecTools/TRT_DriftCircleTool/src/TRT_DriftCircleTool.cxx index 986a6cf5512cea882d5e39c05f689c7ba2bab21b..5c6708e20f546f081f7d88cd53c4b0abc1bad82d 100755 --- a/InnerDetector/InDetRecTools/TRT_DriftCircleTool/src/TRT_DriftCircleTool.cxx +++ b/InnerDetector/InDetRecTools/TRT_DriftCircleTool/src/TRT_DriftCircleTool.cxx @@ -16,13 +16,11 @@ #include "GaudiKernel/DataSvc.h" #include "GaudiKernel/SmartDataPtr.h" #include "TRT_DriftCircleTool/TRT_DriftCircleTool.h" -#include "InDetReadoutGeometry/TRT_BaseElement.h" #include "InDetPrepRawData/TRT_DriftCircle.h" #include "InDetPrepRawData/TRT_DriftCircleCollection.h" #include "InDetRawData/TRT_RDORawData.h" #include "TRT_DriftFunctionTool/ITRT_DriftFunctionTool.h" -#include "InDetReadoutGeometry/TRT_DetectorManager.h" #include "InDetIdentifier/TRT_ID.h" #include "TRT_ConditionsServices/ITRT_StrawStatusSummaryTool.h" @@ -45,8 +43,6 @@ InDet::TRT_DriftCircleTool::TRT_DriftCircleTool(const std::string& t, m_useConditionsHTStatus(false), m_useToTCorrection(false), m_useHTCorrection(false), - m_trt_mgr_location("TRT"), - m_trt_mgr(0), m_trtid(0), m_reject_if_first_bit(false), m_reject_if_first_bit_argon(true), @@ -70,7 +66,6 @@ InDet::TRT_DriftCircleTool::TRT_DriftCircleTool(const std::string& t, m_mask_last_HT_bit_argon(false) { declareInterface<ITRT_DriftCircleTool>(this); - declareProperty("TrtDescrManageLocation",m_trt_mgr_location); declareProperty("TRTDriftFunctionTool", m_driftFunctionTool); declareProperty("ConditionsSummaryTool",m_ConditionsSummary); declareProperty("UseConditionsStatus",m_useConditionsStatus); @@ -134,15 +129,6 @@ StatusCode InDet::TRT_DriftCircleTool::initialize() } } - // Get TRT Detector Manager - // - sc = AthAlgTool::detStore()->retrieve(m_trt_mgr, m_trt_mgr_location); - if (sc.isFailure() || !m_trt_mgr) - { - ATH_MSG_FATAL( "Could not find TRT_DetectorManager: " - << m_trt_mgr_location << " !" ); - return sc; - } // Get TRT ID helper sc = detStore()->retrieve(m_trtid,"TRT_ID"); if ( sc.isFailure() ) { @@ -153,6 +139,9 @@ StatusCode InDet::TRT_DriftCircleTool::initialize() // Initialize readhandle key ATH_CHECK(m_eventInfoKey.initialize()); + // Initialize readCondHandle key + ATH_CHECK(m_trtDetEleContKey.initialize()); + return sc; } @@ -203,6 +192,13 @@ InDet::TRT_DriftCircleCollection* InDet::TRT_DriftCircleTool::convert(int Mode,c return rio; } + SG::ReadCondHandle<InDetDD::TRT_DetElementContainer> trtDetEleHandle(m_trtDetEleContKey); + const InDetDD::TRT_DetElementCollection* elements(trtDetEleHandle->getElements()); + if (not trtDetEleHandle.isValid() or elements==nullptr) { + ATH_MSG_FATAL(m_trtDetEleContKey.fullKey() << " is not available."); + return rio; + } + float mu = -10; SG::ReadHandle<xAOD::EventInfo> eventInfo(m_eventInfoKey); if (eventInfo.isValid()) { @@ -214,7 +210,7 @@ InDet::TRT_DriftCircleCollection* InDet::TRT_DriftCircleTool::convert(int Mode,c //Get the BaseElement and initialize the RIO collection IdentifierHash IHc = rdo ->identifyHash(); - const InDetDD::TRT_BaseElement* pE = m_trt_mgr->getElement(IHc); + const InDetDD::TRT_BaseElement* pE = elements->getDetectorElement(IHc); rio = new InDet::TRT_DriftCircleCollection(IHc); rio->setIdentifier(rdo->identify()); rio->reserve( std::distance(rb, re) ); diff --git a/InnerDetector/InDetRecTools/TRT_DriftCircleTool/src/TRT_DriftCircleToolCosmics.cxx b/InnerDetector/InDetRecTools/TRT_DriftCircleTool/src/TRT_DriftCircleToolCosmics.cxx index 13462f76942bf61ce7a6f2bbe7dfa61dca1ca7e0..b92a9dc251a2323fc572830c93a22d360d5ff41c 100755 --- a/InnerDetector/InDetRecTools/TRT_DriftCircleTool/src/TRT_DriftCircleToolCosmics.cxx +++ b/InnerDetector/InDetRecTools/TRT_DriftCircleTool/src/TRT_DriftCircleToolCosmics.cxx @@ -22,7 +22,6 @@ #include "InDetRawData/TRT_RDORawData.h" #include "TRT_DriftFunctionTool/ITRT_DriftFunctionTool.h" -#include "InDetReadoutGeometry/TRT_DetectorManager.h" #include "InDetIdentifier/TRT_ID.h" #include "InDetConditionsSummaryService/IInDetConditionsTool.h" @@ -47,8 +46,6 @@ InDet::TRT_DriftCircleToolCosmics::TRT_DriftCircleToolCosmics(const std::string& m_driftFunctionTool("TRT_DriftFunctionTool"), m_ConditionsSummary("TRT_StrawStatusSummaryTool",this), m_useConditionsStatus(false), - m_trt_mgr_location("TRT"), - m_trt_mgr(0), m_trtid(0), m_global_offset(0), m_useToTCorrection(false), @@ -76,7 +73,6 @@ InDet::TRT_DriftCircleToolCosmics::TRT_DriftCircleToolCosmics(const std::string& { declareInterface<ITRT_DriftCircleTool>(this); - declareProperty("TrtDescrManageLocation",m_trt_mgr_location); declareProperty("TRTDriftFunctionTool", m_driftFunctionTool); declareProperty("ConditionsSummaryTool",m_ConditionsSummary); declareProperty("UseConditionsStatus",m_useConditionsStatus); @@ -154,16 +150,6 @@ StatusCode InDet::TRT_DriftCircleToolCosmics::initialize() ATH_MSG_INFO(m_driftFunctionTool.propertyName() << ": Retrieved tool " << m_driftFunctionTool.type()); } - - // Get TRT Detector Manager - // - sc = AthAlgTool::detStore()->retrieve(m_trt_mgr, m_trt_mgr_location); - if (sc.isFailure() || !m_trt_mgr) - { - ATH_MSG_FATAL("Could not find TRT_DetectorManager: " - << m_trt_mgr_location << " !"); - return sc; - } // Get TRT ID helper sc = detStore()->retrieve(m_trtid,"TRT_ID"); if ( sc.isFailure() ) { @@ -182,6 +168,10 @@ StatusCode InDet::TRT_DriftCircleToolCosmics::initialize() // Initialize Read handle key ATH_CHECK(m_evtPhaseKey.initialize()); + + // Initialize readCondHandle key + ATH_CHECK(m_trtDetEleContKey.initialize()); + return sc; } @@ -211,7 +201,12 @@ InDet::TRT_DriftCircleCollection* InDet::TRT_DriftCircleToolCosmics::convert(int SG::ReadHandle<ComTime> theComTime(m_evtPhaseKey); - + SG::ReadCondHandle<InDetDD::TRT_DetElementContainer> trtDetEleHandle(m_trtDetEleContKey); + const InDetDD::TRT_DetElementCollection* elements(trtDetEleHandle->getElements()); + if (not trtDetEleHandle.isValid() or elements==nullptr) { + ATH_MSG_FATAL(m_trtDetEleContKey.fullKey() << " is not available."); + return rio; + } float timecor=0.; if (theComTime.isValid()) { @@ -228,7 +223,7 @@ InDet::TRT_DriftCircleCollection* InDet::TRT_DriftCircleToolCosmics::convert(int //Get the BaseElement and the rio of the collection IdentifierHash IHc = rdo ->identifyHash(); - const InDetDD::TRT_BaseElement* pE = m_trt_mgr->getElement(IHc); + const InDetDD::TRT_BaseElement* pE = elements->getDetectorElement(IHc); rio = new InDet::TRT_DriftCircleCollection(IHc); rio->setIdentifier(rdo->identify()); rio->reserve( std::distance(rb, re) ); diff --git a/InnerDetector/InDetRecTools/TRT_ToT_Tools/TRT_ToT_Tools/TRT_ToT_dEdx.h b/InnerDetector/InDetRecTools/TRT_ToT_Tools/TRT_ToT_Tools/TRT_ToT_dEdx.h index ae34900b8809ac24ed97e342318d4a19705ee91f..34b7777d004b639a6bc7e718cdb18d0c40f89951 100644 --- a/InnerDetector/InDetRecTools/TRT_ToT_Tools/TRT_ToT_Tools/TRT_ToT_dEdx.h +++ b/InnerDetector/InDetRecTools/TRT_ToT_Tools/TRT_ToT_Tools/TRT_ToT_dEdx.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef TRT_TOT_DEDX_H @@ -24,6 +24,7 @@ #include "StoreGate/ReadCondHandleKey.h" #include "xAODEventInfo/EventInfo.h" #include "TRT_ConditionsData/TRTDedxcorrection.h" +#include "InDetReadoutGeometry/TRT_DetElementContainer.h" /* @@ -40,9 +41,6 @@ class TRT_ID; class IChronoStatSvc; class ITRT_StrawSummaryTool; -namespace InDetDD { - class TRT_DetectorManager; -} //namespace InDet { // class TRT_DriftCircleOnTrack ; // } @@ -63,9 +61,9 @@ public: private: SG::ReadHandleKey<xAOD::EventInfo> m_eventInfoKey{this,"EventInfoKey","EventInfo","RHK to retrieve xAOD::EventInfo"}; + SG::ReadCondHandleKey<InDetDD::TRT_DetElementContainer> m_trtDetEleContKey{this, "TRTDetEleContKey", "TRT_DetElementContainer", "Key of TRT_DetElementContainer for TRT"}; const TRT_ID* m_trtId; // ID TRT helper Trk::ParticleMasses m_particlemasses; - const InDetDD::TRT_DetectorManager* m_trtman; // ID TRT detector manager // Algorithm switchers bool m_corrected; // If true - make correction using rs-distributions diff --git a/InnerDetector/InDetRecTools/TRT_ToT_Tools/src/TRT_ToT_dEdx.cxx b/InnerDetector/InDetRecTools/TRT_ToT_Tools/src/TRT_ToT_dEdx.cxx index 774254f423e669f9f1ab371f93f15edb20387090..a66db59a0d8726718d5f310c1bdc08b8e95242a5 100644 --- a/InnerDetector/InDetRecTools/TRT_ToT_Tools/src/TRT_ToT_dEdx.cxx +++ b/InnerDetector/InDetRecTools/TRT_ToT_Tools/src/TRT_ToT_dEdx.cxx @@ -14,7 +14,7 @@ #include "InDetIdentifier/TRT_ID.h" #include "InDetRIO_OnTrack/TRT_DriftCircleOnTrack.h" -#include "InDetReadoutGeometry/TRT_DetectorManager.h" + #include "TrkSurfaces/Surface.h" #include "xAODEventInfo/EventInfo.h" @@ -49,7 +49,6 @@ TRT_ToT_dEdx::TRT_ToT_dEdx(const std::string& t, const std::string& n, const IIn m_timingProfile = 0; m_trtId = 0; - m_trtman = 0; } @@ -113,12 +112,6 @@ StatusCode TRT_ToT_dEdx::initialize() return StatusCode::FAILURE; } - sc = detStore()->retrieve(m_trtman, "TRT"); - if (sc.isFailure()){ - ATH_MSG_ERROR ( "Could not get TRT detector manager !" ); - return StatusCode::FAILURE; - } - m_timingProfile=0; sc = service("ChronoStatSvc", m_timingProfile); if ( sc.isFailure() || 0 == m_timingProfile) { @@ -128,6 +121,7 @@ StatusCode TRT_ToT_dEdx::initialize() // Initialize ReadHandleKey and ReadCondHandleKey ATH_CHECK(m_eventInfoKey.initialize()); ATH_CHECK(m_ReadKey.initialize()); + ATH_CHECK(m_trtDetEleContKey.initialize()); sc = m_TRTStrawSummaryTool.retrieve(); if (StatusCode::SUCCESS!= sc ){ @@ -227,6 +221,14 @@ bool TRT_ToT_dEdx::isGood_Hit(const Trk::TrackStateOnSurface *itr, bool divideBy const Trk::TrackParameters* trkP = itr->trackParameters(); if(trkP==0)return false; + + SG::ReadCondHandle<InDetDD::TRT_DetElementContainer> trtDetEleHandle(m_trtDetEleContKey); + const InDetDD::TRT_DetElementCollection* elements(trtDetEleHandle->getElements()); + if (not trtDetEleHandle.isValid() or elements==nullptr) { + ATH_MSG_FATAL(m_trtDetEleContKey.fullKey() << " is not available."); + return false; + } + double Trt_Rtrack = fabs(trkP->parameters()[Trk::locR]); double Trt_RHit = fabs(driftcircle->localParameters()[Trk::driftRadius]); double Trt_HitTheta = trkP->parameters()[Trk::theta]; @@ -234,7 +236,10 @@ bool TRT_ToT_dEdx::isGood_Hit(const Trk::TrackStateOnSurface *itr, bool divideBy double error = sqrt(driftcircle->localCovariance()(Trk::driftRadius,Trk::driftRadius)); Identifier DCId = driftcircle->identify(); int HitPart = m_trtId->barrel_ec(DCId); - const InDetDD::TRT_BaseElement* element = m_trtman->getElement(DCId); + //IdentifierHash hashId = m_trtId->straw_layer_hash(DCId); + Identifier strawLayerId = m_trtId->layer_id(DCId); + IdentifierHash hashId = m_trtId->straw_layer_hash(strawLayerId); + const InDetDD::TRT_BaseElement* element = elements->getDetectorElement(hashId); double strawphi = element->center(DCId).phi(); if ( itr->type(Trk::TrackStateOnSurface::Outlier) ) return false; //Outliers