CMS 3D CMS Logo

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