ATLAS Offline Software
SiliconIDDetDescrCnv.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /***************************************************************************
6  InDet DetDescrCnv package
7  -----------------------------------------
8  ***************************************************************************/
9 
10 
11 #include "SiliconIDDetDescrCnv.h"
12 
15 #include "GaudiKernel/MsgStream.h"
16 #include "StoreGate/StoreGateSvc.h"
17 
19 //#include "Identifier/IdentifierHash.h"
22 #include "InDetIdentifier/SCT_ID.h"
23 
24 
25 //--------------------------------------------------------------------
26 
27 long int
29 {
30  return (storageType());
31 }
32 
33 //--------------------------------------------------------------------
34 
37 {
38  // First call parent init
40  MsgStream log(msgSvc(), "SiliconIDDetDescrCnv");
41  log << MSG::DEBUG << "in initialize" << endmsg;
42 
43  if (sc.isFailure()) {
44  log << MSG::ERROR << "DetDescrConverter::initialize failed" << endmsg;
45  return sc;
46  }
47 
48  // The following is an attempt to "bootstrap" the loading of a
49  // proxy for SiliconID into the detector store. However,
50  // SiliconIDDetDescrCnv::initialize is NOT called by the conversion
51  // service. So for the moment, this cannot be use. Instead the
52  // DetDescrCnvSvc must do the bootstrap from a parameter list.
53 
54 
55 // // Add InDet_DetDescrManager proxy as entry point to the detector store
56 // // - this is ONLY needed for the manager of each system
57 // sc = addToDetStore(classID(), "PidelID");
58 // if (sc.isFailure()) {
59 // log << MSG::FATAL << "Unable to add proxy for SiliconID to the Detector Store!" << endmsg;
60 // return StatusCode::FAILURE;
61 // } else {}
62 
63  return StatusCode::SUCCESS;
64 }
65 
66 //--------------------------------------------------------------------
67 
70 {
71  MsgStream log(msgSvc(), "SiliconIDDetDescrCnv");
72  log << MSG::DEBUG << "in finalize" << endmsg;
73 
74  return StatusCode::SUCCESS;
75 }
76 
77 //--------------------------------------------------------------------
78 
80 SiliconIDDetDescrCnv::createObj(IOpaqueAddress* pAddr, DataObject*& pObj)
81 {
82  //StatusCode sc = StatusCode::SUCCESS;
83  MsgStream log(msgSvc(), "SiliconIDDetDescrCnv");
84  log << MSG::INFO << "in createObj: creating a SiliconID helper object in the detector store" << endmsg;
85 
86  // Create a new SiliconID
87 
88  DetDescrAddress* ddAddr;
89  ddAddr = dynamic_cast<DetDescrAddress*> (pAddr);
90  if(!ddAddr) {
91  log << MSG::FATAL << "Could not cast to DetDescrAddress." << endmsg;
92  return StatusCode::FAILURE;
93  }
94 
95  // Get the StoreGate key of this container.
96  std::string helperKey = *( ddAddr->par() );
97  if ("" == helperKey) {
98  log << MSG::DEBUG << "No Helper key " << endmsg;
99  }
100  else {
101  log << MSG::DEBUG << "Helper key is " << helperKey << endmsg;
102  }
103 
104 
105  // get DetectorStore service
107  StatusCode status = serviceLocator()->service("DetectorStore", detStore);
108  if (status.isFailure()) {
109  log << MSG::FATAL << "DetectorStore service not found !" << endmsg;
110  return StatusCode::FAILURE;
111  } else {}
112 
113  // Get the dictionary manager from the detector store
114  const IdDictManager* idDictMgr = nullptr;
115  status = detStore->retrieve(idDictMgr, "IdDict");
116  if (status.isFailure()) {
117  log << MSG::FATAL << "Could not get IdDictManager !" << endmsg;
118  return StatusCode::FAILURE;
119  }
120  else {
121  log << MSG::DEBUG << " Found the IdDictManager. " << endmsg;
122  }
123 
124  // Get both Pixel and SCT id helpers
125  const PixelID* pixelID = nullptr;
126  status = detStore->retrieve(pixelID, "PixelID");
127  if (status.isFailure()) {
128  log << MSG::FATAL << "Could not get PixelID helper !" << endmsg;
129  return StatusCode::FAILURE;
130  }
131  else {
132  log << MSG::DEBUG << " Found the PixelID. " << endmsg;
133  }
134 
135  const SCT_ID* sctID = nullptr;
136  status = detStore->retrieve(sctID, "SCT_ID");
137  if (status.isFailure()) {
138  log << MSG::FATAL << "Could not get SCT_ID helper !" << endmsg;
139  return StatusCode::FAILURE;
140  }
141  else {
142  log << MSG::DEBUG << " Found the SCT_ID. " << endmsg;
143  }
144 
145  if (!m_siliconId) {
146  // create the helper only once
147  log << MSG::DEBUG << " Create SiliconID. " << endmsg;
148  m_siliconId = new SiliconID(pixelID, sctID);
150  }
151 
152  if (idDictMgr->initializeHelper(*m_siliconId)) {
153  log << MSG::ERROR << "Unable to initialize SiliconID" << endmsg;
154  return StatusCode::FAILURE;
155  }
156  else {
157  log << MSG::DEBUG << " Initialized SiliconID. " << endmsg;
158  }
159 
160  // Pass a pointer to the container to the Persistency service by reference.
161  pObj = SG::asStorable(m_siliconId);
162 
163  return StatusCode::SUCCESS;
164 
165 }
166 
167 //--------------------------------------------------------------------
168 
169 long
171 {
172  return DetDescr_StorageType;
173 }
174 
175 //--------------------------------------------------------------------
176 const CLID&
179 }
180 
181 //--------------------------------------------------------------------
183  :
185  m_siliconId(nullptr)
186 
187 {}
188 
189 
190 
PixelID.h
This is an Identifier helper class for the Pixel subdetector. This class is a factory for creating co...
SCT_ID.h
This is an Identifier helper class for the SCT subdetector. This class is a factory for creating comp...
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
DetDescrAddress.h
SG::asStorable
DataObject * asStorable(T *pObject)
Definition: StorableConversions.h:158
SiliconIDDetDescrCnv::m_siliconId
SiliconID * m_siliconId
The helper - only will create it once.
Definition: SiliconIDDetDescrCnv.h:54
IdDictManager.h
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
ClassID_traits::ID
static const CLID & ID()
the CLID of T
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:50
SiliconIDDetDescrCnv::initialize
virtual StatusCode initialize()
Definition: SiliconIDDetDescrCnv.cxx:36
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
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
SiliconIDDetDescrCnv::createObj
virtual StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj)
Definition: SiliconIDDetDescrCnv.cxx:80
SiliconID.h
This is an Identifier helper class for both the Pixel and SCT subdetectors. This class defines identi...
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
SiliconIDDetDescrCnv::classID
static const CLID & classID()
Definition: SiliconIDDetDescrCnv.cxx:177
IdDictManager
IdDictManager is the interface to identifier dictionaries.
Definition: IdDictManager.h:36
SiliconID
This is an Identifier helper class for both the Pixel and SCT subdetectors. This class defines identi...
Definition: SiliconID.h:46
SiliconIDDetDescrCnv::storageType
static long storageType()
Definition: SiliconIDDetDescrCnv.cxx:170
SCT_ID
Definition: SCT_ID.h:68
DetDescrConverter.h
DEBUG
#define DEBUG
Definition: page_access.h:11
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
SiliconIDDetDescrCnv::SiliconIDDetDescrCnv
SiliconIDDetDescrCnv(ISvcLocator *svcloc)
Definition: SiliconIDDetDescrCnv.cxx:182
SiliconIDDetDescrCnv::repSvcType
virtual long int repSvcType() const
Definition: SiliconIDDetDescrCnv.cxx:28
merge.status
status
Definition: merge.py:17
PixelID
Definition: PixelID.h:67
SiliconIDDetDescrCnv.h
StoreGateSvc.h
SiliconIDDetDescrCnv::finalize
virtual StatusCode finalize()
Definition: SiliconIDDetDescrCnv.cxx:69