ATLAS Offline Software
CaloIDHelper_IDDetDescrCnv.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // $Id$
17 #include "StoreGate/StoreGateSvc.h"
19 #include "Identifier/IdHelper.h"
21 #include "GaudiKernel/IClassIDSvc.h"
22 #include "GaudiKernel/MsgStream.h"
23 
24 
25 namespace CaloIdCnv {
26 
27 
34  DataObject*& pObj)
35 {
36  // Get the a name of the class we're converting.
37  std::string type_name;
38  IClassIDSvc* clidsvc = 0;
39  CHECK( service ("ClassIDSvc", clidsvc) );
40  CHECK( clidsvc->getTypeNameOfID (objType(), type_name) );
41 
42  MsgStream log(msgSvc(), "CaloIDHelper_IDDetDescrCnv");
43  log << MSG::INFO << "in createObj: creating a " << type_name
44  << " helper object in the detector store" << endmsg;
45 
46  // Get the SG key.
47  DetDescrAddress* ddAddr;
48  ddAddr = dynamic_cast<DetDescrAddress*> (pAddr);
49  if(!ddAddr) {
50  log << MSG::FATAL << "Could not cast to DetDescrAddress." << endmsg;
51  return StatusCode::FAILURE;
52  }
53  std::string helperKey = *( ddAddr->par() );
54  if ("" == helperKey) {
55  log << MSG::DEBUG << "No Helper key " << endmsg;
56  }
57  else {
58  log << MSG::DEBUG << "Helper key is " << helperKey << endmsg;
59  }
60 
61  // get DetectorStore service
62  StoreGateSvc * detStore = 0;
63  CHECK( service("DetectorStore", detStore) );
64 
65  // Get the dictionary manager from the detector store
66  const IdDictManager* idDictMgr = 0;
67  CHECK( detStore->retrieve(idDictMgr, "IdDict") );
68 
69  // Create the helper.
70  IdHelper* idhelper = 0;
71  CHECK( createHelper (helperKey, idhelper, pObj) );
72 
73  // Initialize the helper.
74  idhelper->setMessageSvc (msgSvc());
75  if (idDictMgr->initializeHelper(*idhelper)) {
76  log << MSG::ERROR << "Unable to initialize " << type_name << endmsg;
77  return StatusCode::FAILURE;
78  }
79  else {
80  log << MSG::DEBUG << " Initialized " << type_name << endmsg;
81  }
82 
83  return StatusCode::SUCCESS;
84 }
85 
86 
91 {
92  return storageType();
93 }
94 
95 
102  ISvcLocator* svcloc)
103  : DetDescrConverter (clid, svcloc)
104 {
105 }
106 
107 
108 } // namespace CaloIdCnv
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
CaloIdCnv::CaloIDHelper_IDDetDescrCnv::createHelper
virtual StatusCode createHelper(const std::string &helperKey, IdHelper *&idhelper, DataObject *&pObj)=0
Create the helper object.
CaloIdCnv::CaloIDHelper_IDDetDescrCnv::CaloIDHelper_IDDetDescrCnv
CaloIDHelper_IDDetDescrCnv(const CLID &clid, ISvcLocator *svcloc)
Constructor.
Definition: CaloIDHelper_IDDetDescrCnv.cxx:101
DetDescrAddress.h
AthTPCnvSvc_test.clidsvc
clidsvc
Definition: AthTPCnvSvc_test.py:10
IdHelper.h
IdDictManager.h
CaloIdCnv::CaloIDHelper_IDDetDescrCnv::createObj
virtual StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj)
Called by the converter infrastructure to create an object.
Definition: CaloIDHelper_IDDetDescrCnv.cxx:33
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
IdHelper
Definition: IdHelper.h:39
ClassID_traits.h
a traits class that associates a CLID to a type T It also detects whether T inherits from Gaudi DataO...
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
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
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
IdHelper::setMessageSvc
virtual void setMessageSvc(IMessageSvc *msgSvc)=0
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
IdDictManager
IdDictManager is the interface to identifier dictionaries.
Definition: IdDictManager.h:36
errorcheck.h
Helpers for checking error return status codes and reporting errors.
CaloIDHelper_IDDetDescrCnv.h
Common code for creating calo ID helpers in the detector store.
DetDescrConverter::storageType
static long storageType()
Storage type for all DetDescrConverters.
Definition: DetDescrConverter.cxx:35
CaloIdCnv::CaloIDHelper_IDDetDescrCnv::repSvcType
virtual long int repSvcType() const
Return the service type.
Definition: CaloIDHelper_IDDetDescrCnv.cxx:90
DEBUG
#define DEBUG
Definition: page_access.h:11
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
CaloIdCnv
Definition: CaloIDHelper_IDDetDescrCnv.h:43
StoreGateSvc.h