ATLAS Offline Software
RALEmec.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 // RALEmec
6 // Sep 5 JFB
7 
8 // Fetch parameters from a NOVA database structure.
9 
10 #include "LArGeoRAL/RALEmec.h"
12 
13 // Athena Service classes
14 #include "GaudiKernel/Bootstrap.h"
15 #include "GaudiKernel/ISvcLocator.h"
16 #include "StoreGate/StoreGateSvc.h"
17 
18 #include "CLHEP/Units/PhysicalConstants.h"
19 
25 
27 
28 #include <cstdlib>
29 #include <iostream>
30 #include <stdexcept>
31 #include <string>
32 
34 
35 public:
36 
37  Clockwork()= default;
38  ~Clockwork()= default;
39 
40 
48 };
49 
50 
52  m_c(new Clockwork())
53 {
54  // First, fetch the Athena services.
55  ISvcLocator* svcLocator = Gaudi::svcLocator();
56 
57  SmartIF<IGeoDbTagSvc> geoDbTagSvc{svcLocator->service("GeoDbTagSvc")};
58  if(!geoDbTagSvc.isValid()) {
59  throw std::runtime_error ("Cannot locate GeoDBTagSvc");
60  }
61 
62  SmartIF<IRDBAccessSvc> pAccessSvc{svcLocator->service(geoDbTagSvc->getParamSvcName())};
63  if(!pAccessSvc.isValid()) {
64  throw std::runtime_error ("Cannot locate " + geoDbTagSvc->getParamSvcName());
65  }
66 
67  std::string detectorKey;
68  std::string detectorNode;
69  std::string AtlasVersion;
70 
71  if(geoDbTagSvc->getSqliteReader()==nullptr) {
72  // The geometry DB is used
73  SmartIF<IGeoModelSvc> geoModel{svcLocator->service("GeoModelSvc")};
74  if(!geoModel.isValid()) {
75  throw std::runtime_error ("Cannot locate GeoModelSvc");
76  }
77 
78  AtlasVersion = geoModel->atlasVersion();
79  std::string LArVersion = geoModel->LAr_VersionOverride();
80 
81  detectorKey = LArVersion.empty() ? AtlasVersion : LArVersion;
82  detectorNode = LArVersion.empty() ? "ATLAS" : "LAr";
83  }
84 
85  m_c->emecCylLayer = pAccessSvc->getRecordsetPtr("EmecCylLayer",detectorKey, detectorNode);
86  m_c->emecGeometry = pAccessSvc->getRecordsetPtr("EmecGeometry",detectorKey, detectorNode);
87  m_c->emecRapRegion = pAccessSvc->getRecordsetPtr("EmecRapRegion",detectorKey, detectorNode);
88  m_c->emecSamplingSep = pAccessSvc->getRecordsetPtr("EmecSamplingSep",detectorKey, detectorNode);
89  m_c->emecWheelParameters = pAccessSvc->getRecordsetPtr("EmecWheelParameters",detectorKey, detectorNode);
90  m_c->emecWhlOptParm = pAccessSvc->getRecordsetPtr("EmecWhlOptParm",detectorKey, detectorNode);
91  m_c->presamplerPosition = pAccessSvc->getRecordsetPtr("PresamplerPosition",AtlasVersion, "ATLAS");
92 
93 }
94 
95 
97 {
98  delete m_c;
99 }
100 
101 
102 double LArGeo::RALEmec::GetValue(const std::string& a_name,
103  const int a0,
104  const int a1,
105  const int /*a2*/,
106  const int /*a3*/,
107  const int /*a4*/ ) const
108 {
109 
110  std::ostringstream A0STR;
111  A0STR << "_" << a0;
112  const std::string A0 = A0STR.str();
113 
114  std::ostringstream A1STR;
115  A1STR << "_" << a1;
116  const std::string A1 = A1STR.str();
117 
118 
119 
120 
121  if ( a_name == "LArEMECZshift" ) return (*m_c->emecGeometry)[0]->getDouble("ZSHIFT")*CLHEP::cm;
122  if ( a_name == "LArEMECRadiusMin" ) return (*m_c->emecGeometry)[0]->getDouble("RMIN")*CLHEP::cm;
123  if ( a_name == "LArEMECRadiusMax" ) return (*m_c->emecGeometry)[0]->getDouble("RMAX")*CLHEP::cm;
124 
125  if ( a_name == "LArEMECAverageGap" ) return (*m_c->emecGeometry)[0]->getDouble("GAP0")*CLHEP::cm;
126  if ( a_name == "LArEMECStartAbsLength" ) return (*m_c->emecGeometry)[0]->getDouble("SABL")*CLHEP::cm;
127  if ( a_name == "LArEMECRefPoint" ) return (*m_c->emecGeometry)[0]->getDouble("Z0")*CLHEP::cm;
128  if ( a_name == "LArEMECNomLarOrig" ) return (*m_c->emecGeometry)[0]->getDouble("Z1")*CLHEP::cm;
129  if ( a_name == "LArEMECMaxRadiusActivePart" ) return (*m_c->emecGeometry)[0]->getDouble("RLIMIT")*CLHEP::cm;
130  if ( a_name == "LArEMECNumberRadialLayer" ) return (*m_c->emecGeometry)[0]->getInt("NLAYER");
131 
132  if ( a_name == "LArEMECLArThickness" ) return (*m_c->emecGeometry)[0]->getDouble("ETOT")*CLHEP::cm;
133  if ( a_name == "LArEMECKaptonThickness" ) return (*m_c->emecGeometry)[0]->getDouble("EKAP")*CLHEP::cm;
134  if ( a_name == "LArEMECCopperThickness" ) return (*m_c->emecGeometry)[0]->getDouble("ECU")*CLHEP::cm;
135 
136  if ( a_name == "LArEMECHalfCrack" ) return (*m_c->emecGeometry)[0]->getDouble("DCRACK")*CLHEP::cm;
137 
138  if ( a_name == "LArEMECRegionEtaGranularity" ) return (*m_c->emecGeometry)[0]->getDouble("DETA"+A0);
139  if ( a_name == "LArEMECRegionPhiGranularity" ) return (*m_c->emecGeometry)[0]->getDouble("DPHI"+A0);
140 
141 
142  if ( a_name == "LArEMECLayerInnerRadius" ) return (*m_c->emecCylLayer)[a0]->getDouble("RADIL")*CLHEP::cm;
143  if ( a_name == "LArEMECLayerOuterRadius" ) return (*m_c->emecCylLayer)[a0]->getDouble("RADOL")*CLHEP::cm;
144  if ( a_name == "LArEMECLayerInnerAngle" ) return (*m_c->emecCylLayer)[a0]->getDouble("ALFIL")*CLHEP::rad;
145  if ( a_name == "LArEMECLayerOuterAngle" ) return (*m_c->emecCylLayer)[a0]->getDouble("ALFOL")*CLHEP::rad;
146  if ( a_name == "LArEMECAbsorberInnerThickness" ) return (*m_c->emecCylLayer)[a0]->getDouble("TCKIL")*CLHEP::cm;
147  if ( a_name == "LArEMECAbsorberOuterThickness" ) return (*m_c->emecCylLayer)[a0]->getDouble("TCKOL")*CLHEP::cm;
148  if ( a_name == "LArEMECRegionLowEta" ) return (*m_c->emecRapRegion)[a0]->getDouble("ETA1");
149  if ( a_name == "LArEMECRegionHighEta" ) return (*m_c->emecRapRegion)[a0]->getDouble("ETA2");
150  if ( a_name == "LArEMECRegionLowEtaDepth" ) return (*m_c->emecRapRegion)[a0]->getDouble("ZMN"+A1)*CLHEP::cm;
151  if ( a_name == "LArEMECRegionHighEtaDepth" ) return (*m_c->emecRapRegion)[a0]->getDouble("ZMX"+A1)*CLHEP::cm;
152 
153  if ( a_name == "LArEMECLengthSeparationArrays" ) return (*m_c->emecSamplingSep)[0]->getInt("NSEP"+A0);
154  if ( a_name == "LArEMECInnerWheelSeparation" ) return (*m_c->emecSamplingSep)[0]->getDouble("ZIW"+A0)*CLHEP::cm;
155  if ( a_name == "LArEMECZSeparation12" ) return (*m_c->emecSamplingSep)[0]->getDouble("ZSEP12"+A0)*CLHEP::cm;
156  if ( a_name == "LArEMECZSeparation23" ) return (*m_c->emecSamplingSep)[0]->getDouble("ZSEP23"+A0)*CLHEP::cm;
157 
158  // In this case (since the number of wheels isn't likely to change),
159  // hard-code the inner versus the outer wheel.
160  if ( a_name == "LArEMECInnerNumberAbsorbers" ) return (*m_c->emecWheelParameters)[0]->getInt("NABS");
161  if ( a_name == "LArEMECInnerNumberWaves" ) return (*m_c->emecWheelParameters)[0]->getInt("NACC");
162  if ( a_name == "LArEMECInnerMaxEta" ) return (*m_c->emecWheelParameters)[0]->getDouble("ETAINT");
163  if ( a_name == "LArEMECInnerMinEta" ) return (*m_c->emecWheelParameters)[0]->getDouble("ETAEXT");
164  if ( a_name == "LArEMECOuterNumberAbsorbers" ) return (*m_c->emecWheelParameters)[1]->getInt("NABS");
165  if ( a_name == "LArEMECOuterNumberWaves" ) return (*m_c->emecWheelParameters)[1]->getInt("NACC");
166  if ( a_name == "LArEMECOuterMaxEta" ) return (*m_c->emecWheelParameters)[1]->getDouble("ETAINT");
167  if ( a_name == "LArEMECOuterMinEta" ) return (*m_c->emecWheelParameters)[1]->getDouble("ETAEXT");
168 
169  if ( a_name == "LArEMECInnerBeta" ) return (*m_c->emecWhlOptParm)[0]->getDouble("BETX");
170  if ( a_name == "LArEMECInnerLowerAngle" ) return (*m_c->emecWhlOptParm)[0]->getDouble("ALFINT")*CLHEP::rad;
171  if ( a_name == "LArEMECInnerUpperAngle" ) return (*m_c->emecWhlOptParm)[0]->getDouble("ALFEXT")*CLHEP::rad;
172  if ( a_name == "LArEMECInnerLeadThickness" ) return (*m_c->emecWhlOptParm)[0]->getDouble("PBTH")*CLHEP::cm;
173  if ( a_name == "LArEMECOuterBeta" ) return (*m_c->emecWhlOptParm)[1]->getDouble("BETX");
174  if ( a_name == "LArEMECOuterLowerAngle" ) return (*m_c->emecWhlOptParm)[1]->getDouble("ALFINT")*CLHEP::rad;
175  if ( a_name == "LArEMECOuterUpperAngle" ) return (*m_c->emecWhlOptParm)[1]->getDouble("ALFEXT")*CLHEP::rad;
176  if ( a_name == "LArEMECOuterLeadThickness" ) return (*m_c->emecWhlOptParm)[1]->getDouble("PBTH")*CLHEP::cm;
177 
178  if ( a_name == "LArEMECPreNomPos" ) return (*m_c->presamplerPosition)[0]->getDouble("ZPOS")*CLHEP::cm;
179  if ( a_name == "LArEMECPreThickness" ) return (*m_c->presamplerPosition)[0]->getDouble("TCK")*CLHEP::cm;
180  if ( a_name == "LArEMECPreMinRadius" ) return (*m_c->presamplerPosition)[0]->getDouble("RMIN")*CLHEP::cm;
181  if ( a_name == "LArEMECPreMaxRadius" ) return (*m_c->presamplerPosition)[0]->getDouble("RMAX")*CLHEP::cm;
182 
183  // We didn't find a match.
184  MsgStream log(Athena::getMessageSvc(),"RALEmec");
185  std::string errMessage = "RALEmec::GetValue: could not find a match for the key '" + a_name;
186  log << MSG::FATAL << errMessage << endmsg;
187  throw std::runtime_error(errMessage);
188 
189  // Unreached
190 }
LArGeo::RALEmec::Clockwork
Definition: RALEmec.cxx:33
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
LArGeo::RALEmec::Clockwork::emecCylLayer
IRDBRecordset_ptr emecCylLayer
Definition: RALEmec.cxx:41
LArGeo::RALEmec::Clockwork::emecSamplingSep
IRDBRecordset_ptr emecSamplingSep
Definition: RALEmec.cxx:44
LArGeo::RALEmec::Clockwork::Clockwork
Clockwork()=default
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
RALEmec.h
LArGeo::RALEmec::Clockwork::emecRapRegion
IRDBRecordset_ptr emecRapRegion
Definition: RALEmec.cxx:43
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
cm
const double cm
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/FCAL_ChannelMap.cxx:25
LArGeo::RALEmec::~RALEmec
virtual ~RALEmec()
Definition: RALEmec.cxx:96
EventInfoWrite.AtlasVersion
AtlasVersion
Definition: EventInfoWrite.py:17
IRDBAccessSvc.h
Definition of the abstract IRDBAccessSvc interface.
LArGeo::RALEmec::Clockwork::emecWheelParameters
IRDBRecordset_ptr emecWheelParameters
Definition: RALEmec.cxx:45
LArGeo::RALEmec::GetValue
virtual double GetValue(const std::string &, const int i0=INT_MIN, const int i1=INT_MIN, const int i2=INT_MIN, const int i3=INT_MIN, const int i4=INT_MIN) const override
Definition: RALEmec.cxx:102
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
a0
double a0
Definition: globals.cxx:27
IRDBRecordset_ptr
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
Definition: IRDBAccessSvc.h:25
LArGeo::RALEmec::m_c
Clockwork * m_c
Definition: RALEmec.h:34
LArGeo::RALEmec::RALEmec
RALEmec()
Definition: RALEmec.cxx:51
VDetectorParameters.h
LArGeo::RALEmec::Clockwork::presamplerPosition
IRDBRecordset_ptr presamplerPosition
Definition: RALEmec.cxx:47
LArGeo::RALEmec::Clockwork::emecWhlOptParm
IRDBRecordset_ptr emecWhlOptParm
Definition: RALEmec.cxx:46
IRDBRecord.h
Definition of the abstract IRDBRecord interface.
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
IRDBRecordset.h
Definition of the abstract IRDBRecordset interface.
IGeoModelSvc.h
StoreGateSvc.h
IGeoDbTagSvc.h
python.SystemOfUnits.rad
int rad
Definition: SystemOfUnits.py:111
LArGeo::RALEmec::Clockwork::~Clockwork
~Clockwork()=default
LArGeo::RALEmec::Clockwork::emecGeometry
IRDBRecordset_ptr emecGeometry
Definition: RALEmec.cxx:42