CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TopDiLeptonDQM.cc
Go to the documentation of this file.
1 /*
2  * $Date: 2012/01/11 13:53:29 $
3  * $Revision: 1.14 $
4  * \author M. Marienfeld - DESY Hamburg
5  */
6 
7 #include "TLorentzVector.h"
11 
12 using namespace std;
13 using namespace edm;
14 
16 
17  initialize();
18 
19  moduleName_ = ps.getUntrackedParameter<string>("moduleName");
20  fileOutput_ = ps.getParameter<bool>("fileOutput");
21  outputFile_ = ps.getUntrackedParameter<string>("outputFile");
22  triggerResults_ = consumes<TriggerResults>(ps.getParameter<edm::InputTag>("TriggerResults"));
23  hltPaths_ = ps.getParameter<vector<string> >("hltPaths");
24  hltPaths_sig_ = ps.getParameter<vector<string> >("hltPaths_sig");
25  hltPaths_trig_ = ps.getParameter<vector<string> >("hltPaths_trig");
26 
27  vertex_ = consumes<reco::VertexCollection>(ps.getParameter<edm::InputTag>("vertexCollection"));
28  vertex_X_cut_ = ps.getParameter<double>("vertex_X_cut");
29  vertex_Y_cut_ = ps.getParameter<double>("vertex_Y_cut");
30  vertex_Z_cut_ = ps.getParameter<double>("vertex_Z_cut");
31 
32  muons_ = consumes<reco::MuonCollection>(ps.getParameter<edm::InputTag>("muonCollection"));
33  muon_pT_cut_ = ps.getParameter<double>("muon_pT_cut");
34  muon_eta_cut_ = ps.getParameter<double>("muon_eta_cut");
35  muon_iso_cut_ = ps.getParameter<double>("muon_iso_cut");
36 
37  elecs_ = consumes<reco::GsfElectronCollection>(ps.getParameter<edm::InputTag>("elecCollection"));
38  elec_pT_cut_ = ps.getParameter<double>("elec_pT_cut");
39  elec_eta_cut_ = ps.getParameter<double>("elec_eta_cut");
40  elec_iso_cut_ = ps.getParameter<double>("elec_iso_cut");
41  elec_emf_cut_ = ps.getParameter<double>("elec_emf_cut");
42 
43  MassWindow_up_ = ps.getParameter<double>("MassWindow_up");
44  MassWindow_down_ = ps.getParameter<double>("MassWindow_down");
45 
46  for(int i=0; i<100; ++i) {
47  N_sig[i] = 0;
48  N_trig[i] = 0;
49  Eff[i] = 0.;
50  }
51 
52  N_mumu = 0;
53  N_muel = 0;
54  N_elel = 0;
55 
56 
57  if( fileOutput_ ) {
58  const char *fileName = outputFile_.c_str();
59  outfile.open (fileName);
60  }
61 
63 
64  Events_ = 0;
65  Trigs_ = 0;
66  TriggerEff_ = 0;
67  Ntracks_ = 0;
68  Nmuons_ = 0;
69  Nmuons_iso_ = 0;
70  Nmuons_charge_ = 0;
71  VxVy_muons_ = 0;
72  Vz_muons_ = 0;
73  pT_muons_ = 0;
74  eta_muons_ = 0;
75  phi_muons_ = 0;
76  Nelecs_ = 0;
77  Nelecs_iso_ = 0;
78  Nelecs_charge_ = 0;
79  HoverE_elecs_ = 0;
80  pT_elecs_ = 0;
81  eta_elecs_ = 0;
82  phi_elecs_ = 0;
83  MuIso_emEt03_ = 0;
84  MuIso_hadEt03_ = 0;
85  MuIso_hoEt03_ = 0;
86  MuIso_nJets03_ = 0;
87  MuIso_nTracks03_ = 0;
88  MuIso_sumPt03_ = 0;
89  MuIso_CombRelIso03_ = 0;
90  ElecIso_cal_ = 0;
91  ElecIso_trk_ = 0;
92  ElecIso_CombRelIso_ = 0;
93  dimassRC_ = 0;
94  dimassWC_ = 0;
95  dimassRC_LOGX_ = 0;
96  dimassWC_LOGX_ = 0;
97  dimassRC_LOG10_ = 0;
98  dimassWC_LOG10_ = 0;
99  D_eta_muons_ = 0;
100  D_phi_muons_ = 0;
101  D_eta_elecs_ = 0;
102  D_phi_elecs_ = 0;
103  D_eta_lepts_ = 0;
104  D_phi_lepts_ = 0;
105 
106 }
107 
108 
110 
111 }
112 
113 
115 
116 }
117 
118 
120 
121  dbe_->setCurrentFolder(moduleName_);
122 
123  Events_ = dbe_->book1D("00_Events", "Isolated dilepton events", 5, 0., 5.);
124  Events_->setBinLabel( 2, "#mu #mu", 1);
125  Events_->setBinLabel( 3, "#mu e", 1);
126  Events_->setBinLabel( 4, "e e", 1);
127 
128  Trigs_ = dbe_->book1D("01_Trigs", "Fired muon/electron triggers", 15, 0., 15.);
129  TriggerEff_ = dbe_->book1D("02_TriggerEff", "HL Trigger Efficiencies", 10, 0., 10.);
130  TriggerEff_->setTitle("HL Trigger Efficiencies #epsilon_{signal} = #frac{[signal] && [control]}{[control]}");
131  Ntracks_ = dbe_->book1D("Ntracks", "Number of tracks", 50, 0., 50.);
132 
133  Nmuons_ = dbe_->book1D("03_Nmuons", "Number of muons", 20, 0., 10.);
134  Nmuons_iso_ = dbe_->book1D("04_Nmuons_iso", "Number of isolated muons", 20, 0., 10.);
135  Nmuons_charge_ = dbe_->book1D("Nmuons_charge", "Number of muons * moun charge", 19, -10., 10.);
136  VxVy_muons_ = dbe_->book2D("VxVy_muons", "Vertex x-y-positon (global)", 40, -1., 1., 40 , -1., 1.);
137  Vz_muons_ = dbe_->book1D("Vz_muons", "Vertex z-positon (global)", 40, -20., 20.);
138  pT_muons_ = dbe_->book1D("pT_muons", "P_T of muons", 40, 0., 200.);
139  eta_muons_ = dbe_->book1D("eta_muons", "Eta of muons", 50, -5., 5.);
140  phi_muons_ = dbe_->book1D("phi_muons", "Phi of muons", 40, -4., 4.);
141 
142  Nelecs_ = dbe_->book1D("05_Nelecs", "Number of electrons", 20, 0., 10.);
143  Nelecs_iso_ = dbe_->book1D("06_Nelecs_iso", "Number of isolated electrons", 20, 0., 10.);
144  Nelecs_charge_ = dbe_->book1D("Nelecs_charge", "Number of elecs * elec charge", 19, -10., 10.);
145  HoverE_elecs_ = dbe_->book1D("HoverE_elecs", "Hadronic over Ecal energy", 50, 0., 1.);
146  pT_elecs_ = dbe_->book1D("pT_elecs", "P_T of electrons", 40, 0., 200.);
147  eta_elecs_ = dbe_->book1D("eta_elecs", "Eta of electrons", 50, -5., 5.);
148  phi_elecs_ = dbe_->book1D("phi_elecs", "Phi of electrons", 40, -4., 4.);
149 
150  MuIso_emEt03_ = dbe_->book1D("MuIso_emEt03", "Muon emEt03", 20, 0., 20.);
151  MuIso_hadEt03_ = dbe_->book1D("MuIso_hadEt03", "Muon hadEt03", 20, 0., 20.);
152  MuIso_hoEt03_ = dbe_->book1D("MuIso_hoEt03", "Muon hoEt03", 20, 0., 20.);
153  MuIso_nJets03_ = dbe_->book1D("MuIso_nJets03", "Muon nJets03", 10, 0., 10.);
154  MuIso_nTracks03_ = dbe_->book1D("MuIso_nTracks03", "Muon nTracks03", 20, 0., 20.);
155  MuIso_sumPt03_ = dbe_->book1D("MuIso_sumPt03", "Muon sumPt03", 20, 0., 40.);
156  MuIso_CombRelIso03_ = dbe_->book1D("07_MuIso_CombRelIso03", "Muon CombRelIso03", 20, 0., 1.);
157 
158  ElecIso_cal_ = dbe_->book1D("ElecIso_cal", "Electron Iso_cal", 21, -1., 20.);
159  ElecIso_trk_ = dbe_->book1D("ElecIso_trk", "Electron Iso_trk", 21, -2., 40.);
160  ElecIso_CombRelIso_ = dbe_->book1D("08_ElecIso_CombRelIso", "Electron CombRelIso", 20, 0., 1.);
161 
162  const int nbins = 200;
163 
164  double logmin = 0.;
165  double logmax = 3.; // 10^(3.)=1000
166 
167  float bins[nbins+1];
168 
169  for (int i = 0; i <= nbins; i++) {
170 
171  double log = logmin + (logmax-logmin)*i/nbins;
172  bins[i] = std::pow(10.0, log);
173 
174  }
175 
176  dimassRC_ = dbe_->book1D("09_dimassRC", "Dilepton mass RC", 50, 0., 200.);
177  dimassWC_ = dbe_->book1D("11_dimassWC", "Dilepton mass WC", 50, 0., 200.);
178  dimassRC_LOGX_ = dbe_->book1D("10_dimassRC_LOGX", "Dilepton mass RC LOG", nbins, &bins[0]);
179  dimassWC_LOGX_ = dbe_->book1D("12_dimassWC_LOGX", "Dilepton mass WC LOG", nbins, &bins[0]);
180  dimassRC_LOG10_ = dbe_->book1D("dimassRC_LOG10", "Dilepton mass RC LOG", 50, 0., 2.5);
181  dimassWC_LOG10_ = dbe_->book1D("dimassWC_LOG10", "Dilepton mass WC LOG", 50, 0., 2.5);
182 
183  D_eta_muons_ = dbe_->book1D("13_D_eta_muons", "#Delta eta_muons", 20, -5., 5.);
184  D_phi_muons_ = dbe_->book1D("14_D_phi_muons", "#Delta phi_muons", 20, -5., 5.);
185  D_eta_elecs_ = dbe_->book1D("D_eta_elecs", "#Delta eta_elecs", 20, -5., 5.);
186  D_phi_elecs_ = dbe_->book1D("D_phi_elecs", "#Delta phi_elecs", 20, -5., 5.);
187  D_eta_lepts_ = dbe_->book1D("D_eta_lepts", "#Delta eta_lepts", 20, -5., 5.);
188  D_phi_lepts_ = dbe_->book1D("D_phi_lepts", "#Delta phi_lepts", 20, -5., 5.);
189 
190 }
191 
192 
193 void TopDiLeptonDQM::beginRun(const edm::Run& r, const edm::EventSetup& context) {
194 
195 }
196 
197 
198 void TopDiLeptonDQM::analyze(const edm::Event& evt, const edm::EventSetup& context) {
199 
200  // ------------------------
201  // Global Event Variables
202  // ------------------------
203 
204  const int N_TriggerPaths = hltPaths_.size();
205  const int N_SignalPaths = hltPaths_sig_.size();
206  const int N_ControlPaths = hltPaths_trig_.size();
207 
208  bool Fired_Signal_Trigger[100] = {false};
209  bool Fired_Control_Trigger[100] = {false};
210 
211  int N_run = (evt.id()).run();
212  int N_event = (evt.id()).event();
213  int N_lumi = evt.luminosityBlock();
214 
215  int N_leptons = 0;
216  int N_iso_mu = 0;
217  int N_iso_el = 0;
218  // int N_iso_lep = 0; // UNUSED
219 
220  double DilepMass = 0.;
221 
222  double vertex_X = 100.;
223  double vertex_Y = 100.;
224  double vertex_Z = 100.;
225 
226  // ------------------------
227  // Analyze Primary Vertex
228  // ------------------------
229 
231  evt.getByToken(vertex_, vertexs);
232 
233  if( vertexs.failedToGet() ) {
234 
235  // cout << endl << "----------------------------" << endl;
236  // cout << "--- NO PRIMARY VERTEX !! ---" << endl;
237  // cout << "----------------------------" << endl << endl;
238 
239  }
240 
241  if( !vertexs.failedToGet() ) {
242 
243  reco::Vertex primaryVertex = vertexs->front();
244 
245  int numberTracks = primaryVertex.tracksSize();
246  // double ndof = primaryVertex.ndof();
247  bool fake = primaryVertex.isFake();
248 
249  Ntracks_->Fill(numberTracks);
250 
251  if( !fake && numberTracks > 3 ) {
252 
253  vertex_X = primaryVertex.x();
254  vertex_Y = primaryVertex.y();
255  vertex_Z = primaryVertex.z();
256 
257  }
258 
259  }
260 
261  // -------------------------
262  // Analyze Trigger Results
263  // -------------------------
264 
265  edm::Handle<TriggerResults> trigResults;
266  evt.getByToken(triggerResults_, trigResults);
267 
268  if( trigResults.failedToGet() ) {
269 
270  // cout << endl << "-----------------------------" << endl;
271  // cout << "--- NO TRIGGER RESULTS !! ---" << endl;
272  // cout << "-----------------------------" << endl << endl;
273 
274  }
275 
276  if( !trigResults.failedToGet() ) {
277 
278  int N_Triggers = trigResults->size();
279 
280  const edm::TriggerNames & trigName = evt.triggerNames(*trigResults);
281 
282  for( int i_Trig = 0; i_Trig < N_Triggers; ++i_Trig ) {
283 
284  if (trigResults.product()->accept(i_Trig)) {
285 
286  // Check for all trigger paths
287 
288  for( int i = 0; i < N_TriggerPaths; i++ ) {
289 
290  if ( trigName.triggerName(i_Trig)== hltPaths_[i] ) {
291 
292  Trigs_->Fill(i);
293  Trigs_->setBinLabel( i+1, hltPaths_[i], 1);
294 
295  }
296 
297  }
298 
299  // Check for signal & control trigger paths
300 
301  for( int j = 0; j < N_SignalPaths; ++j ) {
302 
303  if( trigName.triggerName(i_Trig) == hltPaths_sig_[j] ) Fired_Signal_Trigger[j] = true;
304 
305  }
306 
307  for( int k = 0; k < N_ControlPaths; ++k ) {
308 
309  if( trigName.triggerName(i_Trig) == hltPaths_trig_[k] ) Fired_Control_Trigger[k] = true;
310 
311  }
312 
313  }
314 
315  }
316 
317  }
318 
319  // ------------------------
320  // Analyze Muon Isolation
321  // ------------------------
322 
324  evt.getByToken(muons_, muons);
325 
326  reco::MuonCollection::const_iterator muon;
327 
328  if( muons.failedToGet() ) {
329 
330  // cout << endl << "------------------------" << endl;
331  // cout << "--- NO RECO MUONS !! ---" << endl;
332  // cout << "------------------------" << endl << endl;
333 
334  }
335 
336  if( !muons.failedToGet() ) {
337 
338  Nmuons_->Fill( muons->size() );
339 
340  N_leptons = N_leptons + muons->size();
341 
342  for(muon = muons->begin(); muon!= muons->end(); ++muon) {
343 
344  float N_muons = muons->size();
345  float Q_muon = muon->charge();
346 
347  Nmuons_charge_->Fill(N_muons*Q_muon);
348 
349  double track_X = 100.;
350  double track_Y = 100.;
351  double track_Z = 100.;
352 
353  if( muon->isGlobalMuon() ) {
354 
355  reco::TrackRef track = muon->globalTrack();
356 
357  track_X = track->vx();
358  track_Y = track->vy();
359  track_Z = track->vz();
360 
361  VxVy_muons_->Fill(track_X, track_Y);
362  Vz_muons_->Fill(track_Z);
363 
364  }
365 
366  // Vertex and kinematic cuts
367 
368  if( track_X > vertex_X_cut_ ) continue;
369  if( track_Y > vertex_Y_cut_ ) continue;
370  if( track_Z > vertex_Z_cut_ ) continue;
371  if( muon->pt() < muon_pT_cut_ ) continue;
372  if( abs(muon->eta()) > muon_eta_cut_ ) continue;
373 
374  reco::MuonIsolation muIso03 = muon->isolationR03();
375 
376  double muonCombRelIso = 1.;
377 
378  if ( muon->pt() != 0. )
379  muonCombRelIso = ( muIso03.emEt + muIso03.hadEt + muIso03.hoEt + muIso03.sumPt ) / muon->pt();
380 
381  MuIso_CombRelIso03_->Fill( muonCombRelIso );
382 
383  MuIso_emEt03_->Fill( muIso03.emEt );
384  MuIso_hadEt03_->Fill( muIso03.hadEt );
385  MuIso_hoEt03_->Fill( muIso03.hoEt );
386  MuIso_nJets03_->Fill( muIso03.nJets );
387  MuIso_nTracks03_->Fill( muIso03.nTracks );
388  MuIso_sumPt03_->Fill( muIso03.sumPt );
389 
390  if( muonCombRelIso < muon_iso_cut_ ) ++N_iso_mu;
391 
392  }
393 
394  Nmuons_iso_->Fill(N_iso_mu);
395 
396  }
397 
398  // ----------------------------
399  // Analyze Electron Isolation
400  // ----------------------------
401 
403  evt.getByToken(elecs_, elecs);
404 
405  reco::GsfElectronCollection::const_iterator elec;
406 
407  if( elecs.failedToGet() ) {
408 
409  // cout << endl << "----------------------------" << endl;
410  // cout << "--- NO RECO ELECTRONS !! ---" << endl;
411  // cout << "----------------------------" << endl << endl;
412 
413  }
414 
415  if( !elecs.failedToGet() ) {
416 
417  Nelecs_->Fill( elecs->size() );
418 
419  N_leptons = N_leptons + elecs->size();
420 
421  for(elec = elecs->begin(); elec!= elecs->end(); ++elec) {
422 
423  float N_elecs = elecs->size();
424  float Q_elec = elec->charge();
425  float HoverE = elec->hcalOverEcal();
426 
427  HoverE_elecs_->Fill( HoverE );
428 
429  Nelecs_charge_->Fill(N_elecs*Q_elec);
430 
431  double track_X = 100.;
432  double track_Y = 100.;
433  double track_Z = 100.;
434 
435  reco::GsfTrackRef track = elec->gsfTrack();
436 
437  track_X = track->vx();
438  track_Y = track->vy();
439  track_Z = track->vz();
440 
441  // Vertex and kinematic cuts
442 
443  if( track_X > vertex_X_cut_ ) continue;
444  if( track_Y > vertex_Y_cut_ ) continue;
445  if( track_Z > vertex_Z_cut_ ) continue;
446  if( elec->pt() < elec_pT_cut_ ) continue;
447  if( abs(elec->eta()) > elec_eta_cut_ ) continue;
448  if( HoverE > elec_emf_cut_ ) continue;
449 
450  reco::GsfElectron::IsolationVariables elecIso = elec->dr03IsolationVariables();
451 
452  double elecCombRelIso = 1.;
453 
454  if ( elec->et() != 0. )
455  elecCombRelIso = ( elecIso.ecalRecHitSumEt + elecIso.hcalDepth1TowerSumEt + elecIso.tkSumPt ) / elec->et();
456 
457  ElecIso_CombRelIso_->Fill( elecCombRelIso );
458 
459  ElecIso_cal_->Fill( elecIso.ecalRecHitSumEt );
460  ElecIso_trk_->Fill( elecIso.tkSumPt );
461 
462  if( elecCombRelIso < elec_iso_cut_ ) ++N_iso_el;
463 
464  }
465 
466  Nelecs_iso_->Fill(N_iso_el);
467 
468  }
469 
470  // N_iso_lep = N_iso_el + N_iso_mu; // UNUSED
471 
472  // --------------------
473  // TWO Isolated MUONS
474  // --------------------
475 
476  // if( N_iso_mu > 1 && Fired_Control_Trigger[0] ) {
477  if( N_iso_mu > 1 ) {
478 
479  // Vertex cut
480 
481  if( vertex_X < vertex_X_cut_ && vertex_Y < vertex_Y_cut_ && vertex_Z < vertex_Z_cut_ ) {
482 
483  ++N_mumu;
484 
485  Events_->Fill(1.);
486 
487  reco::MuonCollection::const_reference mu1 = muons->at(0);
488  reco::MuonCollection::const_reference mu2 = muons->at(1);
489 
490  DilepMass = sqrt( (mu1.energy()+mu2.energy())*(mu1.energy()+mu2.energy())
491  - (mu1.px()+mu2.px())*(mu1.px()+mu2.px())
492  - (mu1.py()+mu2.py())*(mu1.py()+mu2.py())
493  - (mu1.pz()+mu2.pz())*(mu1.pz()+mu2.pz())
494  );
495 
496  // Opposite muon charges -> Right Charge (RC)
497 
498  if( mu1.charge()*mu2.charge() < 0. ) {
499 
500  dimassRC_LOG10_->Fill( log10(DilepMass) );
501  dimassRC_->Fill( DilepMass );
502  dimassRC_LOGX_->Fill( DilepMass );
503 
504  if( DilepMass > MassWindow_down_ && DilepMass < MassWindow_up_ ) {
505 
506  for(muon = muons->begin(); muon!= muons->end(); ++muon) {
507 
508  pT_muons_->Fill( muon->pt() );
509  eta_muons_->Fill( muon->eta() );
510  phi_muons_->Fill( muon->phi() );
511 
512  }
513 
514  D_eta_muons_->Fill(mu1.eta()-mu2.eta());
515  D_phi_muons_->Fill(mu1.phi()-mu2.phi());
516 
517  if(fileOutput_) {
518 
519  if( mu1.isGlobalMuon() && mu2.isGlobalMuon() ) {
520 
521  outfile << "--------------------" << "\n";
522  outfile << " Run : " << N_run << "\n";
523  outfile << " Event : " << N_event << "\n";
524  outfile << "LumiBlock : " << N_lumi << "\n";
525  outfile << " Type : mu mu" << "\n";
526  outfile << "--------------------" << "\n";
527  outfile << "DilepMass : " << DilepMass << "\n";
528  outfile << "Mu1 Pt : " << mu1.pt() << "\n";
529  outfile << "Mu1 Eta : " << mu1.eta() << "\n";
530  outfile << "Mu1 Phi : " << mu1.phi() << "\n";
531  outfile << "Mu2 Pt : " << mu2.pt() << "\n";
532  outfile << "Mu2 Eta : " << mu2.eta() << "\n";
533  outfile << "Mu2 Phi : " << mu2.phi() << "\n";
534  outfile << "--------------------" << "\n";
535 
536  }
537 
538  }
539 
540  // Determinating trigger efficiencies
541 
542  for( int k = 0; k < N_SignalPaths; ++k ) {
543 
544  if( Fired_Signal_Trigger[k] && Fired_Control_Trigger[k] ) ++N_sig[k];
545 
546  if( Fired_Control_Trigger[k] ) ++N_trig[k];
547 
548  if( N_trig[k] != 0 ) Eff[k] = N_sig[k]/static_cast<float>(N_trig[k]);
549 
550  TriggerEff_->setBinContent( k+1, Eff[k] );
551  TriggerEff_->setBinLabel( k+1, "#frac{["+hltPaths_sig_[k]+"]}{vs. ["+hltPaths_trig_[k]+"]}", 1);
552 
553  }
554 
555  }
556 
557  }
558 
559  // Same muon charges -> Wrong Charge (WC)
560 
561  if( mu1.charge()*mu2.charge() > 0. ) {
562 
563  dimassWC_LOG10_->Fill( log10(DilepMass) );
564  dimassWC_->Fill( DilepMass );
565  dimassWC_LOGX_->Fill( DilepMass );
566 
567  if(fileOutput_) {
568 
569  if( mu1.isGlobalMuon() && mu2.isGlobalMuon() ) {
570 
571  outfile << "---------------------" << "\n";
572  outfile << " Run : " << N_run << "\n";
573  outfile << " Event : " << N_event << "\n";
574  outfile << "LumiBlock : " << N_lumi << "\n";
575  outfile << " Type : WC mu mu" << "\n";
576  outfile << "---------------------" << "\n";
577  outfile << "DilepMass : " << DilepMass << "\n";
578  outfile << "Mu1 Pt : " << mu1.pt() << "\n";
579  outfile << "Mu1 Eta : " << mu1.eta() << "\n";
580  outfile << "Mu1 Phi : " << mu1.phi() << "\n";
581  outfile << "Mu2 Pt : " << mu2.pt() << "\n";
582  outfile << "Mu2 Eta : " << mu2.eta() << "\n";
583  outfile << "Mu2 Phi : " << mu2.phi() << "\n";
584  outfile << "---------------------" << "\n";
585 
586  }
587 
588  }
589 
590  }
591 
592  }
593 
594  }
595 
596  // -----------------------------
597  // TWO Isolated LEPTONS (mu/e)
598  // -----------------------------
599 
600  // if( N_iso_el > 0 && N_iso_mu > 0 && Fired_Control_Trigger[0] ) {
601  if( N_iso_el > 0 && N_iso_mu > 0 ) {
602 
603  // Vertex cut
604 
605  if( vertex_X < vertex_X_cut_ && vertex_Y < vertex_Y_cut_ && vertex_Z < vertex_Z_cut_ ) {
606 
607  ++N_muel;
608 
609  Events_->Fill(2.);
610 
611  reco::MuonCollection::const_reference mu1 = muons->at(0);
612  reco::GsfElectronCollection::const_reference el1 = elecs->at(0);
613 
614  DilepMass = sqrt( (mu1.energy()+el1.energy())*(mu1.energy()+el1.energy())
615  - (mu1.px()+el1.px())*(mu1.px()+el1.px())
616  - (mu1.py()+el1.py())*(mu1.py()+el1.py())
617  - (mu1.pz()+el1.pz())*(mu1.pz()+el1.pz())
618  );
619 
620  // Opposite lepton charges -> Right Charge (RC)
621 
622  if( mu1.charge()*el1.charge() < 0. ) {
623 
624  dimassRC_LOG10_->Fill( log10(DilepMass) );
625  dimassRC_->Fill( DilepMass );
626  dimassRC_LOGX_->Fill( DilepMass );
627 
628  if( DilepMass > MassWindow_down_ && DilepMass < MassWindow_up_ ) {
629 
630  for(muon = muons->begin(); muon!= muons->end(); ++muon) {
631 
632  pT_muons_->Fill( muon->pt() );
633  eta_muons_->Fill( muon->eta() );
634  phi_muons_->Fill( muon->phi() );
635 
636  }
637 
638  for(elec = elecs->begin(); elec!= elecs->end(); ++elec) {
639 
640  pT_elecs_->Fill( elec->pt() );
641  eta_elecs_->Fill( elec->eta() );
642  phi_elecs_->Fill( elec->phi() );
643 
644  }
645 
646  D_eta_lepts_->Fill(mu1.eta()-el1.eta());
647  D_phi_lepts_->Fill(mu1.phi()-el1.phi());
648 
649  if(fileOutput_) {
650 
651  if( mu1.isGlobalMuon() && el1.isElectron() ) {
652 
653  outfile << "--------------------" << "\n";
654  outfile << " Run : " << N_run << "\n";
655  outfile << " Event : " << N_event << "\n";
656  outfile << "LumiBlock : " << N_lumi << "\n";
657  outfile << " Type : mu el" << "\n";
658  outfile << "--------------------" << "\n";
659  outfile << "DilepMass : " << DilepMass << "\n";
660  outfile << "Mu1 Pt : " << mu1.pt() << "\n";
661  outfile << "Mu1 Eta : " << mu1.eta() << "\n";
662  outfile << "Mu1 Phi : " << mu1.phi() << "\n";
663  outfile << "El1 Pt : " << el1.pt() << "\n";
664  outfile << "El1 Eta : " << el1.eta() << "\n";
665  outfile << "El1 Phi : " << el1.phi() << "\n";
666  outfile << "--------------------" << "\n";
667 
668  }
669 
670  }
671 
672  // Determinating trigger efficiencies
673 
674  for( int k = 0; k < N_SignalPaths; ++k ) {
675 
676  if( Fired_Signal_Trigger[k] && Fired_Control_Trigger[k] ) ++N_sig[k];
677 
678  if( Fired_Control_Trigger[k] ) ++N_trig[k];
679 
680  if( N_trig[k] != 0 ) Eff[k] = N_sig[k]/static_cast<float>(N_trig[k]);
681 
682  TriggerEff_->setBinContent( k+1, Eff[k] );
683  TriggerEff_->setBinLabel( k+1, "#frac{["+hltPaths_sig_[k]+"]}{vs. ["+hltPaths_trig_[k]+"]}", 1);
684 
685  }
686 
687  }
688 
689  }
690 
691  // Same muon charges -> Wrong Charge (WC)
692 
693  if( mu1.charge()*el1.charge() > 0. ) {
694 
695  dimassWC_LOG10_->Fill( log10(DilepMass) );
696  dimassWC_->Fill( DilepMass );
697  dimassWC_LOGX_->Fill( DilepMass );
698 
699  }
700 
701  }
702 
703  }
704 
705  // ------------------------
706  // TWO Isolated ELECTRONS
707  // ------------------------
708 
709  // if( N_iso_el > 1 && Fired_Control_Trigger[0] ) {
710  if( N_iso_el > 1 ) {
711 
712  // Vertex cut
713 
714  if( vertex_X < vertex_X_cut_ && vertex_Y < vertex_Y_cut_ && vertex_Z < vertex_Z_cut_ ) {
715 
716  ++N_elel;
717 
718  Events_->Fill(3.);
719 
720  reco::GsfElectronCollection::const_reference el1 = elecs->at(0);
721  reco::GsfElectronCollection::const_reference el2 = elecs->at(1);
722 
723  DilepMass = sqrt( (el1.energy()+el2.energy())*(el1.energy()+el2.energy())
724  - (el1.px()+el2.px())*(el1.px()+el2.px())
725  - (el1.py()+el2.py())*(el1.py()+el2.py())
726  - (el1.pz()+el2.pz())*(el1.pz()+el2.pz())
727  );
728 
729  // Opposite lepton charges -> Right Charge (RC)
730 
731  if( el1.charge()*el2.charge() < 0. ) {
732 
733  dimassRC_LOG10_->Fill( log10(DilepMass) );
734  dimassRC_->Fill( DilepMass );
735  dimassRC_LOGX_->Fill( DilepMass );
736 
737  if( DilepMass > MassWindow_down_ && DilepMass < MassWindow_up_ ) {
738 
739  for(elec = elecs->begin(); elec!= elecs->end(); ++elec) {
740 
741  pT_elecs_->Fill( elec->pt() );
742  eta_elecs_->Fill( elec->eta() );
743  phi_elecs_->Fill( elec->phi() );
744 
745  }
746 
747  D_eta_elecs_->Fill(el1.eta()-el2.eta());
748  D_phi_elecs_->Fill(el1.phi()-el2.phi());
749 
750  if(fileOutput_) {
751 
752  if( el1.isElectron() && el2.isElectron() ) {
753 
754  outfile << "--------------------" << "\n";
755  outfile << " Run : " << N_run << "\n";
756  outfile << " Event : " << N_event << "\n";
757  outfile << "LumiBlock : " << N_lumi << "\n";
758  outfile << " Type : el el" << "\n";
759  outfile << "--------------------" << "\n";
760  outfile << "DilepMass : " << DilepMass << "\n";
761  outfile << "El1 Pt : " << el1.pt() << "\n";
762  outfile << "El1 Eta : " << el1.eta() << "\n";
763  outfile << "El1 Phi : " << el1.phi() << "\n";
764  outfile << "El2 Pt : " << el2.pt() << "\n";
765  outfile << "El2 Eta : " << el2.eta() << "\n";
766  outfile << "El2 Phi : " << el2.phi() << "\n";
767  outfile << "--------------------" << "\n";
768 
769  }
770 
771  }
772 
773  // Determinating trigger efficiencies
774 
775  for( int k = 0; k < N_SignalPaths; ++k ) {
776 
777  if( Fired_Signal_Trigger[k] && Fired_Control_Trigger[k] ) ++N_sig[k];
778 
779  if( Fired_Control_Trigger[k] ) ++N_trig[k];
780 
781  if( N_trig[k] != 0 ) Eff[k] = N_sig[k]/static_cast<float>(N_trig[k]);
782 
783  TriggerEff_->setBinContent( k+1, Eff[k] );
784  TriggerEff_->setBinLabel( k+1, "#frac{["+hltPaths_sig_[k]+"]}{vs. ["+hltPaths_trig_[k]+"]}", 1);
785 
786  }
787 
788  }
789 
790  }
791 
792  // Same muon charges -> Wrong Charge (WC)
793 
794  if( el1.charge()*el2.charge() > 0. ) {
795 
796  dimassWC_LOG10_->Fill( log10(DilepMass) );
797  dimassWC_->Fill( DilepMass );
798  dimassWC_LOGX_->Fill( DilepMass );
799 
800  }
801 
802  }
803 
804  }
805 
806 }
807 
808 
809 void TopDiLeptonDQM::endRun(const edm::Run& r, const edm::EventSetup& context) {
810 
811 }
812 
814 
815  if(fileOutput_) outfile.close();
816 
817 }
818 
819 // Local Variables:
820 // show-trailing-whitespace: t
821 // truncate-lines: t
822 // End:
virtual void endJob()
float hadEt
hcal sum-Et
Definition: MuonIsolation.h:9
T getParameter(std::string const &) const
static AlgebraicMatrix initialize()
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
void endRun(const edm::Run &, const edm::EventSetup &)
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
Definition: Event.cc:204
float sumPt
sum-pt of tracks
Definition: MuonIsolation.h:7
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:942
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
double y() const
y coordinate
Definition: Vertex.h:110
void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:59
TopDiLeptonDQM(const edm::ParameterSet &)
T sqrt(T t)
Definition: SSEVec.h:48
float emEt
ecal sum-Et
Definition: MuonIsolation.h:8
int nJets
number of jets in the cone
Definition: MuonIsolation.h:12
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int j
Definition: DBlmapReader.cc:9
double z() const
y coordinate
Definition: Vertex.h:112
float hoEt
ho sum-Et
Definition: MuonIsolation.h:10
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
DQMStore * dbe_
int k[5][pyjets_maxn]
void setTitle(const std::string &title)
set (ie. change) histogram/profile title
virtual void analyze(const edm::Event &, const edm::EventSetup &)
int nTracks
number of tracks in the cone (excluding veto region)
Definition: MuonIsolation.h:11
bool failedToGet() const
Definition: HandleBase.h:80
double x() const
x coordinate
Definition: Vertex.h:108
bool isFake() const
Definition: Vertex.h:64
std::string const & triggerName(unsigned int index) const
Definition: TriggerNames.cc:27
T const * product() const
Definition: Handle.h:81
virtual void beginJob()
edm::EventID id() const
Definition: EventBase.h:56
tuple muons
Definition: patZpeak.py:38
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
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:655
size_t tracksSize() const
number of tracks
Definition: Vertex.cc:34
Definition: Run.h:41
void beginRun(const edm::Run &, const edm::EventSetup &)