CMS 3D CMS Logo

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

Calculate and represent resolution for a physical quantity. More...

#include <Resolution.h>

Public Member Functions

double C () const
 Return the C term (constant term) More...
 
bool inverse () const
 Return the setting of the inverse flag. More...
 
double m () const
 Return the exponent factor in the resolution term. More...
 
double N () const
 Return the N term (noise term) More...
 
double pick (double x, double p, CLHEP::HepRandomEngine &engine) const
 Generate random value from a Gaussian distribution described by this resolution. Given a value $x$, measured for an object with momentum $p$, pick a new value from a Gaussian distribution described by this resolution: with mean $x$ and width $\sigma(p)$. More...
 
double R () const
 Return the R term (resolution term) More...
 
 Resolution (std::string s="")
 Constructor, initialize from a string. More...
 
 Resolution (double C, double R, double m, double N, bool inverse=false)
 Constructor to initialize with four values for C, R, m, N, and the boolean for inverse. More...
 
 Resolution (double res, bool inverse=false)
 Constructor to initialize a constant resolution. More...
 
double sigma (double p) const
 Return the uncertainty for a variable with magnitude p. More...
 

Private Attributes

double _constant_sigma
 
bool _inverse
 
double _noise_sigma
 
double _resolution_exponent
 
double _resolution_sigma
 

Friends

std::ostream & operator<< (std::ostream &s, const Resolution &r)
 Output stream operator, print the content of this Resolution to an output stream. More...
 

Detailed Description

Calculate and represent resolution for a physical quantity.

This class calculate resolutions for some quantity. In general we have three parameters:

Given a physical quantitiy $p$, we calculate the uncertainty in quantity $x$ as:

\[ \sigma(x) = \sqrt{C^{2}p^{2} + R^{2}p + N^{2}} \]

In addition, we also have an inverse flag. If the flag is set, we take the inverse of $p$ before doing the calculations. Therefore $\sigma(x)$ is regarded as actually $\sigma(1/x)$.

We encode he resolution parameters into a string, from which these objects get initialized. The format is

[-]C[,R[,N]]

where parameters within the brackets are optional. If the leading minus is present, the inverse flag is turned on. Omitted parameters are set to 0.

Definition at line 102 of file Resolution.h.

Constructor & Destructor Documentation

hitfit::Resolution::Resolution ( std::string  s = "")

Constructor, initialize from a string.

Parameters
sA string encoding the resolution parameters, as described in the class description.

Definition at line 90 of file Resolution.cc.

References _constant_sigma, _inverse, _noise_sigma, _resolution_sigma, and i.

99 {
100  _inverse = false;
101  _constant_sigma = 0;
102  _resolution_sigma = 0;
103  _noise_sigma = 0;
104 
105  // Skip spaces.
106  double x;
107  string::size_type i = 0;
108  while (i < s.size() && isspace (s[i]))
109  ++i;
110 
111  // Check for the inverse flag.
112  if (s[i] == '-') {
113  _inverse = true;
114  ++i;
115  }
116  else if (s[i] == '+') {
117  ++i;
118  }
119 
120  // Get the constant term.
121  if (get_field (s, i, x)) _constant_sigma = x;
122  i = s.find (',', i);
123 
124  // Look for a resolution term.
125  if (i != string::npos) {
126  ++i;
127  if (get_field (s, i, x)) _resolution_sigma = x;
128 
129  // Look for a noise term.
130  i = s.find (',', i);
131  if (i != string::npos) {
132  if (get_field (s, i+1, x)) _noise_sigma = x;
133  }
134  }
135 }
int i
Definition: DBlmapReader.cc:9
uint16_t size_type
double _resolution_exponent
Definition: Resolution.h:221
double _resolution_sigma
Definition: Resolution.h:216
double _constant_sigma
Definition: Resolution.h:211
hitfit::Resolution::Resolution ( double  C,
double  R,
double  m,
double  N,
bool  inverse = false 
)

Constructor to initialize with four values for C, R, m, N, and the boolean for inverse.

Parameters
CThe constant term
RThe resolution term
mThe exponent factor term
NThe noise term
inverseThe inverse flag.

Definition at line 138 of file Resolution.cc.

143  : _constant_sigma (C),
146  _noise_sigma (N),
147  _inverse (inverse)
148 {
149 }
double R() const
Return the R term (resolution term)
Definition: Resolution.cc:189
double m() const
Return the exponent factor in the resolution term.
Definition: Resolution.cc:195
bool inverse() const
Return the setting of the inverse flag.
Definition: Resolution.cc:171
double _resolution_exponent
Definition: Resolution.h:221
double _resolution_sigma
Definition: Resolution.h:216
double N() const
Return the N term (noise term)
Definition: Resolution.cc:201
double C() const
Return the C term (constant term)
Definition: Resolution.cc:183
double _constant_sigma
Definition: Resolution.h:211
hitfit::Resolution::Resolution ( double  res,
bool  inverse = false 
)

Constructor to initialize a constant resolution.

Parameters
resThe resolution value.
inverseThe inverse flag.

Definition at line 152 of file Resolution.cc.

