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 // $Id: EtaDepResElement.cc,v 1.1 2011/05/26 09:46:59 mseidel Exp $
3 //
4 //
5 // File : src/EtaDepResolution.cc
6 // Author : Haryo Sumowidagdo <Suharyo.Sumowidagdo@cern.ch>
7 // Purpose: Hold on to an element eta-dependent resolution.
8 //
9 
27 #include <sstream>
28 #include <stdexcept>
30 
31 namespace hitfit {
32 
33 EtaDepResElement::EtaDepResElement(double eta1,double eta2,
34  const Vector_Resolution& res):
35  _Vector_Resolution(res)
36 {
37 
38  SetEta(eta1,eta2);
39 
40 }
41 
42 
43 EtaDepResElement::EtaDepResElement(double eta1,double eta2,
44  std::string res):
45  _Vector_Resolution(res)
46 {
47 
48  SetEta(eta1,eta2);
49 
50 }
51 
52 
53 EtaDepResElement::EtaDepResElement(double eta1,double eta2,
54  const Resolution& p_res,
55  const Resolution& eta_res,
56  const Resolution& phi_res,
57  bool use_et):
58  _Vector_Resolution(p_res,eta_res,phi_res,use_et)
59 {
60 
61  SetEta(eta1,eta2);
62 
63 }
64 
65 
67 {
68 }
69 
70 
71 void
72 EtaDepResElement::SetEta(double eta1,double eta2)
73 {
74 
75  if (fabs(eta1 - eta2) < (1.0/double(InverseEtaPrecision))) {
76  throw
77  std::runtime_error("EtaDepResElement::equal EtaMin and EtaMax");
78  }
79 
80  if (eta1 < eta2) {
81  _EtaMin = eta1 ;
82  _EtaMax = eta2 ;
83  } else {
84  _EtaMin = eta2 ;
85  _EtaMax = eta1 ;
86  }
87 
88 }
89 
104 {
105 
106  if (a.IsOverlap(b)) { return false;}
107  return !(a._EtaMax > b._EtaMin);
108 
109 }
110 
111 
112 const double
114 {
115 
116  return _EtaMin;
117 
118 }
119 
120 
121 const double
123 {
124 
125  return _EtaMax;
126 
127 }
128 
129 
130 bool
132 {
133 
134  return (IsInInterval(e._EtaMin) || IsInInterval(e._EtaMax));
135 
136 }
137 
138 
139 bool
141 {
142 
143  return !(IsOverlap(e));
144 
145 }
146 
147 
148 bool
150 {
151 
152  return ((_EtaMin < eta) && (eta < _EtaMax));
153 
154 }
155 
156 
157 bool
158 EtaDepResElement::IsOnEdge(const double& eta) const
159 {
160 
161  bool nearEtaMin = fabs(eta - _EtaMin) < (1.0/double(InverseEtaPrecision));
162  bool nearEtaMax = fabs(eta - _EtaMax) < (1.0/double(InverseEtaPrecision));
163  return nearEtaMin || nearEtaMax ;
164 
165 }
166 
167 
168 bool
170 {
171 
172  return (e.IsOnEdge(_EtaMin) || e.IsOnEdge(_EtaMax));
173 
174 }
175 
176 
177 const Vector_Resolution
179 {
180 
181  return _Vector_Resolution;
182 
183 }
184 
185 
186 std::ostream& operator<< (std::ostream& s, const EtaDepResElement& e)
187 {
188 
189  s << "(" << e._EtaMin << " to " << e._EtaMax << ")" << " / " << e.GetResolution ();
190  return s ;
191 
192 }
193 
194 } // 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:103
Represent a resolution and an range in which the resolution is valid.
T eta() const
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.