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