ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
DetectorDescription
GeoModel
GeoSpecialShapes
src
LArWheelCalculator_Impl
ModuleFanCalculator.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
#include "
ModuleFanCalculator.h
"
6
7
#include "
GeoSpecialShapes/LArWheelCalculator.h
"
8
9
10
11
#ifdef HARDDEBUG
12
#undef HARDDEBUG
13
#endif
14
15
namespace
LArWheelCalculator_Impl
16
{
17
18
ModuleFanCalculator::ModuleFanCalculator
(
LArWheelCalculator
*
lwc
)
19
:
m_lwc
(
lwc
)
20
{
21
}
22
23
double
ModuleFanCalculator::DistanceToTheNearestFan
(CLHEP::Hep3Vector &p,
int
& out_fan_number)
const
24
{
25
static
const
double
halfpi=
M_PI
/2.0;
26
int
fan_number = int((p.phi() - halfpi -
lwc
()->m_ZeroFanPhi_ForDetNeaFan) /
lwc
()->m_FanStepOnPhi);
27
double
angle
=
lwc
()->
m_FanStepOnPhi
* fan_number +
lwc
()->
m_ZeroFanPhi_ForDetNeaFan
;
28
#ifdef HARDDEBUG
29
printf(
"DistanceToTheNearestFan: initial FN %4d\n"
, fan_number);
30
#endif
31
p.rotateZ(-
angle
);
32
// determine search direction
33
double
d0 =
lwc
()->
DistanceToTheNeutralFibre
(p,
lwc
()->adjust_fan_number(fan_number));
34
double
d1 = d0;
35
int
delta = 1;
36
if
(d0 < 0.) delta = -1;
// search direction has been determined
37
angle
= -
lwc
()->
m_FanStepOnPhi
* delta;
38
do
{
// search:
39
p.rotateZ(
angle
);
40
fan_number += delta;
41
d1 =
lwc
()->
DistanceToTheNeutralFibre
(p,
lwc
()->adjust_fan_number(fan_number));
42
}
while
(d0 * d1 > 0.);
43
// if signs of d1 and d0 are different, the point is between current pair
44
if
(delta > 0) fan_number --;
45
46
int
adj_fan_number = fan_number;
47
if
(adj_fan_number <
lwc
()->m_FirstFan) {
48
p.rotateZ((adj_fan_number -
lwc
()->m_FirstFan) *
lwc
()->m_FanStepOnPhi);
49
adj_fan_number =
lwc
()->
m_FirstFan
;
50
}
else
if
(adj_fan_number >=
lwc
()->m_LastFan) {
51
p.rotateZ((adj_fan_number -
lwc
()->m_LastFan + 1) *
lwc
()->m_FanStepOnPhi);
52
adj_fan_number =
lwc
()->
m_LastFan
- 1;
53
}
54
55
p.rotateZ(-0.5 *
angle
);
56
out_fan_number = adj_fan_number;
57
return
lwc
()->
DistanceToTheNeutralFibre
(p, adj_fan_number);
58
}
59
60
int
ModuleFanCalculator::PhiGapNumberForWheel
(
int
i)
const
{
61
i +=
lwc
()->
m_ZeroGapNumber
;
62
i -=
lwc
()->
m_LastFan
/ 2;
63
if
(i < 0) i +=
lwc
()->
m_NumberOfFans
;
64
if
(i >=
lwc
()->m_NumberOfFans) i -=
lwc
()->
m_NumberOfFans
;
65
return
i;
66
}
67
68
std::pair<int, int>
ModuleFanCalculator::GetPhiGapAndSide
(
const
CLHEP::Hep3Vector &p)
const
69
{
70
// Note: this object was changed from static to local for thread-safety.
71
// If this is found to be too costly we can re-evaluate.
72
CLHEP::Hep3Vector p1 = p;
73
static
const
double
halfpi=
M_PI
/2.0;
74
int
fan_number = int((p.phi() - halfpi -
lwc
()->m_ZeroFanPhi) /
lwc
()->m_FanStepOnPhi);
75
76
double
angle
=
lwc
()->
m_FanStepOnPhi
* fan_number +
lwc
()->
m_ZeroFanPhi
;
77
p1.rotateZ(-
angle
);
78
79
double
d0 =
lwc
()->
DistanceToTheNeutralFibre
(p1,
lwc
()->adjust_fan_number(fan_number));
80
double
d1 = d0;
81
82
int
delta = 1;
83
if
(d0 < 0.) delta = -1;
84
angle
= -
lwc
()->
m_FanStepOnPhi
* delta;
85
do
{
86
p1.rotateZ(
angle
);
87
fan_number += delta;
88
d1 =
lwc
()->
DistanceToTheNeutralFibre
(p1,
lwc
()->adjust_fan_number(fan_number));
89
}
while
(d0 * d1 > 0.);
90
if
(delta > 0) fan_number --;
91
if
(!
lwc
()->m_isElectrode) fan_number ++;
92
93
int
adj_fan_number = fan_number;
94
if
(adj_fan_number <
lwc
()->m_FirstFan) adj_fan_number =
lwc
()->
m_FirstFan
- 1;
95
else
if
(adj_fan_number >
lwc
()->m_LastFan) adj_fan_number =
lwc
()->
m_LastFan
;
96
97
p1.rotateZ(-0.5 *
angle
);
98
double
dd =
lwc
()->
DistanceToTheNeutralFibre
(p1, adj_fan_number);
99
int
side = dd < 0.? -1: 1;
100
#ifdef HARDDEBUG
101
printf(
"GetPhiGapAndSide: MFN %4d\n"
, adj_fan_number);
102
#endif
103
return
std::pair<int, int>(adj_fan_number, side);
104
}
105
106
}
M_PI
#define M_PI
Definition
ActiveFraction.h:14
LArWheelCalculator.h
ModuleFanCalculator.h
angle
double angle(const GeoTrf::Vector2D &a, const GeoTrf::Vector2D &b)
Definition
TRTDetectorFactory_Full.cxx:71
LArWheelCalculator_Impl::ModuleFanCalculator::m_lwc
LArWheelCalculator * m_lwc
Definition
ModuleFanCalculator.h:29
LArWheelCalculator_Impl::ModuleFanCalculator::lwc
const LArWheelCalculator * lwc() const
Definition
ModuleFanCalculator.h:26
LArWheelCalculator_Impl::ModuleFanCalculator::GetPhiGapAndSide
virtual std::pair< int, int > GetPhiGapAndSide(const CLHEP::Hep3Vector &p) const
Definition
ModuleFanCalculator.cxx:68
LArWheelCalculator_Impl::ModuleFanCalculator::ModuleFanCalculator
ModuleFanCalculator(LArWheelCalculator *lwc)
Definition
ModuleFanCalculator.cxx:18
LArWheelCalculator_Impl::ModuleFanCalculator::PhiGapNumberForWheel
virtual int PhiGapNumberForWheel(int i) const
Definition
ModuleFanCalculator.cxx:60
LArWheelCalculator_Impl::ModuleFanCalculator::DistanceToTheNearestFan
virtual double DistanceToTheNearestFan(CLHEP::Hep3Vector &p, int &out_fan_number) const
Definition
ModuleFanCalculator.cxx:23
LArWheelCalculator
This class separates some of the geometry details of the LAr endcap.
Definition
LArWheelCalculator.h:57
LArWheelCalculator::m_NumberOfFans
int m_NumberOfFans
Definition
LArWheelCalculator.h:177
LArWheelCalculator::m_LastFan
int m_LastFan
Definition
LArWheelCalculator.h:182
LArWheelCalculator::m_FirstFan
int m_FirstFan
Definition
LArWheelCalculator.h:181
LArWheelCalculator::m_ZeroGapNumber
int m_ZeroGapNumber
Definition
LArWheelCalculator.h:180
LArWheelCalculator::DistanceToTheNeutralFibre
double DistanceToTheNeutralFibre(const CLHEP::Hep3Vector &p, int fan_number) const
Calculates aproximate, probably underestimate, distance to the neutral fibre of the vertical fan.
Definition
LArWheelCalculatorGeometry.cxx:108
LArWheelCalculator::m_FanStepOnPhi
double m_FanStepOnPhi
Definition
LArWheelCalculator.h:174
LArWheelCalculator::m_ZeroFanPhi
double m_ZeroFanPhi
Definition
LArWheelCalculator.h:172
LArWheelCalculator::m_ZeroFanPhi_ForDetNeaFan
double m_ZeroFanPhi_ForDetNeaFan
Definition
LArWheelCalculator.h:173
LArWheelCalculator_Impl
Definition
LArWheelCalculator.h:40
Generated on
for ATLAS Offline Software by
1.17.0