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

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

◆ 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){
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
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)
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 314 of file DistanceCalculatorSaggingOff.cxx.

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