162  : _constant_sigma (0),
163  _resolution_sigma (0),
165  _noise_sigma (res),
166  _inverse (inverse)
167 {
168 }
bool inverse() const
Return the setting of the inverse flag.
Definition: Resolution.cc:171
Definition: Electron.h:4
double _resolution_exponent
Definition: Resolution.h:221
double _resolution_sigma
Definition: Resolution.h:216
double _constant_sigma
Definition: Resolution.h:211

Member Function Documentation

double hitfit::Resolution::C ( ) const

Return the C term (constant term)

Definition at line 183 of file Resolution.cc.

References _constant_sigma.

184 {
185  return _constant_sigma;
186 }
double _constant_sigma
Definition: Resolution.h:211
bool hitfit::Resolution::inverse ( ) const

Return the setting of the inverse flag.

Definition at line 171 of file Resolution.cc.

References _inverse.

Referenced by hitfit::Constrained_Top::Constrained_Top(), hitfit::Constrained_Z::Constrained_Z(), and hitfit::Vector_Resolution::p_sigma().

178 {
179  return _inverse;
180 }
double hitfit::Resolution::m ( ) const

Return the exponent factor in the resolution term.

Definition at line 195 of file Resolution.cc.

References _resolution_exponent.

196 {
197  return _resolution_exponent;
198 }
double _resolution_exponent
Definition: Resolution.h:221
double hitfit::Resolution::N ( ) const

Return the N term (noise term)

Definition at line 201 of file Resolution.cc.

References _noise_sigma.

202 {
203  return _noise_sigma;
204 }
double hitfit::Resolution::pick ( double  x,
double  p,
CLHEP::HepRandomEngine &  engine 
) const

Generate random value from a Gaussian distribution described by this resolution. Given a value $x$, measured for an object with momentum $p$, pick a new value from a Gaussian distribution described by this resolution: with mean $x$ and width $\sigma(p)$.

Parameters
xThe quantity value (distributed mean).
pThe momentum, for calculating the width.
engineThe underlying random number generator.

Definition at line 227 of file Resolution.cc.

References _inverse, relval_steps::gen(), AlCaHLTBitMon_ParallelJobs::p, and sigma().

Referenced by hitfit::Vector_Resolution::phi_sigma(), hitfit::Vector_Resolution::smear(), and hitfit::Lepjets_Event::smear().

241 {
242  CLHEP::RandGauss gen (engine);
243  if (_inverse)
244  return 1 / gen.fire (1 / x, sigma (p));
245  else
246  return gen.fire (x, sigma (p));
247 }
double sigma(double p) const
Return the uncertainty for a variable with magnitude p.
Definition: Resolution.cc:207
def gen(fragment, howMuch)
Production test section ####.
double hitfit::Resolution::R ( ) const

Return the R term (resolution term)

Definition at line 189 of file Resolution.cc.

References _resolution_sigma.

190 {
191  return _resolution_sigma;
192 }
double _resolution_sigma
Definition: Resolution.h:216
double hitfit::Resolution::sigma ( double  p) const

Return the uncertainty for a variable with magnitude p.

Parameters
pThe momentum.

Definition at line 207 of file Resolution.cc.

References _constant_sigma, _inverse, _noise_sigma, _resolution_sigma, AlCaHLTBitMon_ParallelJobs::p, and mathSSE::sqrt().

Referenced by hitfit::Constrained_Top::Constrained_Top(), hitfit::Constrained_Z::Constrained_Z(), pick(), and hitfit::Vector_Resolution::use_et().

217 {
218  if (_inverse)
219  p = 1 / p;
220 
224 }
T sqrt(T t)
Definition: SSEVec.h:18
double _resolution_sigma
Definition: Resolution.h:216
double _constant_sigma
Definition: Resolution.h:211

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  s,
const Resolution r 
)
friend

Output stream operator, print the content of this Resolution to an output stream.

Parameters
sThe stream to which to write.
rThe instance of Resolution to be printed.

Definition at line 258 of file Resolution.cc.

269 {
270  if (r._inverse) s << "-";
271  s << r._constant_sigma << ","
272  << r._resolution_sigma << ","
273  << r._noise_sigma;
274  return s;
275 }

Member Data Documentation

double hitfit::Resolution::_constant_sigma
private

The constant term.

Definition at line 211 of file Resolution.h.

Referenced by C(), hitfit::operator<<(), Resolution(), and sigma().

bool hitfit::Resolution::_inverse
private

The inverse flag.

Definition at line 231 of file Resolution.h.

Referenced by inverse(), hitfit::operator<<(), pick(), Resolution(), and sigma().

double hitfit::Resolution::_noise_sigma
private

The noise term.

Definition at line 226 of file Resolution.h.

Referenced by N(), hitfit::operator<<(), Resolution(), and sigma().

double hitfit::Resolution::_resolution_exponent
private

The m exponential factor in the resolution term.

Definition at line 221 of file Resolution.h.

Referenced by m().

double hitfit::Resolution::_resolution_sigma
private

The resolution term.

Definition at line 216 of file Resolution.h.

Referenced by hitfit::operator<<(), R(), Resolution(), and sigma().