ATLAS Offline Software
HECDetectorManager.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 #include "GaudiKernel/MsgStream.h"
8 #include "GaudiKernel/Bootstrap.h"
9 #include "GaudiKernel/SystemOfUnits.h"
10 #include "StoreGate/StoreGateSvc.h"
18 #include "LArHV/LArHVManager.h"
19 
20 // Class HECDetectorManager
21 
22 HECDetectorManager::HECDetectorManager(const HECHVManager* hvManager, bool isTestBeam)
23  : GeoVDetectorManager()
24  , m_HVManager(hvManager)
25  , m_isTestBeam(isTestBeam)
26 {
27  setName("LArHEC");
28 
29  ISvcLocator *svcLocator = Gaudi::svcLocator();
30 
31  SmartIF<IGeoModelSvc> geoModel{svcLocator->service("GeoModelSvc")};
32  if(!geoModel.isValid())
33  throw std::runtime_error("Error in HECDetectorManager, cannot access GeoModelSvc");
34 
35  SmartIF<IGeoDbTagSvc> geoDbTagSvc{svcLocator->service("GeoDbTagSvc")};
36  if(!geoDbTagSvc.isValid())
37  throw std::runtime_error("Error in HECDetectorManager, cannot access GeoDbTagSvc");
38 
39  SmartIF<IRDBAccessSvc> rdbAccess{svcLocator->service(geoDbTagSvc->getParamSvcName())};
40  if(!rdbAccess.isValid())
41  throw std::runtime_error("Error in HECDetectorManager, cannot access RDBAccessSvc");
42 
43  std::string larKey, larNode;
44  if(geoDbTagSvc->getSqliteReader()==nullptr) {
45  DecodeVersionKey larVersionKey(geoModel, "LAr");
46  larKey = larVersionKey.tag();
47  larNode = larVersionKey.node();
48  }
49 
50  IRDBRecordset_ptr hecLongBlock = rdbAccess->getRecordsetPtr("HecLongitudinalBlock",larKey,larNode);
51  IRDBRecordset_ptr hecPad = rdbAccess->getRecordsetPtr("HecPad",larKey,larNode);
52  IRDBRecordset_ptr hadronicEndcap = rdbAccess->getRecordsetPtr("HadronicEndcap",larKey,larNode);
53 
54  if(hecLongBlock->size()==0) {
55  hecLongBlock = rdbAccess->getRecordsetPtr("HecLongitudinalBlock", "HecLongitudinalBlock-00");
56  if (hecLongBlock->size()==0) {
57  throw std::runtime_error("Error getting HecLongitudinalBlock table");
58  }
59  }
60 
61  if(hecPad->size()==0) {
62  hecPad = rdbAccess->getRecordsetPtr("HecPad","HecPad-00");
63  if (hecPad->size()==0) {
64  throw std::runtime_error("Error getting HecPad table");
65  }
66  }
67 
68  if(hadronicEndcap->size()==0) {
69  hadronicEndcap = rdbAccess->getRecordsetPtr("HadronicEndcap","HadronicEndcap-00");
70  if (hadronicEndcap->size()==0) {
71  throw std::runtime_error("Error getting HadronicEndcap table");
72  }
73  }
74 
75  if (hecPad->size()!=hecLongBlock->size()) throw std::runtime_error("Error. Hec[LongitudinalBlock,Pad] size discrepancy");
76 
77  // Get the focal length:
78  m_focalToRef1 = (*hadronicEndcap)[0]->getDouble("ZORIG")*Gaudi::Units::cm;
80  double betweenWheel=(*hadronicEndcap)[0]->getDouble("GAPWHL")*Gaudi::Units::cm;
81  if(!m_isTestBeam) m_focalToRef2 += betweenWheel;
82 
83  for (unsigned int b=0;b<hecLongBlock->size();b++) {
84  double etaBoundary[15];
85  const IRDBRecord *block = (*hecLongBlock)[b];
86  unsigned int blockNumber= (unsigned int) (block->getDouble("IBLC")+0.01); // will truncate down.
87  double innerRadius= block->getDouble("BLRMN")*Gaudi::Units::cm;
88  double outerRadius= block->getDouble("BLRMX")*Gaudi::Units::cm;
89  double depth= block->getDouble("BLDPTH")*Gaudi::Units::cm;
90  unsigned int numLArGaps= (unsigned int) (block->getDouble("BLMOD") + 0.01); // will truncate down.
91  double frontPlateThickness= block->getDouble("PLATE0")*Gaudi::Units::cm;
92  double backPlateThickness= block->getDouble("PLATEE")*Gaudi::Units::cm;
93 
94  const IRDBRecord *pad = (*hecPad)[b];
95  for (int j=0;j<15;j++) etaBoundary[j]=pad->getDouble("ETA",j);
96  HECLongBlock *longBlock = new HECLongBlock(blockNumber,
97  innerRadius,
98  outerRadius,
99  depth,
100  numLArGaps,
101  frontPlateThickness,
102  backPlateThickness,
103  etaBoundary);
104  m_HecLongBlock.push_back(longBlock);
105  if ((!m_isTestBeam) && b<3) m_focalToRef2 += depth;
106  }
107 
108 
109 }
110 
111 
113 {
114  for (unsigned int i=0;i<getNumBlocks();i++) delete m_HecLongBlock[i];
115  for (unsigned int i=0;i<getNumDetectorRegions();i++) delete m_DetRegionsIterative[i];
116 }
117 
118 
119 
121 {
122  return m_DetRegionsIterative.begin();
123 }
124 
126 {
127  return m_DetRegionsIterative.end();
128 }
129 
130 const HECDetectorRegion * HECDetectorManager::getDetectorRegion (unsigned int endcap, unsigned int sampling, unsigned int region) const
131 {
132  return m_DetRegionsRandom[endcap][sampling][region];
133 }
134 
136 {
137  return m_DetRegionsIterative.size();
138 }
139 
140 PVConstLink HECDetectorManager::getTreeTop (unsigned int i) const
141 {
142  return m_treeTop[i];
143 }
144 
146 {
147  return m_treeTop.size();
148 }
149 
151 {
152  return m_HecLongBlock.begin();
153 }
154 
156 {
157  return m_HecLongBlock.end();
158 }
159 
160 const HECLongBlock * HECDetectorManager::getBlock (unsigned int i) const
161 {
162  return m_HecLongBlock[i];
163 }
164 
165 unsigned int HECDetectorManager::getNumBlocks () const
166 {
167  return m_HecLongBlock.size();
168 }
169 
171 {
172  m_DetRegionsRandom[region->getEndcapIndex()][region->getSamplingIndex()][region->getRegionIndex()] = region;
173  m_DetRegionsIterative.push_back(region);
174 }
175 
176 void HECDetectorManager::addTreeTop (const PVLink& treeTop)
177 {
178  m_treeTop.push_back(treeTop);
179 }
180 
182 {
183  return *m_HVManager;
184 }
185 
186 
HECDetectorManager::m_HVManager
const HECHVManager * m_HVManager
Definition: HECDetectorManager.h:166
LArHVManager.h
egammaParameters::depth
@ depth
pointing depth of the shower as calculated in egammaqgcld
Definition: egammaParamDefs.h:276
HECDetectorManager::m_DetRegionsRandom
HECDetRegionArray m_DetRegionsRandom
An array of Region pointers which exists in order to provide random access to any HECDetectorRegion h...
Definition: HECDetectorManager.h:152
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
HECDetectorManager::m_focalToRef2
double m_focalToRef2
Definition: HECDetectorManager.h:164
HECDetectorManager::~HECDetectorManager
virtual ~HECDetectorManager() override
Destructor.
Definition: HECDetectorManager.cxx:112
DecodeVersionKey::node
const std::string & node() const
Return the version node.
Definition: DecodeVersionKey.cxx:97
HECDetectorRegion.h
HECDetectorManager::getNumDetectorRegions
unsigned int getNumDetectorRegions() const
Gets the number of detectors in the set of detector regions.
Definition: HECDetectorManager.cxx:135
HECDetectorManager::addTreeTop
void addTreeTop(const PVLink &treeTop)
Add a Tree Top.
Definition: HECDetectorManager.cxx:176
HECDetectorManager::m_isTestBeam
bool m_isTestBeam
Definition: HECDetectorManager.h:168
HECDetectorRegion::getRegionIndex
unsigned int getRegionIndex() const
Returns the Region Index.
Definition: HECDetectorRegion.h:172
cm
const double cm
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/FCAL_ChannelMap.cxx:25
HECDetectorManager::beginBlock
HECDetectorManager::BlockConstIterator beginBlock() const
Iterate over blocks.
Definition: HECDetectorManager.cxx:150
IRDBAccessSvc.h
Definition of the abstract IRDBAccessSvc interface.
lumiFormat.i
int i
Definition: lumiFormat.py:85
HECDetectorRegion
Description of a region of homogenous granularity in the hadronic endcap calorimeter.
Definition: HECDetectorRegion.h:31
DecodeVersionKey
This is a helper class to query the version tags from GeoModelSvc and determine the appropriate tag a...
Definition: DecodeVersionKey.h:18
HECDetectorManager::endDetectorRegion
HECDetectorManager::DetectorRegionConstIterator endDetectorRegion() const
Iterate over detector regions.
Definition: HECDetectorManager.cxx:125
HECDetectorManager::m_HecLongBlock
std::vector< const HECLongBlock * > m_HecLongBlock
Definition: HECDetectorManager.h:137
DecodeVersionKey::tag
const std::string & tag() const
Return version tag.
Definition: DecodeVersionKey.cxx:91
HECDetectorManager::BlockConstIterator
std::vector< const HECLongBlock * >::const_iterator BlockConstIterator
Definition: HECDetectorManager.h:32
HECDetectorManager::beginDetectorRegion
HECDetectorManager::DetectorRegionConstIterator beginDetectorRegion() const
Iterate over detector regions.
Definition: HECDetectorManager.cxx:120
HECLongBlock
Definition: HECLongBlock.h:32
IRDBRecordset_ptr
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
Definition: IRDBAccessSvc.h:25
HECDetectorManager::getBlock
const HECLongBlock * getBlock(unsigned int i) const
Random Access to Blocks.
Definition: HECDetectorManager.cxx:160
HECDetectorRegion::getEndcapIndex
HECDetectorRegion::DetectorSide getEndcapIndex() const
The endcap index.
Definition: HECDetectorRegion.h:209
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
HECDetectorManager::getNumBlocks
unsigned int getNumBlocks() const
Gets the number of blocks in the set of blocks.
Definition: HECDetectorManager.cxx:165
HECDetectorManager::getNumTreeTops
virtual unsigned int getNumTreeTops() const override
Gets the total number of tree tops.
Definition: HECDetectorManager.cxx:145
DecodeVersionKey.h
HECHVManager
This class provides direct access to information on the HV electrodes within the barrels....
Definition: HECHVManager.h:36
IRDBRecord.h
Definition of the abstract IRDBRecord interface.
HECDetDescr.h
HECDetectorManager::HECDetectorManager
HECDetectorManager(const HECHVManager *hvManager=nullptr, bool isTestBeam=false)
Constructor.
Definition: HECDetectorManager.cxx:22
IRDBRecord
IRDBRecord is one record in the IRDBRecordset object.
Definition: IRDBRecord.h:27
HECDetectorManager::getTreeTop
virtual PVConstLink getTreeTop(unsigned int i) const override
Gets the ith tree top.
Definition: HECDetectorManager.cxx:140
HECDetectorManager::DetectorRegionConstIterator
std::vector< const HECDetectorRegion * >::const_iterator DetectorRegionConstIterator
Definition: HECDetectorManager.h:33
HECDetectorManager::addDetectorRegion
void addDetectorRegion(const HECDetectorRegion *region)
Add a new HEC Detector Region.
Definition: HECDetectorManager.cxx:170
HECDetectorManager::endBlock
HECDetectorManager::BlockConstIterator endBlock() const
Iterate over blocks.
Definition: HECDetectorManager.cxx:155
HECDetectorManager::getHVManager
const HECHVManager & getHVManager() const
Get the HV Manager.
Definition: HECDetectorManager.cxx:181
IRDBRecord::getDouble
virtual double getDouble(const std::string &fieldName) const =0
Get double field value.
HECDetectorManager::getDetectorRegion
const HECDetectorRegion * getDetectorRegion(unsigned int endcap, unsigned int sampling, unsigned int region) const
Random Access to detector regions.
Definition: HECDetectorManager.cxx:130
IRDBRecordset.h
Definition of the abstract IRDBRecordset interface.
HECDetectorManager::m_DetRegionsIterative
std::vector< const HECDetectorRegion * > m_DetRegionsIterative
A vector of Region pointer which exists in order to provide iterative access to any HECDetectorRegion...
Definition: HECDetectorManager.h:161
IGeoModelSvc.h
StoreGateSvc.h
HECDetectorManager::m_focalToRef1
double m_focalToRef1
Definition: HECDetectorManager.h:163
HECDetectorRegion::getSamplingIndex
unsigned int getSamplingIndex() const
Returns the Sampling Layer Index (0-3)
Definition: HECDetectorRegion.h:165
HECDetectorManager.h
IGeoDbTagSvc.h
HECDetectorManager::m_treeTop
std::vector< PVLink > m_treeTop
This is the set of tree tops managed by this detector node.
Definition: HECDetectorManager.h:143