CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TopHLTSingleLeptonDQM.cc
Go to the documentation of this file.
8 #include <iostream>
9 /*Originally from DQM/Physics by R. Wolf and J. Andrea*/
10 using namespace std;
11 namespace TopHLTSingleLepton {
12 
13  // maximal number of leading jets
14  // to be used for top mass estimate
15  static const unsigned int MAXJETS = 4;
16  // nominal mass of the W boson to
17  // be used for the top mass estimate
18  static const double WMASS = 80.4;
19 
20  MonitorEnsemble::MonitorEnsemble(const char* label, const edm::ParameterSet& cfg) :
21  label_(label), elecIso_(0), elecSelect_(0), pvSelect_(0), muonIso_(0), muonSelect_(0), jetIDSelect_(0), includeBTag_(false), lowerEdge_(-1.), upperEdge_(-1.), logged_(0)
22  {
23  // sources have to be given; this PSet is not optional
24  edm::ParameterSet sources=cfg.getParameter<edm::ParameterSet>("sources");
25  muons_= sources.getParameter<edm::InputTag>("muons");
26  elecs_= sources.getParameter<edm::InputTag>("elecs");
27  jets_ = sources.getParameter<edm::InputTag>("jets" );
28  mets_ = sources.getParameter<std::vector<edm::InputTag> >("mets" );
29  pvs_ = sources.getParameter<edm::InputTag>("pvs" );
30  // electronExtras are optional; they may be omitted or
31  // empty
32  if( cfg.existsAs<edm::ParameterSet>("elecExtras") ){
33  edm::ParameterSet elecExtras=cfg.getParameter<edm::ParameterSet>("elecExtras");
34  // select is optional; in case it's not found no
35  // selection will be applied
36  if( elecExtras.existsAs<std::string>("select") ){
38  }
39  // isolation is optional; in case it's not found no
40  // isolation will be applied
41  if( elecExtras.existsAs<std::string>("isolation") ){
43  }
44  // electronId is optional; in case it's not found the
45  // InputTag will remain empty
46  if( elecExtras.existsAs<edm::ParameterSet>("electronId") ){
47  edm::ParameterSet elecId=elecExtras.getParameter<edm::ParameterSet>("electronId");
48  electronId_= elecId.getParameter<edm::InputTag>("src");
49  eidPattern_= elecId.getParameter<int>("pattern");
50  }
51  }
52  // pvExtras are opetional; they may be omitted or empty
53  if(cfg.existsAs<edm::ParameterSet>("pvExtras")){
54  edm::ParameterSet pvExtras=cfg.getParameter<edm::ParameterSet>("pvExtras");
55  // select is optional; in case it's not found no
56  // selection will be applied
57  if( pvExtras.existsAs<std::string>("select") ){
59  }
60  }
61  // muonExtras are optional; they may be omitted or empty
62  if( cfg.existsAs<edm::ParameterSet>("muonExtras") ){
63  edm::ParameterSet muonExtras=cfg.getParameter<edm::ParameterSet>("muonExtras");
64  // select is optional; in case it's not found no
65  // selection will be applied
66  if( muonExtras.existsAs<std::string>("select") ){
68  }
69  // isolation is optional; in case it's not found no
70  // isolation will be applied
71  if( muonExtras.existsAs<std::string>("isolation") ){
73  }
74  }
75 
76  // jetExtras are optional; they may be omitted or
77  // empty
78  if( cfg.existsAs<edm::ParameterSet>("jetExtras") ){
79  edm::ParameterSet jetExtras=cfg.getParameter<edm::ParameterSet>("jetExtras");
80  // jetCorrector is optional; in case it's not found
81  // the InputTag will remain empty
82  if( jetExtras.existsAs<std::string>("jetCorrector") ){
83  jetCorrector_= jetExtras.getParameter<std::string>("jetCorrector");
84  }
85  // read jetID information if it exists
86  if(jetExtras.existsAs<edm::ParameterSet>("jetID")){
88  jetIDLabel_ =jetID.getParameter<edm::InputTag>("label");
90  }
91  // select is optional; in case it's not found no
92  // selection will be applied (only implemented for
93  // CaloJets at the moment)
94  if( jetExtras.existsAs<std::string>("select") ){
95  jetSelect_= jetExtras.getParameter<std::string>("select");
96  }
97  // jetBDiscriminators are optional; in case they are
98  // not found the InputTag will remain empty; they
99  // consist of pairs of edm::JetFlavorAssociation's &
100  // corresponding working points
101  includeBTag_=jetExtras.existsAs<edm::ParameterSet>("jetBTaggers");
102  if( includeBTag_ ){
103  edm::ParameterSet btagEff=jetExtras.getParameter<edm::ParameterSet>("jetBTaggers").getParameter<edm::ParameterSet>("trackCountingEff");
104  btagEff_= btagEff.getParameter<edm::InputTag>("label"); btagEffWP_= btagEff.getParameter<double>("workingPoint");
105  edm::ParameterSet btagPur=jetExtras.getParameter<edm::ParameterSet>("jetBTaggers").getParameter<edm::ParameterSet>("trackCountingPur");
106  btagPur_= btagPur.getParameter<edm::InputTag>("label"); btagPurWP_= btagPur.getParameter<double>("workingPoint");
107  edm::ParameterSet btagVtx=jetExtras.getParameter<edm::ParameterSet>("jetBTaggers").getParameter<edm::ParameterSet>("secondaryVertex" );
108  btagVtx_= btagVtx.getParameter<edm::InputTag>("label"); btagVtxWP_= btagVtx.getParameter<double>("workingPoint");
109  }
110  }
111 
112  // triggerExtras are optional; they may be omitted or empty
113  if( cfg.existsAs<edm::ParameterSet>("triggerExtras") ){
114  edm::ParameterSet triggerExtras=cfg.getParameter<edm::ParameterSet>("triggerExtras");
115  triggerTable_=triggerExtras.getParameter<edm::InputTag>("src");
116  triggerPaths_=triggerExtras.getParameter<std::vector<std::string> >("paths");
117  }
118 
119  // massExtras is optional; in case it's not found no mass
120  // window cuts are applied for the same flavor monitor
121  // histograms
122  if( cfg.existsAs<edm::ParameterSet>("massExtras") ){
123  edm::ParameterSet massExtras=cfg.getParameter<edm::ParameterSet>("massExtras");
124  lowerEdge_= massExtras.getParameter<double>("lowerEdge");
125  upperEdge_= massExtras.getParameter<double>("upperEdge");
126  }
127 
128  // setup the verbosity level for booking histograms;
129  // per default the verbosity level will be set to
130  // STANDARD. This will also be the chosen level in
131  // the case when the monitoring PSet is not found
133  if( cfg.existsAs<edm::ParameterSet>("monitoring") ){
134  edm::ParameterSet monitoring=cfg.getParameter<edm::ParameterSet>("monitoring");
135  if(monitoring.getParameter<std::string>("verbosity") == "DEBUG" )
136  verbosity_= DEBUG;
137  if(monitoring.getParameter<std::string>("verbosity") == "VERBOSE" )
139  if(monitoring.getParameter<std::string>("verbosity") == "STANDARD")
141  }
142  // and don't forget to do the histogram booking
143  book(cfg.getParameter<std::string>("directory"));
144  }
145 
146  void
148  {
149  //set up the current directory path
150  std::string current(directory); current+=label_;
152  store_->setCurrentFolder(current);
153 
154  // determine number of bins for trigger monitoring
155  unsigned int nPaths=triggerPaths_.size();
156 
157  // --- [STANDARD] --- //
158  // number of selected primary vertices
159  hists_["pvMult_" ] = store_->book1D("PvMult" , "N_{pvs}" , 100, 0., 100.);
160  // pt of the leading muon
161  hists_["muonPt_" ] = store_->book1D("MuonPt" , "pt(#mu)" , 50, 0., 250.);
162  // muon multiplicity before std isolation
163  hists_["muonMult_" ] = store_->book1D("MuonMult" , "N_{All}(#mu)" , 10, 0., 10.);
164  // muon multiplicity after std isolation
165  hists_["muonMultIso_"] = store_->book1D("MuonMultIso", "N_{Iso}(#mu)" , 10, 0., 10.);
166  // pt of the leading electron
167  hists_["elecPt_" ] = store_->book1D("ElecPt" , "pt(e)" , 50, 0., 250.);
168  // electron multiplicity before std isolation
169  hists_["elecMult_" ] = store_->book1D("ElecMult" , "N_{All}(e)" , 10, 0., 10.);
170  // electron multiplicity after std isolation
171  hists_["elecMultIso_"] = store_->book1D("ElecMultIso", "N_{Iso}(e)" , 10, 0., 10.);
172  // multiplicity of jets with pt>20 (corrected to L2+L3)
173  hists_["jetMult_" ] = store_->book1D("JetMult" , "N_{30}(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  // MET (calo)
179  hists_["metCalo_" ] = store_->book1D("METCalo" , "MET_{Calo}" , 50, 0., 200.);
180  // W mass estimate
181  hists_["massW_" ] = store_->book1D("MassW" , "M(W)" , 60, 0., 300.);
182  // Top mass estimate
183  hists_["massTop_" ] = store_->book1D("MassTop" , "M(Top)" , 50, 0., 500.);
184  // Mlb mu
185  hists_["mMub_" ] = store_->book1D("mMub" , "m_{#mub}" , 50, 0., 500.);
186  // W mass transverse estimate mu
187  hists_["MTWm_" ] = store_->book1D("MTWm" , "M_{T}^{W}(#mu)" , 60, 0., 300.);
188  // Top mass transverse estimate mu
189  hists_["mMTT_" ] = store_->book1D("mMTT" , "M_{T}^{t}(#mu)" , 50, 0., 500.);
190 
191  // Mlb e
192  hists_["mEb_" ] = store_->book1D("mEb" , "m_{eb}" , 50, 0., 500.);
193  // W mass transverse estimate e
194  hists_["MTWe_" ] = store_->book1D("MTWe" , "M_{T}^{W}(e)" , 60, 0., 300.);
195  // Top mass transverse estimate e
196  hists_["eMTT_" ] = store_->book1D("eMTT" , "M_{T}^{t}(e)" , 50, 0., 500.);
197 
198 
199 
200 
201  // set bin labels for trigger monitoring
203 
204  if( verbosity_==STANDARD) return;
205 
206  // --- [VERBOSE] --- //
207  // eta of the leading muon
208  hists_["muonEta_" ] = store_->book1D("MuonEta" , "#eta(#mu)" , 30, -3., 3.);
209  // std isolation variable of the leading muon
210  hists_["muonRelIso_" ] = store_->book1D("MuonRelIso" , "Iso_{Rel}(#mu)" , 50, 0., 1.);
211  // eta of the leading electron
212  hists_["elecEta_" ] = store_->book1D("ElecEta" , "#eta(e)" , 30, -3., 3.);
213  // std isolation variable of the leading electron
214  hists_["elecRelIso_" ] = store_->book1D("ElecRelIso" , "Iso_{Rel}(e)" , 50, 0., 1.);
215  // multiplicity of btagged jets (for track counting high efficiency) with pt(L2L3)>30
216  hists_["jetMultBEff_"] = store_->book1D("JetMultBEff", "N_{30}(b/eff)" , 10, 0., 10.);
217  // btag discriminator for track counting high efficiency for jets with pt(L2L3)>30
218  hists_["jetBDiscEff_"] = store_->book1D("JetBDiscEff", "Disc_{b/eff}(jet)", 100, 0., 10.);
219  // pt of the 1. leading jet (corrected to L2+L3)
220  hists_["jet1Pt_" ] = store_->book1D("Jet1Pt" , "pt_{L2L3}(jet1)" , 60, 0., 300.);
221  // pt of the 2. leading jet (corrected to L2+L3)
222  hists_["jet2Pt_" ] = store_->book1D("Jet2Pt" , "pt_{L2L3}(jet2)" , 60, 0., 300.);
223  // pt of the 3. leading jet (corrected to L2+L3)
224  hists_["jet3Pt_" ] = store_->book1D("Jet3Pt" , "pt_{L2L3}(jet3)" , 60, 0., 300.);
225  // pt of the 4. leading jet (corrected to L2+L3)
226  hists_["jet4Pt_" ] = store_->book1D("Jet4Pt" , "pt_{L2L3}(jet4)" , 60, 0., 300.);
227  // eta of the 1.
228  hists_["jet1Eta_" ] = store_->book1D("Jet1Eta" , "#eta(jet1)" , 30, -3., 3.);
229  // eta of the 2.
230  hists_["jet2Eta_" ] = store_->book1D("Jet2Eta" , "#eta(jet2)" , 30, -3., 3.);
231  // eta of the 3.
232  hists_["jet3Eta_" ] = store_->book1D("Jet3Eta" , "#eta(jet3)" , 30, -3., 3.);
233  // eta of the 4.
234  hists_["jet4Eta_" ] = store_->book1D("Jet4Eta" , "#eta(jet4)" , 30, -3., 3.);
235  // MET (tc)
236  hists_["metTC_" ] = store_->book1D("METTC" , "MET_{TC}" , 50, 0., 200.);
237  // MET (pflow)
238  hists_["metPflow_" ] = store_->book1D("METPflow" , "MET_{Pflow}" , 50, 0., 200.);
239  // dz for muons (to suppress cosmis)
240  hists_["muonDelZ_" ] = store_->book1D("MuonDelZ" , "d_{z}(#mu)" , 50, -25., 25.);
241  // dxy for muons (to suppress cosmics)
242  hists_["muonDelXY_" ] = store_->book2D("MuonDelXY" , "d_{xy}(#mu)" , 50, -0.1, 0.1, 50, -0.1, 0.1);
243 
244  // set axes titles for dxy for muons
245  hists_["muonDelXY_" ]->setAxisTitle( "x [cm]", 1); hists_["muonDelXY_" ]->setAxisTitle( "y [cm]", 2);
246 
247  if( verbosity_==VERBOSE) return;
248 
249  // --- [DEBUG] --- //
250  // relative muon isolation in tracker for the leading muon
251  hists_["muonTrkIso_" ] = store_->book1D("MuonTrkIso" , "Iso_{Trk}(#mu)" , 50, 0., 1.);
252  // relative muon isolation in ecal+hcal for the leading muon
253  hists_["muonCalIso_" ] = store_->book1D("MuonCalIso" , "Iso_{Ecal}(#mu)" , 50, 0., 1.);
254  // relative electron isolation in tracker for the leading electron
255  hists_["elecTrkIso_" ] = store_->book1D("ElecTrkIso" , "Iso_{Trk}(e)" , 50, 0., 1.);
256  // relative electron isolation in ecal+hcal for the leading electron
257  hists_["elecCalIso_" ] = store_->book1D("ElecCalIso" , "Iso_{Ecal}(e)" , 50, 0., 1.);
258  // multiplicity of btagged jets (for track counting high purity) with pt(L2L3)>30
259  hists_["jetMultBPur_"] = store_->book1D("JetMultBPur", "N_{30}(b/pur)" , 10, 0., 10.);
260  // btag discriminator for track counting high purity
261  hists_["jetBDiscPur_"] = store_->book1D("JetBDiscPur", "Disc_{b/pur}(Jet)", 100, 0., 10.);
262  // multiplicity of btagged jets (for simple secondary vertex) with pt(L2L3)>30
263  hists_["jetMultBVtx_"] = store_->book1D("JetMultBVtx", "N_{30}(b/vtx)" , 10, 0., 10.);
264  // btag discriminator for simple secondary vertex
265  hists_["jetBDiscVtx_"] = store_->book1D("JetBDiscVtx", "Disc_{b/vtx}(Jet)", 35, -1., 6.);
266  // pt of the 1. leading jet (uncorrected)
267  hists_["jet1PtRaw_" ] = store_->book1D("Jet1PtRaw" , "pt_{Raw}(jet1)" , 60, 0., 300.);
268  // pt of the 2. leading jet (uncorrected)
269  hists_["jet2PtRaw_" ] = store_->book1D("Jet2PtRaw" , "pt_{Raw}(jet2)" , 60, 0., 300.);
270  // pt of the 3. leading jet (uncorrected)
271  hists_["jet3PtRaw_" ] = store_->book1D("Jet3PtRaw" , "pt_{Raw}(jet3)" , 60, 0., 300.);
272  // pt of the 4. leading jet (uncorrected)
273  hists_["jet4PtRaw_" ] = store_->book1D("Jet4PtRaw" , "pt_{Raw}(jet4)" , 60, 0., 300.);
274  // selected events
275  hists_["eventLogger_"] = store_->book2D("EventLogger", "Logged Events" , 9, 0., 9., 10, 0., 10.);
276 
277  // set axes titles for selected events
278  hists_["eventLogger_"]->getTH1()->SetOption("TEXT");
279  hists_["eventLogger_"]->setBinLabel( 1 , "Run" , 1);
280  hists_["eventLogger_"]->setBinLabel( 2 , "Block" , 1);
281  hists_["eventLogger_"]->setBinLabel( 3 , "Event" , 1);
282  hists_["eventLogger_"]->setBinLabel( 4 , "pt_{L2L3}(jet1)" , 1);
283  hists_["eventLogger_"]->setBinLabel( 5 , "pt_{L2L3}(jet2)" , 1);
284  hists_["eventLogger_"]->setBinLabel( 6 , "pt_{L2L3}(jet3)" , 1);
285  hists_["eventLogger_"]->setBinLabel( 7 , "pt_{L2L3}(jet4)" , 1);
286  hists_["eventLogger_"]->setBinLabel( 8 , "M_{W}" , 1);
287  hists_["eventLogger_"]->setBinLabel( 9 , "M_{Top}" , 1);
288  hists_["eventLogger_"]->setAxisTitle("logged evts" , 2);
289  return;
290  }
291 
292  void
299  std::vector< edm::Handle<edm::View<reco::MET> > > mets)
300  {
301  // fetch trigger event if configured such
302  if(!triggerTable_.label().empty()) {
303  if( !triggerTable.isValid() ) return;
304  }
305 
306  /*
307  ------------------------------------------------------------
308 
309  Primary Vertex Monitoring
310 
311  ------------------------------------------------------------
312  */
313  // fill monitoring plots for primary verices
314  if( !pvs.isValid() ) return;
315  unsigned int pvMult = 0;
316  for(edm::View<reco::Vertex>::const_iterator pv=pvs->begin(); pv!=pvs->end(); ++pv){
317  if(!pvSelect_ || (*pvSelect_)(*pv))
318  pvMult++;
319  }
320  fill("pvMult_", pvMult );
321 
322  /*
323  ------------------------------------------------------------
324 
325  Electron Monitoring
326 
327  ------------------------------------------------------------
328  */
329 
330  // check availability of electron id
331  if(!electronId_.label().empty()) {
332  if( !electronId.isValid() ) return;
333  }
334 
335  if( !elecs.isValid() ) return;
336 
337  // loop electron collection
338  unsigned int eMult=0, eMultIso=0;
339  std::vector<const reco::GsfElectron*> isoElecs;
341  for(edm::View<reco::GsfElectron>::const_iterator elec=elecs->begin(); elec!=elecs->end(); ++elec){
342  unsigned int idx = elec-elecs->begin();
343  // restrict to electrons with good electronId
344  if( electronId_.label().empty() ? true : ((int)(*electronId)[elecs->refAt(idx)] & eidPattern_) ){
345  if(!elecSelect_ || (*elecSelect_)(*elec)){
346  double isolationTrk = elec->pt()/(elec->pt()+elec->dr03TkSumPt());
347  double isolationCal = elec->pt()/(elec->pt()+elec->dr03EcalRecHitSumEt()+elec->dr03HcalTowerSumEt());
348  double isolationRel = (elec->dr03TkSumPt()+elec->dr03EcalRecHitSumEt()+elec->dr03HcalTowerSumEt())/elec->pt();
349  if( eMult==0 ){
350  // restrict to the leading electron
351  fill("elecPt_" , elec->pt() );
352  fill("elecEta_", elec->eta());
353  fill("elecRelIso_" , isolationRel );
354  fill("elecTrkIso_" , isolationTrk );
355  fill("elecCalIso_" , isolationCal );
356  }
357  // in addition to the multiplicity counter buffer the iso
358  // electron candidates for later overlap check with jets
359  ++eMult; if(!elecIso_ || (*elecIso_)(*elec)){ if(eMultIso == 0) e = *elec; isoElecs.push_back(&(*elec)); ++eMultIso;}
360  }
361  }
362  }
363  fill("elecMult_", eMult );
364  fill("elecMultIso_", eMultIso);
365 
366  /*
367  ------------------------------------------------------------
368 
369  Muon Monitoring
370 
371  ------------------------------------------------------------
372  */
373 
374  // fill monitoring plots for muons
375  unsigned int mMult=0, mMultIso=0;
376 
377  if( !muons.isValid() ) return;
378 
379  reco::Muon mu;
381  // restrict to globalMuons
382  if( muon->isGlobalMuon() ){
383  fill("muonDelZ_" , muon->globalTrack()->vz());
384  fill("muonDelXY_", muon->globalTrack()->vx(), muon->globalTrack()->vy());
385  // apply preselection
386  if(!muonSelect_ || (*muonSelect_)(*muon)){
387  double isolationTrk = muon->pt()/(muon->pt()+muon->isolationR03().sumPt);
388  double isolationCal = muon->pt()/(muon->pt()+muon->isolationR03().emEt+muon->isolationR03().hadEt);
389  double isolationRel = (muon->isolationR03().sumPt+muon->isolationR03().emEt+muon->isolationR03().hadEt)/muon->pt();
390  if( mMult==0 ){
391  // restrict to leading muon
392  fill("muonPt_" , muon->pt() );
393  fill("muonEta_" , muon->eta());
394  fill("muonRelIso_" , isolationRel );
395  fill("muonTrkIso_" , isolationTrk );
396  fill("muonCalIso_" , isolationCal );
397  }
398  ++mMult; if(!muonIso_ || (*muonIso_)(*muon)) {if(mMultIso == 0) mu = *muon; ++mMultIso;}
399  }
400  }
401  }
402  fill("muonMult_", mMult );
403  fill("muonMultIso_", mMultIso);
404 
405  /*
406  ------------------------------------------------------------
407 
408  Jet Monitoring
409 
410  ------------------------------------------------------------
411  */
412 
413  // check availability of the btaggers
414  if( includeBTag_ ){
415  if( !btagEff.isValid() ) return;
416  if( !btagPur.isValid() ) return;
417  if( !btagVtx.isValid() ) return;
418  }
419  // load jet corrector if configured such
420  const JetCorrector* corrector=0;
421  if(!jetCorrector_.empty()){
422  // check whether a jet correcto is in the event setup or not
423  if(setup.find( edm::eventsetup::EventSetupRecordKey::makeKey<JetCorrectionsRecord>() )){
424  corrector = JetCorrector::getJetCorrector(jetCorrector_, setup);
425  }
426  else{
427  edm::LogVerbatim( "TopHLTSingleLeptonDQM" )
428  << "\n"
429  << "------------------------------------------------------------------------------------- \n"
430  << " No JetCorrectionsRecord available from EventSetup: \n"
431  << " - Jets will not be corrected. \n"
432  << " - If you want to change this add the following lines to your cfg file: \n"
433  << " \n"
434  << " ## load jet corrections \n"
435  << " process.load(\"JetMETCorrections.Configuration.JetCorrectionServicesAllAlgos_cff\") \n"
436  << " process.prefer(\"ak5CaloL2L3\") \n"
437  << " \n"
438  << "------------------------------------------------------------------------------------- \n";
439  }
440  }
441 
442  // loop jet collection
443  std::vector<reco::Jet> correctedJets;
444  unsigned int mult=0, multBEff=0, multBPur=0, multBVtx=0;
445 
446  if( !jets.isValid() ) return;
447 
448  if(jetIDSelect_){
449  if( !jetID.isValid() ) return;
450  }
451 
452  reco::Jet bJetCand;
453  for(edm::View<reco::Jet>::const_iterator jet=jets->begin(); jet!=jets->end(); ++jet){
454  // check jetID for calo jets
455  unsigned int idx = jet-jets->begin();
456  if( jetIDSelect_ && dynamic_cast<const reco::CaloJet*>(jets->refAt(idx).get())){
457  if(!(*jetIDSelect_)((*jetID)[jets->refAt(idx)])) continue;
458  }
459  // chekc additional jet selection for calo, pf and bare reco jets
460  if(dynamic_cast<const reco::CaloJet*>(&*jet)){
461  reco::CaloJet sel = dynamic_cast<const reco::CaloJet&>(*jet); sel.scaleEnergy(corrector ? corrector->correction(*jet) : 1.);
462  StringCutObjectSelector<reco::CaloJet> jetSelect(jetSelect_); if(!jetSelect(sel)){ continue;}
463  }
464  else if(dynamic_cast<const reco::PFJet*>(&*jet)){
465  reco::PFJet sel= dynamic_cast<const reco::PFJet&>(*jet); sel.scaleEnergy(corrector ? corrector->correction(*jet) : 1.);
466  StringCutObjectSelector<reco::PFJet> jetSelect(jetSelect_); if(!jetSelect(sel)) continue;
467  }
468  else{
469  reco::Jet sel = *jet; sel.scaleEnergy(corrector ? corrector->correction(*jet) : 1.);
470  StringCutObjectSelector<reco::Jet> jetSelect(jetSelect_); if(!jetSelect(sel)) continue;
471  }
472  // check for overlaps -- comment this to be synchronous with the selection
473  //bool overlap=false;
474  //for(std::vector<const reco::GsfElectron*>::const_iterator elec=isoElecs.begin(); elec!=isoElecs.end(); ++elec){
475  // if(reco::deltaR((*elec)->eta(), (*elec)->phi(), jet->eta(), jet->phi())<0.4){overlap=true; break;}
476  //} if(overlap){continue;}
477 
478  // prepare jet to fill monitor histograms
479  reco::Jet monitorJet = *jet; monitorJet.scaleEnergy(corrector ? corrector->correction(*jet) : 1.);
480  correctedJets.push_back(monitorJet);
481  ++mult; // determine jet multiplicity
482  if( includeBTag_ ){
483  // fill b-discriminators
484  edm::RefToBase<reco::Jet> jetRef = jets->refAt(idx);
485  fill("jetBDiscEff_", (*btagEff)[jetRef]); if( (*btagEff)[jetRef]>btagEffWP_ ) ++multBEff;
486  fill("jetBDiscPur_", (*btagPur)[jetRef]); if( (*btagPur)[jetRef]>btagPurWP_ ) {if(multBPur == 0) bJetCand = *jet; ++multBPur;}
487  fill("jetBDiscVtx_", (*btagVtx)[jetRef]); if( (*btagVtx)[jetRef]>btagVtxWP_ ) ++multBVtx;
488  }
489  // fill pt (raw or L2L3) for the leading four jets
490  if(idx==0) {fill("jet1Pt_" , monitorJet.pt()); fill("jet1PtRaw_", jet->pt() ); fill("jet1Eta_" , monitorJet.eta());}
491  if(idx==1) {fill("jet2Pt_" , monitorJet.pt()); fill("jet2PtRaw_", jet->pt() ); fill("jet2Eta_" , monitorJet.eta());}
492  if(idx==2) {fill("jet3Pt_" , monitorJet.pt()); fill("jet3PtRaw_", jet->pt() ); fill("jet3Eta_" , monitorJet.eta());}
493  if(idx==3) {fill("jet4Pt_" , monitorJet.pt()); fill("jet4PtRaw_", jet->pt() ); fill("jet4Eta_" , monitorJet.eta());}
494  }
495  fill("jetMult_" , mult );
496  fill("jetMultBEff_", multBEff);
497  fill("jetMultBPur_", multBPur);
498  fill("jetMultBVtx_", multBVtx);
499 
500  /*
501  ------------------------------------------------------------
502 
503  MET Monitoring
504 
505  ------------------------------------------------------------
506  */
507 
508  // fill monitoring histograms for met
509  reco::MET mET;
510  for( int i=0; i<int(mets.size()); i++ ){
512  if( !met.isValid() ) continue;
513  if(met->begin()!=met->end()){
514  unsigned int idx=i;
515  if(idx==0) fill("metCalo_" , met->begin()->et());
516  if(idx==1) fill("metTC_" , met->begin()->et());
517  if(idx==2) fill("metPflow_", met->begin()->et());
518  mET = *(met->begin());
519  }
520  }
521 
522  /*
523  ------------------------------------------------------------
524 
525  Event Monitoring
526 
527  ------------------------------------------------------------
528  */
529 
530  // fill W boson and top mass estimates
531  CalculateHLT eventKinematics(MAXJETS, WMASS);
532  double wMass = eventKinematics.massWBoson (correctedJets);
533  double topMass = eventKinematics.massTopQuark(correctedJets);
534  if(wMass>=0 && topMass>=0) {fill("massW_" , wMass ); fill("massTop_" , topMass);}
535  // fill plots for trigger monitoring
536  if((lowerEdge_==-1. && upperEdge_==-1.) || (lowerEdge_<wMass && wMass<upperEdge_) ){
537  if(!triggerTable_.label().empty()) fill(event, *triggerTable, "trigger", triggerPaths_);
538  if(logged_<=hists_.find("eventLogger_")->second->getNbinsY()){
539  // log runnumber, lumi block, event number & some
540  // more pysics infomation for interesting events
541  fill("eventLogger_", 0.5, logged_+0.5, event.eventAuxiliary().run());
542  fill("eventLogger_", 1.5, logged_+0.5, event.eventAuxiliary().luminosityBlock());
543  fill("eventLogger_", 2.5, logged_+0.5, event.eventAuxiliary().event());
544  if(correctedJets.size()>0) fill("eventLogger_", 3.5, logged_+0.5, correctedJets[0].pt());
545  if(correctedJets.size()>1) fill("eventLogger_", 4.5, logged_+0.5, correctedJets[1].pt());
546  if(correctedJets.size()>2) fill("eventLogger_", 5.5, logged_+0.5, correctedJets[2].pt());
547  if(correctedJets.size()>3) fill("eventLogger_", 6.5, logged_+0.5, correctedJets[3].pt());
548  fill("eventLogger_", 7.5, logged_+0.5, wMass );
549  fill("eventLogger_", 8.5, logged_+0.5, topMass);
550  ++logged_;
551  }
552  }
553  if(multBPur != 0 && mMultIso == 1 ){
554  cout<<bJetCand.pt()<<"\t"<<mu.pt()<<"\t"<<mET.pt()<<endl;
555  double mtW = eventKinematics.tmassWBoson(&mu,mET,bJetCand); fill("MTWm_",mtW);
556  double Mlb = eventKinematics.masslb(&mu,mET,bJetCand); fill("mMub_", Mlb);
557  double MTT = eventKinematics.tmassTopQuark(&mu,mET,bJetCand); fill("mMTT_", MTT);
558  }
559 
560  if(multBPur != 0 && eMultIso == 1 ){
561  double mtW = eventKinematics.tmassWBoson(&mu,mET,bJetCand); fill("MTWe_",mtW);
562  double Mlb = eventKinematics.masslb(&mu,mET,bJetCand); fill("mEb_", Mlb);
563  double MTT = eventKinematics.tmassTopQuark(&mu,mET,bJetCand); fill("eMTT_", MTT);
564  }
565  }
566 
567 }
568 
569 
570 TopHLTSingleLeptonDQM::TopHLTSingleLeptonDQM(const edm::ParameterSet& cfg): triggerTable_(""), vertexSelect_(0), beamspot_(""), beamspotSelect_(0)
571 {
572  edm::ParameterSet sources=cfg.getParameter<edm::ParameterSet>("sources");
573  muonsToken_ = consumes< edm::View<reco::Muon> >(sources.getParameter<edm::InputTag>("muons"));
574  elecsToken_ = consumes< edm::View<reco::GsfElectron> >(sources.getParameter<edm::InputTag>("elecs"));
575  jetsToken_ = consumes< edm::View<reco::Jet> >(sources.getParameter<edm::InputTag>("jets" ));
576  pvsToken_ = consumes< edm::View<reco::Vertex> >(sources.getParameter<edm::InputTag>("pvs" ));
577 
578  metsTemp_ = sources.getParameter<std::vector<edm::InputTag> >("mets" );
579 
580  metsTokens_.resize( metsTemp_.size() );
581  for( int i=0; i<int(metsTemp_.size()); i++ ) metsTokens_[i] = consumes< edm::View<reco::MET> >(metsTemp_[i]);
582 
583  // configure preselection
584  edm::ParameterSet presel=cfg.getParameter<edm::ParameterSet>("preselection");
585  if( presel.existsAs<edm::ParameterSet>("trigger") ){
586  edm::ParameterSet trigger=presel.getParameter<edm::ParameterSet>("trigger");
587  triggerTable_=trigger.getParameter<edm::InputTag>("src");
588  triggerPaths_=trigger.getParameter<std::vector<std::string> >("select");
589  }
590  if( presel.existsAs<edm::ParameterSet>("vertex" ) ){
591  edm::ParameterSet vertex=presel.getParameter<edm::ParameterSet>("vertex");
592  vertex_= vertex.getParameter<edm::InputTag>("src");
593  vertexToken_= consumes< std::vector<reco::Vertex> >(vertex.getParameter<edm::InputTag>("src"));
595  }
596  if( presel.existsAs<edm::ParameterSet>("beamspot" ) ){
597  edm::ParameterSet beamspot=presel.getParameter<edm::ParameterSet>("beamspot");
598  beamspot_= beamspot.getParameter<edm::InputTag>("src");
599  beamspotToken_= consumes<reco::BeamSpot>(beamspot.getParameter<edm::InputTag>("src"));
601  }
602 
603  // elecExtras are optional; they may be omitted or empty
604  if( cfg.existsAs<edm::ParameterSet>("elecExtras") ){
605  edm::ParameterSet elecExtras=cfg.getParameter<edm::ParameterSet>("elecExtras");
606  // electronId is optional; in case it's not found the
607  // InputTag will remain empty
608  if( elecExtras.existsAs<edm::ParameterSet>("electronId") ){
609  edm::ParameterSet elecId=elecExtras.getParameter<edm::ParameterSet>("electronId");
610  electronIdToken_= consumes< edm::ValueMap<float> >(elecId.getParameter<edm::InputTag>("src"));
611  }
612  }
613 
614  // jetExtras are optional; they may be omitted or empty
615  if( cfg.existsAs<edm::ParameterSet>("jetExtras") ){
616  edm::ParameterSet jetExtras=cfg.getParameter<edm::ParameterSet>("jetExtras");
617  // read jetID information if it exists
618  if(jetExtras.existsAs<edm::ParameterSet>("jetID")){
620  jetIDToken_ = consumes<reco::JetIDValueMap>(jetID.getParameter<edm::InputTag>("label"));
621  }
622  }
623 
624  // conifgure the selection
625  std::vector<edm::ParameterSet> sel=cfg.getParameter<std::vector<edm::ParameterSet> >("selection");
626  for(unsigned int i=0; i<sel.size(); ++i){
627  selectionOrder_.push_back(sel.at(i).getParameter<std::string>("label"));
628  selection_[selectionStep(selectionOrder_.back())] = std::make_pair(sel.at(i), new TopHLTSingleLepton::MonitorEnsemble(selectionStep(selectionOrder_.back()).c_str(), cfg.getParameter<edm::ParameterSet>("setup")));
629  }
630 }
631 
632 void
634 {
635 
639 
641  event.getByToken(pvsToken_, pvs);
642 
644  event.getByToken(muonsToken_, muons);
645 
646  edm::Handle<edm::ValueMap<float> > electronId;
647  event.getByToken(electronIdToken_, electronId);
648 
650  event.getByToken(elecsToken_, elecs);
651 
653  event.getByToken(jetsToken_, jets);
654 
656  event.getByToken(jetIDToken_, jetID);
657 
658 
659  edm::Handle<reco::JetTagCollection> btagEff, btagPur, btagVtx;
660  event.getByToken(btagEffToken_, btagEff);
661  event.getByToken(btagPurToken_, btagPur);
662  event.getByToken(btagVtxToken_, btagVtx);
663 
664  std::vector< edm::Handle<edm::View<reco::MET> > > mets;
665  for( int i=0; i<int(metsTemp_.size()); i++ ) event.getByToken(metsTokens_[i],mets[i]);
666 
667 
668  if(!triggerTable_.label().empty()){
669  if( !event.getByToken(triggerTableToken_, triggerTable) ) return;
670  if(!acceptHLT(event, *triggerTable, triggerPaths_)) return;
671  }
672  if(!vertex_.label().empty()){
673  if( !event.getByToken(vertexToken_, vertex) ) return;
674  if(vertex->empty() || !(*vertexSelect_)(vertex->front())) return;
675  }
676  if(!beamspot_.label().empty()){
677  if( !event.getByToken(beamspotToken_, beamspot) ) return;
678  if(!(*beamspotSelect_)(*beamspot)) return;
679  }
680 
681 
682  // apply selection steps
683  unsigned int passed=0;
684  for(std::vector<std::string>::const_iterator selIt=selectionOrder_.begin(); selIt!=selectionOrder_.end(); ++selIt){
685  std::string key = selectionStep(*selIt), type = objectType(*selIt);
686  if(selection_.find(key)!=selection_.end()){
687  if(type=="empty"){
688  selection_[key].second->fill(event, setup, triggerTable, pvs, muons, electronId, elecs, jets, jetID, btagEff, btagPur, btagVtx, mets);
689  }
690  if(type=="Hlt" ){
691 // cout<<"HLT filled"<<endl;
692  selection_[key].second->fill(event, setup, triggerTable, pvs, muons, electronId, elecs, jets, jetID, btagEff, btagPur, btagVtx, mets);
693  }
694  if(type=="muons"){
695 // cout<<"Good Mu found"<<endl;
697  if(step.select(event)){ ++passed;
698  selection_[key].second->fill(event, setup, triggerTable, pvs, muons, electronId, elecs, jets, jetID, btagEff, btagPur, btagVtx, mets);
699  } else break;
700  }
701  if(type=="elecs"){
703  if(step.select(event)){ ++passed;
704  selection_[key].second->fill(event, setup, triggerTable, pvs, muons, electronId, elecs, jets, jetID, btagEff, btagPur, btagVtx, mets);
705  } else break;
706  }
707  if(type=="jets" ){
709  if(step.select(event, setup)){ ++passed;
710  selection_[key].second->fill(event, setup, triggerTable, pvs, muons, electronId, elecs, jets, jetID, btagEff, btagPur, btagVtx, mets);
711  } else break;
712  }
713  if(type=="jets/pf" ){
715  if(step.select(event, setup)){ ++passed;
716  selection_[key].second->fill(event, setup, triggerTable, pvs, muons, electronId, elecs, jets, jetID, btagEff, btagPur, btagVtx, mets);
717  } else break;
718  }
719  if(type=="jets/calo" ){
720 // cout<<"Jet found!"<<endl;
722  if(step.select(event, setup)){ ++passed;
723  selection_[key].second->fill(event, setup, triggerTable, pvs, muons, electronId, elecs, jets, jetID, btagEff, btagPur, btagVtx, mets);
724  } else break;
725  }
726  if(type=="met" ){
728  if(step.select(event)){ ++passed;
729  selection_[key].second->fill(event, setup, triggerTable, pvs, muons, electronId, elecs, jets, jetID, btagEff, btagPur, btagVtx, mets);
730  } else break;
731  }
732  }
733  }
734 }
735 
736 
std::map< std::string, std::pair< edm::ParameterSet, TopHLTSingleLepton::MonitorEnsemble * > > selection_
type
Definition: HCALResponse.h:21
T getParameter(std::string const &) const
edm::InputTag electronId_
electronId label
int i
Definition: DBlmapReader.cc:9
void book(std::string directory)
book histograms in subdirectory directory
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
tuple met
____________________________________________________________________________||
Definition: CaloMET_cfi.py:7
Level verbosity_
verbosity level for booking
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
bool acceptHLT(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
StringCutObjectSelector< reco::JetID > * jetIDSelect_
extra jetID selection on calo jets
double masslb(reco::RecoCandidate *mu, const reco::MET &met, const reco::Jet &b)
calculate mlb estimate
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:872
double massTopQuark(const std::vector< reco::Jet > &jets)
calculate top quark mass estimate
edm::InputTag elecs_
input sources for monitoring
std::vector< edm::InputTag > mets_
considers a vector of METs
edm::EDGetTokenT< reco::JetIDValueMap > jetIDToken_
int logged_
number of logged interesting events
edm::EDGetTokenT< edm::View< reco::GsfElectron > > elecsToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
void fill(const edm::Event &event, const edm::EventSetup &setup, edm::Handle< edm::TriggerResults > triggerTable, edm::Handle< edm::View< reco::Vertex > > pvs, edm::Handle< edm::View< reco::Muon > > muons, edm::Handle< edm::ValueMap< float > > electronId, edm::Handle< edm::View< reco::GsfElectron > > elecs, edm::Handle< edm::View< reco::Jet > > jets, edm::Handle< reco::JetIDValueMap > jetID, edm::Handle< reco::JetTagCollection > btagEff, edm::Handle< reco::JetTagCollection > btagPur, edm::Handle< reco::JetTagCollection > btagVtx, std::vector< edm::Handle< edm::View< reco::MET > > > mets)
fill monitor histograms with electronId and jetCorrections
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
edm::EDGetTokenT< edm::View< reco::Vertex > > pvsToken_
RunNumber_t run() const
edm::EDGetTokenT< std::vector< reco::Vertex > > vertexToken_
edm::EDGetTokenT< reco::JetTagCollection > btagPurToken_
double massWBoson(const std::vector< reco::Jet > &jets)
calculate W boson mass estimate
virtual void scaleEnergy(double fScale)
scale energy of the jet
Definition: Jet.cc:444
edm::InputTag vertex_
primary vertex
StringCutObjectSelector< reco::GsfElectron > * elecSelect_
extra selection on electrons
double lowerEdge_
mass window upper and lower edge
void triggerBinLabels(std::string channel, const std::vector< std::string > &labels)
set configurable labels for trigger monitoring histograms
edm::EDGetTokenT< reco::JetTagCollection > btagEffToken_
Jets made from PFObjects.
Definition: PFJet.h:21
edm::InputTag btagEff_
btag discriminator labels
#define MAXJETS
Definition: myFastSimVal.cc:30
LuminosityBlockNumber_t luminosityBlock() const
const eventsetup::EventSetupRecord * find(const eventsetup::EventSetupRecordKey &) const
Definition: EventSetup.cc:90
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::map< std::string, MonitorElement * > hists_
histogram container
edm::InputTag triggerTable_
trigger table
StringCutObjectSelector< reco::GsfElectron > * elecIso_
extra isolation criterion on electron
std::vector< std::string > triggerPaths_
trigger paths
StringCutObjectSelector< reco::BeamSpot > * beamspotSelect_
string cut selector
edm::InputTag beamspot_
beamspot
Definition: MET.h:32
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
vector< PseudoJet > jets
StringCutObjectSelector< reco::Muon > * muonIso_
extra isolation criterion on muon
edm::EDGetTokenT< edm::TriggerResults > triggerTableToken_
edm::EDGetTokenT< edm::View< reco::Muon > > muonsToken_
static const unsigned int MAXJETS
const int mu
Definition: Constants.h:22
edm::InputTag jetIDLabel_
jetID as an extra selection type
std::vector< std::string > triggerPaths_
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
bool first
Definition: L1TdeRCT.cc:79
bool isValid() const
Definition: HandleBase.h:76
StringCutObjectSelector< reco::Vertex > * pvSelect_
extra selection on primary vertices; meant to investigate the pile-up effect
bool select(const edm::Event &event)
apply selection
double tmassWBoson(reco::RecoCandidate *mu, const reco::MET &met, const reco::Jet &b)
calculate W boson transverse mass estimate
virtual float eta() const GCC11_FINAL
momentum pseudorapidity
std::vector< std::string > selectionOrder_
edm::EDGetTokenT< reco::JetTagCollection > btagVtxToken_
EventAuxiliary const & eventAuxiliary() const
Definition: Event.h:72
edm::EDGetTokenT< edm::View< reco::Jet > > jetsToken_
std::vector< edm::EDGetTokenT< edm::View< reco::MET > > > metsTokens_
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
edm::EDGetTokenT< reco::BeamSpot > beamspotToken_
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
std::string const & label() const
Definition: InputTag.h:42
TopHLTSingleLeptonDQM(const edm::ParameterSet &cfg)
default constructor
std::string selectionStep(const std::string &label)
list key
Definition: combine.py:13
tuple muons
Definition: patZpeak.py:38
edm::InputTag triggerTable_
trigger table
static const double WMASS
StringCutObjectSelector< reco::Vertex > * vertexSelect_
string cut selector
virtual void analyze(const edm::Event &event, const edm::EventSetup &setup)
do this during the event loop
edm::EDGetTokenT< edm::ValueMap< float > > electronIdToken_
tuple cout
Definition: gather_cfg.py:121
volatile std::atomic< bool > shutdown_flag false
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:1000
virtual float pt() const GCC11_FINAL
transverse momentum
std::string objectType(const std::string &label)
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
StringCutObjectSelector< reco::Muon > * muonSelect_
extra selection on muons
EventNumber_t event() const
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:584
std::vector< edm::InputTag > metsTemp_