00001 // 00002 // $Id: Resolution.h,v 1.2 2012/03/19 18:15:04 vadler Exp $ 00003 // 00004 // File: hitfit/Resolution.h 00005 // Purpose: Calculate resolutions for a quantity. 00006 // Created: Jul, 2000, sss, based on run 1 mass analysis code. 00007 // 00008 // This object will calculate resolutions for some quantity. 00009 // We have three parameters: 00010 // 00011 // C - constant term 00012 // R - resolution term 00013 // N - noise term 00014 // 00015 // Given a `momentum' p, we calculate the uncertainty in a quantity x as 00016 // 00017 // sigma(x) = sqrt (C^2 p^2 + R^2 p + N^2) 00018 // 00019 // In addition, we have an `inverse' flag. If that is set, 00020 // we take the inverse of p before doing the above calculation 00021 // (and for p, `sigma(p)' is regarded as actually sigma(1/p)). 00022 // 00023 // We encode the resolution parameters into a string, from which these 00024 // objects get initialized. The format is 00025 // 00026 // [-]C[,R[,N]] 00027 // 00028 // If a leading minus sign is present, that turns on the invert flag. 00029 // Omitted parameters are set to 0. 00030 // 00031 // CMSSW File : interface/Resolution.h 00032 // Original Author : Scott Stuart Snyder <snyder@bnl.gov> for D0 00033 // Imported to CMSSW by Haryo Sumowidagdo <Suharyo.Sumowidagdo@cern.ch> 00034 // 00035 00036 00058 #ifndef HITFIT_RESOLUTION_H 00059 #define HITFIT_RESOLUTION_H 00060 00061 00062 #include <string> 00063 #include <iosfwd> 00064 #include "CLHEP/Random/Random.h" 00065 00066 00067 namespace hitfit { 00068 00069 00103 class Resolution 00104 // 00105 // Purpose: Calculate resolutions for a quantity. 00106 // 00107 { 00108 public: 00109 // Initialize from a string S. The format is as described above. 00116 Resolution (std::string s = ""); 00117 00132 Resolution (double C, 00133 double R, 00134 double m, 00135 double N, 00136 bool inverse = false); 00137 00138 // Initialize to a constant resolution RES. I.e., sigma() will 00139 // always return RES. If INVERSE is true, set the inverse flag. 00147 Resolution (double res, bool inverse = false); 00148 00149 // Return the setting of the inverse flag. 00153 bool inverse () const; 00154 00158 double C() const; 00159 00163 double R() const; 00164 00168 double m() const; 00169 00173 double N() const; 00174 00175 // Return the uncertainty for a momentum P. 00182 double sigma (double p) const; 00183 00184 // Given a value X, measured for an object with momentum P, 00185 // pick a new value from a Gaussian distribution 00186 // described by this resolution --- with mean X and width sigma(P). 00200 double pick (double x, double p, CLHEP::HepRandomEngine& engine) const; 00201 00202 // Dump, for debugging. 00203 friend std::ostream& operator<< (std::ostream& s, const Resolution& r); 00204 00205 00206 private: 00207 // The resolution parameters. 00208 00212 double _constant_sigma; 00213 00217 double _resolution_sigma; 00218 00222 double _resolution_exponent; 00223 00227 double _noise_sigma; 00228 00232 bool _inverse; 00233 }; 00234 00235 00236 } // namespace hitfit 00237 00238 00239 #endif // not HITFIT_RESOLUTION_H