ATLAS Offline Software
VP1DetInfo.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
7 // //
8 // Implementation of class VP1DetInfo //
9 // //
10 // Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
11 // Initial version: March 2008 //
12 // //
14 
15 #include "VP1Utils/VP1DetInfo.h"
19 #include "VP1Base/VP1Msg.h"
20 #include "VP1Base/IVP1System.h"
21 #include "VP1Base/VP1AthenaPtrs.h"
22 
34 
37 #include "InDetIdentifier/SCT_ID.h"
38 #include "InDetIdentifier/TRT_ID.h"
45 
46 #include "Identifier/Identifier.h"
47 
48 //____________________________________________________________________
50 public:
51  template <class T>
52  static const T * cachedRetrieve(const T*& cachedPtr, const char* key, const bool& configallows );
53 
54  static bool m_initialised;
55  static const char m_badInitFlag;//Address of this means bad initialisation.
56 
67  static const CaloIdManager * m_caloIdMgr;
68 
70  static const CscIdHelper * m_cscIDHelper;
71  static const RpcIdHelper * m_rpcIDHelper;
72  static const TgcIdHelper * m_tgcIDHelper;
73  static const sTgcIdHelper * m_stgcIDHelper;
74  static const MdtIdHelper * m_mdtIDHelper;
75  static const MmIdHelper * m_mmIDHelper;
76  static const PixelID * m_pixelIDHelper;
77  static const SCT_ID * m_sctIDHelper;
78  static const TRT_ID * m_trtIDHelper;
79 };
80 
82 const char VP1DetInfo::Imp::m_badInitFlag = ' ';
83 
95 
106 
107 //____________________________________________________________________
108 template <class T>
109 const T * VP1DetInfo::Imp::cachedRetrieve(const T*& cachedPtr, const char* preferredKey, const bool& configallows ) {
110  const T * bad = static_cast<const T*>(static_cast<const void*>(&m_badInitFlag));
111  if (cachedPtr)
112  return ( cachedPtr==bad? 0 : cachedPtr );
113  QString key(preferredKey);
114  if (!configallows) {
115  VP1Msg::messageDebug("VP1DetInfo WARNING: Will not attempt to get (type="+QString(typeid(T).name())+", key="+key+") due to missing/disabled features in job!");
116  cachedPtr = bad;
117  return 0;
118  }
120  //Try to gracefully guess at a different key:
122  if (keys.empty()) {
123  VP1Msg::messageDebug("VP1DetInfo WARNING: Could not find (type="+QString(typeid(T).name())+") in detector store (expected key="+key+")");
124  cachedPtr = bad;
125  return 0;
126  }
127  if (keys.count()>1) {
128  VP1Msg::messageDebug("VP1DetInfo WARNING: Could not find (type="+QString(typeid(T).name())+", key="+key+") in detector store, and could not uniquely guess at alternate key.");
129  cachedPtr = bad;
130  return 0;
131  }
132  VP1Msg::messageDebug("VP1DetInfo WARNING: Could not find (type="+QString(typeid(T).name())+", key="+key+") in detector store. Trying with key="+keys.first()+")");
133  key = keys.first();
134  }
135  if (!VP1SGAccessHelper(VP1AthenaPtrs::detectorStore()).retrieve(cachedPtr,key)||!cachedPtr) {
136  VP1Msg::messageDebug("VP1DetInfo WARNING: Could not retrieve (type="+QString(typeid(T).name())+", key="+key+") from detector store!");
137  cachedPtr = bad;
138  return 0;
139  }
140  VP1Msg::messageVerbose("VP1DetInfo Succesfully retrieved (type="+QString(typeid(T).name())+", key="+key+") from detector store!");
141  return cachedPtr;
142 
143 }
144 
156 
167 
168 //____________________________________________________________________
169 bool VP1DetInfo::isUnsafe( const Identifier& id ) {
170 
171  const AtlasDetectorID * idhelper = atlasIDHelper();
172  if ( !idhelper || !id.is_valid() )
173  return true;
174 
175  if (idhelper->is_indet(id)) {
176  if (!VP1JobConfigInfo::hasTRTGeometry() && idhelper->is_trt(id))
177  return true;
178  if (!VP1JobConfigInfo::hasPixelGeometry() && idhelper->is_pixel(id))
179  return true;
180  if (!VP1JobConfigInfo::hasSCTGeometry() && idhelper->is_sct(id))
181  return true;
182  } else if (idhelper->is_muon(id)) {
184  return true;
185  } else if (idhelper->is_calo(id)) {
186  if (!VP1JobConfigInfo::hasLArGeometry() && idhelper->is_lar(id) )
187  return true;
188  if (!VP1JobConfigInfo::hasTileGeometry() && idhelper->is_tile(id) )
189  return true;
190  }
191  return false;
192 }
CscIdHelper.h
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
PixelID.h
This is an Identifier helper class for the Pixel subdetector. This class is a factory for creating co...
AtlasDetectorID::is_pixel
bool is_pixel(Identifier id) const
Definition: AtlasDetectorID.h:760
bad
@ bad
Definition: SUSYToolsTester.cxx:95
VP1DetInfo::Imp::m_pixelDetMgr
static const InDetDD::PixelDetectorManager * m_pixelDetMgr
Definition: VP1DetInfo.cxx:57
SCT_ID.h
This is an Identifier helper class for the SCT subdetector. This class is a factory for creating comp...
FCALDetectorManager
A manager class providing access to readout geometry information for the forward calorimeter.
Definition: FCALDetectorManager.h:29
VP1DetInfo::mmIDHelper
static const MmIdHelper * mmIDHelper()
Definition: VP1DetInfo.cxx:162
InDetDD::SCT_DetectorManager
Definition: SCT_DetectorManager.h:49
VP1DetInfo::Imp::m_larDetMgr
static const LArDetectorManager * m_larDetMgr
Definition: VP1DetInfo.cxx:65
sTgcIdHelper.h
VP1DetInfo::tileDetMgr
static const TileDetDescrManager * tileDetMgr()
Definition: VP1DetInfo.cxx:149
TRT_DetectorManager.h
EMECDetectorManager
A manager class providing access to readout geometry information for the electromagnetic endcap calor...
Definition: EMECDetectorManager.h:31
AtlasDetectorID::is_lar
bool is_lar(Identifier id) const
Definition: AtlasDetectorID.h:689
TgcIdHelper
Definition: TgcIdHelper.h:50
AtlasDetectorID::is_sct
bool is_sct(Identifier id) const
Definition: AtlasDetectorID.h:770
VP1DetInfo::Imp::m_atlasIDHelper
static const AtlasDetectorID * m_atlasIDHelper
Definition: VP1DetInfo.cxx:69
VP1Msg.h
VP1DetInfo::Imp::m_embDetMgr
static const EMBDetectorManager * m_embDetMgr
Definition: VP1DetInfo.cxx:62
VP1JobConfigInfo::hasTileGeometry
static bool hasTileGeometry()
Definition: VP1JobConfigInfo.cxx:133
FCALDetectorManager.h
EMECDetectorManager.h
VP1DetInfo::Imp::m_cscIDHelper
static const CscIdHelper * m_cscIDHelper
Definition: VP1DetInfo.cxx:70
VP1JobConfigInfo::hasLArGeometry
static bool hasLArGeometry()
Definition: VP1JobConfigInfo.cxx:132
VP1DetInfo::Imp
Definition: VP1DetInfo.cxx:49
VP1DetInfo::pixelDetMgr
static const InDetDD::PixelDetectorManager * pixelDetMgr()
Definition: VP1DetInfo.cxx:145
TRT_ID.h
This is an Identifier helper class for the TRT subdetector. This class is a factory for creating comp...
VP1DetInfo::pixelIDHelper
static const PixelID * pixelIDHelper()
Definition: VP1DetInfo.cxx:164
VP1DetInfo::caloIDMgr
static const CaloIdManager * caloIDMgr()
Definition: VP1DetInfo.cxx:155
VP1DetInfo::Imp::m_fcalDetMgr
static const FCALDetectorManager * m_fcalDetMgr
Definition: VP1DetInfo.cxx:66
VP1DetInfo::embDetMgr
static const EMBDetectorManager * embDetMgr()
Definition: VP1DetInfo.cxx:150
VP1DetInfo::stgcIDHelper
static const sTgcIdHelper * stgcIDHelper()
Definition: VP1DetInfo.cxx:161
VP1DetInfo::atlasIDHelper
static const AtlasDetectorID * atlasIDHelper()
Definition: VP1DetInfo.cxx:157
VP1DetInfo::Imp::m_emecDetMgr
static const EMECDetectorManager * m_emecDetMgr
Definition: VP1DetInfo.cxx:64
AtlasDetectorID::is_trt
bool is_trt(Identifier id) const
Definition: AtlasDetectorID.h:782
RpcIdHelper
Definition: RpcIdHelper.h:51
VP1DetInfo::hecDetMgr
static const HECDetectorManager * hecDetMgr()
Definition: VP1DetInfo.cxx:151
RpcIdHelper.h
TileDetDescrManager.h
VP1AthenaPtrs.h
VP1SGContentsHelper::getKeys
QStringList getKeys() const
Definition: VP1SGContentsHelper.h:55
VP1DetInfo::fcalDetMgr
static const FCALDetectorManager * fcalDetMgr()
Definition: VP1DetInfo.cxx:154
VP1DetInfo.h
VP1DetInfo::tgcIDHelper
static const TgcIdHelper * tgcIDHelper()
Definition: VP1DetInfo.cxx:160
AtlasDetectorID.h
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
EMBDetectorManager
A manager class providing access to readout geometry information for the electromagnetic barrel calor...
Definition: EMBDetectorManager.h:32
VP1DetInfo::emecDetMgr
static const EMECDetectorManager * emecDetMgr()
Definition: VP1DetInfo.cxx:152
PixelDetectorManager.h
CaloIdManager
This class initializes the Calo (LAr and Tile) offline identifiers.
Definition: CaloIdManager.h:45
VP1DetInfo::Imp::m_tileDetMgr
static const TileDetDescrManager * m_tileDetMgr
Definition: VP1DetInfo.cxx:61
TileDetDescrManager
Definition: TileDetDescrManager.h:33
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
VP1DetInfo::larDetMgr
static const LArDetectorManager * larDetMgr()
Definition: VP1DetInfo.cxx:153
VP1DetInfo::Imp::m_sctDetMgr
static const InDetDD::SCT_DetectorManager * m_sctDetMgr
Definition: VP1DetInfo.cxx:58
VP1DetInfo::Imp::m_hecDetMgr
static const HECDetectorManager * m_hecDetMgr
Definition: VP1DetInfo.cxx:63
VP1DetInfo::Imp::m_trtDetMgr
static const InDetDD::TRT_DetectorManager * m_trtDetMgr
Definition: VP1DetInfo.cxx:59
VP1JobConfigInfo::hasSCTGeometry
static bool hasSCTGeometry()
Definition: VP1JobConfigInfo.cxx:128
MdtIdHelper
Definition: MdtIdHelper.h:61
VP1DetInfo::Imp::m_trtIDHelper
static const TRT_ID * m_trtIDHelper
Definition: VP1DetInfo.cxx:78
MmIdHelper.h
MdtIdHelper.h
AtlasDetectorID::is_tile
bool is_tile(Identifier id) const
Definition: AtlasDetectorID.h:695
VP1DetInfo::Imp::m_badInitFlag
static const char m_badInitFlag
Definition: VP1DetInfo.cxx:55
VP1DetInfo::Imp::m_tgcIDHelper
static const TgcIdHelper * m_tgcIDHelper
Definition: VP1DetInfo.cxx:72
VP1DetInfo::rpcIDHelper
static const RpcIdHelper * rpcIDHelper()
Definition: VP1DetInfo.cxx:159
LArDetectorManager
Stored in storegate. Provides access to EMB, EMEC, HEC and FCAL Detector Managers....
Definition: LArDetectorManager.h:26
VP1JobConfigInfo::hasTRTGeometry
static bool hasTRTGeometry()
Definition: VP1JobConfigInfo.cxx:129
HECDetectorManager
A manager class providing access to readout geometry information for the hadronic endcap calorimeter.
Definition: HECDetectorManager.h:28
AtlasDetectorID::is_calo
bool is_calo(Identifier id) const
Definition: AtlasDetectorID.h:707
VP1DetInfo::Imp::m_mmIDHelper
static const MmIdHelper * m_mmIDHelper
Definition: VP1DetInfo.cxx:75
VP1DetInfo::Imp::cachedRetrieve
static const T * cachedRetrieve(const T *&cachedPtr, const char *key, const bool &configallows)
Definition: VP1DetInfo.cxx:109
InDetDD::PixelDetectorManager
Definition: PixelDetectorManager.h:47
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
VP1DetInfo::Imp::m_muonDetMgr
static const MuonGM::MuonDetectorManager * m_muonDetMgr
Definition: VP1DetInfo.cxx:60
AtlasDetectorID::is_indet
bool is_indet(Identifier id) const
Definition: AtlasDetectorID.h:683
VP1Msg::messageVerbose
static void messageVerbose(const QString &)
Definition: VP1Msg.cxx:84
sTgcIdHelper
Definition: sTgcIdHelper.h:55
VP1DetInfo::isUnsafe
static bool isUnsafe(const Identifier &)
Definition: VP1DetInfo.cxx:169
LArDetectorManager.h
VP1SGContentsHelper
Definition: VP1SGContentsHelper.h:26
MuonDetectorManager.h
VP1DetInfo::sctIDHelper
static const SCT_ID * sctIDHelper()
Definition: VP1DetInfo.cxx:165
VP1DetInfo::mdtIDHelper
static const MdtIdHelper * mdtIDHelper()
Definition: VP1DetInfo.cxx:163
VP1DetInfo::Imp::m_initialised
static bool m_initialised
Definition: VP1DetInfo.cxx:54
TRT_ID
Definition: TRT_ID.h:84
VP1DetInfo::muonDetMgr
static const MuonGM::MuonDetectorManager * muonDetMgr()
Definition: VP1DetInfo.cxx:148
InDetDD::TRT_DetectorManager
The Detector Manager for all TRT Detector elements, it acts as the interface to the detector elements...
Definition: TRT_DetectorManager.h:69
VP1DetInfo::trtIDHelper
static const TRT_ID * trtIDHelper()
Definition: VP1DetInfo.cxx:166
VP1Msg::messageDebug
static void messageDebug(const QString &)
Definition: VP1Msg.cxx:39
AtlasDetectorID::is_muon
bool is_muon(Identifier id) const
Definition: AtlasDetectorID.h:701
MmIdHelper
Definition: MmIdHelper.h:54
SCT_ID
Definition: SCT_ID.h:68
CscIdHelper
Definition: CscIdHelper.h:52
MuonGM::MuonDetectorManager
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonDetectorManager.h:49
VP1DetInfo::Imp::m_mdtIDHelper
static const MdtIdHelper * m_mdtIDHelper
Definition: VP1DetInfo.cxx:74
VP1DetInfo::trtDetMgr
static const InDetDD::TRT_DetectorManager * trtDetMgr()
Definition: VP1DetInfo.cxx:147
VP1DetInfo::Imp::m_stgcIDHelper
static const sTgcIdHelper * m_stgcIDHelper
Definition: VP1DetInfo.cxx:73
VP1DetInfo::Imp::m_rpcIDHelper
static const RpcIdHelper * m_rpcIDHelper
Definition: VP1DetInfo.cxx:71
CaloIdManager.h
TgcIdHelper.h
VP1JobConfigInfo.h
VP1DetInfo::Imp::m_pixelIDHelper
static const PixelID * m_pixelIDHelper
Definition: VP1DetInfo.cxx:76
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:790
VP1SGAccessHelper
Definition: VP1SGAccessHelper.h:25
VP1DetInfo::cscIDHelper
static const CscIdHelper * cscIDHelper()
Definition: VP1DetInfo.cxx:158
VP1JobConfigInfo::hasMuonNSWGeometry
static bool hasMuonNSWGeometry()
Definition: VP1JobConfigInfo.cxx:135
VP1JobConfigInfo::hasPixelGeometry
static bool hasPixelGeometry()
Definition: VP1JobConfigInfo.cxx:127
SCT_DetectorManager.h
VP1AthenaPtrs::detectorStore
static StoreGateSvc * detectorStore()
Definition: VP1AthenaPtrs.h:28
VP1JobConfigInfo::hasMuonGeometry
static bool hasMuonGeometry()
Definition: VP1JobConfigInfo.cxx:134
PixelID
Definition: PixelID.h:67
VP1DetInfo::Imp::m_sctIDHelper
static const SCT_ID * m_sctIDHelper
Definition: VP1DetInfo.cxx:77
VP1DetInfo::Imp::m_caloIdMgr
static const CaloIdManager * m_caloIdMgr
Definition: VP1DetInfo.cxx:67
VP1SGAccessHelper.h
EMBDetectorManager.h
IVP1System.h
AtlasDetectorID
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
Definition: AtlasDetectorID.h:57
HECDetectorManager.h
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
VP1SGContentsHelper.h
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
VP1DetInfo::sctDetMgr
static const InDetDD::SCT_DetectorManager * sctDetMgr()
Definition: VP1DetInfo.cxx:146