ATLAS Offline Software
PLR_IDDetDescrCnv.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /***************************************************************************
6  InDet DetDescrCnv package
7  -----------------------------------------
8  ***************************************************************************/
9 
10 #include "PLR_IDDetDescrCnv.h"
11 
14 #include "GaudiKernel/MsgStream.h"
15 #include "StoreGate/StoreGateSvc.h"
16 
19 #include "IdDict/IdDictMgr.h"
20 #include "InDetIdentifier/PLR_ID.h"
21 
22 //--------------------------------------------------------------------
23 
25  : DetDescrConverter(ClassID_traits<PLR_ID>::ID(), svcloc, "PLR_IDDetDescrCnv")
26 {}
27 
28 //--------------------------------------------------------------------
29 
30 long int
32 {
33  return storageType();
34 }
35 
36 //--------------------------------------------------------------------
37 
40 {
42  return StatusCode::SUCCESS;
43 }
44 
45 //--------------------------------------------------------------------
46 
48 PLR_IDDetDescrCnv::createObj(IOpaqueAddress* /*pAddr*/, DataObject*& pObj)
49 {
50  // Get the dictionary manager from the detector store
51  const IdDictManager* idDictMgr;
52  ATH_CHECK( detStore()->retrieve(idDictMgr, "IdDict") );
53 
54  // Only initialize helper if it is the first pass or if there is a
55  // change in the the file or tag
56  bool initHelper{};
57 
58  const IdDictMgr* mgr = idDictMgr->manager();
59 
60  // Internal InDet id tag
61  const std::string & inDetIDTag = mgr->tag();
62 
63  // DoChecks flag
64  bool doChecks = mgr->do_checks();
65 
66  IdDictDictionary* dict = mgr->find_dictionary("InnerDetector");
67  if (!dict) {
68  ATH_MSG_ERROR("unable to find idDict for InnerDetector");
69  return StatusCode::FAILURE;
70  }
71 
72  // File to be read for InDet ids
73  const std::string & inDetIDFileName = dict->file_name();
74 
75  // Tag of RDB record for InDet ids
76  const std::string & inDetIdDictTag = dict->dict_tag();
77 
78  // PLR id helper already exists - second pass. Check for a change
79  if (m_plrId) {
80  if (inDetIDTag != m_inDetIDTag) {
81  // Internal InDet id tag
82  initHelper = true;
83  ATH_MSG_DEBUG(" Changed internal InDet id tag: " << inDetIDTag);
84  }
85  if (inDetIDFileName != m_inDetIDFileName) {
86  // File to be read for InDet ids
87  initHelper = true;
88  ATH_MSG_DEBUG(" Changed InDetFileName: " << inDetIDFileName);
89  }
90  if (inDetIdDictTag != m_inDetIdDictTag) {
91  // Tag of RDB record for InDet ids
92  initHelper = true;
93  ATH_MSG_DEBUG(" Changed InDetIdDictTag: " << inDetIdDictTag);
94  }
95  if (doChecks != m_doChecks) {
96  // DoChecks flag
97  initHelper = true;
98  ATH_MSG_DEBUG(" Changed doChecks flag: " << doChecks);
99  }
100  } else {
101  // create the helper
102  m_plrId = new PLR_ID;
103  initHelper = true;
104  // add in message service for printout
106  }
107 
108  if (initHelper) {
109  ATH_CHECK( idDictMgr->initializeHelper(*m_plrId) == 0 );
110 
111  // Save state:
112  m_inDetIDTag = inDetIDTag;
113  m_inDetIDFileName = inDetIDFileName;
114  m_inDetIdDictTag = inDetIdDictTag;
115  m_doChecks = doChecks;
116  }
117 
118  // Pass a pointer to the container to the Persistency service by reference.
119  pObj = SG::asStorable(m_plrId);
120 
121  return StatusCode::SUCCESS;
122 }
123 
124 //--------------------------------------------------------------------
125 
126 long
128 {
129  return DetDescr_StorageType;
130 }
131 
132 //--------------------------------------------------------------------
133 const CLID&
135 {
137 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
PLR_IDDetDescrCnv::m_plrId
PLR_ID * m_plrId
The helper - only will create it once.
Definition: PLR_IDDetDescrCnv.h:41
IdDictMgr.h
AtlasDetectorID::setMessageSvc
virtual void setMessageSvc(IMessageSvc *msgSvc) override
Definition: AtlasDetectorID.cxx:491
DetDescr_StorageType
const long DetDescr_StorageType
Definition: DetDescrCnvSvc.cxx:20
ID
std::vector< Identifier > ID
Definition: CalibHitIDCheck.h:24
IdDictDictionary.h
initialize
void initialize()
Definition: run_EoverP.cxx:894
PLR_ID.h
PLR_ID
This is a Identifier helper class for the PLR subdetector. This class inherits from PixelID.
Definition: PLR_ID.h:22
DetDescrAddress.h
PLR_IDDetDescrCnv::m_inDetIDFileName
std::string m_inDetIDFileName
File to be read for InDet ids.
Definition: PLR_IDDetDescrCnv.h:44
PLR_IDDetDescrCnv.h
IdDictManager.h
IdDictDictionary::file_name
const std::string & file_name() const
Access to file name.
Definition: IdDictDictionary.h:367
DetDescrConverter::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Handle to DetectorStore.
Definition: DetDescrConverter.h:33
PLR_IDDetDescrCnv::storageType
static long storageType()
Definition: PLR_IDDetDescrCnv.cxx:127
BchCleanup.mgr
mgr
Definition: BchCleanup.py:294
SG::asStorable
DataObject * asStorable(SG::DataObjectSharedPtr< T > pObject)
Definition: DataObjectSharedPtr.h:31
PLR_IDDetDescrCnv::initialize
virtual StatusCode initialize() override
Definition: PLR_IDDetDescrCnv.cxx:39
IdDictMgr
Definition: IdDictMgr.h:15
PLR_IDDetDescrCnv::PLR_IDDetDescrCnv
PLR_IDDetDescrCnv(ISvcLocator *svcloc)
Definition: PLR_IDDetDescrCnv.cxx:24
DetDescrConverter
Definition: DetDescrConverter.h:25
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
PLR_IDDetDescrCnv::classID
static const CLID & classID()
Definition: PLR_IDDetDescrCnv.cxx:134
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:37
PLR_IDDetDescrCnv::m_inDetIDTag
std::string m_inDetIDTag
Internal InDet id tag.
Definition: PLR_IDDetDescrCnv.h:50
PLR_IDDetDescrCnv::repSvcType
virtual long int repSvcType() const override
Definition: PLR_IDDetDescrCnv.cxx:31
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
IdDictManager::initializeHelper
int initializeHelper(IdHelper &helper) const
Return value: 0 OK, >0 error.
Definition: IdDictManager.cxx:37
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
IdDictManager
IdDictManager is the interface to identifier dictionaries.
Definition: IdDictManager.h:26
IdDictDictionary
Definition: IdDictDictionary.h:30
IdDictDictionary::dict_tag
const std::string & dict_tag() const
Access to the dictionary tag.
Definition: IdDictDictionary.h:374
DetDescrConverter.h
PLR_IDDetDescrCnv::m_inDetIdDictTag
std::string m_inDetIdDictTag
Tag of RDB record for InDet ids.
Definition: PLR_IDDetDescrCnv.h:47
IdDictManager::manager
const IdDictMgr * manager(void) const
Definition: IdDictManager.cxx:30
PLR_IDDetDescrCnv::createObj
virtual StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj) override
Definition: PLR_IDDetDescrCnv.cxx:48
ClassID_traits::ID
static CLID ID()
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:44
PLR_IDDetDescrCnv::m_doChecks
bool m_doChecks
Whether or not.
Definition: PLR_IDDetDescrCnv.h:53
StoreGateSvc.h