CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TopHLTDiLeptonOfflineDQM.cc
Go to the documentation of this file.
1 //#include <algorithm>
8 
9 /*Originally from DQM/Physics by R. Wolf and J. Andrea*/
10 
11 namespace TopDiLeptonOffline {
12 
14  label_(label), eidPattern_(0), elecIso_(0), elecSelect_(0), muonIso_(0), muonSelect_(0), jetIDSelect_(0),
15  lowerEdge_(-1.), upperEdge_(-1.), elecMuLogged_(0), diMuonLogged_(0), diElecLogged_(0)
16  {
17  // sources have to be given; this PSet is not optional
18  edm::ParameterSet sources=cfg.getParameter<edm::ParameterSet>("sources");
19  muons_= sources.getParameter<edm::InputTag>("muons");
20  elecs_= sources.getParameter<edm::InputTag>("elecs");
21  jets_ = sources.getParameter<edm::InputTag>("jets" );
22  mets_ = sources.getParameter<std::vector<edm::InputTag> >("mets" );
23 
24  // elecExtras are optional; they may be omitted or empty
25  if( cfg.existsAs<edm::ParameterSet>("elecExtras") ){
26  edm::ParameterSet elecExtras=cfg.getParameter<edm::ParameterSet>("elecExtras");
27  // select is optional; in case it's not found no
28  // selection will be applied
29  if( elecExtras.existsAs<std::string>("select") ){
31  }
32  // isolation is optional; in case it's not found no
33  // isolation will be applied
34  if( elecExtras.existsAs<std::string>("isolation") ){
36  }
37  // electronId is optional; in case it's not found the
38  // InputTag will remain empty
39  if( elecExtras.existsAs<edm::ParameterSet>("electronId") ){
40  edm::ParameterSet elecId=elecExtras.getParameter<edm::ParameterSet>("electronId");
41  electronId_= elecId.getParameter<edm::InputTag>("src");
42  eidPattern_= elecId.getParameter<int>("pattern");
43  }
44  }
45  // muonExtras are optional; they may be omitted or empty
46  if( cfg.existsAs<edm::ParameterSet>("muonExtras") ){
47  edm::ParameterSet muonExtras=cfg.getParameter<edm::ParameterSet>("muonExtras");
48  // select is optional; in case it's not found no
49  // selection will be applied
50  if( muonExtras.existsAs<std::string>("select") ){
52  }
53  // isolation is optional; in case it's not found no
54  // isolation will be applied
55  if( muonExtras.existsAs<std::string>("isolation") ){
57  }
58  }
59  // jetExtras are optional; they may be omitted or empty
60  if( cfg.existsAs<edm::ParameterSet>("jetExtras") ){
61  edm::ParameterSet jetExtras=cfg.getParameter<edm::ParameterSet>("jetExtras");
62  // jetCorrector is optional; in case it's not found
63  // the InputTag will remain empty
64  if( jetExtras.existsAs<std::string>("jetCorrector") ){
65  jetCorrector_= jetExtras.getParameter<std::string>("jetCorrector");
66  }
67  // read jetID information if it exists
68  if(jetExtras.existsAs<edm::ParameterSet>("jetID")){
70  jetIDLabel_ =jetID.getParameter<edm::InputTag>("label");
72  }
73  // select is optional; in case it's not found no
74  // selection will be applied (only implemented for
75  // CaloJets at the moment)
76  if( jetExtras.existsAs<std::string>("select") ){
77  jetSelect_= jetExtras.getParameter<std::string>("select");
78  }
79  }
80  // triggerExtras are optional; they may be omitted or empty
81  if( cfg.existsAs<edm::ParameterSet>("triggerExtras") ){
82  edm::ParameterSet triggerExtras=cfg.getParameter<edm::ParameterSet>("triggerExtras");
83  triggerTable_=triggerExtras.getParameter<edm::InputTag>("src");
84  elecMuPaths_ =triggerExtras.getParameter<std::vector<std::string> >("pathsELECMU");
85  diMuonPaths_ =triggerExtras.getParameter<std::vector<std::string> >("pathsDIMUON");
86  }
87  // massExtras is optional; in case it's not found no mass
88  // window cuts are applied for the same flavor monitor
89  // histograms
90  if( cfg.existsAs<edm::ParameterSet>("massExtras") ){
91  edm::ParameterSet massExtras=cfg.getParameter<edm::ParameterSet>("massExtras");
92  lowerEdge_= massExtras.getParameter<double>("lowerEdge");
93  upperEdge_= massExtras.getParameter<double>("upperEdge");
94  }
95 
96  // setup the verbosity level for booking histograms;
97  // per default the verbosity level will be set to
98  // STANDARD. This will also be the chosen level in
99  // the case when the monitoring PSet is not found
101  if( cfg.existsAs<edm::ParameterSet>("monitoring") ){
102  edm::ParameterSet monitoring=cfg.getParameter<edm::ParameterSet>("monitoring");
103  if(monitoring.getParameter<std::string>("verbosity") == "DEBUG" )
104  verbosity_= DEBUG;
105  if(monitoring.getParameter<std::string>("verbosity") == "VERBOSE" )
107  if(monitoring.getParameter<std::string>("verbosity") == "STANDARD")
109  }
110  // and don't forget to do the histogram booking
111  book(cfg.getParameter<std::string>("directory"));
112  }
113 
114  void
116  {
117  //set up the current directory path
118  std::string current(directory); current+=label_;
121 
122  // determine number of bins for trigger monitoring
123  unsigned int nElecMu=elecMuPaths_.size();
124  unsigned int nDiMuon=diMuonPaths_.size();
125 
126  // --- [STANDARD] --- //
127  //Run Number
128  hists_["RunNumb_" ] = store_->book1D("RunNumber" , "Run Nr." , 1.e4, 1.5e5, 3.e5);
129  // invariant mass of opposite charge lepton pair (only filled for same flavor)
130  hists_["invMass_" ] = store_->book1D("InvMass" , "M(lep1, lep2)" , 80, 0., 320.);
131  // invariant mass of opposite charge lepton pair (only filled for same flavor)
132  hists_["invMassLog_" ] = store_->book1D("InvMassLog" , "log_{10}(M(lep1, lep2))" , 80, .1, 2.5);
133  // invariant mass of same charge lepton pair (log10 for low mass region, only filled for same flavor)
134  hists_["invMassWC_" ] = store_->book1D("InvMassWC" , "M_{WC}(L1, L2)" , 80, 0., 320.);
135  // invariant mass of same charge lepton pair (log10 for low mass region, only filled for same flavor)
136  hists_["invMassWCLog_"] = store_->book1D("InvMassLogWC", "log_{10}(M_{WC})" , 80, .1, 2.5);
137  // decay channel [1]: muon/muon, [2]:elec/elec, [3]:elec/muon
138  hists_["decayChannel_"] = store_->book1D("DecayChannel", "Decay Channel" , 3, 0, 3);
139  // trigger efficiency estimates for the electron muon channel
140  hists_["elecMuEff_" ] = store_->book1D("ElecMuEff" , "Eff(e/#mu paths)" , nElecMu, 0., nElecMu);
141  // monitored trigger occupancy for the electron muon channel
142  hists_["elecMuMon_" ] = store_->book1D("ElecMuMon" , "Mon(e/#mu paths)" , nElecMu, 0., nElecMu);
143  // trigger efficiency estimates for the di muon channel
144  hists_["diMuonEff_" ] = store_->book1D("DiMuonEff" , "Eff(#mu/#mu paths)" , nDiMuon, 0., nDiMuon);
145  // monitored trigger occupancy for the di muon channel
146  hists_["diMuonMon_" ] = store_->book1D("DiMuonMon" , "Mon(#mu/#mu paths)" , nDiMuon, 0., nDiMuon);
147  // pt of the leading lepton
148  hists_["lep1Pt_" ] = store_->book1D("Lep1Pt" , "pt(lep1)" , 50, 0., 200.);
149  // pt of the 2. leading lepton
150  hists_["lep2Pt_" ] = store_->book1D("Lep2Pt" , "pt(lep2)" , 50, 0., 200.);
151  // multiplicity of jets with pt>30 (corrected to L2+L3)
152  hists_["jetMult_" ] = store_->book1D("JetMult" , "N_{30}(jet)" , 21, -0.5, 20.5);
153  // MET (calo)
154  hists_["metCalo_" ] = store_->book1D("METCalo" , "MET_{Calo}" , 50, 0., 200.);
155 
156  // set bin labels for trigger monitoring
159  // set bin labels for decayChannel_
160  hists_["decayChannel_"]->setBinLabel( 1, "#mu e" , 1);
161  hists_["decayChannel_"]->setBinLabel( 2, "#mu #mu", 1);
162  hists_["decayChannel_"]->setBinLabel( 3, "e e" , 1);
163 
164  if( verbosity_==STANDARD) return;
165 
166  // --- [VERBOSE] --- //
167  // mean eta of the candidate leptons
168  hists_["sumEtaL1L2_" ] = store_->book1D("SumEtaL1L2" , "<#eta>(lep1, lep2)" , 100, -5., 5.);
169  // deltaEta between the 2 candidate leptons
170  hists_["dEtaL1L2_" ] = store_->book1D("DEtaL1L2" , "#Delta#eta(lep1,lep2)" , 80, -4., 4.);
171  // deltaPhi between the 2 candidate leptons
172  hists_["dPhiL1L2_" ] = store_->book1D("DPhiL1L2" , "#Delta#phi(lep1,lep2)" , 64, -3.2, 3.2);
173  // pt of the candidate electron (depending on the decay channel)
174  hists_["elecPt_" ] = store_->book1D("ElecPt" , "pt(e)" , 50, 0., 200.);
175  // relative isolation of the candidate electron (depending on the decay channel)
176  hists_["elecRelIso_" ] = store_->book1D("ElecRelIso" , "Iso_{Rel}(e)" , 50, 0., 1.);
177  // pt of the canddiate muon (depending on the decay channel)
178  hists_["muonPt_" ] = store_->book1D("MuonPt" , "pt(#mu)" , 50, 0., 200.);
179  // relative isolation of the candidate muon (depending on the decay channel)
180  hists_["muonRelIso_" ] = store_->book1D("MuonRelIso" , "Iso_{Rel}(#mu)" , 50, 0., 1.);
181  // pt of the 1. leading jet (corrected to L2+L3)
182  hists_["jet1Pt_" ] = store_->book1D("Jet1Pt" , "pt_{L2L3}(jet1)" , 60, 0., 300.);
183  // pt of the 2. leading jet (corrected to L2+L3)
184  hists_["jet2Pt_" ] = store_->book1D("Jet2Pt" , "pt_{L2L3}(jet2)" , 60, 0., 300.);
185  // MET (PF)
186  hists_["metPflow_" ] = store_->book1D("METPflow" , "MET_{Pflow}" , 50, 0., 200.);
187  // MET (TC)
188  hists_["metTC_" ] = store_->book1D("METTC" , "MET_{TC}" , 50, 0., 200.);
189  // dz for muons (to suppress cosmis)
190  hists_["muonDelZ_" ] = store_->book1D("MuonDelZ" , "d_{z}(#mu)" , 50, -25., 25.);
191  // dxy for muons (to suppress cosmics)
192  hists_["muonDelXY_" ] = store_->book2D("MuonDelXY" , "d_{xy}(#mu)" , 50, -1., 1., 50, -1., 1.);
193  // lepton multiplicity after std isolation
194  hists_["lepMultIso_" ] = store_->book2D("LepMultIso" , "N_{Iso}(e) vs N_{Iso}(#mu)" , 5, 0., 5., 5, 0., 5.);
195 
196  // set axes titles for dxy for muons
197  hists_["muonDelXY_" ]->setAxisTitle( "x [cm]", 1); hists_["muonDelXY_" ]->setAxisTitle( "y [cm]", 2);
198  // set axes titles for lepton multiplicity after std isolation
199  hists_["lepMultIso_" ]->setAxisTitle( "N_{Iso}(#mu)", 1); hists_["lepMultIso_" ]->setAxisTitle( "N_{Iso}(elec)", 2);
200 
201  if( verbosity_==VERBOSE) return;
202 
203  // --- [DEBUG] --- //
204  // electron multiplicity after std isolation
205  hists_["elecMultIso_" ] = store_->book1D("ElecMultIso" , "N_{Iso}(e)" , 11, -0.5, 10.5);
206  // muon multiplicity after std isolation
207  hists_["muonMultIso_" ] = store_->book1D("MuonMultIso" , "N_{Iso}(#mu)" , 11, -0.5, 10.5);
208  // calo isolation of the candidate muon (depending on the decay channel)
209  hists_["muonCalIso_" ] = store_->book1D("MuonCalIso" , "Iso_{Cal}(#mu)" , 50, 0., 1.);
210  // track isolation of the candidate muon (depending on the decay channel)
211  hists_["muonTrkIso_" ] = store_->book1D("MuonTrkIso" , "Iso_{Trk}(#mu)" , 50, 0., 1.);
212  // calo isolation of the candidate electron (depending on the decay channel)
213  hists_["elecCalIso_" ] = store_->book1D("ElecCalIso" , "Iso_{Cal}(e)" , 50, 0., 1.);
214  // track isolation of the candidate electron (depending on the decay channel)
215  hists_["elecTrkIso_" ] = store_->book1D("ElecTrkIso" , "Iso_{Trk}(e)" , 50, 0., 1.);
216  // eta of the leading jet
217  hists_["jet1Eta_" ] = store_->book1D("Jet1Eta" , "#eta(jet1)" , 30, -5., 5.);
218  // eta of the 2. leading jet
219  hists_["jet2Eta_" ] = store_->book1D("Jet2Eta" , "#eta(jet2)" , 30, -5., 5.);
220  // pt of the 1. leading jet (not corrected)
221  hists_["jet1PtRaw_" ] = store_->book1D("Jet1PtRaw" , "pt_{Raw}(jet1)" , 60, 0., 300.);
222  // pt of the 2. leading jet (not corrected)
223  hists_["jet2PtRaw_" ] = store_->book1D("Jet2PtRaw" , "pt_{Raw}(jet2)" , 60, 0., 300.);
224  // deltaEta between the 2 leading jets
225  hists_["dEtaJet1Jet2_"] = store_->book1D("DEtaJet1Jet2", "#Delta#eta(jet1,jet2)" , 80, -4., 4.);
226  // deltaEta between the lepton and the leading jet
227  hists_["dEtaJet1Lep1_"] = store_->book1D("DEtaJet1Lep1", "#Delta#eta(jet1,lep1)" , 80, -4., 4.);
228  // deltaEta between the lepton and MET
229  hists_["dEtaLep1MET_" ] = store_->book1D("DEtaLep1MET" , "#Delta#eta(lep1,MET)" , 80, -4., 4.);
230  // deltaEta between leading jet and MET
231  hists_["dEtaJet1MET_" ] = store_->book1D("DEtaJet1MET" , "#Delta#eta(jet1,MET)" , 80, -4., 4.);
232  // deltaPhi of 2 leading jets
233  hists_["dPhiJet1Jet2_"] = store_->book1D("DPhiJet1Jet2", "#Delta#phi(jet1,jet2)" , 64, -3.2, 3.2);
234  // deltaPhi of 1. lepton and 1. jet
235  hists_["dPhiJet1Lep1_"] = store_->book1D("DPhiJet1Lep1", "#Delta#phi(jet1,lep1)" , 64, -3.2, 3.2);
236  // deltaPhi of 1. lepton and MET
237  hists_["dPhiLep1MET_" ] = store_->book1D("DPhiLep1MET" , "#Delta#phi(lep1,MET)" , 64, -3.2, 3.2);
238  // deltaPhi of 1. jet and MET
239  hists_["dPhiJet1MET_" ] = store_->book1D("DPhiJet1MET" , "#Delta#phi(jet1,MET)" , 64, -3.2, 3.2);
240  // selected dimuon events
241  hists_["diMuonLogger_"] = store_->book2D("DiMuonLogger", "Logged DiMuon Events" , 8, 0., 8., 10, 0., 10.);
242  // selected dielec events
243  hists_["diElecLogger_"] = store_->book2D("DiElecLogger", "Logged DiElec Events" , 8, 0., 8., 10, 0., 10.);
244  // selected elemu events
245  hists_["elecMuLogger_"] = store_->book2D("ElecMuLogger", "Logged ElecMu Events" , 8, 0., 8., 10, 0., 10.);
246 
247  // set bin labels for trigger monitoring
248  loggerBinLabels(std::string("diMuonLogger_"));
249  loggerBinLabels(std::string("diElecLogger_"));
250  loggerBinLabels(std::string("elecMuLogger_"));
251  return;
252  }
253 
254  void
259  std::vector< edm::Handle<edm::View<reco::MET> > > mets)
260  {
261  // fetch trigger event if configured such
262  if(!triggerTable_.label().empty()) {
263  if( !triggerTable.isValid() ) return;
264  }
265 
266  /*
267  ------------------------------------------------------------
268 
269  Run and Inst. Luminosity information (Inst. Lumi. filled now with a dummy value=5.0)
270 
271  ------------------------------------------------------------
272  */
273 
274  if (!event.eventAuxiliary().run()) return;
275  fill("RunNumb_", event.eventAuxiliary().run());
276 
277  double dummy=5.; fill("InstLumi_", dummy);
278 
279 
280  /*
281  ------------------------------------------------------------
282 
283  Muon Selection
284 
285  ------------------------------------------------------------
286  */
287 
288  // buffer isolated muons
289  std::vector<const reco::Muon*> isoMuons;
290 
291  if( !muons.isValid() ) return;
292 
294  // restrict to globalMuons
295  if( muon->isGlobalMuon() ){
296  fill("muonDelZ_" , muon->globalTrack()->vz());
297  fill("muonDelXY_", muon->globalTrack()->vx(), muon->globalTrack()->vy());
298  // apply preselection
299  if(!muonSelect_ || (*muonSelect_)(*muon)){
300  double isolationTrk = muon->pt()/(muon->pt()+muon->isolationR03().sumPt);
301  double isolationCal = muon->pt()/(muon->pt()+muon->isolationR03().emEt+muon->isolationR03().hadEt);
302  double isolationRel = (muon->isolationR03().sumPt+muon->isolationR03().emEt+muon->isolationR03().hadEt)/muon->pt();
303  fill("muonTrkIso_" , isolationTrk); fill("muonCalIso_" , isolationCal); fill("muonRelIso_" , isolationRel);
304  if(!muonIso_ || (*muonIso_)(*muon)) isoMuons.push_back(&(*muon));
305  }
306  }
307  }
308  fill("muonMultIso_", isoMuons.size());
309 
310  /*
311  ------------------------------------------------------------
312 
313  Electron Selection
314 
315  ------------------------------------------------------------
316  */
317 
318  // buffer isolated electronss
319  std::vector<const reco::GsfElectron*> isoElecs;
320  if(!electronId_.label().empty()) {
321  if( !electronId.isValid() ) return;
322  }
323 
324  if( !elecs.isValid() ) return;
325 
326  for(edm::View<reco::GsfElectron>::const_iterator elec=elecs->begin(); elec!=elecs->end(); ++elec){
327  // restrict to electrons with good electronId
328  int idx = elec-elecs->begin();
329  if( electronId_.label().empty() ? true : ((int)(*electronId)[elecs->refAt(idx)] & eidPattern_) ){
330  // apply preselection
331  if(!elecSelect_ || (*elecSelect_)(*elec)){
332  double isolationTrk = elec->pt()/(elec->pt()+elec->dr03TkSumPt());
333  double isolationCal = elec->pt()/(elec->pt()+elec->dr03EcalRecHitSumEt()+elec->dr03HcalTowerSumEt());
334  double isolationRel = (elec->dr03TkSumPt()+elec->dr03EcalRecHitSumEt()+elec->dr03HcalTowerSumEt())/elec->pt();
335  fill("elecTrkIso_" , isolationTrk); fill("elecCalIso_" , isolationCal); fill("elecRelIso_" , isolationRel);
336  if(!elecIso_ || (*elecIso_)(*elec)) isoElecs.push_back(&(*elec));
337  }
338  }
339  }
340  fill("elecMultIso_", isoElecs.size());
341 
342  /*
343  ------------------------------------------------------------
344 
345  Jet Selection
346 
347  ------------------------------------------------------------
348  */
349 
350  const JetCorrector* corrector=0;
351  if(!jetCorrector_.empty()){
352  // check whether a jet correcto is in the event setup or not
353  if(setup.find( edm::eventsetup::EventSetupRecordKey::makeKey<JetCorrectionsRecord>() )){
354  corrector = JetCorrector::getJetCorrector(jetCorrector_, setup);
355  }
356  else{
357  edm::LogVerbatim( "TopHLTDiLeptonOfflineDQM" )
358  << "\n"
359  << "------------------------------------------------------------------------------------- \n"
360  << " No JetCorrectionsRecord available from EventSetup: \n"
361  << " - Jets will not be corrected. \n"
362  << " - If you want to change this add the following lines to your cfg file: \n"
363  << " \n"
364  << " ## load jet corrections \n"
365  << " process.load(\"JetMETCorrections.Configuration.JetCorrectionServicesAllAlgos_cff\") \n"
366  << " process.prefer(\"ak5CaloL2L3\") \n"
367  << " \n"
368  << "------------------------------------------------------------------------------------- \n";
369  }
370  }
371 
372  unsigned int mult=0;
373  // buffer leadingJets
374  std::vector<reco::Jet> leadingJets;
375  if( !jets.isValid() ) return;
376 
377  if(jetIDSelect_){
378  if( !jetID.isValid() ) return;
379  }
380 
381  for(edm::View<reco::Jet>::const_iterator jet=jets->begin(); jet!=jets->end(); ++jet){
382  unsigned int idx=jet-jets->begin();
383  if( jetIDSelect_ && dynamic_cast<const reco::CaloJet*>(jets->refAt(idx).get())){
384  if(!(*jetIDSelect_)((*jetID)[jets->refAt(idx)])) continue;
385  }
386  // chekc additional jet selection for calo, pf and bare reco jets
387  if(dynamic_cast<const reco::CaloJet*>(&*jet)){
388  reco::CaloJet sel = dynamic_cast<const reco::CaloJet&>(*jet); sel.scaleEnergy(corrector ? corrector->correction(*jet) : 1.);
389  StringCutObjectSelector<reco::CaloJet> jetSelect(jetSelect_); if(!jetSelect(sel)){ continue;}
390  }
391  else if(dynamic_cast<const reco::PFJet*>(&*jet)){
392  reco::PFJet sel= dynamic_cast<const reco::PFJet&>(*jet); sel.scaleEnergy(corrector ? corrector->correction(*jet) : 1.);
393  StringCutObjectSelector<reco::PFJet> jetSelect(jetSelect_); if(!jetSelect(sel)) continue;
394  }
395  else{
396  reco::Jet sel = *jet; sel.scaleEnergy(corrector ? corrector->correction(*jet) : 1.);
397  StringCutObjectSelector<reco::Jet> jetSelect(jetSelect_); if(!jetSelect(sel)) continue;
398  }
399  // check for overlaps
400  bool overlap=false;
401  for(std::vector<const reco::GsfElectron*>::const_iterator elec=isoElecs.begin(); elec!=isoElecs.end(); ++elec){
402  if(reco::deltaR((*elec)->eta(), (*elec)->phi(), jet->eta(), jet->phi())<0.4){overlap=true; break;}
403  } if(overlap){continue;}
404  // prepare jet to fill monitor histograms
405  reco::Jet monitorJet=*jet; monitorJet.scaleEnergy(corrector ? corrector->correction(*jet) : 1.);
406  ++mult; // determine jet multiplicity
407  if(idx==0) {
408  leadingJets.push_back(monitorJet);
409  fill("jet1Pt_" , monitorJet.pt());
410  fill("jet1PtRaw_" , jet->pt() );
411  fill("jet1Eta_" , jet->eta());
412  }
413  if(idx==1) {
414  leadingJets.push_back(monitorJet);
415  fill("jet2Pt_" , monitorJet.pt());
416  fill("jet2PtRaw_" , jet->pt() );
417  fill("jet2Eta_" , jet->eta());
418  }
419  }
420  if(leadingJets.size()>1){
421  fill("dEtaJet1Jet2_" , leadingJets[0].eta()-leadingJets[1].eta());
422  fill("dPhiJet1Jet2_" , reco::deltaPhi(leadingJets[0].phi(), leadingJets[1].phi()));
423  if( !isoMuons.empty() ){
424  if( isoElecs.empty() || isoMuons[0]->pt()>isoElecs[0]->pt() ){
425  fill("dEtaJet1Lep1_" , isoMuons[0]->eta()-leadingJets[0].eta());
426  fill("dPhiJet1Lep1_" , reco::deltaPhi(isoMuons[0]->phi() , leadingJets[0].phi()));
427  }
428  }
429  if( !isoElecs.empty() ){
430  if( isoMuons.empty() || isoElecs[0]->pt()>isoMuons[0]->pt() ){
431  fill("dEtaJet1Lep1_" , isoElecs[0]->eta()-leadingJets[0].eta());
432  fill("dPhiJet1Lep1_" , reco::deltaPhi(isoElecs[0]->phi() , leadingJets[0].phi()));
433  }
434  }
435  }
436  fill("jetMult_", mult);
437 
438  /*
439  ------------------------------------------------------------
440 
441  MET Selection
442 
443  ------------------------------------------------------------
444  */
445 
446  // buffer for event logging
447  reco::MET caloMET;
448  //for(std::vector<edm::InputTag>::const_iterator met_=mets_.begin(); met_!=mets_.end(); ++met_){
449  //for( met_=mets_.begin(); met_!=mets_.end(); ++met_){
450  for( int i=0; i<int(mets.size()); i++ ){
452  if( !met.isValid() ) continue;
453 
454  if(met->begin()!=met->end()){
455  unsigned int idx=i;
456  if(idx==0){
457  caloMET=*met->begin();
458  fill("metCalo_", met->begin()->et());
459  if(!leadingJets.empty()){
460  fill("dEtaJet1MET_" , leadingJets[0].eta()-met->begin()->eta());
461  fill("dPhiJet1MET_" , reco::deltaPhi(leadingJets[0].phi(), met->begin()->phi()));
462  }
463  if( !isoMuons.empty() ){
464  if( isoElecs.empty() || isoMuons[0]->pt()>isoElecs[0]->pt() ){
465  fill("dEtaLep1MET_" , isoMuons[0]->eta()-met->begin()->eta());
466  fill("dPhiLep1MET_" , reco::deltaPhi(isoMuons[0]->phi(), met->begin()->phi()));
467  }
468  }
469  if( !isoElecs.empty() ){
470  if( isoMuons.empty() || isoElecs[0]->pt()>isoMuons[0]->pt() ){
471  fill("dEtaLep1MET_" , isoElecs[0]->eta()-met->begin()->eta());
472  fill("dPhiLep1MET_" , reco::deltaPhi(isoElecs[0]->phi(), met->begin()->phi()));
473  }
474  }
475  }
476  if(idx==1){ fill("metTC_" , met->begin()->et());}
477  if(idx==2){ fill("metPflow_", met->begin()->et());}
478  }
479  }
480 
481 
482  /*
483  ------------------------------------------------------------
484 
485  Event Monitoring
486 
487  ------------------------------------------------------------
488  */
489 
490  // check number of isolated leptons
491  fill("lepMultIso_", isoMuons.size(), isoElecs.size());
492  // ELECMU channel
493  if( decayChannel(isoMuons, isoElecs) == ELECMU ){
494  fill("decayChannel_", 0.5);
495  double mass = (isoElecs[0]->p4()+isoMuons[0]->p4()).mass();
496  if( (lowerEdge_==-1. && upperEdge_==-1.) || (lowerEdge_<mass && mass<upperEdge_) ){
497 
498  fill("dEtaL1L2_" , isoElecs[0]->eta()-isoMuons[0]->eta());
499  fill("sumEtaL1L2_", (isoElecs[0]->eta()+isoMuons[0]->eta())/2);
500  fill("dPhiL1L2_" , reco::deltaPhi(isoElecs[0]->phi(), isoMuons[0]->eta()));
501  fill("elecPt_", isoElecs[0]->pt()); fill("muonPt_", isoMuons[0]->pt());
502  fill("lep1Pt_", isoElecs[0]->pt()>isoMuons[0]->pt() ? isoElecs[0]->pt() : isoMuons[0]->pt());
503  fill("lep2Pt_", isoElecs[0]->pt()>isoMuons[0]->pt() ? isoMuons[0]->pt() : isoElecs[0]->pt());
504  // fill plots for trigger monitoring
505  if(!triggerTable_.label().empty()) fill(event, *triggerTable, "elecMu", elecMuPaths_);
506  if(elecMuLogged_<=hists_.find("elecMuLogger_")->second->getNbinsY()){
507  // log runnumber, lumi block, event number & some
508  // more pysics infomation for interesting events
509  fill("elecMuLogger_", 0.5, elecMuLogged_+0.5, event.eventAuxiliary().run());
510  fill("elecMuLogger_", 1.5, elecMuLogged_+0.5, event.eventAuxiliary().luminosityBlock());
511  fill("elecMuLogger_", 2.5, elecMuLogged_+0.5, event.eventAuxiliary().event());
512  fill("elecMuLogger_", 3.5, elecMuLogged_+0.5, isoMuons[0]->pt());
513  fill("elecMuLogger_", 4.5, elecMuLogged_+0.5, isoElecs[0]->pt());
514  if(leadingJets.size()>0) fill("elecMuLogger_", 5.5, elecMuLogged_+0.5, leadingJets[0].pt());
515  if(leadingJets.size()>1) fill("elecMuLogger_", 6.5, elecMuLogged_+0.5, leadingJets[1].pt());
516  fill("elecMuLogger_", 7.5, elecMuLogged_+0.5, caloMET.et());
517  ++elecMuLogged_;
518  }
519  }
520  }
521 
522  // DIMUON channel
523  if( decayChannel(isoMuons, isoElecs) == DIMUON ){
524  fill("decayChannel_", 1.5);
525  int charge = isoMuons[0]->charge()*isoMuons[1]->charge();
526  double mass = (isoMuons[0]->p4()+isoMuons[1]->p4()).mass();
527 
528  fill(charge<0 ? "invMass_" : "invMassWC_" , mass );
529  fill(charge<0 ? "invMassLog_" : "invMassWCLog_" , log10(mass));
530  if((lowerEdge_==-1. && upperEdge_==-1.) || (lowerEdge_<mass && mass<upperEdge_) ){
531  fill("dEtaL1L2_" , isoMuons[0]->eta()-isoMuons[1]->eta() );
532  fill("sumEtaL1L2_", (isoMuons[0]->eta()+isoMuons[1]->eta())/2);
533  fill("dPhiL1L2_", reco::deltaPhi(isoMuons[0]->phi(),isoMuons[1]->phi()) );
534  fill("muonPt_", isoMuons[0]->pt()); fill("muonPt_", isoMuons[1]->pt());
535  fill("lep1Pt_", isoMuons[0]->pt()); fill("lep2Pt_", isoMuons[1]->pt());
536  // fill plots for trigger monitoring
537  if(!triggerTable_.label().empty()) fill(event, *triggerTable, "diMuon", diMuonPaths_);
538  if(diMuonLogged_<=hists_.find("diMuonLogger_")->second->getNbinsY()){
539  // log runnumber, lumi block, event number & some
540  // more pysics infomation for interesting events
541  fill("diMuonLogger_", 0.5, diMuonLogged_+0.5, event.eventAuxiliary().run());
542  fill("diMuonLogger_", 1.5, diMuonLogged_+0.5, event.eventAuxiliary().luminosityBlock());
543  fill("diMuonLogger_", 2.5, diMuonLogged_+0.5, event.eventAuxiliary().event());
544  fill("diMuonLogger_", 3.5, diMuonLogged_+0.5, isoMuons[0]->pt());
545  fill("diMuonLogger_", 4.5, diMuonLogged_+0.5, isoMuons[1]->pt());
546  if(leadingJets.size()>0) fill("diMuonLogger_", 5.5, diMuonLogged_+0.5, leadingJets[0].pt());
547  if(leadingJets.size()>1) fill("diMuonLogger_", 6.5, diMuonLogged_+0.5, leadingJets[1].pt());
548  fill("diMuonLogger_", 7.5, diMuonLogged_+0.5, caloMET.et());
549  ++diMuonLogged_;
550  }
551  }
552  }
553 
554  // DIELEC channel
555  if( decayChannel(isoMuons, isoElecs) == DIELEC ){
556  fill("decayChannel_", 2.5);
557  int charge = isoElecs[0]->charge()*isoElecs[1]->charge();
558  double mass = (isoElecs[0]->p4()+isoElecs[1]->p4()).mass();
559  fill(charge<0 ? "invMass_" : "invMassWC_" , mass );
560  fill(charge<0 ? "invMassLog_" : "invMassWCLog_" , log10(mass));
561  if((lowerEdge_==-1. && upperEdge_==-1.) || (lowerEdge_<mass && mass<upperEdge_) ){
562  fill("dEtaL1L2_" , isoElecs[0]->eta()-isoElecs[1]->eta() );
563  fill("sumEtaL1L2_", (isoElecs[0]->eta()+isoElecs[1]->eta())/2);
564  fill("dPhiL1L2_" , reco::deltaPhi(isoElecs[0]->phi(),isoElecs[1]->phi()) );
565  fill("elecPt_", isoElecs[0]->pt()); fill("elecPt_", isoElecs[1]->pt());
566  fill("lep1Pt_", isoElecs[0]->pt()); fill("lep2Pt_", isoElecs[1]->pt());
567  if(diElecLogged_<=hists_.find("diElecLogger_")->second->getNbinsY()){
568  // log runnumber, lumi block, event number & some
569  // more pysics infomation for interesting events
570  fill("diElecLogger_", 0.5, diElecLogged_+0.5, event.eventAuxiliary().run());
571  fill("diElecLogger_", 1.5, diElecLogged_+0.5, event.eventAuxiliary().luminosityBlock());
572  fill("diElecLogger_", 2.5, diElecLogged_+0.5, event.eventAuxiliary().event());
573  fill("diElecLogger_", 3.5, diElecLogged_+0.5, isoElecs[0]->pt());
574  fill("diElecLogger_", 4.5, diElecLogged_+0.5, isoElecs[1]->pt());
575  if(leadingJets.size()>0) fill("diElecLogger_", 5.5, diElecLogged_+0.5, leadingJets[0].pt());
576  if(leadingJets.size()>1) fill("diElecLogger_", 6.5, diElecLogged_+0.5, leadingJets[1].pt());
577  fill("diElecLogger_", 7.5, diElecLogged_+0.5, caloMET.et());
578  ++diElecLogged_;
579  }
580  }
581  }
582  }
583 
584 }
585 
586 TopHLTDiLeptonOfflineDQM::TopHLTDiLeptonOfflineDQM(const edm::ParameterSet& cfg): triggerTable_(""), vertex_(""), vertexSelect_(0), beamspotSelect_(0)
587 {
588  edm::ParameterSet sources=cfg.getParameter<edm::ParameterSet>("sources");
589  muonsToken_ = consumes< edm::View<reco::Muon> >(sources.getParameter<edm::InputTag>("muons"));
590  elecsToken_ = consumes< edm::View<reco::GsfElectron> >(sources.getParameter<edm::InputTag>("elecs"));
591  jetsToken_ = consumes< edm::View<reco::Jet> >(sources.getParameter<edm::InputTag>("jets" ));
592 
593  metsTemp_ = sources.getParameter<std::vector<edm::InputTag> >("mets" );
594 
595  metsTokens_.resize( metsTemp_.size() );
596  for( int i=0; i<int(metsTemp_.size()); i++ ) metsTokens_[i] = consumes< edm::View<reco::MET> >(metsTemp_[i]);
597 
598  // configure the preselection
599  edm::ParameterSet presel=cfg.getParameter<edm::ParameterSet>("preselection");
600  if( presel.existsAs<edm::ParameterSet>("trigger") ){
601  edm::ParameterSet trigger=presel.getParameter<edm::ParameterSet>("trigger");
602  triggerTable_=trigger.getParameter<edm::InputTag>("src");
603  triggerTableToken_ = consumes<edm::TriggerResults>(trigger.getParameter<edm::InputTag>("src"));
604  triggerPaths_=trigger.getParameter<std::vector<std::string> >("select");
605  }
606  if( presel.existsAs<edm::ParameterSet>("vertex" ) ){
607  edm::ParameterSet vertex=presel.getParameter<edm::ParameterSet>("vertex");
608  vertex_= vertex.getParameter<edm::InputTag>("src");
609  vertexToken_= consumes< std::vector<reco::Vertex> >(vertex.getParameter<edm::InputTag>("src"));
611  }
612  if( presel.existsAs<edm::ParameterSet>("beamspot" ) ){
613  edm::ParameterSet beamspot=presel.getParameter<edm::ParameterSet>("beamspot");
614  beamspot_= beamspot.getParameter<edm::InputTag>("src");
615  beamspotToken_= consumes<reco::BeamSpot>(beamspot.getParameter<edm::InputTag>("src"));
617  }
618 
619  // elecExtras are optional; they may be omitted or empty
620  if( cfg.existsAs<edm::ParameterSet>("elecExtras") ){
621  edm::ParameterSet elecExtras=cfg.getParameter<edm::ParameterSet>("elecExtras");
622  // electronId is optional; in case it's not found the
623  // InputTag will remain empty
624  if( elecExtras.existsAs<edm::ParameterSet>("electronId") ){
625  edm::ParameterSet elecId=elecExtras.getParameter<edm::ParameterSet>("electronId");
626  electronIdToken_= consumes< edm::ValueMap<float> >(elecId.getParameter<edm::InputTag>("src"));
627  }
628  }
629 
630  // jetExtras are optional; they may be omitted or empty
631  if( cfg.existsAs<edm::ParameterSet>("jetExtras") ){
632  edm::ParameterSet jetExtras=cfg.getParameter<edm::ParameterSet>("jetExtras");
633  // read jetID information if it exists
634  if(jetExtras.existsAs<edm::ParameterSet>("jetID")){
636  jetIDToken_ = consumes<reco::JetIDValueMap>(jetID.getParameter<edm::InputTag>("label"));
637  }
638  }
639 
640  // conifgure the selection
641  std::vector<edm::ParameterSet> sel=cfg.getParameter<std::vector<edm::ParameterSet> >("selection");
642  for(unsigned int i=0; i<sel.size(); ++i){
643  selectionOrder_.push_back(sel.at(i).getParameter<std::string>("label"));
644  selection_[selectionStep(selectionOrder_.back())] = std::make_pair(sel.at(i), new TopDiLeptonOffline::MonitorEnsemble(selectionStep(selectionOrder_.back()).c_str(), cfg.getParameter<edm::ParameterSet>("setup")));
645  }
646 }
647 
648 void
650 {
654 
656  event.getByToken(muonsToken_, muons);
657 
658  edm::Handle<edm::ValueMap<float> > electronId;
659  event.getByToken(electronIdToken_, electronId);
660 
662  event.getByToken(elecsToken_, elecs);
663 
665  event.getByToken(jetsToken_, jets);
666 
668  event.getByToken(jetIDToken_, jetID);
669 
670  std::vector< edm::Handle<edm::View<reco::MET> > > mets;
671  for( int i=0; i<int(metsTemp_.size()); i++ ) event.getByToken(metsTokens_[i],mets[i]);
672 
673 
674  if(!triggerTable_.label().empty()){
675  if( !event.getByToken(triggerTableToken_, triggerTable) ) return;
676  if(!acceptHLT(event, *triggerTable, triggerPaths_)) return;
677  }
678  if(!vertex_.label().empty()){
679  if( !event.getByToken(vertexToken_, vertex) ) return;
680  if(vertex->empty() || !(*vertexSelect_)(vertex->front())) return;
681  }
682  if(!beamspot_.label().empty()){
683  if( !event.getByToken(beamspotToken_, beamspot) ) return;
684  if(!(*beamspotSelect_)(*beamspot)) return;
685  }
686 
687  // apply selection steps
688  for(std::vector<std::string>::const_iterator selIt=selectionOrder_.begin(); selIt!=selectionOrder_.end(); ++selIt){
689  std::string key = selectionStep(*selIt), type = objectType(*selIt);
690  if(selection_.find(key)!=selection_.end()){
691  if(type=="empty"){
692  selection_[key].second->fill(event, setup, triggerTable, muons, electronId, elecs, jets, jetID, mets);
693  }
694  if(type=="Hlt" ){
695 // cout<<"HLT filled"<<endl;
696  selection_[key].second->fill(event, setup, triggerTable, muons, electronId, elecs, jets, jetID, mets);
697  }
698  if(type=="muons"){
700  if(step.select(event)){
701  selection_[key].second->fill(event, setup, triggerTable, muons, electronId, elecs, jets, jetID, mets);
702  } else break;
703  }
704  if(type=="elecs"){
706  if(step.select(event)){
707  selection_[key].second->fill(event, setup, triggerTable, muons, electronId, elecs, jets, jetID, mets);
708  } else break;
709  }
710  if(type=="jets" ){
712  if(step.select(event, setup)){
713  selection_[key].second->fill(event, setup, triggerTable, muons, electronId, elecs, jets, jetID, mets);
714  } else break;
715  }
716  if(type=="jets/pf" ){
718  if(step.select(event, setup)){
719  selection_[key].second->fill(event, setup, triggerTable, muons, electronId, elecs, jets, jetID, mets);
720  } else break;
721  }
722  if(type=="jets/calo" ){
724  if(step.select(event, setup)){
725  selection_[key].second->fill(event, setup, triggerTable, muons, electronId, elecs, jets, jetID, mets);
726  } else break;
727  }
728  if(type=="met" ){
730  if(step.select(event)){
731  selection_[key].second->fill(event, setup, triggerTable, muons, electronId, elecs, jets, jetID, mets);
732  } else break;
733  }
734  }
735  }
736 }
737 
738 
type
Definition: HCALResponse.h:21
T getParameter(std::string const &) const
StringCutObjectSelector< reco::JetID > * jetIDSelect_
extra jetID selection on calo jets
virtual double et() const GCC11_FINAL
transverse energy
int i
Definition: DBlmapReader.cc:9
edm::EDGetTokenT< edm::View< reco::Muon > > muonsToken_
StringCutObjectSelector< reco::BeamSpot > * beamspotSelect_
string cut selector
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
virtual void analyze(const edm::Event &event, const edm::EventSetup &setup)
do this during the event loop
tuple met
____________________________________________________________________________||
Definition: CaloMET_cfi.py:7
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
edm::EDGetTokenT< reco::JetIDValueMap > jetIDToken_
bool acceptHLT(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:872
edm::EDGetTokenT< reco::JetIDValueMap > jetIDLabel_
jetID as an extra selection type
StringCutObjectSelector< reco::GsfElectron > * elecIso_
extra isolation criterion on electron
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
edm::EDGetTokenT< edm::View< reco::Muon > > muons_
edm::EDGetTokenT< edm::View< reco::Jet > > jetsToken_
Base class for all types of Jets.
Definition: Jet.h:20
MonitorEnsemble(const char *label, const edm::ParameterSet &cfg, edm::ConsumesCollector &&iC)
default contructor
std::vector< edm::InputTag > metsTemp_
DecayChannel decayChannel(const std::vector< const reco::Muon * > &muons, const std::vector< const reco::GsfElectron * > &elecs) const
determine dileptonic decay channel
RunNumber_t run() const
void loggerBinLabels(std::string hist)
set labels for event logging histograms
int elecMuLogged_
number of logged interesting events
virtual void scaleEnergy(double fScale)
scale energy of the jet
Definition: Jet.cc:444
std::string selectionStep(const std::string &label)
T eta() const
double charge(const std::vector< uint8_t > &Ampls)
void fill(const edm::Event &event, const edm::EventSetup &setup)
fill monitor histograms with electronId and jetCorrections
Jets made from PFObjects.
Definition: PFJet.h:21
std::vector< std::string > selectionOrder_
edm::EDGetTokenT< edm::View< reco::GsfElectron > > elecs_
edm::InputTag triggerTable_
trigger table
std::vector< std::string > triggerPaths_
trigger paths
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
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
bool overlap(const reco::Muon &muon1, const reco::Muon &muon2, double pullX=1.0, double pullY=1.0, bool checkAdjacentChambers=false)
StringCutObjectSelector< reco::Vertex > * vertexSelect_
string cut selector
edm::EDGetTokenT< reco::BeamSpot > beamspotToken_
StringCutObjectSelector< reco::Muon > * muonIso_
extra isolation criterion on muon
edm::EDGetTokenT< std::vector< reco::Vertex > > vertexToken_
std::map< std::string, std::pair< edm::ParameterSet, TopDiLeptonOffline::MonitorEnsemble * > > selection_
Definition: MET.h:32
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
vector< PseudoJet > jets
StringCutObjectSelector< reco::Muon > * muonSelect_
extra selection on muons
std::vector< edm::EDGetTokenT< edm::View< reco::MET > > > mets_
considers a vector of METs
auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
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
bool select(const edm::Event &event)
apply selection
TopHLTDiLeptonOfflineDQM(const edm::ParameterSet &cfg)
default constructor
void book(std::string directory)
book histograms in subdirectory directory
double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:12
EventAuxiliary const & eventAuxiliary() const
Definition: Event.h:72
std::vector< std::string > diMuonPaths_
trigger paths for di muon channel
edm::InputTag beamspot_
beamspot
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:50
double lowerEdge_
mass window upper and lower edge
std::string const & label() const
Definition: InputTag.h:42
Level verbosity_
verbosity level for booking
edm::EDGetTokenT< edm::TriggerResults > triggerTableToken_
edm::EDGetTokenT< edm::TriggerResults > triggerTable_
trigger table
std::string objectType(const std::string &label)
std::map< std::string, MonitorElement * > hists_
histogram container
StringCutObjectSelector< reco::GsfElectron > * elecSelect_
extra selection on electrons
list key
Definition: combine.py:13
tuple muons
Definition: patZpeak.py:38
edm::InputTag vertex_
primary vertex
std::vector< std::string > elecMuPaths_
edm::EDGetTokenT< edm::View< reco::GsfElectron > > elecsToken_
std::vector< edm::EDGetTokenT< edm::View< reco::MET > > > metsTokens_
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
edm::EDGetTokenT< edm::ValueMap< float > > electronIdToken_
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
edm::EDGetTokenT< edm::ValueMap< float > > electronId_
electronId label
EventNumber_t event() const
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:584
void triggerBinLabels(std::string channel, const std::vector< std::string > labels)
set configurable labels for trigger monitoring histograms
Definition: DDAxes.h:10