CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
hitfit::EtaDepResolution Class Reference

Hold on to $\eta$-dependent resolution. This class acts as a function object and returns Vector_Resolution as a function of $\eta$. It does not assume symmetry between $+\eta$ and $-\eta$. The interpretation of $\eta$ as physics $\eta$ or detector $\eta$ is left to users's implementation. More...

#include <EtaDepResolution.h>

Public Member Functions

const bool CheckEta (double eta) const
 Check is an input $\eta$ value is within the valid $\eta$-range of this instance. More...
 
bool CheckNoOverlap (const std::vector< EtaDepResElement > &v)
 Check for non-overlapping $\eta$-range between $\eta$-dependent resolution elements in a list. More...
 
 EtaDepResolution ()
 Default constructor, instantiate an EtaDepResolution object with empty list of $\eta$-dependent resolution elements. More...
 
 EtaDepResolution (const std::string &default_file)
 Instantiate an EtaDepResolution object with a filename which contains information about $\eta$-dependent resolution. More...
 
const double EtaMax () const
 Return the upper limit of the valid $\eta$-range. More...
 
const double EtaMin () const
 Return the lower limit of the valid $\eta$-range. More...
 
EtaDepResElement GetEtaDepResElement (double &eta) const
 Return the corresponding $\eta$-dependent resolution element (of type EtaDepResElement)for a value of $\eta$. More...
 
const std::vector< EtaDepResElementGetEtaDepResElement () const
 Access the internal list of $\eta$-dependent resolution elements. More...
 
Vector_Resolution GetResolution (double &eta) const
 Return the corresponding resolution for a value of $\eta$. More...
 
Vector_Resolution operator() (double &eta)
 Allow users to call this instance as a function to access the corresponding resolution for an input value of $\eta$. More...
 
std::vector< EtaDepResElement >::size_type Read (const std::string &default_file)
 Read the $\eta$-dependent resolution information from an ASCII text file. More...
 
std::vector< EtaDepResElement >::size_type Read (const Defaults_Text &defs)
 Read the $\eta$-dependent resolution information from a Defaults_Text object. More...
 
void sort ()
 
 ~EtaDepResolution ()
 

Private Member Functions

std::vector< EtaDepResElement >::const_iterator FindResolution (double &eta) const
 Internal method to return the corresponding $\eta$-dependent resolution element for a given $\eta$ value. More...
 

Private Attributes

std::vector< EtaDepResElement_EtaDepResElement
 

Detailed Description

Hold on to $\eta$-dependent resolution. This class acts as a function object and returns Vector_Resolution as a function of $\eta$. It does not assume symmetry between $+\eta$ and $-\eta$. The interpretation of $\eta$ as physics $\eta$ or detector $\eta$ is left to users's implementation.

Usage:
Users should write the $\eta$-dependent resolution in a plain ASCII text file with the following format:

etadep_etaminX = etamin

etadep_etamaxX = etamax

etadep_vecresX = vecres

where:

X is an integer starting from 0 (0, 1, 2, 3, ...). Users can write as many resolutions as long as each of them has different integer, and complete information regarding $\eta$ range an resolution.

etamin is a floating-point number, the lower limit of the valid $\eta$ range.

etamax is a floating-point number, the upper limit of the valid $\eta$ range.

vecres is a string-encoded Vector_Resolution, see the documentation for Vector_Resolution class for details.

The constructor will read the ASCII text file and read all resolutions in the file. Then it will instantiate the EtaDepResolution and sort the internal list of EtaDepResElement.

Author
Haryo Sumowidagdo Suhar.nosp@m.yo.S.nosp@m.umowi.nosp@m.dagd.nosp@m.o@cer.nosp@m.n.ch
Creation date:
June 2009.

Definition at line 87 of file EtaDepResolution.h.

Constructor & Destructor Documentation

hitfit::EtaDepResolution::EtaDepResolution ( )

Default constructor, instantiate an EtaDepResolution object with empty list of $\eta$-dependent resolution elements.

Definition at line 55 of file EtaDepResolution.cc.

