ATLAS Offline Software
CaloIDHelper_IDDetDescrCnv.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 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  SmartIF<IClassIDSvc> clidsvc{ service ("ClassIDSvc") };
39  CHECK( clidsvc.isValid() );
40  CHECK( clidsvc->getTypeNameOfID (objType(), type_name) );
41 
42  // Get the SG key.
43  DetDescrAddress* ddAddr;
44  CHECK( (ddAddr = dynamic_cast<DetDescrAddress*> (pAddr)) != nullptr );
45  std::string helperKey = *( ddAddr->par() );
46  if (helperKey.empty()) {
47  ATH_MSG_DEBUG("No Helper key ");
48  }
49  else {
50  ATH_MSG_DEBUG("Helper key is " << helperKey);
51  }
52 
53  // Get the dictionary manager from the detector store
54  const IdDictManager* idDictMgr = 0;
55  CHECK( detStore()->retrieve(idDictMgr, "IdDict") );
56 
57  // Create the helper.
58  IdHelper* idhelper = 0;
59  CHECK( createHelper (helperKey, idhelper, pObj) );
60 
61  // Initialize the helper.
62  idhelper->setMessageSvc (msgSvc());
63  if (idDictMgr->initializeHelper(*idhelper)) {
64  ATH_MSG_ERROR("Unable to initialize " << type_name);
65  return StatusCode::FAILURE;
66  }
67  else {
68  ATH_MSG_DEBUG("Initialized " << type_name);
69  }
70 
71  return StatusCode::SUCCESS;
72 }
73 
74 
79 {
80  return storageType();
81 }
82 
83 
90  ISvcLocator* svcloc)
91  : DetDescrConverter (clid, svcloc, "CaloIDHelper_IDDetDescrCnv")
92 {
93 }
94 
95 
96 } // 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:89
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:33
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:78
CaloIdCnv
Definition: CaloIDHelper_IDDetDescrCnv.h:43
StoreGateSvc.h