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