56 {
57 }
hitfit::EtaDepResolution::EtaDepResolution ( const std::string &  default_file)

Instantiate an EtaDepResolution object with a filename which contains information about $\eta$-dependent resolution.

Parameters
default_fileThe input ASCII text file.

Definition at line 60 of file EtaDepResolution.cc.

References Read().

61 {
62  Read(default_file);
63 }
std::vector< EtaDepResElement >::size_type Read(const std::string &default_file)
Read the -dependent resolution information from an ASCII text file.
hitfit::EtaDepResolution::~EtaDepResolution ( )

Destructor.

Definition at line 66 of file EtaDepResolution.cc.

67 {
68 }

Member Function Documentation

const bool hitfit::EtaDepResolution::CheckEta ( double  eta) const

Check is an input $\eta$ value is within the valid $\eta$-range of this instance.

Parameters
etaThe $\eta$ value to be check.
Return:
true if eta is within the valid $\eta$-range.
false if is not within the valid $\eta$-range.

Definition at line 164 of file EtaDepResolution.cc.

References _EtaDepResElement, and FindResolution().

165 {
166  return FindResolution(eta) != _EtaDepResElement.end();
167 }
std::vector< EtaDepResElement >::const_iterator FindResolution(double &eta) const
Internal method to return the corresponding -dependent resolution element for a given value...
std::vector< EtaDepResElement > _EtaDepResElement
bool hitfit::EtaDepResolution::CheckNoOverlap ( const std::vector< EtaDepResElement > &  v)

Check for non-overlapping $\eta$-range between $\eta$-dependent resolution elements in a list.

Parameters
vThe list of $\eta$-dependent resolution elements to check.
Return:
true if there is no overlap.
false if there is overlap.

Definition at line 126 of file EtaDepResolution.cc.

References mps_fire::i.

Referenced by Read().

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 }
uint16_t size_type
const double hitfit::EtaDepResolution::EtaMax ( ) const

Return the upper limit of the valid $\eta$-range.

Definition at line 154 of file EtaDepResolution.cc.

References _EtaDepResElement.

155 {
156  if (!(_EtaDepResElement.empty())) {
157  return _EtaDepResElement.back().EtaMax();
158  }
159  return -999.; // a ridiculously negative large number
160 }
std::vector< EtaDepResElement > _EtaDepResElement
const double hitfit::EtaDepResolution::EtaMin ( ) const

Return the lower limit of the valid $\eta$-range.

Definition at line 144 of file EtaDepResolution.cc.

References _EtaDepResElement.

145 {
146  if (!(_EtaDepResElement.empty())) {
147  return _EtaDepResElement.front().EtaMin();
148  }
149  return 999.; // a ridiculously positive large number
150 }
std::vector< EtaDepResElement > _EtaDepResElement
std::vector< EtaDepResElement >::const_iterator hitfit::EtaDepResolution::FindResolution ( double &  eta) const
private

Internal method to return the corresponding $\eta$-dependent resolution element for a given $\eta$ value.

Parameters
etaThe value of $\eta$ whose corresponding resolution is to be found.
Return:
An iterator (pointer) to the corresponding $\eta$-dependent resolution element.

Definition at line 33 of file EtaDepResolution.cc.

References _EtaDepResElement.

Referenced by CheckEta(), GetEtaDepResElement(), and GetResolution().

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 }
Definition: Electron.h:6
std::vector< EtaDepResElement > _EtaDepResElement
EtaDepResElement hitfit::EtaDepResolution::GetEtaDepResElement ( double &  eta) const

Return the corresponding $\eta$-dependent resolution element (of type EtaDepResElement)for a value of $\eta$.

Parameters
etaThe $\eta$ value for which the corresponding element
Return:
The corresponding element if the input $\eta$ value is valid. Throw a runtime error if the $\eta$ value is invalid.

Definition at line 194 of file EtaDepResolution.cc.

References FindResolution().

195 {
196  return *(FindResolution(eta));
197 }
std::vector< EtaDepResElement >::const_iterator FindResolution(double &eta) const
Internal method to return the corresponding -dependent resolution element for a given value...
const std::vector< EtaDepResElement > hitfit::EtaDepResolution::GetEtaDepResElement ( ) const

