ATLAS Offline Software
Loading...
Searching...
No Matches
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*/
10
11
17#include "Identifier/IdHelper.h"
19#include "GaudiKernel/IClassIDSvc.h"
20#include "GaudiKernel/MsgStream.h"
21
22
23namespace CaloIdCnv {
24
25
31StatusCode CaloIDHelper_IDDetDescrCnv::createObj (IOpaqueAddress* pAddr,
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 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 }
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
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
Common code for creating calo ID helpers in the detector store.
a traits class that associates a CLID to a type T It also detects whether T inherits from Gaudi DataO...
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
uint32_t CLID
The Class ID type.
virtual StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj)
Called by the converter infrastructure to create an object.
virtual StatusCode createHelper(const std::string &helperKey, IdHelper *&idhelper, DataObject *&pObj)=0
Create the helper object.
virtual long int repSvcType() const
Return the service type.
CaloIDHelper_IDDetDescrCnv(const CLID &clid, ISvcLocator *svcloc)
Constructor.
static long storageType()
Storage type for all DetDescrConverters.
DetDescrConverter(const CLID &myCLID, ISvcLocator *svcloc, const char *name=nullptr)
const ServiceHandle< StoreGateSvc > & detStore() const
Handle to DetectorStore.
IdDictManager is the interface to identifier dictionaries.
int initializeHelper(IdHelper &helper) const
Return value: 0 OK, >0 error.
This is an abstract base class for helper classes that know how to convert Identifier <-> IdentifierH...
Definition IdHelper.h:24