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
| // -*- C++ -*-
#include "Rivet/Analysis.hh"
#include "Rivet/Projections/FinalState.hh"
namespace Rivet {
/// @brief Just measures a few random things as an example.
class EXAMPLE_CUTS : public Analysis {
public:
/// Constructor
RIVET_DEFAULT_ANALYSIS_CTOR(EXAMPLE_CUTS);
/// @name Analysis methods
//@{
/// Set up projections and book histograms
void init() {
// Projections
const FinalState cnfs(Cuts::abseta < 4);
declare(cnfs, "FS");
// Histograms
book(_histPt ,"pT", 30, 0, 30);
book(_histMass ,"Mass", 20, 0, 1);
}
/// Do the analysis
void analyze(const Event& event) {
const Particles ps = apply<FinalState>(event, "FS").particlesByPt();
Cut ptcut = Cuts::range(Cuts::pT, 5, 20);
Cut masscut = Cuts::range(Cuts::mass, 0, 0.2);
Cut combine = ptcut && masscut; //< Possible to combine cuts
for (const Particle& p : ps) {
if ( ptcut->accept(p) )
_histPt->fill(p.pT());
if ( combine->accept(p) )
_histMass->fill(p.mass());
}
}
/// Finalize
void finalize() {
normalize(_histPt); normalize(_histMass);
}
//@}
//@{
/// Histograms
Histo1DPtr _histPt, _histMass;
//@}
};
// The hook for the plugin system
RIVET_DECLARE_PLUGIN(EXAMPLE_CUTS);
}
|