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