CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EtaDepResElement.cc
Go to the documentation of this file.
1 //
2 //
3 //
4 // File : src/EtaDepResolution.cc
5 // Author : Haryo Sumowidagdo <Suharyo.Sumowidagdo@cern.ch>
6 // Purpose: Hold on to an element eta-dependent resolution.
7 //
8 
26 #include <sstream>
27 #include <stdexcept>
29 
30 namespace hitfit {
31 
32 EtaDepResElement::EtaDepResElement(double eta1,double eta2,
33  const Vector_Resolution& res):
34  _Vector_Resolution(res)
35 {
36 
37  SetEta(eta1,eta2);
38 
39 }
40 
41 
42 EtaDepResElement::EtaDepResElement(double eta1,double eta2,
43  std::string res):
44  _Vector_Resolution(res)
45 {
46 
47  SetEta(eta1,eta2);
48 
49 }
50 
51 
52 EtaDepResElement::EtaDepResElement(double eta1,double eta2,
53  const Resolution& p_res,
54  const Resolution& eta_res,
55  const Resolution& phi_res,
56  bool use_et):
57  _Vector_Resolution(p_res,eta_res,phi_res,use_et)
58 {
59 
60  SetEta(eta1,eta2);
61 
62 }
63 
64 
66 {
67 }
68 
69 
70 void
71 EtaDepResElement::SetEta(double eta1,double eta2)
72 {
73 
74  if (fabs(eta1 - eta2) < (1.0/double(InverseEtaPrecision))) {
75  throw
76  std::runtime_error("EtaDepResElement::equal EtaMin and EtaMax");
77  }
78 
79  if (eta1 < eta2) {
80  _EtaMin = eta1 ;
81  _EtaMax = eta2 ;
82  } else {
83  _EtaMin = eta2 ;
84  _EtaMax = eta1 ;
85  }
86 
87 }
88 
103 {
104 
105  if (a.IsOverlap(b)) { return false;}
106  return !(a._EtaMax > b._EtaMin);
107 
108 }
109 
110 
111 const double
113 {
114 
115  return _EtaMin;
116 
117 }
118 
119 
120 const double
122 {
123 
124  return _EtaMax;
125 
126 }
127 
128 
129 bool
131 {
132 
133  return (IsInInterval(e._EtaMin) || IsInInterval(e._EtaMax));
134 
135 }
136 
137 
138 bool
140 {
141 
142  return !(IsOverlap(e));
143 
144 }
145 
146 
147 bool
149 {
150 
151  return ((_EtaMin < eta) && (eta < _EtaMax));
152 
153 }
154 
155 
156 bool
157 EtaDepResElement::IsOnEdge(const double& eta) const
158 {
159 
160  bool nearEtaMin = fabs(eta - _EtaMin) < (1.0/double(InverseEtaPrecision));
161  bool nearEtaMax = fabs(eta - _EtaMax) < (1.0/double(InverseEtaPrecision));
162  return nearEtaMin || nearEtaMax ;
163 
164 }
165 
166 
167 bool
169 {
170 
171  return (e.IsOnEdge(_EtaMin) || e.IsOnEdge(_EtaMax));
172 
173 }
174 
175 
176 const Vector_Resolution
178 {
179 
180  return _Vector_Resolution;
181 
182 }
183 
184 
185 std::ostream& operator<< (std::ostream& s, const EtaDepResElement& e)
186 {
187 
188  s << "(" << e._EtaMin << " to " << e._EtaMax << ")" << " / " << e.GetResolution ();
189  return s ;
190 
191 }
192 
193 } // namespace hitfit
bool IsOnEdge(const double &eta) const
Check if an value is at the edge/boundary of this instance&#39;s valid range.
const Vector_Resolution GetResolution() const
Access the resolution.
Calculate and represent resolution for a physical quantity.
Definition: Resolution.h:102
Represent a resolution and an range in which the resolution is valid.
static const int InverseEtaPrecision
Constant, the inverse of precision expected.
bool operator<(const EtaDepResElement &a, const EtaDepResElement &b)
Comparison operator, compare two EtaDepResElement instances based on their respective valid ranges...
Vector_Resolution _Vector_Resolution
EtaDepResElement(double eta1, double eta2, const Vector_Resolution &res)
Construct an instance of EtaDepResElement from the lower limit, upper limit, and the resolution...
bool IsOverlap(const EtaDepResElement &e) const
Check if this instance has overlapping range with another instance of EtaDepResElement.
double b
Definition: hdecay.h:120
void SetEta(double eta1, double eta2)
bool IsNotOverlap(const EtaDepResElement &e) const
Check if this instance does not have overlapping range with another instance.
double a
Definition: hdecay.h:121
std::ostream & operator<<(std::ostream &s, const Constraint_Intermed &ci)
Output stream operator, print the content of this Constraint_Intermed to an output stream...
bool IsInInterval(const double &eta) const
Check if an value is within this instance&#39;s range.
const double EtaMin() const
Return the lower limit of valid range.
Hold on to an element of -dependent resolution object, namely a resolution and range in which the r...
Calculate and represent resolution for a vector of , pseudorapidity , and azimuthal angle ...
const double EtaMax() const
Return the lower limit of valid range.