ATLAS Offline Software
MM_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 #include "MM_IDDetDescrCnv.h"
11 
14 #include "GaudiKernel/MsgStream.h"
15 #include "StoreGate/StoreGateSvc.h"
18 
20 
21 
22 
23 //--------------------------------------------------------------------
24 long int MM_IDDetDescrCnv::repSvcType() const {
25  return (storageType());
26 }
27 
28 //--------------------------------------------------------------------
30  // First call parent init
32  MsgStream log(msgSvc(), "MM_IDDetDescrCnv");
33  log << MSG::DEBUG << "in initialize" << endmsg;
34 
35  if (sc.isFailure()) {
36  log << MSG::ERROR << "DetDescrConverter::initialize failed" << endmsg;
37  return sc;
38  }
39 
40  // diehl: Previously commented out code from TGC version. Maybe useful so leave here
41  // The following is an attempt to "bootstrap" the loading of a
42  // proxy for TgcIdHelper into the detector store. However,
43  // MM_IDDetDescrCnv::initialize is NOT called by the conversion
44  // service. So for the moment, this cannot be use. Instead the
45  // DetDescrCnvSvc must do the bootstrap from a parameter list.
46 
47  // // Add InDet_DetDescrManager proxy as entry point to the detector store
48  // // - this is ONLY needed for the manager of each system
49  // sc = addToDetStore(classID(), "PidelID");
50  // if (sc.isFailure()) {
51  // log << MSG::FATAL << "Unable to add proxy for MmIdHelper to the Detector Store!" << endmsg;
52  // return StatusCode::FAILURE;
53  // } else {}
54 
55  return StatusCode::SUCCESS;
56 } //end MM_IDDetDescrCnv::initialize
57 
58 //--------------------------------------------------------------------
60  MsgStream log(msgSvc(), "MM_IDDetDescrCnv");
61  log << MSG::DEBUG << "in finalize" << endmsg;
62 
63  return StatusCode::SUCCESS;
64 }
65 
66 //--------------------------------------------------------------------
67 StatusCode MM_IDDetDescrCnv::createObj(IOpaqueAddress* pAddr, DataObject*& pObj) {
68  //StatusCode sc = StatusCode::SUCCESS;
69  MsgStream log(msgSvc(), "MM_IDDetDescrCnv");
70  log << MSG::INFO << "in createObj: creating a MmIdHelper object in the detector store" << endmsg;
71 
72  // Create a new MmIdHelper
73  DetDescrAddress* ddAddr;
74  ddAddr = dynamic_cast<DetDescrAddress*> (pAddr);
75  if(!ddAddr) {
76  log << MSG::FATAL << "Could not cast to DetDescrAddress." << endmsg;
77  return StatusCode::FAILURE;
78  }
79 
80  // Get the StoreGate key of this container.
81  std::string helperKey = *( ddAddr->par() );
82  if (helperKey.empty()) {
83  log << MSG::DEBUG << "No Helper key " << endmsg;
84  } else {
85  log << MSG::DEBUG << "Helper key is " << helperKey << endmsg;
86  }
87 
88  // get DetectorStore service
90  StatusCode status = serviceLocator()->service("DetectorStore", detStore);
91  if (status.isFailure()) {
92  log << MSG::FATAL << "DetectorStore service not found !" << endmsg;
93  return StatusCode::FAILURE;
94  } // else {} //pointless else from TGC code - Diehl
95 
96  // Get the dictionary manager from the detector store
97  const IdDictManager* idDictMgr = nullptr;
98  status = detStore->retrieve(idDictMgr, "IdDict");
99  if (status.isFailure()) {
100  log << MSG::FATAL << "Could not get IdDictManager !" << endmsg;
101  return StatusCode::FAILURE;
102  } else {
103  log << MSG::DEBUG << " Found the IdDictManager. " << endmsg;
104  }
105 
106  // create the helper
107  MmIdHelper* mm_id = new MmIdHelper;
108  if (idDictMgr->initializeHelper(*mm_id)) {
109  log << MSG::ERROR << "Unable to initialize MmIdHelper" << endmsg;
110  return StatusCode::FAILURE;
111  }
112 
113  // Pass a pointer to the container to the Persistency service by reference.
114  pObj = SG::asStorable(mm_id);
115 
116  return StatusCode::SUCCESS;
117 } //end MM_IDDetDescrCnv::createObj
118 
119 //--------------------------------------------------------------------
121  return DetDescr_StorageType;
122 }
123 
124 //--------------------------------------------------------------------
127 }
128 
129 //--------------------------------------------------------------------
130 MM_IDDetDescrCnv::MM_IDDetDescrCnv(ISvcLocator* svcloc) :
132 {}
MM_IDDetDescrCnv::createObj
virtual StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj)
Definition: MM_IDDetDescrCnv.cxx:67
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
MM_IDDetDescrCnv::classID
static const CLID & classID()
Definition: MM_IDDetDescrCnv.cxx:125
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
IdDictManager.h
MM_IDDetDescrCnv::storageType
static long storageType()
Definition: MM_IDDetDescrCnv.cxx:120
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
MM_IDDetDescrCnv::initialize
virtual StatusCode initialize()
Definition: MM_IDDetDescrCnv.cxx:29
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
MmIdHelper.h
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
MM_IDDetDescrCnv::repSvcType
virtual long int repSvcType() const
Definition: MM_IDDetDescrCnv.cxx:24
MmIdHelper
Definition: MmIdHelper.h:54
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
MM_IDDetDescrCnv::MM_IDDetDescrCnv
MM_IDDetDescrCnv(ISvcLocator *svcloc)
Definition: MM_IDDetDescrCnv.cxx:130
StoreGateSvc.h
MM_IDDetDescrCnv.h
MM_IDDetDescrCnv::finalize
virtual StatusCode finalize()
Definition: MM_IDDetDescrCnv.cxx:59