ATLAS Offline Software
RPC_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 "RPC_IDDetDescrCnv.h"
12 
15 #include "GaudiKernel/MsgStream.h"
16 #include "StoreGate/StoreGateSvc.h"
20 
21 
22 
23 //--------------------------------------------------------------------
24 
25 long int
27 {
28  return (storageType());
29 }
30 
33 {
34  // First call parent init
36  MsgStream log(msgSvc(), "RPC_IDDetDescrCnv");
37  log << MSG::DEBUG << "in initialize" << endmsg;
38 
39  if (sc.isFailure()) {
40  log << MSG::ERROR << "DetDescrConverter::initialize failed" << endmsg;
41  return sc;
42  }
43 
44 
45  // The following is an attempt to "bootstrap" the loading of a
46  // proxy for RpcIdHelper into the detector store. However,
47  // RPC_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 RpcIdHelper 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(), "RPC_IDDetDescrCnv");
69  log << MSG::DEBUG << "in finalize" << endmsg;
70 
71  return StatusCode::SUCCESS;
72 }
73 
74 //--------------------------------------------------------------------
75 
77 RPC_IDDetDescrCnv::createObj(IOpaqueAddress* pAddr, DataObject*& pObj)
78 {
79  //StatusCode sc = StatusCode::SUCCESS;
80  MsgStream log(msgSvc(), "RPC_IDDetDescrCnv");
81  log << MSG::INFO << "in createObj: creating a RpcIdHelper object in the detector store" << endmsg;
82 
83  // Create a new RpcIdHelper
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  RpcIdHelper* rpc_id = new RpcIdHelper;
124  if (idDictMgr->initializeHelper(*rpc_id)) {
125  log << MSG::ERROR << "Unable to initialize RpcIdHelper from dictionary" << endmsg;
126  return StatusCode::FAILURE;
127  }
128 
129  // Pass a pointer to the container to the Persistency service by reference.
130  pObj = SG::asStorable(rpc_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 
RPC_IDDetDescrCnv::storageType
static long storageType()
Definition: RPC_IDDetDescrCnv.cxx:139
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
StorableConversions.h
convert to and from a SG storable
initialize
void initialize()
Definition: run_EoverP.cxx:894
DetDescrAddress.h
SG::asStorable
DataObject * asStorable(T *pObject)
Definition: StorableConversions.h:158
RPC_IDDetDescrCnv::RPC_IDDetDescrCnv
RPC_IDDetDescrCnv(ISvcLocator *svcloc)
Definition: RPC_IDDetDescrCnv.cxx:151
RPC_IDDetDescrCnv::createObj
virtual StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj)
Definition: RPC_IDDetDescrCnv.cxx:77
RPC_IDDetDescrCnv::classID
static const CLID & classID()
Definition: RPC_IDDetDescrCnv.cxx:146
IdDictManager.h
RpcIdHelper
Definition: RpcIdHelper.h:51
RpcIdHelper.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
RPC_IDDetDescrCnv::finalize
virtual StatusCode finalize()
Definition: RPC_IDDetDescrCnv.cxx:66
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
RPC_IDDetDescrCnv.h
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:40
RPC_IDDetDescrCnv::initialize
virtual StatusCode initialize()
Definition: RPC_IDDetDescrCnv.cxx:32
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
RPC_IDDetDescrCnv::repSvcType
virtual long int repSvcType() const
Definition: RPC_IDDetDescrCnv.cxx:26
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
IdDictManager
IdDictManager is the interface to identifier dictionaries.
Definition: IdDictManager.h:36
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