ATLAS Offline Software
Loading...
Searching...
No Matches
LArWheelCalculator_Impl::DistanceCalculatorSaggingOn Class Reference

Implements details of distance calculation to parts of the LAr endcap with sagging taken into account. More...

#include <DistanceCalculatorSaggingOn.h>

Inheritance diagram for LArWheelCalculator_Impl::DistanceCalculatorSaggingOn:
Collaboration diagram for LArWheelCalculator_Impl::DistanceCalculatorSaggingOn:

Public Types

typedef DistanceCalculatorSaggingOff parent

Public Member Functions

 DistanceCalculatorSaggingOn (const std::string &saggingOptions, LArWheelCalculator *lwc)
 Constructor.
const LArWheelCalculatorlwc () const
 Return the calculator:
Geometry methods
virtual double DistanceToTheNeutralFibre (const CLHEP::Hep3Vector &p, int fan_number) const
virtual CLHEP::Hep3Vector NearestPointOnNeutralFibre (const CLHEP::Hep3Vector &p, int fan_number) const
virtual double AmplitudeOfSurface (const CLHEP::Hep3Vector &P, int side, int fan_number) const
Geometry methods
virtual double DistanceToTheNeutralFibre_ref (const CLHEP::Hep3Vector &p, int fan_number) const
virtual CLHEP::Hep3Vector NearestPointOnNeutralFibre_ref (const CLHEP::Hep3Vector &p, int fan_number) const

Private Member Functions

double get_sagging (const CLHEP::Hep3Vector &P, int fan_number) const
void init_sagging_parameters ()

Private Attributes

std::vector< std::vector< double > > m_sagging_parameter
std::string m_saggingOptions
LArWheelCalculatorm_lwc
double m_EndQuarterWave

Detailed Description

Implements details of distance calculation to parts of the LAr endcap with sagging taken into account.

Definition at line 18 of file DistanceCalculatorSaggingOn.h.

Member Typedef Documentation

◆ parent

Constructor & Destructor Documentation

◆ DistanceCalculatorSaggingOn()

LArWheelCalculator_Impl::DistanceCalculatorSaggingOn::DistanceCalculatorSaggingOn ( const std::string & saggingOptions,
LArWheelCalculator * lwc )

Member Function Documentation

◆ AmplitudeOfSurface()

double LArWheelCalculator_Impl::DistanceCalculatorSaggingOn::AmplitudeOfSurface ( const CLHEP::Hep3Vector & P,
int side,
int fan_number ) const
virtual

Reimplemented from LArWheelCalculator_Impl::DistanceCalculatorSaggingOff.

Definition at line 127 of file DistanceCalculatorSaggingOn.cxx.

127 {
128 return parent::AmplitudeOfSurface(p, side, fan_number) - get_sagging(p, fan_number);
129 }
virtual double AmplitudeOfSurface(const CLHEP::Hep3Vector &P, int side, int fan_number) const
double get_sagging(const CLHEP::Hep3Vector &P, int fan_number) const

◆ DistanceToTheNeutralFibre()

double LArWheelCalculator_Impl::DistanceCalculatorSaggingOn::DistanceToTheNeutralFibre ( const CLHEP::Hep3Vector & p,
int fan_number ) const
virtual

Reimplemented from LArWheelCalculator_Impl::DistanceCalculatorSaggingOff.

Definition at line 117 of file DistanceCalculatorSaggingOn.cxx.

117 {
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 }
virtual double DistanceToTheNeutralFibre(const CLHEP::Hep3Vector &p, int fan_number) const

◆ DistanceToTheNeutralFibre_ref()

double LArWheelCalculator_Impl::DistanceCalculatorSaggingOff::DistanceToTheNeutralFibre_ref ( const CLHEP::Hep3Vector & p,
int fan_number ) const
virtualinherited

Definition at line 147 of file DistanceCalculatorSaggingOff.cxx.

