CMS 3D CMS Logo

DiJetMonitor.cc
Go to the documentation of this file.
1 #include <string>
2 #include <vector>
3 #include <map>
4 
14 
20 
31 
32 class DiJetMonitor : public DQMEDAnalyzer, public TriggerDQMBase {
33 public:
36 
38  ~DiJetMonitor() throw() override;
39  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
40 
41 protected:
43  void analyze(edm::Event const& iEvent, edm::EventSetup const& iSetup) override;
44  bool dijet_selection(double eta_1,
45  double phi_1,
46  double eta_2,
47  double phi_2,
48  double pt_1,
49  double pt_2,
50  int& tag_id,
51  int& probe_id,
52  int Event);
53 
54 private:
56 
59 
62  edm::EDGetTokenT<reco::MuonCollection> muoToken_;
63  edm::EDGetTokenT<reco::PFJetCollection> dijetSrc_; // test for Jet
64 
67 
68  ObjME jetpt1ME_;
69  ObjME jetpt2ME_;
70  ObjME jetPhi1ME_;
71  ObjME jetPhi2ME_;
72  ObjME jetEta1ME_;
73  ObjME jetEta2ME_;
74  ObjME jetphiTagME_;
75  ObjME jetptAvgaME_;
77  ObjME jetptAvgbME_;
78  ObjME jetptTagME_;
79  ObjME jetptPrbME_;
80  ObjME jetptAsyME_;
81  ObjME jetetaPrbME_;
82  ObjME jetetaTagME_;
83  ObjME jetphiPrbME_;
84  ObjME jetAsyEtaME_;
85  ObjME jetEtaPhiME_;
86 
89 
90  int nmuons_;
91  double ptcut_;
92 
93  // Define Phi Bin //
94  const double DiJet_MAX_PHI = 3.2;
95  // unsigned int DiJet_N_PHI = 64;
96  unsigned int DiJet_N_PHI = 32;
98  // Define Eta Bin //
99  const double DiJet_MAX_ETA = 5;
100  //unsigned int DiJet_N_ETA = 50;
101  unsigned int DiJet_N_ETA = 20;
103 
104  const double MAX_asy = 1;
105  const double MIN_asy = -1;
106  //unsigned int N_asy = 100;
107  unsigned int N_asy = 50;
109 };
110 
112  : folderName_(iConfig.getParameter<std::string>("FolderName")),
113  requireValidHLTPaths_(iConfig.getParameter<bool>("requireValidHLTPaths")),
114  hltPathsAreValid_(false),
115  dijetSrc_(mayConsume<reco::PFJetCollection>(iConfig.getParameter<edm::InputTag>("dijetSrc"))),
116  dijetpt_binning_(getHistoPSet(
117  iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet>("dijetPSet"))),
118  dijetptThr_binning_(getHistoPSet(
119  iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet>("dijetPtThrPSet"))),
120  num_genTriggerEventFlag_(new GenericTriggerEventFlag(
121  iConfig.getParameter<edm::ParameterSet>("numGenericTriggerEventPSet"), consumesCollector(), *this)),
122  den_genTriggerEventFlag_(new GenericTriggerEventFlag(
123  iConfig.getParameter<edm::ParameterSet>("denGenericTriggerEventPSet"), consumesCollector(), *this)),
124  ptcut_(iConfig.getParameter<double>("ptcut")) {}
125 
128  num_genTriggerEventFlag_.reset();
129  }
131  den_genTriggerEventFlag_.reset();
132  }
133 }
134 
135 void DiJetMonitor::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const& iRun, edm::EventSetup const& iSetup) {
136  // Initialize the GenericTriggerEventFlag
138  num_genTriggerEventFlag_->initRun(iRun, iSetup);
139  }
141  den_genTriggerEventFlag_->initRun(iRun, iSetup);
142  }
143 
144  // check if every HLT path specified in numerator and denominator has a valid match in the HLT Menu
146  den_genTriggerEventFlag_->on() && num_genTriggerEventFlag_->allHLTPathsAreValid() &&
147  den_genTriggerEventFlag_->allHLTPathsAreValid());
148 
149  // if valid HLT paths are required,
150  // create DQM outputs only if all paths are valid
152  return;
153  }
154 
155  std::string histname, histtitle;
156  std::string currentFolder = folderName_;
157  ibooker.setCurrentFolder(currentFolder);
158 
159  histname = "jetpt1";
160  histtitle = "leading Jet Pt";
162  setMETitle(jetpt1ME_, "Pt_1 [GeV]", "events");
163 
164  histname = "jetpt2";
165  histtitle = "second leading Jet Pt";
167  setMETitle(jetpt2ME_, "Pt_2 [GeV]", "events");
168 
169  histname = "jetphi1";
170  histtitle = "leading Jet Phi";
171  bookME(
173  setMETitle(jetPhi1ME_, "Jet_Phi_1", "events");
174 
175  histname = "jetphi2";
176  histtitle = "second leading Jet Phi";
177  bookME(
179  setMETitle(jetPhi2ME_, "Jet_Phi_2", "events");
180 
181  histname = "jeteta1";
182  histtitle = "leading Jet Eta";
183  bookME(
185  setMETitle(jetEta1ME_, "Jet_Eta_1", "events");
186 
187  histname = "jeteta2";
188  histtitle = "second leading Jet Eta";
189  bookME(
191  setMETitle(jetEta2ME_, "Jet_Eta_2", "events");
192 
193  histname = "jetptAvgB";
194  histtitle = "Pt average before offline selection";
195  bookME(
197  setMETitle(jetptAvgbME_, "(pt_1 + pt_2)*0.5 [GeV]", "events");
198 
199  histname = "jetptAvgA";
200  histtitle = "Pt average after offline selection";
201  bookME(
203  setMETitle(jetptAvgaME_, "(pt_1 + pt_2)*0.5 [GeV]", "events");
204 
205  histname = "jetptAvgAThr";
206  histtitle = "Pt average after offline selection";
207  bookME(ibooker,
209  histname,
210  histtitle,
214  setMETitle(jetptAvgaThrME_, "(pt_1 + pt_2)*0.5 [GeV]", "events");
215 
216  histname = "jetptTag";
217  histtitle = "Tag Jet Pt";
218  bookME(
219  ibooker, jetptTagME_, histname, histtitle, dijetpt_binning_.nbins, dijetpt_binning_.xmin, dijetpt_binning_.xmax);
220  setMETitle(jetptTagME_, "Pt_tag [GeV]", "events ");
221 
222  histname = "jetptPrb";
223  histtitle = "Probe Jet Pt";
224  bookME(
225  ibooker, jetptPrbME_, histname, histtitle, dijetpt_binning_.nbins, dijetpt_binning_.xmin, dijetpt_binning_.xmax);
226  setMETitle(jetptPrbME_, "Pt_prb [GeV]", "events");
227 
228  histname = "jetptAsym";
229  histtitle = "Jet Pt Asymetry";
230  bookME(ibooker, jetptAsyME_, histname, histtitle, asy_binning.nbins, asy_binning.xmin, asy_binning.xmax);
231  setMETitle(jetptAsyME_, "(pt_prb - pt_tag)/(pt_prb + pt_tag)", "events");
232 
233  histname = "jetetaPrb";
234  histtitle = "Probe Jet eta";
235  bookME(ibooker,
236  jetetaPrbME_,
237  histname,
238  histtitle,
242  setMETitle(jetetaPrbME_, "Eta_probe #eta", "events");
243 
244  histname = "jetetaTag";
245  histtitle = "Tag Jet eta";
246  bookME(ibooker,
247  jetetaTagME_,
248  histname,
249  histtitle,
253  setMETitle(jetetaTagME_, "Eta_tag #eta", "events");
254 
255  histname = "ptAsymVSetaPrb";
256  histtitle = "Pt_Asym vs eta_prb";
257  bookME(ibooker,
258  jetAsyEtaME_,
259  histname,
260  histtitle,
267  setMETitle(jetAsyEtaME_, "(pt_prb - pt_tag)/(pt_prb + pt_tag)", "Eta_probe #eta");
268 
269  histname = "etaPrbVSphiPrb";
270  histtitle = "eta_prb vs phi_prb";
271  bookME(ibooker,
272  jetEtaPhiME_,
273  histname,
274  histtitle,
281  setMETitle(jetEtaPhiME_, "Eta_probe #eta", "Phi_probe #phi");
282 
283  histname = "jetphiPrb";
284  histtitle = "Probe Jet phi";
285  bookME(ibooker,
286  jetphiPrbME_,
287  histname,
288  histtitle,
292  setMETitle(jetphiPrbME_, "Phi_probe #phi", "events");
293 
294  histname = "jetphiTag";
295  histtitle = "Tag Jet phi";
296  bookME(ibooker,
297  jetphiTagME_,
298  histname,
299  histtitle,
303  setMETitle(jetphiTagME_, "Phi_tag #phi", "events");
304 }
305 
307  // if valid HLT paths are required,
308  // analyze event only if all paths are valid
310  return;
311  }
312 
313  // Filter out events if Trigger Filtering is requested
314  if (den_genTriggerEventFlag_->on() && !den_genTriggerEventFlag_->accept(iEvent, iSetup))
315  return;
316 
317  std::vector<double> v_jetpt;
318  std::vector<double> v_jeteta;
319  std::vector<double> v_jetphi;
320 
321  v_jetpt.clear();
322  v_jeteta.clear();
323  v_jetphi.clear();
324 
326  iEvent.getByToken(dijetSrc_, offjets);
327  if (!offjets.isValid()) {
328  edm::LogWarning("DiJetMonitor") << "DiJet handle not valid \n";
329  return;
330  }
331  for (reco::PFJetCollection::const_iterator ibegin = offjets->begin(), iend = offjets->end(), ijet = ibegin;
332  ijet != iend;
333  ++ijet) {
334  if (ijet->pt() < ptcut_) {
335  continue;
336  }
337  v_jetpt.push_back(ijet->pt());
338  v_jeteta.push_back(ijet->eta());
339  v_jetphi.push_back(ijet->phi());
340  }
341  if (v_jetpt.size() < 2) {
342  return;
343  }
344  double pt_1 = v_jetpt[0];
345  double eta_1 = v_jeteta[0];
346  double phi_1 = v_jetphi[0];
347  double pt_2 = v_jetpt[1];
348  double eta_2 = v_jeteta[1];
349  double phi_2 = v_jetphi[1];
350  double pt_avg_b = (pt_1 + pt_2) * 0.5;
351  int tag_id = -999, probe_id = -999;
352 
353  jetpt1ME_.denominator->Fill(pt_1);
354  jetpt2ME_.denominator->Fill(pt_2);
355  jetPhi1ME_.denominator->Fill(phi_1);
356  jetPhi2ME_.denominator->Fill(phi_2);
359  jetptAvgbME_.denominator->Fill(pt_avg_b);
360 
361  if (dijet_selection(eta_1, phi_1, eta_2, phi_2, pt_1, pt_2, tag_id, probe_id, iEvent.id().event())) {
362  if (tag_id == 0 && probe_id == 1) {
363  double pt_asy = (pt_2 - pt_1) / (pt_1 + pt_2);
364  double pt_avg = (pt_1 + pt_2) * 0.5;
365  jetptAvgaME_.denominator->Fill(pt_avg);
371  jetptAsyME_.denominator->Fill(pt_asy);
372  jetphiPrbME_.denominator->Fill(phi_2);
373  jetphiTagME_.denominator->Fill(phi_1);
376  }
377  if (tag_id == 1 && probe_id == 0) {
378  double pt_asy = (pt_1 - pt_2) / (pt_2 + pt_1);
379  double pt_avg = (pt_2 + pt_1) * 0.5;
380  jetptAvgaME_.denominator->Fill(pt_avg);
386  jetptAsyME_.denominator->Fill(pt_asy);
387  jetphiPrbME_.denominator->Fill(phi_1);
388  jetphiTagME_.denominator->Fill(phi_2);
391  }
392 
393  if (num_genTriggerEventFlag_->on() && !num_genTriggerEventFlag_->accept(iEvent, iSetup))
394  return;
395 
396  jetpt1ME_.numerator->Fill(pt_1);
397  jetpt2ME_.numerator->Fill(pt_2);
398  jetPhi1ME_.numerator->Fill(phi_1);
399  jetPhi2ME_.numerator->Fill(phi_2);
402  jetptAvgbME_.numerator->Fill(pt_avg_b);
403 
404  if (tag_id == 0 && probe_id == 1) {
405  double pt_asy = (pt_2 - pt_1) / (pt_1 + pt_2);
406  double pt_avg = (pt_1 + pt_2) * 0.5;
407  jetptAvgaME_.numerator->Fill(pt_avg);
408  jetptAvgaThrME_.numerator->Fill(pt_avg);
409  jetptTagME_.numerator->Fill(pt_1);
410  jetptPrbME_.numerator->Fill(pt_2);
413  jetptAsyME_.numerator->Fill(pt_asy);
414  jetphiPrbME_.numerator->Fill(phi_2);
415  jetphiTagME_.numerator->Fill(phi_1);
416  jetAsyEtaME_.numerator->Fill(pt_asy, eta_2);
417  jetEtaPhiME_.numerator->Fill(eta_2, phi_2);
418  }
419  if (tag_id == 1 && probe_id == 0) {
420  double pt_asy = (pt_1 - pt_2) / (pt_2 + pt_1);
421  double pt_avg = (pt_2 + pt_1) * 0.5;
422  jetptAvgaME_.numerator->Fill(pt_avg);
423  jetptAvgaThrME_.numerator->Fill(pt_avg);
424  jetptTagME_.numerator->Fill(pt_2);
425  jetptPrbME_.numerator->Fill(pt_1);
428  jetptAsyME_.numerator->Fill(pt_asy);
429  jetphiPrbME_.numerator->Fill(phi_1);
430  jetphiTagME_.numerator->Fill(phi_2);
431  jetAsyEtaME_.numerator->Fill(pt_asy, eta_1);
432  jetEtaPhiME_.numerator->Fill(eta_1, phi_1);
433  }
434  }
435 }
436 
437 //---- Additional DiJet offline selection------
439  double phi_1,
440  double eta_2,
441  double phi_2,
442  double pt_1,
443  double pt_2,
444  int& tag_id,
445  int& probe_id,
446  int Event) {
447  double etacut = 1.7;
448  double phicut = 2.7;
449 
450  bool passeta = (std::abs(eta_1) < etacut || std::abs(eta_2) < etacut); //check that one of the jets in the barrel
451 
452  float delta_phi_1_2 = (phi_1 - phi_2);
453  bool other_cuts = (std::abs(delta_phi_1_2) >= phicut); //check that jets are back to back
454 
455  if (std::abs(eta_1) < etacut && std::abs(eta_2) > etacut) {
456  tag_id = 0;
457  probe_id = 1;
458  } else if (std::abs(eta_2) < etacut && std::abs(eta_1) > etacut) {
459  tag_id = 1;
460  probe_id = 0;
461  } else if (std::abs(eta_2) < etacut && std::abs(eta_1) < etacut) {
462  int numb = Event % 2;
463  if (numb == 0) {
464  tag_id = 0;
465  probe_id = 1;
466  }
467  if (numb == 1) {
468  tag_id = 1;
469  probe_id = 0;
470  }
471  }
472 
473  return (passeta && other_cuts);
474 }
475 
478  desc.add<std::string>("FolderName", "HLT/JME/Jets/AK4/PF");
479  desc.add<bool>("requireValidHLTPaths", true);
480 
481  desc.add<edm::InputTag>("met", edm::InputTag("pfMet"));
482  desc.add<edm::InputTag>("dijetSrc", edm::InputTag("ak4PFJets"));
483  desc.add<edm::InputTag>("electrons", edm::InputTag("gedGsfElectrons"));
484  desc.add<edm::InputTag>("muons", edm::InputTag("muons"));
485  desc.add<int>("njets", 0);
486  desc.add<int>("nelectrons", 0);
487  desc.add<double>("ptcut", 20);
488 
491 
492  desc.add<edm::ParameterSetDescription>("numGenericTriggerEventPSet", genericTriggerEventPSet);
493  desc.add<edm::ParameterSetDescription>("denGenericTriggerEventPSet", genericTriggerEventPSet);
494 
501  histoPSet.add<edm::ParameterSetDescription>("dijetPtThrPSet", dijetPtThrPSet);
502  std::vector<double> bins = {
503  0., 20., 40., 60., 80., 90., 100., 110., 120., 130., 140., 150., 160.,
504  170., 180., 190., 200., 220., 240., 260., 280., 300., 350., 400., 450., 1000.}; // DiJet pT Binning
505  histoPSet.add<std::vector<double> >("jetptBinning", bins);
506 
510  desc.add<edm::ParameterSetDescription>("histoPSet", histoPSet);
511 
512  descriptions.add("dijetMonitoring", desc);
513 }
514 
dqm::reco::DQMStore DQMStore
Definition: DiJetMonitor.cc:35
ObjME jetetaPrbME_
Definition: DiJetMonitor.cc:81
std::unique_ptr< GenericTriggerEventFlag > den_genTriggerEventFlag_
Definition: DiJetMonitor.cc:88
ObjME jetphiPrbME_
Definition: DiJetMonitor.cc:83
static void fillHistoLSPSetDescription(edm::ParameterSetDescription &pset)
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
std::unique_ptr< GenericTriggerEventFlag > num_genTriggerEventFlag_
Definition: DiJetMonitor.cc:87
unsigned int N_asy
void analyze(edm::Event const &iEvent, edm::EventSetup const &iSetup) override
ObjME jetptPrbME_
Definition: DiJetMonitor.cc:79
MEbinning dijetpt_binning_
Definition: DiJetMonitor.cc:65
ObjME jetAsyEtaME_
Definition: DiJetMonitor.cc:84
const double MAX_asy
MEbinning asy_binning
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
MEbinning dijetptThr_binning_
Definition: DiJetMonitor.cc:66
Provides a code based selection for trigger and DCS information in order to have no failing filters i...
dqm::reco::MonitorElement MonitorElement
Definition: DiJetMonitor.cc:34
static void fillHistoPSetDescription(edm::ParameterSetDescription &pset)
ObjME jetPhi2ME_
Definition: DiJetMonitor.cc:71
std::unique_ptr< T, impl::DeviceDeleter > unique_ptr
ObjME jetptAvgbME_
Definition: DiJetMonitor.cc:77
const std::string folderName_
Definition: DiJetMonitor.cc:55
void setMETitle(ObjME &me, const std::string &titleX, const std::string &titleY)
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
bool hltPathsAreValid_
Definition: DiJetMonitor.cc:58
ObjME jetPhi1ME_
Definition: DiJetMonitor.cc:70
DiJetMonitor(const edm::ParameterSet &)
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
ObjME jetptAsyME_
Definition: DiJetMonitor.cc:80
edm::EDGetTokenT< reco::GsfElectronCollection > eleToken_
Definition: DiJetMonitor.cc:61
void Fill(long long x)
edm::EDGetTokenT< reco::PFJetCollection > dijetSrc_
Definition: DiJetMonitor.cc:63
const bool requireValidHLTPaths_
Definition: DiJetMonitor.cc:57
int iEvent
Definition: GenABIO.cc:224
ObjME jetetaTagME_
Definition: DiJetMonitor.cc:82
ObjME jetphiTagME_
Definition: DiJetMonitor.cc:74
const double DiJet_MAX_PHI
Definition: DiJetMonitor.cc:94
MEbinning dijet_phi_binning
Definition: DiJetMonitor.cc:97
bool dijet_selection(double eta_1, double phi_1, double eta_2, double phi_2, double pt_1, double pt_2, int &tag_id, int &probe_id, int Event)
MonitorElement * denominator
MonitorElement * numerator
ObjME jetEta1ME_
Definition: DiJetMonitor.cc:72
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
unsigned int DiJet_N_ETA
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
ObjME jetptAvgaME_
Definition: DiJetMonitor.cc:75
void add(std::string const &label, ParameterSetDescription const &psetDescription)
ObjME jetptTagME_
Definition: DiJetMonitor.cc:78
~DiJetMonitor() override
bool isValid() const
Definition: HandleBase.h:70
void bookME(DQMStore::IBooker &, ObjME &me, const std::string &histname, const std::string &histtitle, const uint nbins, const double xmin, const double xmax, const bool bookDen=true)
const double DiJet_MAX_ETA
Definition: DiJetMonitor.cc:99
const double MIN_asy
ObjME jetEta2ME_
Definition: DiJetMonitor.cc:73
std::vector< PFJet > PFJetCollection
collection of PFJet objects
fixed size matrix
HLT enums.
edm::EDGetTokenT< reco::MuonCollection > muoToken_
Definition: DiJetMonitor.cc:62
MEbinning dijet_eta_binning
edm::EDGetTokenT< reco::PFMETCollection > metToken_
Definition: DiJetMonitor.cc:60
ObjME jetptAvgaThrME_
Definition: DiJetMonitor.cc:76
Log< level::Warning, false > LogWarning
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
unsigned int DiJet_N_PHI
Definition: DiJetMonitor.cc:96
static void fillPSetDescription(edm::ParameterSetDescription &desc)
Definition: Run.h:45
ObjME jetEtaPhiME_
Definition: DiJetMonitor.cc:85
Collection of PF MET.