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
  • Christian Gutschow
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. This analysis will not produce sensible distributions in case of correlated NLO sub-events.

Source code: MC_WEIGHTS.cc
 1// -*- C++ -*-
 2#include "Rivet/Analysis.hh"
 3#include "Rivet/AnalysisHandler.hh"
 4
 5namespace Rivet {
 6
 7
 8  /// Analysis of the generated event-weight distributions
 9  class MC_WEIGHTS : public Analysis {
10  public:
11
12    RIVET_DEFAULT_ANALYSIS_CTOR(MC_WEIGHTS);
13
14
15    /// @name Analysis methods
16    /// @{
17
18    /// Book histograms and initialise projections before the run
19    void init() {
20      /// @todo Convert to Scatter1D or Counter
21      book(_h_weight_100, "weight_100", 200, -100.0, 100.0);
22      book(_h_weight_10,  "weight_10",  200,  -10.0,  10.0);
23      book(_h_logweight_pos, "logweight_pos", logspace(100, 0.1, 10000.0));
24      book(_h_logweight_neg, "logweight_neg", logspace(100, 0.1, 10000.0));
25
26      book(_h_xsfraction_neg, "xsfraction_neg");
27    }
28
29
30    /// Perform the per-event analysis
31    void analyze(const Event& event) {
32
33      const size_t numWeights = event.weights().size();
34      for (size_t m = 0; m < numWeights; ++m) {
35        const double weight = event.weights()[m];
36        _h_weight_100.get()->_getPersistent(m)->fill(weight, 1.0);
37        _h_weight_10.get()->_getPersistent(m)->fill(weight, 1.0);
38        if (weight < 0.) {
39          _h_logweight_neg.get()->_getPersistent(m)->fill(fabs(weight), 1.0);
40        } else {
41          _h_logweight_pos.get()->_getPersistent(m)->fill(weight, 1.0);
42        }
43      }
44    }
45
46
47    /// Normalise histograms etc., after the run
48    void finalize() {
49      const double sf = 1.0 / numEvents();
50      scale(_h_weight_100, sf);
51      scale(_h_weight_10, sf);
52      scale(_h_logweight_pos, sf);
53      scale(_h_logweight_neg, sf);
54
55      const double totalSumW  = _h_logweight_neg->sumW() + _h_logweight_pos->sumW();
56      const double totalSumW2 = _h_logweight_neg->sumW2() + _h_logweight_pos->sumW2();
57      const double negFrac = _h_logweight_neg->sumW() / totalSumW;
58      const double negFracErr = negFrac * totalSumW / sqrt(totalSumW2);
59      _h_xsfraction_neg->addPoint(0, negFrac, 0.5, negFracErr);
60    }
61
62    /// @}
63
64
65    /// @name Histograms
66    /// @{
67    Scatter2DPtr _h_xsfraction_neg;
68    Histo1DPtr _h_weight_100, _h_weight_10, _h_logweight_pos, _h_logweight_neg;
69    /// @}
70
71  };
72
73
74
75  RIVET_DECLARE_PLUGIN(MC_WEIGHTS);
76
77}