ATLAS Offline Software
TRT_IDDetDescrCnv.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 #include "TRT_IDDetDescrCnv.h"
6 
9 #include "GaudiKernel/MsgStream.h"
10 #include "StoreGate/StoreGateSvc.h"
11 
13 #include "InDetIdentifier/TRT_ID.h"
14 
15 
16 //--------------------------------------------------------------------
17 
18 long int
20 {
21  return (storageType());
22 }
23 
24 //--------------------------------------------------------------------
25 
28 {
30  return StatusCode::SUCCESS;
31 }
32 
33 //--------------------------------------------------------------------
34 
36 TRT_IDDetDescrCnv::createObj(IOpaqueAddress* /*pAddr*/, DataObject*& pObj)
37 {
38  // Get the dictionary manager from the detector store
39  const IdDictManager* idDictMgr;
40  ATH_CHECK( detStore()->retrieve(idDictMgr, "IdDict") );
41 
42  // Only initialize helper if it is the first pass or if there is a
43  // change in the the file or tag
44  bool initHelper = false;
45 
46  const IdDictMgr* mgr = idDictMgr->manager();
47 
48  // Internal InDet id tag
49  std::string inDetIDTag = mgr->tag();
50 
51  // DoChecks flag
52  bool doChecks = mgr->do_checks();
53 
54  IdDictDictionary* dict = mgr->find_dictionary("InnerDetector");
55  if (!dict) {
56  ATH_MSG_ERROR("unable to find idDict for InnerDetector");
57  return StatusCode::FAILURE;
58  }
59 
60  // File to be read for InDet ids
61  std::string inDetIDFileName = dict->file_name();
62 
63  // Tag of RDB record for InDet ids
64  std::string inDetIdDictTag = dict->dict_tag();
65 
66 
67  if (m_trtId) {
68 
69  // TRT id helper already exists - second pass. Check for a
70  // change
71  if (inDetIDTag != m_inDetIDTag) {
72  // Internal InDet id tag
73  initHelper = true;
74  ATH_MSG_DEBUG(" Changed internal InDet id tag: " << inDetIDTag);
75  }
76  if (inDetIDFileName != m_inDetIDFileName) {
77  // File to be read for InDet ids
78  initHelper = true;
79  ATH_MSG_DEBUG(" Changed InDetFileName:" << inDetIDFileName);
80  }
81  if (inDetIdDictTag != m_inDetIdDictTag) {
82  // Tag of RDB record for InDet ids
83  initHelper = true;
84  ATH_MSG_DEBUG(" Changed InDetIdDictTag: " << inDetIdDictTag);
85  }
86  if (doChecks != m_doChecks) {
87  // DoChecks flag
88  initHelper = true;
89  ATH_MSG_DEBUG(" Changed doChecks flag: " << doChecks);
90  }
91  }
92  else {
93  // create the helper
94  m_trtId = new TRT_ID;
95  initHelper = true;
96  // add in message service for printout
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 
120 long
122 {
123  return DetDescr_StorageType;
124 }
125 
126 //--------------------------------------------------------------------
127 const CLID&
129  return ClassID_traits<TRT_ID>::ID();
130 }
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 
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: IdDictDictionary.h:262
TRT_IDDetDescrCnv::m_trtId
TRT_ID * m_trtId
The helper - only will create it once.
Definition: TRT_IDDetDescrCnv.h:35
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
TRT_IDDetDescrCnv::m_inDetIDFileName
std::string m_inDetIDFileName
File to be read for InDet ids.
Definition: TRT_IDDetDescrCnv.h:38
initialize
void initialize()
Definition: run_EoverP.cxx:894
TRT_IDDetDescrCnv::initialize
virtual StatusCode initialize() override
Definition: TRT_IDDetDescrCnv.cxx:27
TRT_IDDetDescrCnv.h
TRT_ID.h
This is an Identifier helper class for the TRT subdetector. This class is a factory for creating comp...
DetDescrAddress.h
IdDictManager.h
DetDescrConverter::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Handle to DetectorStore.
Definition: DetDescrConverter.h:33
BchCleanup.mgr
mgr
Definition: BchCleanup.py:294
TRT_IDDetDescrCnv::storageType
static long storageType()
Definition: TRT_IDDetDescrCnv.cxx:121
SG::asStorable
DataObject * asStorable(SG::DataObjectSharedPtr< T > pObject)
Definition: DataObjectSharedPtr.h:65
ClassID_traits::ID
static const CLID & ID()
the CLID of T
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:50
TRT_IDDetDescrCnv::m_inDetIDTag
std::string m_inDetIDTag
Internal InDet id tag.
Definition: TRT_IDDetDescrCnv.h:44
IdDictMgr
Definition: IdDictMgr.h:14
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
TRT_IDDetDescrCnv::m_inDetIdDictTag
std::string m_inDetIdDictTag
Tag of RDB record for InDet ids.
Definition: TRT_IDDetDescrCnv.h:41
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: IdDictDictionary.h:255
IdDictManager
IdDictManager is the interface to identifier dictionaries.
Definition: IdDictManager.h:36
IdDictDictionary
Definition: IdDictDictionary.h:30
TRT_IDDetDescrCnv::m_doChecks
bool m_doChecks
Whether or not.
Definition: TRT_IDDetDescrCnv.h:47
TRT_ID
Definition: TRT_ID.h:84
TRT_IDDetDescrCnv::createObj
virtual StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj) override
Definition: TRT_IDDetDescrCnv.cxx:36
DetDescrConverter.h
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
IdDictManager::manager
const IdDictMgr * manager(void) const
Definition: IdDictManager.cxx:37
TRT_IDDetDescrCnv::TRT_IDDetDescrCnv
TRT_IDDetDescrCnv(ISvcLocator *svcloc)
Definition: TRT_IDDetDescrCnv.cxx:133
StoreGateSvc.h
TRT_IDDetDescrCnv::repSvcType
virtual long int repSvcType() const override
Definition: TRT_IDDetDescrCnv.cxx:19
TRT_IDDetDescrCnv::classID
static const CLID & classID()
Definition: TRT_IDDetDescrCnv.cxx:128