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