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_Results.cc
0004 // Purpose: Hold the results from kinematic fitting.
0005 // Created: Jul, 2000, sss, based on run 1 mass analysis code.
0006 //
0007 // CMSSW File      : src/Fit_Results.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 #include "TopQuarkAnalysis/TopHitFit/interface/Fit_Results.h"
0013 #include "TopQuarkAnalysis/TopHitFit/interface/Fit_Result.h"
0014 #include <ostream>
0015 #include <cassert>
0016 
0017 /**
0018     @file Fit_Results.cc
0019 
0020     @brief Holds set(s) of results from
0021     more than one kinematic fits.  See the documentation for the header file
0022     Fit_Results.h for details.
0023 
0024     @author Scott Stuart Snyder <snyder@bnl.gov>
0025 
0026     @par Creation date:
0027     Jul 2000.
0028 
0029     @par Modification History:
0030     Apr 2009: Haryo Sumowidagdo <Suharyo.Sumowidagdo@cern.ch>:
0031     Imported to CMSSW.<br>
0032     Nov 2009: Haryo Sumowidagdo <Suharyo.Sumowidagdo@cern.ch>:
0033     Added Doxygen tags for automatic generation of documentation.
0034 
0035     @par Terms of Usage:
0036     With consent from the original author (Scott Snyder).
0037  */
0038 
0039 using std::ostream;
0040 
0041 namespace hitfit {
0042 
0043   Fit_Results::Fit_Results(int max_len, int n_lists)
0044       //
0045       // Purpose: Constructor.
0046       //
0047       // Inputs:
0048       //   max_len -     The maximum length of each list.
0049       //   n_lists -     The number of lists.
0050       //
0051       : _v(n_lists, Fit_Result_Vec(max_len)) {}
0052 
0053   const Fit_Result_Vec& Fit_Results::operator[](std::vector<Fit_Result_Vec>::size_type i) const {
0054     assert(i < _v.size());
0055     return _v[i];
0056   }
0057 
0058   void Fit_Results::push(double chisq,
0059                          const Lepjets_Event& ev,
0060                          const Column_Vector& pullx,
0061                          const Column_Vector& pully,
0062                          double umwhad,
0063                          double utmass,
0064                          double mt,
0065                          double sigmt,
0066                          const std::vector<int>& list_flags)
0067   //
0068   // Purpose: Add a new fit result.
0069   //
0070   // Inputs:
0071   //   chisq -       The fit chisq.
0072   //   ev -          The event kinematics.
0073   //   pullx -       The pull quantities for the well-measured variables.
0074   //   pully -       The pull quantities for the poorly-measured variables.
0075   //   umwhad -      The hadronic W mass before the fit.
0076   //   utmass -      The top quark mass before the fit.
0077   //   mt -          The top quark mass after the fit.
0078   //   sigmt -       The top quark mass uncertainty after the fit.
0079   //   list_flags -  Vector indicating to which lists the result should
0080   //                 be added.
0081   //                 This vector should have a length of N_SIZE.
0082   //                 Each element should be either 0 or 1, depending
0083   //                 on whether or not the result should be added
0084   //                 to the corresponding list.
0085   //
0086   {
0087     assert(list_flags.size() == _v.size());
0088 
0089     auto res = std::make_shared<Fit_Result>(chisq, ev, pullx, pully, umwhad, utmass, mt, sigmt);
0090     for (std::vector<Fit_Result_Vec>::size_type i = 0; i < _v.size(); i++) {
0091       if (list_flags[i])
0092         _v[i].push(res);
0093     }
0094   }
0095 
0096   /**
0097      @brief Output stream operator, print the content of this Fit_Results to
0098      an output stream.
0099 
0100      @param s The output stream to which to write.
0101 
0102      @param res The instance Fit_Results to be printed.
0103    */
0104   std::ostream& operator<<(std::ostream& s, const Fit_Results& res)
0105   //
0106   // Purpose: Print the object to S.
0107   //
0108   // Inputs:
0109   //   s -           The stream to which to write.
0110   //   res -         The object to write.
0111   //
0112   // Returns:
0113   //   The stream S.
0114   //
0115   {
0116     for (std::vector<Fit_Result_Vec>::size_type i = 0; i < res._v.size(); i++)
0117       s << "List " << i << "\n" << res._v[i];
0118     return s;
0119   }
0120 
0121 }  // namespace hitfit