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 28 of file DistanceCalculatorSaggingOff.cxx.

29 {
30 assert(P.y() > 0.);
31 double distance = 0.;
32 double z = P.z() - lwc()->m_StraightStartSection;
33 double x = P.x();
34
35#ifdef LWC_PARAM_ANGLE //old variant
36 const double alpha = lwc()->parameterized_slant_angle(P.y());
37 //double cos_a, sin_a;
38 //::sincos(alpha, &sin_a, &cos_a);
39 CxxUtils::sincos scalpha(alpha);
40 const double cos_a = scalpha.cs, sin_a = scalpha.sn;
41#else // parameterized sine
42 double cos_a, sin_a;
43 lwc()->m_vsincos_par.eval(P.y(), sin_a, cos_a);
44#endif
45 // determination of the nearest quarter-wave number
46 int nqwave = (z < 0.) ? 0 : int(z / lwc()->m_QuarterWaveLength);
47 //if(z < 0.) nqwave = 0;
48 //else nqwave = int(z / lwc()->m_QuarterWaveLength);
49
50 bool begin_qw = false;
51 if((nqwave % 2) != 0){
52 nqwave ++;
53 begin_qw = true;
54 }
55
56 nqwave /= 2;
57
58 // now nqwave is not the number of quarter-wave but the number of half-wave
59 // half-waves with last and zero numbers are not really half-waves but start
60 // and finish quarter-waves
61 // It means that half-wave number 1 begins after starting quarter-wave
62 if(nqwave != 0 && nqwave != lwc()->m_NumberOfHalfWaves){ // regular half-waves
63 z -= nqwave * lwc()->m_HalfWaveLength;
64 // there are some symmetries, so use them
65 if((nqwave % 2) == 0) x = -x;
66 if(begin_qw){
67 z = -z;
68 x = -x;
69 }
70 // certain situation: rising slope of wave, z is positive
71 // rotate to prime-coordinate system (see description)
72 const double z_prime = z * cos_a + x * sin_a;
73 const double x_prime = x * cos_a - z * sin_a;
74 const double straight_part = (lwc()->m_QuarterWaveLength - lwc()->m_FanFoldRadius * sin_a) / cos_a;
75 if(z_prime > straight_part){// fold region
76 const double dz = straight_part - z_prime;
77 const double dx = x_prime + lwc()->m_FanFoldRadius;
78 distance = sqrt(dz*dz + dx*dx) - lwc()->m_FanFoldRadius;
79 } else if(z_prime > -straight_part){
80 distance = x_prime; // straight part of the quarter-wave
81 } else {// fold region
82 const double dz = straight_part + z_prime;
83 const double dx = x_prime - lwc()->m_FanFoldRadius;
84 distance = lwc()->m_FanFoldRadius - sqrt(dz*dz + dx*dx);
85 }
86 // set correct sign for result
87 if(!begin_qw) distance = -distance;
88 if((nqwave % 2) == 0) distance = -distance;
89
90 } else { // start and finish quarter-waves
91 if(nqwave == 0) { // start quarter-wave
92 x = - x;
93 } else { // finish quarter-wave
94 z = lwc()->m_ActiveLength - z;
95 }
96
97 const double tan_beta = sin_a/(1.0 + cos_a); //tan(alpha * 0.5);
98 const double local_straight_section = lwc()->m_FanFoldRadius * tan_beta;
99 if( z < - local_straight_section &&
100 ( x < lwc()->m_FanFoldRadius ||
101 x < - lwc()->m_StraightStartSection * z / local_straight_section / tan_beta ) )
102 {
103 distance = - x;
104 }
105 else {
106 const double z_prime = z * cos_a + x * sin_a;
107 const double x_prime = x * cos_a - z * sin_a;
108 if (z_prime < local_straight_section) { // start fold region
109 const double dz = local_straight_section - z_prime;
110 const double dx = x_prime - lwc()->m_FanFoldRadius;
111 distance = sqrt(dz*dz + dx*dx) - lwc()->m_FanFoldRadius;
112 } else {
113 const double straight_part = (lwc()->m_QuarterWaveLength - lwc()->m_FanFoldRadius * sin_a) / cos_a;
114 if (z_prime <= straight_part) { // straight part of quarter-wave
115 distance = - x_prime;
116 } else { // regular fold region of the quarter-wave
117 const double dz = straight_part - z_prime;
118 const double dx = x_prime + lwc()->m_FanFoldRadius;
119 distance = lwc()->m_FanFoldRadius - sqrt(dz*dz + dx*dx);
120 }
121 }
122 }
123 // set correct sign
124 if (nqwave == 0) distance = -distance;
125 }
126#ifdef HARDDEBUG
127 double dd = DistanceToTheNeutralFibre_ref(P);
128 if(fabs(dd - distance) > 0.000001){
129 //static int cnt = 0;
130 std::cout << "DTNF MISMATCH " << this << " " << P << " "
131 << dd << " vs " << distance << std::endl;
132 //cnt ++;
133 //if(cnt > 100) exit(0);
134 }
135#endif
136 return distance;
137 }
static Double_t P(Double_t *tt, Double_t *par)
#define x
#define z
virtual double DistanceToTheNeutralFibre_ref(const CLHEP::Hep3Vector &p, int fan_number) const
double parameterized_slant_angle(double) const
Calculates wave slant angle using parametrization for current wheel for given distance from calorimet...
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space

◆ 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
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 317 of file DistanceCalculatorSaggingOff.cxx.

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