ATLAS Offline Software
PLR_IDDetDescrCnv.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 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 
18 #include "InDetIdentifier/PLR_ID.h"
19 
20 //--------------------------------------------------------------------
21 
24 {}
25 
26 //--------------------------------------------------------------------
27 
28 long int
30 {
31  return storageType();
32 }
33 
34 //--------------------------------------------------------------------
35 
38 {
39  // First call parent init
41  MsgStream log(msgSvc(), "PLR_IDDetDescrCnv");
42  log << MSG::DEBUG << "in initialize" << endmsg;
43 
44  if (sc.isFailure()) {
45  log << MSG::ERROR << "DetDescrConverter::initialize failed" << endmsg;
46  return sc;
47  }
48 
49  return StatusCode::SUCCESS;
50 }
51 
52 //--------------------------------------------------------------------
53 
55 PLR_IDDetDescrCnv::createObj(IOpaqueAddress* pAddr, DataObject*& pObj)
56 {
57  MsgStream log(msgSvc(), "PLR_IDDetDescrCnv");
58  log << MSG::INFO << "in createObj: creating a PLR_ID helper object in the detector store" << endmsg;
59 
60  // Create a new PLR_ID
61  DetDescrAddress* ddAddr;
62  ddAddr = dynamic_cast<DetDescrAddress*> (pAddr);
63  if(!ddAddr) {
64  log << MSG::FATAL << "Could not cast to DetDescrAddress." << endmsg;
65  return StatusCode::FAILURE;
66  }
67 
68  // Get the StoreGate key of this container.
69  std::string helperKey = *( ddAddr->par() );
70  if ("" == helperKey) {
71  log << MSG::DEBUG << "No Helper key " << endmsg;
72  } else {
73  log << MSG::DEBUG << "Helper key is " << helperKey << endmsg;
74  }
75 
76  // get DetectorStore service
78  StatusCode status = serviceLocator()->service("DetectorStore", detStore);
79  if (status.isFailure()) {
80  log << MSG::FATAL << "DetectorStore service not found !" << endmsg;
81  return StatusCode::FAILURE;
82  }
83 
84  // Get the dictionary manager from the detector store
85  const IdDictManager* idDictMgr;
86  status = detStore->retrieve(idDictMgr, "IdDict");
87  if (status.isFailure()) {
88  log << MSG::FATAL << "Could not get IdDictManager !" << endmsg;
89  return StatusCode::FAILURE;
90  } else {
91  log << MSG::DEBUG << " Found the IdDictManager." << endmsg;
92  }
93 
94 
95  // Only initialize helper if it is the first pass or if there is a
96  // change in the the file or tag
97  bool initHelper{};
98 
99  const IdDictMgr* mgr = idDictMgr->manager();
100 
101  // Internal InDet id tag
102  std::string inDetIDTag = mgr->tag();
103 
104  // DoChecks flag
105  bool doChecks = mgr->do_checks();
106 
107  IdDictDictionary* dict = mgr->find_dictionary("InnerDetector");
108  if (!dict) {
109  log << MSG::ERROR << "unable to find idDict for InnerDetector" << endmsg;
110  return StatusCode::FAILURE;
111  }
112 
113  // File to be read for InDet ids
114  std::string inDetIDFileName = dict->file_name();
115 
116  // Tag of RDB record for InDet ids
117  std::string inDetIdDictTag = dict->dict_tag();
118 
119  // PLR id helper already exists - second pass. Check for a change
120  if (m_plrId) {
121  if (inDetIDTag != m_inDetIDTag) {
122  // Internal InDet id tag
123  initHelper = true;
124  log << MSG::DEBUG << " Changed internal InDet id tag: "
125  << inDetIDTag << endmsg;
126  }
127  if (inDetIDFileName != m_inDetIDFileName) {
128  // File to be read for InDet ids
129  initHelper = true;
130  log << MSG::DEBUG << " Changed InDetFileName: "
131  << inDetIDFileName << endmsg;
132  }
133  if (inDetIdDictTag != m_inDetIdDictTag) {
134  // Tag of RDB record for InDet ids
135  initHelper = true;
136  log << MSG::DEBUG << " Changed InDetIdDictTag: "
137  << inDetIdDictTag
138  << endmsg;
139  }
140  if (doChecks != m_doChecks) {
141  // DoChecks flag
142  initHelper = true;
143  log << MSG::DEBUG << " Changed doChecks flag: "
144  << doChecks
145  << endmsg;
146  }
147  } else {
148  // create the helper
149  m_plrId = new PLR_ID;
150  initHelper = true;
151  // add in message service for printout
153  }
154 
155  if (initHelper) {
156  if (idDictMgr->initializeHelper(*m_plrId)) {
157  log << MSG::ERROR << "Unable to initialize PLR_ID" << endmsg;
158  return StatusCode::FAILURE;
159  }
160  // Save state:
161  m_inDetIDTag = inDetIDTag;
162  m_inDetIDFileName = inDetIDFileName;
163  m_inDetIdDictTag = inDetIdDictTag;
164  m_doChecks = doChecks;
165  }
166 
167  // Pass a pointer to the container to the Persistency service by reference.
168  pObj = SG::asStorable(m_plrId);
169 
170  return StatusCode::SUCCESS;
171 }
172 
173 //--------------------------------------------------------------------
174 
175 long
177 {
178  return DetDescr_StorageType;
179 }
180 
181 //--------------------------------------------------------------------
182 const CLID&
184 {
186 }
PLR_IDDetDescrCnv::m_plrId
PLR_ID * m_plrId
The helper - only will create it once.
Definition: PLR_IDDetDescrCnv.h:41
AtlasDetectorID::setMessageSvc
virtual void setMessageSvc(IMessageSvc *msgSvc) override
Definition: AtlasDetectorID.cxx:748
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
DetDescr_StorageType
const long DetDescr_StorageType
Definition: DetDescrCnvSvc.cxx:20
ID
std::vector< Identifier > ID
Definition: CalibHitIDCheck.h:24
initialize
void initialize()
Definition: run_EoverP.cxx:894
PLR_ID.h
This is an Identifier helper class for the PLR subdetector. This class inherits from PicelID.
PLR_ID
This is an Identifier helper class for the PLR subdetector. This class inherits from PixelID.
Definition: PLR_ID.h:24
DetDescrAddress.h
SG::asStorable
DataObject * asStorable(T *pObject)
Definition: StorableConversions.h:158
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
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
PLR_IDDetDescrCnv::storageType
static long storageType()
Definition: PLR_IDDetDescrCnv.cxx:176
BchCleanup.mgr
mgr
Definition: BchCleanup.py:294
ClassID_traits::ID
static const CLID & ID()
the CLID of T
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:50
PLR_IDDetDescrCnv::initialize
virtual StatusCode initialize() override
Definition: PLR_IDDetDescrCnv.cxx:37
IdDictMgr
Definition: IdDictDefs.h:32
PLR_IDDetDescrCnv::PLR_IDDetDescrCnv
PLR_IDDetDescrCnv(ISvcLocator *svcloc)
Definition: PLR_IDDetDescrCnv.cxx:22
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:128
DetDescrConverter
Definition: DetDescrConverter.h:32
DetDescrAddress
Definition: DetDescrAddress.h:32
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
PLR_IDDetDescrCnv::classID
static const CLID & classID()
Definition: PLR_IDDetDescrCnv.cxx:183
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:40
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:29
IdDictDictionary::dict_tag
std::string dict_tag(void) const
Access to the dictionary tag.
Definition: IdDictDefs.h:700
IdDictManager::initializeHelper
int initializeHelper(IdHelper &helper) const
Return value: 0 OK, >0 error.
Definition: IdDictManager.cxx:44
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
IdDictManager
IdDictManager is the interface to identifier dictionaries.
Definition: IdDictManager.h:36
IdDictDictionary
Definition: IdDictDefs.h:97
IdDictDictionary::file_name
std::string file_name(void) const
Access to file name.
Definition: IdDictDefs.h:692
DetDescrConverter.h
PLR_IDDetDescrCnv::m_inDetIdDictTag
std::string m_inDetIdDictTag
Tag of RDB record for InDet ids.
Definition: PLR_IDDetDescrCnv.h:47
DEBUG
#define DEBUG
Definition: page_access.h:11
IdDictManager::manager
const IdDictMgr * manager(void) const
Definition: IdDictManager.cxx:37
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
PLR_IDDetDescrCnv::createObj
virtual StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj) override
Definition: PLR_IDDetDescrCnv.cxx:55
merge.status
status
Definition: merge.py:17
PLR_IDDetDescrCnv::m_doChecks
bool m_doChecks
Whether or not.
Definition: PLR_IDDetDescrCnv.h:53
StoreGateSvc.h