ATLAS Offline Software
SCT_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 "SCT_IDDetDescrCnv.h"
6 
9 #include "GaudiKernel/MsgStream.h"
10 #include "StoreGate/StoreGateSvc.h"
11 
13 #include "InDetIdentifier/SCT_ID.h"
14 
15 
16 //--------------------------------------------------------------------
17 
18 long int
20 {
21  return (storageType());
22 }
23 
24 //--------------------------------------------------------------------
25 
28 {
29  // First call parent init
31  return StatusCode::SUCCESS;
32 }
33 
34 //--------------------------------------------------------------------
35 
37 SCT_IDDetDescrCnv::createObj(IOpaqueAddress* /*pAddr*/, DataObject*& pObj)
38 {
39  // Get the dictionary manager from the detector store
40  const IdDictManager* idDictMgr;
41  ATH_CHECK( detStore()->retrieve(idDictMgr, "IdDict") );
42 
43  // Only create new helper if it is the first pass or if there is a
44  // change in the the file or tag
45  bool initHelper = false;
46 
47  const IdDictMgr* mgr = idDictMgr->manager();
48 
49  // Internal InDet id tag
50  std::string inDetIDTag = mgr->tag();
51 
52  // DoChecks flag
53  bool doChecks = mgr->do_checks();
54 
55  IdDictDictionary* dict = mgr->find_dictionary("InnerDetector");
56  if (!dict) {
57  ATH_MSG_ERROR("unable to find idDict for InnerDetector");
58  return StatusCode::FAILURE;
59  }
60 
61  // File to be read for InDet ids
62  std::string inDetIDFileName = dict->file_name();
63 
64  // Tag of RDB record for InDet ids
65  std::string inDetIdDictTag = dict->dict_tag();
66 
67 
68  if (m_sctId) {
69 
70  // SCT 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_sctId = new SCT_ID;
96  initHelper = true;
97  // add in message service for printout
99  }
100 
101  if (initHelper) {
102  ATH_CHECK( idDictMgr->initializeHelper(*m_sctId) == 0 );
103  // Save state:
104  m_inDetIDTag = inDetIDTag;
105  m_inDetIDFileName = inDetIDFileName;
106  m_inDetIdDictTag = inDetIdDictTag;
107  m_doChecks = doChecks;
108  }
109 
110  // Pass a pointer to the container to the Persistency service by reference.
111  pObj = SG::asStorable(m_sctId);
112 
113  return StatusCode::SUCCESS;
114 
115 }
116 
117 //--------------------------------------------------------------------
118 
119 long
121 {
122  return DetDescr_StorageType;
123 }
124 
125 //--------------------------------------------------------------------
126 const CLID&
128  return ClassID_traits<SCT_ID>::ID();
129 }
130 
131 //--------------------------------------------------------------------
133  :
134  DetDescrConverter(ClassID_traits<SCT_ID>::ID(), svcloc, "SCT_IDDetDescrCnv"),
135  m_sctId(nullptr),
136  m_doChecks(false)
137 
138 {}
139 
140 
141 
SCT_IDDetDescrCnv::m_inDetIdDictTag
std::string m_inDetIdDictTag
Tag of RDB record for InDet ids.
Definition: SCT_IDDetDescrCnv.h:40
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: IdDictDefs.h:665
SCT_IDDetDescrCnv::storageType
static long storageType()
Definition: SCT_IDDetDescrCnv.cxx:120
SCT_ID.h
This is an Identifier helper class for the SCT subdetector. This class is a factory for creating comp...
SCT_IDDetDescrCnv::createObj
virtual StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj) override
Definition: SCT_IDDetDescrCnv.cxx:37
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
initialize
void initialize()
Definition: run_EoverP.cxx:894
DetDescrAddress.h
SCT_IDDetDescrCnv::SCT_IDDetDescrCnv
SCT_IDDetDescrCnv(ISvcLocator *svcloc)
Definition: SCT_IDDetDescrCnv.cxx:132
SG::asStorable
DataObject * asStorable(T *pObject)
Definition: StorableConversions.h:158
IdDictManager.h
DetDescrConverter::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Handle to DetectorStore.
Definition: DetDescrConverter.h:33
SCT_IDDetDescrCnv::m_inDetIDFileName
std::string m_inDetIDFileName
File to be read for InDet ids.
Definition: SCT_IDDetDescrCnv.h:37
BchCleanup.mgr
mgr
Definition: BchCleanup.py:294
ClassID_traits::ID
static const CLID & ID()
the CLID of T
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:50
IdDictMgr
Definition: IdDictDefs.h:32
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:40
SCT_IDDetDescrCnv::repSvcType
virtual long int repSvcType() const override
Definition: SCT_IDDetDescrCnv.cxx:19
SCT_IDDetDescrCnv.h
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: IdDictDefs.h:657
IdDictManager
IdDictManager is the interface to identifier dictionaries.
Definition: IdDictManager.h:36
IdDictDictionary
Definition: IdDictDefs.h:97
SCT_IDDetDescrCnv::m_sctId
SCT_ID * m_sctId
The helper - only will create it once.
Definition: SCT_IDDetDescrCnv.h:34
SCT_ID
Definition: SCT_ID.h:68
DetDescrConverter.h
SCT_IDDetDescrCnv::m_inDetIDTag
std::string m_inDetIDTag
Internal InDet id tag.
Definition: SCT_IDDetDescrCnv.h:43
SCT_IDDetDescrCnv::initialize
virtual StatusCode initialize() override
Definition: SCT_IDDetDescrCnv.cxx:27
IdDictManager::manager
const IdDictMgr * manager(void) const
Definition: IdDictManager.cxx:37
SCT_IDDetDescrCnv::classID
static const CLID & classID()
Definition: SCT_IDDetDescrCnv.cxx:127
StoreGateSvc.h
SCT_IDDetDescrCnv::m_doChecks
bool m_doChecks
Whether or not.
Definition: SCT_IDDetDescrCnv.h:46