MC_TTBAR.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #include "Rivet/Analysis.hh"
00003 #include "Rivet/RivetAIDA.hh"
00004 #include "Rivet/Tools/Logging.hh"
00005 #include "Rivet/Projections/ChargedFinalState.hh"
00006 
00007 namespace Rivet {
00008 
00009 
00010   /// @brief MC validation analysis for Z + jets events
00011   /// @todo More! This analysis just checks the \f$ \eta \f$ distribution at the moment.
00012   class MC_TTBAR : public Analysis {
00013   public:
00014 
00015     /// @name Constructors etc.
00016     //@{
00017 
00018     /// Constructor
00019     MC_TTBAR()
00020       : Analysis("MC_TTBAR")
00021     {
00022       //setNeedsCrossSection(false);
00023     }
00024 
00025     //@}
00026 
00027 
00028   public:
00029 
00030     /// @name Analysis methods
00031     //@{
00032 
00033     /// Book histograms and initialise projections before the run
00034     void init() {
00035 
00036       const ChargedFinalState cfs(-5.0, 5.0);
00037       addProjection(cfs, "CFS");
00038 
00039       /// @todo Book histograms here, e.g.:
00040       _hist_nch_eta = bookHistogram1D("nch-eta", 20, -5.0, 5.0);
00041       _hist_nch_pt  = bookHistogram1D("nch-pt", 100, 0.0, 200.0);
00042       _hist_nch_phi = bookHistogram1D("nch-phi", 100, 0.0, TWOPI);
00043 
00044     }
00045 
00046 
00047     /// Perform the per-event analysis
00048     void analyze(const Event& event) {
00049       const double weight = event.weight();
00050       const ChargedFinalState& cfs = applyProjection<ChargedFinalState>(event, "CFS");
00051 
00052       foreach (const Particle& p, cfs.particles()) {
00053         double eta = p.momentum().pseudorapidity();
00054         double pT = p.momentum().perp();
00055         double phi = p.momentum().phi();
00056         _hist_nch_eta->fill(eta, weight);
00057         _hist_nch_pt->fill(pT, weight);
00058         _hist_nch_phi->fill(phi, weight);
00059       }
00060 
00061     }
00062 
00063 
00064     /// Normalise histograms etc., after the run
00065     void finalize() {
00066       scale(_hist_nch_eta, 1.0/sumOfWeights());
00067       scale(_hist_nch_pt,  1.0/sumOfWeights());
00068       scale(_hist_nch_phi, 1.0/sumOfWeights());
00069     }
00070 
00071 
00072   private:
00073 
00074     /// @name Histograms
00075     //@{
00076     AIDA::IHistogram1D* _hist_nch_eta;
00077     AIDA::IHistogram1D* _hist_nch_pt;
00078     AIDA::IHistogram1D* _hist_nch_phi;
00079     //@}
00080 
00081   };
00082 
00083 
00084 
00085   // This global object acts as a hook for the plugin system
00086   AnalysisBuilder<MC_TTBAR> plugin_MC_TTBAR;
00087 
00088 
00089 }