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