CMS 3D CMS Logo

HLTObjectsMonitor.cc
Go to the documentation of this file.
1 // system include files
2 #include <memory>
3 #include <sys/time.h>
4 #include <cstdlib>
5 
6 // user include files
11 
20 
22 
23 //for collections
25 
34 
37 
38 #include "TLorentzVector.h"
39 
40 #include <unordered_map>
41 
42 
43 struct hltPlot {
44 
45  std::pair<MonitorElement*,bool> nME;
46  std::pair<MonitorElement*,bool> etaME;
47  std::pair<MonitorElement*,bool> phiME;
48  std::pair<MonitorElement*,bool> ptME;
49  std::pair<MonitorElement*,bool> massME;
50  std::pair<MonitorElement*,bool> energyME;
51  std::pair<MonitorElement*,bool> csvME;
52  std::pair<MonitorElement*,bool> etaVSphiME;
53  std::pair<MonitorElement*,bool> ptMEhep17;
54  std::pair<MonitorElement*,bool> ptMEhem17; // in harvesting step ratio
55  std::pair<MonitorElement*,bool> mrME;
56  std::pair<MonitorElement*,bool> rsqME;
57  std::pair<MonitorElement*,bool> dxyME;
58  std::pair<MonitorElement*,bool> dzME;
59  std::pair<MonitorElement*,bool> dimassME;
60  std::pair<MonitorElement*,bool> dRME;
61  std::pair<MonitorElement*,bool> dRetaVSphiME;
62  std::pair<MonitorElement*,bool> q1q2ME;
63 
66  int pathIDX;
68 
70  std::vector<double> etaBINNING;
71  std::vector<double> ptBINNING;
72  std::vector<double> phiBINNING;
73  std::vector<double> massBINNING;
74  std::vector<double> dxyBINNING;
75  std::vector<double> dzBINNING;
76  std::vector<double> dimassBINNING;
77 
78  bool doPlot2D;
79  bool doPlotETA;
80  bool doPlotMASS;
83  bool doPlotCSV;
84  bool doCALO;
85  bool doPF;
87  bool doPlotDXY;
88  bool doPlotDZ;
90 };
91 //
92 // class declaration
93 //
94 
95 //using namespace edm;
96 using std::unordered_map;
97 
99 
100  public:
101  explicit HLTObjectsMonitor(const edm::ParameterSet&);
102  ~HLTObjectsMonitor() override = default;
103 
104  // static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
105 
106 
107  private:
108  void analyze(const edm::Event&, const edm::EventSetup&) override;
109  void bookHistograms(DQMStore::IBooker &i, edm::Run const&, edm::EventSetup const&) override;
110  void dqmBeginRun(edm::Run const&, edm::EventSetup const&) override;
111 
112  static hltPlot getPlotPSet(edm::ParameterSet pset);
113  void getPSet();
114  bool isHEP17(double eta, double phi);
115  bool isHEM17(double eta, double phi);
116 
117  double dxyFinder(double, double, edm::Handle<reco::RecoChargedCandidateCollection>, edm::Handle<reco::BeamSpot>, double);
118  double dzFinder(double, double, double, double, edm::Handle<reco::RecoChargedCandidateCollection>, double);
119  // ----------member data ---------------------------
120 
124  std::vector<edm::ParameterSet> plotPSETS_;
125 
127 
129  std::vector<hltPlot> hltPlots_;
130 
131  bool debug_;
132 
135 
136 
139 
142 
145 
150 
151  const double MASS_MU = .105658;
152 
153 
154 struct MEbinning {
155  int nbins;
156  double xmin;
157  double xmax;
158 };
159 
160 
161 double MAX_PHI = 3.2;
162 int N_PHI = 64;
163 const MEbinning phi_binning_{
164  N_PHI, -MAX_PHI, MAX_PHI
165 };
166 
167 double MAX_CSV = 1.;
168 int N_CSV = 20;
169 const MEbinning csv_binning_{
170  N_CSV, -MAX_CSV, MAX_CSV
171 };
172 
173 std::vector<double> phi_variable_binning_;
174 
175 /*
176  HEP17 covers
177  - phi between 310° and 330° (-50° to -30°, or -0.87 t.52 rad)
178  - eta between +1.3 and +3.0 (positive side only)
179 */
180 double MAX_PHI_HEP17 = -0.52;
181 double MIN_PHI_HEP17 = -0.87;
182 int N_PHI_HEP17 = 7;
183 const MEbinning phi_binning_hep17_{
184  N_PHI_HEP17, MIN_PHI_HEP17, MAX_PHI_HEP17
185 };
186 double MAX_ETA_HEP17 = 3.0;
187 double MIN_ETA_HEP17 = 1.3;
188 int N_ETA_HEP17 = 6;
189 const MEbinning eta_binning_hep17_{
190  N_ETA_HEP17, MIN_ETA_HEP17, MAX_ETA_HEP17
191 };
192 
193 const MEbinning eta_binning_hem17_{
194  N_ETA_HEP17, -MAX_ETA_HEP17, MIN_ETA_HEP17
195 };
196 
197 };
198 
199 //
200 // constants, enums and typedefs
201 //
202 
203 //
204 // static data member definitions
205 //
206 hltPlot
208 
209  return hltPlot{
210  std::make_pair<MonitorElement*,bool>(nullptr,false),
211  std::make_pair<MonitorElement*,bool>(nullptr,pset.getParameter<bool>("displayInPrimary_eta") ),
212  std::make_pair<MonitorElement*,bool>(nullptr,pset.getParameter<bool>("displayInPrimary_phi") ),
213  std::make_pair<MonitorElement*,bool>(nullptr,pset.getParameter<bool>("displayInPrimary_pt") ),
214  std::make_pair<MonitorElement*,bool>(nullptr,pset.getParameter<bool>("displayInPrimary_mass") ),
215  std::make_pair<MonitorElement*,bool>(nullptr,pset.getParameter<bool>("displayInPrimary_energy") ),
216  std::make_pair<MonitorElement*,bool>(nullptr,pset.getParameter<bool>("displayInPrimary_csv") ),
217  std::make_pair<MonitorElement*,bool>(nullptr,pset.getParameter<bool>("displayInPrimary_etaVSphi") ),
218  std::make_pair<MonitorElement*,bool>(nullptr,pset.getParameter<bool>("displayInPrimary_pt_HEP17") ),
219  std::make_pair<MonitorElement*,bool>(nullptr,pset.getParameter<bool>("displayInPrimary_pt_HEM17") ),
220  std::make_pair<MonitorElement*,bool>(nullptr,pset.getParameter<bool>("displayInPrimary_MR") ),
221  std::make_pair<MonitorElement*,bool>(nullptr,pset.getParameter<bool>("displayInPrimary_RSQ") ),
222  std::make_pair<MonitorElement*,bool>(nullptr,pset.getParameter<bool>("displayInPrimary_dxy") ),
223  std::make_pair<MonitorElement*,bool>(nullptr,pset.getParameter<bool>("displayInPrimary_dz") ),
224  std::make_pair<MonitorElement*,bool>(nullptr,pset.getParameter<bool>("displayInPrimary_dimass") ),
225  std::make_pair<MonitorElement*,bool>(nullptr,false),
226  std::make_pair<MonitorElement*,bool>(nullptr,false),
227  std::make_pair<MonitorElement*,bool>(nullptr,false),
228  pset.getParameter<std::string>("label" ),
229  pset.getParameter<std::string>("pathNAME" ),
230  -1,
231  pset.getParameter<std::string>("moduleNAME"),
232  pset.getParameter<std::string>("xTITLE" ),
233  pset.getParameter<std::vector<double> >("etaBINNING" ),
234  pset.getParameter<std::vector<double> >("ptBINNING" ),
235  pset.getParameter<std::vector<double> >("phiBINNING" ),
236  pset.getParameter<std::vector<double> >("massBINNING" ),
237  pset.getParameter<std::vector<double> >("dxyBINNING" ),
238  pset.getParameter<std::vector<double> >("dzBINNING" ),
239  pset.getParameter<std::vector<double> >("dimassBINNING" ),
240  pset.getUntrackedParameter<bool>("doPlot2D", false ),
241  pset.getUntrackedParameter<bool>("doPlotETA", true ),
242  pset.getUntrackedParameter<bool>("doPlotMASS", false ),
243  pset.getUntrackedParameter<bool>("doPlotENERGY", false ),
244  pset.getUntrackedParameter<bool>("doPlotHEP17", true ),
245  pset.getUntrackedParameter<bool>("doPlotCSV", false ),
246  pset.getUntrackedParameter<bool>("doCALO", false ),
247  pset.getUntrackedParameter<bool>("doPF", false ),
248  pset.getUntrackedParameter<bool>("doPlotRazor", false ),
249  pset.getUntrackedParameter<bool>("doPlotDXY", false ),
250  pset.getUntrackedParameter<bool>("doPlotDZ", false ),
251  pset.getUntrackedParameter<bool>("doPlotDiMass", false )
252  };
253 
254 }
255 
256 void
258 
259  for ( const auto & pset : plotPSETS_ )
260  hltPlots_.push_back( getPlotPSet(pset) );
261 }
262 
263 bool HLTObjectsMonitor::isHEP17(double eta, double phi) {
264  if ( (eta >= MIN_ETA_HEP17 && eta <= MAX_ETA_HEP17) &&
265  (phi >= MIN_PHI_HEP17 && phi <= MAX_PHI_HEP17) ) return true;
266  else
267  return false;
268 }
269 bool HLTObjectsMonitor::isHEM17(double eta, double phi) {
270  if ( (eta >= -MAX_ETA_HEP17 && eta <= -MIN_ETA_HEP17) &&
271  (phi >= MIN_PHI_HEP17 && phi <= MAX_PHI_HEP17) ) return true;
272  else
273  return false;
274 }
275 //
276 // constructors and destructor
277 //
279  : TopFolder_ ( iConfig.getParameter<std::string>("TopFolder") )
280  , label_ ( iConfig.getParameter<std::string>("label") )
281  , processName_ ( iConfig.getParameter<std::string>("processName") )
282  , plotPSETS_ ( iConfig.getParameter<std::vector<edm::ParameterSet> >("plots") )
283  , debug_ ( iConfig.getUntrackedParameter<bool>("debug",false) )
284  , triggerResultsToken_ ( consumes<edm::TriggerResults> (iConfig.getParameter<edm::InputTag>("TriggerResults") ) )
285  , triggerEventToken_ ( consumes<trigger::TriggerEvent>(iConfig.getParameter<edm::InputTag>("TriggerSummary") ) )
286  , beamSpot_ ( iConfig.getParameter<edm::InputTag>("beamspot") )
287  , beamSpotToken_ ( consumes<reco::BeamSpot>(beamSpot_) )
288  , caloJetBTagsToken_ ( consumes<reco::JetTagCollection>(iConfig.getParameter<edm::InputTag>("caloJetBTags") ) )
289  , pfJetBTagsToken_ ( consumes<reco::JetTagCollection>(iConfig.getParameter<edm::InputTag>("pfJetBTags") ) )
290  , muCandidates_ ( iConfig.getParameter<edm::InputTag>("muCandidates") )
291  , muCandidatesToken_ ( consumes<std::vector<reco::RecoChargedCandidate> >(muCandidates_) )
292  , eleCandidates_ ( iConfig.getParameter<edm::InputTag>("eleCandidates") )
293  , eleCandidatesToken_ ( consumes<std::vector<reco::RecoChargedCandidate> >(eleCandidates_) )
294 {
295  getPSet();
296 
297  //now do what ever initialization is needed
298  mainFolder_ = TopFolder_+"/MainShifter";
299  backupFolder_ = TopFolder_+"/Backup";
300 
301  //set Token(s)
302 
303 
304  double step = 2*MAX_PHI/double(N_PHI);
305  for ( int i=0; i<=N_PHI; i++)
306  phi_variable_binning_.push_back(-MAX_PHI + step*i);
307 
308 }
309 
310 
311 //
312 // member functions
313 //
314 
315 // ------------ method called for each event ------------
316 void
318 {
319  // if ( debug_ )
320  // std::cout << "[HLTObjectsMonitor::analyze]" << std::endl;
321 
322  // access trigger results
324  iEvent.getByToken(triggerResultsToken_, triggerResults);
325  if (!triggerResults.isValid()) return;
326 
328  iEvent.getByToken(triggerEventToken_, triggerEvent);
329  if (!triggerEvent.isValid()) return;
330 
332  iEvent.getByToken(caloJetBTagsToken_, caloJetBTags);
333 
335  iEvent.getByToken(pfJetBTagsToken_, pfJetBTags);
336 
338  iEvent.getByToken(muCandidatesToken_, muCandidates);
339 
341  iEvent.getByToken(eleCandidatesToken_, eleCandidates);
342 
344  iEvent.getByToken(beamSpotToken_, beamspot);
345 
346  // loop over path
347  int ibin = -1;
348  for (auto & plot : hltPlots_) {
349  ibin++;
350  if ( plot.pathIDX <= 0 ) continue;
351 
352  if ( triggerResults->accept(plot.pathIDX) ) {
353  if ( debug_ )
354  std::cout << plot.pathNAME << " --> bin: " << ibin << std::endl;
355  eventsPlot_->Fill(ibin);
356 
357  const trigger::TriggerObjectCollection objects = triggerEvent->getObjects();
358  if ( hltConfig_.saveTags(plot.moduleNAME) ) {
359  if ( debug_ )
360  std::cout << "objects: " << objects.size() << std::endl;
361 
362  bool moduleFOUND = false;
363  std::vector<std::string> moduleNames = hltConfig_.moduleLabels(plot.pathIDX);
364  for ( const auto & module : moduleNames ) {
365  if ( module == plot.moduleNAME) moduleFOUND = true;
366  }
367  if ( debug_ )
368  std::cout << plot.moduleNAME << (moduleFOUND ? "" : "NOT" ) << " found in the list of modules" << std::endl;
369 
370  if (debug_)
371  for ( const auto & module : moduleNames ) {
372  unsigned int idx = triggerEvent->filterIndex(edm::InputTag(module,"",processName_));
373  std::cout << "module: " << module;
374  if ( idx < triggerEvent->sizeFilters() )
375  std::cout << " --> " << idx;
376  std::cout << std::endl;
377  }
378  //
379  // trigger accepted and collection w/ objects is available
381  unsigned int moduleIDX = triggerEvent->filterIndex(moduleName);
382  if (debug_)
383  std::cout << "moduleNAME: " << plot.moduleNAME << " --> " << moduleIDX << std::endl;
384 
385  if ( moduleIDX >= triggerEvent->sizeFilters() ) {
386  LogDebug ("HLTObjectsMonitor") << plot.pathNAME << " " << plot.moduleNAME << " is not available ! please, fix update DQM/HLTEvF/python/HLTObjectsMonitor_cfi.py";
387  return;
388  }
389 
390  const trigger::Keys &keys = triggerEvent->filterKeys( moduleIDX );
391  if ( debug_ )
392  std::cout << "keys: " << keys.size() << std::endl;
393 
394  plot.nME.first->Fill(keys.size());
395 
396  double MR = 0.;
397  double RSQ = 0.;
398  for ( const auto & key : keys ) {
399 
400  double pt = objects[key].pt();
401  double eta = objects[key].eta();
402  double phi = objects[key].phi();
403  double mass = objects[key].mass();
404  double energy = objects[key].energy();
405  int id = objects[key].id();
406  if ( debug_ )
407  std::cout << "object ID " << id << " mass: " << mass << std::endl;
408 
409  // single-object plots
410  plot.ptME.first->Fill(pt);
411  if ( plot.doPlotETA ) plot.etaME.first->Fill(eta);
412  plot.phiME.first->Fill(phi);
413 
414  if ( plot.doPlotCSV ) {
415 
416  if ( plot.doCALO ) {
417  if ( !caloJetBTags.isValid() ) plot.csvME.first->Fill(-10.);
418  else {
419  for ( auto it = caloJetBTags->begin();
420  it != caloJetBTags->end(); ++it ) {
421  double dR = deltaR(eta,phi,it->first->eta(),it->first->phi());
422  if ( debug_ )
423  std::cout << "[HLTObjectsMonitor::analyze] deltaR: " << dR << " matched ? " << ( dR <= 0.4 ? "YEAP" : "NOPE" ) << std::endl;
424  plot.csvME.first->Fill(it->second);
425  }
426  }
427 
428  } else if ( plot.doPF ) {
429  if ( !pfJetBTags.isValid() ) plot.csvME.first->Fill(-10.);
430  else {
431  for ( auto it = pfJetBTags->begin();
432  it != pfJetBTags->end(); ++it ) {
433  double dR = deltaR(eta,phi,it->first->eta(),it->first->phi());
434  if ( debug_ )
435  std::cout << "[HLTObjectsMonitor::analyze] deltaR: " << dR << " matched ? " << ( dR <= 0.4 ? "YEAP" : "NOPE" ) << std::endl;
436  plot.csvME.first->Fill(it->second);
437  }
438  }
439  }
440  }
441  if ( plot.doPlotMASS ) plot.massME.first->Fill(mass);
442  if ( plot.doPlotENERGY ) plot.energyME.first->Fill(energy);
443  if ( plot.doPlot2D ) plot.etaVSphiME.first->Fill(eta,phi);
444  if ( plot.doPlotHEP17 ) {
445  if ( isHEP17(eta,phi) ) plot.ptMEhep17.first->Fill(pt);
446  if ( isHEM17(eta,phi) ) plot.ptMEhem17.first->Fill(pt);
447  }
448 
449  if(id == 0){ //the MET object containing MR and Rsq will show up with ID = 0
450  MR = objects[key].px(); //razor variables stored in dummy reco::MET objects
451  RSQ = objects[key].py();
452  }
453 
454  if ( plot.doPlotDXY ) {
455  double dxy = -99.;
456  if ( abs(id) == 13 )
457  dxy = dxyFinder(eta,phi,muCandidates, beamspot, 0.1); // dRcut = 0.1
458  else
459  dxy = dxyFinder(eta,phi,eleCandidates, beamspot, 0.1); // dRcut = 0.1
460  plot.dxyME.first->Fill(dxy);
461  }
462  } // end loop on keys
463  if ( plot.doPlotRazor ) {
464  plot.mrME.first->Fill(MR);
465  plot.rsqME.first->Fill(RSQ);
466  }
467 
468  if ( keys.size() < 2 ) {
469  if ( plot.doPlotDiMass || plot.doPlotDZ )
470  LogDebug ("HLTObjectsMonitor") << plot.pathNAME << " " << plot.moduleNAME << " # objects is (" << keys.size() << ") less than 2 ! you probably want to either change the moduleNAME or switch off di-object system plots (doPlotDZ: " << plot.doPlotDZ << " doPlotDiMass: " << plot.doPlotDiMass << ") in DQM/HLTEvF/python/HLTObjectsMonitor_cfi.py)";
471  } else {
472  for ( const auto & key : keys ) {
473  double pt = objects[key].pt();
474  double eta = objects[key].eta();
475  double phi = objects[key].phi();
476  int id = objects[key].id();
477 
478  unsigned int kCnt0 = 0;
479 
480  TLorentzVector v1;
481  if ( abs(id) == 13 ) // check if it is a muon
482  v1.SetPtEtaPhiM(pt,eta,phi,MASS_MU);
483  else
484  v1.SetPtEtaPhiM(pt,eta,phi,0);
485 
486  unsigned int kCnt1 = 0;
487  for ( const auto & key1: keys ) {
488 
489  if (key != key1 && kCnt1 > kCnt0) { // avoid filling hists with same objs && avoid double counting separate objs
490 
491  double pt2 = objects[key1].phi();
492  double eta2 = objects[key1].eta();
493  double phi2 = objects[key1].phi();
494  int id2 = objects[key1].id();
495 
496  double dR = deltaR( eta, phi, eta2, phi2);
497  plot.dRME.first->Fill(dR);
498  plot.dRetaVSphiME.first->Fill(eta,phi,dR);
499 
500  int q1 = ( id==0 ? 0 : id/abs(id) );
501  int q2 = ( id2==0 ? 0 : id2/abs(id2) );
502  int q1q2 = q1*q2;
503  plot.q1q2ME.first->Fill(q1q2);
504 
505  if ( abs(id) != abs(id2) )
506  edm::LogWarning ("HLTObjectsMonitor") << plot.pathNAME << " " << plot.moduleNAME << " objects have different ID !?!" << abs(id) << " and " << abs(id2);
507 
508  if( (id+id2 ) == 0 ) { // check di-object system charge and flavor
509 
510  TLorentzVector v2;
511  if ( abs( id2 ) == 13 ) // check if it is a muon
512  v2.SetPtEtaPhiM(pt2,eta2,phi2, MASS_MU);
513  else
514  v2.SetPtEtaPhiM(pt2,eta2,phi2, 0);
515 
516  if ( plot.doPlotDiMass ) {
517  TLorentzVector v = v1+v2;
518  plot.dimassME.first->Fill(v.M());
519  }
520 
521  if ( plot.doPlotDZ ) {
522  double dz = -99.;
523  if ( abs(id) == 13 )
524  dz = dzFinder(eta,phi,eta2,phi2,muCandidates, 0.1); // dRcut = 0.1
525  else
526  dz = dzFinder(eta,phi,eta2,phi2,eleCandidates, 0.1); // dRcut = 0.1
527  plot.dzME.first->Fill(dz);
528  }
529  }
530 
531  }
532  kCnt1++;
533  }
534  kCnt0++;
535  }
536 
537  }
538  }
539  }
540  }
541 
542 }
543 
544 // ------------ method called when starting to processes a run ------------
545 void
547 {
548  bool changed = true;
549  if (hltConfig_.init(iRun, iSetup, processName_, changed))
550  if (debug_) std::cout << "[HLTObjectsMonitor::dqmBeginRun] extracting HLTconfig" << std::endl;
551 
552  //get path indicies from menu
553  std::string pathName_noVersion;
554  std::vector<std::string> triggerPaths = hltConfig_.triggerNames();
555 
556  if ( debug_ )
557  std::cout << "[HLTObjectsMonitor::dqmBeginRun] triggerPaths: " << triggerPaths.size() << " <--> " << hltPlots_.size() << std::endl;
558 
559  for (const auto & pathName : triggerPaths) {
560 
561  if ( debug_ )
562  std::cout << "[HLTObjectsMonitor::dqmBeginRun] " << pathName << std::endl;
563 
564  pathName_noVersion = hltConfig_.removeVersion(pathName);
565  // std::cout << "pathName: " << pathName << " --> " << pathName_noVersion << std::endl;
566  for (auto & plot : hltPlots_) {
567  if (plot.pathNAME == pathName_noVersion) {
568  plot.pathIDX = hltConfig_.triggerIndex(pathName);
569  // check that the index makes sense, otherwise force pathIDX = -1
570  if ( plot.pathIDX <= 0 || plot.pathIDX == int(triggerPaths.size()) )
571  plot.pathIDX = -1;
572  }
573  }
574  }
575 
576  if ( debug_ ) {
577  for (const auto & plot : hltPlots_)
578  std::cout << "plot: " << plot.pathNAME << " --> pathIDX: " << plot.pathIDX << std::endl;
579  std::cout << "[HLTObjectsMonitor::dqmBeginRun] DONE" << std::endl;
580  }
581 
582 }
583 
585 {
586 
587  if ( debug_ )
588  std::cout << "[HLTObjectsMonitor::bookHistograms]" << std::endl;
589 
590  ibooker.setCurrentFolder(TopFolder_);
591 
592  std::string name = "eventsPerPath_"+label_;
593  std::string title = " events per path";
594  int nbins = hltPlots_.size();
595  eventsPlot_ = ibooker.book1D(name,title,nbins,-0.5,double(nbins)-0.5);
596  eventsPlot_->setAxisTitle("HLT path");
597  for ( int i=0; i<nbins; i++ ) {
598  eventsPlot_->setBinLabel(i+1,hltPlots_[i].pathNAME);
599  if ( debug_ )
600  std::cout << hltPlots_[i].pathNAME << " --> bin: " << i+1 << std::endl;
601  }
602 
603  for (auto & plot : hltPlots_) {
604 
605  if ( debug_ )
606  std::cout << "booking plots for " << plot.label << std::endl;
607 
608  if ( plot.pathIDX <= 0 ) {
609  LogDebug ("HLTObjectsMonitor") << plot.pathNAME << " is not available in the HLT menu ! no plots are going to be booked for it (update DQM/HLTEvF/python/HLTObjectsMonitor_cfi.py)";
610  continue;
611  }
612  if ( debug_ )
613  std::cout << "booking histograms for " << plot.pathNAME << std::endl;
614 
615  {
616  if ( plot.nME.second )
617  ibooker.setCurrentFolder(mainFolder_);
618  else
620 
621  name = plot.label+"_nobjects";
622  title = plot.pathNAME+" # objects";
623  plot.nME.first = ibooker.book1D(name,title,20,-0.5,19.5);
624  plot.nME.first->setAxisTitle(plot.xTITLE+" # objects");
625  }
626 
627  if ( plot.ptME.second )
628  ibooker.setCurrentFolder(mainFolder_);
629  else
631 
632  name = plot.label+"_pt";
633  title = plot.pathNAME+" p_T";
634  int nbins = (plot.ptBINNING).size()-1;
635  std::vector<float> fbinning((plot.ptBINNING).begin(),(plot.ptBINNING).end());
636  float* arr = &fbinning[0];
637  plot.ptME.first = ibooker.book1D(name,title,nbins,arr);
638  plot.ptME.first->setAxisTitle(plot.xTITLE+" p_{T} [GeV]");
639 
640 
641  {
642  if ( plot.phiME.second )
643  ibooker.setCurrentFolder(mainFolder_);
644  else
646 
647  name = plot.label+"_phi";
648  title = plot.pathNAME+" #phi";
649  int nbins = (plot.phiBINNING).size()-1;
650  std::vector<float> fbinning((plot.phiBINNING).begin(),(plot.phiBINNING).end());
651  float* arr = &fbinning[0];
652  plot.phiME.first = ibooker.book1D(name,title,nbins,arr);
653  plot.phiME.first->setAxisTitle(plot.xTITLE+" #phi [rad]");
654  }
655 
656  if ( plot.doPlotETA ) {
657  if ( plot.etaME.second )
658  ibooker.setCurrentFolder(mainFolder_);
659  else
661 
662  name = plot.label+"_eta";
663  title = plot.pathNAME+" #eta";
664  int nbins = (plot.etaBINNING).size()-1;
665  std::vector<float> fbinning((plot.etaBINNING).begin(),(plot.etaBINNING).end());
666  float* arr = &fbinning[0];
667 
668  plot.etaME.first = ibooker.book1D(name,title,nbins,arr);
669  plot.etaME.first->setAxisTitle(plot.xTITLE+" #eta");
670  }
671 
672  if ( plot.doPlotMASS ) {
673  if ( plot.massME.second )
674  ibooker.setCurrentFolder(mainFolder_);
675  else
677 
678  name = plot.label+"_mass";
679  title = plot.pathNAME+" mass";
680  int nbins = (plot.massBINNING).size()-1;
681  std::vector<float> fbinning((plot.massBINNING).begin(),(plot.massBINNING).end());
682  float* arr = &fbinning[0];
683 
684  plot.massME.first = ibooker.book1D(name,title,nbins,arr);
685  plot.massME.first->setAxisTitle(plot.xTITLE+" mass [GeV]");
686  }
687 
688  if ( plot.doPlotENERGY ) {
689  if ( plot.energyME.second )
690  ibooker.setCurrentFolder(mainFolder_);
691  else
693 
694  name = plot.label+"_energy";
695  title = plot.pathNAME+" energy";
696  int nbins = (plot.ptBINNING).size()-1;
697  std::vector<float> fbinning((plot.ptBINNING).begin(),(plot.ptBINNING).end());
698  float* arr = &fbinning[0];
699 
700  plot.energyME.first = ibooker.book1D(name,title,nbins,arr);
701  plot.energyME.first->setAxisTitle(plot.xTITLE+" energy [GeV]");
702  }
703 
704  if ( plot.doPlotCSV ) {
705  if ( plot.csvME.second )
706  ibooker.setCurrentFolder(mainFolder_);
707  else
709 
710  name = plot.label+"_csv";
711  title = plot.pathNAME+" CSV";
712 
713  plot.csvME.first = ibooker.book1D(name,title,csv_binning_.nbins,csv_binning_.xmin,csv_binning_.xmax);
714  plot.csvME.first->setAxisTitle(plot.xTITLE+" CSV discriminator");
715  }
716 
717  if ( plot.doPlot2D ) {
718  if ( plot.etaVSphiME.second )
719  ibooker.setCurrentFolder(mainFolder_);
720  else
722 
723  name = plot.label+"_etaVSphi";
724  title = plot.pathNAME+" #eta vs #phi";
725  int nbinsX = (plot.etaBINNING).size()-1;
726  std::vector<float> fbinningX((plot.etaBINNING).begin(),(plot.etaBINNING).end());
727  float* arrX = &fbinningX[0];
728  int nbinsY = (plot.phiBINNING).size()-1;;
729  std::vector<float> fbinningY((plot.phiBINNING).begin(),(plot.phiBINNING).end());
730  float* arrY = &fbinningY[0];
731  plot.etaVSphiME.first = ibooker.book2D(name,title,nbinsX,arrX,nbinsY,arrY);
732  plot.etaVSphiME.first->setAxisTitle(plot.xTITLE+" #eta",1);
733  plot.etaVSphiME.first->setAxisTitle(plot.xTITLE+" #phi",2);
734  }
735 
736  if ( plot.doPlotHEP17 ) {
737 
738  if ( plot.ptMEhep17.second )
739  ibooker.setCurrentFolder(mainFolder_);
740  else
742 
743  int nbins = (plot.ptBINNING).size()-1;
744  std::vector<float> fbinning((plot.ptBINNING).begin(),(plot.ptBINNING).end());
745  float* arr = &fbinning[0];
746 
747  name = plot.label+"_pt_HEP17";
748  title = plot.pathNAME+" p_{T} HEP17";
749  plot.ptMEhep17.first = ibooker.book1D(name,title,nbins,arr);
750  plot.ptMEhep17.first->setAxisTitle(plot.xTITLE+" p_{T} [GeV]",1);
751 
752  if ( plot.ptMEhem17.second )
753  ibooker.setCurrentFolder(mainFolder_);
754  else
756 
757  name = plot.label+"_pt_HEM17";
758  title = plot.pathNAME+" p_{T} HEM17";
759  plot.ptMEhem17.first = ibooker.book1D(name,title,nbins,arr);
760  plot.ptMEhem17.first->setAxisTitle(plot.xTITLE+" p_{T} [GeV]",1);
761  }
762 
763  if ( plot.doPlotRazor ) {
764  if ( plot.mrME.second )
765  ibooker.setCurrentFolder(mainFolder_);
766  else
768 
769  name = plot.label+"_mr";
770  title = plot.pathNAME+" M_{R}";
771  plot.mrME.first = ibooker.book1D(name,title,100,0.,100.);
772  plot.mrME.first->setAxisTitle(plot.xTITLE+" M_{R} [GeV]",1);
773 
774  if ( plot.rsqME.second )
775  ibooker.setCurrentFolder(mainFolder_);
776  else
778 
779  name = plot.label+"_rsq";
780  title = plot.pathNAME+" RSQ";
781  plot.rsqME.first = ibooker.book1D(name,title,100,0.,100.);
782  plot.rsqME.first->setAxisTitle(plot.xTITLE+" RSQ [GeV]",1);
783 
784  }
785 
786  if ( plot.doPlotDXY ) {
787 
788  if ( plot.dxyME.second )
789  ibooker.setCurrentFolder(mainFolder_);
790  else
792 
793  name = plot.label+"_dxy";
794  title = plot.pathNAME+" d_{xy}";
795  int nbins = (plot.dxyBINNING).size()-1;
796  std::vector<float> fbinning((plot.dxyBINNING).begin(),(plot.dxyBINNING).end());
797  float* arr = &fbinning[0];
798  plot.dxyME.first = ibooker.book1D(name,title,nbins,arr);
799  plot.dxyME.first->setAxisTitle(plot.xTITLE+" d_{xy} [cm]");
800 
801  }
802 
803  if ( plot.doPlotDZ ) {
804 
805  if ( plot.dzME.second )
806  ibooker.setCurrentFolder(mainFolder_);
807  else
809 
810  name = plot.label+"_dz";
811  title = plot.pathNAME+" d_{z}";
812  int nbins = (plot.dzBINNING).size()-1;
813  std::vector<float> fbinning((plot.dzBINNING).begin(),(plot.dzBINNING).end());
814  float* arr = &fbinning[0];
815  plot.dzME.first = ibooker.book1D(name,title,nbins,arr);
816  plot.dzME.first->setAxisTitle(plot.xTITLE+" d_{z} [cm]");
817 
818  }
819 
820  if ( plot.dRME.second )
821  ibooker.setCurrentFolder(mainFolder_);
822  else
824 
825  name = plot.label+"_dR";
826  title = plot.pathNAME+" di-object dR";
827  plot.dRME.first = ibooker.book1D(name,title,50,0.,5.);
828  plot.dRME.first->setAxisTitle(plot.xTITLE+" dR_{obj,obj}");
829 
830  if ( plot.dRetaVSphiME.second )
831  ibooker.setCurrentFolder(mainFolder_);
832  else
834 
835  name = plot.label+"_dR_etaVSphi";
836  title = plot.pathNAME+" di-object dR in the #eta-#phi plane (of 1st obj)";
837  plot.dRetaVSphiME.first = ibooker.bookProfile2D(name,title,60,-3.,3.,64,-3.2,3.2,0.,5.);
838  plot.dRetaVSphiME.first->setAxisTitle(plot.xTITLE+" #eta",1);
839  plot.dRetaVSphiME.first->setAxisTitle(plot.xTITLE+" #phi",2);
840  plot.dRetaVSphiME.first->setAxisTitle(plot.xTITLE+" dR_{obj,obj}",3);
841 
842  if ( plot.q1q2ME.second )
843  ibooker.setCurrentFolder(mainFolder_);
844  else
846 
847  name = plot.label+"_q1q2";
848  title = plot.pathNAME+" di-object q1xq2";
849  plot.q1q2ME.first = ibooker.book1D(name,title,3,-1.,1.);
850  plot.q1q2ME.first->setAxisTitle(plot.xTITLE+" q_{obj1} x q_{obj2}");
851 
852  if ( plot.doPlotDiMass ) {
853 
854  if ( plot.dimassME.second )
855  ibooker.setCurrentFolder(mainFolder_);
856  else
858 
859  name = plot.label+"_dimass";
860  title = plot.pathNAME+" di-object mass";
861  int nbins = (plot.dimassBINNING).size()-1;
862  std::vector<float> fbinning((plot.dimassBINNING).begin(),(plot.dimassBINNING).end());
863  float* arr = &fbinning[0];
864  plot.dimassME.first = ibooker.book1D(name,title,nbins,arr);
865  plot.dimassME.first->setAxisTitle(plot.xTITLE+" m_{obj,obj} [GeV]");
866 
867  }
868  }
869 
870  if ( debug_ )
871  std::cout << "[HLTObjectsMonitor::bookHistograms] DONE" << std::endl;
872 
873 }
874 
875 double
877 {
878  double dxy = -99.;
879  if ( !candidates.isValid() ) {
880  LogDebug ("HLTObjectsMonitor") << "either " << muCandidates_ << " or " << eleCandidates_ << " is not valid ! please, update DQM/HLTEvF/python/HLTObjectsMonitor_cfi.py"
881  << " by switching OFF doPlotDXY or updating the InputTag collection";
882  return dxy;
883  }
884  if ( !beamspot.isValid() ) {
885  LogDebug ("HLTObjectsMonitor") << beamSpot_ << " is not valid ! please, update DQM/HLTEvF/python/HLTObjectsMonitor_cfi.py"
886  << " by switching OFF doPlotDXY or updating the InputTag collection";
887  return dxy;
888  }
889 
890  bool matched = false;
891  for (reco::RecoChargedCandidateCollection::const_iterator candidate = candidates->begin();
892  candidate != candidates->end(); ++candidate) {
893 
894  if ( deltaR( eta,phi,candidate->eta(),candidate->phi() ) < dRcut ) {
895  matched = true;
896  dxy = (-(candidate->vx()-beamspot->x0()) * candidate->py() + (candidate->vy()-beamspot->y0()) * candidate->px())/candidate->pt();
897  break;
898  }
899  }
900  if (!matched)
901  edm::LogWarning ("HLTObjectsMonitor") << "trigger object does not match ( dR > " << dRcut << ") to any of the candidates in either "
902  << muCandidates_ << " or " << eleCandidates_;
903 
904  return dxy;
905 }
906 
907 double
908 HLTObjectsMonitor::dzFinder(double eta1, double phi1, double eta2, double phi2, edm::Handle<reco::RecoChargedCandidateCollection> candidates, double dRcut = 0.1)
909 {
910  double dz = -99.;
911  if ( !candidates.isValid() ) {
912  LogDebug ("HLTObjectsMonitor") << "either " << muCandidates_ << " or " << eleCandidates_ << " is not valid ! please, update DQM/HLTEvF/python/HLTObjectsMonitor_cfi.py"
913  << " by switching OFF doPlotDZ or updating the InputTag collection";
914  return dz;
915  }
916 
917  const reco::RecoChargedCandidate* cand1;
918  const reco::RecoChargedCandidate* cand2;
919  bool matched1 = false;
920  bool matched2 = false;
921  for (reco::RecoChargedCandidateCollection::const_iterator candidate = candidates->begin();
922  candidate != candidates->end(); ++candidate) {
923 
924  if ( deltaR( eta1,phi1,candidate->eta(),candidate->phi() ) < dRcut ) {
925  matched1 = true;
926  cand1 = &*candidate;
927  if ( debug_ )
928  std::cout << "cand1: " << cand1->pt() << " " << cand1->eta() << " " << cand1->phi() << std::endl;
929  break;
930  }
931  }
932  if (!matched1) {
933  LogDebug ("HLTObjectsMonitor") << "trigger object1 does not match ( dR > " << dRcut << ") to any of the candidates in either "
934  << muCandidates_ << " or " << eleCandidates_;
935  return dz;
936  }
937 
938  for (reco::RecoChargedCandidateCollection::const_iterator candidate = candidates->begin();
939  candidate != candidates->end(); ++candidate) {
940  if ( debug_ ) {
941  std::cout << "candidate: " << candidate->pt() << " cand1: " << cand1->pt() << std::endl;
942  std::cout << "candidate: " << candidate->eta() << " cand1: " << cand1->eta() << std::endl;
943  std::cout << "candidate: " << candidate->phi() << " cand1: " << cand1->phi() << std::endl;
944  }
945  if (&*candidate == cand1) continue;
946 
947  if ( deltaR( eta2,phi2,candidate->eta(),candidate->phi() ) < dRcut ) {
948  matched2 = true;
949  cand2 = &*candidate;
950  if ( debug_ )
951  std::cout << "cand2: " << cand2->pt() << " " << cand2->eta() << " " << cand2->phi() << std::endl;
952  break;
953  }
954  }
955  if (!matched2) {
956  LogDebug ("HLTObjectsMonitor") << "trigger object2 does not match ( dR > " << dRcut << ") to any of the candidates in either "
957  << muCandidates_ << " or " << eleCandidates_;
958  return dz;
959  }
960 
961  dz = cand1->vz() - cand2->vz();
962  return dz;
963 }
964 
965 //define this as a plug-in
#define LogDebug(id)
size
Write out results.
edm::EDGetTokenT< reco::JetTagCollection > pfJetBTagsToken_
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< double > phiBINNING
bool saveTags(const std::string &module) const
Is module an L3 filter (ie, tracked saveTags=true)
std::pair< MonitorElement *, bool > dzME
std::vector< hltPlot > hltPlots_
std::string pathNAME
std::pair< MonitorElement *, bool > dimassME
std::pair< MonitorElement *, bool > csvME
double eta() const final
momentum pseudorapidity
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
trigger::size_type sizeFilters() const
Definition: TriggerEvent.h:135
const MEbinning csv_binning_
std::pair< MonitorElement *, bool > massME
edm::InputTag muCandidates_
virtual example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
edm::EDGetTokenT< reco::JetTagCollection > caloJetBTagsToken_
std::pair< MonitorElement *, bool > energyME
std::vector< double > etaBINNING
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
std::vector< double > dimassBINNING
static hltPlot getPlotPSet(edm::ParameterSet pset)
std::string moduleNAME
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::pair< MonitorElement *, bool > etaVSphiME
std::pair< MonitorElement *, bool > dRetaVSphiME
bool accept() const
Has at least one path accepted the event?
const std::vector< std::string > & triggerNames() const
names of trigger paths
const Keys & filterKeys(trigger::size_type index) const
Definition: TriggerEvent.h:111
trigger::size_type filterIndex(const edm::InputTag &filterTag) const
find index of filter in data-member vector from filter tag
Definition: TriggerEvent.h:123
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
const_iterator end() const
double pt() const final
transverse momentum
std::pair< MonitorElement *, bool > ptMEhem17
JetFloatAssociation::Container JetTagCollection
Definition: JetTag.h:18
std::pair< MonitorElement *, bool > q1q2ME
double q2[4]
Definition: TauolaWrapper.h:88
static const std::string removeVersion(const std::string &trigger)
edm::InputTag beamSpot_
void Fill(long long x)
unsigned int triggerIndex(const std::string &triggerName) const
slot position of trigger path in trigger table (0 to size-1)
void bookHistograms(DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &) override
edm::EDGetTokenT< std::vector< reco::RecoChargedCandidate > > eleCandidatesToken_
bool isHEP17(double eta, double phi)
std::pair< MonitorElement *, bool > etaME
std::pair< MonitorElement *, bool > phiME
int iEvent
Definition: GenABIO.cc:230
std::string moduleName(Provenance const &provenance)
Definition: Provenance.cc:27
std::pair< MonitorElement *, bool > dxyME
HLTObjectsMonitor(const edm::ParameterSet &)
edm::InputTag eleCandidates_
const TriggerObjectCollection & getObjects() const
Definition: TriggerEvent.h:98
MonitorElement * bookProfile2D(Args &&...args)
Definition: DQMStore.h:166
double dxyFinder(double, double, edm::Handle< reco::RecoChargedCandidateCollection >, edm::Handle< reco::BeamSpot >, double)
std::pair< MonitorElement *, bool > mrME
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:118
virtual example_stream void bookHistograms(DQMStore::IBooker &,@example_stream edm::Run const &,@example_stream edm::EventSetup const &) override
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
#define end
Definition: vmac.h:39
static std::string const triggerResults
Definition: EdmProvDump.cc:41
bool isValid() const
Definition: HandleBase.h:74
std::vector< double > massBINNING
std::pair< MonitorElement *, bool > rsqME
double vz() const override
z coordinate of vertex position
std::pair< MonitorElement *, bool > ptME
std::string label
std::vector< double > dzBINNING
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
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
std::pair< MonitorElement *, bool > nME
std::pair< MonitorElement *, bool > dRME
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:279
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:136
double q1[4]
Definition: TauolaWrapper.h:87
std::vector< size_type > Keys
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
HLTConfigProvider hltConfig_
std::pair< MonitorElement *, bool > ptMEhep17
edm::EDGetTokenT< std::vector< reco::RecoChargedCandidate > > muCandidatesToken_
bool isHEM17(double eta, double phi)
fixed size matrix
std::vector< double > phi_variable_binning_
HLT enums.
MonitorElement * eventsPlot_
std::vector< edm::ParameterSet > plotPSETS_
void analyze(const edm::Event &, const edm::EventSetup &) override
double y0() const
y coordinate
Definition: BeamSpot.h:66
double dzFinder(double, double, double, double, edm::Handle< reco::RecoChargedCandidateCollection >, double)
step
static std::string const triggerPaths
Definition: EdmProvDump.cc:42
double phi() const final
momentum azimuthal angle
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
const_iterator begin() const
std::vector< double > dxyBINNING
Definition: vlib.h:208
edm::EDGetTokenT< trigger::TriggerEvent > triggerEventToken_
std::string xTITLE
std::vector< double > ptBINNING
Definition: Run.h:43
double x0() const
x coordinate
Definition: BeamSpot.h:64