CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HitRCheck.h
Go to the documentation of this file.
1 #ifndef HitRCheck_H
2 #define HitRCheck_H
3 
9 
10 class HitRCheck GCC11_FINAL : public HitRZCompatibility {
11 public:
12  static constexpr Algo me =rAlgo;
13 
15 
17  HitRCheck(const HitRZConstraint & rz, Margin margin = Margin(0,0))
18  : HitRZCompatibility(me), theRZ(rz), theTolerance(margin) { }
19 
20  virtual bool operator() (const float & r, const float & z) const
21  { return range(z).inside(r); }
22 
23  inline Range range(const float & z) const;
24 
25  virtual HitRCheck * clone() const { return new HitRCheck(*this); }
26 
27  void setTolerance(const Margin & tolerance) { theTolerance = tolerance; }
28 
29 private:
30  HitRZConstraint theRZ;
32 };
33 
34 
35 
36 HitRCheck::Range HitRCheck::range(const float & z) const
37 {
38  constexpr float rBig = 150.; //something above the detector ranges
39  const auto & lineLeft = theRZ.lineLeft();
40  const auto & lineRight = theRZ.lineRight();
41 
42  float rR = lineRight.rAtZ(z);
43  float rL = lineLeft.rAtZ(z);
44  float rMin = (rR<rL) ? rR : rL;
45  float rMax = (rR<rL) ? rL : rR;
46  // in reality all this never happens!
47  float aMin = (rMin>0) ? rMin : rMax;
48  float aMax = (rMin>0) ? rMax : rBig;
49  aMin = (rMax>0) ? aMin : rBig;
50  return Range(aMin-theTolerance.left(),aMax+theTolerance.right());
51 
52  /* check
53  Range v(aMin-theTolerance.left(),aMax+theTolerance.right());
54  Range ori;
55  if (z > 0.) {
56  if (lineRight.cotLine() <= 0.) ori = Range(rBig, 0); //empty
57  else {
58  float rMin = lineRight.rAtZ(z);
59  if (lineLeft.cotLine() <= 0) ori= Range(rMin-theTolerance.left(),rBig);
60  else {
61  float rMax = lineLeft.rAtZ(z);
62  ori = Range(rMin-theTolerance.left(),rMax+theTolerance.right());
63  }
64  }
65  } else {
66  if (lineLeft.cotLine() >= 0.) ori = Range(rBig, 0); //empty
67  else {
68  float rMin = lineLeft.rAtZ(z);
69  if (lineRight.cotLine()>= 0) ori = Range(rMin-theTolerance.left(),rBig);
70  else {
71  float rMax = lineRight.rAtZ(z);
72  ori= Range(rMin-theTolerance.left(),rMax+theTolerance.right());
73  }
74  }
75  }
76 
77  if (ori!=v)
78  std::cout << "v,ori " << v.first << ',' << v.second <<" "
79  << ori.first << ',' << ori.second << std::endl;
80  return ori;
81  */
82 
83  /* original code
84  if (z > 0.) {
85  if (lineRight.cotLine() <= 0.) return Range(rBig, 0); //empty
86  float rMin = lineRight.rAtZ(z);
87  if (lineLeft.cotLine() <= 0) return Range(rMin-theTolerance.left(),rBig);
88  float rMax = lineLeft.rAtZ(z);
89  return Range(rMin-theTolerance.left(),rMax+theTolerance.right());
90  } else {
91  if (lineLeft.cotLine() >= 0.) return Range(rBig, 0); //empty
92  float rMin = lineLeft.rAtZ(z);
93  if (lineRight.cotLine()>= 0) return Range(rMin-theTolerance.left(),rBig);
94  float rMax = lineRight.rAtZ(z);
95  return Range(rMin-theTolerance.left(),rMax+theTolerance.right());
96  }
97  */
98 }
99 #endif
virtual Range range(const float &rORz) const =0
virtual HitRCheck * clone() const
Definition: HitRCheck.h:25
TkTrackingRegionsMargin< float > Margin
Definition: HitRCheck.h:14
void setTolerance(const Margin &tolerance)
Definition: HitRCheck.h:27
float float float z
PixelRecoRange< float > Range
bool inside(const T &value) const
Margin theTolerance
Definition: HitRCheck.h:31
Definition: fakeMenu.h:6
#define constexpr
virtual bool operator()(const float &r, const float &z) const =0
Unlimited (trivial) bounds.