CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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:
42  void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
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:
55  const std::string folderName_;
56 
59 
60  edm::EDGetTokenT<reco::PFMETCollection> metToken_;
61  edm::EDGetTokenT<reco::GsfElectronCollection> eleToken_;
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 jetptAvgaME_;
72  ObjME jetptAvgbME_;
73  ObjME jetptTagME_;
74  ObjME jetptPrbME_;
75  ObjME jetptAsyME_;
76  ObjME jetetaPrbME_;
77  ObjME jetetaTagME_;
78  ObjME jetphiPrbME_;
79  ObjME jetAsyEtaME_;
80  ObjME jetEtaPhiME_;
81 
84 
85  int nmuons_;
86  double ptcut_;
87 
88  // Define Phi Bin //
89  const double DiJet_MAX_PHI = 3.2;
90  //unsigned int DiJet_N_PHI = 64;
91  unsigned int DiJet_N_PHI = 32;
93  // Define Eta Bin //
94  const double DiJet_MAX_ETA = 5;
95  //unsigned int DiJet_N_ETA = 50;
96  unsigned int DiJet_N_ETA = 20;
98 
99  const double MAX_asy = 1;
100  const double MIN_asy = -1;
101  //unsigned int N_asy = 100;
102  unsigned int N_asy = 50;
104 };
105 
107  : folderName_(iConfig.getParameter<std::string>("FolderName")),
108  requireValidHLTPaths_(iConfig.getParameter<bool>("requireValidHLTPaths")),
109  hltPathsAreValid_(false),
110  dijetSrc_(mayConsume<reco::PFJetCollection>(iConfig.getParameter<edm::InputTag>("dijetSrc"))),
111  dijetpt_binning_(getHistoPSet(
112  iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet>("dijetPSet"))),
113  dijetptThr_binning_(getHistoPSet(
114  iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet>("dijetPtThrPSet"))),
116  iConfig.getParameter<edm::ParameterSet>("numGenericTriggerEventPSet"), consumesCollector(), *this)),
118  iConfig.getParameter<edm::ParameterSet>("denGenericTriggerEventPSet"), consumesCollector(), *this)),
119  ptcut_(iConfig.getParameter<double>("ptcut")) {}
120 
123  num_genTriggerEventFlag_.reset();
124  }
126  den_genTriggerEventFlag_.reset();
127  }
128 }
129 
130 void DiJetMonitor::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const& iRun, edm::EventSetup const& iSetup) {
131  // Initialize the GenericTriggerEventFlag
133  num_genTriggerEventFlag_->initRun(iRun, iSetup);
134  }
136  den_genTriggerEventFlag_->initRun(iRun, iSetup);
137  }
138 
139  // check if every HLT path specified in numerator and denominator has a valid match in the HLT Menu
141  den_genTriggerEventFlag_->on() && num_genTriggerEventFlag_->allHLTPathsAreValid() &&
142  den_genTriggerEventFlag_->allHLTPathsAreValid());
143 
144  // if valid HLT paths are required,
145  // create DQM outputs only if all paths are valid
147  return;
148  }
149 
150  std::string histname, histtitle;
151  std::string currentFolder = folderName_;
152  ibooker.setCurrentFolder(currentFolder);
153 
154  histname = "jetpt1";
155  histtitle = "leading Jet Pt";
157  setMETitle(jetpt1ME_, "Pt_1 [GeV]", "events");
158 
159  histname = "jetpt2";
160  histtitle = "second leading Jet Pt";
162  setMETitle(jetpt2ME_, "Pt_2 [GeV]", "events");
163 
164  histname = "jetptAvgB";
165  histtitle = "Pt average before offline selection";
166  bookME(
168  setMETitle(jetptAvgbME_, "(pt_1 + pt_2)*0.5 [GeV]", "events");
169 
170  histname = "jetptAvgA";
171  histtitle = "Pt average after offline selection";
172  bookME(
174  setMETitle(jetptAvgaME_, "(pt_1 + pt_2)*0.5 [GeV]", "events");
175 
176  histname = "jetptAvgAThr";
177  histtitle = "Pt average after offline selection";
178  bookME(ibooker,
180  histname,
181  histtitle,
185  setMETitle(jetptAvgaThrME_, "(pt_1 + pt_2)*0.5 [GeV]", "events");
186 
187  histname = "jetptTag";
188  histtitle = "Tag Jet Pt";
189  bookME(
190  ibooker, jetptTagME_, histname, histtitle, dijetpt_binning_.nbins, dijetpt_binning_.xmin, dijetpt_binning_.xmax);
191  setMETitle(jetptTagME_, "Pt_tag [GeV]", "events ");
192 
193  histname = "jetptPrb";
194  histtitle = "Probe Jet Pt";
195  bookME(
196  ibooker, jetptPrbME_, histname, histtitle, dijetpt_binning_.nbins, dijetpt_binning_.xmin, dijetpt_binning_.xmax);
197  setMETitle(jetptPrbME_, "Pt_prb [GeV]", "events");
198 
199  histname = "jetptAsym";
200  histtitle = "Jet Pt Asymetry";
201  bookME(ibooker, jetptAsyME_, histname, histtitle, asy_binning.nbins, asy_binning.xmin, asy_binning.xmax);
202  setMETitle(jetptAsyME_, "(pt_prb - pt_tag)/(pt_prb + pt_tag)", "events");
203 
204  histname = "jetetaPrb";
205  histtitle = "Probe Jet eta";
206  bookME(ibooker,
207  jetetaPrbME_,
208  histname,
209  histtitle,
213  setMETitle(jetetaPrbME_, "Eta_probe #eta", "events");
214 
215  histname = "jetetaTag";
216  histtitle = "Tag Jet eta";
217  bookME(ibooker,
218  jetetaTagME_,
219  histname,
220  histtitle,
224  setMETitle(jetetaTagME_, "Eta_tag #eta", "events");
225 
226  histname = "ptAsymVSetaPrb";
227  histtitle = "Pt_Asym vs eta_prb";
228  bookME(ibooker,
229  jetAsyEtaME_,
230  histname,
231  histtitle,
238  setMETitle(jetAsyEtaME_, "(pt_prb - pt_tag)/(pt_prb + pt_tag)", "Eta_probe #eta");
239 
240  histname = "etaPrbVSphiPrb";
241  histtitle = "eta_prb vs phi_prb";
242  bookME(ibooker,
243  jetEtaPhiME_,
244  histname,
245  histtitle,
252  setMETitle(jetEtaPhiME_, "Eta_probe #eta", "Phi_probe #phi");
253 
254  histname = "jetphiPrb";
255  histtitle = "Probe Jet phi";
256  bookME(ibooker,
257  jetphiPrbME_,
258  histname,
259  histtitle,
263  setMETitle(jetphiPrbME_, "Phi_probe #phi", "events");
264 }
265 
267  // if valid HLT paths are required,
268  // analyze event only if all paths are valid
270  return;
271  }
272 
273  // Filter out events if Trigger Filtering is requested
274  if (den_genTriggerEventFlag_->on() && !den_genTriggerEventFlag_->accept(iEvent, iSetup))
275  return;
276 
277  std::vector<double> v_jetpt;
278  std::vector<double> v_jeteta;
279  std::vector<double> v_jetphi;
280 
281  v_jetpt.clear();
282  v_jeteta.clear();
283  v_jetphi.clear();
284 
286  iEvent.getByToken(dijetSrc_, offjets);
287  if (!offjets.isValid()) {
288  edm::LogWarning("DiJetMonitor") << "DiJet handle not valid \n";
289  return;
290  }
291  for (reco::PFJetCollection::const_iterator ibegin = offjets->begin(), iend = offjets->end(), ijet = ibegin;
292  ijet != iend;
293  ++ijet) {
294  if (ijet->pt() < ptcut_) {
295  continue;
296  }
297  v_jetpt.push_back(ijet->pt());
298  v_jeteta.push_back(ijet->eta());
299  v_jetphi.push_back(ijet->phi());
300  }
301  if (v_jetpt.size() < 2) {
302  return;
303  }
304  double pt_1 = v_jetpt[0];
305  double eta_1 = v_jeteta[0];
306  double phi_1 = v_jetphi[0];
307  double pt_2 = v_jetpt[1];
308  double eta_2 = v_jeteta[1];
309  double phi_2 = v_jetphi[1];
310  double pt_avg_b = (pt_1 + pt_2) * 0.5;
311  int tag_id = -999, probe_id = -999;
312 
313  jetpt1ME_.denominator->Fill(pt_1);
314  jetpt2ME_.denominator->Fill(pt_2);
315  jetptAvgbME_.denominator->Fill(pt_avg_b);
316 
317  if (dijet_selection(eta_1, phi_1, eta_2, phi_2, pt_1, pt_2, tag_id, probe_id, iEvent.id().event())) {
318  if (tag_id == 0 && probe_id == 1) {
319  double pt_asy = (pt_2 - pt_1) / (pt_1 + pt_2);
320  double pt_avg = (pt_1 + pt_2) * 0.5;
321  jetptAvgaME_.denominator->Fill(pt_avg);
325  jetetaPrbME_.denominator->Fill(eta_2);
326  jetetaTagME_.denominator->Fill(eta_1);
327  jetptAsyME_.denominator->Fill(pt_asy);
328  jetphiPrbME_.denominator->Fill(phi_2);
329  jetAsyEtaME_.denominator->Fill(pt_asy, eta_2);
330  jetEtaPhiME_.denominator->Fill(eta_2, phi_2);
331  }
332  if (tag_id == 1 && probe_id == 0) {
333  double pt_asy = (pt_1 - pt_2) / (pt_2 + pt_1);
334  double pt_avg = (pt_2 + pt_1) * 0.5;
335  jetptAvgaME_.denominator->Fill(pt_avg);
339  jetetaPrbME_.denominator->Fill(eta_1);
340  jetetaTagME_.denominator->Fill(eta_2);
341  jetptAsyME_.denominator->Fill(pt_asy);
342  jetphiPrbME_.denominator->Fill(phi_1);
343  jetAsyEtaME_.denominator->Fill(pt_asy, eta_1);
344  jetEtaPhiME_.denominator->Fill(eta_1, phi_1);
345  }
346 
347  if (num_genTriggerEventFlag_->on() && !num_genTriggerEventFlag_->accept(iEvent, iSetup))
348  return;
349 
350  jetpt1ME_.numerator->Fill(pt_1);
351  jetpt2ME_.numerator->Fill(pt_2);
352  jetptAvgbME_.numerator->Fill(pt_avg_b);
353 
354  if (tag_id == 0 && probe_id == 1) {
355  double pt_asy = (pt_2 - pt_1) / (pt_1 + pt_2);
356  double pt_avg = (pt_1 + pt_2) * 0.5;
357  jetptAvgaME_.numerator->Fill(pt_avg);
358  jetptAvgaThrME_.numerator->Fill(pt_avg);
359  jetptTagME_.numerator->Fill(pt_1);
360  jetptPrbME_.numerator->Fill(pt_2);
361  jetetaPrbME_.numerator->Fill(eta_2);
362  jetetaTagME_.numerator->Fill(eta_1);
363  jetptAsyME_.numerator->Fill(pt_asy);
364  jetphiPrbME_.numerator->Fill(phi_2);
365  jetAsyEtaME_.numerator->Fill(pt_asy, eta_2);
366  jetEtaPhiME_.numerator->Fill(eta_2, phi_2);
367  }
368  if (tag_id == 1 && probe_id == 0) {
369  double pt_asy = (pt_1 - pt_2) / (pt_2 + pt_1);
370  double pt_avg = (pt_2 + pt_1) * 0.5;
371  jetptAvgaME_.numerator->Fill(pt_avg);
372  jetptAvgaThrME_.numerator->Fill(pt_avg);
373  jetptTagME_.numerator->Fill(pt_2);
374  jetptPrbME_.numerator->Fill(pt_1);
375  jetetaPrbME_.numerator->Fill(eta_1);
376  jetetaTagME_.numerator->Fill(eta_2);
377  jetptAsyME_.numerator->Fill(pt_asy);
378  jetphiPrbME_.numerator->Fill(phi_1);
379  jetAsyEtaME_.numerator->Fill(pt_asy, eta_1);
380  jetEtaPhiME_.numerator->Fill(eta_1, phi_1);
381  }
382  }
383 }
384 
385 //---- Additional DiJet offline selection------
387  double phi_1,
388  double eta_2,
389  double phi_2,
390  double pt_1,
391  double pt_2,
392  int& tag_id,
393  int& probe_id,
394  int Event) {
395  double etacut = 1.7;
396  double phicut = 2.7;
397 
398  bool passeta = (std::abs(eta_1) < etacut || std::abs(eta_2) < etacut); //check that one of the jets in the barrel
399 
400  float delta_phi_1_2 = (phi_1 - phi_2);
401  bool other_cuts = (std::abs(delta_phi_1_2) >= phicut); //check that jets are back to back
402 
403  if (std::abs(eta_1) < etacut && std::abs(eta_2) > etacut) {
404  tag_id = 0;
405  probe_id = 1;
406  } else if (std::abs(eta_2) < etacut && std::abs(eta_1) > etacut) {
407  tag_id = 1;
408  probe_id = 0;
409  } else if (std::abs(eta_2) < etacut && std::abs(eta_1) < etacut) {
410  int numb = Event % 2;
411  if (numb == 0) {
412  tag_id = 0;
413  probe_id = 1;
414  }
415  if (numb == 1) {
416  tag_id = 1;
417  probe_id = 0;
418  }
419  }
420 
421  return (passeta && other_cuts);
422 }
423 
426  desc.add<std::string>("FolderName", "HLT/JME/Jets/AK4/PF");
427  desc.add<bool>("requireValidHLTPaths", true);
428 
429  desc.add<edm::InputTag>("met", edm::InputTag("pfMet"));
430  desc.add<edm::InputTag>("dijetSrc", edm::InputTag("ak4PFJets"));
431  desc.add<edm::InputTag>("electrons", edm::InputTag("gedGsfElectrons"));
432  desc.add<edm::InputTag>("muons", edm::InputTag("muons"));
433  desc.add<int>("njets", 0);
434  desc.add<int>("nelectrons", 0);
435  desc.add<double>("ptcut", 20);
436 
437  edm::ParameterSetDescription genericTriggerEventPSet;
438  genericTriggerEventPSet.add<bool>("andOr");
439  genericTriggerEventPSet.add<edm::InputTag>("dcsInputTag", edm::InputTag("scalersRawToDigi"));
440  genericTriggerEventPSet.add<std::vector<int> >("dcsPartitions", {});
441  genericTriggerEventPSet.add<bool>("andOrDcs", false);
442  genericTriggerEventPSet.add<bool>("errorReplyDcs", true);
443  genericTriggerEventPSet.add<std::string>("dbLabel", "");
444  genericTriggerEventPSet.add<bool>("andOrHlt", true);
445  genericTriggerEventPSet.add<edm::InputTag>("hltInputTag", edm::InputTag("TriggerResults::HLT"));
446  genericTriggerEventPSet.add<std::vector<std::string> >("hltPaths", {});
447  genericTriggerEventPSet.add<bool>("errorReplyHlt", false);
448  genericTriggerEventPSet.add<unsigned int>("verbosityLevel", 1);
449 
450  desc.add<edm::ParameterSetDescription>("numGenericTriggerEventPSet", genericTriggerEventPSet);
451  desc.add<edm::ParameterSetDescription>("denGenericTriggerEventPSet", genericTriggerEventPSet);
452 
455  edm::ParameterSetDescription dijetPtThrPSet;
456  fillHistoPSetDescription(dijetPSet);
457  fillHistoPSetDescription(dijetPtThrPSet);
458  histoPSet.add<edm::ParameterSetDescription>("dijetPSet", dijetPSet);
459  histoPSet.add<edm::ParameterSetDescription>("dijetPtThrPSet", dijetPtThrPSet);
460  std::vector<double> bins = {
461  0., 20., 40., 60., 80., 90., 100., 110., 120., 130., 140., 150., 160.,
462  170., 180., 190., 200., 220., 240., 260., 280., 300., 350., 400., 450., 1000.}; // DiJet pT Binning
463  histoPSet.add<std::vector<double> >("jetptBinning", bins);
464 
467  histoPSet.add<edm::ParameterSetDescription>("lsPSet", lsPSet);
468  desc.add<edm::ParameterSetDescription>("histoPSet", histoPSet);
469 
470  descriptions.add("dijetMonitoring", desc);
471 }
472 
dqm::reco::DQMStore DQMStore
Definition: DiJetMonitor.cc:35
ObjME jetetaPrbME_
Definition: DiJetMonitor.cc:76
EventNumber_t event() const
Definition: EventID.h:40
std::unique_ptr< GenericTriggerEventFlag > den_genTriggerEventFlag_
Definition: DiJetMonitor.cc:83
ObjME jetphiPrbME_
Definition: DiJetMonitor.cc:78
static void fillHistoLSPSetDescription(edm::ParameterSetDescription &pset)
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
std::unique_ptr< GenericTriggerEventFlag > num_genTriggerEventFlag_
Definition: DiJetMonitor.cc:82
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
unsigned int N_asy
den_genTriggerEventFlag_(new GenericTriggerEventFlag(iConfig.getParameter< edm::ParameterSet >("denGenericTriggerEventPSet"), consumesCollector(),*this))
void analyze(edm::Event const &iEvent, edm::EventSetup const &iSetup) override
ObjME jetptPrbME_
Definition: DiJetMonitor.cc:74
MEbinning dijetpt_binning_
Definition: DiJetMonitor.cc:65
ObjME jetAsyEtaME_
Definition: DiJetMonitor.cc:79
const double MAX_asy
Definition: DiJetMonitor.cc:99
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)
std::unique_ptr< T, impl::DeviceDeleter > unique_ptr
ObjME jetptAvgbME_
Definition: DiJetMonitor.cc:72
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
DiJetMonitor(const edm::ParameterSet &)
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
ObjME jetptAsyME_
Definition: DiJetMonitor.cc:75
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:77
const double DiJet_MAX_PHI
Definition: DiJetMonitor.cc:89
MEbinning dijet_phi_binning
Definition: DiJetMonitor.cc:92
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
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
unsigned int DiJet_N_ETA
Definition: DiJetMonitor.cc:96
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isValid() const
Definition: HandleBase.h:70
num_genTriggerEventFlag_(new GenericTriggerEventFlag(iConfig.getParameter< edm::ParameterSet >("numGenericTriggerEventPSet"), consumesCollector(),*this))
ObjME jetptAvgaME_
Definition: DiJetMonitor.cc:70
void add(std::string const &label, ParameterSetDescription const &psetDescription)
ObjME jetptTagME_
Definition: DiJetMonitor.cc:73
~DiJetMonitor() override
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:94
const double MIN_asy
edm::EventID id() const
Definition: EventBase.h:59
std::vector< PFJet > PFJetCollection
collection of PFJet objects
edm::EDGetTokenT< reco::MuonCollection > muoToken_
Definition: DiJetMonitor.cc:62
MEbinning dijet_eta_binning
Definition: DiJetMonitor.cc:97
edm::EDGetTokenT< reco::PFMETCollection > metToken_
Definition: DiJetMonitor.cc:60
ObjME jetptAvgaThrME_
Definition: DiJetMonitor.cc:71
Log< level::Warning, false > LogWarning
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
unsigned int DiJet_N_PHI
Definition: DiJetMonitor.cc:91
Definition: Run.h:45
ObjME jetEtaPhiME_
Definition: DiJetMonitor.cc:80
Collection of PF MET.