CMS 3D CMS Logo

Resolution.h
Go to the documentation of this file.
1 //
2 //
3 // File: hitfit/Resolution.h
4 // Purpose: Calculate resolutions for a quantity.
5 // Created: Jul, 2000, sss, based on run 1 mass analysis code.
6 //
7 // This object will calculate resolutions for some quantity.
8 // We have three parameters:
9 //
10 // C - constant term
11 // R - resolution term
12 // N - noise term
13 //
14 // Given a `momentum' p, we calculate the uncertainty in a quantity x as
15 //
16 // sigma(x) = sqrt (C^2 p^2 + R^2 p + N^2)
17 //
18 // In addition, we have an `inverse' flag. If that is set,
19 // we take the inverse of p before doing the above calculation
20 // (and for p, `sigma(p)' is regarded as actually sigma(1/p)).
21 //
22 // We encode the resolution parameters into a string, from which these
23 // objects get initialized. The format is
24 //
25 // [-]C[,R[,N]]
26 //
27 // If a leading minus sign is present, that turns on the invert flag.
28 // Omitted parameters are set to 0.
29 //
30 // CMSSW File : interface/Resolution.h
31 // Original Author : Scott Stuart Snyder <snyder@bnl.gov> for D0
32 // Imported to CMSSW by Haryo Sumowidagdo <Suharyo.Sumowidagdo@cern.ch>
33 //
34 
56 #ifndef HITFIT_RESOLUTION_H
57 #define HITFIT_RESOLUTION_H
58 
59 #include <string>
60 #include <iosfwd>
61 #include "CLHEP/Random/Random.h"
62 
63 namespace hitfit {
64 
98  class Resolution
99  //
100  // Purpose: Calculate resolutions for a quantity.
101  //
102  {
103  public:
104  // Initialize from a string S. The format is as described above.
111  Resolution(std::string s = "");
112 
127  Resolution(double C, double R, double m, double N, bool inverse = false);
128 
129  // Initialize to a constant resolution RES. I.e., sigma() will
130  // always return RES. If INVERSE is true, set the inverse flag.
138  Resolution(double res, bool inverse = false);
139 
140  // Return the setting of the inverse flag.
144  bool inverse() const;
145 
149  double C() const;
150 
154  double R() const;
155 
159  double m() const;
160 
164  double N() const;
165 
166  // Return the uncertainty for a momentum P.
173  double sigma(double p) const;
174 
175  // Given a value X, measured for an object with momentum P,
176  // pick a new value from a Gaussian distribution
177  // described by this resolution --- with mean X and width sigma(P).
191  double pick(double x, double p, CLHEP::HepRandomEngine& engine) const;
192 
193  // Dump, for debugging.
194  friend std::ostream& operator<<(std::ostream& s, const Resolution& r);
195 
196  private:
197  // The resolution parameters.
198 
203 
208 
213 
217  double _noise_sigma;
218 
222  bool _inverse;
223  };
224 
225 } // namespace hitfit
226 
227 #endif // not HITFIT_RESOLUTION_H
double pick(double x, double p, CLHEP::HepRandomEngine &engine) const
Generate random value from a Gaussian distribution described by this resolution. Given a value ...
Definition: Resolution.cc:182
Calculate and represent resolution for a physical quantity.
Definition: Resolution.h:98
double m() const
Return the exponent factor in the resolution term.
Definition: Resolution.cc:159
friend std::ostream & operator<<(std::ostream &s, const Resolution &r)
Output stream operator, print the content of this Resolution to an output stream. ...
Definition: Resolution.cc:212
Definition: Electron.h:6
double sigma(double p) const
Return the uncertainty for a variable with magnitude p.
Definition: Resolution.cc:163
double _resolution_exponent
Definition: Resolution.h:212
bool inverse() const
Return the setting of the inverse flag.
Definition: Resolution.cc:144
double N() const
Return the N term (noise term)
Definition: Resolution.cc:161
Resolution(std::string s="")
Constructor, initialize from a string.
Definition: Resolution.cc:82
double _resolution_sigma
Definition: Resolution.h:207
float x
double R() const
Return the R term (resolution term)
Definition: Resolution.cc:157
double C() const
Return the C term (constant term)
Definition: Resolution.cc:155
double _constant_sigma
Definition: Resolution.h:202