CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/DQM/Physics/src/TopDiLeptonDQM.cc

Go to the documentation of this file.
00001 /*
00002  *  $Date: 2010/05/12 15:49:56 $
00003  *  $Revision: 1.12 $
00004  *  \author M. Marienfeld - DESY Hamburg
00005  */
00006 
00007 #include "TLorentzVector.h"
00008 #include "DataFormats/Math/interface/deltaR.h"
00009 #include "DQM/Physics/src/TopDiLeptonDQM.h"
00010 #include "FWCore/Common/interface/TriggerNames.h"
00011 
00012 using namespace std;
00013 using namespace edm;
00014 
00015 TopDiLeptonDQM::TopDiLeptonDQM( const edm::ParameterSet& ps ) {
00016 
00017   initialize();
00018 
00019   moduleName_      = ps.getUntrackedParameter<string>("moduleName");
00020   fileOutput_      = ps.getParameter<bool>("fileOutput");
00021   outputFile_      = ps.getUntrackedParameter<string>("outputFile");
00022   triggerResults_  = ps.getParameter<edm::InputTag>("TriggerResults");
00023   hltPaths_        = ps.getParameter<vector<string> >("hltPaths");
00024   hltPaths_sig_    = ps.getParameter<vector<string> >("hltPaths_sig");
00025   hltPaths_trig_   = ps.getParameter<vector<string> >("hltPaths_trig");
00026 
00027   vertex_          = ps.getParameter<edm::InputTag>("vertexCollection");
00028   vertex_X_cut_    = ps.getParameter<double>("vertex_X_cut");
00029   vertex_Y_cut_    = ps.getParameter<double>("vertex_Y_cut");
00030   vertex_Z_cut_    = ps.getParameter<double>("vertex_Z_cut");
00031 
00032   muons_           = ps.getParameter<edm::InputTag>("muonCollection");
00033   muon_pT_cut_     = ps.getParameter<double>("muon_pT_cut");
00034   muon_eta_cut_    = ps.getParameter<double>("muon_eta_cut");
00035   muon_iso_cut_    = ps.getParameter<double>("muon_iso_cut");
00036 
00037   elecs_           = ps.getParameter<edm::InputTag>("elecCollection");
00038   elec_pT_cut_     = ps.getParameter<double>("elec_pT_cut");
00039   elec_eta_cut_    = ps.getParameter<double>("elec_eta_cut");
00040   elec_iso_cut_    = ps.getParameter<double>("elec_iso_cut");
00041   elec_emf_cut_    = ps.getParameter<double>("elec_emf_cut");
00042 
00043   MassWindow_up_   = ps.getParameter<double>("MassWindow_up");
00044   MassWindow_down_ = ps.getParameter<double>("MassWindow_down");
00045 
00046   for(int i=0; i<100; ++i) {
00047     N_sig[i]  = 0;
00048     N_trig[i] = 0;
00049     Eff[i]    = 0.;
00050   }
00051 
00052   N_mumu = 0;
00053   N_muel = 0;
00054   N_elel = 0;
00055 
00056 
00057   if( fileOutput_ ) {
00058     const char *fileName = outputFile_.c_str();
00059     outfile.open (fileName);
00060   }
00061 
00062 }
00063 
00064 
00065 TopDiLeptonDQM::~TopDiLeptonDQM() {
00066 
00067 }
00068 
00069 
00070 void TopDiLeptonDQM::initialize() {
00071 
00072 }
00073 
00074 
00075 void TopDiLeptonDQM::beginJob() {
00076 
00077   dbe_ = Service<DQMStore>().operator->();
00078 
00079   dbe_->setCurrentFolder(moduleName_);
00080 
00081   Events_     = dbe_->book1D("00_Events", "Isolated dilepton events", 5,  0.,  5.);
00082   Events_->setBinLabel( 2, "#mu #mu", 1);
00083   Events_->setBinLabel( 3, "#mu e",   1);
00084   Events_->setBinLabel( 4, "e e",     1);
00085 
00086   Trigs_      = dbe_->book1D("01_Trigs",      "Fired muon/electron triggers", 15,  0., 15.);
00087   TriggerEff_ = dbe_->book1D("02_TriggerEff", "HL Trigger Efficiencies",      10,  0., 10.);
00088   TriggerEff_->setTitle("HL Trigger Efficiencies #epsilon_{signal} = #frac{[signal] && [control]}{[control]}");
00089   Ntracks_    = dbe_->book1D("Ntracks",       "Number of tracks",             50,  0., 50.);
00090 
00091   Nmuons_        = dbe_->book1D("03_Nmuons",     "Number of muons",               20,   0.,  10.);
00092   Nmuons_iso_    = dbe_->book1D("04_Nmuons_iso", "Number of isolated muons",      20,   0.,  10.);
00093   Nmuons_charge_ = dbe_->book1D("Nmuons_charge", "Number of muons * moun charge", 19, -10.,  10.);
00094   VxVy_muons_    = dbe_->book2D("VxVy_muons",    "Vertex x-y-positon (global)",   40,  -1.,   1., 40 , -1., 1.);
00095   Vz_muons_      = dbe_->book1D("Vz_muons",      "Vertex z-positon (global)",     40, -20.,  20.);
00096   pT_muons_      = dbe_->book1D("pT_muons",      "P_T of muons",                  40,   0., 200.);
00097   eta_muons_     = dbe_->book1D("eta_muons",     "Eta of muons",                  50,  -5.,   5.);
00098   phi_muons_     = dbe_->book1D("phi_muons",     "Phi of muons",                  40,  -4.,   4.);
00099 
00100   Nelecs_        = dbe_->book1D("05_Nelecs",     "Number of electrons",           20,   0.,  10.);
00101   Nelecs_iso_    = dbe_->book1D("06_Nelecs_iso", "Number of isolated electrons",  20,   0.,  10.);
00102   Nelecs_charge_ = dbe_->book1D("Nelecs_charge", "Number of elecs * elec charge", 19, -10.,  10.);
00103   HoverE_elecs_  = dbe_->book1D("HoverE_elecs",  "Hadronic over Ecal energy",     50,   0.,   1.);
00104   pT_elecs_      = dbe_->book1D("pT_elecs",      "P_T of electrons",              40,   0., 200.);
00105   eta_elecs_     = dbe_->book1D("eta_elecs",     "Eta of electrons",              50,  -5.,   5.);
00106   phi_elecs_     = dbe_->book1D("phi_elecs",     "Phi of electrons",              40,  -4.,   4.);
00107 
00108   MuIso_emEt03_       = dbe_->book1D("MuIso_emEt03",          "Muon emEt03",       20, 0., 20.);
00109   MuIso_hadEt03_      = dbe_->book1D("MuIso_hadEt03",         "Muon hadEt03",      20, 0., 20.);
00110   MuIso_hoEt03_       = dbe_->book1D("MuIso_hoEt03",          "Muon hoEt03",       20, 0., 20.);
00111   MuIso_nJets03_      = dbe_->book1D("MuIso_nJets03",         "Muon nJets03",      10, 0., 10.);
00112   MuIso_nTracks03_    = dbe_->book1D("MuIso_nTracks03",       "Muon nTracks03",    20, 0., 20.);
00113   MuIso_sumPt03_      = dbe_->book1D("MuIso_sumPt03",         "Muon sumPt03",      20, 0., 40.);
00114   MuIso_CombRelIso03_ = dbe_->book1D("07_MuIso_CombRelIso03", "Muon CombRelIso03", 20, 0.,  1.);
00115 
00116   ElecIso_cal_        = dbe_->book1D("ElecIso_cal",           "Electron Iso_cal",    21, -1., 20.);
00117   ElecIso_trk_        = dbe_->book1D("ElecIso_trk",           "Electron Iso_trk",    21, -2., 40.);
00118   ElecIso_CombRelIso_ = dbe_->book1D("08_ElecIso_CombRelIso", "Electron CombRelIso", 20,  0.,  1.);
00119 
00120   const int nbins = 200;
00121 
00122   double logmin = 0.;
00123   double logmax = 3.;  // 10^(3.)=1000
00124 
00125   float bins[nbins+1];
00126 
00127   for (int i = 0; i <= nbins; i++) {
00128 
00129     double log = logmin + (logmax-logmin)*i/nbins;
00130     bins[i] = std::pow(10.0, log);
00131 
00132   }
00133 
00134   dimassRC_       = dbe_->book1D("09_dimassRC",      "Dilepton mass RC",        50, 0., 200.);
00135   dimassWC_       = dbe_->book1D("11_dimassWC",      "Dilepton mass WC",        50, 0., 200.);
00136   dimassRC_LOGX_  = dbe_->book1D("10_dimassRC_LOGX", "Dilepton mass RC LOG", nbins, &bins[0]);
00137   dimassWC_LOGX_  = dbe_->book1D("12_dimassWC_LOGX", "Dilepton mass WC LOG", nbins, &bins[0]);
00138   dimassRC_LOG10_ = dbe_->book1D("dimassRC_LOG10",   "Dilepton mass RC LOG",    50, 0.,  2.5);
00139   dimassWC_LOG10_ = dbe_->book1D("dimassWC_LOG10",   "Dilepton mass WC LOG",    50, 0.,  2.5);
00140 
00141   D_eta_muons_  = dbe_->book1D("13_D_eta_muons", "#Delta eta_muons", 20, -5., 5.);
00142   D_phi_muons_  = dbe_->book1D("14_D_phi_muons", "#Delta phi_muons", 20, -5., 5.);
00143   D_eta_elecs_  = dbe_->book1D("D_eta_elecs",    "#Delta eta_elecs", 20, -5., 5.);
00144   D_phi_elecs_  = dbe_->book1D("D_phi_elecs",    "#Delta phi_elecs", 20, -5., 5.);
00145   D_eta_lepts_  = dbe_->book1D("D_eta_lepts",    "#Delta eta_lepts", 20, -5., 5.);
00146   D_phi_lepts_  = dbe_->book1D("D_phi_lepts",    "#Delta phi_lepts", 20, -5., 5.);
00147 
00148 }
00149 
00150 
00151 void TopDiLeptonDQM::beginRun(const edm::Run& r, const edm::EventSetup& context) {
00152 
00153 }
00154 
00155 
00156 void TopDiLeptonDQM::analyze(const edm::Event& evt, const edm::EventSetup& context) {
00157 
00158   // ------------------------
00159   //  Global Event Variables
00160   // ------------------------
00161 
00162   const int N_TriggerPaths = hltPaths_.size();
00163   const int N_SignalPaths  = hltPaths_sig_.size();
00164   const int N_ControlPaths = hltPaths_trig_.size();
00165 
00166   bool Fired_Signal_Trigger[100]  = {false};
00167   bool Fired_Control_Trigger[100] = {false};
00168 
00169   int N_run   = (evt.id()).run();
00170   int N_event = (evt.id()).event();
00171   int N_lumi  =  evt.luminosityBlock();
00172 
00173   int N_leptons = 0;
00174   int N_iso_mu  = 0;
00175   int N_iso_el  = 0;
00176   int N_iso_lep = 0;
00177 
00178   double DilepMass = 0.;
00179 
00180   double vertex_X  = 100.;
00181   double vertex_Y  = 100.;
00182   double vertex_Z  = 100.;
00183 
00184   // ------------------------
00185   //  Analyze Primary Vertex
00186   // ------------------------
00187 
00188   edm::Handle<reco::VertexCollection> vertexs;
00189   evt.getByLabel(vertex_, vertexs);
00190 
00191   if( vertexs.failedToGet() ) {
00192 
00193     //    cout << endl << "----------------------------" << endl;
00194     //    cout << "--- NO PRIMARY VERTEX !! ---" << endl;
00195     //    cout << "----------------------------" << endl << endl;
00196 
00197   }
00198 
00199   if( !vertexs.failedToGet() ) {
00200 
00201     reco::Vertex primaryVertex = vertexs->front();
00202 
00203     int numberTracks = primaryVertex.tracksSize();
00204     //    double ndof      = primaryVertex.ndof();
00205     bool fake        = primaryVertex.isFake();
00206 
00207     Ntracks_->Fill(numberTracks);
00208 
00209     if( !fake && numberTracks > 3 ) {
00210 
00211       vertex_X = primaryVertex.x();
00212       vertex_Y = primaryVertex.y();
00213       vertex_Z = primaryVertex.z();
00214 
00215     }
00216 
00217   }
00218 
00219   // -------------------------
00220   //  Analyze Trigger Results
00221   // -------------------------
00222 
00223   edm::Handle<TriggerResults> trigResults;
00224   evt.getByLabel(triggerResults_, trigResults);
00225 
00226   if( trigResults.failedToGet() ) {
00227 
00228     //    cout << endl << "-----------------------------" << endl;
00229     //    cout << "--- NO TRIGGER RESULTS !! ---" << endl;
00230     //    cout << "-----------------------------" << endl << endl;
00231 
00232   }
00233 
00234   if( !trigResults.failedToGet() ) {
00235 
00236     int N_Triggers = trigResults->size();
00237 
00238     const edm::TriggerNames & trigName = evt.triggerNames(*trigResults);
00239 
00240     for( int i_Trig = 0; i_Trig < N_Triggers; ++i_Trig ) {
00241 
00242       if (trigResults.product()->accept(i_Trig)) {
00243 
00244         // Check for all trigger paths
00245 
00246         for( int i = 0; i < N_TriggerPaths; i++ ) {
00247 
00248           if ( trigName.triggerName(i_Trig)== hltPaths_[i] ) {
00249 
00250             Trigs_->Fill(i);
00251             Trigs_->setBinLabel( i+1, hltPaths_[i], 1);
00252 
00253           }
00254 
00255         }
00256 
00257         // Check for signal & control trigger paths
00258 
00259         for( int j = 0; j < N_SignalPaths; ++j ) {
00260 
00261           if( trigName.triggerName(i_Trig) == hltPaths_sig_[j]  )  Fired_Signal_Trigger[j]  = true;
00262 
00263         }
00264 
00265         for( int k = 0; k < N_ControlPaths; ++k ) {
00266 
00267           if( trigName.triggerName(i_Trig) == hltPaths_trig_[k] )  Fired_Control_Trigger[k] = true;
00268 
00269         }
00270 
00271       }
00272 
00273     }
00274 
00275   }
00276 
00277   // ------------------------
00278   //  Analyze Muon Isolation
00279   // ------------------------
00280 
00281   edm::Handle<reco::MuonCollection> muons;
00282   evt.getByLabel(muons_, muons);
00283 
00284   reco::MuonCollection::const_iterator muon;
00285 
00286   if( muons.failedToGet() ) {
00287 
00288     //    cout << endl << "------------------------" << endl;
00289     //    cout << "--- NO RECO MUONS !! ---" << endl;
00290     //    cout << "------------------------" << endl << endl;
00291 
00292   }
00293 
00294   if( !muons.failedToGet() ) {
00295 
00296     Nmuons_->Fill( muons->size() );
00297 
00298     N_leptons = N_leptons + muons->size();
00299 
00300     for(muon = muons->begin(); muon!= muons->end(); ++muon) {
00301 
00302       float  N_muons = muons->size();
00303       float  Q_muon  = muon->charge();
00304 
00305       Nmuons_charge_->Fill(N_muons*Q_muon);
00306 
00307       double track_X = 100.;
00308       double track_Y = 100.;
00309       double track_Z = 100.;
00310 
00311       if( muon->isGlobalMuon() ) {
00312 
00313         reco::TrackRef track = muon->globalTrack();
00314 
00315         track_X = track->vx();
00316         track_Y = track->vy();
00317         track_Z = track->vz();
00318 
00319         VxVy_muons_->Fill(track_X, track_Y);
00320         Vz_muons_->Fill(track_Z);
00321 
00322       }
00323 
00324       // Vertex and kinematic cuts
00325 
00326       if(          track_X > vertex_X_cut_ )  continue;
00327       if(          track_Y > vertex_Y_cut_ )  continue;
00328       if(          track_Z > vertex_Z_cut_ )  continue;
00329       if(     muon->pt()   < muon_pT_cut_  )  continue;
00330       if( abs(muon->eta()) > muon_eta_cut_ )  continue;
00331 
00332       reco::MuonIsolation muIso03 = muon->isolationR03();
00333 
00334       double muonCombRelIso = 1.;
00335 
00336       if ( muon->pt() != 0. )
00337         muonCombRelIso = ( muIso03.emEt + muIso03.hadEt + muIso03.hoEt + muIso03.sumPt ) / muon->pt();
00338 
00339       MuIso_CombRelIso03_->Fill( muonCombRelIso );
00340 
00341       MuIso_emEt03_->Fill(    muIso03.emEt );
00342       MuIso_hadEt03_->Fill(   muIso03.hadEt );
00343       MuIso_hoEt03_->Fill(    muIso03.hoEt );
00344       MuIso_nJets03_->Fill(   muIso03.nJets );
00345       MuIso_nTracks03_->Fill( muIso03.nTracks );
00346       MuIso_sumPt03_->Fill(   muIso03.sumPt );
00347 
00348       if( muonCombRelIso < muon_iso_cut_ )  ++N_iso_mu;
00349 
00350     }
00351 
00352     Nmuons_iso_->Fill(N_iso_mu);
00353 
00354   }
00355 
00356   // ----------------------------
00357   //  Analyze Electron Isolation
00358   // ----------------------------
00359 
00360   edm::Handle<reco::GsfElectronCollection> elecs;
00361   evt.getByLabel(elecs_, elecs);
00362 
00363   reco::GsfElectronCollection::const_iterator elec;
00364 
00365   if( elecs.failedToGet() ) {
00366 
00367     //    cout << endl << "----------------------------" << endl;
00368     //    cout << "--- NO RECO ELECTRONS !! ---" << endl;
00369     //    cout << "----------------------------" << endl << endl;
00370 
00371   }
00372 
00373   if( !elecs.failedToGet() ) {
00374 
00375     Nelecs_->Fill( elecs->size() );
00376 
00377     N_leptons = N_leptons + elecs->size();
00378 
00379     for(elec = elecs->begin(); elec!= elecs->end(); ++elec) {
00380 
00381       float N_elecs = elecs->size();
00382       float Q_elec  = elec->charge();
00383       float HoverE  = elec->hcalOverEcal();
00384 
00385       HoverE_elecs_->Fill( HoverE );
00386 
00387       Nelecs_charge_->Fill(N_elecs*Q_elec);
00388 
00389       double track_X = 100.;
00390       double track_Y = 100.;
00391       double track_Z = 100.;
00392 
00393       reco::GsfTrackRef track = elec->gsfTrack();
00394 
00395       track_X = track->vx();
00396       track_Y = track->vy();
00397       track_Z = track->vz();
00398 
00399       // Vertex and kinematic cuts
00400 
00401       if(          track_X > vertex_X_cut_ )  continue;
00402       if(          track_Y > vertex_Y_cut_ )  continue;
00403       if(          track_Z > vertex_Z_cut_ )  continue;
00404       if(     elec->pt()   < elec_pT_cut_  )  continue;
00405       if( abs(elec->eta()) > elec_eta_cut_ )  continue;
00406       if(           HoverE > elec_emf_cut_ )  continue;
00407 
00408       reco::GsfElectron::IsolationVariables elecIso = elec->dr03IsolationVariables();
00409 
00410       double elecCombRelIso = 1.;
00411 
00412       if ( elec->et() != 0. )
00413         elecCombRelIso = ( elecIso.ecalRecHitSumEt + elecIso.hcalDepth1TowerSumEt + elecIso.tkSumPt ) / elec->et();
00414 
00415       ElecIso_CombRelIso_->Fill( elecCombRelIso );
00416 
00417       ElecIso_cal_->Fill( elecIso.ecalRecHitSumEt );
00418       ElecIso_trk_->Fill( elecIso.tkSumPt );
00419 
00420       if( elecCombRelIso < elec_iso_cut_ )  ++N_iso_el;
00421 
00422     }
00423 
00424     Nelecs_iso_->Fill(N_iso_el);
00425 
00426   }
00427 
00428   N_iso_lep = N_iso_el + N_iso_mu;
00429 
00430   // --------------------
00431   //  TWO Isolated MUONS
00432   // --------------------
00433 
00434   //  if( N_iso_mu > 1 && Fired_Control_Trigger[0] ) {
00435   if( N_iso_mu > 1 ) {
00436 
00437     // Vertex cut
00438 
00439     if( vertex_X < vertex_X_cut_ && vertex_Y < vertex_Y_cut_ && vertex_Z < vertex_Z_cut_ ) {
00440 
00441       ++N_mumu;
00442 
00443       Events_->Fill(1.);
00444 
00445       reco::MuonCollection::const_reference mu1 = muons->at(0);
00446       reco::MuonCollection::const_reference mu2 = muons->at(1);
00447 
00448       DilepMass = sqrt( (mu1.energy()+mu2.energy())*(mu1.energy()+mu2.energy())
00449                         - (mu1.px()+mu2.px())*(mu1.px()+mu2.px())
00450                         - (mu1.py()+mu2.py())*(mu1.py()+mu2.py())
00451                         - (mu1.pz()+mu2.pz())*(mu1.pz()+mu2.pz())
00452                         );
00453 
00454       // Opposite muon charges -> Right Charge (RC)
00455 
00456       if( mu1.charge()*mu2.charge() < 0. ) {
00457 
00458         dimassRC_LOG10_->Fill( log10(DilepMass) );
00459         dimassRC_->Fill(      DilepMass );
00460         dimassRC_LOGX_->Fill( DilepMass );
00461 
00462         if( DilepMass > MassWindow_down_ && DilepMass < MassWindow_up_ ) {
00463 
00464           for(muon = muons->begin(); muon!= muons->end(); ++muon) {
00465 
00466             pT_muons_->Fill(  muon->pt() );
00467             eta_muons_->Fill( muon->eta() );
00468             phi_muons_->Fill( muon->phi() );
00469 
00470           }
00471 
00472           D_eta_muons_->Fill(mu1.eta()-mu2.eta());
00473           D_phi_muons_->Fill(mu1.phi()-mu2.phi());
00474 
00475           if(fileOutput_) {
00476 
00477             if( mu1.isGlobalMuon() && mu2.isGlobalMuon() ) {
00478 
00479               outfile << "--------------------" << "\n";
00480               outfile << "      Run : " << N_run   << "\n";
00481               outfile << "    Event : " << N_event << "\n";
00482               outfile << "LumiBlock : " << N_lumi  << "\n";
00483               outfile << "     Type :  mu mu" << "\n";
00484               outfile << "--------------------" << "\n";
00485               outfile << "DilepMass : " << DilepMass << "\n";
00486               outfile << "Mu1 Pt    : " << mu1.pt() << "\n";
00487               outfile << "Mu1 Eta   : " << mu1.eta() << "\n";
00488               outfile << "Mu1 Phi   : " << mu1.phi() << "\n";
00489               outfile << "Mu2 Pt    : " << mu2.pt() << "\n";
00490               outfile << "Mu2 Eta   : " << mu2.eta() << "\n";
00491               outfile << "Mu2 Phi   : " << mu2.phi() << "\n";
00492               outfile << "--------------------" << "\n";
00493 
00494             }
00495 
00496           }
00497 
00498           // Determinating trigger efficiencies
00499 
00500           for( int k = 0; k < N_SignalPaths; ++k ) {
00501 
00502             if( Fired_Signal_Trigger[k] && Fired_Control_Trigger[k] )  ++N_sig[k];
00503 
00504             if( Fired_Control_Trigger[k] )  ++N_trig[k];
00505 
00506             if( N_trig[k] != 0 )  Eff[k] = N_sig[k]/static_cast<float>(N_trig[k]);
00507 
00508             TriggerEff_->setBinContent( k+1, Eff[k] );
00509             TriggerEff_->setBinLabel( k+1, "#frac{["+hltPaths_sig_[k]+"]}{vs. ["+hltPaths_trig_[k]+"]}", 1);
00510 
00511           }
00512 
00513         }
00514 
00515       }
00516 
00517       // Same muon charges -> Wrong Charge (WC)
00518 
00519       if( mu1.charge()*mu2.charge() > 0. ) {
00520 
00521         dimassWC_LOG10_->Fill( log10(DilepMass) );
00522         dimassWC_->Fill(      DilepMass );
00523         dimassWC_LOGX_->Fill( DilepMass );
00524 
00525         if(fileOutput_) {
00526 
00527           if( mu1.isGlobalMuon() && mu2.isGlobalMuon() ) {
00528 
00529             outfile << "---------------------" << "\n";
00530             outfile << "      Run : " << N_run   << "\n";
00531             outfile << "    Event : " << N_event << "\n";
00532             outfile << "LumiBlock : " << N_lumi  << "\n";
00533             outfile << "     Type :  WC mu mu" << "\n";
00534             outfile << "---------------------" << "\n";
00535             outfile << "DilepMass : " << DilepMass << "\n";
00536             outfile << "Mu1 Pt    : " << mu1.pt() << "\n";
00537             outfile << "Mu1 Eta   : " << mu1.eta() << "\n";
00538             outfile << "Mu1 Phi   : " << mu1.phi() << "\n";
00539             outfile << "Mu2 Pt    : " << mu2.pt() << "\n";
00540             outfile << "Mu2 Eta   : " << mu2.eta() << "\n";
00541             outfile << "Mu2 Phi   : " << mu2.phi() << "\n";
00542             outfile << "---------------------" << "\n";
00543 
00544           }
00545 
00546         }
00547 
00548       }
00549 
00550     }
00551 
00552   }
00553 
00554   // -----------------------------
00555   //  TWO Isolated LEPTONS (mu/e)
00556   // -----------------------------
00557 
00558   //  if( N_iso_el > 0 && N_iso_mu > 0 && Fired_Control_Trigger[0] ) {
00559   if( N_iso_el > 0 && N_iso_mu > 0 ) {
00560 
00561     // Vertex cut
00562 
00563     if( vertex_X < vertex_X_cut_ && vertex_Y < vertex_Y_cut_ && vertex_Z < vertex_Z_cut_ ) {
00564 
00565       ++N_muel;
00566 
00567       Events_->Fill(2.);
00568 
00569       reco::MuonCollection::const_reference        mu1 = muons->at(0);
00570       reco::GsfElectronCollection::const_reference el1 = elecs->at(0);
00571 
00572       DilepMass = sqrt( (mu1.energy()+el1.energy())*(mu1.energy()+el1.energy())
00573                         - (mu1.px()+el1.px())*(mu1.px()+el1.px())
00574                         - (mu1.py()+el1.py())*(mu1.py()+el1.py())
00575                         - (mu1.pz()+el1.pz())*(mu1.pz()+el1.pz())
00576                         );
00577 
00578       // Opposite lepton charges -> Right Charge (RC)
00579 
00580       if( mu1.charge()*el1.charge() < 0. ) {
00581 
00582         dimassRC_LOG10_->Fill( log10(DilepMass) );
00583         dimassRC_->Fill(      DilepMass );
00584         dimassRC_LOGX_->Fill( DilepMass );
00585 
00586         if( DilepMass > MassWindow_down_ && DilepMass < MassWindow_up_ ) {
00587 
00588           for(muon = muons->begin(); muon!= muons->end(); ++muon) {
00589 
00590             pT_muons_->Fill(  muon->pt() );
00591             eta_muons_->Fill( muon->eta() );
00592             phi_muons_->Fill( muon->phi() );
00593 
00594           }
00595 
00596           for(elec = elecs->begin(); elec!= elecs->end(); ++elec) {
00597 
00598             pT_elecs_->Fill(  elec->pt() );
00599             eta_elecs_->Fill( elec->eta() );
00600             phi_elecs_->Fill( elec->phi() );
00601 
00602           }
00603 
00604           D_eta_lepts_->Fill(mu1.eta()-el1.eta());
00605           D_phi_lepts_->Fill(mu1.phi()-el1.phi());
00606 
00607           if(fileOutput_) {
00608 
00609             if( mu1.isGlobalMuon() && el1.isElectron() ) {
00610 
00611               outfile << "--------------------" << "\n";
00612               outfile << "      Run : " << N_run   << "\n";
00613               outfile << "    Event : " << N_event << "\n";
00614               outfile << "LumiBlock : " << N_lumi  << "\n";
00615               outfile << "     Type :  mu el" << "\n";
00616               outfile << "--------------------" << "\n";
00617               outfile << "DilepMass : " << DilepMass << "\n";
00618               outfile << "Mu1 Pt    : " << mu1.pt() << "\n";
00619               outfile << "Mu1 Eta   : " << mu1.eta() << "\n";
00620               outfile << "Mu1 Phi   : " << mu1.phi() << "\n";
00621               outfile << "El1 Pt    : " << el1.pt() << "\n";
00622               outfile << "El1 Eta   : " << el1.eta() << "\n";
00623               outfile << "El1 Phi   : " << el1.phi() << "\n";
00624               outfile << "--------------------" << "\n";
00625 
00626             }
00627 
00628           }
00629 
00630           // Determinating trigger efficiencies
00631 
00632           for( int k = 0; k < N_SignalPaths; ++k ) {
00633 
00634             if( Fired_Signal_Trigger[k] && Fired_Control_Trigger[k] )  ++N_sig[k];
00635 
00636             if( Fired_Control_Trigger[k] )  ++N_trig[k];
00637 
00638             if( N_trig[k] != 0 )  Eff[k] = N_sig[k]/static_cast<float>(N_trig[k]);
00639 
00640             TriggerEff_->setBinContent( k+1, Eff[k] );
00641             TriggerEff_->setBinLabel( k+1, "#frac{["+hltPaths_sig_[k]+"]}{vs. ["+hltPaths_trig_[k]+"]}", 1);
00642 
00643           }
00644 
00645         }
00646 
00647       }
00648 
00649       // Same muon charges -> Wrong Charge (WC)
00650 
00651       if( mu1.charge()*el1.charge() > 0. ) {
00652 
00653         dimassWC_LOG10_->Fill( log10(DilepMass) );
00654         dimassWC_->Fill(      DilepMass );
00655         dimassWC_LOGX_->Fill( DilepMass );
00656 
00657       }
00658 
00659     }
00660 
00661   }
00662 
00663   // ------------------------
00664   //  TWO Isolated ELECTRONS
00665   // ------------------------
00666 
00667   //  if( N_iso_el > 1 && Fired_Control_Trigger[0] ) {
00668   if( N_iso_el > 1 ) {
00669 
00670     // Vertex cut
00671 
00672     if( vertex_X < vertex_X_cut_ && vertex_Y < vertex_Y_cut_ && vertex_Z < vertex_Z_cut_ ) {
00673 
00674       ++N_elel;
00675 
00676       Events_->Fill(3.);
00677 
00678       reco::GsfElectronCollection::const_reference el1 = elecs->at(0);
00679       reco::GsfElectronCollection::const_reference el2 = elecs->at(1);
00680 
00681       DilepMass = sqrt( (el1.energy()+el2.energy())*(el1.energy()+el2.energy())
00682                         - (el1.px()+el2.px())*(el1.px()+el2.px())
00683                         - (el1.py()+el2.py())*(el1.py()+el2.py())
00684                         - (el1.pz()+el2.pz())*(el1.pz()+el2.pz())
00685                         );
00686 
00687       // Opposite lepton charges -> Right Charge (RC)
00688 
00689       if( el1.charge()*el2.charge() < 0. ) {
00690 
00691         dimassRC_LOG10_->Fill( log10(DilepMass) );
00692         dimassRC_->Fill(      DilepMass );
00693         dimassRC_LOGX_->Fill( DilepMass );
00694 
00695         if( DilepMass > MassWindow_down_ && DilepMass < MassWindow_up_ ) {
00696 
00697           for(elec = elecs->begin(); elec!= elecs->end(); ++elec) {
00698 
00699             pT_elecs_->Fill(  elec->pt() );
00700             eta_elecs_->Fill( elec->eta() );
00701             phi_elecs_->Fill( elec->phi() );
00702 
00703           }
00704 
00705           D_eta_elecs_->Fill(el1.eta()-el2.eta());
00706           D_phi_elecs_->Fill(el1.phi()-el2.phi());
00707 
00708           if(fileOutput_) {
00709 
00710             if( el1.isElectron() && el2.isElectron() ) {
00711 
00712               outfile << "--------------------" << "\n";
00713               outfile << "      Run : " << N_run   << "\n";
00714               outfile << "    Event : " << N_event << "\n";
00715               outfile << "LumiBlock : " << N_lumi  << "\n";
00716               outfile << "     Type :  el el" << "\n";
00717               outfile << "--------------------" << "\n";
00718               outfile << "DilepMass : " << DilepMass << "\n";
00719               outfile << "El1 Pt    : " << el1.pt() << "\n";
00720               outfile << "El1 Eta   : " << el1.eta() << "\n";
00721               outfile << "El1 Phi   : " << el1.phi() << "\n";
00722               outfile << "El2 Pt    : " << el2.pt() << "\n";
00723               outfile << "El2 Eta   : " << el2.eta() << "\n";
00724               outfile << "El2 Phi   : " << el2.phi() << "\n";
00725               outfile << "--------------------" << "\n";
00726 
00727             }
00728 
00729           }
00730 
00731           // Determinating trigger efficiencies
00732 
00733           for( int k = 0; k < N_SignalPaths; ++k ) {
00734 
00735             if( Fired_Signal_Trigger[k] && Fired_Control_Trigger[k] )  ++N_sig[k];
00736 
00737             if( Fired_Control_Trigger[k] )  ++N_trig[k];
00738 
00739             if( N_trig[k] != 0 )  Eff[k] = N_sig[k]/static_cast<float>(N_trig[k]);
00740 
00741             TriggerEff_->setBinContent( k+1, Eff[k] );
00742             TriggerEff_->setBinLabel( k+1, "#frac{["+hltPaths_sig_[k]+"]}{vs. ["+hltPaths_trig_[k]+"]}", 1);
00743 
00744           }
00745 
00746         }
00747 
00748       }
00749 
00750       // Same muon charges -> Wrong Charge (WC)
00751 
00752       if( el1.charge()*el2.charge() > 0. ) {
00753 
00754         dimassWC_LOG10_->Fill( log10(DilepMass) );
00755         dimassWC_->Fill(      DilepMass );
00756         dimassWC_LOGX_->Fill( DilepMass );
00757 
00758       }
00759 
00760     }
00761 
00762   }
00763 
00764 }
00765 
00766 
00767 void TopDiLeptonDQM::endRun(const edm::Run& r, const edm::EventSetup& context) {
00768 
00769 }
00770 
00771 void TopDiLeptonDQM::endJob() {
00772 
00773   if(fileOutput_)  outfile.close();
00774 
00775 }