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 
48  SmartIF<IGeoModelSvc> geoModel{svcLocator->service("GeoModelSvc")};
49  if(!geoModel.isValid())
50  throw std::runtime_error("Error in EMECDetectorManager, cannot access GeoModelSvc");
51 
52  SmartIF<IGeoDbTagSvc> geoDbTagSvc{svcLocator->service("GeoDbTagSvc")};
53  if(!geoDbTagSvc.isValid())
54  throw std::runtime_error("Error in EMECDetectorManager, cannot access GeoDbTagSvc");
55 
56  SmartIF<IRDBAccessSvc> rdbAccess{svcLocator->service(geoDbTagSvc->getParamSvcName())};
57  if(!rdbAccess.isValid())
58  throw std::runtime_error("Error in EMECDetectorManager, 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 (const PVLink& treeTop)
135 {
136  m_treeTop.push_back(treeTop);
137 }
138 
140 {
141  const EMECHVManager* out = m_HVManager[io].get();
142  if (!out) {
143  //Support lazy initialization for testbeams
144  ServiceHandle<StoreGateSvc> detStore ("DetectorStore", "HECHVManager");
145  const LArHVManager *manager{nullptr};
146  if (detStore->retrieve(manager)==StatusCode::SUCCESS) {
147  out = &(manager->getEMECHVManager(io));
148  m_HVManager[io].set (out);
149  }
150  }
151  if (!out) {
152  throw std::runtime_error ("EMECDetectorManager::getHVManager: Can't find LArHVManager in DetectorStore");
153  }
154  return *out;
155 }
156 
158 {
160  if (!out) {
161  ServiceHandle<StoreGateSvc> detStore ("DetectorStore", "HECHVManager");
162  const LArHVManager *manager{nullptr};
163  if (detStore->retrieve(manager)==StatusCode::SUCCESS) {
164  out = &(manager->getEMECPresamplerHVManager());
166  }
167  }
168  if (!out) {
169  throw std::runtime_error ("EMECDetectorManager::getPresamplerHVManager: Can't find LArHVManager in DetectorStore");
170  }
171  return *out;
172 }
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
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
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
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
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
DecodeVersionKey::node
const std::string & node() const
Return the version node.
Definition: DecodeVersionKey.cxx:97
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:85
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:91
EMECDetectorManager::EMECMagicNumbers
This is a collection of numbers used to specify the construction of the electromagnetic endcap calori...
Definition: EMECDetectorManager.h:253
EMECDetectorManager::addTreeTop
void addTreeTop(const PVLink &treeTop)
Add a Tree Top.
Definition: EMECDetectorManager.cxx:134
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:157
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
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