CMS 3D CMS Logo

HLTObjectMonitor.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: DQM/HLTObjectMonitor
4 // Class: HLTObjectMonitor
5 //
13 //
14 // Original Author: Charles Nicholas Mueller
15 // Created: Sun, 22 Mar 2015 22:29:00 GMT
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 #include <sys/time.h>
22 #include <cstdlib>
23 
24 // user include files
30 
36 
38 
39 //for collections
49 
52 
53 #include "TMath.h"
54 #include "TStyle.h"
55 #include "TLorentzVector.h"
56 
57 #include <unordered_map>
58 //
59 // class declaration
60 //
61 
62 //using namespace edm;
63 using namespace trigger;
64 using std::string;
65 using std::unordered_map;
66 using std::vector;
67 
69  struct hltPlot {
71  string pathName;
72  string pathNameOR;
73  string moduleName;
74  string moduleNameOR;
75  int pathIndex = -99;
76  int pathIndexOR = -99;
77  string plotLabel;
78  string xAxisLabel;
79  int nBins;
80  double xMin;
81  double xMax;
83  };
84 
85 public:
86  explicit HLTObjectMonitor(const edm::ParameterSet&);
87  ~HLTObjectMonitor() override;
88 
89  // static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
90 
91 private:
92  void analyze(const edm::Event&, const edm::EventSetup&) override;
93  void bookHistograms(DQMStore::IBooker& i, edm::Run const&, edm::EventSetup const&) override;
94  void dqmBeginRun(edm::Run const&, edm::EventSetup const&) override;
95  vector<hltPlot*> plotList;
96  //virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
97  //virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
99  double get_wall_time(void);
100  // ----------member data ---------------------------
101 
106  string backupFolder;
107  unordered_map<string, bool> acceptMap;
108  unordered_map<hltPlot*, edm::ParameterSet*> plotMap;
109 
110  //set Token(-s)
120 
121  //declare params
162 
163  string processName_;
164 
205 };
206 
207 //
208 // constants, enums and typedefs
209 //
210 
211 //
212 // static data member definitions
213 //
214 
215 //
216 // constructors and destructor
217 //
219 
220 {
221  //now do what ever initialization is needed
222  debugPrint = false;
223 
224  topDirectoryName = "HLT/ObjectMonitor";
225  mainShifterFolder = topDirectoryName + "/MainShifter";
226  backupFolder = topDirectoryName + "/Backup";
227 
228  //parse params
229  processName_ = iConfig.getParameter<string>("processName");
230 
231  rsq_pset = iConfig.getParameter<edm::ParameterSet>("rsq");
232  plotMap[&rsq_] = &rsq_pset;
233  mr_pset = iConfig.getParameter<edm::ParameterSet>("mr");
234  plotMap[&mr_] = &mr_pset;
235  alphaT_pset = iConfig.getParameter<edm::ParameterSet>("alphaT");
236  plotMap[&alphaT_] = &alphaT_pset;
237  photonPt_pset = iConfig.getParameter<edm::ParameterSet>("photonPt");
238  plotMap[&photonPt_] = &photonPt_pset;
239  photonEta_pset = iConfig.getParameter<edm::ParameterSet>("photonEta");
240  plotMap[&photonEta_] = &photonEta_pset;
241  photonPhi_pset = iConfig.getParameter<edm::ParameterSet>("photonPhi");
242  plotMap[&photonPhi_] = &photonPhi_pset;
243  muonPt_pset = iConfig.getParameter<edm::ParameterSet>("muonPt");
244  plotMap[&muonPt_] = &muonPt_pset;
245  muonEta_pset = iConfig.getParameter<edm::ParameterSet>("muonEta");
246  plotMap[&muonEta_] = &muonEta_pset;
247  muonPhi_pset = iConfig.getParameter<edm::ParameterSet>("muonPhi");
248  plotMap[&muonPhi_] = &muonPhi_pset;
249  l2muonPt_pset = iConfig.getParameter<edm::ParameterSet>("l2muonPt");
250  plotMap[&l2muonPt_] = &l2muonPt_pset;
251  l2muonEta_pset = iConfig.getParameter<edm::ParameterSet>("l2muonEta");
252  plotMap[&l2muonEta_] = &l2muonEta_pset;
253  l2muonPhi_pset = iConfig.getParameter<edm::ParameterSet>("l2muonPhi");
254  plotMap[&l2muonPhi_] = &l2muonPhi_pset;
255  l2NoBPTXmuonPt_pset = iConfig.getParameter<edm::ParameterSet>("l2NoBPTXmuonPt");
256  plotMap[&l2NoBPTXmuonPt_] = &l2NoBPTXmuonPt_pset;
257  l2NoBPTXmuonEta_pset = iConfig.getParameter<edm::ParameterSet>("l2NoBPTXmuonEta");
258  plotMap[&l2NoBPTXmuonEta_] = &l2NoBPTXmuonEta_pset;
259  l2NoBPTXmuonPhi_pset = iConfig.getParameter<edm::ParameterSet>("l2NoBPTXmuonPhi");
260  plotMap[&l2NoBPTXmuonPhi_] = &l2NoBPTXmuonPhi_pset;
261  electronPt_pset = iConfig.getParameter<edm::ParameterSet>("electronPt");
262  plotMap[&electronPt_] = &electronPt_pset;
263  electronEta_pset = iConfig.getParameter<edm::ParameterSet>("electronEta");
264  plotMap[&electronEta_] = &electronEta_pset;
265  electronPhi_pset = iConfig.getParameter<edm::ParameterSet>("electronPhi");
266  plotMap[&electronPhi_] = &electronPhi_pset;
267  jetPt_pset = iConfig.getParameter<edm::ParameterSet>("jetPt");
268  plotMap[&jetPt_] = &jetPt_pset;
269  jetAK8Mass_pset = iConfig.getParameter<edm::ParameterSet>("jetAK8Mass");
270  plotMap[&jetAK8Mass_] = &jetAK8Mass_pset;
271  diMuonLowMass_pset = iConfig.getParameter<edm::ParameterSet>("diMuonLowMass");
272  plotMap[&diMuonLowMass_] = &diMuonLowMass_pset;
273  caloMetPt_pset = iConfig.getParameter<edm::ParameterSet>("caloMetPt");
274  plotMap[&caloMetPt_] = &caloMetPt_pset;
275  caloMetPhi_pset = iConfig.getParameter<edm::ParameterSet>("caloMetPhi");
276  plotMap[&caloMetPhi_] = &caloMetPhi_pset;
277  pfMetPt_pset = iConfig.getParameter<edm::ParameterSet>("pfMetPt");
278  plotMap[&pfMetPt_] = &pfMetPt_pset;
279  pfMetPhi_pset = iConfig.getParameter<edm::ParameterSet>("pfMetPhi");
280  plotMap[&pfMetPhi_] = &pfMetPhi_pset;
281  caloHtPt_pset = iConfig.getParameter<edm::ParameterSet>("caloHtPt");
282  plotMap[&caloHtPt_] = &caloHtPt_pset;
283  pfHtPt_pset = iConfig.getParameter<edm::ParameterSet>("pfHtPt");
284  plotMap[&pfHtPt_] = &pfHtPt_pset;
285  bJetPhi_pset = iConfig.getParameter<edm::ParameterSet>("bJetPhi");
286  plotMap[&bJetPhi_] = &bJetPhi_pset;
287  bJetEta_pset = iConfig.getParameter<edm::ParameterSet>("bJetEta");
288  plotMap[&bJetEta_] = &bJetEta_pset;
289  bJetCSVCalo_pset = iConfig.getParameter<edm::ParameterSet>("bJetCSVCalo");
290  plotMap[&bJetCSVCalo_] = &bJetCSVCalo_pset;
291  bJetCSVPF_pset = iConfig.getParameter<edm::ParameterSet>("bJetCSVPF");
292  plotMap[&bJetCSVPF_] = &bJetCSVPF_pset;
293  diMuonMass_pset = iConfig.getParameter<edm::ParameterSet>("diMuonMass");
294  plotMap[&diMuonMass_] = &diMuonMass_pset;
295  pAL1DoubleMuZMass_pset = iConfig.getParameter<edm::ParameterSet>("pAL1DoubleMuZMass");
296  plotMap[&pAL1DoubleMuZMass_] = &pAL1DoubleMuZMass_pset;
297  pAL2DoubleMuZMass_pset = iConfig.getParameter<edm::ParameterSet>("pAL2DoubleMuZMass");
298  plotMap[&pAL2DoubleMuZMass_] = &pAL2DoubleMuZMass_pset;
299  pAL3DoubleMuZMass_pset = iConfig.getParameter<edm::ParameterSet>("pAL3DoubleMuZMass");
300  plotMap[&pAL3DoubleMuZMass_] = &pAL3DoubleMuZMass_pset;
301  diElecMass_pset = iConfig.getParameter<edm::ParameterSet>("diElecMass");
302  plotMap[&diElecMass_] = &diElecMass_pset;
303  muonDxy_pset = iConfig.getParameter<edm::ParameterSet>("muonDxy");
304  plotMap[&muonDxy_] = &muonDxy_pset;
305  jetAK8Pt_pset = iConfig.getParameter<edm::ParameterSet>("jetAK8Pt");
306  plotMap[&jetAK8Pt_] = &jetAK8Pt_pset;
307  tauPt_pset = iConfig.getParameter<edm::ParameterSet>("tauPt");
308  plotMap[&tauPt_] = &tauPt_pset;
309  wallTime_pset = iConfig.getParameter<edm::ParameterSet>("wallTime");
310  plotMap[&wallTime_] = &wallTime_pset;
311 
312  for (auto item = plotMap.begin(); item != plotMap.end(); item++) {
313  (*item->first).pathName = (*item->second).getParameter<string>("pathName");
314  (*item->first).moduleName = (*item->second).getParameter<string>("moduleName");
315  (*item->first).nBins = (*item->second).getParameter<int>("NbinsX");
316  (*item->first).xMin = (*item->second).getParameter<double>("Xmin");
317  (*item->first).xMax = (*item->second).getParameter<double>("Xmax");
318  (*item->first).xAxisLabel = (*item->second).getParameter<string>("axisLabel");
319  (*item->first).plotLabel = (*item->second).getParameter<string>("plotLabel");
320  (*item->first).displayInPrimary = (*item->second).getParameter<bool>("mainWorkspace");
321 
322  if ((*item->second).exists("pathName_OR")) {
323  (*item->first).pathNameOR = (*item->second).getParameter<string>("pathName_OR");
324  }
325  if ((*item->second).exists("moduleName_OR")) {
326  (*item->first).moduleNameOR = (*item->second).getParameter<string>("moduleName_OR");
327  }
328 
329  plotList.push_back(item->first);
330  }
331  plotMap.clear();
332 
333  //set Token(s)
334  triggerResultsToken_ = consumes<edm::TriggerResults>(edm::InputTag("TriggerResults", "", processName_));
335  aodTriggerToken_ = consumes<trigger::TriggerEvent>(edm::InputTag("hltTriggerSummaryAOD", "", processName_));
336  lumiScalersToken_ = consumes<LumiScalersCollection>(edm::InputTag("hltScalersRawToDigi", "", ""));
337  beamSpotToken_ = consumes<reco::BeamSpot>(edm::InputTag("hltOnlineBeamSpot", "", processName_));
338  chargedCandToken_ = consumes<vector<reco::RecoChargedCandidate>>(
339  edm::InputTag("hltL3NoFiltersNoVtxMuonCandidates", "", processName_));
340  csvCaloTagsToken_ =
341  consumes<reco::JetTagCollection>(edm::InputTag("hltCombinedSecondaryVertexBJetTagsCalo", "", processName_));
342  csvPfTagsToken_ =
343  consumes<reco::JetTagCollection>(edm::InputTag("hltCombinedSecondaryVertexBJetTagsPF", "", processName_));
344  csvCaloJetsToken_ =
345  consumes<vector<reco::CaloJet>>(edm::InputTag("hltSelector8CentralJetsL1FastJet", "", processName_));
346  csvPfJetsToken_ = consumes<vector<reco::PFJet>>(edm::InputTag("hltPFJetForBtag", "", processName_));
347 }
348 
350  // do anything here that needs to be done at desctruction time
351  // (e.g. close files, deallocate resources etc.)
352 }
353 
354 //
355 // member functions
356 //
357 
358 // ------------ method called for each event ------------
360  double start = get_wall_time();
361 
362  using namespace edm;
363 
364  if (debugPrint)
365  std::cout << "Inside analyze(). " << std::endl;
366 
367  // access trigger results
369  iEvent.getByToken(triggerResultsToken_, triggerResults);
370  if (!triggerResults.isValid())
371  return;
372 
373  edm::Handle<trigger::TriggerEvent> aodTriggerEvent;
374  iEvent.getByToken(aodTriggerToken_, aodTriggerEvent);
375  if (!aodTriggerEvent.isValid())
376  return;
377 
378  //reset everything to not accepted at beginning of each event
379  unordered_map<string, bool> firedMap = acceptMap;
380  for (auto plot : plotList) //loop over paths
381  {
382  if (firedMap[plot->pathName])
383  continue;
384  bool triggerAccept = false;
385  const TriggerObjectCollection objects = aodTriggerEvent->getObjects();
386  edm::InputTag moduleFilter;
388  if (plot->pathIndex > 0 && triggerResults->accept(plot->pathIndex) && hltConfig_.saveTags(plot->moduleName)) {
389  moduleFilter = edm::InputTag(plot->moduleName, "", processName_);
390  pathName = plot->pathName;
391  triggerAccept = true;
392  } else if (plot->pathIndexOR > 0 && triggerResults->accept(plot->pathIndexOR) &&
393  hltConfig_.saveTags(plot->moduleNameOR)) {
394  if (firedMap[plot->pathNameOR])
395  continue;
396  moduleFilter = edm::InputTag(plot->moduleNameOR, "", processName_);
397  pathName = plot->pathNameOR;
398  triggerAccept = true;
399  }
400 
401  if (triggerAccept) {
402  unsigned int moduleFilterIndex = aodTriggerEvent->filterIndex(moduleFilter);
403 
404  if (moduleFilterIndex + 1 > aodTriggerEvent->sizeFilters())
405  return;
406  const Keys& keys = aodTriggerEvent->filterKeys(moduleFilterIndex);
407 
413 
414  //PFHT pt
415  if (pathName == pfHtPt_.pathName) {
416  for (const auto& key : keys)
417  pfHtPt_.ME->Fill(objects[key].pt());
418  }
419 
420  //jet pt
421  else if (pathName == jetPt_.pathName) {
422  for (const auto& key : keys)
423  jetPt_.ME->Fill(objects[key].pt());
424  }
425 
426  //photon pt + eta + phi (all use same path)
427  else if (pathName == photonPt_.pathName) {
428  for (const auto& key : keys) {
429  photonPt_.ME->Fill(objects[key].pt());
430  photonEta_.ME->Fill(objects[key].eta());
431  photonPhi_.ME->Fill(objects[key].phi());
432  }
433  }
434 
435  //electron pt + eta + phi (all use same path)
436  else if (pathName == electronPt_.pathName) {
437  for (const auto& key : keys) {
438  electronPt_.ME->Fill(objects[key].pt());
439  electronEta_.ME->Fill(objects[key].eta());
440  electronPhi_.ME->Fill(objects[key].phi());
441  }
442  }
443 
444  //muon pt + eta + phi (all use same path)
445  else if (pathName == muonPt_.pathName) {
446  for (const auto& key : keys) {
447  muonPt_.ME->Fill(objects[key].pt());
448  muonEta_.ME->Fill(objects[key].eta());
449  muonPhi_.ME->Fill(objects[key].phi());
450  }
451  }
452 
453  //l2muon pt
454  else if (pathName == l2muonPt_.pathName) {
455  for (const auto& key : keys) {
456  l2muonPt_.ME->Fill(objects[key].pt());
457  l2muonEta_.ME->Fill(objects[key].eta());
458  l2muonPhi_.ME->Fill(objects[key].phi());
459  }
460  }
461 
462  //l2NoBPTXmuon pt
463  else if (pathName == l2NoBPTXmuonPt_.pathName) {
464  for (const auto& key : keys) {
465  l2NoBPTXmuonPt_.ME->Fill(objects[key].pt());
466  l2NoBPTXmuonEta_.ME->Fill(objects[key].eta());
467  l2NoBPTXmuonPhi_.ME->Fill(objects[key].phi());
468  }
469  }
470 
471  //Razor
472  else if (pathName == mr_.pathName) {
473  double onlineMR = 0, onlineRsq = 0;
474  for (const auto& key : keys) {
475  if (objects[key].id() == 0) { //the MET object containing MR and Rsq will show up with ID = 0
476  onlineMR = objects[key].px(); //razor variables stored in dummy reco::MET objects
477  onlineRsq = objects[key].py();
478  }
479  mr_.ME->Fill(onlineMR);
480  rsq_.ME->Fill(onlineRsq);
481  }
482  }
483 
484  //alphaT
485  else if (pathName == alphaT_.pathName) {
486  std::vector<ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double>>> alphaT_jets;
487  for (const auto& key : keys) {
488  ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double>> JetLVec(
489  objects[key].pt(), objects[key].eta(), objects[key].phi(), objects[key].mass());
490  alphaT_jets.push_back(JetLVec);
491  }
492 
493  float alphaT = AlphaT(alphaT_jets, false).value();
494  alphaT_.ME->Fill(alphaT);
495  }
496 
497  //tau pt
498  else if (pathName == tauPt_.pathName) {
499  for (const auto& key : keys)
500  tauPt_.ME->Fill(objects[key].pt());
501  }
502 
503  //caloMET pt+phi
504  else if (pathName == caloMetPt_.pathName) {
505  for (const auto& key : keys) {
506  caloMetPt_.ME->Fill(objects[key].pt());
507  caloMetPhi_.ME->Fill(objects[key].phi());
508  }
509  }
510 
511  //caloHT pt
512  else if (pathName == caloHtPt_.pathName) {
513  for (const auto& key : keys) {
514  if (objects[key].id() == 89)
515  caloHtPt_.ME->Fill(objects[key].pt());
516  }
517  }
518 
519  //jetAK8 pt + mass
520  else if (pathName == jetAK8Pt_.pathName) {
521  for (const auto& key : keys) {
522  jetAK8Pt_.ME->Fill(objects[key].pt());
523  jetAK8Mass_.ME->Fill(objects[key].mass());
524  }
525  }
526 
527  //PFMET pt + phi
528  else if (pathName == pfMetPt_.pathName) {
529  for (const auto& key : keys) {
530  pfMetPt_.ME->Fill(objects[key].pt());
531  pfMetPhi_.ME->Fill(objects[key].phi());
532  }
533  }
534 
535  // bjet eta + phi
536  else if (pathName == bJetEta_.pathName || pathName == bJetEta_.pathNameOR) {
537  for (const auto& key : keys) {
538  bJetEta_.ME->Fill(objects[key].eta());
539  bJetPhi_.ME->Fill(objects[key].phi());
540  }
541  }
542 
543  //b-tagging CSV information
544  if (pathName == bJetCSVPF_.pathName) {
546  iEvent.getByToken(csvPfTagsToken_, csvPfTags);
548  iEvent.getByToken(csvPfJetsToken_, csvPfJets);
549 
550  if (csvPfTags.isValid() && csvPfJets.isValid()) {
551  for (auto iter = csvPfTags->begin(); iter != csvPfTags->end(); iter++)
552  bJetCSVPF_.ME->Fill(iter->second);
553  }
554  }
555  if (pathName == bJetCSVCalo_.pathName) {
557  iEvent.getByToken(csvCaloTagsToken_, csvCaloTags);
559  iEvent.getByToken(csvCaloJetsToken_, csvCaloJets);
560 
561  if (csvCaloTags.isValid() && csvCaloJets.isValid()) {
562  for (auto iter = csvCaloTags->begin(); iter != csvCaloTags->end(); iter++)
563  bJetCSVCalo_.ME->Fill(iter->second);
564  }
565  }
566 
567  //muon dxy(use an unique path)
568  else if (pathName == muonDxy_.pathName) {
570  iEvent.getByToken(chargedCandToken_, recoChargedCands);
571  edm::Handle<reco::BeamSpot> recoBeamSpot;
572  iEvent.getByToken(beamSpotToken_, recoBeamSpot);
573  double muon_dxy;
574 
575  if (recoChargedCands.isValid() && recoBeamSpot.isValid()) {
576  for (const auto& key : keys) {
577  muon_dxy = dxyFinder(objects[key].eta(), objects[key].phi(), recoChargedCands, recoBeamSpot);
578  if (muon_dxy != -99.)
579  muonDxy_.ME->Fill(muon_dxy);
580  }
581  }
582  }
583 
584  // ////////////////////////////////
585  // ///
586  // /// double-object plots
587  // ///
588  // ////////////////////////////////
589 
590  //double muon low mass
591  else if (pathName == diMuonLowMass_.pathName) {
592  const double mu_mass(.105658);
593  unsigned int kCnt0 = 0;
594  for (const auto& key0 : keys) {
595  unsigned int kCnt1 = 0;
596  for (const auto& key1 : keys) {
597  if (key0 != key1 &&
598  kCnt1 > kCnt0) // avoid filling hists with same objs && avoid double counting separate objs
599  {
600  if (abs(objects[key0].id()) == 13 &&
601  (objects[key0].id() + objects[key1].id() == 0)) // check muon id and dimuon charge
602  {
603  TLorentzVector mu1, mu2, dimu;
604  mu1.SetPtEtaPhiM(objects[key0].pt(), objects[key0].eta(), objects[key0].phi(), mu_mass);
605  mu2.SetPtEtaPhiM(objects[key1].pt(), objects[key1].eta(), objects[key1].phi(), mu_mass);
606  dimu = mu1 + mu2;
607  diMuonLowMass_.ME->Fill(dimu.M());
608  }
609  }
610  kCnt1 += 1;
611  }
612  kCnt0 += 1;
613  }
614  } //end double object plot
615 
616  else if (pathName == diMuonMass_.pathName || pathName == diMuonMass_.pathNameOR) {
617  const double mu_mass(.105658);
618  unsigned int kCnt0 = 0;
619  for (const auto& key0 : keys) {
620  unsigned int kCnt1 = 0;
621  for (const auto& key1 : keys) {
622  if (key0 != key1 &&
623  kCnt1 > kCnt0) // avoid filling hists with same objs && avoid double counting separate objs
624  {
625  if (abs(objects[key0].id()) == 13 &&
626  (objects[key0].id() + objects[key1].id() == 0)) // check muon id and dimuon charge
627  {
628  TLorentzVector mu1, mu2, dimu;
629  mu1.SetPtEtaPhiM(objects[key0].pt(), objects[key0].eta(), objects[key0].phi(), mu_mass);
630  mu2.SetPtEtaPhiM(objects[key1].pt(), objects[key1].eta(), objects[key1].phi(), mu_mass);
631  dimu = mu1 + mu2;
632  diMuonMass_.ME->Fill(dimu.M());
633  }
634  }
635  kCnt1 += 1;
636  }
637  kCnt0 += 1;
638  }
639  }
640 
641  else if (pathName == pAL1DoubleMuZMass_.pathName) {
642  const double mu_mass(.105658);
643  unsigned int kCnt0 = 0;
644  for (const auto& key0 : keys) {
645  unsigned int kCnt1 = 0;
646  for (const auto& key1 : keys) {
647  if (key0 != key1 &&
648  kCnt1 > kCnt0) // avoid filling hists with same objs && avoid double counting separate objs
649  {
650  // if (abs(objects[key0].id()) == 13 && (objects[key0].id()+objects[key1].id()==0)) // id is not filled for l1 stage2 muons
651  // {
652  TLorentzVector mu1, mu2, dimu;
653  mu1.SetPtEtaPhiM(objects[key0].pt(), objects[key0].eta(), objects[key0].phi(), mu_mass);
654  mu2.SetPtEtaPhiM(objects[key1].pt(), objects[key1].eta(), objects[key1].phi(), mu_mass);
655  dimu = mu1 + mu2;
656  if (dimu.M() > pAL1DoubleMuZMass_.xMin && dimu.M() < pAL1DoubleMuZMass_.xMax)
657  pAL1DoubleMuZMass_.ME->Fill(dimu.M());
658  // }
659  }
660  kCnt1 += 1;
661  }
662  kCnt0 += 1;
663  }
664  }
665 
666  else if (pathName == pAL2DoubleMuZMass_.pathName) {
667  const double mu_mass(.105658);
668  unsigned int kCnt0 = 0;
669  for (const auto& key0 : keys) {
670  unsigned int kCnt1 = 0;
671  for (const auto& key1 : keys) {
672  if (key0 != key1 &&
673  kCnt1 > kCnt0) // avoid filling hists with same objs && avoid double counting separate objs
674  {
675  if (abs(objects[key0].id()) == 13 &&
676  (objects[key0].id() + objects[key1].id() == 0)) // check muon id and dimuon charge
677  {
678  TLorentzVector mu1, mu2, dimu;
679  mu1.SetPtEtaPhiM(objects[key0].pt(), objects[key0].eta(), objects[key0].phi(), mu_mass);
680  mu2.SetPtEtaPhiM(objects[key1].pt(), objects[key1].eta(), objects[key1].phi(), mu_mass);
681  dimu = mu1 + mu2;
682  if (dimu.M() > pAL2DoubleMuZMass_.xMin && dimu.M() < pAL2DoubleMuZMass_.xMax)
683  pAL2DoubleMuZMass_.ME->Fill(dimu.M());
684  }
685  }
686  kCnt1 += 1;
687  }
688  kCnt0 += 1;
689  }
690  }
691 
692  else if (pathName == pAL3DoubleMuZMass_.pathName) {
693  const double mu_mass(.105658);
694  unsigned int kCnt0 = 0;
695  for (const auto& key0 : keys) {
696  unsigned int kCnt1 = 0;
697  for (const auto& key1 : keys) {
698  if (key0 != key1 &&
699  kCnt1 > kCnt0) // avoid filling hists with same objs && avoid double counting separate objs
700  {
701  if (abs(objects[key0].id()) == 13 &&
702  (objects[key0].id() + objects[key1].id() == 0)) // check muon id and dimuon charge
703  {
704  TLorentzVector mu1, mu2, dimu;
705  mu1.SetPtEtaPhiM(objects[key0].pt(), objects[key0].eta(), objects[key0].phi(), mu_mass);
706  mu2.SetPtEtaPhiM(objects[key1].pt(), objects[key1].eta(), objects[key1].phi(), mu_mass);
707  dimu = mu1 + mu2;
708  if (dimu.M() > pAL3DoubleMuZMass_.xMin && dimu.M() < pAL3DoubleMuZMass_.xMax)
709  pAL3DoubleMuZMass_.ME->Fill(dimu.M());
710  }
711  }
712  kCnt1 += 1;
713  }
714  kCnt0 += 1;
715  }
716  }
717 
718  else if (pathName == diElecMass_.pathName) {
719  unsigned int kCnt0 = 0;
720  for (const auto& key0 : keys) {
721  unsigned int kCnt1 = 0;
722  for (const auto& key1 : keys) {
723  if (key0 != key1 &&
724  kCnt1 > kCnt0) // avoid filling hists with same objs && avoid double counting separate objs
725  {
726  // if (abs(objects[key0].id()) == 11 && (objects[key0].id()+objects[key1].id()==0)) // id is not filled for electrons
727  // {
728  TLorentzVector el1, el2, diEl;
729  el1.SetPtEtaPhiM(objects[key0].pt(), objects[key0].eta(), objects[key0].phi(), 0);
730  el2.SetPtEtaPhiM(objects[key1].pt(), objects[key1].eta(), objects[key1].phi(), 0);
731  diEl = el1 + el2;
732  diElecMass_.ME->Fill(diEl.M());
733  // }
734  }
735  kCnt1 += 1;
736  }
737  kCnt0 += 1;
738  }
739  } //end double object plot
740 
741  firedMap[pathName] = true;
742  } //end if trigger accept
743  } //end loop over plots/paths
744 
745  // sleep(1); //sleep for 1s, used to calibrate timing
746  double end = get_wall_time();
747  double wallTime = end - start;
748  wallTime_.ME->Fill(wallTime);
749 }
750 
751 // ------------ method called when starting to processes a run ------------
752 void HLTObjectMonitor::dqmBeginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {
753  if (debugPrint)
754  std::cout << "Calling beginRun. " << std::endl;
755  bool changed = true;
756  if (hltConfig_.init(iRun, iSetup, processName_, changed)) {
757  if (debugPrint)
758  std::cout << "Extracting HLTconfig. " << std::endl;
759  }
760 
761  //get path indicies from menu
762  string pathName_noVersion;
763  vector<string> triggerPaths = hltConfig_.triggerNames();
764 
765  for (const auto& pathName : triggerPaths) {
766  pathName_noVersion = hltConfig_.removeVersion(pathName);
767  for (auto plot : plotList) {
768  if (plot->pathName == pathName_noVersion) {
769  (*plot).pathIndex = hltConfig_.triggerIndex(pathName);
770  } else if (plot->pathNameOR == pathName_noVersion) {
771  (*plot).pathIndexOR = hltConfig_.triggerIndex(pathName);
772  }
773  }
774  }
775  vector<hltPlot*> plotList_temp;
776  for (auto plot : plotList) {
777  if (plot->pathIndex > 0 || plot->pathIndexOR > 0) {
778  plotList_temp.push_back(plot);
779  acceptMap[plot->pathName] = false;
780  if (plot->pathIndexOR > 0)
781  acceptMap[plot->pathNameOR] = false;
782  }
783  }
784  //now re-assign plotList to contain only the plots with paths in the menu.
785  plotList = plotList_temp;
786  plotList_temp.clear();
787 }
788 
789 // ------------ method called when ending the processing of a run ------------
790 
797 
798  //book wall time separately
799  ibooker.setCurrentFolder(mainShifterFolder);
800  wallTime_.ME =
801  ibooker.book1D(wallTime_.plotLabel, wallTime_.pathName, wallTime_.nBins, wallTime_.xMin, wallTime_.xMax);
802  wallTime_.ME->setAxisTitle(wallTime_.xAxisLabel);
803 
804  for (auto plot : plotList) {
805  std::string display_pathNames = plot->pathName;
806  if (!plot->pathNameOR.empty())
807  display_pathNames = plot->pathName + " OR " + plot->pathNameOR;
808 
809  if (plot->displayInPrimary) {
810  ibooker.setCurrentFolder(mainShifterFolder);
811  (*plot).ME = ibooker.book1D(plot->plotLabel, display_pathNames.c_str(), plot->nBins, plot->xMin, plot->xMax);
812  (*plot).ME->setAxisTitle(plot->xAxisLabel);
813  //need to add OR statement
814  } else {
815  ibooker.setCurrentFolder(backupFolder);
816  (*plot).ME = ibooker.book1D(plot->plotLabel, display_pathNames.c_str(), plot->nBins, plot->xMin, plot->xMax);
817  (*plot).ME->setAxisTitle(plot->xAxisLabel);
818  }
819  }
820 }
821 
823  double phi,
825  edm::Handle<reco::BeamSpot> recoBeamSpot) {
826  double dxy = -99.;
827  for (reco::RecoChargedCandidateCollection::const_iterator l3Muon = recoChargedCands->begin();
828  l3Muon != recoChargedCands->end();
829  l3Muon++) {
830  if (deltaR(eta, phi, l3Muon->eta(), l3Muon->phi()) < 0.1) {
831  dxy = (-(l3Muon->vx() - recoBeamSpot->x0()) * l3Muon->py() + (l3Muon->vy() - recoBeamSpot->y0()) * l3Muon->px()) /
832  l3Muon->pt();
833  break;
834  }
835  }
836  return dxy;
837 }
838 
840  struct timeval time;
841  if (gettimeofday(&time, nullptr))
842  return 0;
843  return (double)time.tv_sec + (double)time.tv_usec * .000001;
844 }
845 
846 // ------------ method called when starting to processes a luminosity block ------------
847 /*
848 void
849 HLTObjectMonitor::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
850 {
851 }
852 */
853 
854 // ------------ method called when ending the processing of a luminosity block ------------
855 /*
856 void
857 HLTObjectMonitor::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
858 {
859 }
860 */
861 
862 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
863 // void
864 // HLTObjectMonitor::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
865 // //The following says we do not know what parameters are allowed so do no validation
866 // // Please change this to state exactly what you do use, even if it is no parameters
867 // edm::ParameterSetDescription desc;
868 // desc.setUnknown();
869 // descriptions.addDefault(desc);
870 // }
871 
872 //define this as a plug-in
edm::ParameterSet caloMetPt_pset
Definition: start.py:1
edm::ParameterSet bJetPhi_pset
const Keys & filterKeys(trigger::size_type index) const
Definition: TriggerEvent.h:118
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::ParameterSet bJetCSVCalo_pset
edm::ParameterSet caloHtPt_pset
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
edm::ParameterSet jetAK8Mass_pset
edm::ParameterSet pfMetPhi_pset
edm::ParameterSet muonPhi_pset
void analyze(const edm::Event &, const edm::EventSetup &) override
edm::ParameterSet l2muonEta_pset
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
edm::ParameterSet photonPhi_pset
edm::ParameterSet electronPt_pset
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
trigger::size_type sizeFilters() const
Definition: TriggerEvent.h:146
edm::ParameterSet pAL2DoubleMuZMass_pset
edm::ParameterSet bJetCSVPF_pset
edm::ParameterSet muonEta_pset
edm::ParameterSet diMuonMass_pset
edm::ParameterSet muonDxy_pset
edm::EDGetTokenT< LumiScalersCollection > lumiScalersToken_
const_iterator begin() const
~HLTObjectMonitor() override
edm::ParameterSet l2NoBPTXmuonEta_pset
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
edm::ParameterSet pAL1DoubleMuZMass_pset
edm::ParameterSet l2muonPt_pset
edm::EDGetTokenT< vector< reco::PFJet > > csvPfJetsToken_
example_stream void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
HLTObjectMonitor(const edm::ParameterSet &)
double x0() const
x coordinate
Definition: BeamSpot.h:61
edm::ParameterSet wallTime_pset
edm::ParameterSet diElecMass_pset
int iEvent
Definition: GenABIO.cc:224
edm::ParameterSet photonPt_pset
edm::EDGetTokenT< trigger::TriggerEvent > aodTriggerToken_
edm::ParameterSet electronEta_pset
edm::ParameterSet bJetEta_pset
edm::ParameterSet alphaT_pset
edm::EDGetTokenT< reco::RecoChargedCandidateCollection > chargedCandToken_
edm::ParameterSet tauPt_pset
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const TriggerObjectCollection & getObjects() const
Definition: TriggerEvent.h:101
unordered_map< hltPlot *, edm::ParameterSet * > plotMap
edm::ParameterSet rsq_pset
double y0() const
y coordinate
Definition: BeamSpot.h:63
edm::ParameterSet mr_pset
static std::string const triggerResults
Definition: EdmProvDump.cc:44
edm::ParameterSet pfHtPt_pset
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
const_iterator end() const
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:75
edm::ParameterSet jetPt_pset
HLTConfigProvider hltConfig_
edm::ParameterSet diMuonLowMass_pset
edm::ParameterSet jetAK8Pt_pset
trigger::size_type filterIndex(const edm::InputTag &filterTag) const
find index of filter in data-member vector from filter tag
Definition: TriggerEvent.h:132
edm::ParameterSet l2muonPhi_pset
edm::ParameterSet muonPt_pset
double dxyFinder(double, double, edm::Handle< reco::RecoChargedCandidateCollection >, edm::Handle< reco::BeamSpot >)
edm::ParameterSet pfMetPt_pset
static constexpr float mu_mass
edm::ParameterSet electronPhi_pset
std::vector< size_type > Keys
edm::EDGetTokenT< reco::JetTagCollection > csvCaloTagsToken_
edm::EDGetTokenT< reco::JetTagCollection > csvPfTagsToken_
edm::ParameterSet photonEta_pset
edm::ParameterSet pAL3DoubleMuZMass_pset
bool isValid() const
Definition: HandleBase.h:70
edm::ParameterSet l2NoBPTXmuonPhi_pset
double get_wall_time(void)
HLT enums.
edm::EDGetTokenT< vector< reco::CaloJet > > csvCaloJetsToken_
edm::ParameterSet caloMetPhi_pset
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
vector< hltPlot * > plotList
static std::string const triggerPaths
Definition: EdmProvDump.cc:45
edm::ParameterSet l2NoBPTXmuonPt_pset
Definition: Run.h:45
void bookHistograms(DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &) override
unordered_map< string, bool > acceptMap
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)