Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:31:17

0001 //
0002 //
0003 // File: hitfit/Vector_Resolution.h
0004 // Purpose: Calculate resolutions in p, phi, eta.
0005 // Created: Jul, 2000, sss, based on run 1 mass analysis code.
0006 //
0007 // These objects hold three Resolution objects, one each for p, phi, eta.
0008 // In addition, we have a use_et flag; if set, then the p resolution
0009 // is really in pt.
0010 //
0011 // We can initialize these objects from a string; the format is
0012 //
0013 //   <p-res>/<eta-res>/<phi-res>[/et]
0014 //
0015 // where the resolution formats are as given in Resolution.h.
0016 //
0017 // CMSSW File      : interface/Vector_Resolution.h
0018 // Original Author : Scott Stuart Snyder <snyder@bnl.gov> for D0
0019 // Imported to CMSSW by Haryo Sumowidagdo <Suharyo.Sumowidagdo@cern.ch>
0020 //
0021 
0022 /**
0023     @file Vector_Resolution.h
0024 
0025     @brief Calculate and represent resolution for a vector
0026     of momentum \f$p\f$, pseudorapidity \f$\eta\f$, and azimuthal
0027     angle \f$\phi\f$.
0028 
0029     @author Scott Stuart Snyder <snyder@bnl.gov>
0030 
0031     @par Creation date:
0032     Jul 2000.
0033 
0034     @par Modification History:
0035     Apr 2009: Haryo Sumowidagdo <Suharyo.Sumowidagdo@cern.ch>:
0036     Imported to CMSSW.<br>
0037     Nov 2009: Haryo Sumowidagdo <Suharyo.Sumowidagdo@cern.ch>:
0038     Added doxygen tags for automatic generation of documentation.
0039 
0040     @par Terms of Usage:
0041     With consent for the original author (Scott Snyder).
0042 
0043  */
0044 
0045 #ifndef HITFIT_VECTOR_RESOLUTION_H
0046 #define HITFIT_VECTOR_RESOLUTION_H
0047 
0048 #include <string>
0049 #include <iosfwd>
0050 #include "TopQuarkAnalysis/TopHitFit/interface/Resolution.h"
0051 #include "TopQuarkAnalysis/TopHitFit/interface/fourvec.h"
0052 
0053 namespace hitfit {
0054 
0055   /**
0056     @class Vector_Resolution
0057 
0058     @brief Calculate and represent resolution for a vector of
0059     \f$p\f$, pseudorapidity \f$\eta\f$, and azimuthal angle \f$\phi\f$.
0060     An instance of this class holds three Resolution objects, one each for
0061     \f$p\f$, \f$\eta\f$, and \f$\phi\f$.  In addition, we have a flag
0062     to indicate if the momentum resolution is in \f$p_{T}\f$ or \f$p\f$.
0063     This flag is set by appending [/et] at the end of the string.
0064 
0065     This class is initialized from a string with format
0066 
0067     \verbatim
0068 <p-resolution>/<eta-resolution>/<phi-resolution>[/et]
0069     \endverbatim
0070 
0071     where the resolution formats are given in the documentation for
0072     the Resolution class.
0073 
0074     Addendum by Haryo Sumowidagdo:
0075     When using the inverse flag, only the inverse flag in p-resolution
0076     will be used by the fitter to set that flag which says the error in 'p'
0077     is really the error on '1/p'.
0078     The inverse flag for \f$\eta\f$ in eta-resolution and \f$\phi\f$
0079     in phi-resolution are not used by the fitter.  As usually the
0080     angular resolution is of the form
0081 
0082     \f$ \sigma_{\eta,\phi} = \sqrt{\frac{C^{2}}{p^{2}} + \frac{R^{2}}{p} + N^2}\f$
0083 
0084     where \f$ p \f$ can be the magnitude of the momentum (\f$ p \f$) or
0085     or transverse momentum (\f$ p_{T} \f$), one then can (and should!)
0086     use the inverse flag for \f$ \eta \f$ and  \f$ \phi \f$ resolution.
0087 
0088  */
0089   class Vector_Resolution
0090   //
0091   // Purpose: Calculate resolutions in p, phi, eta.
0092   //
0093   {
0094   public:
0095     // Constructor.  Create a vector resolution object with infinite precision
0096     /**
0097      @brief Constructor, instantiate an instance of Vector_Resolution with
0098      infinite precision.
0099    */
0100     Vector_Resolution();
0101 
0102     // Constructor.  Parse a string as described above.
0103     /**
0104      @brief Constructor, instantiate an instance of Vector_Resolution from
0105      a string using format as described in the class description.
0106 
0107      @param s String enconding the resolution parameters.
0108    */
0109     Vector_Resolution(std::string s);
0110 
0111     // Constructor from individual resolution objects.
0112     /**
0113      @brief Constructor, instantiate an instance of Vector_Resolution from
0114      three instances of Resolution objects.
0115 
0116      @param p_res The momentum resolution.
0117 
0118      @param eta_res The pseudorapidity resolution.
0119 
0120      @param phi_res The azimuthal angle resolution.
0121 
0122      @param use_et If <b>TRUE</b> then use \f$p_{T}\f$ instead of \f$p\f$
0123      for momentum resolution.
0124    */
0125     Vector_Resolution(const Resolution& p_res,
0126                       const Resolution& eta_res,
0127                       const Resolution& phi_res,
0128                       bool use_et = false);
0129 
0130     // Get back the individual resolution objects.
0131     /**
0132      @brief Return a constant reference to the momentum resolution.
0133    */
0134     const Resolution& p_res() const;
0135 
0136     /**
0137      @brief Return a constant reference to the pseudorapidity resolution.
0138    */
0139     const Resolution& eta_res() const;
0140 
0141     /**
0142      @brief Return a constant reference to the azimuthal angle resolution.
0143    */
0144     const Resolution& phi_res() const;
0145 
0146     // Return the use_et flag.
0147     /**
0148      @brief Return the <i>use_et</i> flag.
0149    */
0150     bool use_et() const;
0151 
0152     // Calculate resolutions from a 4-momentum.
0153     /**
0154      @brief Calculate the momentum resolution of a four-momentum.
0155 
0156      @param v The four-momentum.
0157    */
0158     double p_sigma(const Fourvec& v) const;
0159 
0160     /**
0161      @brief Calculate the pseudorapidity resolution of a four-momentum.
0162 
0163      @param v The four-momentum.
0164    */
0165     double eta_sigma(const Fourvec& v) const;
0166 
0167     /**
0168      @brief Calculate the azimuthal angle resolution of a four-momentum.
0169 
0170      @param v The four-momentum.
0171    */
0172     double phi_sigma(const Fourvec& v) const;
0173 
0174     // Smear a 4-vector V according to the resolutions.
0175     // If DO_SMEAR_DIR is false, only smear the total energy.
0176     /**
0177      @brief Smear a four-momentum according to the resolutions.
0178 
0179      @param v The four-momentum to smear.
0180 
0181      @param engine The underlying random number generator.
0182 
0183      @param do_smear_dir If <b>FALSE</b>, only smear the energy.
0184      If <b>TRUE</b>, also smear the direction.
0185    */
0186     void smear(Fourvec& v, CLHEP::HepRandomEngine& engine, bool do_smear_dir = false) const;
0187 
0188     // Dump this object, for debugging.
0189     friend std::ostream& operator<<(std::ostream& s, const Vector_Resolution& r);
0190 
0191   private:
0192     // State for this object.
0193     /**
0194      The momentum resolution.
0195    */
0196     Resolution _p_res;
0197 
0198     /**
0199      The pseudorapidity resolution.
0200    */
0201     Resolution _eta_res;
0202 
0203     /**
0204      The phi resolution.
0205    */
0206     Resolution _phi_res;
0207 
0208     /**
0209      The momentum resolution.
0210    */
0211     bool _use_et;
0212 
0213     // Helper.
0214     /**
0215      @brief Helper function to smear direction.
0216 
0217      @param v The four-momentum to smear.
0218 
0219      @param engine The underlying random number generator.
0220    */
0221     void smear_dir(Fourvec& v, CLHEP::HepRandomEngine& engine) const;
0222   };
0223 
0224 }  // namespace hitfit
0225 
0226 #endif  // not HITFIT_VECTOR_RESOLUTION_H