ATLAS Offline Software
HGTD_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 
6 #include "HGTD_IDDetDescrCnv.h"
7 
10 #include "StoreGate/StoreGateSvc.h"
11 
13 
15 
16 //--------------------------------------------------------------------
17 
18 long int
20 {
21  return (storageType());
22 }
23 
24 //--------------------------------------------------------------------
25 
28 {
29  // First call parent init
31 
32  return StatusCode::SUCCESS;
33 }
34 
35 //--------------------------------------------------------------------
36 
38 HGTD_IDDetDescrCnv::createObj(IOpaqueAddress* /*pAddr*/, DataObject*& pObj)
39 {
40  ATH_MSG_INFO( "in createObj: creating a HGTD_ID helper object in the detector store" );
41 
42  // Get the dictionary manager from the detector store
43  const IdDictManager* idDictMgr;
44  ATH_CHECK( detStore()->retrieve(idDictMgr, "IdDict") );
45 
46  // Only initialize helper if it is the first pass or if there is a
47  // change in the the file or tag
48  bool initHelper = false;
49 
50  const IdDictMgr* mgr = idDictMgr->manager();
51 
52  // Internal InDet id tag
53  std::string inDetIDTag = mgr->tag();
54 
55  // DoChecks flag
56  bool doChecks = mgr->do_checks();
57 
58  IdDictDictionary* dict = mgr->find_dictionary("InnerDetector");
59  if (!dict) {
60  ATH_MSG_ERROR( "unable to find idDict for InnerDetector" );
61  return StatusCode::FAILURE;
62  }
63 
64  // File to be read for InDet ids
65  std::string inDetIDFileName = dict->file_name();
66  // Tag of RDB record for InDet ids
67  std::string inDetIdDictTag = dict->dict_tag();
68 
69  if (m_hgtdId) {
70  // HGTD id helper already exists - second pass. Check for a
71  // change
72  if (inDetIDTag != m_inDetIDTag) {
73  // Internal InDet id tag
74  initHelper = true;
75  ATH_MSG_DEBUG( " Changed internal InDet id tag: " << inDetIDTag );
76  }
77  if (inDetIDFileName != m_inDetIDFileName) {
78  // File to be read for InDet ids
79  initHelper = true;
80  ATH_MSG_DEBUG( " Changed InDetFileName:" << inDetIDFileName );
81  }
82  if (inDetIdDictTag != m_inDetIdDictTag) {
83  // Tag of RDB record for InDet ids
84  initHelper = true;
85  ATH_MSG_DEBUG( " Changed InDetIdDictTag: " << inDetIdDictTag );
86  }
87  if (doChecks != m_doChecks) {
88  // DoChecks flag
89  initHelper = true;
90  ATH_MSG_DEBUG( " Changed doChecks flag: " << doChecks );
91  }
92  }
93  else {
94  // create the helper
95  m_hgtdId = std::make_unique<HGTD_ID>();
96  initHelper = true;
97  // add in message service for printout
98  m_hgtdId->setMessageSvc(msgSvc());
99  if(dict->m_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 = 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_hgtdId.release());
118 
119  return StatusCode::SUCCESS;
120 
121 }
122 
123 //--------------------------------------------------------------------
124 
125 long
127 {
128  return DetDescr_StorageType;
129 }
130 
131 //--------------------------------------------------------------------
132 const CLID&
135 }
136 
137 //--------------------------------------------------------------------
139  :
140  DetDescrConverter(ClassID_traits<HGTD_ID>::ID(), svcloc, "HGTD_IDDetDescrCnv"),
141  m_hgtdId(),
142  m_doChecks(false)
143 
144 {}
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
HGTD_IDDetDescrCnv::m_inDetIDTag
std::string m_inDetIDTag
Internal InDet id tag.
Definition: HGTD_IDDetDescrCnv.h:44
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
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:41
HGTD_IDDetDescrCnv::createObj
virtual StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj) override final
Definition: HGTD_IDDetDescrCnv.cxx:38
HGTD_IDDetDescrCnv::storageType
static long storageType()
Definition: HGTD_IDDetDescrCnv.cxx:126
DetDescrAddress.h
IdDictManager.h
HGTD_IDDetDescrCnv::classID
static const CLID & classID()
Definition: HGTD_IDDetDescrCnv.cxx:133
DetDescrConverter::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Handle to DetectorStore.
Definition: DetDescrConverter.h:33
IdDictDictionary::m_version
std::string m_version
Definition: IdDictDictionary.h:217
HGTD_IDDetDescrCnv::initialize
virtual StatusCode initialize() override final
Definition: HGTD_IDDetDescrCnv.cxx:27
BchCleanup.mgr
mgr
Definition: BchCleanup.py:294
SG::asStorable
DataObject * asStorable(SG::DataObjectSharedPtr< T > pObject)
Definition: DataObjectSharedPtr.h:65
HGTD_IDDetDescrCnv.h
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
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: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
HGTD_IDDetDescrCnv::repSvcType
virtual long int repSvcType() const override final
Definition: HGTD_IDDetDescrCnv.cxx:19
IdDictManager
IdDictManager is the interface to identifier dictionaries.
Definition: IdDictManager.h:36
IdDictDictionary
Definition: IdDictDictionary.h:30
DetDescrConverter.h
HGTD_IDDetDescrCnv::m_hgtdId
std::unique_ptr< HGTD_ID > m_hgtdId
The helper - only will create it once.
Definition: HGTD_IDDetDescrCnv.h:35
IdDictManager::manager
const IdDictMgr * manager(void) const
Definition: IdDictManager.cxx:37
HGTD_IDDetDescrCnv::m_inDetIDFileName
std::string m_inDetIDFileName
File to be read for InDet ids.
Definition: HGTD_IDDetDescrCnv.h:38
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:138
StoreGateSvc.h
HGTD_IDDetDescrCnv::m_doChecks
bool m_doChecks
Whether or not.
Definition: HGTD_IDDetDescrCnv.h:47