ATLAS Offline Software
RALEmb.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 // RALEmb
6 // Sep 5 JFB
7 
8 // Fetch parameters from a NOVA database structure.
9 
10 #include "LArGeoRAL/RALEmb.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 
49 };
50 
51 
53  m_c(new Clockwork())
54 {
55  // First, fetch the Athena services.
56  ISvcLocator* svcLocator = Gaudi::svcLocator();
57 
58  SmartIF<IGeoDbTagSvc> geoDbTagSvc{svcLocator->service("GeoDbTagSvc")};
59  if(!geoDbTagSvc.isValid()) {
60  throw std::runtime_error ("Cannot locate GeoDBTagSvc");
61  }
62 
63  SmartIF<IRDBAccessSvc> pAccessSvc{svcLocator->service(geoDbTagSvc->getParamSvcName())};
64  if(!pAccessSvc.isValid()) {
65  throw std::runtime_error ("Cannot locate " + geoDbTagSvc->getParamSvcName());
66  }
67 
68  std::string detectorKey;
69  std::string detectorNode;
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  std::string 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  if ( LArVersion.empty()) {
86  LArVersion=pAccessSvc->getChildTag("LAr",AtlasVersion,"ATLAS");
87  }
88 
89  MsgStream log(Athena::getMessageSvc(),"RALEmb");
90 
91  if (LArVersion == "LAr-00" || LArVersion == "LAr-01" ||
92  LArVersion == "LAr-Rome-Initial-00" ||
93  LArVersion == "LAr-H6-00" ||
94  LArVersion == "LAr-Commissioning-00" ||
95  LArVersion == "LAr-G3-00") {
96  m_oldDB=true;
97  log << MSG::INFO << " in RALEmb: old database tag used, some values are hard coded" << endmsg;
98  log << MSG::INFO << " Non projectivity of lead transition will not be simulated " << endmsg;
99  }
100 
101  if (LArVersion == "LAr-00" || LArVersion == "LAr-01" || LArVersion == "LAr-02" ||
102  LArVersion == "LAr-Rome-Initial-00" ||
103  LArVersion == "LAr-H8-00" ||
104  LArVersion == "LAr-H6-00" ||
105  LArVersion == "LAr-Commissioning-00" ||
106  LArVersion == "LAr-G3-00") {
107  m_oldSagging=true;
108  log << MSG::INFO << " in RALEmb: only old sagging values available" << endmsg;
109  }
110 
111  if (LArVersion == "LAr-00" || LArVersion == "LAr-01" || LArVersion == "LAr-02" ||
112  LArVersion == "LAr-03" || LArVersion == "LAr-04" ||
113  LArVersion == "LAr-Rome-Initial-00" ||
114  LArVersion == "LAr-H8-00" ||
115  LArVersion == "LAr-H6-00" ||
116  LArVersion == "LAr-Commissioning-00" ||
117  LArVersion == "LAr-Commissioning-01" ||
118  LArVersion == "LAr-G3-00" ||
119  LArVersion == "LAr-02-Align-00" ||
120  LArVersion == "LAr-02-Align-01" ||
121  LArVersion == "LAr-H6-2002-00" ||
122  LArVersion == "LAr-H6-2003-00" ||
123  LArVersion == "LAr-TBEC-00" ) {
124  m_oldContract=true;
125  }
126  }
127 
128 
129  m_c->barrelGeometry = pAccessSvc->getRecordsetPtr("BarrelGeometry",detectorKey, detectorNode);
130  m_c->barrelSagging = pAccessSvc->getRecordsetPtr("BarrelSagging",detectorKey, detectorNode);
131  m_c->barrelAccordionCables = pAccessSvc->getRecordsetPtr("BarrelAccordionCables",detectorKey, detectorNode);
132  m_c->barrelMotherboards = pAccessSvc->getRecordsetPtr("BarrelMotherboards",detectorKey, detectorNode);
133  m_c->barrelLongDiv = pAccessSvc->getRecordsetPtr("BarrelLongDiv",detectorKey, detectorNode);
134  m_c->presamplerGeometry = pAccessSvc->getRecordsetPtr("PresamplerGeometry",detectorKey, detectorNode);
135  if (!m_oldDB) m_c->barrelEtaTrans = pAccessSvc->getRecordsetPtr("BarrelEtaTrans",detectorKey,detectorNode);
136 
137  if (!m_oldContract) m_c->coldContraction = pAccessSvc->getRecordsetPtr("ColdContraction",detectorKey,detectorNode);
138 }
139 
140 
142 {
143  delete m_c;
144 }
145 
146 
147 double LArGeo::RALEmb::GetValue(const std::string& a_name,
148  const int a0,
149  const int /*a1*/,
150  const int /*a2*/,
151  const int /*a3*/,
152  const int /*a4*/ ) const
153 {
154 
155  std::ostringstream A0STR;
156  A0STR << "_" << a0;
157  const std::string A0 = A0STR.str();
158 
159  if ( a_name == "LArEMBnoOFPhysPhiCell" ) return (*m_c->barrelGeometry)[0]->getInt("NCELMX");
160 // GU 7-oct-05 phifirst is stored in radians not in degre
161  if ( a_name == "LArEMBAbsPhiFirst" ) return (*m_c->barrelGeometry)[0]->getDouble("PHIFIRST");
162  if ( a_name == "LArEMBPhiGapWidth" ) return (*m_c->barrelGeometry)[0]->getDouble("PHIGAP")*CLHEP::cm;
163  if ( a_name == "LArEMBPhiGapAperture" ) return (*m_c->barrelGeometry)[0]->getDouble("ALFA")*CLHEP::deg;
164  if ( a_name == "LArEMBMotherRmin" ) return (*m_c->barrelGeometry)[0]->getDouble("RMIN")*CLHEP::cm;
165  if ( a_name == "LArEMBMotherRmax" ) return (*m_c->barrelGeometry)[0]->getDouble("RMAX")*CLHEP::cm;
166  if ( a_name == "LArEMBFiducialRmax" ) return (*m_c->barrelGeometry)[0]->getDouble("ROUT_AC")*CLHEP::cm;
167  if ( a_name == "LArEMBMotherZmin" ) return (*m_c->barrelGeometry)[0]->getDouble("ZMIN")*CLHEP::cm;
168  if ( a_name == "LArEMBMotherZmax" ) return (*m_c->barrelGeometry)[0]->getDouble("ZMAX")*CLHEP::cm;
169  if ( a_name == "LArEMBnoOFAccZigs" ) return (*m_c->barrelGeometry)[0]->getInt("NBRT");
170  if ( a_name == "LArEMBnoOFAccSamps" ) return (*m_c->barrelGeometry)[0]->getInt("NSTAMX");
171  if ( a_name == "LArEMBInnerElectronics" ) return (*m_c->barrelGeometry)[0]->getDouble("XEL1")*CLHEP::cm;
172  if ( a_name == "LArEMBLArGapTail" ) return (*m_c->barrelGeometry)[0]->getDouble("XTAL")*CLHEP::cm;
173  if ( a_name == "LArEMBG10SupportBarsIn" ) return (*m_c->barrelGeometry)[0]->getDouble("XG10")*CLHEP::cm;
174  if ( a_name == "LArEMBG10SupportBarsOut" ) return (*m_c->barrelGeometry)[0]->getDouble("XGSB")*CLHEP::cm;
175  if ( a_name == "LArEMBZmin" ) return (*m_c->barrelGeometry)[0]->getDouble("ZMIN")*CLHEP::cm;
176  if ( a_name == "LArEMBZmax" ) return (*m_c->barrelGeometry)[0]->getDouble("ZMAX")*CLHEP::cm;
177  if ( a_name == "LArEMBAccTrackMin" ) return (*m_c->barrelGeometry)[0]->getDouble("RHOMIN")*CLHEP::cm;
178  if ( a_name == "LArEMBRadiusInnerAccordion" ) return (*m_c->barrelGeometry)[0]->getDouble("RIN_AC")*CLHEP::cm;
179  if ( a_name == "LArEMBRadiusOuterAccordion" ) return (*m_c->barrelGeometry)[0]->getDouble("ROUT_AC")*CLHEP::cm;
180  if ( a_name == "LArEMBMaxEtaAcceptance" ) return (*m_c->barrelGeometry)[0]->getDouble("ETACUT");
181  if ( a_name == "LArEMBThickEtaAcceptance" ) return (*m_c->barrelGeometry)[0]->getDouble("ETACU1");
182  if ( a_name == "LArEMBRadiusAtCurvature" ) return (*m_c->barrelGeometry)[0]->getDouble("RHOCEN"+A0)*CLHEP::cm;
183  if ( a_name == "LArEMBPhiAtCurvature" ) return (*m_c->barrelGeometry)[0]->getDouble("PHICEN"+A0)*CLHEP::deg;
184  if ( a_name == "LArEMBDeltaZigAngle" ) return (*m_c->barrelGeometry)[0]->getDouble("DELTA"+A0)*CLHEP::deg;
185  if ( a_name == "LArEMBNeutFiberRadius" ) return (*m_c->barrelGeometry)[0]->getDouble("RINT")*CLHEP::cm;
186  if ( a_name == "LArEMBLeadTipThickFront" ) return (*m_c->barrelGeometry)[0]->getDouble("XTIP_PB")*CLHEP::cm;
187  if ( a_name == "LArEMBLeadTipThickEnd" ) return (*m_c->barrelGeometry)[0]->getDouble("XTIP_PC")*CLHEP::cm;
188  if ( a_name == "LArEMBG10TipThickFront" ) return (*m_c->barrelGeometry)[0]->getDouble("XTIP_GT")*CLHEP::cm;
189  if ( a_name == "LArEMBG10TipThickEnd" ) return (*m_c->barrelGeometry)[0]->getDouble("XTIP_GS")*CLHEP::cm;
190  if ( a_name == "LArEMBThinAbsGlue" ) return (*m_c->barrelGeometry)[0]->getDouble("TGGL")*CLHEP::cm;
191  if ( a_name == "LArEMBThinAbsIron" ) return (*m_c->barrelGeometry)[0]->getDouble("TGFE")*CLHEP::cm;
192  if ( a_name == "LArEMBThinAbsLead" ) return (*m_c->barrelGeometry)[0]->getDouble("TGPB")*CLHEP::cm;
193  if ( a_name == "LArEMBThickAbsGlue" ) return (*m_c->barrelGeometry)[0]->getDouble("THGL")*CLHEP::cm;
194  if ( a_name == "LArEMBThickAbsIron" ) return (*m_c->barrelGeometry)[0]->getDouble("THFE")*CLHEP::cm;
195  if ( a_name == "LArEMBThickAbsLead" ) return (*m_c->barrelGeometry)[0]->getDouble("THPB")*CLHEP::cm;
196  if ( a_name == "LArEMBThickElecCopper" ) return (*m_c->barrelGeometry)[0]->getDouble("THCU")*CLHEP::cm;
197  if ( a_name == "LArEMBThickElecKapton" ) return (*m_c->barrelGeometry)[0]->getDouble("THFG")*CLHEP::cm;
198  if ( a_name == "LArEMBRminHighZ" ) {
199  if (!m_oldDB) return (*m_c->barrelGeometry)[0]->getDouble("RMINHIGHZ")*CLHEP::cm;
200  else return 154.8*CLHEP::cm;
201  }
202  if ( a_name == "LArEMBDeltaRS12" ) {
203  if (!m_oldDB) return (*m_c->barrelGeometry)[0]->getDouble("DELTARS12")*CLHEP::cm;
204  else return 0.11*CLHEP::cm;
205  }
206  if ( a_name == "LArEMBphiMaxBarrel" ) {
207  if (!m_oldDB) return (*m_c->barrelGeometry)[0]->getDouble("PHIMAXBARREL");
208  else return 360.;
209  }
210  if ( a_name == "LArEMBG10FrontDeltaZ" ) {
211  if (!m_oldDB) return (*m_c->barrelGeometry)[0]->getDouble("G10FRONTDELTAZ")*CLHEP::cm;
212  else return 309.4*CLHEP::cm;
213  }
214 
215  //
216 
217 
218  // 2) FROM ASAG structure
219 
220 
221  if ( a_name == "LArEMBSaggingAmplitude" ) {
222  return (*m_c->barrelSagging)[0]->getDouble("SAG"+A0)*CLHEP::cm;
223  }
224  if ( a_name == "LArEMBSaggingAmplitude2" ) {
225  if (!m_oldSagging) return (*m_c->barrelSagging)[0]->getDouble("SAG"+A0+"_X")*CLHEP::cm;
226  else return 0;
227  }
228 
229 
230 
231  //
232 
233  // 3) FROM ACCA ( electronics cables)
234 
235  if ( a_name == "LArEMBmasspercentCu" ) return (*m_c->barrelAccordionCables)[0]->getDouble("PERCU");
236  if ( a_name == "LArEMBmasspercentKap" ) return (*m_c->barrelAccordionCables)[0]->getDouble("PERKAP");
237  if ( a_name == "LArEMBCablethickat0" ) return (*m_c->barrelAccordionCables)[0]->getDouble("THICKIN")*CLHEP::cm;
238  if ( a_name == "LArEMBthickincrfac" ) return (*m_c->barrelAccordionCables)[0]->getDouble("THICKFAC")*CLHEP::cm;
239  if ( a_name == "LArEMBCableEtaheight" ) return (*m_c->barrelAccordionCables)[0]->getDouble("HEIGHT")*CLHEP::cm;
240  if ( a_name == "LArEMBnoOFcableBundle" ) return (*m_c->barrelAccordionCables)[0]->getInt("ACCORCAB");
241  if ( a_name == "LArEMBCablclearfrPS" ) return (*m_c->barrelAccordionCables)[0]->getDouble("CLEARANCE")*CLHEP::cm;
242 
243 
244  // 4) FROM (*C->BARRELMOTHERBOARDS) ( electronics mother_boards)
245  if ( a_name == "LArEMBEpoxyVolumicMass" ) return (*m_c->barrelMotherboards)[0]->getDouble("DG10")*(CLHEP::g/CLHEP::cm3);
246  if ( a_name == "LArEMBCuThickness" ) return (*m_c->barrelMotherboards)[0]->getDouble("THICU")*CLHEP::cm;
247  if ( a_name == "LArEMBG10Thickness" ) return (*m_c->barrelMotherboards)[0]->getDouble("THIG10")*CLHEP::cm;
248  if ( a_name == "LArEMBMoBoTchickness" ) return (*m_c->barrelMotherboards)[0]->getDouble("THIMB")*CLHEP::cm;
249  if ( a_name == "LArEMBMoBoHeight" ) return (*m_c->barrelMotherboards)[0]->getDouble("HEIGHTMB")*CLHEP::cm;
250  if ( a_name == "LArEMBnoOFmothboard" ) return (*m_c->barrelMotherboards)[0]->getInt("MOTHBOAR");
251  if ( a_name == "LArEMBMoBoclearfrPS" ) return (*m_c->barrelMotherboards)[0]->getDouble("CLEARANCE")*CLHEP::cm;
252 
253  //
254 
255  // 5) FROM ACCO ( Longitudinal Barrel Parameters)
256  if ( a_name == "LArEMBfiducialMothZmax" ) return (*m_c->barrelLongDiv)[0]->getDouble("ZMAXACT")*CLHEP::cm;
257  if ( a_name == "LArEMBfiducialMothZmin" ) {
258  if (!m_oldDB) return (*m_c->barrelLongDiv)[0]->getDouble("ZMINACT")*CLHEP::cm;
259  else return 0.4*CLHEP::cm;
260  }
261 
262  //
263 
264  // 6) FROM COPG ( PreSampler Barrel Parameters)
265  if ( a_name == "LArEMBarrelRmin" ) return (*m_c->presamplerGeometry)[0]->getDouble("RMIN")*CLHEP::cm;
266 
267  // 7) FROM BarrelEtaTrans
268  if ( a_name == "LArEMBEtaTrans" ) {
269  if (!m_oldDB) return (*m_c->barrelEtaTrans)[a0]->getDouble("ETATRANS");
270  else return 0.8;
271  }
272 
273  // 8) FROM ColdContraction
274  if (!m_oldContract) {
275  if (a_name == "LArEMBAbsorberContraction") return (*m_c->coldContraction)[0]->getDouble("ABSORBERCONTRACTION");
276  }
277  else {
278  if (a_name == "LArEMBAbsorberContraction") return 0.997;
279  }
280 
281  // We didn't find a match.
282  MsgStream log(Athena::getMessageSvc(),"RALEmb");
283  std::string errMessage = "RALEmb::GetValue: could not find a match for the key '" + a_name;
284  log << MSG::FATAL << errMessage << endmsg;
285  throw std::runtime_error(errMessage);
286 
287  // Unreached.
288 }
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::RALEmb::Clockwork::barrelLongDiv
IRDBRecordset_ptr barrelLongDiv
Definition: RALEmb.cxx:45
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
cm3
#define cm3
deg
#define deg
Definition: SbPolyhedron.cxx:17
LArGeo::RALEmb::m_c
Clockwork * m_c
Definition: RALEmb.h:34
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
LArGeo::RALEmb::Clockwork::presamplerGeometry
IRDBRecordset_ptr presamplerGeometry
Definition: RALEmb.cxx:46
LArGeo::RALEmb::m_oldContract
bool m_oldContract
Definition: RALEmb.h:38
cm
const double cm
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/FCAL_ChannelMap.cxx:25
LArGeo::RALEmb::Clockwork
Definition: RALEmb.cxx:33
EventInfoWrite.AtlasVersion
AtlasVersion
Definition: EventInfoWrite.py:17
IRDBAccessSvc.h
Definition of the abstract IRDBAccessSvc interface.
python.CaloCondTools.g
g
Definition: CaloCondTools.py:15
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
LArGeo::RALEmb::Clockwork::barrelGeometry
IRDBRecordset_ptr barrelGeometry
Definition: RALEmb.cxx:41
LArGeo::RALEmb::Clockwork::barrelSagging
IRDBRecordset_ptr barrelSagging
Definition: RALEmb.cxx:42
a0
double a0
Definition: globals.cxx:27
IRDBRecordset_ptr
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
Definition: IRDBAccessSvc.h:25
RALEmb.h
VDetectorParameters.h
LArGeo::RALEmb::m_oldSagging
bool m_oldSagging
Definition: RALEmb.h:37
IRDBRecord.h
Definition of the abstract IRDBRecord interface.
LArGeo::RALEmb::Clockwork::barrelEtaTrans
IRDBRecordset_ptr barrelEtaTrans
Definition: RALEmb.cxx:47
LArGeo::RALEmb::~RALEmb
virtual ~RALEmb()
Definition: RALEmb.cxx:141
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
LArGeo::RALEmb::Clockwork::Clockwork
Clockwork()=default
LArGeo::RALEmb::Clockwork::barrelMotherboards
IRDBRecordset_ptr barrelMotherboards
Definition: RALEmb.cxx:44
IRDBRecordset.h
Definition of the abstract IRDBRecordset interface.
IGeoModelSvc.h
StoreGateSvc.h
LArGeo::RALEmb::RALEmb
RALEmb()
Definition: RALEmb.cxx:52
LArGeo::RALEmb::Clockwork::barrelAccordionCables
IRDBRecordset_ptr barrelAccordionCables
Definition: RALEmb.cxx:43
IGeoDbTagSvc.h
LArGeo::RALEmb::m_oldDB
bool m_oldDB
Definition: RALEmb.h:36
LArGeo::RALEmb::Clockwork::coldContraction
IRDBRecordset_ptr coldContraction
Definition: RALEmb.cxx:48
LArGeo::RALEmb::Clockwork::~Clockwork
~Clockwork()=default
LArGeo::RALEmb::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: RALEmb.cxx:147