Access the internal list of $\eta$-dependent resolution elements.

Return:
The list of $\eta$-dependent resolution elements.

Definition at line 201 of file EtaDepResolution.cc.

References _EtaDepResElement.

202 {
203  return _EtaDepResElement;
204 }
std::vector< EtaDepResElement > _EtaDepResElement
Vector_Resolution hitfit::EtaDepResolution::GetResolution ( double &  eta) const

Return the corresponding resolution for a value of $\eta$.

Parameters
etaThe $\eta$ value for which the corresponding resolution is desired.
Return:
The corresponding resolution if the input $\eta$ value is valid. Throw a runtime error if the $\eta$ value is invalid.

Definition at line 178 of file EtaDepResolution.cc.

References _EtaDepResElement, FindResolution(), and python.rootplot.argparse::message.

Referenced by operator()().

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 }
std::vector< EtaDepResElement >::const_iterator FindResolution(double &eta) const
Internal method to return the corresponding -dependent resolution element for a given value...
std::vector< EtaDepResElement > _EtaDepResElement
Vector_Resolution hitfit::EtaDepResolution::operator() ( double &  eta)

Allow users to call this instance as a function to access the corresponding resolution for an input value of $\eta$.

Parameters
etaThe $\eta$ value for which the corresponding resolution is desired.
Return:
The corresponding resolution if the input $\eta$ value is valid. Throw a runtime error if the $\eta$ value is invalid.

Definition at line 171 of file EtaDepResolution.cc.

References GetResolution().

172 {
173  return GetResolution(eta);
174 }
Vector_Resolution GetResolution(double &eta) const
Return the corresponding resolution for a value of .
std::vector< EtaDepResElement >::size_type hitfit::EtaDepResolution::Read ( const std::string &  default_file)

Read the $\eta$-dependent resolution information from an ASCII text file.

Parameters
default_fileThe ASCII text file to read.
Return:
The number of $\eta$-dependent resolution element read from the file.

Definition at line 72 of file EtaDepResolution.cc.

References _EtaDepResElement.

Referenced by EtaDepResolution().

73 {
74  const Defaults_Text defs(default_file);
75  Read(defs);
76  return _EtaDepResElement.size();
77 }
std::vector< EtaDepResElement >::size_type Read(const std::string &default_file)
Read the -dependent resolution information from an ASCII text file.
std::vector< EtaDepResElement > _EtaDepResElement
std::vector< EtaDepResElement >::size_type hitfit::EtaDepResolution::Read ( const Defaults_Text defs)

Read the $\eta$-dependent resolution information from a Defaults_Text object.

Parameters
defsThe Defaults_Text object to read.
Return:
The number of $\eta$-dependent resolution element read from the file.

Definition at line 81 of file EtaDepResolution.cc.

References _EtaDepResElement, CheckNoOverlap(), hitfit::Defaults_Text::exists(), hitfit::Defaults_Text::get_float(), hitfit::Defaults_Text::get_string(), mps_fire::i, and sort().

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 }
bool CheckNoOverlap(const std::vector< EtaDepResElement > &v)
Check for non-overlapping -range between -dependent resolution elements in a list.
uint16_t size_type
Definition: Electron.h:6
std::vector< EtaDepResElement > _EtaDepResElement
void hitfit::EtaDepResolution::sort ( )

Sort the internal list of $\eta$-dependent resolution elements.

Definition at line 49 of file EtaDepResolution.cc.

References _EtaDepResElement.

Referenced by Read().

50 {
51  std::stable_sort(_EtaDepResElement.begin(),_EtaDepResElement.end());
52 }
std::vector< EtaDepResElement > _EtaDepResElement

Member Data Documentation

std::vector<EtaDepResElement> hitfit::EtaDepResolution::_EtaDepResElement
private

List of $\eta$-dependent resolution elements.

Definition at line 94 of file EtaDepResolution.h.

Referenced by CheckEta(), EtaMax(), EtaMin(), FindResolution(), GetEtaDepResElement(), GetResolution(), Read(), and sort().