ATLAS Offline Software
MDT_IDDetDescrCnv.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /***************************************************************************
6  Muon DetDescrCnv package
7  -----------------------------------------
8  ***************************************************************************/
9 
10 
11 #include "MDT_IDDetDescrCnv.h"
12 
15 #include "GaudiKernel/MsgStream.h"
16 #include "StoreGate/StoreGateSvc.h"
20 
21 
22 //--------------------------------------------------------------------
23 
24 long int
26 {
27  return (storageType());
28 }
29 
30 //--------------------------------------------------------------------
31 
34 {
35  // First call parent init
37  MsgStream log(msgSvc(), "MDT_IDDetDescrCnv");
38  log << MSG::DEBUG << "in initialize" << endmsg;
39 
40  if (sc.isFailure()) {
41  log << MSG::ERROR << "DetDescrConverter::initialize failed" << endmsg;
42  return sc;
43  }
44 
45  // The following is an attempt to "bootstrap" the loading of a
46  // proxy for MdtIdHelper into the detector store. However,
47  // MDT_IDDetDescrCnv::initialize is NOT called by the conversion
48  // service. So for the moment, this cannot be use. Instead the
49  // DetDescrCnvSvc must do the bootstrap from a parameter list.
50 
51 
52 // // Add InDet_DetDescrManager proxy as entry point to the detector store
53 // // - this is ONLY needed for the manager of each system
54 // sc = addToDetStore(classID(), "PidelID");
55 // if (sc.isFailure()) {
56 // log << MSG::FATAL << "Unable to add proxy for MdtIdHelper to the Detector Store!" << endmsg;
57 // return StatusCode::FAILURE;
58 // } else {}
59 
60  return StatusCode::SUCCESS;
61 }
62 
63 //--------------------------------------------------------------------
64 
67 {
68  MsgStream log(msgSvc(), "MDT_IDDetDescrCnv");
69  log << MSG::DEBUG << "in finalize" << endmsg;
70 
71  return StatusCode::SUCCESS;
72 }
73 
74 //--------------------------------------------------------------------
75 
77 MDT_IDDetDescrCnv::createObj(IOpaqueAddress* pAddr, DataObject*& pObj)
78 {
79  //StatusCode sc = StatusCode::SUCCESS;
80  MsgStream log(msgSvc(), "MDT_IDDetDescrCnv");
81  log << MSG::INFO << "in createObj: creating a MdtIdHelper object in the detector store" << endmsg;
82 
83  // Create a new MdtIdHelper
84 
85  DetDescrAddress* ddAddr;
86  ddAddr = dynamic_cast<DetDescrAddress*> (pAddr);
87  if(!ddAddr) {
88  log << MSG::FATAL << "Could not cast to DetDescrAddress." << endmsg;
89  return StatusCode::FAILURE;
90  }
91 
92  // Get the StoreGate key of this container.
93  std::string helperKey = *( ddAddr->par() );
94  if (helperKey.empty()) {
95  log << MSG::DEBUG << "No Helper key " << endmsg;
96  }
97  else {
98  log << MSG::DEBUG << "Helper key is " << helperKey << endmsg;
99  }
100 
101 
102  // get DetectorStore service
104  StatusCode status = serviceLocator()->service("DetectorStore", detStore);
105  if (status.isFailure()) {
106  log << MSG::FATAL << "DetectorStore service not found !" << endmsg;
107  return StatusCode::FAILURE;
108  } else {}
109 
110  // Get the dictionary manager from the detector store
111  const IdDictManager* idDictMgr = nullptr;
112  status = detStore->retrieve(idDictMgr, "IdDict");
113  if (status.isFailure()) {
114  log << MSG::FATAL << "Could not get IdDictManager !" << endmsg;
115  return StatusCode::FAILURE;
116  }
117  else {
118  log << MSG::DEBUG << " Found the IdDictManager. " << endmsg;
119  }
120 
121 
122  // create the helper
123  MdtIdHelper* mdt_id = new MdtIdHelper;
124  if (idDictMgr->initializeHelper(*mdt_id)) {
125  log << MSG::ERROR << "Unable to initialize MdtIdHelper" << endmsg;
126  return StatusCode::FAILURE;
127  }
128 
129  // Pass a pointer to the container to the Persistency service by reference.
130  pObj = SG::asStorable(mdt_id);
131 
132  return StatusCode::SUCCESS;
133 
134 }
135 
136 //--------------------------------------------------------------------
137 
138 long
140 {
141  return DetDescr_StorageType;
142 }
143 
144 //--------------------------------------------------------------------
145 const CLID&
148 }
149 
150 //--------------------------------------------------------------------
152  :
154 {}
155 
156 
157 
MDT_IDDetDescrCnv.h
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
DetDescr_StorageType
const long DetDescr_StorageType
Definition: DetDescrCnvSvc.cxx:20
MDT_IDDetDescrCnv::storageType
static long storageType()
Definition: MDT_IDDetDescrCnv.cxx:139
ID
std::vector< Identifier > ID
Definition: CalibHitIDCheck.h:24
StorableConversions.h
convert to and from a SG storable
initialize
void initialize()
Definition: run_EoverP.cxx:894
MDT_IDDetDescrCnv::initialize
virtual StatusCode initialize()
Definition: MDT_IDDetDescrCnv.cxx:33
DetDescrAddress.h
SG::asStorable
DataObject * asStorable(T *pObject)
Definition: StorableConversions.h:158
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
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
MdtIdHelper
Definition: MdtIdHelper.h:61
MdtIdHelper.h
MDT_IDDetDescrCnv::repSvcType
virtual long int repSvcType() const
Definition: MDT_IDDetDescrCnv.cxx:25
MDT_IDDetDescrCnv::createObj
virtual StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj)
Definition: MDT_IDDetDescrCnv.cxx:77
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
MDT_IDDetDescrCnv::classID
static const CLID & classID()
Definition: MDT_IDDetDescrCnv.cxx:146
IdDictManager
IdDictManager is the interface to identifier dictionaries.
Definition: IdDictManager.h:36
MDT_IDDetDescrCnv::MDT_IDDetDescrCnv
MDT_IDDetDescrCnv(ISvcLocator *svcloc)
Definition: MDT_IDDetDescrCnv.cxx:151
DetDescrConverter.h
DEBUG
#define DEBUG
Definition: page_access.h:11
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
merge.status
status
Definition: merge.py:17
StoreGateSvc.h
MDT_IDDetDescrCnv::finalize
virtual StatusCode finalize()
Definition: MDT_IDDetDescrCnv.cxx:66