149 {
150 double z = P.z() - lwc()->m_StraightStartSection;
151 double x = P.x();
152
153#ifdef LWC_PARAM_ANGLE //old variant
154 const double alpha = lwc()->parameterized_slant_angle(P.y());
155 CxxUtils::sincos scalpha(alpha);
156 double cos_a = scalpha.cs, sin_a = scalpha.sn;
157#else // parameterized sine
158 double cos_a, sin_a;
159 lwc()->m_vsincos_par.eval(P.y(), sin_a, cos_a);
160#endif
161
162 bool sqw = false;
163 if(z > lwc()->m_QuarterWaveLength){
164 if(z < m_EndQuarterWave){ // regular half-waves
165 unsigned int nhwave = (unsigned int)(z / lwc()->m_HalfWaveLength + 0.5);
166 z -= lwc()->m_HalfWaveLength * nhwave;
167 const double straight_part = (lwc()->m_QuarterWaveLength - lwc()->m_FanFoldRadius * sin_a) / cos_a;
168 nhwave &= 1U;
169 if(nhwave == 0) sin_a = - sin_a;
170 double z_prime = z * cos_a + x * sin_a;
171 const double x_prime = z * sin_a - x * cos_a;
172 if(z_prime > straight_part){ // up fold region
173 const double dz = z_prime - straight_part;
174 if(nhwave == 0){
175 const double dx = x_prime + lwc()->m_FanFoldRadius;
176 return sqrt(dz*dz + dx*dx) - lwc()->m_FanFoldRadius;
177 } else {
178 const double dx = x_prime - lwc()->m_FanFoldRadius;
179 return lwc()->m_FanFoldRadius - sqrt(dz*dz + dx*dx);
180 }
181 }
182 z_prime += straight_part;
183 if(z_prime > 0){
184 return x_prime; // straight part of the quarter-wave
185 } else { // low fold region
186 const double &dz = z_prime;
187 if(nhwave == 0){
188 const double dx = x_prime - lwc()->m_FanFoldRadius;
189 return lwc()->m_FanFoldRadius - sqrt(dz*dz + dx*dx);
190 } else {
191 const double dx = x_prime + lwc()->m_FanFoldRadius;
192 return sqrt(dz*dz + dx*dx) - lwc()->m_FanFoldRadius;
193 }
194 }
195 } else { // ending quarter-wave
196 z = lwc()->m_ActiveLength - z;
197 }
198 } else { // starting quarter-wave
199 x = - x;
200 sqw = true;
201 }
202
203 // start and finish quarter-waves
204 const double tan_beta = sin_a/(1.0 + cos_a); //tan(alpha * 0.5);
205 const double local_straight_section = lwc()->m_FanFoldRadius * tan_beta;
206 if(z < - local_straight_section &&
207 ( x < lwc()->m_FanFoldRadius ||
208 x < - lwc()->m_StraightStartSection * z / local_straight_section / tan_beta ))
209 {
210 return sqw? x: (-x);
211 }
212 else {
213 const double z_prime = z * cos_a + x * sin_a;
214 const double x_prime = x * cos_a - z * sin_a;
215 if (z_prime < local_straight_section) { // start fold region
216 const double dz = local_straight_section - z_prime;
217 const double dx = x_prime - lwc()->m_FanFoldRadius;
218 if(sqw) return lwc()->m_FanFoldRadius - sqrt(dz*dz + dx*dx);
219 else return sqrt(dz*dz + dx*dx) - lwc()->m_FanFoldRadius;
220 } else {
221 const double straight_part =
222 (lwc()->m_QuarterWaveLength - lwc()->m_FanFoldRadius * sin_a) / cos_a;
223 if (z_prime <= straight_part) { // straight part of quarter-wave
224 return sqw? x_prime: (-x_prime);
225 } else { // regular fold region of the quarter-wave
226 const double dz = straight_part - z_prime;
227 const double dx = x_prime + lwc()->m_FanFoldRadius;
228 if(sqw) return sqrt(dz*dz + dx*dx) - lwc()->m_FanFoldRadius;
229 else return lwc()->m_FanFoldRadius - sqrt(dz*dz + dx*dx);
230 }
231 }
232 }
233 // ???
234 std::abort();
235 }
static Double_t P(Double_t *tt, Double_t *par)
#define x
#define z
double parameterized_slant_angle(double) const
Calculates wave slant angle using parametrization for current wheel for given distance from calorimet...

