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>
8 using namespace std;
9 namespace TopSingleLepton {
10 
11  // maximal number of leading jets
12  // to be used for top mass estimate
13  static const unsigned int MAXJETS = 4;
14  // nominal mass of the W boson to
15  // be used for the top mass estimate
16  static const double WMASS = 80.4;
17 
18  MonitorEnsemble::MonitorEnsemble(const char* label, const edm::ParameterSet& cfg) :
19  label_(label), elecIso_(0), elecSelect_(0), pvSelect_(0), muonIso_(0), muonSelect_(0), jetIDSelect_(0), includeBTag_(false), lowerEdge_(-1.), upperEdge_(-1.), logged_(0)
20  {
21  // sources have to be given; this PSet is not optional
22  edm::ParameterSet sources=cfg.getParameter<edm::ParameterSet>("sources");
23  muons_= sources.getParameter<edm::InputTag>("muons");
24  elecs_= sources.getParameter<edm::InputTag>("elecs");
25  jets_ = sources.getParameter<edm::InputTag>("jets" );
26  mets_ = sources.getParameter<std::vector<edm::InputTag> >("mets" );
27  pvs_ = sources.getParameter<edm::InputTag>("pvs" );
28  // electronExtras are optional; they may be omitted or
29  // empty
30  if( cfg.existsAs<edm::ParameterSet>("elecExtras") ){
31  edm::ParameterSet elecExtras=cfg.getParameter<edm::ParameterSet>("elecExtras");
32  // select is optional; in case it's not found no
33  // selection will be applied
34  if( elecExtras.existsAs<std::string>("select") ){
36  }
37  // isolation is optional; in case it's not found no
38  // isolation will be applied
39  if( elecExtras.existsAs<std::string>("isolation") ){
41  }
42  // electronId is optional; in case it's not found the
43  // InputTag will remain empty
44  if( elecExtras.existsAs<edm::ParameterSet>("electronId") ){
45  edm::ParameterSet elecId=elecExtras.getParameter<edm::ParameterSet>("electronId");
46  electronId_= elecId.getParameter<edm::InputTag>("src");
47  eidPattern_= elecId.getParameter<int>("pattern");
48  }
49  }
50  // pvExtras are opetional; they may be omitted or empty
51  if(cfg.existsAs<edm::ParameterSet>("pvExtras")){
52  edm::ParameterSet pvExtras=cfg.getParameter<edm::ParameterSet>("pvExtras");
53  // select is optional; in case it's not found no
54  // selection will be applied
55  if( pvExtras.existsAs<std::string>("select") ){
57  }
58  }
59  // muonExtras are optional; they may be omitted or empty
60  if( cfg.existsAs<edm::ParameterSet>("muonExtras") ){
61  edm::ParameterSet muonExtras=cfg.getParameter<edm::ParameterSet>("muonExtras");
62  // select is optional; in case it's not found no
63  // selection will be applied
64  if( muonExtras.existsAs<std::string>("select") ){
66  }
67  // isolation is optional; in case it's not found no
68  // isolation will be applied
69  if( muonExtras.existsAs<std::string>("isolation") ){
71  }
72  }
73 
74  // jetExtras are optional; they may be omitted or
75  // empty
76  if( cfg.existsAs<edm::ParameterSet>("jetExtras") ){
77  edm::ParameterSet jetExtras=cfg.getParameter<edm::ParameterSet>("jetExtras");
78  // jetCorrector is optional; in case it's not found
79  // the InputTag will remain empty
80  if( jetExtras.existsAs<std::string>("jetCorrector") ){
81  jetCorrector_= jetExtras.getParameter<std::string>("jetCorrector");
82  }
83  // read jetID information if it exists
84  if(jetExtras.existsAs<edm::ParameterSet>("jetID")){
86  jetIDLabel_ =jetID.getParameter<edm::InputTag>("label");
88  }
89  // select is optional; in case it's not found no
90  // selection will be applied (only implemented for
91  // CaloJets at the moment)
92  if( jetExtras.existsAs<std::string>("select") ){
93  jetSelect_= jetExtras.getParameter<std::string>("select");
94  }
95  // jetBDiscriminators are optional; in case they are
96  // not found the InputTag will remain empty; they
97  // consist of pairs of edm::JetFlavorAssociation's &
98  // corresponding working points
99  includeBTag_=jetExtras.existsAs<edm::ParameterSet>("jetBTaggers");
100  if( includeBTag_ ){
101  edm::ParameterSet btagEff=jetExtras.getParameter<edm::ParameterSet>("jetBTaggers").getParameter<edm::ParameterSet>("trackCountingEff");
102  btagEff_= btagEff.getParameter<edm::InputTag>("label"); btagEffWP_= btagEff.getParameter<double>("workingPoint");
103  edm::ParameterSet btagPur=jetExtras.getParameter<edm::ParameterSet>("jetBTaggers").getParameter<edm::ParameterSet>("trackCountingPur");
104  btagPur_= btagPur.getParameter<edm::InputTag>("label"); btagPurWP_= btagPur.getParameter<double>("workingPoint");
105  edm::ParameterSet btagVtx=jetExtras.getParameter<edm::ParameterSet>("jetBTaggers").getParameter<edm::ParameterSet>("secondaryVertex" );
106  btagVtx_= btagVtx.getParameter<edm::InputTag>("label"); btagVtxWP_= btagVtx.getParameter<double>("workingPoint");
107  }
108  }
109 
110  // triggerExtras are optional; they may be omitted or empty
111  if( cfg.existsAs<edm::ParameterSet>("triggerExtras") ){
112  edm::ParameterSet triggerExtras=cfg.getParameter<edm::ParameterSet>("triggerExtras");
113  triggerTable_=triggerExtras.getParameter<edm::InputTag>("src");
114  triggerPaths_=triggerExtras.getParameter<std::vector<std::string> >("paths");
115  }
116 
117  // massExtras is optional; in case it's not found no mass
118  // window cuts are applied for the same flavor monitor
119  // histograms
120  if( cfg.existsAs<edm::ParameterSet>("massExtras") ){
121  edm::ParameterSet massExtras=cfg.getParameter<edm::ParameterSet>("massExtras");
122  lowerEdge_= massExtras.getParameter<double>("lowerEdge");
123  upperEdge_= massExtras.getParameter<double>("upperEdge");
124  }
125 
126  // setup the verbosity level for booking histograms;
127  // per default the verbosity level will be set to
128  // STANDARD. This will also be the chosen level in
129  // the case when the monitoring PSet is not found
131  if( cfg.existsAs<edm::ParameterSet>("monitoring") ){
132  edm::ParameterSet monitoring=cfg.getParameter<edm::ParameterSet>("monitoring");
133  if(monitoring.getParameter<std::string>("verbosity") == "DEBUG" )
134  verbosity_= DEBUG;
135  if(monitoring.getParameter<std::string>("verbosity") == "VERBOSE" )
137  if(monitoring.getParameter<std::string>("verbosity") == "STANDARD")
139  }
140  // and don't forget to do the histogram booking
141  book(cfg.getParameter<std::string>("directory"));
142  }
143 
144  void
146  {
147  //set up the current directory path
148  std::string current(directory); current+=label_;
150  store_->setCurrentFolder(current);
151 
152  // determine number of bins for trigger monitoring
153  unsigned int nPaths=triggerPaths_.size();
154 
155  // --- [STANDARD] --- //
156  // number of selected primary vertices
157  hists_["pvMult_" ] = store_->book1D("PvMult" , "N_{pvs}" , 100, 0., 100.);
158  // pt of the leading muon
159  hists_["muonPt_" ] = store_->book1D("MuonPt" , "pt(#mu)" , 50, 0., 250.);
160  // muon multiplicity before std isolation
161  hists_["muonMult_" ] = store_->book1D("MuonMult" , "N_{All}(#mu)" , 10, 0., 10.);
162  // muon multiplicity after std isolation
163  hists_["muonMultIso_"] = store_->book1D("MuonMultIso", "N_{Iso}(#mu)" , 10, 0., 10.);
164  // pt of the leading electron
165  hists_["elecPt_" ] = store_->book1D("ElecPt" , "pt(e)" , 50, 0., 250.);
166  // electron multiplicity before std isolation
167  hists_["elecMult_" ] = store_->book1D("ElecMult" , "N_{All}(e)" , 10, 0., 10.);
168  // electron multiplicity after std isolation
169  hists_["elecMultIso_"] = store_->book1D("ElecMultIso", "N_{Iso}(e)" , 10, 0., 10.);
170  // multiplicity of jets with pt>20 (corrected to L2+L3)
171  hists_["jetMult_" ] = store_->book1D("JetMult" , "N_{30}(jet)" , 10, 0., 10.);
172  // trigger efficiency estimates for single lepton triggers
173  hists_["triggerEff_" ] = store_->book1D("TriggerEff" , "Eff(trigger)" , nPaths, 0., nPaths);
174  // monitored trigger occupancy for single lepton triggers
175  hists_["triggerMon_" ] = store_->book1D("TriggerMon" , "Mon(trigger)" , nPaths, 0., nPaths);
176  // MET (calo)
177  hists_["metCalo_" ] = store_->book1D("METCalo" , "MET_{Calo}" , 50, 0., 200.);
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 
183  // set bin labels for trigger monitoring
185 
186  if( verbosity_==STANDARD) return;
187 
188  // --- [VERBOSE] --- //
189  // eta of the leading muon
190  hists_["muonEta_" ] = store_->book1D("MuonEta" , "#eta(#mu)" , 30, -3., 3.);
191  // std isolation variable of the leading muon
192  hists_["muonRelIso_" ] = store_->book1D("MuonRelIso" , "Iso_{Rel}(#mu)" , 50, 0., 1.);
193  // eta of the leading electron
194  hists_["elecEta_" ] = store_->book1D("ElecEta" , "#eta(e)" , 30, -3., 3.);
195  // std isolation variable of the leading electron
196  hists_["elecRelIso_" ] = store_->book1D("ElecRelIso" , "Iso_{Rel}(e)" , 50, 0., 1.);
197  // multiplicity of btagged jets (for track counting high efficiency) with pt(L2L3)>30
198  hists_["jetMultBEff_"] = store_->book1D("JetMultBEff", "N_{30}(b/eff)" , 10, 0., 10.);
199  // btag discriminator for track counting high efficiency for jets with pt(L2L3)>30
200  hists_["jetBDiscEff_"] = store_->book1D("JetBDiscEff", "Disc_{b/eff}(jet)", 100, 0., 10.);
201  // pt of the 1. leading jet (corrected to L2+L3)
202  hists_["jet1Pt_" ] = store_->book1D("Jet1Pt" , "pt_{L2L3}(jet1)" , 60, 0., 300.);
203  // pt of the 2. leading jet (corrected to L2+L3)
204  hists_["jet2Pt_" ] = store_->book1D("Jet2Pt" , "pt_{L2L3}(jet2)" , 60, 0., 300.);
205  // pt of the 3. leading jet (corrected to L2+L3)
206  hists_["jet3Pt_" ] = store_->book1D("Jet3Pt" , "pt_{L2L3}(jet3)" , 60, 0., 300.);
207  // pt of the 4. leading jet (corrected to L2+L3)
208  hists_["jet4Pt_" ] = store_->book1D("Jet4Pt" , "pt_{L2L3}(jet4)" , 60, 0., 300.);
209  // MET (tc)
210  hists_["metTC_" ] = store_->book1D("METTC" , "MET_{TC}" , 50, 0., 200.);
211  // MET (pflow)
212  hists_["metPflow_" ] = store_->book1D("METPflow" , "MET_{Pflow}" , 50, 0., 200.);
213  // dz for muons (to suppress cosmis)
214  hists_["muonDelZ_" ] = store_->book1D("MuonDelZ" , "d_{z}(#mu)" , 50, -25., 25.);
215  // dxy for muons (to suppress cosmics)
216  hists_["muonDelXY_" ] = store_->book2D("MuonDelXY" , "d_{xy}(#mu)" , 50, -0.1, 0.1, 50, -0.1, 0.1);
217 
218  // set axes titles for dxy for muons
219  hists_["muonDelXY_" ]->setAxisTitle( "x [cm]", 1); hists_["muonDelXY_" ]->setAxisTitle( "y [cm]", 2);
220 
221  if( verbosity_==VERBOSE) return;
222 
223  // --- [DEBUG] --- //
224  // relative muon isolation in tracker for the leading muon
225  hists_["muonTrkIso_" ] = store_->book1D("MuonTrkIso" , "Iso_{Trk}(#mu)" , 50, 0., 1.);
226  // relative muon isolation in ecal+hcal for the leading muon
227  hists_["muonCalIso_" ] = store_->book1D("MuonCalIso" , "Iso_{Ecal}(#mu)" , 50, 0., 1.);
228  // relative electron isolation in tracker for the leading electron
229  hists_["elecTrkIso_" ] = store_->book1D("ElecTrkIso" , "Iso_{Trk}(e)" , 50, 0., 1.);
230  // relative electron isolation in ecal+hcal for the leading electron
231  hists_["elecCalIso_" ] = store_->book1D("ElecCalIso" , "Iso_{Ecal}(e)" , 50, 0., 1.);
232  // multiplicity of btagged jets (for track counting high purity) with pt(L2L3)>30
233  hists_["jetMultBPur_"] = store_->book1D("JetMultBPur", "N_{30}(b/pur)" , 10, 0., 10.);
234  // btag discriminator for track counting high purity
235  hists_["jetBDiscPur_"] = store_->book1D("JetBDiscPur", "Disc_{b/pur}(Jet)", 100, 0., 10.);
236  // multiplicity of btagged jets (for simple secondary vertex) with pt(L2L3)>30
237  hists_["jetMultBVtx_"] = store_->book1D("JetMultBVtx", "N_{30}(b/vtx)" , 10, 0., 10.);
238  // btag discriminator for simple secondary vertex
239  hists_["jetBDiscVtx_"] = store_->book1D("JetBDiscVtx", "Disc_{b/vtx}(Jet)", 35, -1., 6.);
240  // pt of the 1. leading jet (uncorrected)
241  hists_["jet1PtRaw_" ] = store_->book1D("Jet1PtRaw" , "pt_{Raw}(jet1)" , 60, 0., 300.);
242  // pt of the 2. leading jet (uncorrected)
243  hists_["jet2PtRaw_" ] = store_->book1D("Jet2PtRaw" , "pt_{Raw}(jet2)" , 60, 0., 300.);
244  // pt of the 3. leading jet (uncorrected)
245  hists_["jet3PtRaw_" ] = store_->book1D("Jet3PtRaw" , "pt_{Raw}(jet3)" , 60, 0., 300.);
246  // pt of the 4. leading jet (uncorrected)
247  hists_["jet4PtRaw_" ] = store_->book1D("Jet4PtRaw" , "pt_{Raw}(jet4)" , 60, 0., 300.);
248  // selected events
249  hists_["eventLogger_"] = store_->book2D("EventLogger", "Logged Events" , 9, 0., 9., 10, 0., 10.);
250 
251  // set axes titles for selected events
252  hists_["eventLogger_"]->getTH1()->SetOption("TEXT");
253  hists_["eventLogger_"]->setBinLabel( 1 , "Run" , 1);
254  hists_["eventLogger_"]->setBinLabel( 2 , "Block" , 1);
255  hists_["eventLogger_"]->setBinLabel( 3 , "Event" , 1);
256  hists_["eventLogger_"]->setBinLabel( 4 , "pt_{L2L3}(jet1)" , 1);
257  hists_["eventLogger_"]->setBinLabel( 5 , "pt_{L2L3}(jet2)" , 1);
258  hists_["eventLogger_"]->setBinLabel( 6 , "pt_{L2L3}(jet3)" , 1);
259  hists_["eventLogger_"]->setBinLabel( 7 , "pt_{L2L3}(jet4)" , 1);
260  hists_["eventLogger_"]->setBinLabel( 8 , "M_{W}" , 1);
261  hists_["eventLogger_"]->setBinLabel( 9 , "M_{Top}" , 1);
262  hists_["eventLogger_"]->setAxisTitle("logged evts" , 2);
263  return;
264  }
265 
266  void
268  {
269  // fetch trigger event if configured such
271  if(!triggerTable_.label().empty()) {
272  if( !event.getByLabel(triggerTable_, triggerTable) ) return;
273  }
274 
275  /*
276  ------------------------------------------------------------
277 
278  Primary Vertex Monitoring
279 
280  ------------------------------------------------------------
281  */
282  // fill monitoring plots for primary verices
284  if( !event.getByLabel(pvs_, pvs) ) return;
285  unsigned int pvMult = 0;
286  for(edm::View<reco::Vertex>::const_iterator pv=pvs->begin(); pv!=pvs->end(); ++pv){
287  if(!pvSelect_ || (*pvSelect_)(*pv))
288  pvMult++;
289  }
290  fill("pvMult_", pvMult );
291 
292  /*
293  ------------------------------------------------------------
294 
295  Electron Monitoring
296 
297  ------------------------------------------------------------
298  */
299 
300  // fill monitoring plots for electrons
302  if( !event.getByLabel(elecs_, elecs) ) return;
303 
304  // check availability of electron id
305  edm::Handle<edm::ValueMap<float> > electronId;
306  if(!electronId_.label().empty()) {
307  if( !event.getByLabel(electronId_, electronId) ) return;
308  }
309 
310  // loop electron collection
311  unsigned int eMult=0, eMultIso=0;
312  std::vector<const reco::GsfElectron*> isoElecs;
313  for(edm::View<reco::GsfElectron>::const_iterator elec=elecs->begin(); elec!=elecs->end(); ++elec){
314  unsigned int idx = elec-elecs->begin();
315  // restrict to electrons with good electronId
316  if( electronId_.label().empty() ? true : ((int)(*electronId)[elecs->refAt(idx)] & eidPattern_) ){
317  if(!elecSelect_ || (*elecSelect_)(*elec)){
318  double isolationTrk = elec->pt()/(elec->pt()+elec->dr03TkSumPt());
319  double isolationCal = elec->pt()/(elec->pt()+elec->dr03EcalRecHitSumEt()+elec->dr03HcalTowerSumEt());
320  double isolationRel = (elec->dr03TkSumPt()+elec->dr03EcalRecHitSumEt()+elec->dr03HcalTowerSumEt())/elec->pt();
321  if( eMult==0 ){
322  // restrict to the leading electron
323  fill("elecPt_" , elec->pt() );
324  fill("elecEta_", elec->eta());
325  fill("elecRelIso_" , isolationRel );
326  fill("elecTrkIso_" , isolationTrk );
327  fill("elecCalIso_" , isolationCal );
328  }
329  // in addition to the multiplicity counter buffer the iso
330  // electron candidates for later overlap check with jets
331  ++eMult; if(!elecIso_ || (*elecIso_)(*elec)){ isoElecs.push_back(&(*elec)); ++eMultIso;}
332  }
333  }
334  }
335  fill("elecMult_", eMult );
336  fill("elecMultIso_", eMultIso);
337 
338  /*
339  ------------------------------------------------------------
340 
341  Muon Monitoring
342 
343  ------------------------------------------------------------
344  */
345 
346  // fill monitoring plots for muons
347  unsigned int mMult=0, mMultIso=0;
348 
350  if( !event.getByLabel(muons_, muons) ) return;
351 
352  for(edm::View<reco::Muon>::const_iterator muon=muons->begin(); muon!=muons->end(); ++muon){
353  // restrict to globalMuons
354  if( muon->isGlobalMuon() ){
355  fill("muonDelZ_" , muon->globalTrack()->vz());
356  fill("muonDelXY_", muon->globalTrack()->vx(), muon->globalTrack()->vy());
357  // apply preselection
358  if(!muonSelect_ || (*muonSelect_)(*muon)){
359  double isolationTrk = muon->pt()/(muon->pt()+muon->isolationR03().sumPt);
360  double isolationCal = muon->pt()/(muon->pt()+muon->isolationR03().emEt+muon->isolationR03().hadEt);
361  double isolationRel = (muon->isolationR03().sumPt+muon->isolationR03().emEt+muon->isolationR03().hadEt)/muon->pt();
362  if( mMult==0 ){
363  // restrict to leading muon
364  fill("muonPt_" , muon->pt() );
365  fill("muonEta_" , muon->eta());
366  fill("muonRelIso_" , isolationRel );
367  fill("muonTrkIso_" , isolationTrk );
368  fill("muonCalIso_" , isolationCal );
369  }
370  ++mMult; if(!muonIso_ || (*muonIso_)(*muon)) ++mMultIso;
371  }
372  }
373  }
374  fill("muonMult_", mMult );
375  fill("muonMultIso_", mMultIso);
376 
377  /*
378  ------------------------------------------------------------
379 
380  Jet Monitoring
381 
382  ------------------------------------------------------------
383  */
384 
385  // check availability of the btaggers
386  edm::Handle<reco::JetTagCollection> btagEff, btagPur, btagVtx;
387  if( includeBTag_ ){
388  if( !event.getByLabel(btagEff_, btagEff) ) return;
389  if( !event.getByLabel(btagPur_, btagPur) ) return;
390  if( !event.getByLabel(btagVtx_, btagVtx) ) return;
391  }
392  // load jet corrector if configured such
393  const JetCorrector* corrector=0;
394  if(!jetCorrector_.empty()){
395  // check whether a jet correcto is in the event setup or not
396  if(setup.find( edm::eventsetup::EventSetupRecordKey::makeKey<JetCorrectionsRecord>() )){
397  corrector = JetCorrector::getJetCorrector(jetCorrector_, setup);
398  }
399  else{
400  edm::LogVerbatim( "TopSingleLeptonDQM" )
401  << "\n"
402  << "------------------------------------------------------------------------------------- \n"
403  << " No JetCorrectionsRecord available from EventSetup: \n"
404  << " - Jets will not be corrected. \n"
405  << " - If you want to change this add the following lines to your cfg file: \n"
406  << " \n"
407  << " ## load jet corrections \n"
408  << " process.load(\"JetMETCorrections.Configuration.JetCorrectionServicesAllAlgos_cff\") \n"
409  << " process.prefer(\"ak5CaloL2L3\") \n"
410  << " \n"
411  << "------------------------------------------------------------------------------------- \n";
412  }
413  }
414 
415  // loop jet collection
416  std::vector<reco::Jet> correctedJets;
417  unsigned int mult=0, multBEff=0, multBPur=0, multBVtx=0;
418 
420  if( !event.getByLabel(jets_, jets) ) return;
421 
423  if(jetIDSelect_){
424  if( !event.getByLabel(jetIDLabel_, jetID) ) return;
425  }
426 
427  for(edm::View<reco::Jet>::const_iterator jet=jets->begin(); jet!=jets->end(); ++jet){
428  // check jetID for calo jets
429  unsigned int idx = jet-jets->begin();
430  if( jetIDSelect_ && dynamic_cast<const reco::CaloJet*>(jets->refAt(idx).get())){
431  if(!(*jetIDSelect_)((*jetID)[jets->refAt(idx)])) continue;
432  }
433  // chekc additional jet selection for calo, pf and bare reco jets
434  if(dynamic_cast<const reco::CaloJet*>(&*jet)){
435  reco::CaloJet sel = dynamic_cast<const reco::CaloJet&>(*jet); sel.scaleEnergy(corrector ? corrector->correction(*jet) : 1.);
436  StringCutObjectSelector<reco::CaloJet> jetSelect(jetSelect_); if(!jetSelect(sel)){ continue;}
437  }
438  else if(dynamic_cast<const reco::PFJet*>(&*jet)){
439  reco::PFJet sel= dynamic_cast<const reco::PFJet&>(*jet); sel.scaleEnergy(corrector ? corrector->correction(*jet) : 1.);
440  StringCutObjectSelector<reco::PFJet> jetSelect(jetSelect_); if(!jetSelect(sel)) continue;
441  }
442  else{
443  reco::Jet sel = *jet; sel.scaleEnergy(corrector ? corrector->correction(*jet) : 1.);
444  StringCutObjectSelector<reco::Jet> jetSelect(jetSelect_); if(!jetSelect(sel)) continue;
445  }
446  // check for overlaps -- comment this to be synchronous with the selection
447  //bool overlap=false;
448  //for(std::vector<const reco::GsfElectron*>::const_iterator elec=isoElecs.begin(); elec!=isoElecs.end(); ++elec){
449  // if(reco::deltaR((*elec)->eta(), (*elec)->phi(), jet->eta(), jet->phi())<0.4){overlap=true; break;}
450  //} if(overlap){continue;}
451 
452  // prepare jet to fill monitor histograms
453  reco::Jet monitorJet = *jet; monitorJet.scaleEnergy(corrector ? corrector->correction(*jet) : 1.);
454  correctedJets.push_back(monitorJet);
455  ++mult; // determine jet multiplicity
456  if( includeBTag_ ){
457  // fill b-discriminators
458  edm::RefToBase<reco::Jet> jetRef = jets->refAt(idx);
459  fill("jetBDiscEff_", (*btagEff)[jetRef]); if( (*btagEff)[jetRef]>btagEffWP_ ) ++multBEff;
460  fill("jetBDiscPur_", (*btagPur)[jetRef]); if( (*btagPur)[jetRef]>btagPurWP_ ) ++multBPur;
461  fill("jetBDiscVtx_", (*btagVtx)[jetRef]); if( (*btagVtx)[jetRef]>btagVtxWP_ ) ++multBVtx;
462  }
463  // fill pt (raw or L2L3) for the leading four jets
464  if(idx==0) {fill("jet1Pt_" , monitorJet.pt()); fill("jet1PtRaw_", jet->pt() );}
465  if(idx==1) {fill("jet2Pt_" , monitorJet.pt()); fill("jet2PtRaw_", jet->pt() );}
466  if(idx==2) {fill("jet3Pt_" , monitorJet.pt()); fill("jet3PtRaw_", jet->pt() );}
467  if(idx==3) {fill("jet4Pt_" , monitorJet.pt()); fill("jet4PtRaw_", jet->pt() );}
468  }
469  fill("jetMult_" , mult );
470  fill("jetMultBEff_", multBEff);
471  fill("jetMultBPur_", multBPur);
472  fill("jetMultBVtx_", multBVtx);
473 
474  /*
475  ------------------------------------------------------------
476 
477  MET Monitoring
478 
479  ------------------------------------------------------------
480  */
481 
482  // fill monitoring histograms for met
483  for(std::vector<edm::InputTag>::const_iterator met_=mets_.begin(); met_!=mets_.end(); ++met_){
485  if( !event.getByLabel(*met_, met) ) continue;
486  if(met->begin()!=met->end()){
487  unsigned int idx=met_-mets_.begin();
488  if(idx==0) fill("metCalo_" , met->begin()->et());
489  if(idx==1) fill("metTC_" , met->begin()->et());
490  if(idx==2) fill("metPflow_", met->begin()->et());
491  }
492  }
493 
494  /*
495  ------------------------------------------------------------
496 
497  Event Monitoring
498 
499  ------------------------------------------------------------
500  */
501 
502  // fill W boson and top mass estimates
503  Calculate eventKinematics(MAXJETS, WMASS);
504  double wMass = eventKinematics.massWBoson (correctedJets);
505  double topMass = eventKinematics.massTopQuark(correctedJets);
506  if(wMass>=0 && topMass>=0) {fill("massW_" , wMass ); fill("massTop_" , topMass);}
507  // fill plots for trigger monitoring
508  if((lowerEdge_==-1. && upperEdge_==-1.) || (lowerEdge_<wMass && wMass<upperEdge_) ){
509  if(!triggerTable_.label().empty()) fill(event, *triggerTable, "trigger", triggerPaths_);
510  if(logged_<=hists_.find("eventLogger_")->second->getNbinsY()){
511  // log runnumber, lumi block, event number & some
512  // more pysics infomation for interesting events
513  fill("eventLogger_", 0.5, logged_+0.5, event.eventAuxiliary().run());
514  fill("eventLogger_", 1.5, logged_+0.5, event.eventAuxiliary().luminosityBlock());
515  fill("eventLogger_", 2.5, logged_+0.5, event.eventAuxiliary().event());
516  if(correctedJets.size()>0) fill("eventLogger_", 3.5, logged_+0.5, correctedJets[0].pt());
517  if(correctedJets.size()>1) fill("eventLogger_", 4.5, logged_+0.5, correctedJets[1].pt());
518  if(correctedJets.size()>2) fill("eventLogger_", 5.5, logged_+0.5, correctedJets[2].pt());
519  if(correctedJets.size()>3) fill("eventLogger_", 6.5, logged_+0.5, correctedJets[3].pt());
520  fill("eventLogger_", 7.5, logged_+0.5, wMass );
521  fill("eventLogger_", 8.5, logged_+0.5, topMass);
522  ++logged_;
523  }
524  }
525  }
526 
527 }
528 
529 
530 TopSingleLeptonDQM::TopSingleLeptonDQM(const edm::ParameterSet& cfg): triggerTable_(""), vertexSelect_(0), beamspot_(""), beamspotSelect_(0)
531 {
532  // configure preselection
533  edm::ParameterSet presel=cfg.getParameter<edm::ParameterSet>("preselection");
534  if( presel.existsAs<edm::ParameterSet>("trigger") ){
535  edm::ParameterSet trigger=presel.getParameter<edm::ParameterSet>("trigger");
536  triggerTable_=trigger.getParameter<edm::InputTag>("src");
537  triggerPaths_=trigger.getParameter<std::vector<std::string> >("select");
538  }
539  if( presel.existsAs<edm::ParameterSet>("vertex" ) ){
540  edm::ParameterSet vertex=presel.getParameter<edm::ParameterSet>("vertex");
541  vertex_= vertex.getParameter<edm::InputTag>("src");
543  }
544  if( presel.existsAs<edm::ParameterSet>("beamspot" ) ){
545  edm::ParameterSet beamspot=presel.getParameter<edm::ParameterSet>("beamspot");
546  beamspot_= beamspot.getParameter<edm::InputTag>("src");
548  }
549 
550  // conifgure the selection
551  std::vector<edm::ParameterSet> sel=cfg.getParameter<std::vector<edm::ParameterSet> >("selection");
552  for(unsigned int i=0; i<sel.size(); ++i){
553  selectionOrder_.push_back(sel.at(i).getParameter<std::string>("label"));
554  selection_[selectionStep(selectionOrder_.back())] = std::make_pair(sel.at(i), new TopSingleLepton::MonitorEnsemble(selectionStep(selectionOrder_.back()).c_str(), cfg.getParameter<edm::ParameterSet>("setup")));
555  }
556 }
557 
558 void
560 {
561  if(!triggerTable_.label().empty()){
563  if( !event.getByLabel(triggerTable_, triggerTable) ) return;
564  if(!accept(event, *triggerTable, triggerPaths_)) return;
565  }
566  //cout<<"trig passed"<<endl;
567  if(!beamspot_.label().empty()){
569  if( !event.getByLabel(beamspot_, beamspot) ) return;
570  if(!(*beamspotSelect_)(*beamspot)) return;
571  }
572  // apply selection steps
573  unsigned int passed=0;
574  for(std::vector<std::string>::const_iterator selIt=selectionOrder_.begin(); selIt!=selectionOrder_.end(); ++selIt){
575  std::string key = selectionStep(*selIt), type = objectType(*selIt);
576  if(selection_.find(key)!=selection_.end()){
577  if(type=="empty"){
578  selection_[key].second->fill(event, setup);
579  }
580  if(type=="muons"){
582  if(step.select(event)){ ++passed;
583  selection_[key].second->fill(event, setup);
584  } else break;
585  }
586  if(type=="elecs"){
588  if(step.select(event)){ ++passed;
589  selection_[key].second->fill(event, setup);
590  } else break;
591  }
592  if(type=="pvs" ){
594  if(step.selectVertex(event)){ ++passed;
595  selection_[key].second->fill(event, setup);
596  } else break;
597  }
598  if(type=="jets" ){
600  if(step.select(event, setup)){ ++passed;
601  selection_[key].second->fill(event, setup);
602  } else break;
603  }
604  if(type=="jets/pf" ){
606  if(step.select(event, setup)){ ++passed;
607  selection_[key].second->fill(event, setup);
608  } else break;
609  }
610  if(type=="jets/calo" ){
612  if(step.select(event, setup)){ ++passed;
613  selection_[key].second->fill(event, setup);
614  } else break;
615  }
616  if(type=="met" ){
618  if(step.select(event)){ ++passed;
619  selection_[key].second->fill(event, setup);
620  } else break;
621  }
622  }
623  }
624 }
625 
626 
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
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
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:187
Jets made from CaloTowers.
Definition: CaloJet.h:30
bool select(const edm::Event &event)
apply selection
edm::InputTag elecs_
input sources for monitoring
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:722
edm::InputTag triggerTable_
trigger table
std::vector< edm::InputTag > mets_
considers a vector of METs
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:21
bool selectVertex(const edm::Event &event)
double massTopQuark(const std::vector< reco::Jet > &jets)
calculate W boson mass estimate
RunNumber_t run() const
StringCutObjectSelector< reco::BeamSpot > * beamspotSelect_
string cut selector
TopSingleLeptonDQM(const edm::ParameterSet &cfg)
default constructor
virtual void scaleEnergy(double fScale)
scale energy of the jet
Definition: Jet.cc:445
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:22
Jets made from PFObjects.
Definition: PFJet.h:22
std::vector< std::string > triggerPaths_
trigger paths
double massWBoson(const std::vector< reco::Jet > &jets)
calculate W boson mass estimate
Definition: TopDQMHelpers.cc:9
std::vector< std::string > selectionOrder_
#define MAXJETS
Definition: myFastSimVal.cc:30
std::string selectionStep(const std::string &label)
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
edm::InputTag vertex_
primary vertex
static const double WMASS
double lowerEdge_
mass window upper and lower edge
edm::InputTag btagEff_
btag discriminator labels
Helper class for the calculation of a top and a W boson mass estime.
Definition: TopDQMHelpers.h:65
std::map< std::string, std::pair< edm::ParameterSet, TopSingleLepton::MonitorEnsemble * > > selection_
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
edm::InputTag triggerTable_
trigger table
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:94
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
EventAuxiliary const & eventAuxiliary() const
Definition: Event.h:65
edm::InputTag jetIDLabel_
jetID as an extra selection type
std::string label_
instance label
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
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:51
StringCutObjectSelector< reco::GsfElectron > * elecSelect_
extra selection on electrons
Templated helper class to allow a selection on a certain object collection.
std::string const & label() const
Definition: InputTag.h:42
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
edm::InputTag electronId_
electronId label
void triggerBinLabels(std::string channel, const std::vector< std::string > labels)
set configurable labels for trigger monitoring histograms
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:850
virtual float pt() const GCC11_FINAL
transverse momentum
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:434
virtual void analyze(const edm::Event &event, const edm::EventSetup &setup)
do this during the event loop
StringCutObjectSelector< reco::Vertex > * vertexSelect_
string cut selector
DQMStore * store_
storage manager