CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CMS_TEST_ANALYSIS.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 #include "Rivet/Analysis.hh"
3 #include "Rivet/RivetAIDA.hh"
4 #include "Rivet/Tools/Logging.hh"
5 #include "Rivet/Projections/FinalState.hh"
6 #include "Rivet/Projections/FastJets.hh"
7 #include "Rivet/Projections/WFinder.hh"
8 #include "Rivet/Projections/ZFinder.hh"
9 #include "Rivet/Particle.hh"
10 #include "Rivet/Tools/ParticleIdUtils.hh"
11 #include "fastjet/tools/Filter.hh"
12 #include "fastjet/tools/Pruner.hh"
13 
14 namespace Rivet {
15 
16 
17  class CMS_TEST_ANALYSIS : public Analysis {
18  public:
19 
21 
22 
25  : Analysis("CMS_TEST_ANALYSIS"),
26  _filter(fastjet::Filter(fastjet::JetDefinition(fastjet::cambridge_algorithm, 0.3), fastjet::SelectorNHardest(3))),
27  _trimmer(fastjet::Filter(fastjet::JetDefinition(fastjet::kt_algorithm, 0.2), fastjet::SelectorPtFractionMin(0.03))),
28  _pruner(fastjet::Pruner(fastjet::cambridge_algorithm, 0.1, 0.5))
29  { }
30 
32 
33 
34  public:
35 
37 
38 
40  void init() {
41  FinalState fs(-2.4, 2.4, 0*GeV);
42  addProjection(fs, "FS");
43 
44  // Jet collections
45  addProjection(FastJets(fs, FastJets::ANTIKT, 0.7), "JetsAK7");
46  addProjection(FastJets(fs, FastJets::CAM, 0.8), "JetsCA8");
47  addProjection(FastJets(fs, FastJets::CAM, 1.2), "JetsCA12");
48 
49  // Histograms
50  for (size_t i = 0; i < N_PT_BINS_dj; ++i ) {
51  _h_ungroomedAvgJetMass_dj[i] = bookHistogram1D(i+1+0*N_PT_BINS_dj, 1, 1);
52  _h_filteredAvgJetMass_dj[i] = bookHistogram1D(i+1+1*N_PT_BINS_dj, 1, 1);
53  _h_trimmedAvgJetMass_dj[i] = bookHistogram1D(i+1+2*N_PT_BINS_dj, 1, 1);
54  _h_prunedAvgJetMass_dj[i] = bookHistogram1D(i+1+3*N_PT_BINS_dj, 1, 1);
55  }
56  }
57 
58 
59  // Find the pT histogram bin index for value pt (in GeV), to hack a 2D histogram equivalent
61  size_t findPtBin(double ptJ) {
62  const double ptBins_dj[N_PT_BINS_dj+1] = { 220.0, 300.0, 450.0, 500.0, 600.0, 800.0, 1000.0, 1500.0};
63  for (size_t ibin = 0; ibin < N_PT_BINS_dj; ++ibin) {
64  if (inRange(ptJ, ptBins_dj[ibin], ptBins_dj[ibin+1])) return ibin;
65  }
66  return N_PT_BINS_dj;
67  }
68 
69 
71  void analyze(const Event& event) {
72  const double weight = event.weight();
73 
74  // Look at events with >= 2 jets
75  const PseudoJets& psjetsAK7 = applyProjection<FastJets>(event, "JetsAK7").pseudoJetsByPt( 50.0*GeV );
76  if (psjetsAK7.size() < 2) vetoEvent;
77 
78  // Get the leading two jets and find their average pT
79  const fastjet::PseudoJet& j0 = psjetsAK7[0];
80  const fastjet::PseudoJet& j1 = psjetsAK7[1];
81  double ptAvg = 0.5 * (j0.pt() + j1.pt());
82 
83  // Find the appropriate mean pT bin and escape if needed
84  const size_t njetBin = findPtBin(ptAvg/GeV);
85  if (njetBin >= N_PT_BINS_dj) vetoEvent;
86 
87  // Now run the substructure algs...
88  fastjet::PseudoJet filtered0 = _filter(j0);
89  fastjet::PseudoJet filtered1 = _filter(j1);
90  fastjet::PseudoJet trimmed0 = _trimmer(j0);
91  fastjet::PseudoJet trimmed1 = _trimmer(j1);
92  fastjet::PseudoJet pruned0 = _pruner(j0);
93  fastjet::PseudoJet pruned1 = _pruner(j1);
94 
95  // ... and fill the histograms
96  _h_ungroomedAvgJetMass_dj[njetBin]->fill(0.5*(j0.m() + j1.m())/GeV, weight);
97  _h_filteredAvgJetMass_dj[njetBin]->fill(0.5*(filtered0.m() + filtered1.m())/GeV, weight);
98  _h_trimmedAvgJetMass_dj[njetBin]->fill(0.5*(trimmed0.m() + trimmed1.m())/GeV, weight);
99  _h_prunedAvgJetMass_dj[njetBin]->fill(0.5*(pruned0.m() + pruned1.m())/GeV, weight);
100  }
101 
102 
104  void finalize() {
105  const double normalizationVal = 1000;
106  for (size_t i = 0; i < N_PT_BINS_dj; ++i) {
107  normalize(_h_ungroomedAvgJetMass_dj[i], normalizationVal);
108  normalize(_h_filteredAvgJetMass_dj[i], normalizationVal);
109  normalize(_h_trimmedAvgJetMass_dj[i], normalizationVal);
110  normalize(_h_prunedAvgJetMass_dj[i], normalizationVal);
111  }
112  }
113 
115 
116 
117  private:
118 
120 
123  const fastjet::Pruner _pruner;
125 
126 
128 
131  AIDA::IHistogram1D *_h_ungroomedJet0pt, *_h_ungroomedJet1pt;
134  AIDA::IHistogram1D* _h_trimmedAvgJetMass_dj[N_PT_BINS_dj];
135  AIDA::IHistogram1D* _h_prunedAvgJetMass_dj[N_PT_BINS_dj];
137 
138 
139  };
140 
141 
142 
143  // The hook for the plugin system
145 
146 
147 }
int i
Definition: DBlmapReader.cc:9
tuple Filter
Definition: Filter_cff.py:5
AIDA::IHistogram1D * _h_prunedAvgJetMass_dj[N_PT_BINS_dj]
AIDA::IHistogram1D * _h_ungroomedJet1pt
DECLARE_RIVET_PLUGIN(CMS_TEST_ANALYSIS)
AIDA::IHistogram1D * _h_trimmedAvgJetMass_dj[N_PT_BINS_dj]
size_t findPtBin(double ptJ)
void analyze(const Event &event)
Perform the per-event analysis.
AIDA::IHistogram1D * _h_filteredAvgJetMass_dj[N_PT_BINS_dj]
AIDA::IHistogram1D * _h_ungroomedAvgJetMass_dj[N_PT_BINS_dj]
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
void finalize()
Normalise histograms etc., after the run.
const fastjet::Filter _filter
void init()
Book histograms and initialise projections before the run.
CMS_TEST_ANALYSIS()
Constructor.
AIDA::IHistogram1D * _h_ungroomedJet0pt
enum Rivet::CMS_TEST_ANALYSIS::@478 BINS_dj
const fastjet::Filter _trimmer
const fastjet::Pruner _pruner