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 
35 
57 #ifndef HITFIT_RESOLUTION_H
58 #define HITFIT_RESOLUTION_H
59 
60 
61 #include <string>
62 #include <iosfwd>
63 #include "CLHEP/Random/Random.h"
64 
65 
66 namespace hitfit {
67 
68 
103 //
104 // Purpose: Calculate resolutions for a quantity.
105 //
106 {
107 public:
108  // Initialize from a string S. The format is as described above.
115  Resolution (std::string s = "");
116 
131  Resolution (double C,
132  double R,
133  double m,
134  double N,
135  bool inverse = false);
136 
137  // Initialize to a constant resolution RES. I.e., sigma() will
138  // always return RES. If INVERSE is true, set the inverse flag.
146  Resolution (double res, bool inverse = false);
147 
148  // Return the setting of the inverse flag.
152  bool inverse () const;
153 
157  double C() const;
158 
162  double R() const;
163 
167  double m() const;
168 
172  double N() const;
173 
174  // Return the uncertainty for a momentum P.
181  double sigma (double p) const;
182 
183  // Given a value X, measured for an object with momentum P,
184  // pick a new value from a Gaussian distribution
185  // described by this resolution --- with mean X and width sigma(P).
199  double pick (double x, double p, CLHEP::HepRandomEngine& engine) const;
200 
201  // Dump, for debugging.
202  friend std::ostream& operator<< (std::ostream& s, const Resolution& r);
203 
204 
205 private:
206  // The resolution parameters.
207 
212 
217 
222 
226  double _noise_sigma;
227 
231  bool _inverse;
232 };
233 
234 
235 } // namespace hitfit
236 
237 
238 #endif // not HITFIT_RESOLUTION_H
double R() const
Return the R term (resolution term)
Definition: Resolution.cc:189
Calculate and represent resolution for a physical quantity.
Definition: Resolution.h:102
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
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:258
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:227
Definition: Electron.h:4
double _resolution_exponent
Definition: Resolution.h:221
T x() const
Cartesian x coordinate.
double sigma(double p) const
Return the uncertainty for a variable with magnitude p.
Definition: Resolution.cc:207
Resolution(std::string s="")
Constructor, initialize from a string.
Definition: Resolution.cc:90
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