ATLAS Offline Software
ZdcIDDetDescrCnv.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 /***************************************************************************
6  ForwardIdCnv package
7  -----------------------------------------
8  ***************************************************************************/
9 
10 #include "ZdcIDDetDescrCnv.h"
11 
14 #include "StoreGate/StoreGateSvc.h"
15 #include "GaudiKernel/MsgStream.h"
16 
18 #include "ZdcIdentifier/ZdcID.h"
19 
20 
21 //--------------------------------------------------------------------
22 
23 long int
25 {
26  return (storageType());
27 }
28 
29 //--------------------------------------------------------------------
30 
33 {
35  return StatusCode::SUCCESS;
36 }
37 
38 //--------------------------------------------------------------------
39 
41 ZdcIDDetDescrCnv::createObj(IOpaqueAddress* /*pAddr*/, DataObject*& pObj)
42 {
43  // Get the dictionary manager from the detector store
44  const IdDictManager* idDictMgr = nullptr;
45  ATH_CHECK( detStore()->retrieve(idDictMgr, "IdDict") );
46 
47  // Only initialize helper if it is the first pass or if there is a
48  // change in the the file or tag
49  bool initHelper = false;
50 
51  const IdDictMgr* mgr = idDictMgr->manager();
52 
53  // Internal InDet id tag
54  std::string inDetIDTag = mgr->tag();
55 
56  // DoChecks flag
57  bool doChecks = mgr->do_checks();
58 
59  IdDictDictionary* dict = mgr->find_dictionary("InnerDetector");
60  if (!dict) {
61  ATH_MSG_ERROR("unable to find idDict for InnerDetector");
62  return StatusCode::FAILURE;
63  }
64 
65  // File to be read for InDet ids
66  std::string inDetIDFileName = dict->file_name();
67 
68  // Tag of RDB record for InDet ids
69  std::string inDetIdDictTag = dict->dict_tag();
70 
71 
72  if (m_zdcId) {
73 
74  // Zdc id helper already exists - second pass. Check for a
75  // change
76  if (inDetIDTag != m_inDetIDTag) {
77  // Internal InDet id tag
78  initHelper = true;
79  ATH_MSG_DEBUG(" Changed internal InDet id tag: " << inDetIDTag);
80  }
81  if (inDetIDFileName != m_inDetIDFileName) {
82  // File to be read for InDet ids
83  initHelper = true;
84  ATH_MSG_DEBUG(" Changed InDetFileName:" << inDetIDFileName);
85  }
86  if (inDetIdDictTag != m_inDetIdDictTag) {
87  // Tag of RDB record for InDet ids
88  initHelper = true;
89  ATH_MSG_DEBUG(" Changed InDetIdDictTag: " << inDetIdDictTag);
90  }
91  if (doChecks != m_doChecks) {
92  // DoChecks flag
93  initHelper = true;
94  ATH_MSG_DEBUG(" Changed doChecks flag: " << doChecks);
95  }
96  }
97  else {
98  // create the helper
99  m_zdcId = new ZdcID;
100  initHelper = true;
101  // add in message service for printout
103  }
104 
105  if (initHelper) {
106  ATH_CHECK( idDictMgr->initializeHelper(*m_zdcId) == 0 );
107 
108  // Save state:
109  m_inDetIDTag = inDetIDTag;
110  m_inDetIDFileName = inDetIDFileName;
111  m_inDetIdDictTag = 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 
124 long
126 {
127  return DetDescr_StorageType;
128 }
129 
130 //--------------------------------------------------------------------
131 const CLID&
133  return ClassID_traits<ZdcID>::ID();
134 }
135 
136 //--------------------------------------------------------------------
138  :
139  DetDescrConverter(ClassID_traits<ZdcID>::ID(), svcloc, "ZdcIDDetDescrCnv"),
140  m_zdcId(0),
141  m_doChecks(false)
142 
143 {}
144 
145 
146 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
IdDictDictionary::dict_tag
const std::string & dict_tag(void) const
Access to the dictionary tag.
Definition: IdDictDefs.h:665
ZdcIDDetDescrCnv::initialize
virtual StatusCode initialize() override
Definition: ZdcIDDetDescrCnv.cxx:32
ZdcIDDetDescrCnv.h
AtlasDetectorID::setMessageSvc
virtual void setMessageSvc(IMessageSvc *msgSvc) override
Definition: AtlasDetectorID.cxx:748
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:132
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
SG::asStorable
DataObject * asStorable(T *pObject)
Definition: StorableConversions.h:158
IdDictManager.h
DetDescrConverter::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Handle to DetectorStore.
Definition: DetDescrConverter.h:33
BchCleanup.mgr
mgr
Definition: BchCleanup.py:294
ClassID_traits::ID
static const CLID & ID()
the CLID of T
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:50
IdDictMgr
Definition: IdDictDefs.h:32
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:40
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:44
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
IdDictDictionary::file_name
const std::string & file_name(void) const
Access to file name.
Definition: IdDictDefs.h:657
ZdcIDDetDescrCnv::repSvcType
virtual long int repSvcType() const override
Definition: ZdcIDDetDescrCnv.cxx:24
ZdcIDDetDescrCnv::createObj
virtual StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj) override
Definition: ZdcIDDetDescrCnv.cxx:41
IdDictManager
IdDictManager is the interface to identifier dictionaries.
Definition: IdDictManager.h:36
IdDictDictionary
Definition: IdDictDefs.h:97
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:125
ZdcID.h
DetDescrConverter.h
IdDictManager::manager
const IdDictMgr * manager(void) const
Definition: IdDictManager.cxx:37
ZdcIDDetDescrCnv::ZdcIDDetDescrCnv
ZdcIDDetDescrCnv(ISvcLocator *svcloc)
Definition: ZdcIDDetDescrCnv.cxx:137
ZdcIDDetDescrCnv::m_doChecks
bool m_doChecks
Whether or not.
Definition: ZdcIDDetDescrCnv.h:46
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