CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Resolution.h
Go to the documentation of this file.
1 //
2 // $Id: Resolution.h,v 1.2 2012/03/19 18:15:04 vadler Exp $
3 //
4 // File: hitfit/Resolution.h
5 // Purpose: Calculate resolutions for a quantity.
6 // Created: Jul, 2000, sss, based on run 1 mass analysis code.
7 //
8 // This object will calculate resolutions for some quantity.
9 // We have three parameters:
10 //
11 // C - constant term
12 // R - resolution term
13 // N - noise term
14 //
15 // Given a `momentum' p, we calculate the uncertainty in a quantity x as
16 //
17 // sigma(x) = sqrt (C^2 p^2 + R^2 p + N^2)
18 //
19 // In addition, we have an `inverse' flag. If that is set,
20 // we take the inverse of p before doing the above calculation
21 // (and for p, `sigma(p)' is regarded as actually sigma(1/p)).
22 //
23 // We encode the resolution parameters into a string, from which these
24 // objects get initialized. The format is
25 //
26 // [-]C[,R[,N]]
27 //
28 // If a leading minus sign is present, that turns on the invert flag.
29 // Omitted parameters are set to 0.
30 //
31 // CMSSW File : interface/Resolution.h
32 // Original Author : Scott Stuart Snyder <snyder@bnl.gov> for D0
33 // Imported to CMSSW by Haryo Sumowidagdo <Suharyo.Sumowidagdo@cern.ch>
34 //
35 
36 
58 #ifndef HITFIT_RESOLUTION_H
59 #define HITFIT_RESOLUTION_H
60 
61 
62 #include <string>
63 #include <iosfwd>
64 #include "CLHEP/Random/Random.h"
65 
66 
67 namespace hitfit {
68 
69 
104 //
105 // Purpose: Calculate resolutions for a quantity.
106 //
107 {
108 public:
109  // Initialize from a string S. The format is as described above.
116  Resolution (std::string s = "");
117 
132  Resolution (double C,
133  double R,
134  double m,
135  double N,
136  bool inverse = false);
137 
138  // Initialize to a constant resolution RES. I.e., sigma() will
139  // always return RES. If INVERSE is true, set the inverse flag.
147  Resolution (double res, bool inverse = false);
148 
149  // Return the setting of the inverse flag.
153  bool inverse () const;
154 
158  double C() const;
159 
163  double R() const;
164 
168  double m() const;
169 
173  double N() const;
174 
175  // Return the uncertainty for a momentum P.
182  double sigma (double p) const;
183 
184  // Given a value X, measured for an object with momentum P,
185  // pick a new value from a Gaussian distribution
186  // described by this resolution --- with mean X and width sigma(P).
200  double pick (double x, double p, CLHEP::HepRandomEngine& engine) const;
201 
202  // Dump, for debugging.
203  friend std::ostream& operator<< (std::ostream& s, const Resolution& r);
204 
205 
206 private:
207  // The resolution parameters.
208 
213 
218 
223 
227  double _noise_sigma;
228 
232  bool _inverse;
233 };
234 
235 
236 } // namespace hitfit
237 
238 
239 #endif // not HITFIT_RESOLUTION_H
double R() const
Return the R term (resolution term)
Definition: Resolution.cc:190
Calculate and represent resolution for a physical quantity.
Definition: Resolution.h:103
double m() const
Return the exponent factor in the resolution term.
Definition: Resolution.cc:196
bool inverse() const
Return the setting of the inverse flag.
Definition: Resolution.cc:172
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:259
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:228
double _resolution_exponent
Definition: Resolution.h:222
double sigma(double p) const
Return the uncertainty for a variable with magnitude p.
Definition: Resolution.cc:208
Resolution(std::string s="")
Constructor, initialize from a string.
Definition: Resolution.cc:91
double _resolution_sigma
Definition: Resolution.h:217
double N() const
Return the N term (noise term)
Definition: Resolution.cc:202
x
Definition: VDTMath.h:216
double C() const
Return the C term (constant term)
Definition: Resolution.cc:184
double _constant_sigma
Definition: Resolution.h:212