ATLAS Offline Software
Loading...
Searching...
No Matches
HGTD_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
7
11
13
16#include "IdDict/IdDictMgr.h"
17
18//--------------------------------------------------------------------
19
20long int
22{
23 return (storageType());
24}
25
26//--------------------------------------------------------------------
27
28StatusCode
30{
31 // First call parent init
32 ATH_CHECK(DetDescrConverter::initialize());
33
34 return StatusCode::SUCCESS;
35}
36
37//--------------------------------------------------------------------
38
39StatusCode
40HGTD_IDDetDescrCnv::createObj(IOpaqueAddress* /*pAddr*/, DataObject*& pObj)
41{
42 ATH_MSG_INFO( "in createObj: creating a HGTD_ID helper object in the detector store" );
43
44 // Get the dictionary manager from the detector store
45 const IdDictManager* idDictMgr;
46 ATH_CHECK( detStore()->retrieve(idDictMgr, "IdDict") );
47
48 // Only initialize helper if it is the first pass or if there is a
49 // change in the the file or tag
50 bool initHelper = false;
51
52 const IdDictMgr* mgr = idDictMgr->manager();
53
54 // Internal InDet id tag
55 std::string inDetIDTag = mgr->tag();
56
57 // DoChecks flag
58 bool doChecks = mgr->do_checks();
59
60 const IdDictDictionary* dict = mgr->find_dictionary("InnerDetector");
61 if (!dict) {
62 ATH_MSG_ERROR( "unable to find idDict for InnerDetector" );
63 return StatusCode::FAILURE;
64 }
65
66 // File to be read for InDet ids
67 std::string inDetIDFileName = dict->file_name();
68 // Tag of RDB record for InDet ids
69 std::string inDetIdDictTag = dict->dict_tag();
70
71 if (m_hgtdId) {
72 // HGTD id helper already exists - second pass. Check for a
73 // change
74 if (inDetIDTag != m_inDetIDTag) {
75 // Internal InDet id tag
76 initHelper = true;
77 ATH_MSG_DEBUG( " Changed internal InDet id tag: " << inDetIDTag );
78 }
79 if (inDetIDFileName != m_inDetIDFileName) {
80 // File to be read for InDet ids
81 initHelper = true;
82 ATH_MSG_DEBUG( " Changed InDetFileName:" << inDetIDFileName );
83 }
84 if (inDetIdDictTag != m_inDetIdDictTag) {
85 // Tag of RDB record for InDet ids
86 initHelper = true;
87 ATH_MSG_DEBUG( " Changed InDetIdDictTag: " << inDetIdDictTag );
88 }
89 if (doChecks != m_doChecks) {
90 // DoChecks flag
91 initHelper = true;
92 ATH_MSG_DEBUG( " Changed doChecks flag: " << doChecks );
93 }
94 }
95 else {
96 // create the helper
97 m_hgtdId = std::make_unique<HGTD_ID>();
98 initHelper = true;
99 if(dict->version() == "P2-RUN4"){
100 m_hgtdId->set_useNewIdentifierScheme(true);
101 }
102 }
103
104 if (initHelper) {
105 if (idDictMgr->initializeHelper(*m_hgtdId)) {
106 ATH_MSG_ERROR( "Unable to initialize HGTD_ID" );
107 return StatusCode::FAILURE;
108 }
109 // Save state:
110 m_inDetIDTag = std::move(inDetIDTag);
111 m_inDetIDFileName = std::move(inDetIDFileName);
112 m_inDetIdDictTag = std::move(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_hgtdId.release());
118
119 return StatusCode::SUCCESS;
120
121}
122
123//--------------------------------------------------------------------
124
125long
130
131//--------------------------------------------------------------------
132const CLID&
136
137//--------------------------------------------------------------------
139 :
140 DetDescrConverter(ClassID_traits<HGTD_ID>::ID(), svcloc, "HGTD_IDDetDescrCnv"),
141 m_hgtdId(),
142 m_doChecks(false)
143
144{}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(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.
std::string m_inDetIDFileName
File to be read for InDet ids.
virtual long int repSvcType() const override final
static const CLID & classID()
std::string m_inDetIdDictTag
Tag of RDB record for InDet ids.
virtual StatusCode initialize() override final
virtual StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj) override final
std::string m_inDetIDTag
Internal InDet id tag.
HGTD_IDDetDescrCnv(ISvcLocator *svcloc)
bool m_doChecks
Whether or not.
std::unique_ptr< HGTD_ID > m_hgtdId
The helper - only will create it once.
This is an Identifier helper class for the HGTD subdetector.
Definition HGTD_ID.h:47
IdDictManager is the interface to identifier dictionaries.
const IdDictMgr * manager(void) const
int initializeHelper(IdHelper &helper) const
Return value: 0 OK, >0 error.
DataObject * asStorable(SG::DataObjectSharedPtr< T > pObject)
Default, invalid implementation of ClassID_traits.