ATLAS Offline Software
EMECDetectorManager.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 "GaudiKernel/MsgStream.h"
6 #include "GaudiKernel/Bootstrap.h"
7 #include "GaudiKernel/SystemOfUnits.h"
8 #include "GaudiKernel/ServiceHandle.h"
9 
13 
20 #include "StoreGate/StoreGateSvc.h"
21 #include "LArHV/LArHVManager.h"
22 // Class EMECDetectorManager
23 
25  , const EMECHVManager* hvManagerOuter
26  , const EMECPresamplerHVManager* presamplerHVManager)
27  : m_MagicNumbers(new EMECMagicNumbers())
28  , m_presamplerHVManager(presamplerHVManager)
29 {
30  setName("LArEMEC");
31 
32  for (unsigned int r=0;r<6;r++) {
33  for (unsigned int s=0;s<4;s++) {
34  for (unsigned int io=0;io<2;io++) {
35  for (unsigned int e=0;e<2;e++) {
36  m_DetRegionsRandom[r][s][io][e]=nullptr;
37  }
38  }
39  }
40  }
41 
42  m_HVManager[0].store (hvManagerInner);
43  m_HVManager[1].store (hvManagerOuter);
44 
45  // The EMEC gets and managers certain arrays needed to build descriptors. Here is that:
46  ISvcLocator *svcLocator = Gaudi::svcLocator();
47  IRDBAccessSvc *rdbAccess{nullptr};
48  IGeoModelSvc *geoModel{nullptr};
49  IGeoDbTagSvc *geoDbTagSvc{nullptr};
50 
51  if(svcLocator->service("GeoModelSvc",geoModel) == StatusCode::FAILURE)
52  throw std::runtime_error("Error in HECDetectorManager, cannot access GeoModelSvc");
53 
54  if(svcLocator->service("GeoDbTagSvc",geoDbTagSvc) == StatusCode::FAILURE)
55  throw std::runtime_error("Error in HECDetectorManager, cannot access GeoDbTagSvc");
56 
57  if(svcLocator->service(geoDbTagSvc->getParamSvcName(),rdbAccess) == StatusCode::FAILURE)
58  throw std::runtime_error("Error in HECDetectorManager, cannot access RDBAccessSvc");
59 
60  std::string larKey, larNode;
61  if(geoDbTagSvc->getSqliteReader()==nullptr) {
62  DecodeVersionKey larVersionKey(geoModel, "LAr");
63  larKey = larVersionKey.tag();
64  larNode = larVersionKey.node();
65  }
66 
67  IRDBRecordset_ptr emecSamplingSep = rdbAccess->getRecordsetPtr("EmecSamplingSep", larKey, larNode);
68  if (emecSamplingSep->size()==0) throw std::runtime_error("Error getting EmecSamplingSep table");
69 
70  const IRDBRecord *ess = (*emecSamplingSep)[0];
71  for (int j=0;j<7;j++) m_ziw.push_back(ess->getDouble("ZIW",j)*Gaudi::Units::cm);
72  for (int j=0;j<44;j++) m_zsep12.push_back(ess->getDouble("ZSEP12",j)*Gaudi::Units::cm);
73  for (int j=0;j<22;j++) m_zsep23.push_back(ess->getDouble("ZSEP23",j)*Gaudi::Units::cm);
74 
75  IRDBRecordset_ptr emecMagicNumbers = rdbAccess->getRecordsetPtr("EmecMagicNumbers", larKey, larNode);
76  if (emecMagicNumbers->size()==0) {
77  emecMagicNumbers = rdbAccess->getRecordsetPtr("EmecMagicNumbers", "EmecMagicNumbers-00");
78  if (emecMagicNumbers->size()==0) {
79  throw std::runtime_error("Error getting EmecMagicNumbers table");
80  }
81  }
82  m_MagicNumbers->focalToRef =(*emecMagicNumbers)[0]->getDouble("FOCALTOREF")*Gaudi::Units::mm;
83  m_MagicNumbers->refToActive =(*emecMagicNumbers)[0]->getDouble("REFTOACTIVE")*Gaudi::Units::mm;
84  m_MagicNumbers->activeLength =(*emecMagicNumbers)[0]->getDouble("ACTIVELENGTH")*Gaudi::Units::mm;
85  m_MagicNumbers->refToPresampler =(*emecMagicNumbers)[0]->getDouble("REFTOPRESAMPLER")*Gaudi::Units::mm;
86  m_MagicNumbers->presamplerLength =(*emecMagicNumbers)[0]->getDouble("PRESAMPLERLENGTH")*Gaudi::Units::mm;
87 }
88 
89 
91  for (unsigned int i=0;i<getNumDetectorRegions();i++) delete m_DetRegionsIterative[i];
92  delete m_MagicNumbers;
93 }
94 
95 
96 
97 //## Other Operations (implementation)
99 {
100  return m_DetRegionsIterative.begin();
101 }
102 
104 {
105  return m_DetRegionsIterative.end();
106 }
107 
108 const EMECDetectorRegion * EMECDetectorManager::getDetectorRegion (unsigned int endcap, unsigned int sampling, unsigned int region, bool inner) const
109 {
110  return m_DetRegionsRandom[region][sampling][inner ? 1 : 0][endcap];
111 }
112 
114 {
115  return m_DetRegionsIterative.size();
116 }
117 
118 PVConstLink EMECDetectorManager::getTreeTop (unsigned int i) const
119 {
120  return m_treeTop[i];
121 }
122 
124 {
125  return m_treeTop.size();
126 }
127 
129 {
130  m_DetRegionsIterative.push_back(region);
131  m_DetRegionsRandom[region->getRegionIndex()][region->getSamplingIndex()][region->getRadialIndex()][region->getEndcapIndex()] = region;
132 }
133 
134 void EMECDetectorManager::addTreeTop (PVLink treeTop)
135 {
136  m_treeTop.push_back(treeTop);
137 }
138 
140 {
141  if(!m_HVManager[io].get()) {
142  //Support lazy initialization for testbeams
143  ServiceHandle<StoreGateSvc> detStore ("DetectorStore", "HECHVManager");
144  const LArHVManager *manager{nullptr};
145  if (detStore->retrieve(manager)==StatusCode::SUCCESS) {
146  m_HVManager[io].set (&(manager->getEMECHVManager(io)));
147  }
148  }
149  // cppcheck-suppress nullPointerRedundantCheck; false positive
150  return *(m_HVManager[io].get());
151 }
152 
154 {
155  if (!m_presamplerHVManager.get()) {
156  ServiceHandle<StoreGateSvc> detStore ("DetectorStore", "HECHVManager");
157  const LArHVManager *manager{nullptr};
158  if (detStore->retrieve(manager)==StatusCode::SUCCESS) {
159  m_presamplerHVManager.set (&(manager->getEMECPresamplerHVManager()));
160  }
161  }
162  // cppcheck-suppress nullPointerRedundantCheck; false positive
163  return *m_presamplerHVManager.get();
164 }
EMECPresamplerHVManager
This class provides direct access to information on the HV electrodes within the EMEC....
Definition: EMECPresamplerHVManager.h:36
EMECDetectorManager::getNumDetectorRegions
unsigned int getNumDetectorRegions() const
Gets the number of detectors in the set of detector regions.
Definition: EMECDetectorManager.cxx:113
beamspotman.r
def r
Definition: beamspotman.py:676
LArHVManager.h
EMECDetectorManager::addDetectorRegion
void addDetectorRegion(const EMECDetectorRegion *region)
Add a new HEC Detector Region.
Definition: EMECDetectorManager.cxx:128
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
EMECDetectorRegion::getEndcapIndex
EMECDetectorRegion::DetectorSide getEndcapIndex() const
The endcap index.
Definition: EMECDetectorRegion.h:214
EMECDetectorManager::EMECMagicNumbers::focalToRef
double focalToRef
Distance from focal length to reference plane
Definition: EMECDetectorManager.h:259
IGeoModelSvc
Definition: IGeoModelSvc.h:17
EMECDetectorManager::m_zsep23
std::vector< double > m_zsep23
A vector of doubles used to hold an array of sampling separations for the EMEC outer wheel between sa...
Definition: EMECDetectorManager.h:233
EMECDetectorManager::m_presamplerHVManager
CxxUtils::CachedPointer< const EMECPresamplerHVManager > m_presamplerHVManager
Definition: EMECDetectorManager.h:245
EMECDetectorManager.h
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
EMECDetectorManager::m_zsep12
std::vector< double > m_zsep12
A vector of doubles used to hold an array of sampling separations for the EMEC outer wheel between sa...
Definition: EMECDetectorManager.h:225
EMECDetectorManager::m_DetRegionsIterative
std::vector< const EMECDetectorRegion * > m_DetRegionsIterative
A vector of Region pointers which exists in order to provide iterative access to any EMECDetectorRegi...
Definition: EMECDetectorManager.h:201
DecodeVersionKey::node
const std::string & node() const
Return the version node.
Definition: DecodeVersionKey.cxx:99
EMECDetectorRegion
Definition: EMECDetectorRegion.h:30
EMECDetectorManager::getTreeTop
virtual PVConstLink getTreeTop(unsigned int i) const override
Gets the ith tree top.
Definition: EMECDetectorManager.cxx:118
EMECDetectorManager::m_DetRegionsRandom
EMECDetRegionArray m_DetRegionsRandom
A vector of Region pointers which exists in order to provide iterative access to any EMECDetectorRegi...
Definition: EMECDetectorManager.h:208
EMECDetectorRegion::getRadialIndex
unsigned int getRadialIndex() const
Returns the Radial (Outer Wheel=0,InnerWheel=1) Index.
Definition: EMECDetectorRegion.h:178
CxxUtils::CachedPointer::set
void set(pointer_t elt) const
Set the element, assuming it is currently null.
cm
const double cm
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/FCAL_ChannelMap.cxx:25
IRDBAccessSvc.h
Definition of the abstract IRDBAccessSvc interface.
EMECDetectorManager::beginDetectorRegion
EMECDetectorManager::DetectorRegionConstIterator beginDetectorRegion() const
Iterate over detector regions.
Definition: EMECDetectorManager.cxx:98
lumiFormat.i
int i
Definition: lumiFormat.py:92
IRDBAccessSvc
IRDBAccessSvc is an abstract interface to the athena service that provides the following functionalit...
Definition: IRDBAccessSvc.h:45
EMECDetectorManager::addTreeTop
void addTreeTop(PVLink treeTop)
Add a Tree Top.
Definition: EMECDetectorManager.cxx:134
DecodeVersionKey
This is a helper class to query the version tags from GeoModelSvc and determine the appropriate tag a...
Definition: DecodeVersionKey.h:18
EMECDetectorManager::getHVManager
const EMECHVManager & getHVManager(EMECHVManager::IOType io) const
Get the HV Managers.
Definition: EMECDetectorManager.cxx:139
EMECDetectorManager::EMECMagicNumbers::activeLength
double activeLength
Total active length.
Definition: EMECDetectorManager.h:269
EMECDetectorManager::EMECMagicNumbers::refToActive
double refToActive
Distance from reference plane to active volume.
Definition: EMECDetectorManager.h:264
DecodeVersionKey::tag
const std::string & tag() const
Return version tag.
Definition: DecodeVersionKey.cxx:93
IGeoDbTagSvc
Definition: IGeoDbTagSvc.h:26
EMECDetectorManager::EMECMagicNumbers
This is a collection of numbers used to specify the construction of the electromagnetic endcap calori...
Definition: EMECDetectorManager.h:253
IRDBRecordset_ptr
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
Definition: IRDBAccessSvc.h:25
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
EMECDetectorManager::m_HVManager
CxxUtils::CachedPointer< const EMECHVManager > m_HVManager[2]
The HV Managers for the emec;.
Definition: EMECDetectorManager.h:243
EMECDetectorManager::EMECMagicNumbers::refToPresampler
double refToPresampler
Distance from reference plane to presampler.
Definition: EMECDetectorManager.h:274
EMECDetectorManager::getDetectorRegion
const EMECDetectorRegion * getDetectorRegion(unsigned int endcap, unsigned int sampling, unsigned int region, bool inner) const
Random Access to detector regions.
Definition: EMECDetectorManager.cxx:108
EMECDetDescr.h
EMECDetectorRegion::getSamplingIndex
unsigned int getSamplingIndex() const
Returns the Sampling Layer Index.
Definition: EMECDetectorRegion.h:164
EMECDetectorManager::getNumTreeTops
virtual unsigned int getNumTreeTops() const override
Gets the total number of tree tops.
Definition: EMECDetectorManager.cxx:123
DecodeVersionKey.h
EMECDetectorManager::m_treeTop
std::vector< PVLink > m_treeTop
This is the set of tree tops managed by this detector node.
Definition: EMECDetectorManager.h:194
python.SystemOfUnits.mm
int mm
Definition: SystemOfUnits.py:83
EMECDetectorManager::getPresamplerHVManager
const EMECPresamplerHVManager & getPresamplerHVManager() const
Get the HV Manager (presampler)
Definition: EMECDetectorManager.cxx:153
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
LArHVManager
This class provides access to the High Voltage throughout the LAr. High voltage conditions can also b...
Definition: LArHVManager.h:24
IRDBRecord.h
Definition of the abstract IRDBRecord interface.
CxxUtils::CachedPointer::store
void store(pointer_t elt)
Store a new value to the element.
EMECDetectorManager::m_MagicNumbers
EMECMagicNumbers * m_MagicNumbers
Clockwork for the EMECDetectorManager.
Definition: EMECDetectorManager.h:238
IRDBRecord
IRDBRecord is one record in the IRDBRecordset object.
Definition: IRDBRecord.h:27
EMECHVModule::IOType
IOType
Definition: EMECHVModule.h:22
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition: hcg.cxx:127
CxxUtils::CachedPointer::get
pointer_t get() const
Return the current value of the element.
python.Logging.manager
manager
Definition: PhysicsAnalysis/D3PDTools/AnaAlgorithm/python/Logging.py:92
IRDBRecord::getDouble
virtual double getDouble(const std::string &fieldName) const =0
Get double field value.
EMECDetectorRegion::getRegionIndex
unsigned int getRegionIndex() const
Returns the Region Index.
Definition: EMECDetectorRegion.h:171
EMECDetectorManager::m_ziw
std::vector< double > m_ziw
A vector of doubles used to hold an array of sampling separations for the EMEC inner wheel.
Definition: EMECDetectorManager.h:215
IRDBRecordset.h
Definition of the abstract IRDBRecordset interface.
EMECDetectorManager::EMECMagicNumbers::presamplerLength
double presamplerLength
Overall length of the presampler.
Definition: EMECDetectorManager.h:279
EMECHVManager
This class provides direct access to information on the HV electrodes within the EMEC....
Definition: EMECHVManager.h:36
IGeoModelSvc.h
StoreGateSvc.h
EMECDetectorRegion.h
EMECDetectorManager::~EMECDetectorManager
virtual ~EMECDetectorManager() override
Destructor.
Definition: EMECDetectorManager.cxx:90
EMECDetectorManager::DetectorRegionConstIterator
std::vector< const EMECDetectorRegion * >::const_iterator DetectorRegionConstIterator
Definition: EMECDetectorManager.h:34
IGeoDbTagSvc.h
EMECDetectorManager::EMECDetectorManager
EMECDetectorManager(const EMECHVManager *hvManagerInner=nullptr, const EMECHVManager *hvManagerOuter=nullptr, const EMECPresamplerHVManager *presamplerHVManager=nullptr)
Constructor.
Definition: EMECDetectorManager.cxx:24
ServiceHandle< StoreGateSvc >
EMECDetectorManager::endDetectorRegion
EMECDetectorManager::DetectorRegionConstIterator endDetectorRegion() const
Iterate over detector regions.
Definition: EMECDetectorManager.cxx:103