CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TopSingleLeptonHLTOfflineDQM.cc
Go to the documentation of this file.
7 
11 #include <iostream>
12 
16 
18 
20 
21 #include <cassert>
22 
23 /*Originally from DQM/Physics by R. Wolf and J. Andrea*/
24 using namespace std;
25 namespace HLTOfflineDQMTopSingleLepton {
26 
27  // maximal number of leading jets
28  // to be used for top mass estimate
29  static const unsigned int MAXJETS = 4;
30  // nominal mass of the W boson to
31  // be used for the top mass estimate
32  static const double WMASS = 80.4;
33  // maximal Delta to consider
34  // hlt and reco objects matched
35  static const double DRMIN = 0.05;
36 
37  MonitorSingleLepton::MonitorSingleLepton(const char* label, const edm::ParameterSet& cfg, edm::ConsumesCollector&& iC) :
38  label_(label), elecIso_(0), elecSelect_(0), pvSelect_(0), muonIso_(0), muonSelect_(0), jetIDSelect_(0), includeBTag_(false), lowerEdge_(-1.), upperEdge_(-1.), logged_(0)
39  {
40  // sources have to be given; this PSet is not optional
41  edm::ParameterSet sources=cfg.getParameter<edm::ParameterSet>("sources");
42  muons_= iC.consumes< edm::View<reco::Muon> >(sources.getParameter<edm::InputTag>("muons"));
43  elecs_= iC.consumes< edm::View<reco::GsfElectron> >(sources.getParameter<edm::InputTag>("elecs"));
44  jets_ = iC.consumes< edm::View<reco::Jet> >(sources.getParameter<edm::InputTag>("jets" ));
45 
46  const auto& mets = sources.getParameter<std::vector<edm::InputTag>>("mets");
47  for (const auto& met: mets) {
48  mets_.push_back(iC.consumes<edm::View<reco::MET>>(met));
49  }
50 
51  pvs_ = iC.consumes< edm::View<reco::Vertex> >(sources.getParameter<edm::InputTag>("pvs" ));
52 
53  // electronExtras are optional; they may be omitted or
54  // empty
55  if( cfg.existsAs<edm::ParameterSet>("elecExtras") ){
56  edm::ParameterSet elecExtras=cfg.getParameter<edm::ParameterSet>("elecExtras");
57  // select is optional; in case it's not found no
58  // selection will be applied
59  if( elecExtras.existsAs<std::string>("select") ){
61  }
62  // isolation is optional; in case it's not found no
63  // isolation will be applied
64  if( elecExtras.existsAs<std::string>("isolation") ){
66  }
67  // electronId is optional; in case it's not found the
68  // InputTag will remain empty
69  if( elecExtras.existsAs<edm::ParameterSet>("electronId") ){
70  edm::ParameterSet elecId=elecExtras.getParameter<edm::ParameterSet>("electronId");
71  electronId_= iC.consumes< edm::ValueMap<float> >(elecId.getParameter<edm::InputTag>("src"));
72  eidPattern_= elecId.getParameter<int>("pattern");
73  }
74  }
75  // pvExtras are optional; they may be omitted or empty
76  if(cfg.existsAs<edm::ParameterSet>("pvExtras")){
77  edm::ParameterSet pvExtras=cfg.getParameter<edm::ParameterSet>("pvExtras");
78  // select is optional; in case it's not found no
79  // selection will be applied
80  if( pvExtras.existsAs<std::string>("select") ){
82  }
83  }
84  // muonExtras are optional; they may be omitted or empty
85  if( cfg.existsAs<edm::ParameterSet>("muonExtras") ){
86  edm::ParameterSet muonExtras=cfg.getParameter<edm::ParameterSet>("muonExtras");
87  // select is optional; in case it's not found no
88  // selection will be applied
89  if( muonExtras.existsAs<std::string>("select") ){
91  }
92  // isolation is optional; in case it's not found no
93  // isolation will be applied
94  if( muonExtras.existsAs<std::string>("isolation") ){
96  }
97  }
98 
99  // jetExtras are optional; they may be omitted or
100  // empty
101  if( cfg.existsAs<edm::ParameterSet>("jetExtras") ){
102  edm::ParameterSet jetExtras=cfg.getParameter<edm::ParameterSet>("jetExtras");
103  // jetCorrector is optional; in case it's not found
104  // the InputTag will remain empty
105  if( jetExtras.existsAs<std::string>("jetCorrector") ){
106  jetCorrector_= jetExtras.getParameter<std::string>("jetCorrector");
107  }
108  // read jetID information if it exists
109  if(jetExtras.existsAs<edm::ParameterSet>("jetID")){
111  jetIDLabel_ = iC.consumes< reco::JetIDValueMap >(jetID.getParameter<edm::InputTag>("label"));
113  }
114  // select is optional; in case it's not found no
115  // selection will be applied (only implemented for
116  // CaloJets at the moment)
117  if( jetExtras.existsAs<std::string>("select") ){
118  jetSelect_= jetExtras.getParameter<std::string>("select");
119  }
120  // jetBDiscriminators are optional; in case they are
121  // not found the InputTag will remain empty; they
122  // consist of pairs of edm::JetFlavorAssociation's &
123  // corresponding working points
124  includeBTag_=jetExtras.existsAs<edm::ParameterSet>("jetBTaggers");
125  if( includeBTag_ ){
126  edm::ParameterSet btagEff=jetExtras.getParameter<edm::ParameterSet>("jetBTaggers").getParameter<edm::ParameterSet>("trackCountingEff");
127  btagEff_= iC.consumes< reco::JetTagCollection >(btagEff.getParameter<edm::InputTag>("label")); btagEffWP_= btagEff.getParameter<double>("workingPoint");
128  edm::ParameterSet btagPur=jetExtras.getParameter<edm::ParameterSet>("jetBTaggers").getParameter<edm::ParameterSet>("trackCountingPur");
129  btagPur_= iC.consumes< reco::JetTagCollection >(btagPur.getParameter<edm::InputTag>("label")); btagPurWP_= btagPur.getParameter<double>("workingPoint");
130  edm::ParameterSet btagVtx=jetExtras.getParameter<edm::ParameterSet>("jetBTaggers").getParameter<edm::ParameterSet>("secondaryVertex" );
131  btagVtx_= iC.consumes< reco::JetTagCollection >(btagVtx.getParameter<edm::InputTag>("label")); btagVtxWP_= btagVtx.getParameter<double>("workingPoint");
132  }
133  }
134 
135  // triggerExtras are optional; they may be omitted or empty
136  processName_ = "HLT";
137  if( cfg.existsAs<edm::ParameterSet>("triggerExtras") ){
138  edm::ParameterSet triggerExtras=cfg.getParameter<edm::ParameterSet>("triggerExtras");
139  triggerTable_= iC.consumes< edm::TriggerResults >(triggerExtras.getParameter<edm::InputTag>("src"));
140  processName_ = triggerExtras.getParameter<edm::InputTag>("src").process();
141  triggerPaths_=triggerExtras.getParameter<std::vector<std::string> >("paths");
142  }
143 
144  // massExtras is optional; in case it's not found no mass
145  // window cuts are applied for the same flavor monitor
146  // histograms
147  if( cfg.existsAs<edm::ParameterSet>("massExtras") ){
148  edm::ParameterSet massExtras=cfg.getParameter<edm::ParameterSet>("massExtras");
149  lowerEdge_= massExtras.getParameter<double>("lowerEdge");
150  upperEdge_= massExtras.getParameter<double>("upperEdge");
151  }
152 
153  // and don't forget to do the histogram booking
154  folder_=cfg.getParameter<std::string>("directory");
155 
156  triggerEventWithRefsTag_ = iC.consumes< trigger::TriggerEventWithRefs >(edm::InputTag("hltTriggerSummaryRAW","",processName_));
157 
158  }
159 
160  void
162  {
163  //set up the current directory path
164  std::string current(folder_); current+=label_;
165  store_.setCurrentFolder(current);
166 
167  // determine number of bins for trigger monitoring
168  unsigned int nPaths=triggerPaths_.size();
169 
170  // number of selected primary vertices
171  hists_["pvMult_" ] = store_.book1D("PvMult" , "N_{pvs}" , 100, 0., 100.);
172  // multiplicity of jets with pt>20 (corrected to L2+L3)
173  hists_["jetMult_" ] = store_.book1D("JetMult" , "N_{20}(jet)" , 10, 0., 10.);
174  // // trigger efficiency estimates for single lepton triggers
175  // hists_["triggerEff_" ] = store_.book1D("TriggerEff" , "Eff(trigger)" , nPaths, 0., nPaths);
176  // monitored trigger occupancy for single lepton triggers
177  hists_["triggerMon_" ] = store_.book1D("TriggerMon" , "Mon(trigger)" , nPaths, 0., nPaths);
178  // W mass estimate
179  hists_["massW_" ] = store_.book1D("MassW" , "M(W)" , 60, 0., 300.);
180  // Top mass estimate
181  hists_["massTop_" ] = store_.book1D("MassTop" , "M(Top)" , 50, 0., 500.);
182  // Mlb mu
183  hists_["mMub_" ] = store_.book1D("mMub" , "m_{#mub}" , 50, 0., 500.);
184  // W mass transverse estimate mu
185  hists_["MTWm_" ] = store_.book1D("MTWm" , "M_{T}^{W}(#mu)" , 60, 0., 300.);
186  // Top mass transverse estimate mu
187  hists_["mMTT_" ] = store_.book1D("mMTT" , "M_{T}^{t}(#mu)" , 50, 0., 500.);
188  // Mlb e
189  hists_["mEb_" ] = store_.book1D("mEb" , "m_{eb}" , 50, 0., 500.);
190  // W mass transverse estimate e
191  hists_["MTWe_" ] = store_.book1D("MTWe" , "M_{T}^{W}(e)" , 60, 0., 300.);
192  // Top mass transverse estimate e
193  hists_["eMTT_" ] = store_.book1D("eMTT" , "M_{T}^{t}(e)" , 50, 0., 500.);
194  // set bin labels for trigger monitoring
196  // multiplicity of btagged jets (for track counting high efficiency) with pt(L2L3)>20
197  hists_["jetMultBEff_"] = store_.book1D("JetMultBProb", "N_{20}(b/prob)" , 10, 0., 10.);
198  // btag discriminator for track counting high efficiency for jets with pt(L2L3)>20
199  hists_["jetBDiscEff_"] = store_.book1D("JetBDiscProb", "Disc_{b/prob}(jet)", 25, 0., 2.5);
200  // multiplicity of btagged jets (for track counting high purity) with pt(L2L3)>20
201  hists_["jetMultBPur_"] = store_.book1D("JetMultBPur", "N_{20}(b/pur)" , 10, 0., 10.);
202  // btag discriminator for track counting high purity
203  hists_["jetBDiscPur_"] = store_.book1D("JetBDiscPur", "Disc_{b/pur}(Jet)", 100, 0., 10.);
204  // multiplicity of btagged jets (for simple secondary vertex) with pt(L2L3)>20
205  hists_["jetMultBVtx_"] = store_.book1D("JetMultBVtx", "N_{20}(b/vtx)" , 10, 0., 10.);
206  // btag discriminator for simple secondary vertex
207  hists_["jetBDiscVtx_"] = store_.book1D("JetBDiscVtx", "Disc_{b/vtx}(Jet)", 35, -1., 6.);
208  // selected events
209  hists_["eventLogger_"] = store_.book2D("EventLogger", "Logged Events" , 3, 0., 3., 4, 0., 4.);
210  // set axes titles for selected events
211  hists_["eventLogger_"]->getTH1()->SetOption("TEXT");
212  hists_["eventLogger_"]->setBinLabel( 1 , "Run" , 1);
213  hists_["eventLogger_"]->setBinLabel( 2 , "Block" , 1);
214  hists_["eventLogger_"]->setBinLabel( 3 , "Event" , 1);
215  hists_["eventLogger_"]->setAxisTitle("logged evts" , 2);
216 
217  // deltaR min between hlt iso lepton and reco iso lepton wrt eta
218  hists_["leptDeltaREta_"] = store_.book2D("DeltaRMinEtaLepton", "#Delta R_{min}(leptons) wrt #eta", 30, -3, 3, 10, 0., 0.1);
219  // deltaR min between hlt jets and reco jets wrt eta
220  hists_["jetDeltaREta_"] = store_.book2D("DeltaRMinEtaJet", "#Delta R_{min}(jets) wrt #eta", 30, -3, 3, 10, 0., 0.1);
221  // resolution in pT for matched isolated leptons
222  hists_["leptResolution_"] = store_.book1D("ResIsoLeptons", "#Delta p_{T}/p_{T}(matched leptons)", 20, 0., 0.1);
223  // resolution in pT for matched jets
224  hists_["jetResolution_"] = store_.book1D("ResIsoJets", "#Delta p_{T}/p_{T}(matched jets)", 20, 0., 0.1);
225  // matching monitoring
226  hists_["matchingMon_"] = store_.book1D("MatchingMon", "Mon(matching)", 5, 0., 5.);
227  // set axes titles for matching monitoring
228  hists_["matchingMon_"]->setBinLabel( 1 , "iso lepton" );
229  hists_["matchingMon_"]->setBinLabel( 2 , "1st jet" );
230  hists_["matchingMon_"]->setBinLabel( 3 , "2nd jet" );
231  hists_["matchingMon_"]->setBinLabel( 4 , "3rd jet" );
232  hists_["matchingMon_"]->setBinLabel( 5 , "all " );
233 
234  return;
235  }
236 
237  void
239  {
240  // fetch trigger event if configured such
243  if( !event.getByToken(triggerTable_, triggerTable) ) return;
244  }
245 
246  edm::Handle<trigger::TriggerEventWithRefs> triggerEventWithRefsHandle;
247  if(!event.getByToken(triggerEventWithRefsTag_,triggerEventWithRefsHandle)) return;
248 
249  /*
250  ------------------------------------------------------------
251 
252  Primary Vertex Monitoring
253 
254  ------------------------------------------------------------
255  */
256  // fill monitoring plots for primary verices
258  if( !event.getByToken(pvs_, pvs) ) {
259  edm::LogWarning( "TopSingleLeptonHLTOfflineDQM" )
260  << "Vertex collection not found \n";
261  return;
262  }
263  unsigned int pvMult = 0;
264  for(edm::View<reco::Vertex>::const_iterator pv=pvs->begin(); pv!=pvs->end(); ++pv){
265  if(!pvSelect_ || (*pvSelect_)(*pv))
266  pvMult++;
267  }
268  fill("pvMult_", pvMult );
269 
270  /*
271  ------------------------------------------------------------
272 
273  Electron Monitoring
274 
275  ------------------------------------------------------------
276  */
277 
278  // fill monitoring plots for electrons
280  if( !event.getByToken(elecs_, elecs) ) {
281  edm::LogWarning( "TopSingleLeptonHLTOfflineDQM" )
282  << "Electron collection not found \n";
283  return;
284  }
285 
286  // check availability of electron id
287  edm::Handle<edm::ValueMap<float> > electronId;
289  if( !event.getByToken(electronId_, electronId) ) return;
290  }
291 
292  // loop electron collection
293  unsigned int eMultIso=0;
294  std::vector<const reco::GsfElectron*> isoElecs;
296  for(edm::View<reco::GsfElectron>::const_iterator elec=elecs->begin(); elec!=elecs->end(); ++elec){
297  unsigned int idx = elec-elecs->begin();
298  // restrict to electrons with good electronId
299  if( electronId_.isUninitialized() ? true : ((int)(*electronId)[elecs->refAt(idx)] & eidPattern_) ){
300  if(!elecSelect_ || (*elecSelect_)(*elec)){
301  if(!elecIso_ || (*elecIso_)(*elec)){ if(eMultIso == 0) e = *elec; isoElecs.push_back(&(*elec)); ++eMultIso;}
302  }
303  }
304  }
305 
306  /*
307  ------------------------------------------------------------
308 
309  Muon Monitoring
310 
311  ------------------------------------------------------------
312  */
313 
314  // fill monitoring plots for muons
315  unsigned int mMultIso=0;
317  std::vector<const reco::Muon*> isoMuons;
318  if( !event.getByToken(muons_, muons) ) {
319  edm::LogWarning( "TopSingleLeptonHLTOfflineDQM" )
320  << "Muon collection not found \n";
321  return;
322  }
323  reco::Muon mu;
324  for(edm::View<reco::Muon>::const_iterator muon=muons->begin(); muon!=muons->end(); ++muon){
325  // restrict to globalMuons
326  if( muon->isGlobalMuon() ){
327  // apply preselection
328  if(!muonSelect_ || (*muonSelect_)(*muon)){
329  if(!muonIso_ || (*muonIso_)(*muon)) {if(mMultIso == 0) mu = *muon; isoMuons.push_back(&(*muon)); ++mMultIso;}
330  }
331  }
332  }
333 
334  /*
335  ------------------------------------------------------------
336 
337  Jet Monitoring
338 
339  ------------------------------------------------------------
340  */
341 
342  // check availability of the btaggers
343  edm::Handle<reco::JetTagCollection> btagEff, btagPur, btagVtx;
344  if( includeBTag_ ){
345  if( !event.getByToken(btagEff_, btagEff) ) return;
346  if( !event.getByToken(btagPur_, btagPur) ) return;
347  if( !event.getByToken(btagVtx_, btagVtx) ) return;
348  }
349  // load jet corrector if configured such
350  const JetCorrector* corrector=0;
351  if(!jetCorrector_.empty()){
352  // check whether a jet corrector is in the event setup or not
353  if(setup.find( edm::eventsetup::EventSetupRecordKey::makeKey<JetCorrectionsRecord>() )){
354  corrector = JetCorrector::getJetCorrector(jetCorrector_, setup);
355  }
356  else{
357  edm::LogVerbatim( "TopSingleLeptonHLTOfflineDQM" )
358  << "\n"
359  << "------------------------------------------------------------------------------------- \n"
360  << " No JetCorrectionsRecord available from EventSetup: \n"
361  << " - Jets will not be corrected. \n"
362  << " - If you want to change this add the following lines to your cfg file: \n"
363  << " \n"
364  << " ## load jet corrections \n"
365  << " process.load(\"JetMETCorrections.Configuration.JetCorrectionServicesAllAlgos_cff\") \n"
366  << " process.prefer(\"ak5CaloL2L3\") \n"
367  << " \n"
368  << "------------------------------------------------------------------------------------- \n";
369  }
370  }
371 
372  // loop jet collection
373  std::vector<reco::Jet> correctedJets;
374  unsigned int mult=0, multBEff=0, multBPur=0, multBVtx=0;
375 
377  if( !event.getByToken(jets_, jets) ) {
378  edm::LogWarning( "TopSingleLeptonHLTOfflineDQM" )
379  << "Jet collection not found \n";
380  return;
381  }
382 
384  if(jetIDSelect_){
385  if( !event.getByToken(jetIDLabel_, jetID) ) return;
386  }
387  reco::Jet bJetCand;
388  for(edm::View<reco::Jet>::const_iterator jet=jets->begin(); jet!=jets->end(); ++jet){
389  // check jetID for calo jets
390  unsigned int idx = jet-jets->begin();
391  if( jetIDSelect_ && dynamic_cast<const reco::CaloJet*>(jets->refAt(idx).get())){
392  if(!(*jetIDSelect_)((*jetID)[jets->refAt(idx)])) continue;
393  }
394  // chekc additional jet selection for calo, pf and bare reco jets
395  if(dynamic_cast<const reco::CaloJet*>(&*jet)){
396  reco::CaloJet sel = dynamic_cast<const reco::CaloJet&>(*jet); sel.scaleEnergy(corrector ? corrector->correction(*jet) : 1.);
397  StringCutObjectSelector<reco::CaloJet> jetSelect(jetSelect_); if(!jetSelect(sel)){ continue;}
398  }
399  else if(dynamic_cast<const reco::PFJet*>(&*jet)){
400  reco::PFJet sel= dynamic_cast<const reco::PFJet&>(*jet); sel.scaleEnergy(corrector ? corrector->correction(*jet) : 1.);
401  StringCutObjectSelector<reco::PFJet> jetSelect(jetSelect_); if(!jetSelect(sel)) continue;
402  }
403  else{
404  reco::Jet sel = *jet; sel.scaleEnergy(corrector ? corrector->correction(*jet) : 1.);
405  StringCutObjectSelector<reco::Jet> jetSelect(jetSelect_); if(!jetSelect(sel)) continue;
406  }
407 
408  // prepare jet to fill monitor histograms
409  reco::Jet monitorJet = *jet; monitorJet.scaleEnergy(corrector ? corrector->correction(*jet) : 1.);
410  correctedJets.push_back(monitorJet);
411  ++mult; // determine jet multiplicity
412  if( includeBTag_ ){
413  // fill b-discriminators
414  edm::RefToBase<reco::Jet> jetRef = jets->refAt(idx);
415  // for the btagEff collection
416  double btagEffDisc = (*btagEff)[jetRef];
417  fill("jetBDiscEff_", btagEffDisc);
418  if( (*btagEff)[jetRef]>btagEffWP_ ) ++multBEff;
419  // for the btagPur collection
420  double btagPurDisc = (*btagPur)[jetRef];
421  fill("jetBDiscPur_", btagPurDisc);
422  if( (*btagPur)[jetRef]>btagPurWP_ ) {if(multBPur == 0) bJetCand = *jet; ++multBPur;}
423  // for the btagVtx collection
424  double btagVtxDisc = (*btagVtx)[jetRef];
425  fill("jetBDiscVtx_", btagVtxDisc);
426  if( (*btagVtx)[jetRef]>btagVtxWP_ ) ++multBVtx;
427  }
428  }
429  fill("jetMult_" , mult );
430  fill("jetMultBEff_", multBEff);
431  fill("jetMultBPur_", multBPur);
432  fill("jetMultBVtx_", multBVtx);
433 
434  /*
435  ------------------------------------------------------------
436 
437  MET Monitoring
438 
439  ------------------------------------------------------------
440  */
441 
442  // fill monitoring histograms for met
443  reco::MET mET;
444  for(std::vector< edm::EDGetTokenT< edm::View<reco::MET> > >::const_iterator met_=mets_.begin(); met_!=mets_.end(); ++met_){
446  if( !event.getByToken(*met_, met) ) continue;
447  if(met->begin()!=met->end()){
448  mET = *(met->begin());
449  }
450  }
451 
452  /*
453  ------------------------------------------------------------
454 
455  Event Monitoring
456 
457  ------------------------------------------------------------
458  */
459 
460  // fill W boson and top mass estimates
461  CalculateHLT eventKinematics(MAXJETS, WMASS);
462  double wMass = eventKinematics.massWBoson (correctedJets);
463  double topMass = eventKinematics.massTopQuark(correctedJets);
464  if(wMass>=0 && topMass>=0) {fill("massW_" , wMass ); fill("massTop_" , topMass);}
465  // fill plots for trigger monitoring
466  if((lowerEdge_==-1. && upperEdge_==-1.) || (lowerEdge_<wMass && wMass<upperEdge_) ){
467  if(!triggerTable_.isUninitialized()) fill(event, *triggerTable, "trigger", triggerPaths_);
468  if(logged_<=hists_.find("eventLogger_")->second->getNbinsY()){
469  // log runnumber, lumi block, event number & some
470  // more pysics infomation for interesting events
471  fill("eventLogger_", 0.5, logged_+0.5, event.eventAuxiliary().run());
472  fill("eventLogger_", 1.5, logged_+0.5, event.eventAuxiliary().luminosityBlock());
473  fill("eventLogger_", 2.5, logged_+0.5, event.eventAuxiliary().event());
474  ++logged_;
475  }
476  }
477  if(multBPur != 0 && mMultIso == 1 ){
478  double mtW = eventKinematics.tmassWBoson(&mu,mET,bJetCand); if (mtW == mtW) fill("MTWm_",mtW);
479  double Mlb = eventKinematics.masslb(&mu,mET,bJetCand); if (Mlb == Mlb) fill("mMub_", Mlb);
480  double MTT = eventKinematics.tmassTopQuark(&mu,mET,bJetCand); if (MTT == MTT) fill("mMTT_", MTT);
481  }
482 
483  if(multBPur != 0 && eMultIso == 1 ){
484  double mtW = eventKinematics.tmassWBoson(&mu,mET,bJetCand); if (mtW == mtW)fill("MTWe_",mtW);
485  double Mlb = eventKinematics.masslb(&mu,mET,bJetCand); if (Mlb == Mlb) fill("mEb_", Mlb);
486  double MTT = eventKinematics.tmassTopQuark(&mu,mET,bJetCand); if (MTT == MTT) fill("eMTT_", MTT);
487  }
488 
489 
490  /*
491  ------------------------------------------------------------
492 
493  HLT Objects Monitoring
494 
495  ------------------------------------------------------------
496  */
497 
498  const edm::TriggerNames& triggerNames = event.triggerNames(*triggerTable);
499  // loop over trigger paths
500  for(unsigned int i=0; i<triggerNames.triggerNames().size(); ++i){
501  // consider only path from triggerPaths
502  string name = triggerNames.triggerNames()[i];
503  bool isInteresting = false;
504  for (unsigned int j=0; j<triggerPaths.size(); j++) {
505  if (TString(name.c_str()).Contains(TString(triggerPaths[j]), TString::kIgnoreCase)) isInteresting = true;
506  }
507  if (!isInteresting) continue;
508  // dump infos on the considered trigger path
509  const unsigned int triggerIndex = triggerNames.triggerIndex(name);
510  // get modules for the considered trigger path
511  const vector<string>& moduleLabels(hltConfig.moduleLabels(triggerIndex));
512  const unsigned int moduleIndex(triggerTable->index(triggerIndex));
513  // Results from TriggerEventWithRefs product
514  electronIds_.clear(); electronRefs_.clear();
515  muonIds_.clear(); muonRefs_.clear();
516  pfjetIds_.clear(); pfjetRefs_.clear();
517  // look only for modules actually run in this path
518  unsigned int kElec=0;
519  unsigned int kMuon=0;
520  unsigned int kJet=0;
521  for (unsigned int k=0; k<=moduleIndex; ++k) {
522  const string& moduleLabel(moduleLabels[k]);
523  const string moduleType(hltConfig.moduleType(moduleLabel));
524  // check whether the module is packed up in TriggerEventWithRef product
525  const unsigned int filterIndex(triggerEventWithRefsHandle->filterIndex(edm::InputTag(moduleLabel,"",processName_)));
526  if (filterIndex<triggerEventWithRefsHandle->size()) {
527  triggerEventWithRefsHandle->getObjects(filterIndex,electronIds_,electronRefs_);
528  const unsigned int nElectrons(electronIds_.size());
529  if (nElectrons>0) kElec = k;
530 
531  triggerEventWithRefsHandle->getObjects(filterIndex,muonIds_,muonRefs_);
532  const unsigned int nMuons(muonIds_.size());
533  if (nMuons>0) kMuon = k;
534 
535  triggerEventWithRefsHandle->getObjects(filterIndex,pfjetIds_,pfjetRefs_);
536  const unsigned int nPFJets(pfjetIds_.size());
537  if (nPFJets>0) kJet = k;
538  }
539  }
540  bool isMatched = true;
541  bool lMatched = false;
542  bool j1Matched = false;
543  bool j2Matched = false;
544  bool j3Matched = false;
545  // access to hlt elecs
546  double eDeltaRMin = 500.;
547  unsigned int eIndMatched = 500;
548  electronIds_.clear(); electronRefs_.clear();
549  if (kElec > 0) {
550  const string& moduleLabelElec(moduleLabels[kElec]);
551  const string moduleTypeElec(hltConfig.moduleType(moduleLabelElec));
552  const unsigned int filterIndexElec(triggerEventWithRefsHandle->filterIndex(edm::InputTag(moduleLabelElec,"",processName_)));
553  triggerEventWithRefsHandle->getObjects(filterIndexElec,electronIds_,electronRefs_);
554  for (unsigned int inde = 0; inde < isoElecs.size(); inde++) {
555  double deltar = deltaR(*electronRefs_[0],*isoElecs[inde]);
556  if (deltar < eDeltaRMin) {
557  eDeltaRMin = deltar;
558  eIndMatched = inde;
559  }
560  }
561  if (eDeltaRMin < DRMIN) lMatched = true;
562  }
563  // access to hlt muons
564  muonIds_.clear(); muonRefs_.clear();
565  double mDeltaRMin = 500.;
566  unsigned int mIndMatched = 500;
567  if (kMuon > 0) {
568  const string& moduleLabelMuon(moduleLabels[kMuon]);
569  const string moduleTypeMuon(hltConfig.moduleType(moduleLabelMuon));
570  const unsigned int filterIndexMuon(triggerEventWithRefsHandle->filterIndex(edm::InputTag(moduleLabelMuon,"",processName_)));
571  triggerEventWithRefsHandle->getObjects(filterIndexMuon,muonIds_,muonRefs_);
572  for (unsigned int indm = 0; indm < isoMuons.size(); indm++) {
573  double deltar = deltaR(*muonRefs_[0],*isoMuons[indm]);
574  if (deltar < mDeltaRMin) {
575  mDeltaRMin = deltar;
576  mIndMatched = indm;
577  }
578  }
579  if (mDeltaRMin < DRMIN) lMatched = true;
580  }
581  // access to hlt pf jets
582  const unsigned int nPFJets(pfjetIds_.size());
583  pfjetIds_.clear(); pfjetRefs_.clear();
584  double j1DeltaRMin = 500.;
585  double j2DeltaRMin = 500.;
586  double j3DeltaRMin = 500.;
587  unsigned int j1IndMatched = 500;
588  unsigned int j2IndMatched = 500;
589  unsigned int j3IndMatched = 500;
590  if (kJet > 0) {
591  const string& moduleLabelJet(moduleLabels[kJet]);
592  const string moduleTypeJet(hltConfig.moduleType(moduleLabelJet));
593  const unsigned int filterIndexJet(triggerEventWithRefsHandle->filterIndex(edm::InputTag(moduleLabelJet,"",processName_)));
594  triggerEventWithRefsHandle->getObjects(filterIndexJet,pfjetIds_,pfjetRefs_);
595  for (unsigned int indj = 0; indj < correctedJets.size(); indj++) {
596  double deltar1 = deltaR(*pfjetRefs_[0],correctedJets[indj]);
597  if (deltar1 < j1DeltaRMin) {j1DeltaRMin = deltar1; j1IndMatched = indj;}
598  if (nPFJets > 1) {
599  double deltar2 = deltaR(*pfjetRefs_[1],correctedJets[indj]);
600  if (deltar2 < j2DeltaRMin) {j2DeltaRMin = deltar2; j2IndMatched = indj;}
601  if (nPFJets > 2) {
602  double deltar3 = deltaR(*pfjetRefs_[2],correctedJets[indj]);
603  if (deltar3 < j3DeltaRMin) {j3DeltaRMin = deltar3; j3IndMatched = indj;}
604  }
605  }
606  }
607  if (nPFJets > 0 && j1DeltaRMin < DRMIN) j1Matched = true;
608  if (nPFJets > 1 && j2DeltaRMin < DRMIN) j2Matched = true;
609  if (nPFJets > 2 && j3DeltaRMin < DRMIN) j3Matched = true;
610  }
611  if (eIndMatched < 500) {
612  fill("leptDeltaREta_", isoElecs[eIndMatched]->eta(), eDeltaRMin);
613  if (lMatched) fill("leptResolution_", fabs(isoElecs[eIndMatched]->pt()-electronRefs_[0]->pt())/isoElecs[eIndMatched]->pt() );
614  }
615  if (mIndMatched < 500) {
616  fill("leptDeltaREta_", isoMuons[mIndMatched]->eta(), mDeltaRMin);
617  if (lMatched) fill("leptResolution_", fabs(isoMuons[mIndMatched]->pt()-muonRefs_[0]->pt())/isoMuons[mIndMatched]->pt() );
618  }
619  if (lMatched) fill("matchingMon_", 0.5 );
620  else isMatched = false;
621  if (j1IndMatched < 500) {
622  fill("jetDeltaREta_", correctedJets[j1IndMatched].eta(), j1DeltaRMin);
623  if (j1Matched) {
624  fill("jetResolution_", fabs(correctedJets[j1IndMatched].pt()-pfjetRefs_[0]->pt())/correctedJets[j1IndMatched].pt() );
625  fill("matchingMon_", 1.5 );
626  }
627  else isMatched = false;
628  if (j2IndMatched < 500) {
629  fill("jetDeltaREta_", correctedJets[j2IndMatched].eta(), j2DeltaRMin);
630  if (j2Matched) {
631  fill("jetResolution_", fabs(correctedJets[j2IndMatched].pt()-pfjetRefs_[1]->pt())/correctedJets[j2IndMatched].pt() );
632  fill("matchingMon_", 2.5 );
633  }
634  else isMatched = false;
635  if (j3IndMatched < 500) {
636  fill("jetDeltaREta_", correctedJets[j3IndMatched].eta(), j3DeltaRMin);
637  if (j3Matched) {
638  fill("jetResolution_", fabs(correctedJets[j3IndMatched].pt()-pfjetRefs_[2]->pt())/correctedJets[j3IndMatched].pt() );
639  fill("matchingMon_", 3.5 );
640  }
641  else isMatched = false;
642  }
643  }
644  }
645  if (isMatched) fill("matchingMon_", 4.5 );
646 
647  }
648 
649  }
650 
651 }
652 
654 
655 TopSingleLeptonHLTOfflineDQM::TopSingleLeptonHLTOfflineDQM(const edm::ParameterSet& cfg): vertexSelect_(0), beamspotSelect_(0)
656 {
657  // configure preselection
658  edm::ParameterSet presel=cfg.getParameter<edm::ParameterSet>("preselection");
659  if( presel.existsAs<edm::ParameterSet>("trigger") ){
660  edm::ParameterSet trigger=presel.getParameter<edm::ParameterSet>("trigger");
661  triggerTable_= consumes< edm::TriggerResults >(trigger.getParameter<edm::InputTag>("src"));
662  triggerPaths_=trigger.getParameter<std::vector<std::string> >("select");
663  }
664  if( presel.existsAs<edm::ParameterSet>("vertex" ) ){
665  edm::ParameterSet vertex=presel.getParameter<edm::ParameterSet>("vertex");
666  vertex_= consumes< std::vector<reco::Vertex> >(vertex.getParameter<edm::InputTag>("src"));
668  }
669  if( presel.existsAs<edm::ParameterSet>("beamspot" ) ){
670  edm::ParameterSet beamspot=presel.getParameter<edm::ParameterSet>("beamspot");
671  beamspot_= consumes< reco::BeamSpot >(beamspot.getParameter<edm::InputTag>("src"));
673  }
674 
675  // configure the selection
676  std::vector<edm::ParameterSet> sel=cfg.getParameter<std::vector<edm::ParameterSet> >("selection");
677  for(unsigned int i=0; i<sel.size(); ++i){
678  selectionOrder_.push_back(sel.at(i).getParameter<std::string>("label"));
680  }
681 
682  for (const std::string& s: selectionOrder_) {
684 
685  if (selection_.find(key) == selection_.end())
686  continue;
687 
688  if (type == "muons"){
690  }
691  if (type == "elecs"){
693  }
694  if (type == "jets"){
696  }
697  if (type == "jets/pf"){
699  }
700  if (type == "jets/calo"){
702  }
703  if (type == "met"){
705  }
706  }
707 }
708 
709  void
711 {
712  using namespace std;
713  using namespace edm;
714 
715  bool changed(true);
716  if (!hltConfig_.init(iRun,iSetup,"*",changed)) {
717  edm::LogWarning( "TopSingleLeptonHLTOfflineDQM" )
718  << "Config extraction failure with process name "
720  << "\n";
721  return;
722  }
723 }
724 
725  void
727 {
730  if( !event.getByToken(triggerTable_, triggerTable) ) return;
731  if(!acceptHLT(event, *triggerTable, triggerPaths_)) return;
732  }
733  if(!vertex_.isUninitialized()){
735  if( !event.getByToken(vertex_, vertex) ) return;
736  if(vertex->empty() || !(*vertexSelect_)(vertex->front())) return;
737  }
738  if(!beamspot_.isUninitialized()){
740  if( !event.getByToken(beamspot_, beamspot) ) return;
741  if(!(*beamspotSelect_)(*beamspot)) return;
742  }
743  // apply selection steps
744  for(std::vector<std::string>::const_iterator selIt=selectionOrder_.begin(); selIt!=selectionOrder_.end(); ++selIt){
745  std::string key = selectionStep(*selIt), type = objectType(*selIt);
746  if(selection_.find(key)!=selection_.end()){
747 
748  if(type=="empty"){
749  selection_[key].second->fill(event, setup, hltConfig_, triggerPaths_);
750  continue;
751  }
752  if(type=="Hlt" ){
753  selection_[key].second->fill(event, setup, hltConfig_, triggerPaths_);
754  continue;
755  }
756 
757  bool passSel = true;
758 
759  for(std::vector<std::string>::const_iterator selIt2=selectionOrder_.begin(); selIt2<=selIt; ++selIt2){
760  std::string key2 = selectionStep(*selIt2), type2 = objectType(*selIt2);
761  if(selection_.find(key2)==selection_.end()) continue;
762 
763  if(type2=="Hlt" || type2=="empty" ) continue;
764  if (!selectmap_[type2]->select(event)) passSel=false;
765 
766  } // end 2nd loop
767 
768  // Apply cumulative event selection
769  if ( !passSel ) continue;
770 
771  selection_[key].second->fill(event, setup, hltConfig_, triggerPaths_);
772 
773  }
774  }
775 }
776 
777 void
779 {
780  for (auto& sel: selection_) {
781  sel.second.second->book(i);
782  }
783 }
type
Definition: HCALResponse.h:21
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
tuple met
____________________________________________________________________________||
Definition: CaloMET_cfi.py:4
const std::string moduleType(const std::string &module) const
C++ class name of module.
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:184
Jets made from CaloTowers.
Definition: CaloJet.h:29
StringCutObjectSelector< reco::JetID > * jetIDSelect_
extra jetID selection on calo jets
std::map< std::string, SelectionStepHLTBase * > selectmap_
StringCutObjectSelector< reco::GsfElectron > * elecSelect_
extra selection on electrons
double masslb(reco::RecoCandidate *mu, const reco::MET &met, const reco::Jet &b)
calculate mlb estimate
double massTopQuark(const std::vector< reco::Jet > &jets)
calculate top quark mass estimate
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
virtual void analyze(const edm::Event &event, const edm::EventSetup &setup)
void bookHistograms(DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &) override
virtual double correction(const LorentzVector &fJet) const =0
get correction using Jet information only
Base class for all types of Jets.
Definition: Jet.h:20
double tmassTopQuark(reco::RecoCandidate *mu, const reco::MET &met, const reco::Jet &b)
calculate top quark transverse mass estimate
StringCutObjectSelector< reco::Vertex > * pvSelect_
extra selection on primary vertices; meant to investigate the pile-up effect
RunNumber_t run() const
std::map< std::string, MonitorElement * > hists_
histogram container
double massWBoson(const std::vector< reco::Jet > &jets)
calculate W boson mass estimate
edm::EDGetTokenT< reco::JetTagCollection > btagPur_
virtual void scaleEnergy(double fScale)
scale energy of the jet
Definition: Jet.cc:444
edm::EDGetTokenT< edm::View< reco::GsfElectron > > elecs_
input sources for monitoring
std::string selectionStep(const std::string &label)
T eta() const
edm::EDGetTokenT< reco::JetIDValueMap > jetIDLabel_
jetID as an extra selection type
std::vector< edm::EDGetTokenT< edm::View< reco::MET > > > mets_
considers a vector of METs
void book(DQMStore::IBooker &store_)
book histograms in subdirectory directory
std::vector< std::string > selectionOrder_
Strings const & triggerNames() const
Definition: TriggerNames.cc:24
Jets made from PFObjects.
Definition: PFJet.h:21
#define MAXJETS
Definition: myFastSimVal.cc:30
LuminosityBlockNumber_t luminosityBlock() const
const eventsetup::EventSetupRecord * find(const eventsetup::EventSetupRecordKey &) const
Definition: EventSetup.cc:90
edm::EDGetTokenT< trigger::TriggerEventWithRefs > triggerEventWithRefsTag_
edm::EDGetTokenT< edm::TriggerResults > triggerTable_
trigger table
unsigned int triggerIndex(std::string const &name) const
Definition: TriggerNames.cc:32
edm::EDGetTokenT< std::vector< reco::Vertex > > vertex_
primary vertex
void fill(const edm::Event &event, const edm::EventSetup &setup, const HLTConfigProvider &hltConfig, const std::vector< std::string > triggerPaths)
fill monitor histograms with electronId and jetCorrections
Definition: MET.h:39
StringCutObjectSelector< reco::BeamSpot > * beamspotSelect_
string cut selector
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
edm::EDGetTokenT< edm::View< reco::Muon > > muons_
std::map< std::string, std::pair< edm::ParameterSet, HLTOfflineDQMTopSingleLepton::MonitorSingleLepton * > > selection_
vector< PseudoJet > jets
edm::EDGetTokenT< reco::JetTagCollection > btagEff_
btag discriminator labels
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:113
int j
Definition: DBlmapReader.cc:9
bool isMatched(TrackingRecHit const &hit)
void triggerBinLabels(std::string channel, const std::vector< std::string > &labels)
set configurable labels for trigger monitoring histograms
const int mu
Definition: Constants.h:22
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
edm::EDGetTokenT< edm::View< reco::Vertex > > pvs_
double tmassWBoson(reco::RecoCandidate *mu, const reco::MET &met, const reco::Jet &b)
calculate W boson transverse mass estimate
const std::string & processName() const
process name
std::vector< std::string > triggerPaths_
trigger paths
virtual void dqmBeginRun(const edm::Run &r, const edm::EventSetup &c)
do this during the event loop
int k[5][pyjets_maxn]
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
StringCutObjectSelector< reco::Muon > * muonIso_
extra isolation criterion on muon
EventAuxiliary const & eventAuxiliary() const
Definition: Event.h:72
StringCutObjectSelector< reco::Vertex > * vertexSelect_
string cut selector
StringCutObjectSelector< reco::GsfElectron > * elecIso_
extra isolation criterion on electron
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
edm::EDGetTokenT< reco::BeamSpot > beamspot_
beamspot
bool acceptHLT(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:131
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
static const JetCorrector * getJetCorrector(const std::string &fName, const edm::EventSetup &fSetup)
retrieve corrector from the event setup. troughs exception if something is missing ...
Definition: JetCorrector.cc:50
edm::EDGetTokenT< edm::View< reco::Jet > > jets_
std::string objectType(const std::string &label)
TopSingleLeptonHLTOfflineDQM(const edm::ParameterSet &cfg)
default constructor
list key
Definition: combine.py:13
tuple muons
Definition: patZpeak.py:38
edm::EDGetTokenT< edm::TriggerResults > triggerTable_
trigger table
bool isUninitialized() const
Definition: EDGetToken.h:71
edm::EDGetTokenT< reco::JetTagCollection > btagVtx_
edm::EDGetTokenT< edm::ValueMap< float > > electronId_
electronId label
volatile std::atomic< bool > shutdown_flag false
StringCutObjectSelector< reco::Muon > * muonSelect_
extra selection on muons
tuple process
Definition: LaserDQM_cfg.py:3
static std::string const triggerPaths
Definition: EdmProvDump.cc:42
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
tuple size
Write out results.
EventNumber_t event() const
Definition: Run.h:41