Rivet is hosted by Hepforge, IPPP Durham

## Rivet analyses reference

### MC_WEIGHTS

MC analysis for distributions of event weights
Experiment: ()
Status: VALIDATED
Authors:
• Frank Siegert
No references listed
Beams: * *
Beam energies: ANY
Run details:
• Suitable for any process.

Analysis for studying event weight distributions and fraction of events with negative weights.

Source code: MC_WEIGHTS.cc
  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 // -*- C++ -*- #include "Rivet/Analysis.hh" namespace Rivet { /// @brief Analysis for the generated cross section class MC_WEIGHTS : public Analysis { public: /// @name Constructors etc. //@{ /// Constructor MC_WEIGHTS() : Analysis("MC_WEIGHTS") { } //@} public: /// @name Analysis methods //@{ /// Book histograms and initialise projections before the run void init() { /// @todo Convert to Scatter1D or Counter _h_weight_100 = bookHisto1D("weight_100", 200, -100.0, 100.0); _h_weight_10 = bookHisto1D("weight_10", 200, -10.0, 10.0); _h_logweight_pos = bookHisto1D("logweight_pos", logspace(100, 0.1, 10000.0)); _h_logweight_neg = bookHisto1D("logweight_neg", logspace(100, 0.1, 10000.0)); _h_xsfraction_neg = bookScatter2D("xsfraction_neg"); _sow_pos = _sow_neg = _nevts = 0.; } /// Perform the per-event analysis void analyze(const Event& event) { double w = event.weight(); _nevts += 1.0; _h_weight_100->fill(w, 1.0); _h_weight_10->fill(w, 1.0); if (w<0.0) { _h_logweight_neg->fill(fabs(w), 1.0); _sow_neg += fabs(w); } else { _h_logweight_pos->fill(w, 1.0); _sow_pos += w; } } /// Normalise histograms etc., after the run void finalize() { scale(_h_weight_100, 1.0/_nevts); scale(_h_weight_10, 1.0/_nevts); scale(_h_logweight_pos, 1.0/_nevts); scale(_h_logweight_neg, 1.0/_nevts); /// @todo correct unc estimate: _h_xsfraction_neg->addPoint(0, _sow_neg/(_sow_neg+_sow_pos), 0.5, 0.0); } //@} private: /// @name Histograms //@{ Scatter2DPtr _h_xsfraction_neg; Histo1DPtr _h_weight_100, _h_weight_10, _h_logweight_pos, _h_logweight_neg; double _sow_pos, _sow_neg, _nevts; //@} }; // The hook for the plugin system DECLARE_RIVET_PLUGIN(MC_WEIGHTS); }