ATLAS Offline Software
DistanceCalculatorSaggingOn.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 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  ISvcLocator* svcLocator = Gaudi::svcLocator();
42  IMessageSvc* msgSvc;
43  StatusCode status = svcLocator->service("MessageSvc", msgSvc);
44  if(status.isFailure()){
45  throw std::runtime_error("LArWheelCalculator constructor: \
46  cannot initialze message service");
47  }
48  MsgStream msg(msgSvc, "LArWheelCalculator_Impl::DistanceCalculatorSaggingOn");
49 #else
50  PortableMsgStream msg("LArWheelCalculator_Impl::DistanceCalculatorSaggingOn");
51 #endif
52  std::string sagging_opt_value = m_saggingOptions;
53  m_sagging_parameter.resize (lwc()->m_NumberOfFans, std::vector<double> (5, 0.));
54  // if(m_SaggingOn) {
55  if(sagging_opt_value.substr(0, 4) == "file"){
56  std::string sag_file = sagging_opt_value.substr(5);
57  msg << MSG::DEBUG
58  << "geting sagging parameters from file "
59  << sag_file << " ..." << endmsg;
60  FILE *F = fopen(sag_file.c_str(), "r");
61  if(F == 0){
62  msg << MSG::FATAL
63  << "cannot open EMEC sagging parameters file "
64  << sag_file
65  << endmsg;
66  throw std::runtime_error("LArWheelCalculator: read sagging parameters from file");
67  }
68  int s, w, t, n;
69  double p0, p1, p2, p3, p4;
70  while(!feof(F) &&
71  fscanf(F, "%80d %80d %80d %80d %80le %80le %80le %80le %80le",
72  &s, &w, &t, &n, &p0, &p1, &p2, &p3, &p4) == 9)
73  {
74  if(s == lwc()->m_AtlasZside &&
75  ((w == 0 && lwc()->m_isInner) || (w == 1 && !lwc()->m_isInner)) &&
76  ((t == 0 && !lwc()->m_isElectrode) || (t == 1 && lwc()->m_isElectrode)) &&
77  (n >= 0 && n < lwc()->m_NumberOfFans))
78  {
79  m_sagging_parameter[n][0] = p0;
80  m_sagging_parameter[n][1] = p1;
81  m_sagging_parameter[n][2] = p2;
82  m_sagging_parameter[n][3] = p3;
83  m_sagging_parameter[n][4] = p4;
84  msg << MSG::VERBOSE
85  << "sagging for " << s << " " << w << " " << t
86  << " " << n << ": " << p0 << " " << p1 << " "
87  << p2 << " " << p3 << endmsg;
88  }
89  }
90  fclose(F);
91  } else {
92  double a, b, c, d;
93  if(sscanf(sagging_opt_value.c_str(), "%80le %80le %80le %80le", &a, &b, &c, &d) != 4){
94  msg << MSG::ERROR
95  << "wrong value(s) "
96  << " for EMEC sagging parameters: "
97  << sagging_opt_value << ", defaults are used" << endmsg;
98  } else {
99  for(int j = 0; j < lwc()->m_NumberOfFans; j ++){
100  if(lwc()->m_isInner){
101  m_sagging_parameter[j][1] = a;
102  m_sagging_parameter[j][0] = b * mm;
103  } else {
104  m_sagging_parameter[j][1] = c;
105  m_sagging_parameter[j][0] = d * mm;
106  }
107  }
108  }
109  }
110  // }
111  msg << MSG::INFO << "Sagging parameters : " << m_sagging_parameter[0][0] << " " << m_sagging_parameter[0][1] << endmsg
112  << "Sagging parameters : " << m_sagging_parameter[1][0] << " " << m_sagging_parameter[1][1] << endmsg;
113  }
114 
115  // Represents aproximate, probably underestimate, distance to the
116  // neutral fibre of the vertical fan. Sign of return value means
117  // side of the fan; negative - lower phi.
118  //
119  // Uses m_fan_number to compute sagging.
120  double DistanceCalculatorSaggingOn::DistanceToTheNeutralFibre(const CLHEP::Hep3Vector &p, int fan_number) const {
121  CLHEP::Hep3Vector sagging_corrected( p.x()+get_sagging(p, fan_number), p.y(), p.z() );
122  return parent::DistanceToTheNeutralFibre(sagging_corrected, fan_number);
123  }
124 
125  CLHEP::Hep3Vector DistanceCalculatorSaggingOn::NearestPointOnNeutralFibre(const CLHEP::Hep3Vector &p, int fan_number) const {
126  CLHEP::Hep3Vector sagging_corrected( p.x()+get_sagging(p, fan_number), p.y(), p.z() );
127  return parent::NearestPointOnNeutralFibre(sagging_corrected, fan_number);
128  }
129 
130  double DistanceCalculatorSaggingOn::AmplitudeOfSurface(const CLHEP::Hep3Vector& p, int side, int fan_number) const {
131  return parent::AmplitudeOfSurface(p, side, fan_number) - get_sagging(p, fan_number);
132  }
133 
134 
135  // the function uses m_fan_number for phi-dependent sagging computation
136  double DistanceCalculatorSaggingOn::get_sagging(const CLHEP::Hep3Vector &P, int fan_number) const {
137 #ifdef HARDDEBUG
138  std::cout << "get_sagging: MFN = " << fan_number << std::endl;
139 #endif
140  double dx = P.z() / lwc()->m_HalfWheelThickness - 1.;
141  dx *= dx;
142  dx = 1. - dx;
143  //dx *= SaggingAmplitude * sin(FanStepOnPhi * m_fan_number + ZeroFanPhi);
144  //int n = m_fan_number;
145  //if(n < 0) n += m_NumberOfFans;
146  //n += m_ZeroGapNumber;
147  //if(n >= m_NumberOfFans) n -= m_NumberOfFans;
148  //const std::vector<double>& sp = m_sagging_parameter[n];
149  const std::vector<double>& sp = m_sagging_parameter[fan_number];
150  double R = P.r() / mm;
151  double r = R;
152  double result = sp[0];
153  result += R * sp[1];
154  R *= r;
155  result += R * sp[2];
156  R *= r;
157  result += R * sp[3];
158  R *= r;
159  result += R * sp[4];
160 
161 #ifdef HARDDEBUG
162  /*printf("get_sagging: (%6.3f, %6.3f, %6.3f) %6.3f; MFN %4d;"
163  "n %3d; sp %6.4f %6.4f; dx %6.3f; %.6f\n", P.x()/mm, P.y()/mm, P.z()/mm,
164  r, m_fan_number, n, sp[0], sp[1], dx, result*dx);*/
165  printf("get_sagging: (%6.3f, %6.3f, %6.3f) %6.3f;"
166  " sp %6.4f %6.4f; dx %6.3f; %.6f\n", P.x()/mm, P.y()/mm, P.z()/mm,
167  r, sp[0], sp[1], dx, result*dx);
168 #endif //HARDDEBUG
169 
170  return result * dx;
171  }
172 
173 }
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.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
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
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ParticleJetTools::p3
Amg::Vector3D p3(const xAOD::TruthVertex *p)
Definition: ParticleJetLabelCommon.cxx:55
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:136
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
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
LArWheelCalculator_Impl::DistanceCalculatorSaggingOn::AmplitudeOfSurface
virtual double AmplitudeOfSurface(const CLHEP::Hep3Vector &P, int side, int fan_number) const
Definition: DistanceCalculatorSaggingOn.cxx:130
LArWheelCalculator
Definition: LArWheelCalculator.h:58
LArWheelCalculator_Impl::DistanceCalculatorSaggingOn::DistanceToTheNeutralFibre
virtual double DistanceToTheNeutralFibre(const CLHEP::Hep3Vector &p, int fan_number) const
Definition: DistanceCalculatorSaggingOn.cxx:120
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:41
LArWheelCalculator::m_NumberOfFans
int m_NumberOfFans
Definition: LArWheelCalculator.h:176
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:165
LArWheelCalculator_Impl::DistanceCalculatorSaggingOn::NearestPointOnNeutralFibre
virtual CLHEP::Hep3Vector NearestPointOnNeutralFibre(const CLHEP::Hep3Vector &p, int fan_number) const
Definition: DistanceCalculatorSaggingOn.cxx:125
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
merge.status
status
Definition: merge.py:17
LArWheelCalculator::m_isInner
bool m_isInner
Definition: LArWheelCalculator.h:185
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
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
LArWheelCalculator.h