|
||||
File indexing completed on 2024-04-06 12:31:17
0001 // 0002 // 0003 // File: hitfit/Resolution.h 0004 // Purpose: Calculate resolutions for a quantity. 0005 // Created: Jul, 2000, sss, based on run 1 mass analysis code. 0006 // 0007 // This object will calculate resolutions for some quantity. 0008 // We have three parameters: 0009 // 0010 // C - constant term 0011 // R - resolution term 0012 // N - noise term 0013 // 0014 // Given a `momentum' p, we calculate the uncertainty in a quantity x as 0015 // 0016 // sigma(x) = sqrt (C^2 p^2 + R^2 p + N^2) 0017 // 0018 // In addition, we have an `inverse' flag. If that is set, 0019 // we take the inverse of p before doing the above calculation 0020 // (and for p, `sigma(p)' is regarded as actually sigma(1/p)). 0021 // 0022 // We encode the resolution parameters into a string, from which these 0023 // objects get initialized. The format is 0024 // 0025 // [-]C[,R[,N]] 0026 // 0027 // If a leading minus sign is present, that turns on the invert flag. 0028 // Omitted parameters are set to 0. 0029 // 0030 // CMSSW File : interface/Resolution.h 0031 // Original Author : Scott Stuart Snyder <snyder@bnl.gov> for D0 0032 // Imported to CMSSW by Haryo Sumowidagdo <Suharyo.Sumowidagdo@cern.ch> 0033 // 0034 0035 /** 0036 @file Resolution.h 0037 0038 @brief Calculate and represent resolution for a physical quantity. 0039 0040 @author Scott Stuart Snyder <snyder@bnl.gov> 0041 0042 @par Creation date: 0043 Jul 2000. 0044 0045 @par Modification History: 0046 Apr 2009: Haryo Sumowidagdo <Suharyo.Sumowidagdo@cern.ch>: 0047 Imported to CMSSW.<br> 0048 Nov 2009: Haryo Sumowidagdo <Suharyo.Sumowidagdo@cern.ch>: 0049 Added doxygen tags for automatic generation of documentation. 0050 0051 @par Terms of Usage: 0052 With consent for the original author (Scott Snyder). 0053 0054 */ 0055 0056 #ifndef HITFIT_RESOLUTION_H 0057 #define HITFIT_RESOLUTION_H 0058 0059 #include <string> 0060 #include <iosfwd> 0061 #include "CLHEP/Random/Random.h" 0062 0063 namespace hitfit { 0064 0065 /** 0066 @class Resolution 0067 0068 @brief Calculate and represent resolution for a physical quantity. 0069 0070 This class calculate resolutions for some quantity. In general we have 0071 three parameters: 0072 - <b>C</b> constant term. 0073 - <b>R</b> resolution term. 0074 - <b>N</b> noise term. 0075 0076 Given a physical quantitiy \f$p\f$, we calculate the uncertainty 0077 in quantity \f$x\f$ as: 0078 0079 \f[ 0080 \sigma(x) = \sqrt{C^{2}p^{2} + R^{2}p + N^{2}} 0081 \f] 0082 0083 In addition, we also have an inverse flag. If the flag is set, we 0084 take the inverse of \f$p\f$ before doing the calculations. 0085 Therefore \f$\sigma(x)\f$ is regarded as actually \f$\sigma(1/x)\f$. 0086 0087 We encode he resolution parameters into a string, from which these 0088 objects get initialized. The format is 0089 0090 \verbatim 0091 [-]C[,R[,N]] 0092 \endverbatim 0093 0094 where parameters within the brackets are optional. If the leading minus 0095 is present, the inverse flag is turned on. Omitted parameters are set 0096 to 0. 0097 */ 0098 class Resolution 0099 // 0100 // Purpose: Calculate resolutions for a quantity. 0101 // 0102 { 0103 public: 0104 // Initialize from a string S. The format is as described above. 0105 /** 0106 @brief Constructor, initialize from a string. 0107 0108 @param s A string encoding the resolution parameters, as described in 0109 the class description. 0110 */ 0111 Resolution(std::string s = ""); 0112 0113 /** 0114 @brief Constructor to initialize with four values for C, R, m, N, 0115 and the boolean for inverse 0116 0117 @param C The constant term 0118 0119 @param R The resolution term 0120 0121 @param m The exponent factor term 0122 0123 @param N The noise term 0124 0125 @param inverse The inverse flag. 0126 */ 0127 Resolution(double C, double R, double m, double N, bool inverse = false); 0128 0129 // Initialize to a constant resolution RES. I.e., sigma() will 0130 // always return RES. If INVERSE is true, set the inverse flag. 0131 /** 0132 @brief Constructor to initialize a constant resolution. 0133 0134 @param res The resolution value. 0135 0136 @param inverse The inverse flag. 0137 */ 0138 Resolution(double res, bool inverse = false); 0139 0140 // Return the setting of the inverse flag. 0141 /** 0142 @brief Return the setting of the inverse flag. 0143 */ 0144 bool inverse() const; 0145 0146 /** 0147 @brief Return the C term (constant term) 0148 */ 0149 double C() const; 0150 0151 /** 0152 @brief Return the R term (resolution term) 0153 */ 0154 double R() const; 0155 0156 /** 0157 @brief Return the exponent factor in the resolution term. 0158 */ 0159 double m() const; 0160 0161 /** 0162 @brief Return the N term (noise term) 0163 */ 0164 double N() const; 0165 0166 // Return the uncertainty for a momentum P. 0167 /** 0168 @brief Return the uncertainty for a variable with magnitude 0169 <i>p</i>. 0170 0171 @param p The momentum. 0172 */ 0173 double sigma(double p) const; 0174 0175 // Given a value X, measured for an object with momentum P, 0176 // pick a new value from a Gaussian distribution 0177 // described by this resolution --- with mean X and width sigma(P). 0178 /** 0179 @brief Generate random value from a Gaussian distribution 0180 described by this resolution. Given a value \f$x\f$, measured 0181 for an object with momentum \f$p\f$, pick a new value 0182 from a Gaussian distribution described by this resolution: 0183 with mean \f$x\f$ and width \f$\sigma(p)\f$. 0184 0185 @param x The quantity value (distributed mean). 0186 0187 @param p The momentum, for calculating the width. 0188 0189 @param engine The underlying random number generator. 0190 */ 0191 double pick(double x, double p, CLHEP::HepRandomEngine& engine) const; 0192 0193 // Dump, for debugging. 0194 friend std::ostream& operator<<(std::ostream& s, const Resolution& r); 0195 0196 private: 0197 // The resolution parameters. 0198 0199 /** 0200 The constant term. 0201 */ 0202 double _constant_sigma; 0203 0204 /** 0205 The resolution term. 0206 */ 0207 double _resolution_sigma; 0208 0209 /** 0210 The m exponential factor in the resolution term. 0211 */ 0212 double _resolution_exponent; 0213 0214 /** 0215 The noise term. 0216 */ 0217 double _noise_sigma; 0218 0219 /** 0220 The inverse flag. 0221 */ 0222 bool _inverse; 0223 }; 0224 0225 } // namespace hitfit 0226 0227 #endif // not HITFIT_RESOLUTION_H
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.2.1 LXR engine. The LXR team |