test
CMS 3D CMS Logo

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