5#ifndef LARWHEELCALCULATOR_IMPL_WHEELFANCALCULATOR_H
6#define LARWHEELCALCULATOR_IMPL_WHEELFANCALCULATOR_H
22 template <
typename SaggingType>
31 return lwc->DistanceToTheNeutralFibre(p, lwc->adjust_fan_number(fan_number));
40 return lwc->DistanceToTheNeutralFibre(p, -531135);
50 template <
typename SaggingType, FanSearchDirection_t dir >
54 template <FanSearchDirection_t dir >
58 static inline void next(
int &) {}
67 static inline void next(
int &fan_number) {
70 static inline void adjust(
int &fan_number) {
79 static inline void next(
int &fan_number) {
85 template <FanSearchDirection_t dir>
92 template <
typename T >
93 static inline bool pred(T val) {
102 template <
typename T >
103 static inline bool pred(T val) {
109 template <
typename SaggingType, FanSearchDirection_t dir,
class NFDistance >
111 const double angle, CLHEP::Hep3Vector &p)
116 double d1 = NFDistance::calculate(lwc, fan_number, p);
125 d1 = NFDistance::calculate(lwc, fan_number, p);
138 template <
typename SaggingType>
152 static const double halfpi=
M_PI/2.0;
153 int fan_number = int((p.phi() - halfpi -
lwc()->m_ZeroFanPhi_ForDetNeaFan) /
lwc()->m_FanStepOnPhi);
156 printf(
"DistanceToTheNearestFan: initial FN %4d\n", fan_number);
162 const double d0 = NFDistance::calculate(
lwc(), fan_number, p);
166 const int delta = (d0 < 0.) ? -1 : 1;
196 p.rotateZ(-0.5 * step_angle);
198 printf(
"DistanceToTheNearestFan: final FN %4d\n", fan_number);
212 static const double halfpi=
M_PI/2.0;
213 CLHEP::Hep3Vector p1 = p;
215 int fan_number = int((p.phi() - halfpi -
lwc()->m_ZeroFanPhi) /
lwc()->m_FanStepOnPhi);
221 const double d0 = NFDistance::calculate(
lwc(), fan_number, p1);
227 const int delta = (d0 < 0.) ? -1 : 1;
232 p1.rotateZ(step_angle);
234 d1 = NFDistance::calculate(
lwc(), fan_number, p1);
237 }
while(d0 * d1 > 0.);
239 if(delta > 0) fan_number --;
240 if(!
lwc()->m_isElectrode) fan_number ++;
242 p1.rotateZ(-0.5 * step_angle);
246 int side = dd < 0.? -1: 1;
248 printf(
"GetPhiGapAndSide: MFN %4d\n", a_fan_number);
250 return std::pair<int, int>(a_fan_number, side);
double angle(const GeoTrf::Vector2D &a, const GeoTrf::Vector2D &b)
static double calculate(const LArWheelCalculator *lwc, int, CLHEP::Hep3Vector &p)
static double calculate(const LArWheelCalculator *lwc, int fan_number, CLHEP::Hep3Vector &p)
Abstract interface for fan calculator classes that handle distance calculation to parts of the LAr en...
static void adjust(int &)
static void next(int &fan_number)
static void adjust(int &)
static void adjust(int &fan_number)
static void next(int &fan_number)
virtual std::pair< int, int > GetPhiGapAndSide(const CLHEP::Hep3Vector &p) const
virtual double DistanceToTheNearestFan(CLHEP::Hep3Vector &p, int &out_fan_number) const
WheelFanCalculator(LArWheelCalculator *lwc)
LArWheelCalculator * m_lwc
virtual int PhiGapNumberForWheel(int i) const
const LArWheelCalculator * lwc() const
This class separates some of the geometry details of the LAr endcap.
int adjust_fan_number(int fan_number) const
double DistanceToTheNeutralFibre(const CLHEP::Hep3Vector &p, int fan_number) const
Calculates aproximate, probably underestimate, distance to the neutral fibre of the vertical fan.
double m_ZeroFanPhi_ForDetNeaFan
void rotate_to_nearest_fan(const LArWheelCalculator *lwc, int &fan_number, const double angle, CLHEP::Hep3Vector &p)