CMS 3D CMS Logo

RivetAnalysis.h
Go to the documentation of this file.
1 #ifndef GeneratorInterface_RivetInterface_RivetAnalysis_H
2 #define GeneratorInterface_RivetInterface_RivetAnalysis_H
3 
5 
6 #include "Rivet/Analysis.hh"
7 #include "Rivet/Projections/FinalState.hh"
8 #include "Rivet/Particle.hh"
9 #include "Rivet/Particle.fhh"
10 #include "Rivet/Event.hh"
11 #include "Rivet/Projections/FastJets.hh"
12 #include "Rivet/Projections/JetAlg.hh"
13 #include "Rivet/Projections/ChargedLeptons.hh"
14 #include "Rivet/Projections/PromptFinalState.hh"
15 #include "Rivet/Projections/DressedLeptons.hh"
16 #include "Rivet/Projections/VetoedFinalState.hh"
17 #include "Rivet/Projections/IdentifiedFinalState.hh"
18 #include "Rivet/Projections/MissingMomentum.hh"
19 #include "Rivet/Tools/RivetHepMC.hh"
20 
21 namespace Rivet {
22 
23  class RivetAnalysis : public Analysis {
24 
25  public:
26  std::vector<DressedLepton> leptons() const {return _leptons;}
27  ParticleVector photons() const {return _photons;}
28  ParticleVector neutrinos() const {return _neutrinos;}
29  Jets jets() const {return _jets;}
30  Jets fatjets() const {return _fatjets;}
31  Vector3 met() const {return _met;}
32 
33  private:
37 
42 
44 
45  std::vector<DressedLepton> _leptons;
46  ParticleVector _photons, _neutrinos;
47  Jets _jets, _fatjets;
48  Vector3 _met;
49 
50  public:
51  RivetAnalysis(const edm::ParameterSet& pset) : Analysis("RivetAnalysis"),
52  _usePromptFinalStates(pset.getParameter<bool>("usePromptFinalStates")),
53  _excludePromptLeptonsFromJetClustering(pset.getParameter<bool>("excludePromptLeptonsFromJetClustering")),
54  _excludeNeutrinosFromJetClustering(pset.getParameter<bool>("excludeNeutrinosFromJetClustering")),
55 
56  _particleMinPt (pset.getParameter<double>("particleMinPt")),
57  _particleMaxEta (pset.getParameter<double>("particleMaxEta")),
58 
59  _lepConeSize (pset.getParameter<double>("lepConeSize")),
60  _lepMinPt (pset.getParameter<double>("lepMinPt")),
61  _lepMaxEta (pset.getParameter<double>("lepMaxEta")),
62 
63  _jetConeSize (pset.getParameter<double>("jetConeSize")),
64  _jetMinPt (pset.getParameter<double>("jetMinPt")),
65  _jetMaxEta (pset.getParameter<double>("jetMaxEta")),
66 
67  _fatJetConeSize (pset.getParameter<double>("fatJetConeSize")),
68  _fatJetMinPt (pset.getParameter<double>("fatJetMinPt")),
69  _fatJetMaxEta (pset.getParameter<double>("fatJetMaxEta")),
70 
71  _phoMinPt (pset.getParameter<double>("phoMinPt")),
72  _phoMaxEta (pset.getParameter<double>("phoMaxEta")),
73  _phoIsoConeSize (pset.getParameter<double>("phoIsoConeSize")),
74  _phoMaxRelIso (pset.getParameter<double>("phoMaxRelIso"))
75  {
76  }
77 
78  // Initialize Rivet projections
79  void init() override {
80  // Cuts
81  Cut particle_cut = (Cuts::abseta < _particleMaxEta) and (Cuts::pT > _particleMinPt*GeV);
82  Cut lepton_cut = (Cuts::abseta < _lepMaxEta) and (Cuts::pT > _lepMinPt*GeV);
83 
84  // Generic final state
85  FinalState fs(particle_cut);
86 
87  addProjection(fs, "FS");
88 
89  // Dressed leptons
90  ChargedLeptons charged_leptons(fs);
91  IdentifiedFinalState photons(fs);
92  photons.acceptIdPair(PID::PHOTON);
93 
94  PromptFinalState prompt_leptons(charged_leptons);
95  prompt_leptons.acceptMuonDecays(true);
96  prompt_leptons.acceptTauDecays(true);
97 
98  PromptFinalState prompt_photons(photons);
99  prompt_photons.acceptMuonDecays(true);
100  prompt_photons.acceptTauDecays(true);
101 
102  // useDecayPhotons=true allows for photons with tau ancestor,
103  // photons from hadrons are vetoed by the PromptFinalState;
104  // will be default DressedLeptons behaviour for Rivet >= 2.5.4
105  DressedLeptons dressed_leptons(prompt_photons, prompt_leptons, _lepConeSize,
106  lepton_cut, /*cluster*/ true, /*useDecayPhotons*/ true);
107  if (not _usePromptFinalStates)
108  dressed_leptons = DressedLeptons(photons, charged_leptons, _lepConeSize,
109  lepton_cut, /*cluster*/ true, /*useDecayPhotons*/ true);
110  addProjection(dressed_leptons, "DressedLeptons");
111 
112  // Photons
113  addProjection(photons, "Photons");
114 
115  // Jets
116  VetoedFinalState fsForJets(fs);
117  if (_usePromptFinalStates and _excludePromptLeptonsFromJetClustering)
118  fsForJets.addVetoOnThisFinalState(dressed_leptons);
119  JetAlg::InvisiblesStrategy invisiblesStrategy = JetAlg::DECAY_INVISIBLES;
120  if (_excludeNeutrinosFromJetClustering)
121  invisiblesStrategy = JetAlg::NO_INVISIBLES;
122  addProjection(FastJets(fsForJets, FastJets::ANTIKT, _jetConeSize,
123  JetAlg::ALL_MUONS, invisiblesStrategy), "Jets");
124 
125  // FatJets
126  addProjection(FastJets(fsForJets, FastJets::ANTIKT, _fatJetConeSize), "FatJets");
127 
128  // Neutrinos
129  IdentifiedFinalState neutrinos(fs);
130  neutrinos.acceptNeutrinos();
131  if (_usePromptFinalStates) {
132  PromptFinalState prompt_neutrinos(neutrinos);
133  prompt_neutrinos.acceptMuonDecays(true);
134  prompt_neutrinos.acceptTauDecays(true);
135  addProjection(prompt_neutrinos, "Neutrinos");
136  }
137  else
138  addProjection(neutrinos, "Neutrinos");
139 
140  // MET
141  addProjection(MissingMomentum(fs), "MET");
142  };
143 
144  // Apply Rivet projections
145  void analyze(const Event& event) override {
146  _jets.clear();
147  _fatjets.clear();
148  _leptons.clear();
149  _photons.clear();
150  _neutrinos.clear();
151 
152  // Get analysis objects from projections
153  Cut jet_cut = (Cuts::abseta < _jetMaxEta) and (Cuts::pT > _jetMinPt*GeV);
154  Cut fatjet_cut = (Cuts::abseta < _fatJetMaxEta) and (Cuts::pT > _fatJetMinPt*GeV);
155 
156  _leptons = applyProjection<DressedLeptons>(event, "DressedLeptons").dressedLeptons();
157  // search tau ancestors
158  for ( auto & lepton : _leptons ) {
159  const auto & cl = lepton.constituentLepton();
160  for ( auto & p : cl.ancestors()) {
161  if (p.abspid() == 15) {
162  p.setMomentum(p.momentum()*10e-20);
163  lepton.addPhoton(p, false);
164  }
165  }
166  }
167 
168  Particles fsparticles = applyProjection<FinalState>(event,"FS").particles();
169 
170  for ( auto & photon : applyProjection<FinalState>(event, "Photons").particlesByPt() ) {
171 
172  if (photon.pt() < _phoMinPt)
173  continue;
174 
175  if (abs(photon.eta()) > _phoMaxEta)
176  continue;
177 
178  double photonptsum = 0;
179 
180  for (auto &fsparticle : fsparticles) {
181 
182  if (deltaR(fsparticle, photon) == 0)
183  continue;
184 
185  if (deltaR(fsparticle, photon) > _phoIsoConeSize)
186  continue;
187 
188  photonptsum += fsparticle.pt();
189  }
190 
191  if (photonptsum/photon.pt() > _phoMaxRelIso)
192  continue;
193 
194  _photons.push_back(photon);
195 
196  }
197 
198  _jets = applyProjection<FastJets>(event, "Jets").jetsByPt(jet_cut);
199  _fatjets = applyProjection<FastJets>(event, "FatJets").jetsByPt(fatjet_cut);
200  _neutrinos = applyProjection<FinalState>(event, "Neutrinos").particlesByPt();
201  _met = applyProjection<MissingMomentum>(event, "MET").missingMomentum().p3();
202  };
203 
204  // Do nothing here
205  void finalize() override {};
206 
207  };
208 
209 }
210 
211 #endif
const double GeV
Definition: MathUtil.h:16
Vector3 met() const
Definition: RivetAnalysis.h:31
void finalize() override
void init() override
Definition: RivetAnalysis.h:79
std::vector< DressedLepton > _leptons
Definition: RivetAnalysis.h:45
Jets fatjets() const
Definition: RivetAnalysis.h:30
ParticleVector _photons
Definition: RivetAnalysis.h:46
ParticleVector neutrinos() const
Definition: RivetAnalysis.h:28
RivetAnalysis(const edm::ParameterSet &pset)
Definition: RivetAnalysis.h:51
Jets jets() const
Definition: RivetAnalysis.h:29
ParticleVector photons() const
Definition: RivetAnalysis.h:27
bool _excludeNeutrinosFromJetClustering
Definition: RivetAnalysis.h:36
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< DressedLepton > leptons() const
Definition: RivetAnalysis.h:26
void analyze(const Event &event) override
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
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
bool _excludePromptLeptonsFromJetClustering
Definition: RivetAnalysis.h:35
ParticleVector _neutrinos
Definition: RivetAnalysis.h:46
Definition: event.py:1