CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/DQM/Physics/src/EwkElecDQM.cc

Go to the documentation of this file.
00001 #include "DQM/Physics/src/EwkElecDQM.h"
00002 
00003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00005 #include "DataFormats/Common/interface/Handle.h"
00006 
00007 #include "FWCore/ServiceRegistry/interface/Service.h"
00008 #include "CommonTools/UtilAlgos/interface/TFileService.h"
00009 
00010 #include "DQMServices/Core/interface/DQMStore.h"
00011 #include "DQMServices/Core/interface/MonitorElement.h"
00012 
00013 #include "DataFormats/TrackReco/interface/Track.h"
00014 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
00015 
00016 //#include "DataFormats/MuonReco/interface/Muon.h"
00017 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h" // I guess this is the right one??
00018 // also need Fwd.h file ???
00019 #include "DataFormats/METReco/interface/MET.h"
00020 #include "DataFormats/JetReco/interface/Jet.h"
00021 #include "DataFormats/JetReco/interface/CaloJet.h"
00022 #include "DataFormats/METReco/interface/CaloMET.h"
00023 #include "DataFormats/METReco/interface/CaloMETCollection.h"
00024 #include "DataFormats/METReco/interface/CaloMETFwd.h"
00025 
00026 #include "DataFormats/GeometryVector/interface/Phi.h"
00027 
00028 #include "FWCore/Common/interface/TriggerNames.h"
00029 #include "FWCore/Framework/interface/Event.h"
00030 #include "DataFormats/Common/interface/TriggerResults.h"
00031 
00032 #include "DataFormats/Common/interface/View.h"
00033   
00034 using namespace edm;
00035 using namespace std;
00036 using namespace reco;
00037 
00038 EwkElecDQM::EwkElecDQM( const ParameterSet & cfg ) :
00039       // Input collections
00040       trigTag_(cfg.getUntrackedParameter<edm::InputTag> ("TrigTag", edm::InputTag("TriggerResults::HLT"))),
00041       //      muonTag_(cfg.getUntrackedParameter<edm::InputTag> ("MuonTag", edm::InputTag("muons"))),
00042       elecTag_(cfg.getUntrackedParameter<edm::InputTag> ("ElecTag", edm::InputTag("gsfElectrons"))), 
00043       metTag_(cfg.getUntrackedParameter<edm::InputTag> ("METTag", edm::InputTag("met"))),
00044       //      metIncludesMuons_(cfg.getUntrackedParameter<bool> ("METIncludesMuons", false)),
00045       jetTag_(cfg.getUntrackedParameter<edm::InputTag> ("JetTag", edm::InputTag("sisCone5CaloJets"))),
00046 
00047       // Main cuts 
00048       //      muonTrig_(cfg.getUntrackedParameter<std::string> ("MuonTrig", "HLT_Mu9")),
00049       //elecTrig_(cfg.getUntrackedParameter<std::vector< std::string > >("ElecTrig", "HLT_Ele10_SW_L1R")), 
00050       elecTrig_(cfg.getUntrackedParameter<std::vector< std::string > >("ElecTrig")), 
00051       //      ptCut_(cfg.getUntrackedParameter<double>("PtCut", 25.)),
00052       ptCut_(cfg.getUntrackedParameter<double>("PtCut", 10.)),
00053       //      etaCut_(cfg.getUntrackedParameter<double>("EtaCut", 2.1)),
00054       etaCut_(cfg.getUntrackedParameter<double>("EtaCut", 2.4)),
00055       sieieCutBarrel_(cfg.getUntrackedParameter<double>("SieieBarrel", 0.01)),
00056       sieieCutEndcap_(cfg.getUntrackedParameter<double>("SieieEndcap", 0.028)),
00057       detainCutBarrel_(cfg.getUntrackedParameter<double>("DetainBarrel", 0.0071)),
00058       detainCutEndcap_(cfg.getUntrackedParameter<double>("DetainEndcap", 0.0066)),
00059       //      isRelativeIso_(cfg.getUntrackedParameter<bool>("IsRelativeIso", true)),
00060       //      isCombinedIso_(cfg.getUntrackedParameter<bool>("IsCombinedIso", false)),
00061       //      isoCut03_(cfg.getUntrackedParameter<double>("IsoCut03", 0.1)),
00062       ecalIsoCutBarrel_(cfg.getUntrackedParameter<double>("EcalIsoCutBarrel", 5.7)),
00063       ecalIsoCutEndcap_(cfg.getUntrackedParameter<double>("EcalIsoCutEndcap", 5.0)),
00064       hcalIsoCutBarrel_(cfg.getUntrackedParameter<double>("HcalIsoCutBarrel", 8.1)),
00065       hcalIsoCutEndcap_(cfg.getUntrackedParameter<double>("HcalIsoCutEndcap", 3.4)),
00066       trkIsoCutBarrel_(cfg.getUntrackedParameter<double>("TrkIsoCutBarrel", 7.2)),
00067       trkIsoCutEndcap_(cfg.getUntrackedParameter<double>("TrkIsoCutEndcap", 5.1)),
00068       mtMin_(cfg.getUntrackedParameter<double>("MtMin", -999999)),
00069       mtMax_(cfg.getUntrackedParameter<double>("MtMax", 999999.)),
00070       metMin_(cfg.getUntrackedParameter<double>("MetMin", -999999.)),
00071       metMax_(cfg.getUntrackedParameter<double>("MetMax", 999999.)),
00072       //      acopCut_(cfg.getUntrackedParameter<double>("AcopCut", 2.)),
00073 
00074       // Muon quality cuts
00075       //      dxyCut_(cfg.getUntrackedParameter<double>("DxyCut", 0.2)),
00076       //      normalizedChi2Cut_(cfg.getUntrackedParameter<double>("NormalizedChi2Cut", 10.)),
00077       //      trackerHitsCut_(cfg.getUntrackedParameter<int>("TrackerHitsCut", 11)),
00078       //      isAlsoTrackerMuon_(cfg.getUntrackedParameter<bool>("IsAlsoTrackerMuon", true)),
00079 
00080       // Z rejection
00081       //      ptThrForZ1_(cfg.getUntrackedParameter<double>("PtThrForZ1", 20.)),
00082       //      ptThrForZ2_(cfg.getUntrackedParameter<double>("PtThrForZ2", 10.)),
00083 
00084       // Top rejection
00085       eJetMin_(cfg.getUntrackedParameter<double>("EJetMin", 999999.)),
00086       nJetMax_(cfg.getUntrackedParameter<int>("NJetMax", 999999))
00087       
00088 //       caloJetCollection_(cfg.getUntrackedParameter<edm:InputTag>("CaloJetCollection","sisCone5CaloJets"))
00089 
00090 
00091 
00092 {
00093 }
00094 
00095 void EwkElecDQM::beginRun(const Run& r, const EventSetup&) {
00096       nall = 0;
00097       nsel = 0;
00098 
00099       nrec = 0; 
00100       neid = 0;
00101       niso = 0; 
00102 //       nhlt = 0; 
00103 //       nmet = 0;
00104 }
00105 
00106 
00107 void EwkElecDQM::beginJob() {
00108       theDbe = Service<DQMStore>().operator->();
00109       theDbe->setCurrentFolder("Physics/EwkElecDQM");
00110       init_histograms();
00111 }
00112 
00113 void EwkElecDQM::init_histograms() {
00114 
00115       char chtitle[256] = "";
00116       for (int i=0; i<2; ++i) {
00117 //             snprintf(chtitle, 255, "Muon transverse momentum (global muon) [GeV]");
00118 //             pt_before_ = theDbe->book1D("PT_BEFORECUTS",chtitle,100,0.,100.);
00119 //             pt_after_ = theDbe->book1D("PT_LASTCUT",chtitle,100,0.,100.);
00120 
00121             snprintf(chtitle, 255, "Electron transverse momentum [GeV]");
00122             pt_before_ = theDbe->book1D("PT_BEFORECUTS",chtitle,100,0.,100.);
00123             pt_after_ = theDbe->book1D("PT_LASTCUT",chtitle,100,0.,100.);
00124 
00125             snprintf(chtitle, 255, "Electron pseudo-rapidity");
00126             eta_before_ = theDbe->book1D("ETA_BEFORECUTS",chtitle,50,-2.5,2.5);
00127             eta_after_ = theDbe->book1D("ETA_LASTCUT",chtitle,50,-2.5,2.5);
00128 
00129             snprintf(chtitle, 255, "Electron #sigma_{i#etai#eta} (barrel)");
00130             sieiebarrel_before_ = theDbe->book1D("SIEIEBARREL_BEFORECUTS",chtitle,70,0.,0.07);
00131             sieiebarrel_after_ = theDbe->book1D("SIEIEBARREL_LASTCUT",chtitle,70,0.,0.07);
00132 
00133             snprintf(chtitle, 255, "Electron #sigma_{i#etai#eta} (endcap)");
00134             sieieendcap_before_ = theDbe->book1D("SIEIEENDCAP_BEFORECUTS",chtitle,70,0.,0.07);
00135             sieieendcap_after_ = theDbe->book1D("SIEIEENDCAP_LASTCUT",chtitle,70,0.,0.07);
00136 
00137             snprintf(chtitle, 255, "Electron #Delta#eta_{in} (barrel)");
00138             detainbarrel_before_ = theDbe->book1D("DETAINBARREL_BEFORECUTS",chtitle,40,-0.02,0.02);
00139             detainbarrel_after_ = theDbe->book1D("DETAINBARREL_LASTCUT",chtitle,40,-0.02,0.02);
00140 
00141             snprintf(chtitle, 255, "Electron #Delta#eta_{in} (endcap)");
00142             detainendcap_before_ = theDbe->book1D("DETAINENDCAP_BEFORECUTS",chtitle,40,-0.02,0.02);
00143             detainendcap_after_ = theDbe->book1D("DETAINENDCAP_LASTCUT",chtitle,40,-0.02,0.02);
00144 
00145 //             snprintf(chtitle, 255, "Muon transverse distance to beam spot [cm]");
00146 //             dxy_before_ = theDbe->book1D("DXY_BEFORECUTS",chtitle,100,-0.5,0.5);
00147 //             dxy_after_ = theDbe->book1D("DXY_LASTCUT",chtitle,100,-0.5,0.5);
00148 
00149 //             snprintf(chtitle, 255, "Normalized Chi2, inner track fit");
00150 //             chi2_before_ = theDbe->book1D("CHI2_BEFORECUTS",chtitle,100,0.,100.);
00151 //             chi2_after_ = theDbe->book1D("CHI2_LASTCUT",chtitle,100,0.,100.);
00152 
00153 //             snprintf(chtitle, 255, "Number of hits, inner track");
00154 //             nhits_before_ = theDbe->book1D("NHITS_BEFORECUTS",chtitle,40,-0.5,39.5);
00155 //             nhits_after_ = theDbe->book1D("NHITS_LASTCUT",chtitle,40,-0.5,39.5);
00156 
00157 //             snprintf(chtitle, 255, "Tracker-muon flag (for global muons)");
00158 //             tkmu_before_ = theDbe->book1D("TKMU_BEFORECUTS",chtitle,2,-0.5,1.5);
00159 //             tkmu_after_ = theDbe->book1D("TKMU_LASTCUT",chtitle,2,-0.5,1.5);
00160 
00161 //             if (isRelativeIso_) {
00162 //                   if (isCombinedIso_) {
00163 //                         snprintf(chtitle, 255, "Relative (combined) isolation variable");
00164 //                   } else {
00165 //                         snprintf(chtitle, 255, "Relative (tracker) isolation variable");
00166 //                   }
00167 //                   iso_before_ = theDbe->book1D("ISO_BEFORECUTS",chtitle,100, 0., 1.);
00168 //                   iso_after_ = theDbe->book1D("ISO_LASTCUT",chtitle,100, 0., 1.);
00169 //             } else {
00170 //                   if (isCombinedIso_) {
00171 //                         snprintf(chtitle, 255, "Absolute (combined) isolation variable [GeV]");
00172 //                   } else {
00173 //                         snprintf(chtitle, 255, "Absolute (tracker) isolation variable [GeV]");
00174 //                   }
00175 //                   iso_before_ = theDbe->book1D("ISO_BEFORECUTS",chtitle,100, 0., 20.);
00176 //                   iso_after_ = theDbe->book1D("ISO_LASTCUT",chtitle,100, 0., 20.);
00177 //             }
00178 
00179             snprintf(chtitle, 255, "Absolute electron ECAL isolation variable (barrel) [GeV]");
00180             ecalisobarrel_before_ = theDbe->book1D("ECALISOBARREL_BEFORECUTS",chtitle,50,0.,50.);
00181             ecalisobarrel_after_ = theDbe->book1D("ECALISOBARREL_LASTCUT",chtitle,50,0.,50.);
00182 
00183             snprintf(chtitle, 255, "Absolute electron ECAL isolation variable (endcap) [GeV]");
00184             ecalisoendcap_before_ = theDbe->book1D("ECALISOENDCAP_BEFORECUTS",chtitle,50,0.,50.);
00185             ecalisoendcap_after_ = theDbe->book1D("ECALISOENDCAP_LASTCUT",chtitle,50,0.,50.);
00186 
00187             snprintf(chtitle, 255, "Absolute electron HCAL isolation variable (barrel) [GeV]");
00188             hcalisobarrel_before_ = theDbe->book1D("HCALISOBARREL_BEFORECUTS",chtitle,50,0.,50.);
00189             hcalisobarrel_after_ = theDbe->book1D("HCALISOBARREL_LASTCUT",chtitle,50,0.,50.);
00190 
00191             snprintf(chtitle, 255, "Absolute electron HCAL isolation variable (endcap) [GeV]");
00192             hcalisoendcap_before_ = theDbe->book1D("HCALISOENDCAP_BEFORECUTS",chtitle,50,0.,50.);
00193             hcalisoendcap_after_ = theDbe->book1D("HCALISOENDCAP_LASTCUT",chtitle,50,0.,50.);
00194 
00195             snprintf(chtitle, 255, "Absolute electron track isolation variable (barrel) [GeV]");
00196             trkisobarrel_before_ = theDbe->book1D("TRKISOBARREL_BEFORECUTS",chtitle,50,0.,50.);
00197             trkisobarrel_after_ = theDbe->book1D("TRKISOBARREL_LASTCUT",chtitle,50,0.,50.);
00198 
00199             snprintf(chtitle, 255, "Absolute electron track isolation variable (endcap) [GeV]");
00200             trkisoendcap_before_ = theDbe->book1D("TRKISOENDCAP_BEFORECUTS",chtitle,50,0.,50.);
00201             trkisoendcap_after_ = theDbe->book1D("TRKISOENDCAP_LASTCUT",chtitle,50,0.,50.);
00202 
00203 //             snprintf(chtitle, 255, "Trigger response (bit %s)", muonTrig_.data());
00204 //             trig_before_ = theDbe->book1D("TRIG_BEFORECUTS",chtitle,2,-0.5,1.5);
00205 //             trig_after_ = theDbe->book1D("TRIG_LASTCUT",chtitle,2,-0.5,1.5);
00206 
00207             //snprintf(chtitle, 255, "Trigger response (bit %s)", elecTrig_.data());
00208             snprintf(chtitle, 255, "Trigger response"); // elecTrig_ is now a vector of strings!
00209             trig_before_ = theDbe->book1D("TRIG_BEFORECUTS",chtitle,2,-0.5,1.5);
00210             trig_after_ = theDbe->book1D("TRIG_LASTCUT",chtitle,2,-0.5,1.5);
00211 
00212             snprintf(chtitle, 255, "Di-electron invariant mass [GeV]");
00213             invmass_before_ = theDbe->book1D("INVMASS_BEFORECUTS",chtitle,100,0.,200.);
00214             invmass_after_ = theDbe->book1D("INVMASS_AFTERCUTS",chtitle,100,0.,200.);
00215 
00216             snprintf(chtitle, 255, "Number of electrons in event");
00217             nelectrons_before_ = theDbe->book1D("NELECTRONS_BEFORECUTS",chtitle,10,-0.5,9.5);
00218             nelectrons_after_ = theDbe->book1D("NELECTRONS_AFTERCUTS",chtitle,10,-0.5,9.5);
00219 
00220             snprintf(chtitle, 255, "Transverse mass (%s) [GeV]", metTag_.label().data());
00221             mt_before_ = theDbe->book1D("MT_BEFORECUTS",chtitle,150,0.,300.);
00222             mt_after_ = theDbe->book1D("MT_LASTCUT",chtitle,150,0.,300.);
00223 
00224 //             snprintf(chtitle, 255, "Transverse mass (%s) [GeV]", metTag_.label().data());
00225 //             mt_before_ = theDbe->book1D("MT_BEFORECUTS",chtitle,150,0.,300.);
00226 //             mt_after_ = theDbe->book1D("MT_LASTCUT",chtitle,150,0.,300.);
00227 
00228             snprintf(chtitle, 255, "Missing transverse energy (%s) [GeV]", metTag_.label().data());
00229             met_before_ = theDbe->book1D("MET_BEFORECUTS",chtitle,100,0.,200.);
00230             met_after_ = theDbe->book1D("MET_LASTCUT",chtitle,100,0.,200.);
00231 
00232 //             snprintf(chtitle, 255, "MU-MET (%s) acoplanarity", metTag_.label().data());
00233 //             acop_before_ = theDbe->book1D("ACOP_BEFORECUTS",chtitle,50,0.,M_PI);
00234 //             acop_after_ = theDbe->book1D("ACOP_LASTCUT",chtitle,50,0.,M_PI);
00235 
00236 //             snprintf(chtitle, 255, "Z rejection: number of muons above %.2f GeV", ptThrForZ1_);
00237 //             nz1_before_ = theDbe->book1D("NZ1_BEFORECUTS",chtitle,10,-0.5,9.5);
00238 //             nz1_after_ = theDbe->book1D("NZ1_LASTCUT",chtitle,10,-0.5,9.5);
00239 
00240 //             snprintf(chtitle, 255, "Z rejection: number of muons above %.2f GeV", ptThrForZ2_);
00241 //             nz2_before_ = theDbe->book1D("NZ2_BEFORECUTS",chtitle,10,-0.5,9.5);
00242 //             nz2_after_ = theDbe->book1D("NZ2_LASTCUT",chtitle,10,-0.5,9.5);
00243 
00244              snprintf(chtitle, 255, "Number of jets (%s) above %.2f GeV", jetTag_.label().data(), eJetMin_);
00245              njets_before_ = theDbe->book1D("NJETS_BEFORECUTS",chtitle,10,-0.5,9.5);
00246              njets_after_  = theDbe->book1D("NJETS_LASTCUT",chtitle,10,-0.5,9.5);
00247              snprintf(chtitle, 255, "Jet with highest E_{T} (%s)", jetTag_.label().data());
00248              jet_et_before_       = theDbe->book1D("JETET1_BEFORECUTS",chtitle, 20, 0., 200.0);
00249              jet_et_after_       = theDbe->book1D("JETET1_AFTERCUTS",chtitle, 20, 0., 200.0);
00250              snprintf(chtitle, 255, "Eta of Jet with highest E_{T} (%s)", jetTag_.label().data());
00251              jet_eta_before_       = theDbe->book1D("JETETA1_BEFORECUTS",chtitle, 20, -5, 5);
00252              jet_eta_after_       = theDbe->book1D("JETETA1_AFTERCUTS",chtitle, 20, -5, 5);
00253 //           snprintf(chtitle, 255, "Jet with 2nd highest E_{T} (%s)", jetTag_.label().data());
00254 //           jet2_et_before      = theDbe->book1D("JETET2_BEFORECUTS",chtitle, 20, 0., 200.0);
00255 //           jet2_et_after       = theDbe->book1D("JETET2_AFTERCUTS",chtitle, 20, 0., 200.0);
00256              
00257 
00258 
00259       }
00260 }
00261 
00262 
00263 void EwkElecDQM::endJob() {
00264 }
00265 
00266 void EwkElecDQM::endRun(const Run& r, const EventSetup&) {
00267 
00268   // overall
00269   double all = nall;
00270   double esel = nsel/all;
00271   LogVerbatim("") << "\n>>>>>> SELECTION SUMMARY BEGIN >>>>>>>>>>>>>>>";
00272   LogVerbatim("") << "Total number of events analyzed: " << nall << " [events]";
00273   LogVerbatim("") << "Total number of events selected: " << nsel << " [events]";
00274   LogVerbatim("") << "Overall efficiency:             " << "(" << setprecision(4) << esel*100. <<" +/- "<< setprecision(2) << sqrt(esel*(1-esel)/all)*100. << ")%";
00275   
00276   double erec = nrec/all;
00277   double eeid = neid/all;
00278   double eiso = niso/all;
00279 //   double ehlt = nhlt/all;
00280 //   double emet = nmet/all;
00281   
00282   // general reconstruction step??
00283   double num = nrec;
00284   double eff = erec;
00285   double err = sqrt(eff*(1-eff)/all);
00286   LogVerbatim("") << "Passing Pt/Eta/Quality cuts:    " << num << " [events], (" << setprecision(4) << eff*100. <<" +/- "<< setprecision(2) << err*100. << ")%";
00287 
00288   // electron ID step  
00289   num = neid;
00290   eff = eeid;
00291   err = sqrt(eff*(1-eff)/all);
00292   double effstep = 0.;
00293   double errstep = 0.;
00294   if (nrec>0) effstep = eeid/erec;
00295   if (nrec>0) errstep = sqrt(effstep*(1-effstep)/nrec);
00296   LogVerbatim("") << "Passing eID cuts:         " << num << " [events], (" << setprecision(4) << eff*100. <<" +/- "<< setprecision(2) << err*100. << ")%, to previous step: (" <<  setprecision(4) << effstep*100. << " +/- "<< setprecision(2) << errstep*100. <<")%";
00297   
00298   // isolation step  
00299   num = niso;
00300   eff = eiso;
00301   err = sqrt(eff*(1-eff)/all);
00302   effstep = 0.;
00303   errstep = 0.;
00304   if (neid>0) effstep = eiso/eeid;
00305   if (neid>0) errstep = sqrt(effstep*(1-effstep)/neid);
00306   LogVerbatim("") << "Passing isolation cuts:         " << num << " [events], (" << setprecision(4) << eff*100. <<" +/- "<< setprecision(2) << err*100. << ")%, to previous step: (" <<  setprecision(4) << effstep*100. << " +/- "<< setprecision(2) << errstep*100. <<")%";
00307   
00308 //   // trigger step
00309 //   num = nhlt;
00310 //   eff = ehlt;
00311 //   err = sqrt(eff*(1-eff)/all);
00312 //   effstep = 0.;
00313 //   errstep = 0.;
00314 //   if (niso>0) effstep = ehlt/eiso;
00315 //   if (niso>0) errstep = sqrt(effstep*(1-effstep)/niso);
00316 //   LogVerbatim("") << "Passing HLT criteria:           " << num << " [events], (" << setprecision(4) << eff*100. <<" +/- "<< setprecision(2) << err*100. << ")%, to previous step: (" <<  setprecision(4) << effstep*100. << " +/- "<< setprecision(2) << errstep*100. <<")%";
00317   
00318   // trigger step
00319   num = nsel;
00320   eff = esel;
00321   err = sqrt(eff*(1-eff)/all);
00322   effstep = 0.;
00323   errstep = 0.;
00324   if (niso>0) effstep = esel/eiso;
00325   if (niso>0) errstep = sqrt(effstep*(1-effstep)/niso);
00326   LogVerbatim("") << "Passing HLT criteria:           " << num << " [events], (" << setprecision(4) << eff*100. <<" +/- "<< setprecision(2) << err*100. << ")%, to previous step: (" <<  setprecision(4) << effstep*100. << " +/- "<< setprecision(2) << errstep*100. <<")%";
00327   
00328 //   // met/acoplanarity cuts 
00329 //   num = nmet;
00330 //   eff = emet;
00331 //   err = sqrt(eff*(1-eff)/all);
00332 //   effstep = 0.;
00333 //   errstep = 0.;
00334 //   if (nhlt>0) effstep = emet/ehlt;
00335 //   if (nhlt>0) errstep = sqrt(effstep*(1-effstep)/nhlt);
00336 //   LogVerbatim("") << "Passing MET/acoplanarity cuts:  " << num << " [events], (" << setprecision(4) << eff*100. <<" +/- "<< setprecision(2) << err*100. << ")%, to previous step: (" <<  setprecision(4) << effstep*100. << " +/- "<< setprecision(2) << errstep*100. <<")%";
00337   
00338 //   // Z/top selection cuts ALSO LAST STEP so "sel" for "selection"
00339 //   num = nsel;
00340 //   eff = esel;
00341 //   err = sqrt(eff*(1-eff)/all);
00342 //   effstep = 0.;
00343 //   errstep = 0.;
00344 //   if (nmet>0) effstep = esel/emet;
00345 //   if (nmet>0) errstep = sqrt(effstep*(1-effstep)/nmet);
00346 //   LogVerbatim("") << "Passing Z/top rejection cuts:   " << num << " [events], (" << setprecision(4) << eff*100. <<" +/- "<< setprecision(2) << err*100. << ")%, to previous step: (" <<  setprecision(4) << effstep*100. << " +/- "<< setprecision(2) << errstep*100. <<")%";
00347   
00348   LogVerbatim("") << ">>>>>> SELECTION SUMMARY END   >>>>>>>>>>>>>>>\n";
00349 }
00350 
00351 void EwkElecDQM::analyze (const Event & ev, const EventSetup &) {
00352       
00353       // Reset global event selection flags
00354       bool rec_sel = false;
00355       bool eid_sel = false;
00356       bool iso_sel = false;
00357 //       bool hlt_sel = false;
00358       bool met_sel = false;
00359       bool all_sel = false;
00360 
00361 //       // Muon collection
00362 //       Handle<View<Muon> > muonCollection;
00363 //       if (!ev.getByLabel(muonTag_, muonCollection)) {
00364 //             LogWarning("") << ">>> Muon collection does not exist !!!";
00365 //             return;
00366 //       }
00367 //       unsigned int muonCollectionSize = muonCollection->size();
00368 
00369       // Electron collection
00370       Handle<View<GsfElectron> > electronCollection;
00371       if (!ev.getByLabel(elecTag_, electronCollection)) {
00372         //LogWarning("") << ">>> Electron collection does not exist !!!";
00373         return;
00374       }
00375       unsigned int electronCollectionSize = electronCollection->size();
00376 
00377       // Beam spot
00378       Handle<reco::BeamSpot> beamSpotHandle;
00379       if (!ev.getByLabel(InputTag("offlineBeamSpot"), beamSpotHandle)) {
00380         //LogWarning("") << ">>> No beam spot found !!!";
00381         return;
00382       }
00383         // MET
00384       double met_px = 0.;
00385       double met_py = 0.;
00386       Handle<View<MET> > metCollection;
00387       if (!ev.getByLabel(metTag_, metCollection)) {
00388         //LogWarning("") << ">>> MET collection does not exist !!!";
00389         return;
00390       }
00391       const MET& met = metCollection->at(0);
00392       met_px = met.px();
00393       met_py = met.py();
00394 //       if (!metIncludesMuons_) {
00395 //             for (unsigned int i=0; i<muonCollectionSize; i++) {
00396 //                   const Muon& mu = muonCollection->at(i);
00397 //                   if (!mu.isGlobalMuon()) continue;
00398 //                   met_px -= mu.px();
00399 //                   met_py -= mu.py();
00400 //             }
00401 //       }
00402       double met_et = sqrt(met_px*met_px+met_py*met_py);
00403       LogTrace("") << ">>> MET, MET_px, MET_py: " << met_et << ", " << met_px << ", " << met_py << " [GeV]";
00404       met_before_->Fill(met_et);
00405 
00406       // Trigger
00407       Handle<TriggerResults> triggerResults;
00408       if (!ev.getByLabel(trigTag_, triggerResults)) {
00409         //LogWarning("") << ">>> TRIGGER collection does not exist !!!";
00410         return;
00411       }
00412       const edm::TriggerNames & trigNames = ev.triggerNames(*triggerResults);
00413       bool trigger_fired = false;
00414       /*
00415       for (unsigned int i=0; i<triggerResults->size(); i++) {
00416             if (triggerResults->accept(i)) {
00417                   LogTrace("") << "Accept by: " << i << ", Trigger: " << trigNames.triggerName(i);
00418             }
00419       }
00420       */
00421 
00422       // the following gives error on CRAFT08 data where itrig1=19 (vector index out of range)
00423       /*
00424       int itrig1 = trigNames.triggerIndex(muonTrig_);
00425       if (triggerResults->accept(itrig1)) trigger_fired = true;
00426       */
00427       //suggested replacement: lm250909
00428       for (unsigned int i=0; i<triggerResults->size(); i++) 
00429         {
00430           std::string trigName = trigNames.triggerName(i);
00431           for (unsigned int j = 0; j < elecTrig_.size(); j++)
00432             {
00433               if ( trigName == elecTrig_.at(j) && triggerResults->accept(i)) 
00434                 {
00435                   trigger_fired = true;
00436                 }
00437             }
00438         }
00439 
00440 
00441       LogTrace("") << ">>> Trigger bit: " << trigger_fired << " for one of ( " ;
00442       for (unsigned int k = 0; k < elecTrig_.size(); k++)
00443         {
00444           LogTrace("") << elecTrig_.at(k) << " ";
00445         }
00446       LogTrace("") << ")";
00447       trig_before_->Fill(trigger_fired);
00448 
00449 //       // Loop to reject/control Z->mumu is done separately
00450 //       unsigned int nmuonsForZ1 = 0;
00451 //       unsigned int nmuonsForZ2 = 0;
00452 //       for (unsigned int i=0; i<muonCollectionSize; i++) {
00453 //             const Muon& mu = muonCollection->at(i);
00454 //             if (!mu.isGlobalMuon()) continue;
00455 //             double pt = mu.pt();
00456 //             if (pt>ptThrForZ1_) nmuonsForZ1++;
00457 //             if (pt>ptThrForZ2_) nmuonsForZ2++;
00458 //       }
00459 //       LogTrace("") << "> Z rejection: muons above " << ptThrForZ1_ << " [GeV]: " << nmuonsForZ1;
00460 //       LogTrace("") << "> Z rejection: muons above " << ptThrForZ2_ << " [GeV]: " << nmuonsForZ2;
00461 //       nz1_before_->Fill(nmuonsForZ1);
00462 //       nz2_before_->Fill(nmuonsForZ2);
00463       
00464       // Jet collection
00465       Handle<View<Jet> > jetCollection;
00466       if (!ev.getByLabel(jetTag_, jetCollection)) {
00467         //LogError("") << ">>> JET collection does not exist !!!";
00468         return;
00469       }      
00470       float electron_et   = -8.0;
00471       float electron_eta  = -8.0;
00472       float electron_phi  = -8.0;
00473       float electron2_et  = -9.0;
00474       float electron2_eta = -9.0;
00475       float electron2_phi = -9.0;
00476       //need to get some electron info so jets can be cleaned of them
00477       for (unsigned int i=0; i<electronCollectionSize; i++) 
00478         {
00479           const GsfElectron& elec = electronCollection->at(i);   
00480 
00481           if (i < 1)
00482             {
00483                electron_et   = elec.pt();
00484                electron_eta  = elec.eta();
00485                electron_phi  = elec.phi();
00486             }
00487           if (i == 2)
00488             {
00489                electron2_et  = elec.pt();
00490                electron2_eta = elec.eta();
00491                electron2_phi = elec.phi();
00492             }       
00493         }
00494 
00495       float jet_et    = -8.0;
00496       float jet_eta   = -8.0;
00497       float jet_phi   = -8.0;
00498       int   jet_count = 0;
00499       float jet2_et   = -9.0;
00500       float jet2_eta  = -9.0;
00501       float jet2_phi  = -9.0;
00502       unsigned int jetCollectionSize = jetCollection->size();
00503       int njets = 0;
00504       for (unsigned int i=0; i<jetCollectionSize; i++) {
00505         const Jet& jet = jetCollection->at(i);
00506         
00507         float jet_current_et = jet.et();
00508 //      cout << "jet_current_et " << jet_current_et << endl;
00509         // if it overlaps with electron, it is not a jet
00510         if ( electron_et>0.0 && fabs(jet.eta()-electron_eta ) < 0.2 
00511              && calcDeltaPhi(jet.phi(), electron_phi ) < 0.2)
00512           continue;
00513         if ( electron2_et>0.0&& fabs(jet.eta()-electron2_eta) < 0.2 
00514              && calcDeltaPhi(jet.phi(), electron2_phi) < 0.2) 
00515           continue;
00516 
00517         // if it has too low Et, throw away
00518 //      if (jet_current_et < eJetMin_) continue; //Keep if only want to plot above jet cut
00519 
00520         if (jet.et()>eJetMin_) 
00521           {
00522             njets++;
00523             jet_count++;
00524           }
00525         if (jet_current_et > jet_et) 
00526           {
00527             jet2_et  = jet_et;  // 2nd highest jet get's et from current highest
00528             jet2_eta = jet_eta;
00529             jet2_phi = jet_phi;
00530             jet_et   = jet.et(); // current highest jet gets et from the new highest
00531             jet_eta  = jet.eta();
00532             jet_phi  = jet.phi();
00533           } 
00534         else if (jet_current_et > jet2_et) 
00535           {
00536             jet2_et  = jet.et();
00537             jet2_eta = jet.eta();
00538             jet2_phi = jet.phi();
00539           }
00540       }
00541 
00542       //Fill After all electron cuts (or both before and after)
00543       if (jet_et>10) //don't want low energy "jets"
00544         {
00545           jet_et_before_   ->Fill(jet_et);
00546 //        jet2_et_before_  ->Fill(jet2_et);
00547           jet_eta_before_  ->Fill(jet_eta);
00548         }
00549 
00550 
00551       LogTrace("") << ">>> Total number of jets: " << jetCollectionSize;
00552       LogTrace("") << ">>> Number of jets above " << eJetMin_ << " [GeV]: " << njets;
00553       njets_before_->Fill(njets);
00554 
00555       // Start counting
00556       nall++;
00557 
00558       // Histograms per event should be done only once, so keep track of them
00559       bool hlt_hist_done = false;
00560       //bool minv_hist_done = false;
00561        bool met_hist_done = false;
00562 //       bool nz1_hist_done = false;
00563 //       bool nz2_hist_done = false;
00564       bool njets_hist_done = false;
00565 
00566       // Central selection criteria
00567       //const int NFLAGS = 13; // number of individual selection criteria
00568       const int NFLAGS = 11; // number of individual selection criteria
00569       // 0: pt cut           | rec
00570       // 1: eta cut          | rec
00571       // 2: sieie            | eid
00572       // 3: detain           | eid
00573       // 4: ecal iso         | iso
00574       // 5: hcal iso         | iso
00575       // 6: trk iso          | iso
00576       // 7: trigger fired    | hlt/all
00577       bool electron_sel[NFLAGS];
00578 
00579       // for invariant mass calculation
00580       // keep track of highest-pt electrons for initial (RECO) electrons 
00581       // and "good" electrons (passing all cuts)
00582       // first array dimension is for first or second good electron
00583       // second array dimension is for relevant quantities of good electron
00584       //    [0]: 1 for electron found or 0 for not found (if 0, no other quantities filled)
00585       //    [1]: mSqr
00586       //    [2]: E
00587       //    [3]: px
00588       //    [4]: py
00589       //    [5]: pz
00590       // inv mass = sqrt(m_1^2 + m_2^2 + 2*(E_1*E_2 - (px1*px2 + py1*py2 + pz1+pz2) ) )
00591       double electron[2][6];
00592       double goodElectron[2][6];
00593       nGoodElectrons = 0;
00594       for (unsigned int i = 0; i < 2; i++)
00595         {
00596           for (unsigned int j = 0; j < 6; j++)
00597             {
00598               electron[i][j] = 0.;
00599               goodElectron[i][j] = 0.;
00600             }
00601         }
00602 
00603       for (unsigned int i=0; i<electronCollectionSize; i++) 
00604         {
00605           for (int j=0; j<NFLAGS; ++j) 
00606             {
00607               electron_sel[j] = false;
00608             }
00609           
00610           const GsfElectron& elec = electronCollection->at(i);
00611           //if (!mu.isGlobalMuon()) continue;
00612           //if (mu.globalTrack().isNull()) continue;
00613           //if (mu.innerTrack().isNull()) continue;
00614           
00615           LogTrace("") << "> elec: processing electron number " << i << "...";
00616           //reco::TrackRef gm = mu.globalTrack();
00617           //reco::TrackRef tk = mu.innerTrack();
00618           // should have stuff for electron track?
00619           
00620           if (i < 2)
00621             {
00622               electron[i][0] = 1.;
00623               electron[i][1] = elec.massSqr();
00624               electron[i][2] = elec.energy();
00625               electron[i][3] = elec.px();
00626               electron[i][4] = elec.py();
00627               electron[i][5] = elec.pz();
00628             }
00629 
00630           // Pt,eta cuts
00631           double pt = elec.pt();
00632           double px = elec.px();
00633           double py = elec.py();
00634           double eta = elec.eta();
00635           LogTrace("") << "\t... pt, eta: " << pt << " [GeV], " << eta;;
00636           if (pt>ptCut_) electron_sel[0] = true; 
00637           if (fabs(eta)<etaCut_) electron_sel[1] = true; 
00638           
00639           bool isBarrel = false;
00640           bool isEndcap = false;
00641           if (eta < 1.4442 && eta > -1.4442)
00642             {
00643               isBarrel = true;
00644             }
00645           else if ((eta > 1.56 && eta < 2.4) || (eta < -1.56 && eta > -2.4))
00646             {
00647               isEndcap = true;
00648             }
00649           
00650           //             // d0, chi2, nhits quality cuts
00651           //             double dxy = tk->dxy(beamSpotHandle->position());
00652           //             double normalizedChi2 = gm->normalizedChi2();
00653           //             double trackerHits = tk->numberOfValidHits();
00654           //             LogTrace("") << "\t... dxy, normalizedChi2, trackerHits, isTrackerMuon?: " << dxy << " [cm], " << normalizedChi2 << ", " << trackerHits << ", " << mu.isTrackerMuon();
00655           //             if (fabs(dxy)<dxyCut_) muon_sel[2] = true; 
00656           //             if (normalizedChi2<normalizedChi2Cut_) muon_sel[3] = true; 
00657           //             if (trackerHits>=trackerHitsCut_) muon_sel[4] = true; 
00658           //             if (mu.isTrackerMuon()) muon_sel[5] = true; 
00659           
00660           pt_before_->Fill(pt);
00661           eta_before_->Fill(eta);
00662           //             dxy_before_->Fill(dxy);
00663           //             chi2_before_->Fill(normalizedChi2);
00664           //             nhits_before_->Fill(trackerHits);
00665           //             tkmu_before_->Fill(mu.isTrackerMuon());
00666           
00667           
00668           // Electron ID cuts
00669           double sieie = (double) elec.sigmaIetaIeta();
00670           double detain = (double) elec.deltaEtaSuperClusterTrackAtVtx(); // think this is detain
00671           if (sieie < sieieCutBarrel_ && isBarrel) electron_sel[2] = true; 
00672           if (sieie < sieieCutEndcap_ && isEndcap) electron_sel[2] = true; 
00673           if (detain < detainCutBarrel_ && isBarrel) electron_sel[3] = true; 
00674           if (detain < detainCutEndcap_ && isEndcap) electron_sel[3] = true; 
00675           if (isBarrel)
00676             {
00677               LogTrace("") << "\t... sieie value " << sieie << " (barrel), pass? " << electron_sel[2]; 
00678               LogTrace("") << "\t... detain value " << detain << " (barrel), pass? " << electron_sel[3]; 
00679             }
00680           else if (isEndcap)
00681             {
00682               LogTrace("") << "\t... sieie value " << sieie << " (endcap), pass? " << electron_sel[2]; 
00683               LogTrace("") << "\t... detain value " << detain << " (endcap), pass? " << electron_sel[2]; 
00684             }
00685           
00686           if (isBarrel) 
00687             {
00688               sieiebarrel_before_->Fill(sieie);
00689               detainbarrel_before_->Fill(detain);
00690             }
00691           else if (isEndcap) 
00692             {
00693               sieieendcap_before_->Fill(sieie);
00694               detainendcap_before_->Fill(detain);
00695             }
00696           
00697           
00698           
00699           // Isolation cuts
00700           //double isovar = mu.isolationR03().sumPt;
00701           double ecalisovar = elec.dr03EcalRecHitSumEt();  // picked one set! 
00702           double hcalisovar = elec.dr03HcalTowerSumEt();   // try others if 
00703           double trkisovar = elec.dr04TkSumPt();           // doesn't work 
00704           //if (isCombinedIso_) {
00705           //isovar += mu.isolationR03().emEt;
00706           //isovar += mu.isolationR03().hadEt;
00707           //}
00708           //if (isRelativeIso_) isovar /= pt;
00709           if (ecalisovar<ecalIsoCutBarrel_ && isBarrel) electron_sel[4] = true; 
00710           if (ecalisovar<ecalIsoCutEndcap_ && isEndcap) electron_sel[4] = true; 
00711           if (hcalisovar<hcalIsoCutBarrel_ && isBarrel) electron_sel[5] = true; 
00712           if (hcalisovar<hcalIsoCutEndcap_ && isEndcap) electron_sel[5] = true; 
00713           if (trkisovar<trkIsoCutBarrel_ && isBarrel) electron_sel[6] = true;   
00714           if (trkisovar<trkIsoCutEndcap_ && isEndcap) electron_sel[6] = true;   
00715           if (isBarrel)
00716             {
00717               LogTrace("") << "\t... ecal isolation value " << ecalisovar << " (barrel), pass? " << electron_sel[4]; 
00718               LogTrace("") << "\t... hcal isolation value " << hcalisovar << " (barrel), pass? " << electron_sel[5];
00719               LogTrace("") << "\t... trk isolation value " << trkisovar << " (barrel), pass? " << electron_sel[6];
00720             }
00721           else if (isEndcap)
00722             {
00723               LogTrace("") << "\t... ecal isolation value " << ecalisovar << " (endcap), pass? " << electron_sel[4]; 
00724               LogTrace("") << "\t... hcal isolation value " << hcalisovar << " (endcap), pass? " << electron_sel[5];
00725               LogTrace("") << "\t... trk isolation value " << trkisovar << " (endcap), pass? " << electron_sel[6];
00726             }
00727           
00728           //iso_before_->Fill(isovar);
00729           if (isBarrel) 
00730             {
00731               ecalisobarrel_before_->Fill(ecalisovar);
00732               hcalisobarrel_before_->Fill(hcalisovar);
00733               trkisobarrel_before_->Fill(trkisovar);
00734             }
00735           else if (isEndcap) 
00736             {
00737               ecalisoendcap_before_->Fill(ecalisovar);
00738               hcalisoendcap_before_->Fill(hcalisovar);
00739               trkisoendcap_before_->Fill(trkisovar);
00740             }
00741           
00742           
00743           // HLT 
00744           if (trigger_fired) electron_sel[7] = true; 
00745           
00746           
00747           //             // MET/MT cuts
00748           double w_et = met_et+pt;
00749           double w_px = met_px+px;
00750           double w_py = met_py+py;
00751           
00752           double massT = w_et*w_et - w_px*w_px - w_py*w_py;
00753           massT = (massT>0) ? sqrt(massT) : 0;
00754           
00755           LogTrace("") << "\t... W mass, W_et, W_px, W_py: " << massT << ", " << w_et << ", " << w_px << ", " << w_py << " [GeV]";
00756           if (massT>mtMin_ && massT<mtMax_) electron_sel[8] = true; 
00757           mt_before_->Fill(massT);
00758           if (met_et>metMin_ && met_et<metMax_) electron_sel[9] = true; 
00759           
00760           //             // Acoplanarity cuts
00761           //             Geom::Phi<double> deltaphi(mu.phi()-atan2(met_py,met_px));
00762           //             double acop = deltaphi.value();
00763           //             if (acop<0) acop = - acop;
00764           //             acop = M_PI - acop;
00765           //             LogTrace("") << "\t... acoplanarity: " << acop;
00766           //             if (acop<acopCut_) muon_sel[10] = true; 
00767           //             acop_before_->Fill(acop);
00768           
00769           //             // Remaining flags (from global event information)
00770           //             if (nmuonsForZ1<1 || nmuonsForZ2<2) muon_sel[11] = true; 
00771           if (njets<=nJetMax_) electron_sel[10] = true; 
00772           
00773           // Collect necessary flags "per electron"
00774           int flags_passed = 0;
00775           bool rec_sel_this = true;
00776           bool eid_sel_this = true;
00777           bool iso_sel_this = true;
00778           bool met_sel_this = true;
00779           bool all_sel_this = true;
00780           for (int j=0; j<NFLAGS; ++j) 
00781             {
00782               if (electron_sel[j]) flags_passed += 1;
00783               if (j<2  && !electron_sel[j]) rec_sel_this = false;
00784               if (j<4  && !electron_sel[j]) eid_sel_this = false;
00785               if (j<7  && !electron_sel[j]) iso_sel_this = false;
00786               if (j<9 && !electron_sel[j]) met_sel_this = false;
00787               if (!electron_sel[j]) all_sel_this = false;
00788             }
00789           
00790           if (all_sel_this)
00791             {
00792               if (nGoodElectrons < 2)
00793                 {
00794                   goodElectron[nGoodElectrons][0] = 1.;
00795                   goodElectron[nGoodElectrons][1] = elec.massSqr();
00796                   goodElectron[nGoodElectrons][2] = elec.energy();
00797                   goodElectron[nGoodElectrons][3] = elec.px();
00798                   goodElectron[nGoodElectrons][4] = elec.py();
00799                   goodElectron[nGoodElectrons][5] = elec.pz();
00800                 }
00801               nGoodElectrons++;
00802             }
00803 
00804           //             // "rec" => pt,eta and quality cuts are satisfied
00805           //             if (rec_sel_this) rec_sel = true;
00806           //             // "iso" => "rec" AND "muon is isolated"
00807           //             if (iso_sel_this) iso_sel = true;
00808           //             // "hlt" => "iso" AND "event is triggered"
00809           //             if (hlt_sel_this) hlt_sel = true;
00810           //             // "all" => "met" AND "Z/top rejection cuts"
00811           //             if (all_sel_this) all_sel = true;
00812           
00813           // "rec" => pt,eta cuts are satisfied
00814           if (rec_sel_this) rec_sel = true;
00815           // "eid" => "rec" AND "electron passes ID"
00816           if (eid_sel_this) iso_sel = true;
00817           // "iso" => "eid" AND "electron is isolated"
00818           if (iso_sel_this) iso_sel = true;
00819           // "met" => "iso" AND "MET/MT"
00820           if (met_sel_this) met_sel = true;
00821           // "all" => "met" AND "event is triggered"
00822           if (all_sel_this) all_sel = true;
00823 
00824           // Do N-1 histograms now (and only once for global event quantities)
00825           if (flags_passed >= (NFLAGS-1)) 
00826             {
00827               if (!electron_sel[0] || flags_passed==NFLAGS) 
00828                 {
00829                   pt_after_->Fill(pt);
00830                 }
00831               if (!electron_sel[1] || flags_passed==NFLAGS) 
00832                 {
00833                   eta_after_->Fill(eta);
00834                 }
00835               if (!electron_sel[2] || flags_passed==NFLAGS) 
00836                 {
00837                   if (isBarrel)
00838                     {
00839                       sieiebarrel_after_->Fill(sieie);
00840                     }
00841                   else if (isEndcap)
00842                     {
00843                       sieieendcap_after_->Fill(sieie);
00844                     }
00845                 }
00846               if (!electron_sel[3] || flags_passed==NFLAGS) 
00847                 {
00848                   if (isBarrel)
00849                     {
00850                       detainbarrel_after_->Fill(detain);
00851                     }
00852                   else if (isEndcap)
00853                     {
00854                       detainendcap_after_->Fill(detain);
00855                     }
00856                 }
00857               if (!electron_sel[4] || flags_passed==NFLAGS) 
00858                 {
00859                   if (isBarrel)
00860                     {
00861                       ecalisobarrel_after_->Fill(ecalisovar);
00862                     }
00863                   else if (isEndcap)
00864                     {
00865                       ecalisoendcap_after_->Fill(ecalisovar);
00866                     }
00867                 }
00868               if (!electron_sel[5] || flags_passed==NFLAGS) 
00869                 {
00870                   if (isBarrel)
00871                     {
00872                       hcalisobarrel_after_->Fill(hcalisovar);
00873                     }
00874                   else if (isEndcap)
00875                     {
00876                       hcalisoendcap_after_->Fill(hcalisovar);
00877                     }
00878                 }
00879               if (!electron_sel[6] || flags_passed==NFLAGS) 
00880                 {
00881                   if (isBarrel)
00882                     {
00883                       trkisobarrel_after_->Fill(trkisovar);
00884                     }
00885                   else if (isEndcap)
00886                     {
00887                       trkisoendcap_after_->Fill(trkisovar);
00888                     }
00889                 }
00890               //                if (!electron_sel[3] || flags_passed==NFLAGS) 
00891               //                  {
00892               //                    detain_after_->Fill(detain);
00893               //                  }
00894               //                if (!electron_sel[4] || flags_passed==NFLAGS) 
00895               //                  {
00896               //                    ecaliso_after_->Fill(trackerHits);
00897               //                  }
00898               //                if (!electron_sel[5] || flags_passed==NFLAGS) 
00899               //                  {
00900               //                    tkelectr_after_->Fill(electr.isTrackerElectron());
00901               //                  }
00902               //                if (!electron_sel[6] || flags_passed==NFLAGS) 
00903               //                  {
00904               //                    iso_after_->Fill(isovar);
00905               //                  }
00906               if (!electron_sel[7] || flags_passed==NFLAGS) 
00907                 {
00908                   if (!hlt_hist_done) 
00909                     {
00910                       trig_after_->Fill(trigger_fired);
00911                     }
00912                 }
00913               hlt_hist_done = true;
00914               if (!electron_sel[8] || flags_passed==NFLAGS) 
00915                 {
00916                   mt_after_->Fill(massT);
00917                 }
00918               if (!electron_sel[9] || flags_passed==NFLAGS) 
00919                 {
00920                   if (!met_hist_done) {
00921                     met_after_->Fill(met_et);
00922                   }
00923                 }
00924               met_hist_done = true;
00925               //                   if (!muon_sel[10] || flags_passed==NFLAGS) 
00926               //                         acop_after_->Fill(acop);
00927               //                   if (!muon_sel[11] || flags_passed==NFLAGS) 
00928               //                         if (!nz1_hist_done) nz1_after_->Fill(nmuonsForZ1);
00929               //                         nz1_hist_done = true;
00930               //                   if (!muon_sel[11] || flags_passed==NFLAGS) 
00931               //                         if (!nz2_hist_done) nz2_after_->Fill(nmuonsForZ2);
00932               //                         nz2_hist_done = true;
00933               if (!electron_sel[10] || flags_passed==NFLAGS) {
00934                 if (!njets_hist_done) 
00935                   {
00936                     njets_after_->Fill(njets);
00937                     if (jet_et>10) //don't want low energy "jets"
00938                       {
00939                         jet_et_after_   ->Fill(jet_et);
00940                         jet_eta_after_  ->Fill(jet_eta);
00941                       }
00942                   }
00943               }
00944               njets_hist_done = true;
00945 
00946             } // end N-1 histos block
00947           
00948         } // end loop through electrons
00949 
00950       // inv mass = sqrt(m_1^2 + m_2^2 + 2*(E_1*E_2 - (px1*px2 + py1*py2 + pz1+pz2) ) )
00951       double invMass;
00952 
00953       nelectrons_before_->Fill(electronCollectionSize);
00954       if (electronCollectionSize > 1)
00955         {
00956           invMass = sqrt(electron[0][1] + electron[1][1] + 2*(electron[0][2]*electron[1][2] - (electron[0][3]*electron[1][3] + electron[0][4]*electron[1][4] + electron[0][5]*electron[1][5]) ) );
00957           invmass_before_->Fill(invMass);
00958         }
00959 
00960       nelectrons_after_->Fill(nGoodElectrons);
00961       if (nGoodElectrons > 1)
00962         {
00963           invMass = sqrt(goodElectron[0][1] + goodElectron[1][1] + 2*(goodElectron[0][2]*goodElectron[1][2] - (goodElectron[0][3]*goodElectron[1][3] + goodElectron[0][4]*goodElectron[1][4] + goodElectron[0][5]*goodElectron[1][5]) ) );
00964           invmass_after_->Fill(invMass);
00965         }
00966 
00967       // Collect final flags
00968       if (rec_sel) nrec++;
00969       if (eid_sel) neid++;
00970       if (iso_sel) niso++;
00971       //      if (hlt_sel) nhlt++;
00972       //      if (met_sel) nmet++;
00973 
00974       if (all_sel) {
00975             nsel++;
00976             LogTrace("") << ">>>> Event ACCEPTED";
00977       } else {
00978             LogTrace("") << ">>>> Event REJECTED";
00979       }
00980 
00981 
00982 
00983       return;
00984 
00985 }
00986 
00987 // This always returns only a positive deltaPhi
00988 double EwkElecDQM::calcDeltaPhi(double phi1, double phi2) {
00989 
00990   double deltaPhi = phi1 - phi2;
00991 
00992   if (deltaPhi < 0) deltaPhi = -deltaPhi;
00993 
00994   if (deltaPhi > 3.1415926) {
00995     deltaPhi = 2 * 3.1415926 - deltaPhi;
00996   }
00997 
00998   return deltaPhi;
00999 }
01000