CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/DQM/Physics/src/TopDiLeptonDQM.cc

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