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