ATLAS Offline Software
PLR_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  InDet DetDescrCnv package
7  -----------------------------------------
8  ***************************************************************************/
9 
10 #include "PLR_IDDetDescrCnv.h"
11 
14 #include "GaudiKernel/MsgStream.h"
15 #include "StoreGate/StoreGateSvc.h"
16 
18 #include "InDetIdentifier/PLR_ID.h"
19 
20 //--------------------------------------------------------------------
21 
23  : DetDescrConverter(ClassID_traits<PLR_ID>::ID(), svcloc, "PLR_IDDetDescrCnv")
24 {}
25 
26 //--------------------------------------------------------------------
27 
28 long int
30 {
31  return storageType();
32 }
33 
34 //--------------------------------------------------------------------
35 
38 {
40  return StatusCode::SUCCESS;
41 }
42 
43 //--------------------------------------------------------------------
44 
46 PLR_IDDetDescrCnv::createObj(IOpaqueAddress* /*pAddr*/, DataObject*& pObj)
47 {
48  // Get the dictionary manager from the detector store
49  const IdDictManager* idDictMgr;
50  ATH_CHECK( detStore()->retrieve(idDictMgr, "IdDict") );
51 
52  // Only initialize helper if it is the first pass or if there is a
53  // change in the the file or tag
54  bool initHelper{};
55 
56  const IdDictMgr* mgr = idDictMgr->manager();
57 
58  // Internal InDet id tag
59  std::string inDetIDTag = mgr->tag();
60 
61  // DoChecks flag
62  bool doChecks = mgr->do_checks();
63 
64  IdDictDictionary* dict = mgr->find_dictionary("InnerDetector");
65  if (!dict) {
66  ATH_MSG_ERROR("unable to find idDict for InnerDetector");
67  return StatusCode::FAILURE;
68  }
69 
70  // File to be read for InDet ids
71  std::string inDetIDFileName = dict->file_name();
72 
73  // Tag of RDB record for InDet ids
74  std::string inDetIdDictTag = dict->dict_tag();
75 
76  // PLR id helper already exists - second pass. Check for a change
77  if (m_plrId) {
78  if (inDetIDTag != m_inDetIDTag) {
79  // Internal InDet id tag
80  initHelper = true;
81  ATH_MSG_DEBUG(" Changed internal InDet id tag: " << inDetIDTag);
82  }
83  if (inDetIDFileName != m_inDetIDFileName) {
84  // File to be read for InDet ids
85  initHelper = true;
86  ATH_MSG_DEBUG(" Changed InDetFileName: " << inDetIDFileName);
87  }
88  if (inDetIdDictTag != m_inDetIdDictTag) {
89  // Tag of RDB record for InDet ids
90  initHelper = true;
91  ATH_MSG_DEBUG(" Changed InDetIdDictTag: " << inDetIdDictTag);
92  }
93  if (doChecks != m_doChecks) {
94  // DoChecks flag
95  initHelper = true;
96  ATH_MSG_DEBUG(" Changed doChecks flag: " << doChecks);
97  }
98  } else {
99  // create the helper
100  m_plrId = new PLR_ID;
101  initHelper = true;
102  // add in message service for printout
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 
124 long
126 {
127  return DetDescr_StorageType;
128 }
129 
130 //--------------------------------------------------------------------
131 const CLID&
133 {
135 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
PLR_IDDetDescrCnv::m_plrId
PLR_ID * m_plrId
The helper - only will create it once.
Definition: PLR_IDDetDescrCnv.h:41
IdDictDictionary::dict_tag
const std::string & dict_tag(void) const
Access to the dictionary tag.
Definition: IdDictDefs.h:665
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
PLR_ID.h
This is an Identifier helper class for the PLR subdetector. This class inherits from PicelID.
PLR_ID
This is an Identifier helper class for the PLR subdetector. This class inherits from PixelID.
Definition: PLR_ID.h:24
DetDescrAddress.h
SG::asStorable
DataObject * asStorable(T *pObject)
Definition: StorableConversions.h:158
PLR_IDDetDescrCnv::m_inDetIDFileName
std::string m_inDetIDFileName
File to be read for InDet ids.
Definition: PLR_IDDetDescrCnv.h:44
PLR_IDDetDescrCnv.h
IdDictManager.h
DetDescrConverter::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Handle to DetectorStore.
Definition: DetDescrConverter.h:33
PLR_IDDetDescrCnv::storageType
static long storageType()
Definition: PLR_IDDetDescrCnv.cxx:125
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
PLR_IDDetDescrCnv::initialize
virtual StatusCode initialize() override
Definition: PLR_IDDetDescrCnv.cxx:37
IdDictMgr
Definition: IdDictDefs.h:32
PLR_IDDetDescrCnv::PLR_IDDetDescrCnv
PLR_IDDetDescrCnv(ISvcLocator *svcloc)
Definition: PLR_IDDetDescrCnv.cxx:22
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
PLR_IDDetDescrCnv::classID
static const CLID & classID()
Definition: PLR_IDDetDescrCnv.cxx:132
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
PLR_IDDetDescrCnv::m_inDetIDTag
std::string m_inDetIDTag
Internal InDet id tag.
Definition: PLR_IDDetDescrCnv.h:50
PLR_IDDetDescrCnv::repSvcType
virtual long int repSvcType() const override
Definition: PLR_IDDetDescrCnv.cxx:29
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
DetDescrConverter.h
PLR_IDDetDescrCnv::m_inDetIdDictTag
std::string m_inDetIdDictTag
Tag of RDB record for InDet ids.
Definition: PLR_IDDetDescrCnv.h:47
IdDictManager::manager
const IdDictMgr * manager(void) const
Definition: IdDictManager.cxx:37
PLR_IDDetDescrCnv::createObj
virtual StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj) override
Definition: PLR_IDDetDescrCnv.cxx:46
PLR_IDDetDescrCnv::m_doChecks
bool m_doChecks
Whether or not.
Definition: PLR_IDDetDescrCnv.h:53
StoreGateSvc.h