ATLAS Offline Software
Loading...
Searching...
No Matches
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
22using GeoModelKernelUnits::mm;
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}
#define endmsg
static Double_t sp
static Double_t a
static Double_t P(Double_t *tt, Double_t *par)
#define F(x, y, z)
Definition MD5.cxx:112
virtual double DistanceToTheNeutralFibre(const CLHEP::Hep3Vector &p, int fan_number) const
virtual CLHEP::Hep3Vector NearestPointOnNeutralFibre(const CLHEP::Hep3Vector &p, int fan_number) const
const LArWheelCalculator * lwc() const
Return the calculator:
virtual double AmplitudeOfSurface(const CLHEP::Hep3Vector &P, int side, int fan_number) const
DistanceCalculatorSaggingOn(const std::string &saggingOptions, LArWheelCalculator *lwc)
Constructor.
virtual double DistanceToTheNeutralFibre(const CLHEP::Hep3Vector &p, int fan_number) const
virtual CLHEP::Hep3Vector NearestPointOnNeutralFibre(const CLHEP::Hep3Vector &p, int fan_number) const
double get_sagging(const CLHEP::Hep3Vector &P, int fan_number) const
virtual double AmplitudeOfSurface(const CLHEP::Hep3Vector &P, int side, int fan_number) const
This class separates some of the geometry details of the LAr endcap.
int r
Definition globals.cxx:22
MsgStream & msg
Definition testRead.cxx:32