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 // $Id: EtaDepResolution.cc,v 1.2 2011/10/13 12:34:16 snaumann Exp $
3 //
4 // File : src/EtaDepResolution.cc
5 // Author : Haryo Sumowidagdo <Suharyo.Sumowidagdo@cern.ch>
6 // Purpose: Hold on to eta-dependent resolution.
7 //
8 
26 #include <algorithm>
27 #include <sstream>
28 #include <stdexcept>
30 
31 namespace hitfit {
32 
33 std::vector<EtaDepResElement>::const_iterator
35 {
36 
37  for (std::vector<EtaDepResElement>::const_iterator res = _EtaDepResElement.begin() ;
38  res != _EtaDepResElement.end() ;
39  ++res) {
40  if (res->IsInInterval(eta) || res->IsOnEdge(eta)) {
41  return res;
42  }
43  }
44  return _EtaDepResElement.end() ;
45 
46 }
47 
48 
49 void
51 {
52  std::stable_sort(_EtaDepResElement.begin(),_EtaDepResElement.end());
53 }
54 
55 
57 {
58 }
59 
60 
61 EtaDepResolution::EtaDepResolution(const std::string& default_file)
62 {
63  Read(default_file);
64 }
65 
66 
68 {
69 }
70 
71 
73 EtaDepResolution::Read(const std::string& default_file)
74 {
75  const Defaults_Text defs(default_file);
76  Read(defs);
77  return _EtaDepResElement.size();
78 }
79 
80 
83 {
84 
85  _EtaDepResElement.clear();
86 
88  ;
89  ++i) {
90 
91  std::ostringstream os_etamin ;
92  std::ostringstream os_etamax ;
93  std::ostringstream os_res ;
94 
95  os_etamin << "etadep_etamin" << i ;
96  os_etamax << "etadep_etamax" << i ;
97  os_res << "etadep_vecres" << i ;
98 
99  if (defs.exists(os_etamin.str()) &&
100  defs.exists(os_etamax.str()) &&
101  defs.exists(os_res.str())) {
102 
103  double etamin = defs.get_float(os_etamin.str());
104  double etamax = defs.get_float(os_etamax.str());
105  Vector_Resolution res(defs.get_string(os_res.str()));
106  _EtaDepResElement.push_back(EtaDepResElement(etamin,etamax,res));
107 
108  }
109  else {
110  break;
111  }
112 
113  }
114 
116  sort();
117  } else {
118  _EtaDepResElement.clear();
119  }
120 
121  return _EtaDepResElement.size();
122 
123 }
124 
125 
126 bool
127 EtaDepResolution::CheckNoOverlap(const std::vector<EtaDepResElement>& v)
128 {
130  i != v.size() ;
131  i++) {
133  j != v.size() ;
134  j++) {
135  if (v[i].IsOverlap(v[j])) {
136  return false;
137  }
138  }
139  }
140  return true;
141 }
142 
143 
144 const double
146 {
147  if (!(_EtaDepResElement.empty())) {
148  return _EtaDepResElement.front().EtaMin();
149  }
150  return 999.; // a ridiculously positive large number
151 }
152 
153 
154 const double
156 {
157  if (!(_EtaDepResElement.empty())) {
158  return _EtaDepResElement.back().EtaMax();
159  }
160  return -999.; // a ridiculously negative large number
161 }
162 
163 
164 const bool
166 {
167  return FindResolution(eta) != _EtaDepResElement.end();
168 }
169 
170 
173 {
174  return GetResolution(eta);
175 }
176 
177 
180 {
181 
182  std::vector<EtaDepResElement>::const_iterator etaDepResEleVecIter = FindResolution(eta);
183  if (etaDepResEleVecIter != _EtaDepResElement.end()) {
184  return etaDepResEleVecIter->GetResolution();
185  }
186 
187  std::stringstream message;
188  message << "Error, the given eta value : "
189  << eta << " is not inside the valid eta range!" ;
190 
191  throw std::runtime_error(message.str());
192 }
193 
196 {
197  return *(FindResolution(eta));
198 }
199 
200 
201 const std::vector<EtaDepResElement>
203 {
204  return _EtaDepResElement;
205 }
206 
207 } // 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.
T eta() const
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 ...
mathSSE::Vec4< T > v