ATLAS Offline Software
DistanceCalculatorSaggingOn.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 #ifndef PORTABLE_LAR_SHAPE
6  #include "GaudiKernel/MsgStream.h"
7  #include "GaudiKernel/ISvcLocator.h"
8  #include "GaudiKernel/Bootstrap.h"
9 #else
11 #endif
13 #include "CLHEP/Vector/ThreeVector.h"
14 
15 #include <vector>
16 #include <stdexcept>
17 
19 
20 #include "GeoModelKernel/Units.h"
21 
23 
24 
26 {
29  : parent(lwc),
30  m_saggingOptions(saggingOptions)
31 
32  {
34  }
35 
37  {
38 
39  // Get pointer to the message service
40 #ifndef PORTABLE_LAR_SHAPE
41  SmartIF<IMessageSvc> msgSvc{Gaudi::svcLocator()->service("MessageSvc")};
42  if(!msgSvc.isValid()) {
43  throw std::runtime_error("LArWheelCalculator constructor: cannot initialze message service");
44  }
45  MsgStream msg(msgSvc, "LArWheelCalculator_Impl::DistanceCalculatorSaggingOn");
46 #else
47  PortableMsgStream msg("LArWheelCalculator_Impl::DistanceCalculatorSaggingOn");
48 #endif
49  std::string sagging_opt_value = m_saggingOptions;
50  m_sagging_parameter.resize (lwc()->m_NumberOfFans, std::vector<double> (5, 0.));
51  // if(m_SaggingOn) {
52  if(sagging_opt_value.substr(0, 4) == "file"){
53  std::string sag_file = sagging_opt_value.substr(5);
54  msg << MSG::DEBUG
55  << "geting sagging parameters from file "
56  << sag_file << " ..." << endmsg;
57  FILE *F = fopen(sag_file.c_str(), "r");
58  if(F == 0){
59  msg << MSG::FATAL
60  << "cannot open EMEC sagging parameters file "
61  << sag_file
62  << endmsg;
63  throw std::runtime_error("LArWheelCalculator: read sagging parameters from file");
64  }
65  int s, w, t, n;
66  double p0, p1, p2, p3, p4;
67  while(!feof(F) &&
68  fscanf(F, "%80d %80d %80d %80d %80le %80le %80le %80le %80le",
69  &s, &w, &t, &n, &p0, &p1, &p2, &p3, &p4) == 9)
70  {
71  if(s == lwc()->m_AtlasZside &&
72  ((w == 0 && lwc()->m_isInner) || (w == 1 && !lwc()->m_isInner)) &&
73  ((t == 0 && !lwc()->m_isElectrode) || (t == 1 && lwc()->m_isElectrode)) &&
74  (n >= 0 && n < lwc()->m_NumberOfFans))
75  {
76  m_sagging_parameter[n][0] = p0;
77  m_sagging_parameter[n][1] = p1;
78  m_sagging_parameter[n][2] = p2;
79  m_sagging_parameter[n][3] = p3;
80  m_sagging_parameter[n][4] = p4;
81  msg << MSG::VERBOSE
82  << "sagging for " << s << " " << w << " " << t
83  << " " << n << ": " << p0 << " " << p1 << " "
84  << p2 << " " << p3 << endmsg;
85  }
86  }
87  fclose(F);
88  } else {
89  double a, b, c, d;
90  if(sscanf(sagging_opt_value.c_str(), "%80le %80le %80le %80le", &a, &b, &c, &d) != 4){
91  msg << MSG::ERROR
92  << "wrong value(s) "
93  << " for EMEC sagging parameters: "
94  << sagging_opt_value << ", defaults are used" << endmsg;
95  } else {
96  for(int j = 0; j < lwc()->m_NumberOfFans; j ++){
97  if(lwc()->m_isInner){
98  m_sagging_parameter[j][1] = a;
99  m_sagging_parameter[j][0] = b * mm;
100  } else {
101  m_sagging_parameter[j][1] = c;
102  m_sagging_parameter[j][0] = d * mm;
103  }
104  }
105  }
106  }
107  // }
108  msg << MSG::INFO << "Sagging parameters : " << m_sagging_parameter[0][0] << " " << m_sagging_parameter[0][1] << endmsg
109  << "Sagging parameters : " << m_sagging_parameter[1][0] << " " << m_sagging_parameter[1][1] << endmsg;
110  }
111 
112  // Represents aproximate, probably underestimate, distance to the
113  // neutral fibre of the vertical fan. Sign of return value means
114  // side of the fan; negative - lower phi.
115  //
116  // Uses m_fan_number to compute sagging.
117  double DistanceCalculatorSaggingOn::DistanceToTheNeutralFibre(const CLHEP::Hep3Vector &p, int fan_number) const {
118  CLHEP::Hep3Vector sagging_corrected( p.x()+get_sagging(p, fan_number), p.y(), p.z() );
119  return parent::DistanceToTheNeutralFibre(sagging_corrected, fan_number);
120  }
121 
122  CLHEP::Hep3Vector DistanceCalculatorSaggingOn::NearestPointOnNeutralFibre(const CLHEP::Hep3Vector &p, int fan_number) const {
123  CLHEP::Hep3Vector sagging_corrected( p.x()+get_sagging(p, fan_number), p.y(), p.z() );
124  return parent::NearestPointOnNeutralFibre(sagging_corrected, fan_number);
125  }
126 
127  double DistanceCalculatorSaggingOn::AmplitudeOfSurface(const CLHEP::Hep3Vector& p, int side, int fan_number) const {
128  return parent::AmplitudeOfSurface(p, side, fan_number) - get_sagging(p, fan_number);
129  }
130 
131 
132  // the function uses m_fan_number for phi-dependent sagging computation
133  double DistanceCalculatorSaggingOn::get_sagging(const CLHEP::Hep3Vector &P, int fan_number) const {
134 #ifdef HARDDEBUG
135  std::cout << "get_sagging: MFN = " << fan_number << std::endl;
136 #endif
137  double dx = P.z() / lwc()->m_HalfWheelThickness - 1.;
138  dx *= dx;
139  dx = 1. - dx;
140  //dx *= SaggingAmplitude * sin(FanStepOnPhi * m_fan_number + ZeroFanPhi);
141  //int n = m_fan_number;
142  //if(n < 0) n += m_NumberOfFans;
143  //n += m_ZeroGapNumber;
144  //if(n >= m_NumberOfFans) n -= m_NumberOfFans;
145  //const std::vector<double>& sp = m_sagging_parameter[n];
146  const std::vector<double>& sp = m_sagging_parameter[fan_number];
147  double R = P.r() / mm;
148  double r = R;
149  double result = sp[0];
150  result += R * sp[1];
151  R *= r;
152  result += R * sp[2];
153  R *= r;
154  result += R * sp[3];
155  R *= r;
156  result += R * sp[4];
157 
158 #ifdef HARDDEBUG
159  /*printf("get_sagging: (%6.3f, %6.3f, %6.3f) %6.3f; MFN %4d;"
160  "n %3d; sp %6.4f %6.4f; dx %6.3f; %.6f\n", P.x()/mm, P.y()/mm, P.z()/mm,
161  r, m_fan_number, n, sp[0], sp[1], dx, result*dx);*/
162  printf("get_sagging: (%6.3f, %6.3f, %6.3f) %6.3f;"
163  " sp %6.4f %6.4f; dx %6.3f; %.6f\n", P.x()/mm, P.y()/mm, P.z()/mm,
164  r, sp[0], sp[1], dx, result*dx);
165 #endif //HARDDEBUG
166 
167  return result * dx;
168  }
169 
170 }
beamspotman.r
def r
Definition: beamspotman.py:676
LArWheelCalculator_Impl::DistanceCalculatorSaggingOn::m_sagging_parameter
std::vector< std::vector< double > > m_sagging_parameter
Definition: DistanceCalculatorSaggingOn.h:41
LArWheelCalculator_Impl::DistanceCalculatorSaggingOn::DistanceCalculatorSaggingOn
DistanceCalculatorSaggingOn(const std::string &saggingOptions, LArWheelCalculator *lwc)
Constructor.
Definition: DistanceCalculatorSaggingOn.cxx:27
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
get_generator_info.result
result
Definition: get_generator_info.py:21
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
hist_file_dump.d
d
Definition: hist_file_dump.py:137
CaloSwCorrections.lwc
def lwc(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:215
DMTest::P
P_v1 P
Definition: P.h:23
TRTCalib_cfilter.p1
p1
Definition: TRTCalib_cfilter.py:130
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
TRT::Hit::side
@ side
Definition: HitInfo.h:83
LArWheelCalculator_Impl::DistanceCalculatorSaggingOff::DistanceToTheNeutralFibre
virtual double DistanceToTheNeutralFibre(const CLHEP::Hep3Vector &p, int fan_number) const
Definition: DistanceCalculatorSaggingOff.cxx:29
LArWheelCalculator_Impl::DistanceCalculatorSaggingOn::get_sagging
double get_sagging(const CLHEP::Hep3Vector &P, int fan_number) const
Definition: DistanceCalculatorSaggingOn.cxx:133
TRTCalib_cfilter.p2
p2
Definition: TRTCalib_cfilter.py:131
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
beamspotman.n
n
Definition: beamspotman.py:731
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
LArWheelCalculator_Impl::DistanceCalculatorSaggingOn::AmplitudeOfSurface
virtual double AmplitudeOfSurface(const CLHEP::Hep3Vector &P, int side, int fan_number) const
Definition: DistanceCalculatorSaggingOn.cxx:127
LArWheelCalculator
Definition: LArWheelCalculator.h:60
LArWheelCalculator_Impl::DistanceCalculatorSaggingOn::DistanceToTheNeutralFibre
virtual double DistanceToTheNeutralFibre(const CLHEP::Hep3Vector &p, int fan_number) const
Definition: DistanceCalculatorSaggingOn.cxx:117
LArWheelCalculator_Impl::DistanceCalculatorSaggingOff
Implements details of distance calculation to parts of the LAr endcap without sagging corrections.
Definition: DistanceCalculatorSaggingOff.h:21
LArWheelCalculator_Impl
Definition: LArWheelCalculator.h:43
LArWheelCalculator::m_NumberOfFans
int m_NumberOfFans
Definition: LArWheelCalculator.h:180
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
LArWheelCalculator_Impl::DistanceCalculatorSaggingOff::AmplitudeOfSurface
virtual double AmplitudeOfSurface(const CLHEP::Hep3Vector &P, int side, int fan_number) const
Definition: DistanceCalculatorSaggingOff.cxx:418
LArWheelCalculator::m_HalfWheelThickness
double m_HalfWheelThickness
Definition: LArWheelCalculator.h:169
LArWheelCalculator_Impl::DistanceCalculatorSaggingOn::NearestPointOnNeutralFibre
virtual CLHEP::Hep3Vector NearestPointOnNeutralFibre(const CLHEP::Hep3Vector &p, int fan_number) const
Definition: DistanceCalculatorSaggingOn.cxx:122
LArWheelCalculator_Impl::DistanceCalculatorSaggingOff::NearestPointOnNeutralFibre
virtual CLHEP::Hep3Vector NearestPointOnNeutralFibre(const CLHEP::Hep3Vector &p, int fan_number) const
Definition: DistanceCalculatorSaggingOff.cxx:237
python.SystemOfUnits.mm
int mm
Definition: SystemOfUnits.py:83
a
TList * a
Definition: liststreamerinfos.cxx:10
DEBUG
#define DEBUG
Definition: page_access.h:11
F
#define F(x, y, z)
Definition: MD5.cxx:112
makeTRTBarrelCans.dx
tuple dx
Definition: makeTRTBarrelCans.py:20
LArWheelCalculator::m_isInner
bool m_isInner
Definition: LArWheelCalculator.h:189
DistanceCalculatorSaggingOn.h
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200
LArWheelCalculator_Impl::DistanceCalculatorSaggingOn::init_sagging_parameters
void init_sagging_parameters()
Definition: DistanceCalculatorSaggingOn.cxx:36
LArWheelCalculator_Impl::DistanceCalculatorSaggingOn::m_saggingOptions
std::string m_saggingOptions
Definition: DistanceCalculatorSaggingOn.h:42
TRTCalib_cfilter.p3
p3
Definition: TRTCalib_cfilter.py:132
python.compressB64.c
def c
Definition: compressB64.py:93
LArWheelCalculator_Impl::DistanceCalculatorSaggingOff::lwc
const LArWheelCalculator * lwc() const
Return the calculator:
Definition: DistanceCalculatorSaggingOff.h:38
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
PortableMsgStream.h
TRTCalib_cfilter.p0
p0
Definition: TRTCalib_cfilter.py:129
LArWheelCalculator.h