Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 //
0002 //
0003 // File: src/Fit_Result.cc
0004 // Purpose: Hold the result from a single kinematic fit.
0005 // Created: Jul, 2000, sss, based on run 1 mass analysis code.
0006 //
0007 // CMSSW File      : src/Fit_Result.cc
0008 // Original Author : Scott Stuart Snyder <snyder@bnl.gov> for D0
0009 // Imported to CMSSW by Haryo Sumowidagdo <Suharyo.Sumowidagdo@cern.ch>
0010 //
0011 
0012 /**
0013     @file Fit_Result.cc
0014 
0015     @brief Hold the result of one kinematic fit.  See the documentation
0016     for the header file Fit_Result.h for details.
0017 
0018     @author Scott Stuart Snyder <snyder@bnl.gov>
0019 
0020     @par Creation date:
0021     Jul 2000.
0022 
0023     @par Modification History:
0024     Apr 2009: Haryo Sumowidagdo <Suharyo.Sumowidagdo@cern.ch>:
0025     Imported to CMSSW.<br>
0026     Nov 2009: Haryo Sumowidagdo <Suharyo.Sumowidagdo@cern.ch>:
0027     Added Doxygen tags for automatic generation of documentation.
0028 
0029     @par Terms of Usage:
0030     With consent from the original author (Scott Snyder).
0031 
0032  */
0033 
0034 #include "TopQuarkAnalysis/TopHitFit/interface/Fit_Result.h"
0035 #include <ostream>
0036 #include <cmath>
0037 
0038 using std::abs;
0039 using std::ostream;
0040 
0041 namespace hitfit {
0042 
0043   Fit_Result::Fit_Result(double chisq,
0044                          const Lepjets_Event& ev,
0045                          const Column_Vector& pullx,
0046                          const Column_Vector& pully,
0047                          double umwhad,
0048                          double utmass,
0049                          double mt,
0050                          double sigmt)
0051       //
0052       // Purpose: Constructor.
0053       //
0054       // Inputs:
0055       //   chisq -       The fit chisq.
0056       //   ev -          The event kinematics.
0057       //   pullx -       The pull quantities for the well-measured variables.
0058       //   pully -       The pull quantities for the poorly-measured variables.
0059       //   umwhad -      The hadronic W mass before the fit.
0060       //   utmass -      The top quark mass before the fit.
0061       //   mt -          The top quark mass after the fit.
0062       //   sigmt -       The top quark mass uncertainty after the fit.
0063       //
0064       : _chisq(chisq), _umwhad(umwhad), _utmass(utmass), _mt(mt), _sigmt(sigmt), _pullx(pullx), _pully(pully), _ev(ev) {}
0065 
0066   double Fit_Result::chisq() const
0067   //
0068   // Purpose: Return the fit chisq.
0069   //
0070   // Returns:
0071   //   Return the fit chisq.
0072   //
0073   {
0074     return _chisq;
0075   }
0076 
0077   double Fit_Result::umwhad() const
0078   //
0079   // Purpose: Return the hadronic W mass before the fit.
0080   //
0081   // Returns:
0082   //   The hadronic W mass before the fit.
0083   //
0084   {
0085     return _umwhad;
0086   }
0087 
0088   double Fit_Result::utmass() const
0089   //
0090   // Purpose: Return the top mass before the fit.
0091   //
0092   // Returns:
0093   //   The top mass before the fit.
0094   //
0095   {
0096     return _utmass;
0097   }
0098 
0099   double Fit_Result::mt() const
0100   //
0101   // Purpose: Return the top mass after the fit.
0102   //
0103   // Returns:
0104   //   The top mass after the fit.
0105   //
0106   {
0107     return _mt;
0108   }
0109 
0110   double Fit_Result::sigmt() const
0111   //
0112   // Purpose: Return the top mass uncertainty after the fit.
0113   //
0114   // Returns:
0115   //   The top mass uncertainty after the fit.
0116   //
0117   {
0118     return _sigmt;
0119   }
0120 
0121   const Column_Vector& Fit_Result::pullx() const
0122   //
0123   // Purpose: Return the pull quantities for the well-measured variables.
0124   //
0125   // Returns:
0126   //   The pull quantities for the well-measured variables.
0127   //
0128   {
0129     return _pullx;
0130   }
0131 
0132   const Column_Vector& Fit_Result::pully() const
0133   //
0134   // Purpose: Return the pull quantities for the poorly-measured variables.
0135   //
0136   // Returns:
0137   //   The pull quantities for the poorly-measured variables.
0138   //
0139   {
0140     return _pully;
0141   }
0142 
0143   std::vector<int> Fit_Result::jet_types()
0144   //
0145   // Purpose: Returns the jet types of the fit
0146   //
0147   {
0148     return _ev.jet_types();
0149   }
0150 
0151   const Lepjets_Event& Fit_Result::ev() const
0152   //
0153   // Purpose: Return the event kinematic quantities after the fit.
0154   //
0155   // Returns:
0156   //   The event kinematic quantities after the fit.
0157   //
0158   {
0159     return _ev;
0160   }
0161 
0162   /**
0163     @brief Sort fit results based on their \f$\chi^{2}\f$.
0164 
0165     @param a The first instance of Fit_Result to compare.
0166 
0167     @param b The second instance of Fit_Result to compare.
0168 
0169     @par Return:
0170     <b>TRUE</b> if the first instance has smaller absolute value of
0171     \f$\chi^{2}\f$ than b.<br>
0172     <b>FALSE</b> all other cases.
0173 */
0174   bool operator<(const Fit_Result& a, const Fit_Result& b)
0175   //
0176   // Purpose: Compare two objects by chisq.
0177   //          The use of abs() is to make sure that the -1000 flags
0178   //          go to the end.
0179   //
0180   // Inputs:
0181   //   a -           The first object to compare.
0182   //   b -           The second object to compare.
0183   //
0184   // Returns:
0185   //   The result of the comparison.
0186   //
0187   {
0188     return abs(a._chisq) < abs(b._chisq);
0189   }
0190 
0191   /**
0192      @brief Output stream operator, print the content of this Fit_Result to
0193      an output stream.
0194 
0195      @param s The output stream to which to write.
0196 
0197      @param res The instance of Fit_Result to be printed.
0198    */
0199   std::ostream& operator<<(std::ostream& s, const Fit_Result& res)
0200   //
0201   // Purpose: Print the object to S.
0202   //
0203   // Inputs:
0204   //   s -           The stream to which to write.
0205   //   res -         The object to write.
0206   //
0207   // Returns:
0208   //   The stream S.
0209   //
0210   {
0211     s << "chisq: " << res._chisq << "\n";
0212     s << "umwhad: " << res._umwhad << "\n";
0213     s << "utmass: " << res._utmass << "\n";
0214     s << "mt: " << res._mt << "\n";
0215     s << "sigmt: " << res._sigmt << "\n";
0216     s << res._ev;
0217     s << "pullx: " << res._pullx.T();
0218     s << "pully: " << res._pully.T();
0219     return s;
0220   }
0221 
0222 }  // namespace hitfit