ATLAS Offline Software
TGC_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 "TGC_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(), "TGC_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  // The following is an attempt to "bootstrap" the loading of a
45  // proxy for TgcIdHelper into the detector store. However,
46  // TGC_IDDetDescrCnv::initialize is NOT called by the conversion
47  // service. So for the moment, this cannot be use. Instead the
48  // DetDescrCnvSvc must do the bootstrap from a parameter list.
49 
50 
51 // // Add InDet_DetDescrManager proxy as entry point to the detector store
52 // // - this is ONLY needed for the manager of each system
53 // sc = addToDetStore(classID(), "PidelID");
54 // if (sc.isFailure()) {
55 // log << MSG::FATAL << "Unable to add proxy for TgcIdHelper to the Detector Store!" << endmsg;
56 // return StatusCode::FAILURE;
57 // } else {}
58 
59  return StatusCode::SUCCESS;
60 }
61 
62 //--------------------------------------------------------------------
63 
66 {
67  MsgStream log(msgSvc(), "TGC_IDDetDescrCnv");
68  log << MSG::DEBUG << "in finalize" << endmsg;
69 
70  return StatusCode::SUCCESS;
71 }
72 
73 //--------------------------------------------------------------------
74 
76 TGC_IDDetDescrCnv::createObj(IOpaqueAddress* pAddr, DataObject*& pObj)
77 {
78  //StatusCode sc = StatusCode::SUCCESS;
79  MsgStream log(msgSvc(), "TGC_IDDetDescrCnv");
80  log << MSG::INFO << "in createObj: creating a TgcIdHelper object in the detector store" << endmsg;
81 
82  // Create a new TgcIdHelper
83 
84  DetDescrAddress* ddAddr;
85  ddAddr = dynamic_cast<DetDescrAddress*> (pAddr);
86  if(!ddAddr) {
87  log << MSG::FATAL << "Could not cast to DetDescrAddress." << endmsg;
88  return StatusCode::FAILURE;
89  }
90 
91  // Get the StoreGate key of this container.
92  std::string helperKey = *( ddAddr->par() );
93  if (helperKey.empty()) {
94  log << MSG::DEBUG << "No Helper key " << endmsg;
95  }
96  else {
97  log << MSG::DEBUG << "Helper key is " << helperKey << endmsg;
98  }
99 
100 
101  // get DetectorStore service
103  StatusCode status = serviceLocator()->service("DetectorStore", detStore);
104  if (status.isFailure()) {
105  log << MSG::FATAL << "DetectorStore service not found !" << endmsg;
106  return StatusCode::FAILURE;
107  } else {}
108 
109  // Get the dictionary manager from the detector store
110  const IdDictManager* idDictMgr = nullptr;
111  status = detStore->retrieve(idDictMgr, "IdDict");
112  if (status.isFailure()) {
113  log << MSG::FATAL << "Could not get IdDictManager !" << endmsg;
114  return StatusCode::FAILURE;
115  }
116  else {
117  log << MSG::DEBUG << " Found the IdDictManager. " << endmsg;
118  }
119 
120 
121  // create the helper
122  TgcIdHelper* tgc_id = new TgcIdHelper;
123  if (idDictMgr->initializeHelper(*tgc_id)) {
124  log << MSG::ERROR << "Unable to initialize TgcIdHelper" << endmsg;
125  return StatusCode::FAILURE;
126  }
127 
128  // Pass a pointer to the container to the Persistency service by reference.
129  pObj = SG::asStorable(tgc_id);
130 
131  return StatusCode::SUCCESS;
132 
133 }
134 
135 //--------------------------------------------------------------------
136 
137 long
139 {
140  return DetDescr_StorageType;
141 }
142 
143 //--------------------------------------------------------------------
144 const CLID&
147 }
148 
149 //--------------------------------------------------------------------
151  :
153 {}
154 
155 
156 
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
TgcIdHelper
Definition: TgcIdHelper.h:50
initialize
void initialize()
Definition: run_EoverP.cxx:894
DetDescrAddress.h
SG::asStorable
DataObject * asStorable(T *pObject)
Definition: StorableConversions.h:158
IdDictManager.h
TGC_IDDetDescrCnv::classID
static const CLID & classID()
Definition: TGC_IDDetDescrCnv.cxx:145
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
TGC_IDDetDescrCnv::createObj
virtual StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj)
Definition: TGC_IDDetDescrCnv.cxx:76
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:128
DetDescrConverter
Definition: DetDescrConverter.h:32
DetDescrAddress
Definition: DetDescrAddress.h:32
TGC_IDDetDescrCnv::initialize
virtual StatusCode initialize()
Definition: TGC_IDDetDescrCnv.cxx: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
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
TGC_IDDetDescrCnv::storageType
static long storageType()
Definition: TGC_IDDetDescrCnv.cxx:138
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
IdDictManager
IdDictManager is the interface to identifier dictionaries.
Definition: IdDictManager.h:36
TGC_IDDetDescrCnv::repSvcType
virtual long int repSvcType() const
Definition: TGC_IDDetDescrCnv.cxx:26
TGC_IDDetDescrCnv.h
DetDescrConverter.h
DEBUG
#define DEBUG
Definition: page_access.h:11
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
TgcIdHelper.h
merge.status
status
Definition: merge.py:17
TGC_IDDetDescrCnv::finalize
virtual StatusCode finalize()
Definition: TGC_IDDetDescrCnv.cxx:65
StoreGateSvc.h
TGC_IDDetDescrCnv::TGC_IDDetDescrCnv
TGC_IDDetDescrCnv(ISvcLocator *svcloc)
Definition: TGC_IDDetDescrCnv.cxx:150