◆ get_sagging()

double LArWheelCalculator_Impl::DistanceCalculatorSaggingOn::get_sagging ( const CLHEP::Hep3Vector & P,
int fan_number ) const
private

Definition at line 133 of file DistanceCalculatorSaggingOn.cxx.

133 {
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 }
static Double_t sp
int r
Definition globals.cxx:22
double R(const INavigable4Momentum *p1, const double v_eta, const double v_phi)

◆ init_sagging_parameters()

void LArWheelCalculator_Impl::DistanceCalculatorSaggingOn::init_sagging_parameters ( )
private

Definition at line 36 of file DistanceCalculatorSaggingOn.cxx.

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 {
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 }
#define endmsg
static Double_t a
#define F(x, y, z)
Definition MD5.cxx:112
msgSvc
Provide convenience handles for various services.
Definition StdJOSetup.py:36
MsgStream & msg
Definition testRead.cxx:32

◆ lwc()

const LArWheelCalculator * LArWheelCalculator_Impl::DistanceCalculatorSaggingOff::lwc ( ) const
inlineinherited

Return the calculator:

Definition at line 38 of file DistanceCalculatorSaggingOff.h.

◆ NearestPointOnNeutralFibre()

CLHEP::Hep3Vector LArWheelCalculator_Impl::DistanceCalculatorSaggingOn::NearestPointOnNeutralFibre ( const CLHEP::Hep3Vector & p,
int fan_number ) const
virtual

Reimplemented from LArWheelCalculator_Impl::DistanceCalculatorSaggingOff.

Definition at line 122 of file DistanceCalculatorSaggingOn.cxx.

122 {
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 }
virtual CLHEP::Hep3Vector NearestPointOnNeutralFibre(const CLHEP::Hep3Vector &p, int fan_number) const

◆ NearestPointOnNeutralFibre_ref()

CLHEP::Hep3Vector LArWheelCalculator_Impl::DistanceCalculatorSaggingOff::NearestPointOnNeutralFibre_ref ( const CLHEP::Hep3Vector & p,
int fan_number ) const
virtualinherited

Definition at line 325 of file DistanceCalculatorSaggingOff.cxx.

