ATLAS Offline Software
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 
6 #include "HGTD_IDDetDescrCnv.h"
7 
10 #include "StoreGate/StoreGateSvc.h"
11 
13 
16 #include "IdDict/IdDictMgr.h"
17 
18 //--------------------------------------------------------------------
19 
20 long int
22 {
23  return (storageType());
24 }
25 
26 //--------------------------------------------------------------------
27 
30 {
31  // First call parent init
33 
34  return StatusCode::SUCCESS;
35 }
36 
37 //--------------------------------------------------------------------
38 
40 HGTD_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  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  // add in message service for printout
100  m_hgtdId->setMessageSvc(msgSvc());
101  if(dict->version() == "P2-RUN4"){
102  m_hgtdId->set_useNewIdentifierScheme(true);
103  }
104  }
105 
106  if (initHelper) {
107  if (idDictMgr->initializeHelper(*m_hgtdId)) {
108  ATH_MSG_ERROR( "Unable to initialize HGTD_ID" );
109  return StatusCode::FAILURE;
110  }
111  // Save state:
112  m_inDetIDTag = std::move(inDetIDTag);
113  m_inDetIDFileName = std::move(inDetIDFileName);
114  m_inDetIdDictTag = std::move(inDetIdDictTag);
115  m_doChecks = doChecks;
116  }
117 
118  // Pass a pointer to the container to the Persistency service by reference.
119  pObj = SG::asStorable(m_hgtdId.release());
120 
121  return StatusCode::SUCCESS;
122 
123 }
124 
125 //--------------------------------------------------------------------
126 
127 long
129 {
130  return DetDescr_StorageType;
131 }
132 
133 //--------------------------------------------------------------------
134 const CLID&
137 }
138 
139 //--------------------------------------------------------------------
141  :
142  DetDescrConverter(ClassID_traits<HGTD_ID>::ID(), svcloc, "HGTD_IDDetDescrCnv"),
143  m_hgtdId(),
144  m_doChecks(false)
145 
146 {}
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
IdDictMgr.h
HGTD_IDDetDescrCnv::m_inDetIDTag
std::string m_inDetIDTag
Internal InDet id tag.
Definition: HGTD_IDDetDescrCnv.h:51
AthCheckMacros.h
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
DetDescr_StorageType
const long DetDescr_StorageType
Definition: DetDescrCnvSvc.cxx:20
ID
std::vector< Identifier > ID
Definition: CalibHitIDCheck.h:24
IdDictDictionary::version
const std::string & version() const
Dictionary version.
Definition: IdDictDictionary.h:341
IdDictDictionary.h
initialize
void initialize()
Definition: run_EoverP.cxx:894
HGTD_IDDetDescrCnv::m_inDetIdDictTag
std::string m_inDetIdDictTag
Tag of RDB record for InDet ids.
Definition: HGTD_IDDetDescrCnv.h:48
HGTD_IDDetDescrCnv::createObj
virtual StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj) override final
Definition: HGTD_IDDetDescrCnv.cxx:40
HGTD_IDDetDescrCnv::storageType
static long storageType()
Definition: HGTD_IDDetDescrCnv.cxx:128
DetDescrAddress.h
IdDictManager.h
HGTD_IDDetDescrCnv::classID
static const CLID & classID()
Definition: HGTD_IDDetDescrCnv.cxx:135
IdDictDictionary::file_name
const std::string & file_name() const
Access to file name.
Definition: IdDictDictionary.h:367
DetDescrConverter::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Handle to DetectorStore.
Definition: DetDescrConverter.h:33
HGTD_IDDetDescrCnv::initialize
virtual StatusCode initialize() override final
Definition: HGTD_IDDetDescrCnv.cxx:29
BchCleanup.mgr
mgr
Definition: BchCleanup.py:294
SG::asStorable
DataObject * asStorable(SG::DataObjectSharedPtr< T > pObject)
Definition: DataObjectSharedPtr.h:31
HGTD_IDDetDescrCnv.h
IdDictMgr
Definition: IdDictMgr.h:15
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:37
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
HGTD_ID
Definition: HGTD_ID.h:47
IdDictManager::initializeHelper
int initializeHelper(IdHelper &helper) const
Return value: 0 OK, >0 error.
Definition: IdDictManager.cxx:37
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
HGTD_IDDetDescrCnv::repSvcType
virtual long int repSvcType() const override final
Definition: HGTD_IDDetDescrCnv.cxx:21
IdDictManager
IdDictManager is the interface to identifier dictionaries.
Definition: IdDictManager.h:26
IdDictDictionary
Definition: IdDictDictionary.h:30
IdDictDictionary::dict_tag
const std::string & dict_tag() const
Access to the dictionary tag.
Definition: IdDictDictionary.h:374
DetDescrConverter.h
HGTD_IDDetDescrCnv::m_hgtdId
std::unique_ptr< HGTD_ID > m_hgtdId
The helper - only will create it once.
Definition: HGTD_IDDetDescrCnv.h:42
IdDictManager::manager
const IdDictMgr * manager(void) const
Definition: IdDictManager.cxx:30
HGTD_IDDetDescrCnv::m_inDetIDFileName
std::string m_inDetIDFileName
File to be read for InDet ids.
Definition: HGTD_IDDetDescrCnv.h:45
ClassID_traits::ID
static CLID ID()
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:44
HGTD_IDDetDescrCnv::HGTD_IDDetDescrCnv
HGTD_IDDetDescrCnv(ISvcLocator *svcloc)
Definition: HGTD_IDDetDescrCnv.cxx:140
StoreGateSvc.h
HGTD_IDDetDescrCnv::m_doChecks
bool m_doChecks
Whether or not.
Definition: HGTD_IDDetDescrCnv.h:54