CMS 3D CMS Logo

SusyDQM.h
Go to the documentation of this file.
1 #ifndef SusyDQM_H
2 #define SusyDQM_H
3 
4 #include <string>
5 #include <vector>
6 
14 
17 
38 
39 class TH1F;
40 class TH2F;
41 
42 class PtGreater {
43 public:
44  template <typename T>
45  bool operator()(const T& i, const T& j) {
46  return (i.pt() > j.pt());
47  }
48 };
49 
50 template <typename Mu, typename Ele, typename Jet, typename Met>
51 class SusyDQM : public DQMEDAnalyzer {
52 public:
53  explicit SusyDQM(const edm::ParameterSet&);
54  ~SusyDQM() override;
55 
56 protected:
57  void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
58 
59 private:
60  void analyze(const edm::Event&, const edm::EventSetup&) override;
61  virtual bool goodSusyElectron(const Ele*);
62  virtual bool goodSusyMuon(const Mu*);
63 
65 
67 
73 
74  double elec_eta_cut_;
75  double elec_mva_cut_;
76  double elec_d0_cut_;
77 
78  double muon_eta_cut_;
81  double muon_d0_cut_;
82 
85 
88 
94 
95  double RAL_met_cut_;
96 
98 
104 
110 
113 
115 
122 
132 };
133 
134 template <typename Mu, typename Ele, typename Jet, typename Met>
136  parameters_ = pset;
137  moduleName_ = pset.getUntrackedParameter<std::string>("moduleName");
138 
139  muons_ = consumes<std::vector<reco::Muon> >(pset.getParameter<edm::InputTag>("muonCollection"));
140  electrons_ = consumes<std::vector<reco::GsfElectron> >(pset.getParameter<edm::InputTag>("electronCollection"));
141  jets_ = consumes<std::vector<reco::CaloJet> >(pset.getParameter<edm::InputTag>("jetCollection"));
142  met_ = consumes<std::vector<reco::CaloMET> >(pset.getParameter<edm::InputTag>("metCollection"));
143  vertex_ = consumes<reco::VertexCollection>(pset.getParameter<edm::InputTag>("vertexCollection"));
144 
145  muon_eta_cut_ = pset.getParameter<double>("muon_eta_cut");
146  muon_nHits_cut_ = pset.getParameter<double>("muon_nHits_cut");
147  muon_nChi2_cut_ = pset.getParameter<double>("muon_nChi2_cut");
148  muon_d0_cut_ = pset.getParameter<double>("muon_d0_cut");
149 
150  elec_eta_cut_ = pset.getParameter<double>("elec_eta_cut");
151  elec_mva_cut_ = pset.getParameter<double>("elec_mva_cut");
152  elec_d0_cut_ = pset.getParameter<double>("elec_d0_cut");
153 
154  RAL_muon_pt_cut_ = pset.getParameter<double>("RAL_muon_pt_cut");
155  RAL_muon_iso_cut_ = pset.getParameter<double>("RAL_muon_iso_cut");
156 
157  RAL_elec_pt_cut_ = pset.getParameter<double>("RAL_elec_pt_cut");
158  RAL_elec_iso_cut_ = pset.getParameter<double>("RAL_elec_iso_cut");
159 
160  RAL_jet_pt_cut_ = pset.getParameter<double>("RAL_jet_pt_cut");
161  RAL_jet_sum_pt_cut_ = pset.getParameter<double>("RAL_jet_sum_pt_cut");
162  RAL_jet_eta_cut_ = pset.getParameter<double>("RAL_jet_eta_cut");
163  RAL_jet_min_emf_cut_ = pset.getParameter<double>("RAL_jet_min_emf_cut");
164  RAL_jet_max_emf_cut_ = pset.getParameter<double>("RAL_jet_max_emf_cut");
165 
166  RAL_met_cut_ = pset.getParameter<double>("RAL_met_cut");
167 
168  hRAL_N_muons_ = nullptr;
169  hRAL_pt_muons_ = nullptr;
170  hRAL_eta_muons_ = nullptr;
171  hRAL_phi_muons_ = nullptr;
172  hRAL_Iso_muons_ = nullptr;
173  hRAL_N_elecs_ = nullptr;
174  hRAL_pt_elecs_ = nullptr;
175  hRAL_eta_elecs_ = nullptr;
176  hRAL_phi_elecs_ = nullptr;
177  hRAL_Iso_elecs_ = nullptr;
178  hRAL_Sum_pt_jets_ = nullptr;
179  hRAL_Met_ = nullptr;
180  hRAL_dR_emu_ = nullptr;
181  hRAL_mass_OS_mumu_ = nullptr;
182  hRAL_mass_OS_ee_ = nullptr;
183  hRAL_mass_OS_emu_ = nullptr;
184  hRAL_mass_SS_mumu_ = nullptr;
185  hRAL_mass_SS_ee_ = nullptr;
186  hRAL_mass_SS_emu_ = nullptr;
187  hRAL_Muon_monitor_ = nullptr;
188  hRAL_Electron_monitor_ = nullptr;
189  hRAL_OSee_monitor_ = nullptr;
190  hRAL_OSemu_monitor_ = nullptr;
191  hRAL_OSmumu_monitor_ = nullptr;
192  hRAL_SSee_monitor_ = nullptr;
193  hRAL_SSemu_monitor_ = nullptr;
194  hRAL_SSmumu_monitor_ = nullptr;
195  hRAL_TriMuon_monitor_ = nullptr;
196 }
197 
198 template <typename Mu, typename Ele, typename Jet, typename Met>
200 
201 template <typename Mu, typename Ele, typename Jet, typename Met>
203  iBooker.setCurrentFolder(moduleName_);
204 
205  hRAL_N_muons_ = iBooker.book1D("RAL_N_muons", "RAL_N_muons", 10, 0., 10.);
206  hRAL_pt_muons_ = iBooker.book1D("RAL_pt_muons", "RAL_pt_muons", 50, 0., 300.);
207  hRAL_eta_muons_ = iBooker.book1D("RAL_eta_muons", "RAL_eta_muons", 50, -2.5, 2.5);
208  hRAL_phi_muons_ = iBooker.book1D("RAL_phi_muons", "RAL_phi_muons", 50, -4., 4.);
209  hRAL_Iso_muons_ = iBooker.book1D("RAL_Iso_muons", "RAL_Iso_muons", 50, 0., 25.);
210 
211  hRAL_N_elecs_ = iBooker.book1D("RAL_N_elecs", "RAL_N_elecs", 10, 0., 10.);
212  hRAL_pt_elecs_ = iBooker.book1D("RAL_pt_elecs", "RAL_pt_elecs", 50, 0., 300.);
213  hRAL_eta_elecs_ = iBooker.book1D("RAL_eta_elecs", "RAL_eta_elecs", 50, -2.5, 2.5);
214  hRAL_phi_elecs_ = iBooker.book1D("RAL_phi_elecs", "RAL_phi_elecs", 50, -4., 4.);
215  hRAL_Iso_elecs_ = iBooker.book1D("RAL_Iso_elecs", "RAL_Iso_elecs", 50, 0., 25.);
216 
217  hRAL_Sum_pt_jets_ = iBooker.book1D("RAL_Sum_pt_jets", "RAL_Sum_pt_jets", 50, 0., 2000.);
218  hRAL_Met_ = iBooker.book1D("RAL_Met", "RAL_Met", 50, 0., 1000.);
219 
220  hRAL_dR_emu_ = iBooker.book1D("RAL_deltaR_emu", "RAL_deltaR_emu", 50, 0., 10.);
221 
222  hRAL_mass_OS_mumu_ = iBooker.book1D("RAL_mass_OS_mumu", "RAL_mass_OS_mumu", 50, 0., 300.);
223  hRAL_mass_OS_ee_ = iBooker.book1D("RAL_mass_OS_ee", "RAL_mass_OS_ee", 50, 0., 300.);
224  hRAL_mass_OS_emu_ = iBooker.book1D("RAL_mass_OS_emu", "RAL_mass_OS_emu", 50, 0., 300.);
225  hRAL_mass_SS_mumu_ = iBooker.book1D("RAL_mass_SS_mumu", "RAL_mass_SS_mumu", 50, 0., 300.);
226  hRAL_mass_SS_ee_ = iBooker.book1D("RAL_mass_SS_ee", "RAL_mass_SS_ee", 50, 0., 300.);
227  hRAL_mass_SS_emu_ = iBooker.book1D("RAL_mass_SS_emu", "RAL_mass_SS_emu", 50, 0., 300.);
228 
229  hRAL_Muon_monitor_ =
230  iBooker.book2D("RAL_Single_Muon_Selection", "RAL_Single_Muon_Selection", 50, 0., 1000., 50, 0., 1000.);
231  hRAL_Electron_monitor_ =
232  iBooker.book2D("RAL_Single_Electron_Selection", "RAL_Single_Electron_Selection", 50, 0., 1000., 50, 0., 1000.);
233  hRAL_OSee_monitor_ =
234  iBooker.book2D("RAL_OS_Electron_Selection", "RAL_OS_Electron_Selection", 50, 0., 1000., 50, 0., 1000.);
235  hRAL_OSemu_monitor_ =
236  iBooker.book2D("RAL_OS_ElectronMuon_Selection", "RAL_OS_ElectronMuon_Selection", 50, 0., 1000., 50, 0., 1000.);
237  hRAL_OSmumu_monitor_ = iBooker.book2D("RAL_OS_Muon_Selection", "RAL_OS_Muon_Selection", 50, 0., 1000., 50, 0., 1000.);
238  hRAL_SSee_monitor_ =
239  iBooker.book2D("RAL_SS_Electron_Selection", "RAL_SS_Electron_Selection", 50, 0., 1000., 50, 0., 1000.);
240  hRAL_SSemu_monitor_ =
241  iBooker.book2D("RAL_SS_ElectronMuon_Selection", "RAL_SS_ElectronMuon_Selection", 50, 0., 1000., 50, 0., 1000.);
242  hRAL_SSmumu_monitor_ = iBooker.book2D("RAL_SS_Muon_Selection", "RAL_SS_Muon_Selection", 50, 0., 1000., 50, 0., 1000.);
243  hRAL_TriMuon_monitor_ =
244  iBooker.book2D("RAL_Tri_Muon_Selection", "RAL_Tri_Muon_Selection", 50, 0., 1000., 50, 0., 1000.);
245 }
246 
247 template <typename Mu, typename Ele, typename Jet, typename Met>
249  // if (ele->pt() < elec_pt_cut_)
250  // return false;
251  if (fabs(ele->eta()) > elec_eta_cut_)
252  return false;
253  // if (ele->mva() < elec_mva_cut_)
254  // return false;
255  if (fabs(ele->gsfTrack()->dxy(bs)) > elec_d0_cut_)
256  return false;
257  return true;
258 }
259 
260 template <typename Mu, typename Ele, typename Jet, typename Met>
262  // if (mu->pt() < muon_pt_cut_)
263  // return false;
264  if (fabs(mu->eta()) > muon_eta_cut_)
265  return false;
266  if (!mu->isGlobalMuon())
267  return false;
268  if (mu->innerTrack()->numberOfValidHits() < muon_nHits_cut_)
269  return false;
270  if (mu->globalTrack()->normalizedChi2() > muon_nChi2_cut_)
271  return false;
272  if (fabs(mu->innerTrack()->dxy(bs)) > muon_d0_cut_)
273  return false;
274  return true;
275 }
276 
277 template <typename Mu, typename Ele, typename Jet, typename Met>
280  bool isFound = evt.getByToken(muons_, muons);
281  if (!isFound)
282  return;
283 
285  isFound = evt.getByToken(electrons_, elecs);
286  if (!isFound)
287  return;
288 
291  isFound = evt.getByToken(jets_, cJets);
292  if (!isFound)
293  return;
294  std::vector<Jet> jets = *cJets;
295  std::sort(jets.begin(), jets.end(), PtGreater());
296 
298  isFound = evt.getByToken(met_, mets);
299  if (!isFound)
300  return;
301 
303  isFound = evt.getByToken(vertex_, vertices);
304  if (!isFound)
305  return;
306 
308  // Leptonic DQM histos
310 
311  float sumPt = 0.;
312  for (typename std::vector<Jet>::const_iterator jet_i = jets.begin(); jet_i != jets.end(); ++jet_i) {
313  if (jet_i->pt() < RAL_jet_pt_cut_)
314  continue;
315  if (fabs(jet_i->eta()) > RAL_jet_eta_cut_)
316  continue;
317  if (fabs(jet_i->eta()) > RAL_jet_eta_cut_)
318  continue;
319  if (jet_i->emEnergyFraction() < RAL_jet_min_emf_cut_)
320  continue;
321  if (jet_i->emEnergyFraction() > RAL_jet_max_emf_cut_)
322  continue;
323  sumPt += jet_i->pt();
324  }
325 
326  hRAL_Sum_pt_jets_->Fill(sumPt);
327 
328  float MET = 0.;
329  for (typename std::vector<Met>::const_iterator met_i = mets->begin(); met_i != mets->end(); ++met_i) {
330  MET = met_i->pt();
331  break;
332  }
333 
334  hRAL_Met_->Fill(MET);
335 
336  int nMuons = 0;
337  int nSSmumu = 0;
338  int nOSmumu = 0;
339  int nSSemu = 0;
340  int nOSemu = 0;
341  float inv = 0.;
342  float dR = 0.;
343 
344  for (typename std::vector<Mu>::const_iterator mu_i = muons->begin(); mu_i != muons->end(); ++mu_i) {
345  if (!(goodSusyMuon(&(*mu_i)) && mu_i->pt() > RAL_muon_pt_cut_))
346  continue;
347  ++nMuons;
348 
349  hRAL_pt_muons_->Fill(mu_i->pt());
350  hRAL_eta_muons_->Fill(mu_i->eta());
351  hRAL_phi_muons_->Fill(mu_i->phi());
352 
353  reco::MuonIsolation muIso = mu_i->isolationR03();
354  hRAL_Iso_muons_->Fill(muIso.emEt + muIso.hadEt + muIso.sumPt);
355 
356  // Muon muon pairs
357  for (typename std::vector<Mu>::const_iterator mu_j = muons->begin(); mu_j != muons->end(); ++mu_j) {
358  if (mu_i >= mu_j)
359  continue;
360  if (!(goodSusyMuon(&(*mu_j)) && mu_j->pt() > RAL_muon_pt_cut_))
361  continue;
362 
363  inv = (mu_i->p4() + mu_j->p4()).M();
364  if (mu_i->charge() * mu_j->charge() > 0) {
365  ++nSSmumu;
366  hRAL_mass_SS_mumu_->Fill(inv);
367  }
368  if (mu_i->charge() * mu_j->charge() < 0) {
369  ++nOSmumu;
370  hRAL_mass_OS_mumu_->Fill(inv);
371  }
372  }
373 
374  // Electron muon pairs
375  for (typename std::vector<Ele>::const_iterator ele_j = elecs->begin(); ele_j != elecs->end(); ++ele_j) {
376  if (!(goodSusyElectron(&(*ele_j)) && ele_j->pt() > RAL_elec_pt_cut_))
377  continue;
378  inv = (mu_i->p4() + ele_j->p4()).M();
379  dR = deltaR(*mu_i, *ele_j);
380  hRAL_dR_emu_->Fill(dR);
381  if (mu_i->charge() * ele_j->charge() > 0) {
382  ++nSSemu;
383  hRAL_mass_SS_emu_->Fill(inv);
384  }
385  if (mu_i->charge() * ele_j->charge() < 0) {
386  ++nOSemu;
387  hRAL_mass_OS_emu_->Fill(inv);
388  }
389  }
390  }
391 
392  hRAL_N_muons_->Fill(nMuons);
393 
394  int nElectrons = 0;
395  int nSSee = 0;
396  int nOSee = 0;
397  for (typename std::vector<Ele>::const_iterator ele_i = elecs->begin(); ele_i != elecs->end(); ++ele_i) {
398  if (!(goodSusyElectron(&(*ele_i)) && ele_i->pt() > RAL_elec_pt_cut_))
399  continue;
400  nElectrons++;
401 
402  hRAL_pt_elecs_->Fill(ele_i->pt());
403  hRAL_eta_elecs_->Fill(ele_i->eta());
404  hRAL_phi_elecs_->Fill(ele_i->phi());
405 
406  hRAL_Iso_elecs_->Fill(ele_i->dr03TkSumPt() + ele_i->dr03EcalRecHitSumEt() + ele_i->dr03HcalTowerSumEt());
407 
408  // Electron electron pairs
409  for (typename std::vector<Ele>::const_iterator ele_j = elecs->begin(); ele_j != elecs->end(); ++ele_j) {
410  if (ele_i >= ele_j)
411  continue;
412  if (!(goodSusyElectron(&(*ele_j)) && ele_j->pt() > RAL_elec_pt_cut_))
413  continue;
414 
415  inv = (ele_i->p4() + ele_j->p4()).M();
416  if (ele_i->charge() * ele_j->charge() > 0) {
417  ++nSSee;
418  hRAL_mass_SS_ee_->Fill(inv);
419  }
420  if (ele_i->charge() * ele_j->charge() < 0) {
421  ++nOSee;
422  hRAL_mass_OS_ee_->Fill(inv);
423  }
424  }
425  }
426 
427  hRAL_N_elecs_->Fill(nElectrons);
428 
429  if (MET > RAL_met_cut_ && sumPt > RAL_jet_sum_pt_cut_) {
430  if (nMuons >= 1) {
431  hRAL_Muon_monitor_->Fill(sumPt, MET);
432  }
433  if (nElectrons >= 1) {
434  hRAL_Electron_monitor_->Fill(sumPt, MET);
435  }
436  if (nOSee >= 1) {
437  hRAL_OSee_monitor_->Fill(sumPt, MET);
438  }
439  if (nOSemu >= 1) {
440  hRAL_OSemu_monitor_->Fill(sumPt, MET);
441  }
442  if (nOSmumu >= 1) {
443  hRAL_OSmumu_monitor_->Fill(sumPt, MET);
444  }
445  if (nSSee >= 1) {
446  hRAL_SSee_monitor_->Fill(sumPt, MET);
447  }
448  if (nSSemu >= 1) {
449  hRAL_SSemu_monitor_->Fill(sumPt, MET);
450  }
451  if (nSSmumu >= 1) {
452  hRAL_SSmumu_monitor_->Fill(sumPt, MET);
453  }
454  }
455  if (nMuons >= 3) {
456  hRAL_TriMuon_monitor_->Fill(sumPt, MET);
457  }
458 }
459 
460 #endif
461 
MonitorElement * hRAL_Iso_elecs_
Definition: SusyDQM.h:109
MonitorElement * hRAL_OSemu_monitor_
Definition: SusyDQM.h:126
float hadEt
hcal sum-Et
Definition: MuonIsolation.h:8
MonitorElement * hRAL_N_muons_
Definition: SusyDQM.h:99
edm::EDGetTokenT< std::vector< reco::GsfElectron > > electrons_
Definition: SusyDQM.h:69
float sumPt
sum-pt of tracks
Definition: MuonIsolation.h:6
double RAL_muon_pt_cut_
Definition: SusyDQM.h:83
SusyDQM(const edm::ParameterSet &)
Definition: SusyDQM.h:135
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
math::XYZPoint bs
Definition: SusyDQM.h:97
MonitorElement * hRAL_Iso_muons_
Definition: SusyDQM.h:103
virtual bool goodSusyMuon(const Mu *)
Definition: SusyDQM.h:261
MonitorElement * hRAL_SSmumu_monitor_
Definition: SusyDQM.h:130
MonitorElement * hRAL_Sum_pt_jets_
Definition: SusyDQM.h:111
std::string moduleName_
Definition: SusyDQM.h:66
double RAL_elec_iso_cut_
Definition: SusyDQM.h:87
edm::EDGetTokenT< reco::VertexCollection > vertex_
Definition: SusyDQM.h:72
double RAL_jet_sum_pt_cut_
Definition: SusyDQM.h:93
double RAL_jet_pt_cut_
Definition: SusyDQM.h:89
MonitorElement * hRAL_eta_elecs_
Definition: SusyDQM.h:107
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:536
edm::EDGetTokenT< std::vector< reco::Muon > > muons_
Definition: SusyDQM.h:68
double RAL_jet_max_emf_cut_
Definition: SusyDQM.h:92
MonitorElement * hRAL_mass_SS_mumu_
Definition: SusyDQM.h:119
double RAL_jet_min_emf_cut_
Definition: SusyDQM.h:91
MonitorElement * hRAL_mass_SS_emu_
Definition: SusyDQM.h:121
MonitorElement * hRAL_OSee_monitor_
Definition: SusyDQM.h:125
edm::EDGetTokenT< std::vector< reco::CaloJet > > jets_
Definition: SusyDQM.h:70
double RAL_elec_pt_cut_
Definition: SusyDQM.h:86
edm::EDGetTokenT< std::vector< reco::CaloMET > > met_
Definition: SusyDQM.h:71
double elec_eta_cut_
Definition: SusyDQM.h:74
double muon_eta_cut_
Definition: SusyDQM.h:78
MonitorElement * hRAL_mass_OS_emu_
Definition: SusyDQM.h:118
MonitorElement * hRAL_mass_OS_mumu_
Definition: SusyDQM.h:116
float emEt
ecal sum-Et
Definition: MuonIsolation.h:7
double RAL_muon_iso_cut_
Definition: SusyDQM.h:84
MonitorElement * hRAL_OSmumu_monitor_
Definition: SusyDQM.h:127
virtual bool goodSusyElectron(const Ele *)
Definition: SusyDQM.h:248
MonitorElement * hRAL_Muon_monitor_
Definition: SusyDQM.h:123
MonitorElement * hRAL_pt_elecs_
Definition: SusyDQM.h:106
MonitorElement * hRAL_eta_muons_
Definition: SusyDQM.h:101
MonitorElement * hRAL_phi_elecs_
Definition: SusyDQM.h:108
edm::ParameterSet parameters_
Definition: SusyDQM.h:64
MonitorElement * hRAL_pt_muons_
Definition: SusyDQM.h:100
MonitorElement * hRAL_N_elecs_
Definition: SusyDQM.h:105
MonitorElement * hRAL_Electron_monitor_
Definition: SusyDQM.h:124
double muon_nChi2_cut_
Definition: SusyDQM.h:80
double muon_d0_cut_
Definition: SusyDQM.h:81
double elec_mva_cut_
Definition: SusyDQM.h:75
Definition: L1GtObject.h:29
MonitorElement * hRAL_Met_
Definition: SusyDQM.h:112
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: SusyDQM.h:202
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
double elec_d0_cut_
Definition: SusyDQM.h:76
double RAL_jet_eta_cut_
Definition: SusyDQM.h:90
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:212
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: SusyDQM.h:278
MonitorElement * hRAL_SSee_monitor_
Definition: SusyDQM.h:128
MonitorElement * hRAL_SSemu_monitor_
Definition: SusyDQM.h:129
MonitorElement * hRAL_mass_OS_ee_
Definition: SusyDQM.h:117
MonitorElement * hRAL_TriMuon_monitor_
Definition: SusyDQM.h:131
double RAL_met_cut_
Definition: SusyDQM.h:95
~SusyDQM() override
Definition: SusyDQM.h:199
MonitorElement * hRAL_phi_muons_
Definition: SusyDQM.h:102
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
MonitorElement * hRAL_mass_SS_ee_
Definition: SusyDQM.h:120
long double T
bool operator()(const T &i, const T &j)
Definition: SusyDQM.h:45
MonitorElement * hRAL_dR_emu_
Definition: SusyDQM.h:114
double muon_nHits_cut_
Definition: SusyDQM.h:79
Definition: Run.h:45
SusyDQM< reco::Muon, reco::GsfElectron, reco::CaloJet, reco::CaloMET > RecoSusyDQM
Definition: SusyDQM.h:462