ATLAS Offline Software
Loading...
Searching...
No Matches
ZdcIDDetDescrCnv.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5/***************************************************************************
6 ForwardIdCnv package
7 -----------------------------------------
8 ***************************************************************************/
9
10#include "ZdcIDDetDescrCnv.h"
11
15#include "GaudiKernel/MsgStream.h"
16
19#include "IdDict/IdDictMgr.h"
20#include "ZdcIdentifier/ZdcID.h"
21
22
23//--------------------------------------------------------------------
24
25long int
27{
28 return (storageType());
29}
30
31//--------------------------------------------------------------------
32
33StatusCode
35{
36 ATH_CHECK( DetDescrConverter::initialize() );
37 return StatusCode::SUCCESS;
38}
39
40//--------------------------------------------------------------------
41
42StatusCode
43ZdcIDDetDescrCnv::createObj(IOpaqueAddress* /*pAddr*/, DataObject*& pObj)
44{
45 // Get the dictionary manager from the detector store
46 const IdDictManager* idDictMgr = nullptr;
47 ATH_CHECK( detStore()->retrieve(idDictMgr, "IdDict") );
48
49 // Only initialize helper if it is the first pass or if there is a
50 // change in the the file or tag
51 bool initHelper = false;
52
53 const IdDictMgr* mgr = idDictMgr->manager();
54
55 // Internal InDet id tag
56 std::string inDetIDTag = mgr->tag();
57
58 // DoChecks flag
59 bool doChecks = mgr->do_checks();
60
61 const IdDictDictionary* dict = mgr->find_dictionary("InnerDetector");
62 if (!dict) {
63 ATH_MSG_ERROR("unable to find idDict for InnerDetector");
64 return StatusCode::FAILURE;
65 }
66
67 // File to be read for InDet ids
68 std::string inDetIDFileName = dict->file_name();
69
70 // Tag of RDB record for InDet ids
71 std::string inDetIdDictTag = dict->dict_tag();
72
73
74 if (m_zdcId) {
75
76 // Zdc id helper already exists - second pass. Check for a
77 // change
78 if (inDetIDTag != m_inDetIDTag) {
79 // Internal InDet id tag
80 initHelper = true;
81 ATH_MSG_DEBUG(" Changed internal InDet id tag: " << inDetIDTag);
82 }
83 if (inDetIDFileName != m_inDetIDFileName) {
84 // File to be read for InDet ids
85 initHelper = true;
86 ATH_MSG_DEBUG(" Changed InDetFileName:" << inDetIDFileName);
87 }
88 if (inDetIdDictTag != m_inDetIdDictTag) {
89 // Tag of RDB record for InDet ids
90 initHelper = true;
91 ATH_MSG_DEBUG(" Changed InDetIdDictTag: " << inDetIdDictTag);
92 }
93 if (doChecks != m_doChecks) {
94 // DoChecks flag
95 initHelper = true;
96 ATH_MSG_DEBUG(" Changed doChecks flag: " << doChecks);
97 }
98 }
99 else {
100 // create the helper
101 m_zdcId = new ZdcID;
102 initHelper = true;
103 }
104
105 if (initHelper) {
106 ATH_CHECK( idDictMgr->initializeHelper(*m_zdcId) == 0 );
107
108 // Save state:
109 m_inDetIDTag = std::move(inDetIDTag);
110 m_inDetIDFileName = std::move(inDetIDFileName);
111 m_inDetIdDictTag = std::move(inDetIdDictTag);
112 m_doChecks = doChecks;
113 }
114
115 // Pass a pointer to the container to the Persistency service by reference.
116 pObj = SG::asStorable(m_zdcId);
117
118 return StatusCode::SUCCESS;
119
120}
121
122//--------------------------------------------------------------------
123
124long
129
130//--------------------------------------------------------------------
131const CLID&
135
136//--------------------------------------------------------------------
138 :
139 DetDescrConverter(ClassID_traits<ZdcID>::ID(), svcloc, "ZdcIDDetDescrCnv"),
140 m_zdcId(0),
141 m_doChecks(false)
142
143{}
144
145
146
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
std::vector< Identifier > ID
const long DetDescr_StorageType
uint32_t CLID
The Class ID type.
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.
const IdDictMgr * manager(void) const
int initializeHelper(IdHelper &helper) const
Return value: 0 OK, >0 error.
static long storageType()
std::string m_inDetIdDictTag
Tag of RDB record for InDet ids.
virtual StatusCode initialize() override
std::string m_inDetIDTag
Internal InDet id tag.
std::string m_inDetIDFileName
File to be read for InDet ids.
static const CLID & classID()
virtual long int repSvcType() const override
ZdcID * m_zdcId
The helper - only will create it once.
virtual StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj) override
bool m_doChecks
Whether or not.
ZdcIDDetDescrCnv(ISvcLocator *svcloc)
Definition ZdcID.h:25
DataObject * asStorable(SG::DataObjectSharedPtr< T > pObject)
Default, invalid implementation of ClassID_traits.