CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EtaDepResolution.cc
Go to the documentation of this file.
1 //
2 //
3 // File : src/EtaDepResolution.cc
4 // Author : Haryo Sumowidagdo <Suharyo.Sumowidagdo@cern.ch>
5 // Purpose: Hold on to eta-dependent resolution.
6 //
7 
25 #include <algorithm>
26 #include <sstream>
27 #include <stdexcept>
29 
30 namespace hitfit {
31 
32 std::vector<EtaDepResElement>::const_iterator
34 {
35 
36  for (std::vector<EtaDepResElement>::const_iterator res = _EtaDepResElement.begin() ;
37  res != _EtaDepResElement.end() ;
38  ++res) {
39  if (res->IsInInterval(eta) || res->IsOnEdge(eta)) {
40  return res;
41  }
42  }
43  return _EtaDepResElement.end() ;
44 
45 }
46 
47 
48 void
50 {
51  std::stable_sort(_EtaDepResElement.begin(),_EtaDepResElement.end());
52 }
53 
54 
56 {
57 }
58 
59 
61 {
62  Read(default_file);
63 }
64 
65 
67 {
68 }
69 
70 
72 EtaDepResolution::Read(const std::string& default_file)
73 {
74  const Defaults_Text defs(default_file);
75  Read(defs);
76  return _EtaDepResElement.size();
77 }
78 
79 
82 {
83 
84  _EtaDepResElement.clear();
85 
87  ;
88  ++i) {
89 
90  std::ostringstream os_etamin ;
91  std::ostringstream os_etamax ;
92  std::ostringstream os_res ;
93 
94  os_etamin << "etadep_etamin" << i ;
95  os_etamax << "etadep_etamax" << i ;
96  os_res << "etadep_vecres" << i ;
97 
98  if (defs.exists(os_etamin.str()) &&
99  defs.exists(os_etamax.str()) &&
100  defs.exists(os_res.str())) {
101 
102  double etamin = defs.get_float(os_etamin.str());
103  double etamax = defs.get_float(os_etamax.str());
104  Vector_Resolution res(defs.get_string(os_res.str()));
105  _EtaDepResElement.push_back(EtaDepResElement(etamin,etamax,res));
106 
107  }
108  else {
109  break;
110  }
111 
112  }
113 
115  sort();
116  } else {
117  _EtaDepResElement.clear();
118  }
119 
120  return _EtaDepResElement.size();
121 
122 }
123 
124 
125 bool
126 EtaDepResolution::CheckNoOverlap(const std::vector<EtaDepResElement>& v)
127 {
129  i != v.size() ;
130  i++) {
132  j != v.size() ;
133  j++) {
134  if (v[i].IsOverlap(v[j])) {
135  return false;
136  }
137  }
138  }
139  return true;
140 }
141 
142 
143 const double
145 {
146  if (!(_EtaDepResElement.empty())) {
147  return _EtaDepResElement.front().EtaMin();
148  }
149  return 999.; // a ridiculously positive large number
150 }
151 
152 
153 const double
155 {
156  if (!(_EtaDepResElement.empty())) {
157  return _EtaDepResElement.back().EtaMax();
158  }
159  return -999.; // a ridiculously negative large number
160 }
161 
162 
163 const bool
165 {
166  return FindResolution(eta) != _EtaDepResElement.end();
167 }
168 
169 
172 {
173  return GetResolution(eta);
174 }
175 
176 
179 {
180 
181  std::vector<EtaDepResElement>::const_iterator etaDepResEleVecIter = FindResolution(eta);
182  if (etaDepResEleVecIter != _EtaDepResElement.end()) {
183  return etaDepResEleVecIter->GetResolution();
184  }
185 
186  std::stringstream message;
187  message << "Error, the given eta value : "
188  << eta << " is not inside the valid eta range!" ;
189 
190  throw std::runtime_error(message.str());
191 }
192 
195 {
196  return *(FindResolution(eta));
197 }
198 
199 
200 const std::vector<EtaDepResElement>
202 {
203  return _EtaDepResElement;
204 }
205 
206 } // namespace hitfit
int i
Definition: DBlmapReader.cc:9
const double EtaMax() const
Return the upper limit of the valid -range.
std::vector< EtaDepResElement >::size_type Read(const std::string &default_file)
Read the -dependent resolution information from an ASCII text file.
const std::vector< EtaDepResElement > GetEtaDepResElement() const
Access the internal list of -dependent resolution elements.
A lightweight implementation of the Defaults interface that uses simple ASCII text files...
virtual bool exists(std::string name) const
std::vector< EtaDepResElement >::const_iterator FindResolution(double &eta) const
Internal method to return the corresponding -dependent resolution element for a given value...
Represent a resolution and an range in which the resolution is valid.
bool CheckNoOverlap(const std::vector< EtaDepResElement > &v)
Check for non-overlapping -range between -dependent resolution elements in a list.
uint16_t size_type
Vector_Resolution GetResolution(double &eta) const
Return the corresponding resolution for a value of .
const double EtaMin() const
Return the lower limit of the valid -range.
std::vector< EtaDepResElement > _EtaDepResElement
int j
Definition: DBlmapReader.cc:9
virtual double get_float(std::string name) const
Vector_Resolution operator()(double &eta)
Allow users to call this instance as a function to access the corresponding resolution for an input v...
Hold on to -dependent resolution. This class acts as a function object and returns Vector_Resolution ...
EtaDepResolution()
Default constructor, instantiate an EtaDepResolution object with empty list of -dependent resolution ...
virtual std::string get_string(std::string name) const
const bool CheckEta(double eta) const
Check is an input value is within the valid -range of this instance.
Calculate and represent resolution for a vector of , pseudorapidity , and azimuthal angle ...