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