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