CMS 3D CMS Logo

ZGammaplusJetsMonitor.cc
Go to the documentation of this file.
1 #include <string>
2 #include <vector>
3 
23 
24 #include "TLorentzVector.h"
25 #include <cassert>
26 #include "TPRegexp.h"
27 
29 public:
32 
34  ~ZGammaplusJetsMonitor() throw() override;
35 
36  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
37 
38 protected:
40  void analyze(edm::Event const& iEvent, edm::EventSetup const& iSetup) override;
41  void dqmBeginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) override;
42 
43  bool islowRefPt(double RefPt);
44  bool ismediumRefPt(double RefPt);
45  bool ishighRefPt(double RefPt);
46 
47  bool isBarrel(double eta);
48  bool isEndCapInner(double eta);
49  bool isEndCapOuter(double eta);
50  bool isForward(double eta);
51 
52  bool isMatched(double hltJetEta, double hltJetPhi, double OffJetEta, double OffJetPhi);
53 
54  void bookMESub(DQMStore::IBooker&,
55  ObjME* a_me,
56  const int len_,
57  const std::string& h_Name,
58  const std::string& h_Title,
59  const std::string& h_subOptName,
60  const std::string& h_subOptTitle,
61  const bool doDirectBalancevsReferencePt = true,
62  const bool bookDen = false);
63 
64  void fillME(ObjME* a_me,
65  const double directbalance_,
66  const double Difjetref_,
67  const double Assymetry_,
68  const double ReferencePt_,
69  const double Jetpt_,
70  const bool doDirectBalancevsReferencePt = true);
71 
72 private:
74 
75  const std::string processName_; // process name of (HLT) process for which to get HLT configuration
76  // The instance of the HLTConfigProvider as a data member
78 
81  const std::string pathName;
82  const std::string moduleName;
85  const edm::EDGetTokenT<reco::JetCorrector> correctorToken_;
86 
87  double muon_pt;
88  double muon_eta;
89  double pt_cut;
90  double Z_DM;
91  double Z_Pt;
92  double dphi_cut;
93  double offline_cut;
95 
99  MEbinning DifJetRefPT_Binning{50, -75.0, 75.0};
100 
101  //# of variables: 1. direct balance, 2. difference, 3. asymmetry, 4. hltobjectPt, 5. hltJetPt, 6. directbalanceVShltobjectPt
102  ObjME a_ME[6];
103  ObjME a_ME_HB[6];
104  ObjME a_ME_HE_I[6];
105  ObjME a_ME_HE_O[6];
106  ObjME a_ME_HF[6];
119 
120  ObjME mZMassME_;
122 
123  std::vector<double> v_jetpt;
124  std::vector<double> v_jeteta;
125  std::vector<double> v_jetphi;
126 
127  std::vector<double> trigobj_pt;
128  std::vector<double> trigobj_eta;
129  std::vector<double> trigobj_phi;
130 
131  TLorentzVector muon_1;
132  TLorentzVector muon_2;
133  TLorentzVector Zhltreco;
135 };
136 
138  : folderName_(iConfig.getParameter<std::string>("FolderName")),
139  processName_(iConfig.getParameter<std::string>("processName")),
140  triggerEventObject_(consumes<trigger::TriggerEvent>(iConfig.getParameter<edm::InputTag>("triggerEventObject"))),
141  triggerResultsToken_(consumes<edm::TriggerResults>(iConfig.getParameter<edm::InputTag>("TriggerResultsLabel"))),
142  pathName(iConfig.getParameter<std::string>("PathName")),
143  moduleName(iConfig.getParameter<std::string>("ModuleName")),
144  jetInputTag_(iConfig.getParameter<edm::InputTag>("jets")),
145  jetToken_(mayConsume<reco::PFJetCollection>(jetInputTag_)),
146  correctorToken_(mayConsume<reco::JetCorrector>(iConfig.getParameter<edm::InputTag>("corrector"))),
147  muon_pt(iConfig.getParameter<double>("muonpt")),
148  muon_eta(iConfig.getParameter<double>("muoneta")),
149  pt_cut(iConfig.getParameter<double>("ptcut")),
150  Z_DM(iConfig.getParameter<double>("Z_Dmass")),
151  Z_Pt(iConfig.getParameter<double>("Z_pt")),
152  dphi_cut(iConfig.getParameter<double>("DeltaPhi")),
153  offline_cut(iConfig.getParameter<double>("OfflineCut")),
154  isMuonPath_(iConfig.getParameter<bool>("isMuonPath")),
155  directbalance_Binning(iConfig.getParameter<edm::ParameterSet>("histoPSet")
156  .getParameter<std::vector<double> >("directbalanceBinning")),
157  TrObjPt_Binning(
158  iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<std::vector<double> >("TrObjPtBinning")),
159  jetpt_Binning(
160  iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<std::vector<double> >("jetptBinning")) {}
161 
163 
165  edm::Run const& iRun,
166  edm::EventSetup const& iSetup) {
167  std::string histname, histtitle;
168  std::string hist_obtag = "";
169  std::string histtitle_obtag = "";
170  std::string currentFolder = folderName_;
171  ibooker.setCurrentFolder(currentFolder);
172 
173  if (isMuonPath_) {
174  hist_obtag = "Z";
175  histtitle_obtag = "Z ";
176  histname = "DiMuonMass";
177  histtitle = "DiMuonMass";
178  bookME(ibooker, mZMassME_, histname, histtitle, 50, 71., 111., false);
179  } else {
180  hist_obtag = "Photon";
181  histtitle_obtag = "Photon";
182  }
183 
184  histname = "DPhi" + hist_obtag + "Jet";
185  histtitle = "DPhi " + hist_obtag + " Jet";
186  bookME(ibooker, DPhiRefJetME_, histname, histtitle, 100, 0., acos(-1.), false);
187 
188  bookMESub(ibooker, a_ME, sizeof(a_ME) / sizeof(a_ME[0]), hist_obtag, histtitle_obtag, "", "");
189  bookMESub(ibooker, a_ME_HB, sizeof(a_ME_HB) / sizeof(a_ME_HB[0]), hist_obtag, histtitle_obtag, "HB", "(HB)", true);
190  bookMESub(ibooker,
191  a_ME_HE_I,
192  sizeof(a_ME_HE_I) / sizeof(a_ME_HE_I[0]),
193  hist_obtag,
194  histtitle_obtag,
195  "HEInner",
196  "(HE Inner)",
197  true);
198  bookMESub(ibooker,
199  a_ME_HE_O,
200  sizeof(a_ME_HE_O) / sizeof(a_ME_HE_O[0]),
201  hist_obtag,
202  histtitle_obtag,
203  "HEOuter",
204  "(HE Outer)",
205  true);
206  bookMESub(ibooker, a_ME_HF, sizeof(a_ME_HF) / sizeof(a_ME_HF[0]), hist_obtag, histtitle_obtag, "HF", "(HF)", true);
207  bookMESub(ibooker,
209  sizeof(a_ME_HB_lowRefPt) / sizeof(a_ME_HB_lowRefPt[0]),
210  hist_obtag,
211  histtitle_obtag,
212  "HB_lowRefPt",
213  "(HB) lowRefPt",
214  true);
215  bookMESub(ibooker,
217  sizeof(a_ME_HE_I_lowRefPt) / sizeof(a_ME_HE_I_lowRefPt[0]),
218  hist_obtag,
219  histtitle_obtag,
220  "HEInner_lowRefPt",
221  "(HE Inner) lowRefPt",
222  true);
223  bookMESub(ibooker,
225  sizeof(a_ME_HE_O_lowRefPt) / sizeof(a_ME_HE_O_lowRefPt[0]),
226  hist_obtag,
227  histtitle_obtag,
228  "HEOuter_lowRefPt",
229  "(HE Outer) lowRefPt",
230  true);
231  bookMESub(ibooker,
233  sizeof(a_ME_HF_lowRefPt) / sizeof(a_ME_HF_lowRefPt[0]),
234  hist_obtag,
235  histtitle_obtag,
236  "HF_lowRefPt",
237  "(HF) lowRefPt",
238  true);
239  bookMESub(ibooker,
241  sizeof(a_ME_HB_mediumRefPt) / sizeof(a_ME_HB_mediumRefPt[0]),
242  hist_obtag,
243  histtitle_obtag,
244  "HB_mediumRefPt",
245  "(HB) mediumRefPt",
246  true);
247  bookMESub(ibooker,
249  sizeof(a_ME_HE_I_mediumRefPt) / sizeof(a_ME_HE_I_mediumRefPt[0]),
250  hist_obtag,
251  histtitle_obtag,
252  "HEInner_mediumRefPt",
253  "(HE Inner) mediumRefPt",
254  true);
255  bookMESub(ibooker,
257  sizeof(a_ME_HE_O_mediumRefPt) / sizeof(a_ME_HE_O_mediumRefPt[0]),
258  hist_obtag,
259  histtitle_obtag,
260  "HEOuter_mediumRefPt",
261  "(HE Outer) mediumRefPt",
262  true);
263  bookMESub(ibooker,
265  sizeof(a_ME_HF_mediumRefPt) / sizeof(a_ME_HF_mediumRefPt[0]),
266  hist_obtag,
267  histtitle_obtag,
268  "HF_mediumRefPt",
269  "(HF) mediumRefPt",
270  true);
271  bookMESub(ibooker,
273  sizeof(a_ME_HB_highRefPt) / sizeof(a_ME_HB_highRefPt[0]),
274  hist_obtag,
275  histtitle_obtag,
276  "HB_highRefPt",
277  "(HB) highRefPt",
278  true);
279  bookMESub(ibooker,
281  sizeof(a_ME_HE_I_highRefPt) / sizeof(a_ME_HE_I_highRefPt[0]),
282  hist_obtag,
283  histtitle_obtag,
284  "HEInner_highRefPt",
285  "(HE Inner) highRefPt",
286  true);
287  bookMESub(ibooker,
289  sizeof(a_ME_HE_O_highRefPt) / sizeof(a_ME_HE_O_highRefPt[0]),
290  hist_obtag,
291  histtitle_obtag,
292  "HEOuter_highRefPt",
293  "(HE Outer) highRefPt",
294  true);
295  bookMESub(ibooker,
297  sizeof(a_ME_HF_highRefPt) / sizeof(a_ME_HF_highRefPt[0]),
298  hist_obtag,
299  histtitle_obtag,
300  "HF_highRefPt",
301  "(HF) highRefPt",
302  true);
303 }
304 
306  v_jetpt.clear();
307  v_jeteta.clear();
308  v_jetphi.clear();
309 
310  trigobj_pt.clear();
311  trigobj_eta.clear();
312  trigobj_phi.clear();
313 
314  // ------------------ Get TriggerResults -----------------
317  if (!triggerResults.isValid())
318  return;
319 
320  edm::Handle<trigger::TriggerEvent> aodTriggerEvent;
321  iEvent.getByToken(triggerEventObject_, aodTriggerEvent);
322  if (!aodTriggerEvent.isValid())
323  return;
324 
325  edm::TriggerNames triggerNames_ = iEvent.triggerNames(*triggerResults); // all trigger names available
326 
327  bool passTrig = false;
328 
329  unsigned hltcfgIndex = hltConfig_.triggerIndex(fullpathName);
330  unsigned index = triggerNames_.triggerIndex(fullpathName); // find in which index is that path
331  if (!(hltcfgIndex == index)) {
332  edm::LogInfo("ZGammaplusJetsMonitor") << " Error in trigger index";
333  return;
334  }
335 
336  if (index > 0 && index < triggerNames_.size() &&
337  triggerResults->accept(index)) { //trigger is accepted and index is valid
338  edm::LogInfo("ZGammaplusJetsMonitor") << " Trigger accepted";
339  passTrig = true;
340  }
341  if (!passTrig) {
342  edm::LogInfo("ZGammaplusJetsMonitor") << " Trigger did not pass"; // skip event if trigger fails
343  return;
344  }
345 
346  // ---------------- find module for this path ------------------------
347  const unsigned int module_size = hltConfig_.size(index);
348  std::vector<std::string> module_names = hltConfig_.moduleLabels(index); // (pathname) works too
349  if (!(module_size == module_names.size())) {
350  edm::LogInfo("ZGammaplusJetsMonitor") << "ERROR IN MODULES COUNTING";
351  return;
352  }
353  if (module_size == 0) {
354  edm::LogInfo("ZGammaplusJetsMonitor") << "no modules in this path ?!?!";
355  return;
356  }
357 
358  // Find the module
359  edm::InputTag moduleFilter;
360  moduleFilter = edm::InputTag(moduleName, "", processName_);
361  edm::LogInfo("ZGammaplusJetsMonitor") << " ModuleFilter " << moduleFilter;
362 
363  // check whether the module is packed up in TriggerEvent product
364  trigger::size_type filterIndex_ = aodTriggerEvent->filterIndex(moduleFilter);
365  edm::LogInfo("ZGammaplusJetsMonitor") << " filter index " << filterIndex_ << " | filter size "
366  << aodTriggerEvent->sizeFilters();
367  if (filterIndex_ >= aodTriggerEvent->sizeFilters()) {
368  return;
369  }
370 
371  edm::LogInfo("ZGammaplusJetsMonitor") << " filter label|filter index" << moduleName << "|" << filterIndex_;
372 
373  const trigger::Vids& VIDS_ = aodTriggerEvent->filterIds(filterIndex_);
374  const trigger::Keys& KEYS_ = aodTriggerEvent->filterKeys(filterIndex_);
375  const trigger::size_type nI_ = VIDS_.size();
376  const trigger::size_type nK_ = KEYS_.size();
377  assert(nI_ == nK_);
378  const trigger::TriggerObjectCollection& TOC(aodTriggerEvent->getObjects());
379  for (trigger::size_type idx = 0; idx < nI_; ++idx) {
380  const trigger::TriggerObject& TO(TOC[KEYS_[idx]]);
381  //VIDS : muons-->83 / jets-->85 / met-->87 / photon-->81
382  edm::LogInfo("ZGammaplusJetsMonitor") << " idx: " << idx << "| vid " << VIDS_[idx] << "|"
383  << " keys " << KEYS_[idx] << "triggerobject: "
384  << " obj_id " << TO.id() << " Pt " << TO.pt() << " eta " << TO.eta()
385  << " phi " << TO.phi() << " mass " << TO.mass();
386  }
387  if (VIDS_[0] == 81) { //photon
388  for (const auto& key : KEYS_) {
389  trigobj_pt.push_back(TOC[key].pt());
390  trigobj_eta.push_back(TOC[key].eta());
391  trigobj_phi.push_back(TOC[key].phi());
392  }
393  }
394  if (VIDS_[0] == 83 && nK_ < 2) { //muon
395  edm::LogInfo("ZGammaplusJetsMonitor") << " under 2 objects cant have a dimuon";
396  return;
397  } else {
398  for (const auto& key : KEYS_) {
399  double pt = TOC[key].pt();
400  double eta = TOC[key].eta();
401  double phi = TOC[key].phi();
402  double mass = TOC[key].mass();
403  int id = TOC[key].id();
404  unsigned int kCnt0 = 0;
405 
406  TLorentzVector v1; //keep first muon
407  if (std::abs(id) == 13) { // check if it is a muon
408  v1.SetPtEtaPhiM(pt, eta, phi, mass);
409  } else {
410  v1.SetPtEtaPhiM(0., 0., 0., 0.);
411  }
412  unsigned int kCnt1 = 0;
413  for (const auto& key1 : KEYS_) {
414  if (key != key1 && kCnt1 > kCnt0) { // avoid double counting separate objs
415 
416  double pt2 = TOC[key1].pt();
417  double eta2 = TOC[key1].eta();
418  double phi2 = TOC[key1].phi();
419  double mass2 = TOC[key1].mass();
420  int id2 = TOC[key1].id();
421 
422  if ((id + id2) == 0) { // check di-object system charge and flavor
423 
424  TLorentzVector v2;
425  if (std::abs(id2) == 13) { // check if it is a muon
426  v2.SetPtEtaPhiM(pt2, eta2, phi2, mass2);
427  } else {
428  v2.SetPtEtaPhiM(0., 0., 0., 0.0);
429  }
430 
431  muon_1 = v1;
432  muon_2 = v2;
433  bool muon_pass = muon_1.Pt() > muon_pt && muon_2.Pt() > muon_pt && std::abs(muon_1.Eta()) < muon_eta &&
434  std::abs(muon_2.Eta()) < muon_eta;
435  if (!muon_pass) {
436  return;
437  }
438 
439  Zhltreco = muon_1 + muon_2;
440  bool Z_pass = std::abs(Zhltreco.M() - 91.2) < Z_DM && Zhltreco.Pt() > Z_Pt;
441  if (!Z_pass) {
442  return;
443  }
444  trigobj_pt.push_back(Zhltreco.Pt());
445  trigobj_eta.push_back(Zhltreco.Eta());
446  trigobj_phi.push_back(Zhltreco.Phi());
447  } //end check di-object
448  else { //if not di-object
449  return;
450  }
451  } // end avoid duplicate objects
452  kCnt1++;
453  } // key1
454  kCnt0++;
455  } // key
456  } // end else
457 
458  // ---------------- module for Jet leg Jets --------------------------
459  // index of last module executed in this Path
460  const unsigned int moduleIndex = triggerResults->index(index); // here would be HLTBool at the end
461  edm::LogInfo("ZGammaplusJetsMonitor")
462  << " Module Index " << moduleIndex - 1 << " Module Name "
463  << module_names[moduleIndex - 1]; // the second to last would be the last module that is saved
464  assert(moduleIndex < module_size);
465 
466  // results from TriggerEvent product
467  const std::string& ImoduleLabel = module_names[moduleIndex - 1];
468  const std::string ImoduleType = hltConfig_.moduleType(ImoduleLabel);
469  edm::LogInfo("ZGammaplusJetsMonitor") << ImoduleLabel << " | " << ImoduleType;
470  // check whether the module is packed up in TriggerEvent product
471  const unsigned int filterIndex = aodTriggerEvent->filterIndex(edm::InputTag(ImoduleLabel, "", processName_));
472  if (filterIndex >= aodTriggerEvent->sizeFilters()) {
473  return;
474  }
475  const trigger::Vids& VIDS = aodTriggerEvent->filterIds(filterIndex);
476  const trigger::Keys& KEYS = aodTriggerEvent->filterKeys(filterIndex);
477  const trigger::size_type nI = VIDS.size();
478  const trigger::size_type nK = KEYS.size();
479  assert(nI == nK);
480  const trigger::TriggerObjectCollection& objects(aodTriggerEvent->getObjects());
481  for (trigger::size_type idx = 0; idx < nI; ++idx) {
482  const trigger::TriggerObject& TO_(objects[KEYS[idx]]);
483  //VIDS : muons-->83 / jets-->85 / met-->87
484  edm::LogInfo("ZGammaplusJetsMonitor")
485  << " idx " << idx << " vid " << VIDS[idx] << "/"
486  << " keys " << KEYS[idx] << ": "
487  << " obj_id " << TO_.id() << " " << TO_.pt() << " " << TO_.eta() << " " << TO_.phi() << " " << TO_.mass();
488  }
489  for (const auto& key : KEYS) {
490  v_jetpt.push_back(objects[key].pt());
491  v_jeteta.push_back(objects[key].eta());
492  v_jetphi.push_back(objects[key].phi());
493  }
494  bool Jet_pass = (!v_jetpt.empty() && v_jetpt[0] >= pt_cut);
495  if (!Jet_pass) {
496  return;
497  }
498  double dphi = std::abs(v_jetphi[0] - trigobj_phi[0]);
499  if (dphi > M_PI) {
500  dphi = 2 * M_PI - dphi;
501  }
502  if (dphi < dphi_cut) { // be sure is back to back
503  return;
504  }
505  // --- offline Jets -----
507  iEvent.getByToken(jetToken_, jetHandle);
509  iEvent.getByToken(correctorToken_, Corrector);
510  double leading_JetPt = -10.0;
511  double leading_JetEta = -10.0;
512  double leading_JetPhi = -10.0;
513  int ind = 0;
514 
515  if (!jetHandle.isValid()) {
516  edm::LogWarning("ZGammaplusJetsMonitor")
517  << "skipping events because the collection " << jetInputTag_.label().c_str() << " is not available";
518  return;
519  }
520  for (auto const& j : *jetHandle) {
521  if (Corrector.isValid()) {
522  double jec = Corrector->correction(j);
523  double cor_jet = jec * j.pt();
524  if (cor_jet > leading_JetPt) {
525  leading_JetPt = cor_jet;
526  leading_JetEta = j.eta();
527  leading_JetPhi = j.phi();
528  }
529  } else if (!Corrector.isValid() && ind == 0) {
530  leading_JetPt = j.pt();
531  leading_JetEta = j.eta();
532  leading_JetPhi = j.phi();
533  ind += 1;
534  }
535  }
536  if (leading_JetPt < offline_cut) { // offline cuts
537  return;
538  }
539 
540  if (!(isMatched(v_jeteta[0], v_jetphi[0], leading_JetEta, leading_JetPhi))) {
541  return;
542  }
543 
544  double DirectBalance_ = v_jetpt[0] / trigobj_pt[0];
545  double DifJ1PtTrObjPt_ = v_jetpt[0] - trigobj_pt[0];
546  double asymmetry = (trigobj_pt[0] - v_jetpt[0]) / (trigobj_pt[0] + v_jetpt[0]);
547 
548  // ------------------------- Filling Histos -----------------------------------
549  if (isMuonPath_) {
551  }
553  fillME(a_ME, DirectBalance_, DifJ1PtTrObjPt_, asymmetry, trigobj_pt[0], v_jetpt[0], true);
554  if (isBarrel(v_jeteta[0])) {
555  fillME(a_ME_HB, DirectBalance_, DifJ1PtTrObjPt_, asymmetry, trigobj_pt[0], v_jetpt[0], true);
556  if (islowRefPt(trigobj_pt[0])) {
557  fillME(a_ME_HB_lowRefPt, DirectBalance_, DifJ1PtTrObjPt_, asymmetry, trigobj_pt[0], v_jetpt[0], true);
558  } else if (ismediumRefPt(trigobj_pt[0])) {
559  fillME(a_ME_HB_mediumRefPt, DirectBalance_, DifJ1PtTrObjPt_, asymmetry, trigobj_pt[0], v_jetpt[0], true);
560  } else if (ishighRefPt(trigobj_pt[0])) {
561  fillME(a_ME_HB_highRefPt, DirectBalance_, DifJ1PtTrObjPt_, asymmetry, trigobj_pt[0], v_jetpt[0], true);
562  }
563  } // end is barrel
564  if (isEndCapInner(v_jeteta[0])) {
565  fillME(a_ME_HE_I, DirectBalance_, DifJ1PtTrObjPt_, asymmetry, trigobj_pt[0], v_jetpt[0], true);
566  if (islowRefPt(trigobj_pt[0])) {
567  fillME(a_ME_HE_I_lowRefPt, DirectBalance_, DifJ1PtTrObjPt_, asymmetry, trigobj_pt[0], v_jetpt[0], true);
568  } else if (ismediumRefPt(trigobj_pt[0])) {
569  fillME(a_ME_HE_I_mediumRefPt, DirectBalance_, DifJ1PtTrObjPt_, asymmetry, trigobj_pt[0], v_jetpt[0], true);
570  } else if (ishighRefPt(trigobj_pt[0])) {
571  fillME(a_ME_HE_I_highRefPt, DirectBalance_, DifJ1PtTrObjPt_, asymmetry, trigobj_pt[0], v_jetpt[0], true);
572  }
573  } // end is endcap-inner
574  if (isEndCapOuter(v_jeteta[0])) {
575  fillME(a_ME_HE_O, DirectBalance_, DifJ1PtTrObjPt_, asymmetry, trigobj_pt[0], v_jetpt[0], true);
576  if (islowRefPt(trigobj_pt[0])) {
577  fillME(a_ME_HE_O_lowRefPt, DirectBalance_, DifJ1PtTrObjPt_, asymmetry, trigobj_pt[0], v_jetpt[0], true);
578  } else if (ismediumRefPt(trigobj_pt[0])) {
579  fillME(a_ME_HE_O_mediumRefPt, DirectBalance_, DifJ1PtTrObjPt_, asymmetry, trigobj_pt[0], v_jetpt[0], true);
580  } else if (ishighRefPt(trigobj_pt[0])) {
581  fillME(a_ME_HE_O_highRefPt, DirectBalance_, DifJ1PtTrObjPt_, asymmetry, trigobj_pt[0], v_jetpt[0], true);
582  }
583  } // end is endcap-outer
584  if (isForward(v_jeteta[0])) {
585  fillME(a_ME_HF, DirectBalance_, DifJ1PtTrObjPt_, asymmetry, trigobj_pt[0], v_jetpt[0], true);
586  if (islowRefPt(trigobj_pt[0])) {
587  fillME(a_ME_HF_lowRefPt, DirectBalance_, DifJ1PtTrObjPt_, asymmetry, trigobj_pt[0], v_jetpt[0], true);
588  } else if (ismediumRefPt(trigobj_pt[0])) {
589  fillME(a_ME_HF_mediumRefPt, DirectBalance_, DifJ1PtTrObjPt_, asymmetry, trigobj_pt[0], v_jetpt[0], true);
590  } else if (ishighRefPt(trigobj_pt[0])) {
591  fillME(a_ME_HF_highRefPt, DirectBalance_, DifJ1PtTrObjPt_, asymmetry, trigobj_pt[0], v_jetpt[0], true);
592  }
593  } // end is Forward
594 }
595 // ----- Reference'Pt categories: low[30,50), medium[50,100), high[100,inf) -----
597  bool output = false;
598  if (refPt >= 30. && refPt < 50.)
599  output = true;
600  return output;
601 }
602 
604  bool output = false;
605  if (refPt >= 50. && refPt < 100.)
606  output = true;
607  return output;
608 }
609 
611  bool output = false;
612  if (refPt >= 100.)
613  output = true;
614  return output;
615 }
616 // --------- detector areas ---------------------------------------------------
618  bool output = false;
619  if (std::abs(eta) <= 1.3)
620  output = true;
621  return output;
622 }
623 
625  bool output = false;
626  if (std::abs(eta) <= 2.5 && std::abs(eta) > 1.3)
627  output = true;
628  return output;
629 }
630 
632  bool output = false;
633  if (std::abs(eta) <= 3.0 && std::abs(eta) > 2.5)
634  output = true;
635  return output;
636 }
637 
639  bool output = false;
640  if (std::abs(eta) > 3.0)
641  output = true;
642  return output;
643 }
644 // --------- Matching ---------------------------------------------------------------
645 bool ZGammaplusJetsMonitor::isMatched(double hltJetEta, double hltJetPhi, double OffJetEta, double OffJetPhi) {
646  bool output = false;
647  double DRMatched2 = 0.16;
648  double dR2 = deltaR2(hltJetEta, hltJetPhi, OffJetEta, OffJetPhi);
649  if (dR2 < DRMatched2)
650  output = true;
651  return output;
652 }
653 
655  const double directbalance_,
656  const double Difjetref_,
657  const double Asymmetry_,
658  const double ReferencePt_,
659  const double Jetpt_,
660  const bool doDirectBalancevsReferencePt) {
661  a_me[0].numerator->Fill(directbalance_); // index 0 = DirectBalance
662  a_me[1].numerator->Fill(Difjetref_); // index 1 = Leading JetPt minus Reference Pt
663  a_me[2].numerator->Fill(Asymmetry_); // index 2 = asymmetry
664  a_me[3].numerator->Fill(ReferencePt_); // index 3 = Reference Pt
665  a_me[4].numerator->Fill(Jetpt_); // index 4 = Jet Pt
666  if (doDirectBalancevsReferencePt) {
667  a_me[5].numerator->Fill(ReferencePt_, directbalance_); // index 5 = Balance vs Reference' Pt
668  }
669 }
670 
672  ObjME* a_me,
673  const int len_,
674  const std::string& h_Name,
675  const std::string& h_Title,
676  const std::string& h_subOptName,
677  const std::string& hSubT,
678  const bool doDirectBalancevsReferencePt,
679  const bool bookDen) {
680  std::string hName = h_Name;
681  std::string hTitle = h_Title;
682  const std::string hSubN = h_subOptName.empty() ? "" : "_" + h_subOptName;
683 
684  int nbin_DifJetRef = DifJetRefPT_Binning.nbins;
685  double maxbin_DifJetRef = DifJetRefPT_Binning.xmax;
686  double minbin_DifJetRef = DifJetRefPT_Binning.xmin;
687 
688  hName = "DirectBalance" + hSubN;
689  hTitle = " DirectBalance " + hSubT;
690  bookME(Ibooker, a_me[0], hName, hTitle, directbalance_Binning, bookDen);
691  setMETitle(a_me[0], "HLTJetPt/" + h_Name + "Pt", "events");
692 
693  hName = "JetPt1_minus_" + h_Name + "Pt" + hSubN;
694  hTitle = "LeadingJet Pt minus " + h_Name + " Pt " + hSubT;
695  bookME(Ibooker, a_me[1], hName, hTitle, nbin_DifJetRef, minbin_DifJetRef, maxbin_DifJetRef, bookDen);
696  setMETitle(a_me[1], "Pt dif [GeV]", "events");
697 
698  hName = h_Name + "JetAsymmetry" + hSubN;
699  hTitle = h_Title + " Jet Asymmetry " + hSubT;
700  bookME(Ibooker, a_me[2], hName, hTitle, directbalance_Binning, bookDen);
701  setMETitle(a_me[2], hTitle, "events");
702 
703  hName = h_Name + "pT" + hSubN;
704  hTitle = h_Title + " pT " + hSubT;
705  bookME(Ibooker, a_me[3], hName, hTitle, TrObjPt_Binning, bookDen);
706  setMETitle(a_me[3], h_Title + " pT [GeV]", "events / [GeV]");
707 
708  hName = "JetpT" + hSubN;
709  hTitle = "Jet pT " + hSubN;
710  bookME(Ibooker, a_me[4], hName, hTitle, jetpt_Binning, bookDen);
711  setMETitle(a_me[4], hTitle + " [GeV]", "events / [GeV]");
712 
713  if (doDirectBalancevsReferencePt) {
714  hName = "DirectBalanceVs" + h_Name + "Pt" + hSubN;
715  hTitle = "Direct Balance vs " + h_Title + " Pt " + hSubT;
716  bookME(Ibooker, a_me[5], hName, hTitle, TrObjPt_Binning, directbalance_Binning, bookDen);
717  setMETitle(a_me[5], h_Title + " pt", "Direct Balance");
718  }
719 }
720 
722  TPRegexp pattern(pathName);
723  // https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuideHighLevelTrigger#Access_to_the_HLT_configuration
724  // "init" return value indicates whether intitialisation has succeeded
725  // "changed" parameter indicates whether the config has actually changed
726  bool changed(true);
727  if (hltConfig_.init(iRun, iSetup, processName_, changed)) {
728  // if init returns TRUE, initialisation has succeeded!
729  if (changed) {
730  // The HLT config has actually changed wrt the previous Run, hence rebook your
731  // histograms or do anything else dependent on the revised HLT config
732  std::vector<std::string> triggerPaths = hltConfig_.triggerNames();
733  for (const auto& PATHNAME : triggerPaths) {
734  edm::LogInfo("ZGammaplusJetsMonitor::dqmBeginRun ") << PATHNAME;
735  if (TString(PATHNAME).Contains(pattern)) {
736  fullpathName = PATHNAME;
737  }
738  }
739  }
740  } else {
741  // if init returns FALSE, initialisation has NOT succeeded, which indicates a problem
742  // with the file and/or code and needs to be investigated!
743  edm::LogError("ZGammaplusJetsMonitor") << " HLT config extraction failure with process name " << processName_;
744  // In this case, all access methods will return empty values!
745  }
746 }
747 
750  desc.add<std::string>("FolderName", "HLT/JME/ZGammaPlusJets");
751  desc.add<std::string>("processName", "HLT");
752  desc.add<edm::InputTag>("triggerEventObject", edm::InputTag("hltTriggerSummaryAOD::HLT"));
753  desc.add<edm::InputTag>("TriggerResultsLabel", edm::InputTag("TriggerResults::HLT"));
754  desc.add<std::string>("PathName", "");
755  desc.add<std::string>("ModuleName", "");
756  desc.add<edm::InputTag>("jets", edm::InputTag("ak4PFJetsPuppi"));
757  desc.add<edm::InputTag>("corrector", edm::InputTag("ak4PFPuppiL1FastL2L3Corrector"));
758 
759  desc.add<double>("muonpt", 20.);
760  desc.add<double>("muoneta", 2.3);
761  desc.add<double>("ptcut", 30.);
762  desc.add<double>("Z_Dmass", 20.);
763  desc.add<double>("Z_pt", 30.);
764  desc.add<double>("DeltaPhi", 2.7);
765  desc.add<double>("OfflineCut", 20.0);
766  desc.add<bool>("isMuonPath", true);
767 
769 
770  std::vector<double> bins = {
771  -3.99, -3.97, -3.95, -3.93, -3.91, -3.89, -3.87, -3.85, -3.83, -3.81, -3.79, -3.77, -3.75, -3.73, -3.71, -3.69,
772  -3.67, -3.65, -3.63, -3.61, -3.59, -3.57, -3.55, -3.53, -3.51, -3.49, -3.47, -3.45, -3.43, -3.41, -3.39, -3.37,
773  -3.35, -3.33, -3.31, -3.29, -3.27, -3.25, -3.23, -3.21, -3.19, -3.17, -3.15, -3.13, -3.11, -3.09, -3.07, -3.05,
774  -3.03, -3.01, -2.99, -2.97, -2.95, -2.93, -2.91, -2.89, -2.87, -2.85, -2.83, -2.81, -2.79, -2.77, -2.75, -2.73,
775  -2.71, -2.69, -2.67, -2.65, -2.63, -2.61, -2.59, -2.57, -2.55, -2.53, -2.51, -2.49, -2.47, -2.45, -2.43, -2.41,
776  -2.39, -2.37, -2.35, -2.33, -2.31, -2.29, -2.27, -2.25, -2.23, -2.21, -2.19, -2.17, -2.15, -2.13, -2.11, -2.09,
777  -2.07, -2.05, -2.03, -2.01, -1.99, -1.97, -1.95, -1.93, -1.91, -1.89, -1.87, -1.85, -1.83, -1.81, -1.79, -1.77,
778  -1.75, -1.73, -1.71, -1.69, -1.67, -1.65, -1.63, -1.61, -1.59, -1.57, -1.55, -1.53, -1.51, -1.49, -1.47, -1.45,
779  -1.43, -1.41, -1.39, -1.37, -1.35, -1.33, -1.31, -1.29, -1.27, -1.25, -1.23, -1.21, -1.19, -1.17, -1.15, -1.13,
780  -1.11, -1.09, -1.07, -1.05, -1.03, -1.01, -0.99, -0.97, -0.95, -0.93, -0.91, -0.89, -0.87, -0.85, -0.83, -0.81,
781  -0.79, -0.77, -0.75, -0.73, -0.71, -0.69, -0.67, -0.65, -0.63, -0.61, -0.59, -0.57, -0.55, -0.53, -0.51, -0.49,
782  -0.47, -0.45, -0.43, -0.41, -0.39, -0.37, -0.35, -0.33, -0.31, -0.29, -0.27, -0.25, -0.23, -0.21, -0.19, -0.17,
783  -0.15, -0.13, -0.11, -0.09, -0.07, -0.05, -0.03, -0.01, 0.01, 0.03, 0.05, 0.07, 0.09, 0.11, 0.13, 0.15,
784  0.17, 0.19, 0.21, 0.23, 0.25, 0.27, 0.29, 0.31, 0.33, 0.35, 0.37, 0.39, 0.41, 0.43, 0.45, 0.47,
785  0.49, 0.51, 0.53, 0.55, 0.57, 0.59, 0.61, 0.63, 0.65, 0.67, 0.69, 0.71, 0.73, 0.75, 0.77, 0.79,
786  0.81, 0.83, 0.85, 0.87, 0.89, 0.91, 0.93, 0.95, 0.97, 0.99, 1.01, 1.03, 1.05, 1.07, 1.09, 1.11,
787  1.13, 1.15, 1.17, 1.19, 1.21, 1.23, 1.25, 1.27, 1.29, 1.31, 1.33, 1.35, 1.37, 1.39, 1.41, 1.43,
788  1.45, 1.47, 1.49, 1.51, 1.53, 1.55, 1.57, 1.59, 1.61, 1.63, 1.65, 1.67, 1.69, 1.71, 1.73, 1.75,
789  1.77, 1.79, 1.81, 1.83, 1.85, 1.87, 1.89, 1.91, 1.93, 1.95, 1.97, 1.99, 2.01, 2.03, 2.05, 2.07,
790  2.09, 2.11, 2.13, 2.15, 2.17, 2.19, 2.21, 2.23, 2.25, 2.27, 2.29, 2.31, 2.33, 2.35, 2.37, 2.39,
791  2.41, 2.43, 2.45, 2.47, 2.49, 2.51, 2.53, 2.55, 2.57, 2.59, 2.61, 2.63, 2.65, 2.67, 2.69, 2.71,
792  2.73, 2.75, 2.77, 2.79, 2.81, 2.83, 2.85, 2.87, 2.89, 2.91, 2.93, 2.95, 2.97, 2.99, 3.01, 3.03,
793  3.05, 3.07, 3.09, 3.11, 3.13, 3.15, 3.17, 3.19, 3.21, 3.23, 3.25, 3.27, 3.29, 3.31, 3.33, 3.35,
794  3.37, 3.39, 3.41, 3.43, 3.45, 3.47, 3.49, 3.51, 3.53, 3.55, 3.57, 3.59, 3.61, 3.63, 3.65, 3.67,
795  3.69, 3.71, 3.73, 3.75, 3.77, 3.79, 3.81, 3.83, 3.85, 3.87, 3.89, 3.91, 3.93, 3.95, 3.97, 3.99,
796  4.01, 4.03, 4.05, 4.07, 4.09, 4.11, 4.13, 4.15, 4.17, 4.19, 4.21, 4.23, 4.25, 4.27, 4.29, 4.31,
797  4.33, 4.35, 4.37, 4.39, 4.41, 4.43, 4.45, 4.47, 4.49, 4.51, 4.53, 4.55, 4.57, 4.59, 4.61, 4.63,
798  4.65, 4.67, 4.69, 4.71, 4.73, 4.75, 4.77, 4.79, 4.81, 4.83, 4.85, 4.87, 4.89, 4.91, 4.93, 4.95,
799  4.97, 4.99, 5.01, 5.03, 5.05, 5.07, 5.09, 5.11, 5.13, 5.15, 5.17, 5.19, 5.21, 5.23, 5.25, 5.27,
800  5.29, 5.31, 5.33, 5.35, 5.37, 5.39, 5.41, 5.43, 5.45, 5.47, 5.49, 5.51, 5.53, 5.55, 5.57, 5.59,
801  5.61, 5.63, 5.65, 5.67, 5.69, 5.71, 5.73, 5.75, 5.77, 5.79, 5.81, 5.83, 5.85, 5.87, 5.89, 5.91,
802  5.93, 5.95, 5.97, 5.99};
803 
804  histoPSet.add<std::vector<double> >("directbalanceBinning", bins);
805 
806  std::vector<double> bins_ = {12, 15, 20, 25, 30, 35, 40, 45, 50, 60, 70,
807  85, 105, 130, 175, 230, 300, 400, 500, 700, 1000, 1500}; // Z or photon pT Binning
808  histoPSet.add<std::vector<double> >("TrObjPtBinning", bins_);
809  std::vector<double> Jbins_ = {
810  0., 20., 40., 60., 80., 90., 100., 110., 120., 130., 140., 150., 160.,
811  170., 180., 190., 200., 220., 240., 260., 280., 300., 350., 400., 450., 1000.}; // Jet pT Binning
812  histoPSet.add<std::vector<double> >("jetptBinning", Jbins_);
813 
814  desc.add<edm::ParameterSetDescription>("histoPSet", histoPSet);
815 
816  descriptions.add("zgammajetsmonitoring", desc);
817 }
818 
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const Keys & filterKeys(trigger::size_type index) const
Definition: TriggerEvent.h:119
const edm::InputTag jetInputTag_
const edm::EDGetTokenT< reco::JetCorrector > correctorToken_
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
std::vector< double > directbalance_Binning
const edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
trigger::size_type sizeFilters() const
Definition: TriggerEvent.h:147
HLTConfigProvider hltConfig_
std::vector< double > v_jetphi
bool isMatched(double hltJetEta, double hltJetPhi, double OffJetEta, double OffJetPhi)
bool islowRefPt(double RefPt)
const std::string moduleType(const std::string &module) const
C++ class name of module.
dqm::reco::MonitorElement MonitorElement
std::vector< double > trigobj_eta
std::string const & label() const
Definition: InputTag.h:36
std::vector< double > v_jeteta
Log< level::Error, false > LogError
double correction(const LorentzVector &fJet) const
get correction using Jet information only
Definition: JetCorrector.h:46
assert(be >=bs)
uint16_t size_type
void setMETitle(ObjME &me, const std::string &titleX, const std::string &titleY)
std::vector< double > trigobj_phi
const std::string processName_
void dqmBeginRun(edm::Run const &iRun, edm::EventSetup const &iSetup) override
unsigned int triggerIndex(std::string_view name) const
Definition: TriggerNames.cc:52
void Fill(long long x)
Single trigger physics object (e.g., an isolated muon)
Definition: TriggerObject.h:21
void bookMESub(DQMStore::IBooker &, ObjME *a_me, const int len_, const std::string &h_Name, const std::string &h_Title, const std::string &h_subOptName, const std::string &h_subOptTitle, const bool doDirectBalancevsReferencePt=true, const bool bookDen=false)
int iEvent
Definition: GenABIO.cc:224
dqm::reco::DQMStore DQMStore
ALPAKA_FN_ACC static ALPAKA_FN_INLINE float dR2(Position4 pos1, Position4 pos2)
unsigned int size() const
number of trigger paths in trigger table
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
const edm::EDGetTokenT< trigger::TriggerEvent > triggerEventObject_
MonitorElement * numerator
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const TriggerObjectCollection & getObjects() const
Definition: TriggerEvent.h:102
int id() const
getters
Definition: TriggerObject.h:51
key
prepare the HTCondor submission files and eventually submit them
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
unsigned int triggerIndex(const std::string &triggerName) const
slot position of trigger path in trigger table (0 to size-1)
static std::string const triggerResults
Definition: EdmProvDump.cc:47
ZGammaplusJetsMonitor(const edm::ParameterSet &)
std::size_t size() const
Definition: TriggerNames.cc:59
#define M_PI
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:75
Log< level::Info, false > LogInfo
const Vids & filterIds(trigger::size_type index) const
Definition: TriggerEvent.h:118
std::vector< double > v_jetpt
bool ismediumRefPt(double RefPt)
trigger::size_type filterIndex(const edm::InputTag &filterTag) const
find index of filter in data-member vector from filter tag
Definition: TriggerEvent.h:133
std::vector< double > trigobj_pt
std::vector< size_type > Keys
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
const edm::EDGetTokenT< reco::PFJetCollection > jetToken_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
bool ishighRefPt(double RefPt)
const std::vector< std::string > & triggerNames() const
names of trigger paths
void fillME(ObjME *a_me, const double directbalance_, const double Difjetref_, const double Assymetry_, const double ReferencePt_, const double Jetpt_, const bool doDirectBalancevsReferencePt=true)
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)
void analyze(edm::Event const &iEvent, edm::EventSetup const &iSetup) override
std::vector< PFJet > PFJetCollection
collection of PFJet objects
fixed size matrix
HLT enums.
std::vector< double > jetpt_Binning
const std::string moduleName
Definition: output.py:1
Log< level::Warning, false > LogWarning
static std::string const triggerPaths
Definition: EdmProvDump.cc:48
const std::string folderName_
std::vector< int > Vids
Definition: Run.h:45
bool passTrig(const float objEta, float objPhi, const trigger::TriggerEvent &trigEvt, const std::string &filterName, const std::string &processName)
Definition: UtilFuncs.h:14
std::vector< double > TrObjPt_Binning