CMS 3D CMS Logo

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