CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
NoBPTXMonitor.cc
Go to the documentation of this file.
12 
13 #include <string>
14 #include <vector>
15 
16 class NoBPTXMonitor : public DQMEDAnalyzer, public TriggerDQMBase {
17 public:
20 
23  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
24 
25 protected:
26  void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
27  void analyze(edm::Event const& iEvent, edm::EventSetup const& iSetup) override;
28 
29 private:
30  const std::string folderName_;
31 
34 
35  edm::EDGetTokenT<reco::CaloJetCollection> jetToken_;
36  edm::EDGetTokenT<reco::TrackCollection> muonToken_;
37 
48 
69 
72 
75 
76  unsigned int njets_;
77  unsigned int nmuons_;
78 };
79 
81  : folderName_(iConfig.getParameter<std::string>("FolderName")),
82  requireValidHLTPaths_(iConfig.getParameter<bool>("requireValidHLTPaths")),
83  hltPathsAreValid_(false),
84  jetToken_(consumes<reco::CaloJetCollection>(iConfig.getParameter<edm::InputTag>("jets"))),
85  muonToken_(consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("muons"))),
86  jetE_variable_binning_(
87  iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<std::vector<double> >("jetEBinning")),
88  jetE_binning_(getHistoPSet(
89  iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet>("jetEPSet"))),
90  jetEta_binning_(getHistoPSet(
91  iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet>("jetEtaPSet"))),
92  jetPhi_binning_(getHistoPSet(
93  iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet>("jetPhiPSet"))),
94  muonPt_variable_binning_(
95  iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<std::vector<double> >("muonPtBinning")),
96  muonPt_binning_(getHistoPSet(
97  iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet>("muonPtPSet"))),
98  muonEta_binning_(getHistoPSet(
99  iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet>("muonEtaPSet"))),
100  muonPhi_binning_(getHistoPSet(
101  iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet>("muonPhiPSet"))),
102  ls_binning_(
103  getHistoPSet(iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet>("lsPSet"))),
104  bx_binning_(getHistoLSPSet(
105  iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet>("bxPSet"))),
106  num_genTriggerEventFlag_(new GenericTriggerEventFlag(
107  iConfig.getParameter<edm::ParameterSet>("numGenericTriggerEventPSet"), consumesCollector(), *this)),
108  den_genTriggerEventFlag_(new GenericTriggerEventFlag(
109  iConfig.getParameter<edm::ParameterSet>("denGenericTriggerEventPSet"), consumesCollector(), *this)),
110  jetSelection_(iConfig.getParameter<std::string>("jetSelection")),
111  muonSelection_(iConfig.getParameter<std::string>("muonSelection")),
112  njets_(iConfig.getParameter<unsigned int>("njets")),
113  nmuons_(iConfig.getParameter<unsigned int>("nmuons")) {}
114 
117  num_genTriggerEventFlag_.reset();
118  }
120  den_genTriggerEventFlag_.reset();
121  }
122 }
123 
124 void NoBPTXMonitor::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const& iRun, edm::EventSetup const& iSetup) {
125  // Initialize the GenericTriggerEventFlag
127  num_genTriggerEventFlag_->initRun(iRun, iSetup);
128  }
130  den_genTriggerEventFlag_->initRun(iRun, iSetup);
131  }
132 
133  // check if every HLT path specified in numerator and denominator has a valid match in the HLT Menu
135  den_genTriggerEventFlag_->on() && num_genTriggerEventFlag_->allHLTPathsAreValid() &&
136  den_genTriggerEventFlag_->allHLTPathsAreValid());
137 
138  // if valid HLT paths are required,
139  // create DQM outputs only if all paths are valid
141  return;
142  }
143 
144  std::string histname, histtitle;
145 
146  std::string currentFolder = folderName_;
147  ibooker.setCurrentFolder(currentFolder);
148 
149  histname = "jetE";
150  histtitle = "jetE";
151  bookME(ibooker, jetENoBPTX_, histname, histtitle, jetE_binning_.nbins, jetE_binning_.xmin, jetE_binning_.xmax);
152  setMETitle(jetENoBPTX_, "Jet E [GeV]", "Events / [GeV]");
153 
154  histname = "jetE_variable";
155  histtitle = "jetE";
156  bookME(ibooker, jetENoBPTX_variableBinning_, histname, histtitle, jetE_variable_binning_);
157  setMETitle(jetENoBPTX_variableBinning_, "Jet E [GeV]", "Events / [GeV]");
158 
159  histname = "jetEVsLS";
160  histtitle = "jetE vs LS";
161  bookME(ibooker,
162  jetEVsLS_,
163  histname,
164  histtitle,
170  setMETitle(jetEVsLS_, "LS", "Jet E [GeV]");
171 
172  histname = "jetEVsBX";
173  histtitle = "jetE vs BX";
174  bookME(ibooker,
175  jetEVsBX_,
176  histname,
177  histtitle,
183  false);
184  setMETitle(jetEVsBX_, "BX", "Jet E [GeV]");
185 
186  histname = "jetEta";
187  histtitle = "jetEta";
188  bookME(
189  ibooker, jetEtaNoBPTX_, histname, histtitle, jetEta_binning_.nbins, jetEta_binning_.xmin, jetEta_binning_.xmax);
190  setMETitle(jetEtaNoBPTX_, "Jet #eta", "Events");
191 
192  histname = "jetEtaVsLS";
193  histtitle = "jetEta vs LS";
194  bookME(ibooker,
195  jetEtaVsLS_,
196  histname,
197  histtitle,
203  false);
204  setMETitle(jetEtaVsLS_, "LS", "Jet #eta");
205 
206  histname = "jetEtaVsBX";
207  histtitle = "jetEta vs BX";
208  bookME(ibooker,
209  jetEtaVsBX_,
210  histname,
211  histtitle,
217  false);
218  setMETitle(jetEtaVsBX_, "BX", "Jet #eta");
219 
220  histname = "jetPhi";
221  histtitle = "jetPhi";
222  bookME(
223  ibooker, jetPhiNoBPTX_, histname, histtitle, jetPhi_binning_.nbins, jetPhi_binning_.xmin, jetPhi_binning_.xmax);
224  setMETitle(jetPhiNoBPTX_, "Jet #phi", "Events");
225 
226  histname = "jetPhiVsLS";
227  histtitle = "jetPhi vs LS";
228  bookME(ibooker,
229  jetPhiVsLS_,
230  histname,
231  histtitle,
237  false);
238  setMETitle(jetPhiVsLS_, "LS", "Jet #phi");
239 
240  histname = "jetPhiVsBX";
241  histtitle = "jetPhi vs BX";
242  bookME(ibooker,
243  jetPhiVsBX_,
244  histname,
245  histtitle,
251  false);
252  setMETitle(jetPhiVsBX_, "BX", "Jet #phi");
253 
254  histname = "muonPt";
255  histtitle = "muonPt";
256  bookME(
257  ibooker, muonPtNoBPTX_, histname, histtitle, muonPt_binning_.nbins, muonPt_binning_.xmin, muonPt_binning_.xmax);
258  setMETitle(muonPtNoBPTX_, "DisplacedStandAlone Muon p_{T} [GeV]", "Events / [GeV]");
259 
260  histname = "muonPt_variable";
261  histtitle = "muonPt";
262  bookME(ibooker, muonPtNoBPTX_variableBinning_, histname, histtitle, muonPt_variable_binning_);
263  setMETitle(muonPtNoBPTX_variableBinning_, "DisplacedStandAlone Muon p_{T} [GeV]", "Events / [GeV]");
264 
265  histname = "muonPtVsLS";
266  histtitle = "muonPt vs LS";
267  bookME(ibooker,
268  muonPtVsLS_,
269  histname,
270  histtitle,
276  false);
277  setMETitle(muonPtVsLS_, "LS", "DisplacedStandAlone Muon p_{T} [GeV]");
278 
279  histname = "muonPtVsBX";
280  histtitle = "muonPt vs BX";
281  bookME(ibooker,
282  muonPtVsBX_,
283  histname,
284  histtitle,
290  false);
291  setMETitle(muonPtVsBX_, "BX", "DisplacedStandAlone Muon p_{T} [GeV]");
292 
293  histname = "muonEta";
294  histtitle = "muonEta";
295  bookME(ibooker,
297  histname,
298  histtitle,
302  setMETitle(muonEtaNoBPTX_, "DisplacedStandAlone Muon #eta", "Events");
303 
304  histname = "muonEtaVsLS";
305  histtitle = "muonEta vs LS";
306  bookME(ibooker,
307  muonEtaVsLS_,
308  histname,
309  histtitle,
315  false);
316  setMETitle(muonEtaVsLS_, "LS", "DisplacedStandAlone Muon #eta");
317 
318  histname = "muonEtaVsBX";
319  histtitle = "muonEta vs BX";
320  bookME(ibooker,
321  muonEtaVsBX_,
322  histname,
323  histtitle,
329  false);
330  setMETitle(muonEtaVsBX_, "BX", "DisplacedStandAlone Muon #eta");
331 
332  histname = "muonPhi";
333  histtitle = "muonPhi";
334  bookME(ibooker,
336  histname,
337  histtitle,
341  setMETitle(muonPhiNoBPTX_, "DisplacedStandAlone Muon #phi", "Events");
342 
343  histname = "muonPhiVsLS";
344  histtitle = "muonPhi vs LS";
345  bookME(ibooker,
346  muonPhiVsLS_,
347  histname,
348  histtitle,
354  false);
355  setMETitle(muonPhiVsLS_, "LS", "DisplacedStandAlone Muon #phi");
356 
357  histname = "muonPhiVsBX";
358  histtitle = "muonPhi vs BX";
359  bookME(ibooker,
360  muonPhiVsBX_,
361  histname,
362  histtitle,
368  false);
369  setMETitle(muonPhiVsBX_, "BX", "DisplacedStandAlone Muon #phi");
370 }
371 
373  // if valid HLT paths are required,
374  // analyze event only if all paths are valid
376  return;
377  }
378 
379  // Filter out events if Trigger Filtering is requested
380  if (den_genTriggerEventFlag_->on() && !den_genTriggerEventFlag_->accept(iEvent, iSetup)) {
381  return;
382  }
383 
384  const int ls = iEvent.id().luminosityBlock();
385  const int bx = iEvent.bunchCrossing();
386 
388  iEvent.getByToken(jetToken_, jetHandle);
389 
390  if ((unsigned int)(jetHandle->size()) < njets_)
391  return;
392 
393  std::vector<reco::CaloJet> jets;
394  for (auto const& j : *jetHandle) {
395  if (jetSelection_(j))
396  jets.push_back(j);
397  }
398 
399  if ((unsigned int)(jets.size()) < njets_)
400  return;
401 
402  double jetE = -999;
403  double jetEta = -999;
404  double jetPhi = -999;
405  if (!jets.empty()) {
406  jetE = jets[0].energy();
407  jetEta = jets[0].eta();
408  jetPhi = jets[0].phi();
409  }
410 
412  iEvent.getByToken(muonToken_, DSAHandle);
413 
414  if ((unsigned int)(DSAHandle->size()) < nmuons_)
415  return;
416 
417  std::vector<reco::Track> muons;
418  for (auto const& m : *DSAHandle) {
419  if (muonSelection_(m))
420  muons.push_back(m);
421  }
422 
423  if ((unsigned int)(muons.size()) < nmuons_)
424  return;
425 
426  double muonPt = -999;
427  double muonEta = -999;
428  double muonPhi = -999;
429  if (!muons.empty()) {
430  muonPt = muons[0].pt();
431  muonEta = muons[0].eta();
432  muonPhi = muons[0].phi();
433  }
434 
435  // passes numerator-trigger (fill-numerator flag)
436  const bool trg_passed = (num_genTriggerEventFlag_->on() && num_genTriggerEventFlag_->accept(iEvent, iSetup));
437 
438  // filling histograms
439  jetENoBPTX_.fill(trg_passed, jetE);
440  jetENoBPTX_variableBinning_.fill(trg_passed, jetE);
441  jetEtaNoBPTX_.fill(trg_passed, jetEta);
442  jetPhiNoBPTX_.fill(trg_passed, jetPhi);
443  muonPtNoBPTX_.fill(trg_passed, muonPt);
444  muonPtNoBPTX_variableBinning_.fill(trg_passed, muonPt);
445  muonEtaNoBPTX_.fill(trg_passed, muonEta);
446  muonPhiNoBPTX_.fill(trg_passed, muonPhi);
447 
448  jetEVsLS_.fill(trg_passed, ls, jetE);
449 
450  if (trg_passed) {
451  jetEVsBX_.numerator->Fill(bx, jetE);
452  jetEtaVsLS_.numerator->Fill(ls, jetEta);
453  jetEtaVsBX_.numerator->Fill(bx, jetEta);
454  jetPhiVsLS_.numerator->Fill(ls, jetPhi);
455  jetPhiVsBX_.numerator->Fill(bx, jetPhi);
456  muonPtVsLS_.numerator->Fill(ls, muonPt);
457  muonPtVsBX_.numerator->Fill(bx, muonPt);
458  muonEtaVsLS_.numerator->Fill(ls, muonEta);
459  muonEtaVsBX_.numerator->Fill(bx, muonEta);
460  muonPhiVsLS_.numerator->Fill(ls, muonPhi);
461  muonPhiVsBX_.numerator->Fill(bx, muonPhi);
462  }
463 }
464 
467  desc.add<std::string>("FolderName", "HLT/NoBPTX");
468  desc.add<bool>("requireValidHLTPaths", true);
469 
470  desc.add<edm::InputTag>("jets", edm::InputTag("ak4CaloJets"));
471  desc.add<edm::InputTag>("muons", edm::InputTag("displacedStandAloneMuons"));
472  desc.add<std::string>("jetSelection", "pt > 0");
473  desc.add<std::string>("muonSelection", "pt > 0");
474  desc.add<unsigned int>("njets", 0);
475  desc.add<unsigned int>("nmuons", 0);
476 
477  edm::ParameterSetDescription genericTriggerEventPSet;
478  GenericTriggerEventFlag::fillPSetDescription(genericTriggerEventPSet);
479  desc.add<edm::ParameterSetDescription>("numGenericTriggerEventPSet", genericTriggerEventPSet);
480  desc.add<edm::ParameterSetDescription>("denGenericTriggerEventPSet", genericTriggerEventPSet);
481 
484  edm::ParameterSetDescription jetEtaPSet;
485  edm::ParameterSetDescription jetPhiPSet;
486  edm::ParameterSetDescription muonPtPSet;
487  edm::ParameterSetDescription muonEtaPSet;
488  edm::ParameterSetDescription muonPhiPSet;
491  fillHistoPSetDescription(jetEPSet);
492  fillHistoPSetDescription(jetEtaPSet);
493  fillHistoPSetDescription(jetPhiPSet);
494  fillHistoPSetDescription(muonPtPSet);
495  fillHistoPSetDescription(muonEtaPSet);
496  fillHistoPSetDescription(muonPhiPSet);
497  fillHistoPSetDescription(lsPSet);
499  histoPSet.add<edm::ParameterSetDescription>("jetEPSet", jetEPSet);
500  histoPSet.add<edm::ParameterSetDescription>("jetEtaPSet", jetEtaPSet);
501  histoPSet.add<edm::ParameterSetDescription>("jetPhiPSet", jetPhiPSet);
502  histoPSet.add<edm::ParameterSetDescription>("muonPtPSet", muonPtPSet);
503  histoPSet.add<edm::ParameterSetDescription>("muonEtaPSet", muonEtaPSet);
504  histoPSet.add<edm::ParameterSetDescription>("muonPhiPSet", muonPhiPSet);
505  histoPSet.add<edm::ParameterSetDescription>("lsPSet", lsPSet);
506  histoPSet.add<edm::ParameterSetDescription>("bxPSet", bxPSet);
507  std::vector<double> bins = {0., 20., 40., 60., 80., 90., 100., 110., 120., 130., 140., 150., 160.,
508  170., 180., 190., 200., 220., 240., 260., 280., 300., 350., 400., 450., 1000.};
509  histoPSet.add<std::vector<double> >("jetEBinning", bins);
510  histoPSet.add<std::vector<double> >("muonPtBinning", bins);
511 
512  desc.add<edm::ParameterSetDescription>("histoPSet", histoPSet);
513 
514  descriptions.add("NoBPTXMonitoring", desc);
515 }
516 
517 // Define this as a plug-in
ObjME muonEtaNoBPTX_
edm::EDGetTokenT< reco::TrackCollection > muonToken_
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
StringCutObjectSelector< reco::CaloJet, true > jetSelection_
static void fillHistoLSPSetDescription(edm::ParameterSetDescription &pset)
ObjME muonPtNoBPTX_variableBinning_
const bool requireValidHLTPaths_
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
def ls
Definition: eostools.py:349
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
edm::EDGetTokenT< reco::CaloJetCollection > jetToken_
int bunchCrossing() const
Definition: EventBase.h:64
static MEbinning getHistoLSPSet(const edm::ParameterSet &pset)
dqm::reco::DQMStore DQMStore
Provides a code based selection for trigger and DCS information in order to have no failing filters i...
~NoBPTXMonitor() override
MEbinning muonEta_binning_
static void fillHistoPSetDescription(edm::ParameterSetDescription &pset)
std::vector< double > jetE_variable_binning_
std::unique_ptr< T, impl::DeviceDeleter > unique_ptr
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:39
void setMETitle(ObjME &me, const std::string &titleX, const std::string &titleY)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
bool hltPathsAreValid_
const std::string folderName_
void Fill(long long x)
static MEbinning getHistoPSet(const edm::ParameterSet &pset)
int iEvent
Definition: GenABIO.cc:224
#define override(base_class)
vector< PseudoJet > jets
MonitorElement * numerator
std::unique_ptr< GenericTriggerEventFlag > den_genTriggerEventFlag_
MEbinning ls_binning_
dqm::reco::MonitorElement MonitorElement
void fill(const bool pass_num, Args...args)
MEbinning jetEta_binning_
MEbinning jetE_binning_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
unsigned int njets_
unsigned int nmuons_
void analyze(edm::Event const &iEvent, edm::EventSetup const &iSetup) override
MEbinning muonPt_binning_
ObjME muonPhiNoBPTX_
StringCutObjectSelector< reco::Track, true > muonSelection_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void bookME(DQMStore::IBooker &, ObjME &me, const std::string &histname, const std::string &histtitle, const uint nbins, const double xmin, const double xmax, const bool bookDen=true)
edm::EventID id() const
Definition: EventBase.h:59
tuple numGenericTriggerEventPSet
MEbinning jetPhi_binning_
tuple muons
Definition: patZpeak.py:41
tuple denGenericTriggerEventPSet
std::unique_ptr< GenericTriggerEventFlag > num_genTriggerEventFlag_
MEbinning muonPhi_binning_
NoBPTXMonitor(const edm::ParameterSet &)
static void fillPSetDescription(edm::ParameterSetDescription &desc)
ObjME jetENoBPTX_variableBinning_
std::vector< double > muonPt_variable_binning_
MEbinning bx_binning_
Definition: Run.h:45
std::vector< CaloJet > CaloJetCollection
collection of CaloJet objects