MC_XS.cc
Go to the documentation of this file.
00001 // -*- C++ -*- 00002 #include "Rivet/Analysis.hh" 00003 #include "HepMC/HepMCDefs.h" 00004 00005 namespace Rivet { 00006 00007 00008 /// @brief Analysis for the generated cross section 00009 class MC_XS : public Analysis { 00010 public: 00011 00012 /// @name Constructors etc. 00013 //@{ 00014 00015 /// Constructor 00016 MC_XS() 00017 : Analysis("MC_XS") 00018 { } 00019 00020 //@} 00021 00022 00023 public: 00024 00025 /// @name Analysis methods 00026 //@{ 00027 00028 /// Book histograms and initialise projections before the run 00029 void init() { 00030 /// @todo Convert to Scatter1D or Counter 00031 _h_XS = bookScatter2D("XS"); 00032 _h_N = bookHisto1D("N", 1, 0.0, 1.0); 00033 _h_pmXS = bookHisto1D("pmXS", 2, -1.0, 1.0); 00034 _h_pmN = bookHisto1D("pmN", 2, -1.0, 1.0); 00035 _mc_xs = _mc_error = 0.; 00036 } 00037 00038 00039 /// Perform the per-event analysis 00040 void analyze(const Event& event) { 00041 _h_N->fill(0.5,1.); 00042 _h_pmXS->fill(0.5*(event.weight() > 0 ? 1. : -1), abs(event.weight())); 00043 _h_pmN ->fill(0.5*(event.weight() > 0 ? 1. : -1), 1.); 00044 #ifdef HEPMC_HAS_CROSS_SECTION 00045 _mc_xs = event.genEvent()->cross_section()->cross_section(); 00046 _mc_error = event.genEvent()->cross_section()->cross_section_error(); 00047 #endif 00048 } 00049 00050 00051 /// Normalise histograms etc., after the run 00052 void finalize() { 00053 scale(_h_pmXS, crossSection()/sumOfWeights()); 00054 #ifndef HEPMC_HAS_CROSS_SECTION 00055 _mc_xs = crossSection(); 00056 _mc_error = 0.0; 00057 #endif 00058 _h_XS->addPoint(0, _mc_xs, 0.5, _mc_error); 00059 } 00060 00061 //@} 00062 00063 00064 private: 00065 00066 /// @name Histograms 00067 //@{ 00068 Scatter2DPtr _h_XS; 00069 Histo1DPtr _h_N; 00070 Histo1DPtr _h_pmXS; 00071 Histo1DPtr _h_pmN; 00072 double _mc_xs, _mc_error; 00073 //@} 00074 00075 }; 00076 00077 00078 // The hook for the plugin system 00079 DECLARE_RIVET_PLUGIN(MC_XS); 00080 00081 } Generated on Tue May 13 2014 11:38:28 for The Rivet MC analysis system by ![]() |