Rivet analyses referenceCMS_2011_I883318$B^+$ cross section at 7 TeVExperiment: CMS (LHC) Inspire ID: 883318 Status: VALIDATED Authors:
Beam energies: (3500.0, 3500.0) GeV Run details:
Measurement of the cross section for the production of $B^+$ mesons at 7 TeV by the CMS experiment. Source code: CMS_2011_I883318.cc 1// -*- C++ -*-
2#include "Rivet/Analysis.hh"
3#include "Rivet/Projections/UnstableParticles.hh"
4
5namespace Rivet {
6
7
8 /// @brief B+ at 7 TeV
9 class CMS_2011_I883318 : public Analysis {
10 public:
11
12 /// Constructor
13 RIVET_DEFAULT_ANALYSIS_CTOR(CMS_2011_I883318);
14
15
16 /// @name Analysis methods
17 /// @{
18
19 /// Book histograms and initialise projections before the run
20 void init() {
21 // projection
22 declare(UnstableParticles(), "UFS");
23 // histograms
24 book(_h_total, 1, 1, 1);
25 book(_h_pT , 2, 1, 1);
26 book(_h_y , 3, 1, 1);
27 }
28
29
30 /// Perform the per-event analysis
31 void analyze(const Event& event) {
32 if (_edges[0].empty()) {
33 _edges[0] = _h_total->xEdges();
34 _edges[1] = _h_pT->xEdges();
35 }
36 // Final state of unstable particles to get particle spectra
37 const UnstableParticles& ufs = apply<UnstableParticles>(event, "UFS");
38 // loop over B+ states
39 for (const Particle& p : ufs.particles(Cuts::abspid==521)) {
40 // cuts on pT and rapidity
41 const double y = p.absrap();
42 const double pT = p.perp();
43 if (pT<5. || y>2.4) continue;
44 _h_total->fill(_edges[0][0]);
45 const size_t idx = _axis.index(pT);
46 const string edge = (idx&&idx<_edges[1].size()) ? _edges[1][idx-1] : "OTHER"s;
47 _h_pT->fill(edge);
48 _h_y->fill(y);
49 }
50 }
51
52
53 /// Normalise histograms etc., after the run
54 void finalize() {
55 const double fact = 0.5*crossSection()/microbarn/sumOfWeights();
56 scale(_h_total, fact);
57 scale(_h_pT, fact);
58 for (auto& b : _h_pT->bins()) {
59 const size_t idx = b.index();
60 b.scaleW(1.0/_axis.width(idx));
61 }
62 // 0.5 from +/- y
63 scale(_h_y, 0.5*fact);
64 }
65
66 /// @}
67
68
69 /// @name Histograms
70 /// @{
71 BinnedHistoPtr<string> _h_total,_h_pT;
72 Histo1DPtr _h_y;
73 vector<string> _edges[2];
74 YODA::Axis<double> _axis{5.0,10.0,13.0,17.0,24.0,30.0};
75 /// @}
76
77
78 };
79
80
81 RIVET_DECLARE_PLUGIN(CMS_2011_I883318);
82
83}
|