ATLAS Offline Software
AtlasIDDetDescrCnv.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /***************************************************************************
6  InDet DetDescrCnv package
7  -----------------------------------------
8  ***************************************************************************/
9 
10 //<doc><file> $Id: AtlasIDDetDescrCnv.cxx,v 1.4 2009-02-15 13:08:19 schaffer Exp $
11 //<version> $Name: not supported by cvs2svn $
12 
13 //<<<<<< INCLUDES >>>>>>
14 
15 #include "AtlasIDDetDescrCnv.h"
16 
19 #include "GaudiKernel/MsgStream.h"
21 #include "StoreGate/StoreGateSvc.h"
22 
25 
26 //<<<<<< PRIVATE DEFINES >>>>>>
27 //<<<<<< PRIVATE CONSTANTS >>>>>>
28 //<<<<<< PRIVATE TYPES >>>>>>
29 //<<<<<< PRIVATE VARIABLE DEFINITIONS >>>>>>
30 //<<<<<< PUBLIC VARIABLE DEFINITIONS >>>>>>
31 //<<<<<< CLASS STRUCTURE INITIALIZATION >>>>>>
32 //<<<<<< PRIVATE FUNCTION DEFINITIONS >>>>>>
33 //<<<<<< PUBLIC FUNCTION DEFINITIONS >>>>>>
34 //<<<<<< MEMBER FUNCTION DEFINITIONS >>>>>>
35 
36 //--------------------------------------------------------------------
37 
38 long int
40 {
41  return (storageType());
42 }
43 
44 //--------------------------------------------------------------------
45 
48 {
49  // First call parent init
51  MsgStream log(msgSvc(), "AtlasIDDetDescrCnv");
52  log << MSG::DEBUG << "in initialize" << endmsg;
53 
54  if (sc.isFailure()) {
55  log << MSG::ERROR << "DetDescrConverter::initialize failed" << endmsg;
56  return sc;
57  }
58 
59  // The following is an attempt to "bootstrap" the loading of a
60  // proxy for AtlasDetectorID into the detector store. However,
61  // AtlasIDDetDescrCnv::initialize is NOT called by the conversion
62  // service. So for the moment, this cannot be use. Instead the
63  // DetDescrCnvSvc must do the bootstrap from a parameter list.
64 
65 
66 // // Add InDet_DetDescrManager proxy as entry point to the detector store
67 // // - this is ONLY needed for the manager of each system
68 // sc = addToDetStore(classID(), "PidelID");
69 // if (sc.isFailure()) {
70 // log << MSG::FATAL << "Unable to add proxy for AtlasDetectorID to the Detector Store!" << endmsg;
71 // return StatusCode::FAILURE;
72 // } else {}
73 
74  return StatusCode::SUCCESS;
75 }
76 
77 //--------------------------------------------------------------------
78 
81 {
82  MsgStream log(msgSvc(), "AtlasIDDetDescrCnv");
83  log << MSG::DEBUG << "in finalize" << endmsg;
84 
85  return StatusCode::SUCCESS;
86 }
87 
88 //--------------------------------------------------------------------
89 
91 AtlasIDDetDescrCnv::createObj(IOpaqueAddress* pAddr, DataObject*& pObj)
92 {
93  //StatusCode sc = StatusCode::SUCCESS;
94  MsgStream log(msgSvc(), "AtlasIDDetDescrCnv");
95  log << MSG::INFO << "in createObj: creating a AtlasDetectorID helper object in the detector store" << endmsg;
96 
97  // Create a new AtlasDetectorID
98 
99  DetDescrAddress* ddAddr;
100  ddAddr = dynamic_cast<DetDescrAddress*> (pAddr);
101  if(!ddAddr) {
102  log << MSG::FATAL << "Could not cast to DetDescrAddress." << endmsg;
103  return StatusCode::FAILURE;
104  }
105 
106  // Get the StoreGate key of this container.
107  std::string helperKey = *( ddAddr->par() );
108  if ("" == helperKey) {
109  log << MSG::DEBUG << "No Helper key " << endmsg;
110  }
111  else {
112  log << MSG::DEBUG << "Helper key is " << helperKey << endmsg;
113  }
114 
115 
116  // get DetectorStore service
118  StatusCode status = serviceLocator()->service("DetectorStore", detStore);
119  if (status.isFailure()) {
120  log << MSG::FATAL << "DetectorStore service not found !" << endmsg;
121  return StatusCode::FAILURE;
122  } else {}
123 
124  // Get the dictionary manager from the detector store
125  const IdDictManager* idDictMgr;
126  status = detStore->retrieve(idDictMgr, "IdDict");
127  if (status.isFailure()) {
128  log << MSG::FATAL << "Could not get IdDictManager !" << endmsg;
129  return StatusCode::FAILURE;
130  }
131  else {
132  log << MSG::DEBUG << " Found the IdDictManager. " << endmsg;
133  }
134 
135 
136  // create the helper
137  auto atlas_id = std::make_unique<AtlasDetectorID>();
138  atlas_id->setMessageSvc(msgSvc());
139 
140  if (idDictMgr->initializeHelper(*atlas_id)) {
141  log << MSG::ERROR << "Unable to initialize AtlasDetectorID" << endmsg;
142  return StatusCode::FAILURE;
143  }
144 
145  // Pass a pointer to the container to the Persistency service by reference.
146  pObj = SG::asStorable(std::move(atlas_id));
147 
148  return StatusCode::SUCCESS;
149 
150 }
151 
152 //--------------------------------------------------------------------
153 
154 long int
156 {
157  return DetDescr_StorageType;
158 }
159 
160 //--------------------------------------------------------------------
161 const CLID&
164 }
165 
166 //--------------------------------------------------------------------
168  :
170 {}
171 
172 
173 
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
AtlasIDDetDescrCnv::createObj
virtual StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj)
Definition: AtlasIDDetDescrCnv.cxx:91
initialize
void initialize()
Definition: run_EoverP.cxx:894
DetDescrAddress.h
SG::asStorable
DataObject * asStorable(T *pObject)
Definition: StorableConversions.h:158
IdDictManager.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
AtlasDetectorID.h
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
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
AtlasIDDetDescrCnv::initialize
virtual StatusCode initialize()
Definition: AtlasIDDetDescrCnv.cxx:47
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:40
AtlasIDDetDescrCnv::storageType
static long int storageType()
Definition: AtlasIDDetDescrCnv.cxx:155
AtlasIDDetDescrCnv::AtlasIDDetDescrCnv
AtlasIDDetDescrCnv(ISvcLocator *svcloc)
Definition: AtlasIDDetDescrCnv.cxx:167
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
AtlasIDDetDescrCnv::finalize
virtual StatusCode finalize()
Definition: AtlasIDDetDescrCnv.cxx:80
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
IdDictManager
IdDictManager is the interface to identifier dictionaries.
Definition: IdDictManager.h:36
AtlasIDDetDescrCnv::classID
static const CLID & classID()
Definition: AtlasIDDetDescrCnv.cxx:162
AtlasIDDetDescrCnv::repSvcType
virtual long int repSvcType() const
Definition: AtlasIDDetDescrCnv.cxx:39
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
AtlasDetectorID
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
Definition: AtlasDetectorID.h:57
AtlasIDDetDescrCnv.h