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 /// @todo Include more projections as required, e.g. ChargedFinalState, FastJets, ZFinder... 00007 00008 namespace Rivet { 00009 00010 00011 class MC_TTBAR : public Analysis { 00012 public: 00013 00014 /// @name Constructors etc. 00015 //@{ 00016 00017 /// Constructor 00018 MC_TTBAR() 00019 : Analysis("MC_TTBAR") 00020 { 00021 //setNeedsCrossSection(false); 00022 } 00023 00024 //@} 00025 00026 00027 public: 00028 00029 /// @name Analysis methods 00030 //@{ 00031 00032 /// Book histograms and initialise projections before the run 00033 void init() { 00034 00035 const ChargedFinalState cfs(-5.0, 5.0); 00036 addProjection(cfs, "CFS"); 00037 00038 /// @todo Book histograms here, e.g.: 00039 _hist_nch_eta = bookHistogram1D("nch-eta", 20, -5.0, 5.0); 00040 00041 } 00042 00043 00044 /// Perform the per-event analysis 00045 void analyze(const Event& event) { 00046 const double weight = event.weight(); 00047 const ChargedFinalState& cfs = applyProjection<ChargedFinalState>(event, "CFS"); 00048 00049 foreach (const Particle& p, cfs.particles()) { 00050 double eta = p.momentum().pseudorapidity(); 00051 _hist_nch_eta->fill(eta, weight); 00052 } 00053 00054 } 00055 00056 00057 /// Normalise histograms etc., after the run 00058 void finalize() { 00059 scale(_hist_nch_eta, 1.0/sumOfWeights()); 00060 } 00061 00062 00063 private: 00064 00065 /// @name Histograms 00066 //@{ 00067 AIDA::IHistogram1D* _hist_nch_eta; 00068 //@} 00069 00070 }; 00071 00072 00073 00074 // This global object acts as a hook for the plugin system 00075 AnalysisBuilder<MC_TTBAR> plugin_MC_TTBAR; 00076 00077 00078 }