ATLAS Offline Software
Loading...
Searching...
No Matches
EMECDetectorManager.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 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
21#include "LArHV/LArHVManager.h"
22// Class EMECDetectorManager
23
25 , const EMECHVManager* hvManagerOuter
26 , const EMECPresamplerHVManager* presamplerHVManager)
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)
102
107
108const 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
118PVConstLink 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 size_t iregion = region->getRegionIndex();
132 if (iregion >= 6) {
133 throw std::out_of_range("EMECDetectorManager::addDetectorRegion -- region");
134 }
135 size_t isampling = region->getSamplingIndex();
136 if (isampling >= 4) {
137 throw std::out_of_range("EMECDetectorManager::addDetectorRegion -- sampling");
138 }
139 // coverity[checked_return]
140 size_t iradius = region->getRadialIndex();
141 if (iradius >= 2) {
142 throw std::out_of_range("EMECDetectorManager::addDetectorRegion -- radius");
143 }
144 size_t iendcap = region->getEndcapIndex();
145 if (iendcap >= 2) {
146 throw std::out_of_range("EMECDetectorManager::addDetectorRegion -- endcap");
147 }
148 m_DetRegionsRandom[iregion][isampling][iradius][iendcap] = region;
149}
150
151void EMECDetectorManager::addTreeTop (const PVLink& treeTop)
152{
153 m_treeTop.push_back(treeTop);
154}
155
157{
158 const EMECHVManager* out = m_HVManager[io].get();
159 if (!out) {
160 //Support lazy initialization for testbeams
161 ServiceHandle<StoreGateSvc> detStore ("DetectorStore", "HECHVManager");
162 const LArHVManager *manager{nullptr};
163 if (detStore->retrieve(manager)==StatusCode::SUCCESS) {
164 out = &(manager->getEMECHVManager(io));
165 m_HVManager[io].set (out);
166 }
167 }
168 if (!out) {
169 throw std::runtime_error ("EMECDetectorManager::getHVManager: Can't find LArHVManager in DetectorStore");
170 }
171 return *out;
172}
173
175{
177 if (!out) {
178 ServiceHandle<StoreGateSvc> detStore ("DetectorStore", "HECHVManager");
179 const LArHVManager *manager{nullptr};
180 if (detStore->retrieve(manager)==StatusCode::SUCCESS) {
181 out = &(manager->getEMECPresamplerHVManager());
182 m_presamplerHVManager.set (out);
183 }
184 }
185 if (!out) {
186 throw std::runtime_error ("EMECDetectorManager::getPresamplerHVManager: Can't find LArHVManager in DetectorStore");
187 }
188 return *out;
189}
Definition of the abstract IRDBAccessSvc interface.
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
Definition of the abstract IRDBRecord interface.
Definition of the abstract IRDBRecordset interface.
This is a helper class to query the version tags from GeoModelSvc and determine the appropriate tag a...
const std::string & tag() const
Return version tag.
const std::string & node() const
Return the version node.
This is a collection of numbers used to specify the construction of the electromagnetic endcap calori...
CxxUtils::CachedPointer< const EMECPresamplerHVManager > m_presamplerHVManager
const EMECDetectorRegion * getDetectorRegion(unsigned int endcap, unsigned int sampling, unsigned int region, bool inner) const
Random Access to detector regions.
const EMECPresamplerHVManager & getPresamplerHVManager() const
Get the HV Manager (presampler)
EMECDetRegionArray m_DetRegionsRandom
A vector of Region pointers which exists in order to provide iterative access to any EMECDetectorRegi...
virtual PVConstLink getTreeTop(unsigned int i) const override
Gets the ith tree top.
virtual unsigned int getNumTreeTops() const override
Gets the total number of tree tops.
CxxUtils::CachedPointer< const EMECHVManager > m_HVManager[2]
The HV Managers for the emec;.
void addTreeTop(const PVLink &treeTop)
Add a Tree Top.
EMECDetectorManager::DetectorRegionConstIterator endDetectorRegion() const
Iterate over detector regions.
EMECMagicNumbers * m_MagicNumbers
Clockwork for the EMECDetectorManager.
void addDetectorRegion(const EMECDetectorRegion *region)
Add a new HEC Detector Region.
std::vector< double > m_zsep23
A vector of doubles used to hold an array of sampling separations for the EMEC outer wheel between sa...
std::vector< double > m_zsep12
A vector of doubles used to hold an array of sampling separations for the EMEC outer wheel between sa...
unsigned int getNumDetectorRegions() const
Gets the number of detectors in the set of detector regions.
EMECDetectorManager(const EMECHVManager *hvManagerInner=nullptr, const EMECHVManager *hvManagerOuter=nullptr, const EMECPresamplerHVManager *presamplerHVManager=nullptr)
Constructor.
virtual ~EMECDetectorManager() override
Destructor.
std::vector< double > m_ziw
A vector of doubles used to hold an array of sampling separations for the EMEC inner wheel.
const EMECHVManager & getHVManager(EMECHVManager::IOType io) const
Get the HV Managers.
std::vector< PVLink > m_treeTop
This is the set of tree tops managed by this detector node.
std::vector< const EMECDetectorRegion * > m_DetRegionsIterative
A vector of Region pointers which exists in order to provide iterative access to any EMECDetectorRegi...
EMECDetectorManager::DetectorRegionConstIterator beginDetectorRegion() const
Iterate over detector regions.
std::vector< constEMECDetectorRegion * >::const_iterator DetectorRegionConstIterator
unsigned int getRadialIndex() const
Returns the Radial (Outer Wheel=0,InnerWheel=1) Index.
unsigned int getRegionIndex() const
Returns the Region Index.
EMECDetectorRegion::DetectorSide getEndcapIndex() const
The endcap index.
unsigned int getSamplingIndex() const
Returns the Sampling Layer Index.
This class provides direct access to information on the HV electrodes within the EMEC.
EMECHVModule::IOType IOType
This class provides direct access to information on the HV electrodes within the EMEC.
IRDBRecord is one record in the IRDBRecordset object.
Definition IRDBRecord.h:27
virtual double getDouble(const std::string &fieldName) const =0
Get double field value.
virtual unsigned int size() const =0
This class provides access to the High Voltage throughout the LAr.
int r
Definition globals.cxx:22