CMS 3D CMS Logo

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