CMS 3D CMS Logo

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, const Vector_Resolution& res) : _Vector_Resolution(res) {
33  SetEta(eta1, eta2);
34  }
35 
36  EtaDepResElement::EtaDepResElement(double eta1, double eta2, std::string res) : _Vector_Resolution(res) {
37  SetEta(eta1, eta2);
38  }
39 
41  double eta2,
42  const Resolution& p_res,
43  const Resolution& eta_res,
44  const Resolution& phi_res,
45  bool use_et)
46  : _Vector_Resolution(p_res, eta_res, phi_res, use_et) {
47  SetEta(eta1, eta2);
48  }
49 
51 
52  void EtaDepResElement::SetEta(double eta1, double eta2) {
53  if (fabs(eta1 - eta2) < (1.0 / double(InverseEtaPrecision))) {
54  throw std::runtime_error("EtaDepResElement::equal EtaMin and EtaMax");
55  }
56 
57  if (eta1 < eta2) {
58  _EtaMin = eta1;
59  _EtaMax = eta2;
60  } else {
61  _EtaMin = eta2;
62  _EtaMax = eta1;
63  }
64  }
65 
80  if (a.IsOverlap(b)) {
81  return false;
82  }
83  return !(a._EtaMax > b._EtaMin);
84  }
85 
86  const double EtaDepResElement::EtaMin() const { return _EtaMin; }
87 
88  const double EtaDepResElement::EtaMax() const { return _EtaMax; }
89 
91  return (IsInInterval(e._EtaMin) || IsInInterval(e._EtaMax));
92  }
93 
94  bool EtaDepResElement::IsNotOverlap(const EtaDepResElement& e) const { return !(IsOverlap(e)); }
95 
96  bool EtaDepResElement::IsInInterval(const double& eta) const { return ((_EtaMin < eta) && (eta < _EtaMax)); }
97 
98  bool EtaDepResElement::IsOnEdge(const double& eta) const {
99  bool nearEtaMin = fabs(eta - _EtaMin) < (1.0 / double(InverseEtaPrecision));
100  bool nearEtaMax = fabs(eta - _EtaMax) < (1.0 / double(InverseEtaPrecision));
101  return nearEtaMin || nearEtaMax;
102  }
103 
105  return (e.IsOnEdge(_EtaMin) || e.IsOnEdge(_EtaMax));
106  }
107 
109 
110  std::ostream& operator<<(std::ostream& s, const EtaDepResElement& e) {
111  s << "(" << e._EtaMin << " to " << e._EtaMax << ")"
112  << " / " << e.GetResolution();
113  return s;
114  }
115 
116 } // 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 double EtaMin() const
Return the lower limit of valid range.
Calculate and represent resolution for a physical quantity.
Definition: Resolution.h:98
const Vector_Resolution GetResolution() const
Access the resolution.
bool IsInInterval(const double &eta) const
Check if an value is within this instance&#39;s range.
Represent a resolution and an range in which the resolution is valid.
Definition: Electron.h:6
static const int InverseEtaPrecision
Constant, the inverse of precision expected.
bool IsOverlap(const EtaDepResElement &e) const
Check if this instance has overlapping range with another instance of EtaDepResElement.
bool operator<(const EtaDepResElement &a, const EtaDepResElement &b)
Comparison operator, compare two EtaDepResElement instances based on their respective valid ranges...
Vector_Resolution _Vector_Resolution
const double EtaMax() const
Return the lower limit of valid range.
bool IsNotOverlap(const EtaDepResElement &e) const
Check if this instance does not have overlapping range with another instance.
EtaDepResElement(double eta1, double eta2, const Vector_Resolution &res)
Construct an instance of EtaDepResElement from the lower limit, upper limit, and the resolution...
double b
Definition: hdecay.h:120
void SetEta(double eta1, double eta2)
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...
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 ...