ATLAS Offline Software
CaloIDHelper_IDDetDescrCnv.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
15 #include "StoreGate/StoreGateSvc.h"
17 #include "Identifier/IdHelper.h"
19 #include "GaudiKernel/IClassIDSvc.h"
20 #include "GaudiKernel/MsgStream.h"
21 
22 
23 namespace CaloIdCnv {
24 
25 
32  DataObject*& pObj)
33 {
34  // Get the a name of the class we're converting.
35  std::string type_name;
36  SmartIF<IClassIDSvc> clidsvc{ service ("ClassIDSvc") };
37  CHECK( clidsvc.isValid() );
38  CHECK( clidsvc->getTypeNameOfID (objType(), type_name) );
39 
40  // Get the SG key.
41  DetDescrAddress* ddAddr = dynamic_cast<DetDescrAddress*> (pAddr);
42  if (!ddAddr) {
43  ATH_MSG_ERROR ("Dynamic cast to DetDescrAddress fails!");
44  return StatusCode::FAILURE;
45  }
46  std::string helperKey = *( ddAddr->par() );
47  if (helperKey.empty()) {
48  ATH_MSG_DEBUG("No Helper key ");
49  }
50  else {
51  ATH_MSG_DEBUG("Helper key is " << helperKey);
52  }
53 
54  // Get the dictionary manager from the detector store
55  const IdDictManager* idDictMgr = 0;
56  CHECK( detStore()->retrieve(idDictMgr, "IdDict") );
57 
58  // Create the helper.
59  IdHelper* idhelper = 0;
60  CHECK( createHelper (helperKey, idhelper, pObj) );
61 
62  // Initialize the helper.
63  idhelper->setMessageSvc (msgSvc());
64  if (idDictMgr->initializeHelper(*idhelper)) {
65  ATH_MSG_ERROR("Unable to initialize " << type_name);
66  return StatusCode::FAILURE;
67  }
68  else {
69  ATH_MSG_DEBUG("Initialized " << type_name);
70  }
71 
72  return StatusCode::SUCCESS;
73 }
74 
75 
80 {
81  return storageType();
82 }
83 
84 
91  ISvcLocator* svcloc)
92  : DetDescrConverter (clid, svcloc, "CaloIDHelper_IDDetDescrCnv")
93 {
94 }
95 
96 
97 } // namespace CaloIdCnv
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
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:90
DetDescrAddress.h
IdHelper.h
IdDictManager.h
DetDescrConverter::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Handle to DetectorStore.
Definition: DetDescrConverter.h:33
CaloIdCnv::CaloIDHelper_IDDetDescrCnv::createObj
virtual StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj)
Called by the converter infrastructure to create an object.
Definition: CaloIDHelper_IDDetDescrCnv.cxx:31
DetDescrConverter
Definition: DetDescrConverter.h:25
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
DetDescrAddress
Definition: DetDescrAddress.h:32
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
IdHelper
This is an abstract base class for helper classes that know how to convert Identifier <-> IdentifierH...
Definition: IdHelper.h:24
ClassID_traits.h
a traits class that associates a CLID to a type T It also detects whether T inherits from Gaudi DataO...
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
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
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:30
CaloIdCnv::CaloIDHelper_IDDetDescrCnv::repSvcType
virtual long int repSvcType() const
Return the service type.
Definition: CaloIDHelper_IDDetDescrCnv.cxx:79
CaloIdCnv
Definition: CaloIDHelper_IDDetDescrCnv.h:43
StoreGateSvc.h