ATLAS Offline Software
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 
14 #include "StoreGate/StoreGateSvc.h"
15 #include "GaudiKernel/MsgStream.h"
16 
19 #include "IdDict/IdDictMgr.h"
20 #include "ZdcIdentifier/ZdcID.h"
21 
22 
23 //--------------------------------------------------------------------
24 
25 long int
27 {
28  return (storageType());
29 }
30 
31 //--------------------------------------------------------------------
32 
35 {
37  return StatusCode::SUCCESS;
38 }
39 
40 //--------------------------------------------------------------------
41 
43 ZdcIDDetDescrCnv::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  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  // add in message service for printout
105  }
106 
107  if (initHelper) {
108  ATH_CHECK( idDictMgr->initializeHelper(*m_zdcId) == 0 );
109 
110  // Save state:
111  m_inDetIDTag = std::move(inDetIDTag);
112  m_inDetIDFileName = std::move(inDetIDFileName);
113  m_inDetIdDictTag = std::move(inDetIdDictTag);
114  m_doChecks = doChecks;
115  }
116 
117  // Pass a pointer to the container to the Persistency service by reference.
118  pObj = SG::asStorable(m_zdcId);
119 
120  return StatusCode::SUCCESS;
121 
122 }
123 
124 //--------------------------------------------------------------------
125 
126 long
128 {
129  return DetDescr_StorageType;
130 }
131 
132 //--------------------------------------------------------------------
133 const CLID&
135  return ClassID_traits<ZdcID>::ID();
136 }
137 
138 //--------------------------------------------------------------------
140  :
141  DetDescrConverter(ClassID_traits<ZdcID>::ID(), svcloc, "ZdcIDDetDescrCnv"),
142  m_zdcId(0),
143  m_doChecks(false)
144 
145 {}
146 
147 
148 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
IdDictMgr.h
ZdcIDDetDescrCnv::initialize
virtual StatusCode initialize() override
Definition: ZdcIDDetDescrCnv.cxx:34
ZdcIDDetDescrCnv.h
AtlasDetectorID::setMessageSvc
virtual void setMessageSvc(IMessageSvc *msgSvc) override
Definition: AtlasDetectorID.cxx:491
DetDescr_StorageType
const long DetDescr_StorageType
Definition: DetDescrCnvSvc.cxx:20
ID
std::vector< Identifier > ID
Definition: CalibHitIDCheck.h:24
ZdcIDDetDescrCnv::classID
static const CLID & classID()
Definition: ZdcIDDetDescrCnv.cxx:134
IdDictDictionary.h
ZdcIDDetDescrCnv::m_zdcId
ZdcID * m_zdcId
The helper - only will create it once.
Definition: ZdcIDDetDescrCnv.h:34
initialize
void initialize()
Definition: run_EoverP.cxx:894
DetDescrAddress.h
IdDictManager.h
IdDictDictionary::file_name
const std::string & file_name() const
Access to file name.
Definition: IdDictDictionary.h:367
DetDescrConverter::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Handle to DetectorStore.
Definition: DetDescrConverter.h:33
BchCleanup.mgr
mgr
Definition: BchCleanup.py:294
SG::asStorable
DataObject * asStorable(SG::DataObjectSharedPtr< T > pObject)
Definition: DataObjectSharedPtr.h:31
IdDictMgr
Definition: IdDictMgr.h:15
ZdcIDDetDescrCnv::m_inDetIDTag
std::string m_inDetIDTag
Internal InDet id tag.
Definition: ZdcIDDetDescrCnv.h:43
DetDescrConverter
Definition: DetDescrConverter.h:25
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
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
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:37
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
IdDictManager::initializeHelper
int initializeHelper(IdHelper &helper) const
Return value: 0 OK, >0 error.
Definition: IdDictManager.cxx:37
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
ZdcIDDetDescrCnv::repSvcType
virtual long int repSvcType() const override
Definition: ZdcIDDetDescrCnv.cxx:26
ZdcIDDetDescrCnv::createObj
virtual StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj) override
Definition: ZdcIDDetDescrCnv.cxx:43
IdDictManager
IdDictManager is the interface to identifier dictionaries.
Definition: IdDictManager.h:26
IdDictDictionary
Definition: IdDictDictionary.h:30
ZdcIDDetDescrCnv::m_inDetIdDictTag
std::string m_inDetIdDictTag
Tag of RDB record for InDet ids.
Definition: ZdcIDDetDescrCnv.h:40
ZdcIDDetDescrCnv::storageType
static long storageType()
Definition: ZdcIDDetDescrCnv.cxx:127
ZdcID.h
IdDictDictionary::dict_tag
const std::string & dict_tag() const
Access to the dictionary tag.
Definition: IdDictDictionary.h:374
DetDescrConverter.h
IdDictManager::manager
const IdDictMgr * manager(void) const
Definition: IdDictManager.cxx:30
ZdcIDDetDescrCnv::ZdcIDDetDescrCnv
ZdcIDDetDescrCnv(ISvcLocator *svcloc)
Definition: ZdcIDDetDescrCnv.cxx:139
ZdcIDDetDescrCnv::m_doChecks
bool m_doChecks
Whether or not.
Definition: ZdcIDDetDescrCnv.h:46
ClassID_traits::ID
static CLID ID()
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:44
ZdcIDDetDescrCnv::m_inDetIDFileName
std::string m_inDetIDFileName
File to be read for InDet ids.
Definition: ZdcIDDetDescrCnv.h:37
StoreGateSvc.h
ZdcID
Definition: ZdcID.h:25