326 {
327 CLHEP::Hep3Vector result;
328 double z = P.z() - lwc()->m_StraightStartSection;
329 double x = P.x();
330 double y = P.y();
331
332#ifdef LWC_PARAM_ANGLE //old variant
333 const double alpha = lwc()->parameterized_slant_angle(P.y());
334 CxxUtils::sincos scalpha(alpha);
335 double cos_a = scalpha.cs, sin_a = scalpha.sn;
336#else // parameterized sine
337 double cos_a, sin_a;
338 lwc()->m_vsincos_par.eval(P.y(), sin_a, cos_a);
339#endif
340
341 bool sqw = false;
342 if(z > lwc()->m_QuarterWaveLength){
343 if(z < m_EndQuarterWave){ // regular half-waves
344 unsigned int nhwave = (unsigned int)(z / lwc()->m_HalfWaveLength + 0.5);
345 const double zshift = lwc()->m_HalfWaveLength * nhwave;
346 z -= zshift;
347 const double straight_part =
348 (lwc()->m_QuarterWaveLength - lwc()->m_FanFoldRadius * sin_a) / cos_a;
349 nhwave &= 1U;
350 if(nhwave == 0) sin_a = - sin_a;
351 const double z_prime = z * cos_a + x * sin_a;
352 if(z_prime > straight_part){ // up fold
353 const double x_prime = x * cos_a - z * sin_a;
354 const double dz = straight_part - z_prime;
355 double a1 = atan(fabs(dz / (x_prime + lwc()->m_FanFoldRadius)));
356 const double x1 = lwc()->m_FanFoldRadius * (cos(a1) - 1.);
357 const double z1 = straight_part + lwc()->m_FanFoldRadius * sin(a1);
358 result.set(x1*cos_a - z1*sin_a, y, z1*cos_a + z1*sin_a);
359 return result;
360 } else if(z_prime > -straight_part){ // straight part
361 result.set(-z_prime * sin_a, y, z_prime*cos_a + zshift);
362 return result;
363 } else { // low fold
364 const double x_prime = x * cos_a - z * sin_a;
365 const double dz = straight_part + z_prime;
366 double a1 = atan(fabs(dz / (x_prime + lwc()->m_FanFoldRadius)));
367 const double x1 = lwc()->m_FanFoldRadius * (cos(a1) - 1.);
368 const double z1 = straight_part + lwc()->m_FanFoldRadius * sin(a1);
369 result.set(x1*cos_a - z1*sin_a, y, z1*cos_a + z1*sin_a);
370 return result;
371 }
372 } else { // ending quarter-wave
373 z = lwc()->m_ActiveLength - z;
374 }
375 } else { // starting quarter-wave
376 x = - x;
377 sqw = true;
378 }
379
380 // start and finish quarter-waves
381 const double tan_beta = sin_a / (1.0 + cos_a);
382 const double local_straight_section = lwc()->m_FanFoldRadius * tan_beta;
383 if(z < - local_straight_section &&
384 (x < lwc()->m_FanFoldRadius ||
385 x < - lwc()->m_StraightStartSection * z / local_straight_section / tan_beta))
386 {
387 result.set(0., y, z);
388 }
389 else {
390 const double z_prime = z * cos_a + x * sin_a;
391 const double x_prime = x * cos_a - z * sin_a;
392 if(z_prime < local_straight_section) {
393 double a = fabs(atan((local_straight_section - z_prime) / (x_prime - lwc()->m_FanFoldRadius)));
394 result.set(lwc()->m_FanFoldRadius * (1 - cos(a)), y, local_straight_section - lwc()->m_FanFoldRadius * sin(a));
395 } else {
396 double straight_part = (lwc()->m_QuarterWaveLength - lwc()->m_FanFoldRadius * sin_a) / cos_a;
397 if(z_prime <= straight_part) {
398 result.set(0., y, z_prime);
399 } else {
400 double a = fabs(atan((straight_part - z_prime) / (x_prime + lwc()->m_FanFoldRadius)) );
401 result.set(lwc()->m_FanFoldRadius * (cos(a) - 1), y, straight_part + lwc()->m_FanFoldRadius * sin(a));
402 }
403 }
404 result.rotateY(asin(sin_a));
405 }
406 if(sqw) result.setX(-result.x());
407 else result.setZ(lwc()->m_ActiveLength - result.z());
408 result.setZ(result.z() + lwc()->m_StraightStartSection);
409 return result;
410 }
#define y

Member Data Documentation

◆ m_EndQuarterWave

double LArWheelCalculator_Impl::DistanceCalculatorSaggingOff::m_EndQuarterWave
privateinherited

Definition at line 43 of file DistanceCalculatorSaggingOff.h.

◆ m_lwc

LArWheelCalculator* LArWheelCalculator_Impl::DistanceCalculatorSaggingOff::m_lwc
privateinherited

Definition at line 42 of file DistanceCalculatorSaggingOff.h.

◆ m_sagging_parameter

std::vector<std::vector<double> > LArWheelCalculator_Impl::DistanceCalculatorSaggingOn::m_sagging_parameter
private

Definition at line 41 of file DistanceCalculatorSaggingOn.h.

◆ m_saggingOptions

std::string LArWheelCalculator_Impl::DistanceCalculatorSaggingOn::m_saggingOptions
private

Definition at line 42 of file DistanceCalculatorSaggingOn.h.


The documentation for this class was generated from the following files: