ATLAS Offline Software
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 
8 
9 
10 
11 #ifdef HARDDEBUG
12 #undef HARDDEBUG
13 #endif
14 
16 {
17 
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 
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 }
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
CaloSwCorrections.lwc
def lwc(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:215
LArWheelCalculator_Impl::ModuleFanCalculator::ModuleFanCalculator
ModuleFanCalculator(LArWheelCalculator *lwc)
Definition: ModuleFanCalculator.cxx:18
M_PI
#define M_PI
Definition: ActiveFraction.h:11
dq_defect_virtual_defect_validation.d1
d1
Definition: dq_defect_virtual_defect_validation.py:79
LArWheelCalculator_Impl::ModuleFanCalculator::GetPhiGapAndSide
virtual std::pair< int, int > GetPhiGapAndSide(const CLHEP::Hep3Vector &p) const
Definition: ModuleFanCalculator.cxx:68
LArWheelCalculator_Impl::ModuleFanCalculator::lwc
const LArWheelCalculator * lwc() const
Definition: ModuleFanCalculator.h:26
TRT::Hit::side
@ side
Definition: HitInfo.h:83
LArWheelCalculator::m_ZeroFanPhi_ForDetNeaFan
double m_ZeroFanPhi_ForDetNeaFan
Definition: LArWheelCalculator.h:172
LArWheelCalculator_Impl::ModuleFanCalculator::PhiGapNumberForWheel
virtual int PhiGapNumberForWheel(int i) const
Definition: ModuleFanCalculator.cxx:60
lumiFormat.i
int i
Definition: lumiFormat.py:92
angle
double angle(const GeoTrf::Vector2D &a, const GeoTrf::Vector2D &b)
Definition: TRTDetectorFactory_Full.cxx:73
TRT::Track::d0
@ d0
Definition: InnerDetector/InDetCalibEvent/TRT_CalibData/TRT_CalibData/TrackInfo.h:62
LArWheelCalculator
Definition: LArWheelCalculator.h:58
LArWheelCalculator_Impl::ModuleFanCalculator::DistanceToTheNearestFan
virtual double DistanceToTheNearestFan(CLHEP::Hep3Vector &p, int &out_fan_number) const
Definition: ModuleFanCalculator.cxx:23
LArWheelCalculator_Impl
Definition: LArWheelCalculator.h:41
LArWheelCalculator::m_NumberOfFans
int m_NumberOfFans
Definition: LArWheelCalculator.h:176
LArWheelCalculator::m_ZeroFanPhi
double m_ZeroFanPhi
Definition: LArWheelCalculator.h:171
LArWheelCalculator::m_FirstFan
int m_FirstFan
Definition: LArWheelCalculator.h:180
LArWheelCalculator::m_FanStepOnPhi
double m_FanStepOnPhi
Definition: LArWheelCalculator.h:173
library_scraper.dd
list dd
Definition: library_scraper.py:46
LArWheelCalculator::m_ZeroGapNumber
int m_ZeroGapNumber
Definition: LArWheelCalculator.h:179
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_LastFan
int m_LastFan
Definition: LArWheelCalculator.h:181
python.PhysicalConstants.halfpi
float halfpi
Definition: PhysicalConstants.py:51
LArWheelCalculator.h
ModuleFanCalculator.h