CMS 3D CMS Logo

/data/git/CMSSW_5_3_11_patch5/src/DQMOffline/EGamma/plugins/ElectronAnalyzer.cc

Go to the documentation of this file.
00001 #include "DQMOffline/EGamma/plugins/ElectronAnalyzer.h"
00002 
00003 #include "DQMServices/Core/interface/MonitorElement.h"
00004 
00005 #include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
00006 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
00007 #include "DataFormats/EgammaReco/interface/BasicClusterFwd.h"
00008 #include "DataFormats/VertexReco/interface/VertexFwd.h"
00009 #include "DataFormats/VertexReco/interface/Vertex.h"
00010 #include "DataFormats/Common/interface/Handle.h"
00011 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
00012 #include "DataFormats/Common/interface/TriggerResults.h"
00013 
00014 #include "FWCore/Common/interface/TriggerNames.h"
00015 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00016 #include "FWCore/Framework/interface/EDAnalyzer.h"
00017 #include "FWCore/Framework/interface/Event.h"
00018 #include "FWCore/Framework/interface/MakerMacros.h"
00019 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00020 //#include "FWCore/Framework/interface/EDAnalyzer.h"
00021 #include "FWCore/ServiceRegistry/interface/Service.h"
00022 
00023 #include "CLHEP/Units/GlobalPhysicalConstants.h"
00024 #include "TMath.h"
00025 
00026 #include <iostream>
00027 
00028 using namespace reco ;
00029 
00030 ElectronAnalyzer::ElectronAnalyzer( const edm::ParameterSet & conf )
00031  : ElectronDqmAnalyzerBase(conf)
00032  {
00033   // general, collections
00034   Selection_ = conf.getParameter<int>("Selection");
00035   electronCollection_ = conf.getParameter<edm::InputTag>("ElectronCollection");
00036   matchingObjectCollection_ = conf.getParameter<edm::InputTag>("MatchingObjectCollection");
00037   trackCollection_ = conf.getParameter<edm::InputTag>("TrackCollection");
00038   vertexCollection_ = conf.getParameter<edm::InputTag>("VertexCollection");
00039   gsftrackCollection_ = conf.getParameter<edm::InputTag>("GsfTrackCollection");
00040   beamSpotTag_ = conf.getParameter<edm::InputTag>("BeamSpot");
00041   readAOD_ = conf.getParameter<bool>("ReadAOD");
00042 
00043   // matching
00044   matchingCondition_ = conf.getParameter<std::string>("MatchingCondition");
00045   assert (matchingCondition_=="Cone") ;
00046   maxPtMatchingObject_ = conf.getParameter<double>("MaxPtMatchingObject");
00047   maxAbsEtaMatchingObject_ = conf.getParameter<double>("MaxAbsEtaMatchingObject");
00048   deltaR_ = conf.getParameter<double>("DeltaR");
00049 
00050   // electron selection
00051   minEt_ = conf.getParameter<double>("MinEt");
00052   minPt_ = conf.getParameter<double>("MinPt");
00053   maxAbsEta_ = conf.getParameter<double>("MaxAbsEta");
00054   isEB_ = conf.getParameter<bool>("SelectEb");
00055   isEE_ = conf.getParameter<bool>("SelectEe");
00056   isNotEBEEGap_ = conf.getParameter<bool>("SelectNotEbEeGap");
00057   isEcalDriven_ = conf.getParameter<bool>("SelectEcalDriven");
00058   isTrackerDriven_ = conf.getParameter<bool>("SelectTrackerDriven");
00059   eOverPMinBarrel_ = conf.getParameter<double>("MinEopBarrel");
00060   eOverPMaxBarrel_ = conf.getParameter<double>("MaxEopBarrel");
00061   eOverPMinEndcaps_ = conf.getParameter<double>("MinEopEndcaps");
00062   eOverPMaxEndcaps_ = conf.getParameter<double>("MaxEopEndcaps");
00063   dEtaMinBarrel_ = conf.getParameter<double>("MinDetaBarrel");
00064   dEtaMaxBarrel_ = conf.getParameter<double>("MaxDetaBarrel");
00065   dEtaMinEndcaps_ = conf.getParameter<double>("MinDetaEndcaps");
00066   dEtaMaxEndcaps_ = conf.getParameter<double>("MaxDetaEndcaps");
00067   dPhiMinBarrel_ = conf.getParameter<double>("MinDphiBarrel");
00068   dPhiMaxBarrel_ = conf.getParameter<double>("MaxDphiBarrel");
00069   dPhiMinEndcaps_ = conf.getParameter<double>("MinDphiEndcaps");
00070   dPhiMaxEndcaps_ = conf.getParameter<double>("MaxDphiEndcaps");
00071   sigIetaIetaMinBarrel_ = conf.getParameter<double>("MinSigIetaIetaBarrel");
00072   sigIetaIetaMaxBarrel_ = conf.getParameter<double>("MaxSigIetaIetaBarrel");
00073   sigIetaIetaMinEndcaps_ = conf.getParameter<double>("MinSigIetaIetaEndcaps");
00074   sigIetaIetaMaxEndcaps_ = conf.getParameter<double>("MaxSigIetaIetaEndcaps");
00075   hadronicOverEmMaxBarrel_ = conf.getParameter<double>("MaxHoeBarrel");
00076   hadronicOverEmMaxEndcaps_ = conf.getParameter<double>("MaxHoeEndcaps");
00077   mvaMin_ = conf.getParameter<double>("MinMva");
00078   tipMaxBarrel_ = conf.getParameter<double>("MaxTipBarrel");
00079   tipMaxEndcaps_ = conf.getParameter<double>("MaxTipEndcaps");
00080   tkIso03Max_ = conf.getParameter<double>("MaxTkIso03");
00081   hcalIso03Depth1MaxBarrel_ = conf.getParameter<double>("MaxHcalIso03Depth1Barrel");
00082   hcalIso03Depth1MaxEndcaps_ = conf.getParameter<double>("MaxHcalIso03Depth1Endcaps");
00083   hcalIso03Depth2MaxEndcaps_ = conf.getParameter<double>("MaxHcalIso03Depth2Endcaps");
00084   ecalIso03MaxBarrel_ = conf.getParameter<double>("MaxEcalIso03Barrel");
00085   ecalIso03MaxEndcaps_ = conf.getParameter<double>("MaxEcalIso03Endcaps");
00086 
00087   // for trigger
00088   triggerResults_ = conf.getParameter<edm::InputTag>("TriggerResults");
00089 //  HLTPathsByName_= conf.getParameter<std::vector<std::string > >("HltPaths");
00090 //  HLTPathsByIndex_.resize(HLTPathsByName_.size());
00091 
00092   // histos limits and binning
00093   nbineta=conf.getParameter<int>("NbinEta");
00094   nbineta2D=conf.getParameter<int>("NbinEta2D");
00095   etamin=conf.getParameter<double>("EtaMin");
00096   etamax=conf.getParameter<double>("EtaMax");
00097   //
00098   nbinphi=conf.getParameter<int>("NbinPhi");
00099   nbinphi2D=conf.getParameter<int>("NbinPhi2D");
00100   phimin=conf.getParameter<double>("PhiMin");
00101   phimax=conf.getParameter<double>("PhiMax");
00102   //
00103   nbinpt=conf.getParameter<int>("NbinPt");
00104   nbinpteff=conf.getParameter<int>("NbinPtEff");
00105   nbinpt2D=conf.getParameter<int>("NbinPt2D");
00106   ptmax=conf.getParameter<double>("PtMax");
00107   //
00108   nbinp=conf.getParameter<int>("NbinP");
00109   nbinp2D=conf.getParameter<int>("NbinP2D");
00110   pmax=conf.getParameter<double>("PMax");
00111   //
00112   nbineop=conf.getParameter<int>("NbinEop");
00113   nbineop2D=conf.getParameter<int>("NbinEop2D");
00114   eopmax=conf.getParameter<double>("EopMax");
00115   eopmaxsht=conf.getParameter<double>("EopMaxSht");
00116   //
00117   nbindeta=conf.getParameter<int>("NbinDeta");
00118   detamin=conf.getParameter<double>("DetaMin");
00119   detamax=conf.getParameter<double>("DetaMax");
00120   //
00121   nbindphi=conf.getParameter<int>("NbinDphi");
00122   dphimin=conf.getParameter<double>("DphiMin");
00123   dphimax=conf.getParameter<double>("DphiMax");
00124   //
00125   nbindetamatch=conf.getParameter<int>("NbinDetaMatch");
00126   nbindetamatch2D=conf.getParameter<int>("NbinDetaMatch2D");
00127   detamatchmin=conf.getParameter<double>("DetaMatchMin");
00128   detamatchmax=conf.getParameter<double>("DetaMatchMax");
00129   //
00130   nbindphimatch=conf.getParameter<int>("NbinDphiMatch");
00131   nbindphimatch2D=conf.getParameter<int>("NbinDphiMatch2D");
00132   dphimatchmin=conf.getParameter<double>("DphiMatchMin");
00133   dphimatchmax=conf.getParameter<double>("DphiMatchMax");
00134   //
00135   nbinfhits=conf.getParameter<int>("NbinFhits");
00136   fhitsmax=conf.getParameter<double>("FhitsMax");
00137   //
00138   nbinlhits=conf.getParameter<int>("NbinLhits");
00139   lhitsmax=conf.getParameter<double>("LhitsMax");
00140   //
00141   nbinxyz=conf.getParameter<int>("NbinXyz");
00142   nbinxyz2D=conf.getParameter<int>("NbinXyz2D");
00143   //
00144   nbinpoptrue= conf.getParameter<int>("NbinPopTrue");
00145   poptruemin=conf.getParameter<double>("PopTrueMin");
00146   poptruemax=conf.getParameter<double>("PopTrueMax");
00147   //
00148   nbinmee= conf.getParameter<int>("NbinMee");
00149   meemin=conf.getParameter<double>("MeeMin");
00150   meemax=conf.getParameter<double>("MeeMax");
00151   //
00152   nbinhoe= conf.getParameter<int>("NbinHoe");
00153   hoemin=conf.getParameter<double>("HoeMin");
00154   hoemax=conf.getParameter<double>("HoeMax");
00155  }
00156 
00157 ElectronAnalyzer::~ElectronAnalyzer()
00158  {}
00159 
00160 void ElectronAnalyzer::book()
00161  {
00162   nEvents_ = 0 ;
00163   //nAfterTrigger_ = 0 ;
00164 
00165 
00166   // basic quantities
00167 //  h1_num_= bookH1("num","# rec electrons",20, 0.,20.,"N_{ele}");
00168 //  h1_vertexP = bookH1("vertexP",        "ele p at vertex",       nbinp,0.,pmax,"p_{vertex} (GeV/c)");
00169 //  h1_Et = bookH1("Et","ele SC transverse energy",  nbinpt,0.,ptmax,"E_{T} (GeV)");
00170 //  h1_vertexTIP = bookH1("vertexTIP","ele transverse impact parameter (wrt bs)",90,0.,0.15,"TIP (cm)");
00171 //  h1_charge = bookH1("charge","ele charge",5,-2.,2.,"charge");
00172   h1_vertexPt_barrel = bookH1("vertexPt_barrel","ele transverse momentum in barrel",nbinpt,0.,ptmax,"p_{T vertex} (GeV/c)");
00173   h1_vertexPt_endcaps = bookH1("vertexPt_endcaps","ele transverse momentum in endcaps",nbinpt,0.,ptmax,"p_{T vertex} (GeV/c)");
00174   h1_vertexEta = bookH1("vertexEta","ele momentum #eta",nbineta,etamin,etamax,"#eta");
00175 //  h1_vertexPhi = bookH1("vertexPhi","ele  momentum #phi",nbinphi,phimin,phimax,"#phi (rad)");
00176   h2_vertexEtaVsPhi = bookH2("vertexEtaVsPhi","ele momentum #eta vs #phi",nbineta2D,etamin,etamax,nbinphi2D,phimin,phimax,"#eta","#phi (rad)");
00177 //  h1_vertexX = bookH1("vertexX","ele vertex x",nbinxyz,-0.1,0.1,"x (cm)");
00178 //  h1_vertexY = bookH1("vertexY","ele vertex y",nbinxyz,-0.1,0.1,"y (cm)");
00179   h2_vertexXvsY = bookH2("vertexXvsY","ele vertex x vs y",nbinxyz2D,-0.1,0.1,nbinxyz2D,-0.1,0.1,"x (cm)","y (cm)");
00180   h1_vertexZ = bookH1("vertexZ","ele vertex z",nbinxyz,-25, 25,"z (cm)");
00181 
00182   // super-clusters
00183 //  h1_sclEn = bookH1("sclEnergy","ele supercluster energy",nbinp,0.,pmax,"E (GeV)");
00184 //  h1_sclEta = bookH1("sclEta","ele supercluster #eta",nbineta,etamin,etamax,"#eta");
00185 //  h1_sclPhi = bookH1("sclPhi","ele supercluster #phi",nbinphi,phimin,phimax,"#phi (rad)");
00186   h1_sclEt = bookH1("sclEt","ele supercluster transverse energy",nbinpt,0.,ptmax,"E_{T} (GeV)");
00187 
00188   // electron track
00189 //  h1_ambiguousTracks = bookH1("ambiguousTracks","ele # ambiguous tracks",  5,0.,5.,"N_{amb. tk}");
00190 //  h2_ambiguousTracksVsEta = bookH2("ambiguousTracksVsEta","ele # ambiguous tracks  vs #eta",  nbineta2D,etamin,etamax,5,0.,5.,"#eta","N_{amb. tk}");
00191 //  h2_ambiguousTracksVsPhi = bookH2("ambiguousTracksVsPhi","ele # ambiguous tracks  vs #phi",  nbinphi2D,phimin,phimax,5,0.,5.,"#phi(rad)","N_{amb. tk}");
00192 //  h2_ambiguousTracksVsPt = bookH2("ambiguousTracksVsPt","ele # ambiguous tracks vs pt",  nbinpt2D,0.,ptmax,5,0.,5.,"p_{T} (GeV/c),"N_{amb. tk}");
00193   h1_chi2 = bookH1("chi2","ele track #chi^{2}",100,0.,15.,"#Chi^{2}");
00194   py_chi2VsEta = bookP1("chi2VsEta","ele track #chi^{2} vs #eta",nbineta2D,etamin,etamax,0.,15.,"#eta","<#chi^{2}>");
00195   py_chi2VsPhi = bookP1("chi2VsPhi","ele track #chi^{2} vs #phi",nbinphi2D,phimin,phimax,0.,15.,"#phi (rad)","<#chi^{2}>");
00196   //h2_chi2VsPt = bookH2("chi2VsPt","ele track #chi^{2} vs pt",nbinpt2D,0.,ptmax,50,0.,15.,"p_{T} (GeV/c)","<#chi^{2}>");
00197   h1_foundHits = bookH1("foundHits","ele track # found hits",nbinfhits,0.,fhitsmax,"N_{hits}");
00198   py_foundHitsVsEta = bookP1("foundHitsVsEta","ele track # found hits vs #eta",nbineta2D,etamin,etamax,0.,fhitsmax,"#eta","<# hits>");
00199   py_foundHitsVsPhi = bookP1("foundHitsVsPhi","ele track # found hits vs #phi",nbinphi2D,phimin,phimax,0.,fhitsmax,"#phi (rad)","<# hits>");
00200 //  h2_foundHitsVsPt = bookH2("foundHitsVsPt","ele track # found hits vs pt",nbinpt2D,0.,ptmax,nbinfhits,0.,fhitsmax,"p_{T} (GeV/c)","<# hits>");
00201   h1_lostHits = bookH1("lostHits","ele track # lost hits",5,0.,5.,"N_{lost hits}");
00202   py_lostHitsVsEta = bookP1("lostHitsVsEta","ele track # lost hits vs #eta",nbineta2D,etamin,etamax,0.,lhitsmax,"#eta","<# hits>");
00203   py_lostHitsVsPhi = bookP1("lostHitsVsPhi","ele track # lost hits vs #eta",nbinphi2D,phimin,phimax,0.,lhitsmax,"#phi (rad)","<# hits>");
00204 //  h2_lostHitsVsPt = bookH2("lostHitsVsPt","ele track # lost hits vs #eta",nbinpt2D,0.,ptmax,nbinlhits,0.,lhitsmax,"p_{T} (GeV/c)","<# hits>");
00205 
00206   // electron matching and ID
00207   //h1_EoPout = bookH1( "EoPout","ele E/P_{out}",nbineop,0.,eopmax,"E_{seed}/P_{out}");
00208   //h1_dEtaCl_propOut = bookH1( "dEtaCl_propOut","ele #eta_{cl} - #eta_{tr}, prop from outermost",nbindetamatch,detamatchmin,detamatchmax,"#eta_{seedcl} - #eta_{tr}");
00209   //h1_dPhiCl_propOut = bookH1( "dPhiCl_propOut","ele #phi_{cl} - #phi_{tr}, prop from outermost",nbindphimatch,dphimatchmin,dphimatchmax,"#phi_{seedcl} - #phi_{tr} (rad)");
00210   //h1_outerP = bookH1( "outerP","ele track outer p, mean",nbinp,0.,pmax,"P_{out} (GeV/c)");
00211   //h1_outerP_mode = bookH1( "outerP_mode","ele track outer p, mode",nbinp,0.,pmax,"P_{out} (GeV/c)");
00212   h1_Eop_barrel = bookH1( "Eop_barrel","ele E/P_{vertex} in barrel",nbineop,0.,eopmax,"E/P_{vertex}");
00213   h1_Eop_endcaps = bookH1( "Eop_endcaps","ele E/P_{vertex} in endcaps",nbineop,0.,eopmax,"E/P_{vertex}");
00214   py_EopVsPhi = bookP1("EopVsPhi","ele E/P_{vertex} vs #phi",nbinphi2D,phimin,phimax,0.,eopmax,"#phi (rad)","<E/P_{vertex}>");
00215 //  h2_EopVsPt = bookH2("EopVsPt","ele E/P_{vertex} vs pt",nbinpt2D,0.,ptmax,nbineop,0.,eopmax,"p_{T} (GeV/c)","E/P_{vertex}");
00216   h1_EeleOPout_barrel = bookH1( "EeleOPout_barrel","ele E_{ele}/P_{out} in barrel",nbineop,0.,eopmax,"E_{ele}/P_{out}");
00217   h1_EeleOPout_endcaps = bookH1( "EeleOPout_endcaps","ele E_{ele}/P_{out} in endcaps",nbineop,0.,eopmax,"E_{ele}/P_{out}");
00218 //  h2_EeleOPoutVsPhi = bookH2("EeleOPoutVsPhi","ele E_{ele}/P_{out} vs #phi",nbinphi2D,phimin,phimax,nbineop,0.,eopmax,"#phi","E_{ele}/P_{out}");
00219 //  h2_EeleOPoutVsPt = bookH2("EeleOPoutVsPt","ele E_{ele}/P_{out} vs pt",nbinpt2D,0.,ptmax,nbineop,0.,eopmax,"p_{T} (GeV/c)","E_{ele}/P_{out}");
00220   h1_dEtaSc_propVtx_barrel = bookH1( "dEtaSc_propVtx_barrel","ele #eta_{sc} - #eta_{tr}, prop from vertex, in barrel",nbindetamatch,detamatchmin,detamatchmax,"#eta_{sc} - #eta_{tr}");
00221   h1_dEtaSc_propVtx_endcaps = bookH1( "dEtaSc_propVtx_endcaps","ele #eta_{sc} - #eta_{tr}, prop from vertex, in endcaps",nbindetamatch,detamatchmin,detamatchmax,"#eta_{sc} - #eta_{tr}");
00222   py_dEtaSc_propVtxVsPhi = bookP1("dEtaSc_propVtxVsPhi","ele #eta_{sc} - #eta_{tr}, prop from vertex vs #phi",nbinphi2D,phimin,phimax,detamatchmin,detamatchmax,"#phi (rad)","<#eta_{sc} - #eta_{tr}>");
00223 //  h2_dEtaSc_propVtxVsPt = bookH2("dEtaSc_propVtxVsPt","ele #eta_{sc} - #eta_{tr}, prop from vertex vs pt",nbinpt2D,0.,ptmax,nbindetamatch,detamatchmin,detamatchmax,"#eta_{sc} - #eta_{tr}");
00224   h1_dEtaEleCl_propOut_barrel = bookH1( "dEtaEleCl_propOut_barrel","ele #eta_{EleCl} - #eta_{tr}, prop from outermost, in barrel",nbindetamatch,detamatchmin,detamatchmax,"#eta_{elecl} - #eta_{tr}");
00225   h1_dEtaEleCl_propOut_endcaps = bookH1( "dEtaEleCl_propOut_endcaps","ele #eta_{EleCl} - #eta_{tr}, prop from outermost, in endcaps",nbindetamatch,detamatchmin,detamatchmax,"#eta_{elecl} - #eta_{tr}");
00226 //  h2_dEtaEleCl_propOutVsPhi = bookH2("dEtaEleCl_propOutVsPhi","ele #eta_{EleCl} - #eta_{tr}, prop from outermost vs #phi",nbinphi2D,phimin,phimax,nbindetamatch,detamatchmin,detamatchmax,"#phi (rad)","#eta_{elecl} - #eta_{tr}");
00227 //  h2_dEtaEleCl_propOutVsPt = bookH2("dEtaEleCl_propOutVsPt","ele #eta_{EleCl} - #eta_{tr}, prop from outermost vs pt",nbinpt2D,0.,ptmax,nbindetamatch,detamatchmin,detamatchmax,"p_{T} (GeV/c)","#eta_{elecl} - #eta_{tr}");
00228   h1_dPhiSc_propVtx_barrel = bookH1( "dPhiSc_propVtx_barrel","ele #phi_{sc} - #phi_{tr}, prop from vertex, in barrel",nbindphimatch,dphimatchmin,dphimatchmax,"#phi_{sc} - #phi_{tr} (rad)");
00229   h1_dPhiSc_propVtx_endcaps = bookH1( "dPhiSc_propVtx_endcaps","ele #phi_{sc} - #phi_{tr}, prop from vertex, in endcaps",nbindphimatch,dphimatchmin,dphimatchmax,"#phi_{sc} - #phi_{tr} (rad)");
00230   py_dPhiSc_propVtxVsPhi = bookP1("dPhiSc_propVtxVsPhi","ele #phi_{sc} - #phi_{tr}, prop from vertex vs #phi",nbinphi2D,phimin,phimax,dphimatchmin,dphimatchmax,"#phi (rad)","<#phi_{sc} - #phi_{tr}> (rad)");
00231 //  h2_dPhiSc_propVtxVsPt = bookH2("dPhiSc_propVtxVsPt","ele #phi_{sc} - #phi_{tr}, prop from vertex vs pt",nbinpt2D,0.,ptmax,nbindphimatch,dphimatchmin,dphimatchmax,"p_{T} (GeV/c)","#phi_{sc} - #phi_{tr} (rad)");
00232   h1_dPhiEleCl_propOut_barrel = bookH1( "dPhiEleCl_propOut_barrel","ele #phi_{EleCl} - #phi_{tr}, prop from outermost, in barrel",nbindphimatch,dphimatchmin,dphimatchmax,"#phi_{elecl} - #phi_{tr} (rad)");
00233   h1_dPhiEleCl_propOut_endcaps = bookH1( "dPhiEleCl_propOut_endcaps","ele #phi_{EleCl} - #phi_{tr}, prop from outermost, in endcaps",nbindphimatch,dphimatchmin,dphimatchmax,"#phi_{elecl} - #phi_{tr} (rad)");
00234 //  h2_dPhiEleCl_propOutVsPhi = bookH2("dPhiEleCl_propOutVsPhi","ele #phi_{EleCl} - #phi_{tr}, prop from outermost vs #phi",nbinphi2D,phimin,phimax,nbindphimatch,dphimatchmin,dphimatchmax,"#phi_{elecl} - #phi_{tr} (rad)");
00235 //  h2_dPhiEleCl_propOutVsPt = bookH2("dPhiEleCl_propOutVsPt","ele #phi_{EleCl} - #phi_{tr}, prop from outermost vs pt",nbinpt2D,0.,ptmax,nbindphimatch,dphimatchmin,dphimatchmax,"p_{T} (GeV/c)","#phi_{elecl} - #phi_{tr} (rad)");
00236   h1_Hoe_barrel = bookH1("Hoe_barrel","ele hadronic energy / em energy, in barrel", nbinhoe, hoemin, hoemax,"H/E","Events","ELE_LOGY E1 P") ;
00237   h1_Hoe_endcaps = bookH1("Hoe_endcaps","ele hadronic energy / em energy, in endcaps", nbinhoe, hoemin, hoemax,"H/E","Events","ELE_LOGY E1 P") ;
00238   py_HoeVsPhi = bookP1("HoeVsPhi","ele hadronic energy / em energy vs #phi",nbinphi2D,phimin,phimax,hoemin,hoemax,"#phi (rad)","<H/E>","E1 P") ;
00239 //  h2_HoeVsPt = bookH2("HoeVsPt","ele hadronic energy / em energy vs pt",nbinpt2D,0.,ptmax,nbinhoe,hoemin,hoemax,"p_{T} (GeV/c)","<H/E>","ELE_LOGY COLZ") ;
00240   h1_sclSigEtaEta_barrel = bookH1("sclSigEtaEta_barrel","ele supercluster sigma ieta ieta in barrel",100,0.,0.05,"sietaieta");
00241   h1_sclSigEtaEta_endcaps = bookH1("sclSigEtaEta_endcaps","ele supercluster sigma ieta ieta in endcaps",100,0.,0.05,"sietaieta");
00242 
00243   // fbrem
00244 //  h1_innerPt_mean = bookH1( "innerPt_mean","ele track inner p_{T}, mean",nbinpt,0.,ptmax,"P_{T in} (GeV/c)");
00245 //  h1_outerPt_mean = bookH1( "outerPt_mean","ele track outer p_{T}, mean",nbinpt,0.,ptmax,"P_{T out} (GeV/c)");
00246 //  h1_outerPt_mode = bookH1( "outerPt_mode","ele track outer p_{T}, mode",nbinpt,0.,ptmax,"P_{T out} (GeV/c)");
00247 //  //h_PinMnPout_mode = bookH1( "PinMnPout_mode","ele track inner p - outer p, mode"   ,nbinp,0.,100.,"P_{in} - P_{out} (GeV/c)");
00248 //  h1_PinMnPout = bookH1( "PinMnPout","ele track inner p - outer p, mean" ,nbinp,0.,200.,"P_{in} - P_{out} (GeV/c)");
00249 //  h1_PinMnPout_mode = bookH1( "PinMnPout_mode","ele track inner p - outer p, mode",nbinp,0.,100.,"P_{in} - P_{out}, mode (GeV/c)");
00250   h1_fbrem = bookH1("fbrem","ele brem fraction",100,0.,1.,"P_{in} - P_{out} / P_{in}") ;
00251   py_fbremVsEta = bookP1("fbremVsEta","ele brem fraction vs #eta",nbineta2D,etamin,etamax,0.,1.,"#eta","<P_{in} - P_{out} / P_{in}>") ;
00252   py_fbremVsPhi = bookP1("fbremVsPhi","ele brem fraction vs #phi",nbinphi2D,phimin,phimax,0.,1.,"#phi (rad)","<P_{in} - P_{out} / P_{in}>") ;
00253 //  h2_fbremVsPt = bookH2("fbremVsPt","ele brem fraction vs pt",nbinpt2D,0.,ptmax,100,0.,1.,"p_{T} (GeV/c)","<P_{in} - P_{out} / P_{in}>") ;
00254   h1_classes = bookH1("classes","ele electron classes",10,0.0,10.);
00255 
00256   // pflow
00257   h1_mva = bookH1( "mva","ele identification mva",100,-1.,1.,"mva");
00258   h1_provenance = bookH1( "provenance","ele provenance",5,-2.,3.,"provenance");
00259 
00260   // isolation
00261   h1_tkSumPt_dr03 = bookH1("tkSumPt_dr03","tk isolation sum, dR=0.3",100,0.0,20.,"TkIsoSum (GeV/c)","Events","ELE_LOGY E1 P");
00262   h1_ecalRecHitSumEt_dr03 = bookH1("ecalRecHitSumEt_dr03","ecal isolation sum, dR=0.3",100,0.0,20.,"EcalIsoSum (GeV)","Events","ELE_LOGY E1 P");
00263   h1_hcalTowerSumEt_dr03 = bookH1("hcalTowerSumEt_dr03","hcal isolation sum, dR=0.3",100,0.0,20.,"HcalIsoSum (GeV)","Events","ELE_LOGY E1 P");
00264 //  h1_hcalDepth1TowerSumEt_dr03 = bookH1("hcalDepth1TowerSumEt_dr03","hcal depth1 isolation sum, dR=0.3",100,0.0,20.,"Hcal1IsoSum (GeV)","Events","ELE_LOGY E1 P");
00265 //  h1_hcalDepth2TowerSumEt_dr03 = bookH1("hcalDepth2TowerSumEt_dr03","hcal depth2 isolation sum, dR=0.3",100,0.0,20.,"Hcal2IsoSum (GeV)","Events","ELE_LOGY E1 P");
00266 //  h1_tkSumPt_dr04 = bookH1("tkSumPt_dr04","hcal isolation sum",100,0.0,20.,"TkIsoSum (GeV/c)","Events","ELE_LOGY E1 P");
00267 //  h1_ecalRecHitSumEt_dr04 = bookH1("ecalRecHitSumEt_dr04","ecal isolation sum, dR=0.4",100,0.0,20.,"EcalIsoSum (GeV)","Events","ELE_LOGY E1 P");
00268 //  h1_hcalTowerSumEt_dr04 = bookH1("hcalTowerSumEt_dr04","hcal isolation sum, dR=0.4",100,0.0,20.,"HcalIsoSum (GeV)","Events","ELE_LOGY E1 P");
00271 
00272   // di-electron mass
00273   setBookIndex(200) ;
00274   h1_mee = bookH1("mee","ele pairs invariant mass", nbinmee, meemin, meemax,"m_{ee} (GeV/c^{2})");
00275   h1_mee_os = bookH1("mee_os","ele pairs invariant mass, opposite sign", nbinmee, meemin, meemax,"m_{e^{+}e^{-}} (GeV/c^{2})");
00276 
00277 
00278 
00279   //===========================
00280   // histos for matching and matched matched objects
00281   //===========================
00282 
00283   // matching object
00284   std::string matchingObjectType ;
00285   if (std::string::npos!=matchingObjectCollection_.label().find("SuperCluster",0))
00286    { matchingObjectType = "SC" ; }
00287   if (matchingObjectType=="")
00288    { edm::LogError("ElectronMcFakeValidator::beginJob")<<"Unknown matching object type !" ; }
00289   else
00290    { edm::LogInfo("ElectronMcFakeValidator::beginJob")<<"Matching object type: "<<matchingObjectType ; }
00291 //  std::string htitle = "# "+matchingObjectType+"s", xtitle = "N_{"+matchingObjectType+"}" ;
00292 //  h1_matchingObject_Num = bookH1withSumw2("matchingObject_Num",htitle,nbinfhits,0.,fhitsmax,xtitle) ;
00293 
00294   // matching object distributions
00295   h1_matchingObject_Eta = bookH1withSumw2("matchingObject_Eta",matchingObjectType+" #eta",nbineta,etamin,etamax,"#eta_{SC}");
00296 //  h1_matchingObject_AbsEta = bookH1withSumw2("matchingObject_AbsEta",matchingObjectType+" |#eta|",nbineta/2,0.,etamax,"|#eta|_{SC}");
00297 //  h1_matchingObject_P = bookH1withSumw2("matchingObject_P",matchingObjectType+" p",nbinp,0.,pmax,"E_{SC} (GeV)");
00298   h1_matchingObject_Pt = bookH1withSumw2("matchingObject_Pt",matchingObjectType+" pt",nbinpteff,5.,ptmax,"pt_{SC} (GeV/c)");
00299   h1_matchingObject_Phi = bookH1withSumw2("matchingObject_Phi",matchingObjectType+" #phi",nbinphi,phimin,phimax,"#phi (rad)");
00300 //  h1_matchingObject_Z = bookH1withSumw2("matchingObject_Z",matchingObjectType+" z",nbinxyz,-25,25,"z (cm)");
00301 
00302   h1_matchedObject_Eta = bookH1withSumw2("matchedObject_Eta","Efficiency vs matching SC #eta",nbineta,etamin,etamax,"#eta_{SC}");
00303 //  h1_matchedObject_AbsEta = bookH1withSumw2("matchedObject_AbsEta","Efficiency vs matching SC |#eta|",nbineta/2,0.,2.5,"|#eta|_{SC}");
00304   h1_matchedObject_Pt = bookH1withSumw2("matchedObject_Pt","Efficiency vs matching SC E_{T}",nbinpteff,5.,ptmax,"pt_{SC} (GeV/c)");
00305   h1_matchedObject_Phi = bookH1withSumw2("matchedObject_Phi","Efficiency vs matching SC #phi",nbinphi,phimin,phimax,"#phi (rad)");
00306 //  h1_matchedObject_Z = bookH1withSumw2("matchedObject_Z","Efficiency vs matching SC z",nbinxyz,-25,25,"z (cm)");
00307 
00308 //  // classes
00309 //  h1_matchedEle_eta = bookH1( "matchedEle_eta", "ele electron #eta",  nbineta/2,0.0,etamax,"#eta");
00310 //  h1_matchedEle_eta_golden = bookH1( "matchedEle_eta_golden", "ele electron #eta golden",  nbineta/2,0.0,etamax,"#eta");
00311 //  h1_matchedEle_eta_shower = bookH1( "matchedEle_eta_shower", "ele electron #eta showering",  nbineta/2,0.0,etamax,"#eta");
00312 //  //h1_matchedEle_eta_bbrem = bookH1( "matchedEle_eta_bbrem", "ele electron #eta bbrem",  nbineta/2,0.0,etamax,"#eta");
00313 //  //h1_matchedEle_eta_narrow = bookH1( "matchedEle_eta_narrow", "ele electron #eta narrow",  nbineta/2,0.0,etamax,"#eta");
00314 //
00315  }
00316 
00317 void ElectronAnalyzer::analyze( const edm::Event& iEvent, const edm::EventSetup & iSetup )
00318 {
00319   nEvents_++ ;
00320 //  if (!trigger(iEvent)) return ;
00321 //  nAfterTrigger_++ ;
00322 
00323 //  edm::Handle<SuperClusterCollection> barrelSCs ;
00324 //  iEvent.getByLabel("correctedHybridSuperClusters",barrelSCs) ;
00325 //  edm::Handle<SuperClusterCollection> endcapsSCs ;
00326 //  iEvent.getByLabel("correctedMulti5x5SuperClustersWithPreshower",endcapsSCs) ;
00327 //  std::cout<<"[ElectronMcSignalValidator::analyze]"
00328 //    <<"Event "<<iEvent.id()
00329 //    <<" has "<<barrelSCs.product()->size()<<" barrel superclusters"
00330 //    <<" and "<<endcapsSCs.product()->size()<<" endcaps superclusters" ;
00331 //
00332   edm::Handle<GsfElectronCollection> gsfElectrons ;
00333   iEvent.getByLabel(electronCollection_,gsfElectrons) ;
00334   edm::Handle<reco::SuperClusterCollection> recoClusters ;
00335   iEvent.getByLabel(matchingObjectCollection_,recoClusters) ;
00336   edm::Handle<reco::TrackCollection> tracks;
00337   iEvent.getByLabel(trackCollection_,tracks);
00338   edm::Handle<reco::GsfTrackCollection> gsfTracks;
00339   iEvent.getByLabel(gsftrackCollection_,gsfTracks);
00340   edm::Handle<reco::VertexCollection> vertices;
00341   iEvent.getByLabel(vertexCollection_,vertices);
00342   edm::Handle<reco::BeamSpot> recoBeamSpotHandle ;
00343   iEvent.getByLabel(beamSpotTag_,recoBeamSpotHandle) ;
00344   const BeamSpot bs = *recoBeamSpotHandle ;
00345 
00346   int ievt = iEvent.id().event();
00347   int irun = iEvent.id().run();
00348   int ils = iEvent.luminosityBlock();
00349 
00350   edm::LogInfo("ElectronAnalyzer::analyze")
00351     <<"Treating "<<gsfElectrons.product()->size()<<" electrons"
00352     <<" from event "<<ievt<<" in run "<<irun<<" and lumiblock "<<ils ;
00353   //h1_num_->Fill((*gsfElectrons).size()) ;
00354 
00355   // selected rec electrons
00356   reco::GsfElectronCollection::const_iterator gsfIter ;
00357   for
00358    ( gsfIter=gsfElectrons->begin() ;
00359      gsfIter!=gsfElectrons->end();
00360      gsfIter++ )
00361    {
00362     // vertex TIP
00363     double vertexTIP =
00364      (gsfIter->vertex().x()-bs.position().x()) * (gsfIter->vertex().x()-bs.position().x()) +
00365      (gsfIter->vertex().y()-bs.position().y()) * (gsfIter->vertex().y()-bs.position().y()) ;
00366     vertexTIP = sqrt(vertexTIP) ;
00367 
00368     // select electrons
00369     if (!selected(gsfIter,vertexTIP)) continue ;
00370 
00371     // basic quantities
00372     if (gsfIter->isEB()) h1_vertexPt_barrel->Fill( gsfIter->pt() );
00373     if (gsfIter->isEE()) h1_vertexPt_endcaps->Fill( gsfIter->pt() );
00374     h1_vertexEta->Fill( gsfIter->eta() );
00375 //    h1_vertexPhi->Fill( gsfIter->phi() );
00376     h2_vertexEtaVsPhi->Fill( gsfIter->eta(), gsfIter->phi() );
00377 //    h1_vertexX->Fill( gsfIter->vertex().x() );
00378 //    h1_vertexY->Fill( gsfIter->vertex().y() );
00379     h2_vertexXvsY->Fill( gsfIter->vertex().x(), gsfIter->vertex().y() );
00380     h1_vertexZ->Fill( gsfIter->vertex().z() );
00381 //    h1_vertexP->Fill( gsfIter->p() );
00382 //    h1_Et->Fill( gsfIter->superCluster()->energy()/cosh( gsfIter->superCluster()->eta()) );
00383 //    h1_vertexTIP->Fill( vertexTIP );
00384 //    h1_charge->Fill( gsfIter->charge() );
00385 
00386     // supercluster related distributions
00387     reco::SuperClusterRef sclRef = gsfIter->superCluster() ;
00388     // ALREADY DONE IN GSF ELECTRON CORE
00389     //    if (!gsfIter->ecalDrivenSeed()&&gsfIter->trackerDrivenSeed())
00390     //      sclRef = gsfIter->pflowSuperCluster() ;
00391 //    h1_sclEn->Fill(sclRef->energy());
00392 //    h1_sclEta->Fill(sclRef->eta());
00393 //    h1_sclPhi->Fill(sclRef->phi());
00394     double R=TMath::Sqrt(sclRef->x()*sclRef->x() + sclRef->y()*sclRef->y() +sclRef->z()*sclRef->z());
00395     double Rt=TMath::Sqrt(sclRef->x()*sclRef->x() + sclRef->y()*sclRef->y());
00396     h1_sclEt->Fill(sclRef->energy()*(Rt/R));
00397 
00398     // track related distributions
00399 //    h1_ambiguousTracks->Fill( gsfIter->ambiguousGsfTracksSize() );
00400 //    h2_ambiguousTracksVsEta->Fill( gsfIter->eta(), gsfIter->ambiguousGsfTracksSize() );
00401 //    h2_ambiguousTracksVsPhi->Fill( gsfIter->phi(), gsfIter->ambiguousGsfTracksSize() );
00402 //    h2_ambiguousTracksVsPt->Fill( gsfIter->pt(), gsfIter->ambiguousGsfTracksSize() );
00403     if (!readAOD_)
00404      { // track extra does not exist in AOD
00405       h1_foundHits->Fill( gsfIter->gsfTrack()->numberOfValidHits() );
00406       py_foundHitsVsEta->Fill( gsfIter->eta(), gsfIter->gsfTrack()->numberOfValidHits() );
00407       py_foundHitsVsPhi->Fill( gsfIter->phi(), gsfIter->gsfTrack()->numberOfValidHits() );
00408       //h2_foundHitsVsPt->Fill( gsfIter->pt(), gsfIter->gsfTrack()->numberOfValidHits() );
00409       h1_lostHits->Fill( gsfIter->gsfTrack()->numberOfLostHits() );
00410       py_lostHitsVsEta->Fill( gsfIter->eta(), gsfIter->gsfTrack()->numberOfLostHits() );
00411       py_lostHitsVsPhi->Fill( gsfIter->phi(), gsfIter->gsfTrack()->numberOfLostHits() );
00412       //h2_lostHitsVsPt->Fill( gsfIter->pt(), gsfIter->gsfTrack()->numberOfLostHits() );
00413       h1_chi2->Fill( gsfIter->gsfTrack()->normalizedChi2() );
00414       py_chi2VsEta->Fill( gsfIter->eta(), gsfIter->gsfTrack()->normalizedChi2() );
00415       py_chi2VsPhi->Fill( gsfIter->phi(), gsfIter->gsfTrack()->normalizedChi2() );
00416       //h2_chi2VsPt->Fill( gsfIter->pt(), gsfIter->gsfTrack()->normalizedChi2() );
00417      }
00418 
00419     // match distributions
00420     if (gsfIter->isEB())
00421      {
00422       h1_Eop_barrel->Fill( gsfIter->eSuperClusterOverP() );
00423       h1_EeleOPout_barrel->Fill( gsfIter->eEleClusterOverPout() );
00424       h1_dEtaSc_propVtx_barrel->Fill(gsfIter->deltaEtaSuperClusterTrackAtVtx());
00425       h1_dEtaEleCl_propOut_barrel->Fill(gsfIter->deltaEtaEleClusterTrackAtCalo());
00426       h1_dPhiSc_propVtx_barrel->Fill(gsfIter->deltaPhiSuperClusterTrackAtVtx());
00427       h1_dPhiEleCl_propOut_barrel->Fill(gsfIter->deltaPhiEleClusterTrackAtCalo());
00428       h1_Hoe_barrel->Fill(gsfIter->hadronicOverEm());
00429       h1_sclSigEtaEta_barrel->Fill( gsfIter->scSigmaEtaEta() );
00430      }
00431     if (gsfIter->isEE())
00432      {
00433       h1_Eop_endcaps->Fill( gsfIter->eSuperClusterOverP() );
00434       h1_EeleOPout_endcaps->Fill( gsfIter->eEleClusterOverPout() );
00435       h1_dEtaSc_propVtx_endcaps->Fill(gsfIter->deltaEtaSuperClusterTrackAtVtx());
00436       h1_dEtaEleCl_propOut_endcaps->Fill(gsfIter->deltaEtaEleClusterTrackAtCalo());
00437       h1_dPhiSc_propVtx_endcaps->Fill(gsfIter->deltaPhiSuperClusterTrackAtVtx());
00438       h1_dPhiEleCl_propOut_endcaps->Fill(gsfIter->deltaPhiEleClusterTrackAtCalo());
00439       h1_Hoe_endcaps->Fill(gsfIter->hadronicOverEm());
00440       h1_sclSigEtaEta_endcaps->Fill( gsfIter->scSigmaEtaEta() );
00441      }
00442     py_EopVsPhi->Fill( gsfIter->phi(), gsfIter->eSuperClusterOverP() );
00443 //    h2_EopVsPt->Fill( gsfIter->pt(), gsfIter->eSuperClusterOverP() );
00444 //    h2_EeleOPoutVsPhi->Fill( gsfIter->phi(), gsfIter->eEleClusterOverPout() );
00445 //    h2_EeleOPoutVsPt->Fill( gsfIter->pt(), gsfIter->eEleClusterOverPout() );
00446     py_dEtaSc_propVtxVsPhi->Fill(gsfIter->phi(), gsfIter->deltaEtaSuperClusterTrackAtVtx());
00447 //    h2_dEtaSc_propVtxVsPt->Fill(gsfIter->pt(), gsfIter->deltaEtaSuperClusterTrackAtVtx());
00448 //    h2_dEtaEleCl_propOutVsPhi->Fill(gsfIter->phi(), gsfIter->deltaEtaEleClusterTrackAtCalo());
00449 //    h2_dEtaEleCl_propOutVsPt->Fill(gsfIter->pt(), gsfIter->deltaEtaEleClusterTrackAtCalo());
00450     py_dPhiSc_propVtxVsPhi->Fill(gsfIter->phi(), gsfIter->deltaPhiSuperClusterTrackAtVtx());
00451 //    h2_dPhiSc_propVtxVsPt->Fill(gsfIter->pt(), gsfIter->deltaPhiSuperClusterTrackAtVtx());
00452 //    h2_dPhiEleCl_propOutVsPhi->Fill(gsfIter->phi(), gsfIter->deltaPhiEleClusterTrackAtCalo());
00453 //    h2_dPhiEleCl_propOutVsPt->Fill(gsfIter->pt(), gsfIter->deltaPhiEleClusterTrackAtCalo());
00454     py_HoeVsPhi->Fill(gsfIter->phi(), gsfIter->hadronicOverEm());
00455 //    h2_HoeVsPt->Fill(gsfIter->pt(), gsfIter->hadronicOverEm());
00456 
00457 //    // from gsf track interface, hence using mean
00458 //    if (!readAOD_)
00459 //     { // track extra does not exist in AOD
00460 //      h_PinMnPout->Fill( gsfIter->gsfTrack()->innerMomentum().R() - gsfIter->gsfTrack()->outerMomentum().R() );
00461 //      //h_outerP->Fill( gsfIter->gsfTrack()->outerMomentum().R() );
00462 //      h_innerPt_mean->Fill( gsfIter->gsfTrack()->innerMomentum().Rho() );
00463 //      h_outerPt_mean->Fill( gsfIter->gsfTrack()->outerMomentum().Rho() );
00464 //     }
00465 //
00466 //    // from electron interface, hence using mode
00467 //    h_PinMnPout_mode->Fill( gsfIter->trackMomentumAtVtx().R() - gsfIter->trackMomentumOut().R() );
00468 //    //h_outerP_mode->Fill( gsfIter->trackMomentumOut().R() );
00469 //    h_outerPt_mode->Fill( gsfIter->trackMomentumOut().Rho() );
00470 //
00471 
00472     // fbrem, classes
00473     h1_fbrem->Fill(gsfIter->fbrem()) ;
00474     py_fbremVsEta->Fill(gsfIter->eta(),gsfIter->fbrem()) ;
00475     py_fbremVsPhi->Fill(gsfIter->phi(),gsfIter->fbrem()) ;
00476 //    h2_fbremVsPt->Fill(gsfIter->pt(),gsfIter->fbrem()) ;
00477     int eleClass = gsfIter->classification() ;
00478     if (gsfIter->isEE()) eleClass+=5;
00479     h1_classes->Fill(eleClass) ;
00480 
00481 
00482     // pflow
00483     h1_mva->Fill(gsfIter->mva()) ;
00484     if (gsfIter->ecalDrivenSeed()) h1_provenance->Fill(1.) ;
00485     if (gsfIter->trackerDrivenSeed()) h1_provenance->Fill(-1.) ;
00486     if (gsfIter->trackerDrivenSeed()||gsfIter->ecalDrivenSeed()) h1_provenance->Fill(0.);
00487     if (gsfIter->trackerDrivenSeed()&&!gsfIter->ecalDrivenSeed()) h1_provenance->Fill(-2.);
00488     if (!gsfIter->trackerDrivenSeed()&&gsfIter->ecalDrivenSeed()) h1_provenance->Fill(2.);
00489 
00490     // isolation
00491     h1_tkSumPt_dr03->Fill(gsfIter->dr03TkSumPt());
00492     h1_ecalRecHitSumEt_dr03->Fill(gsfIter->dr03EcalRecHitSumEt());
00493     h1_hcalTowerSumEt_dr03->Fill(gsfIter->dr03HcalTowerSumEt());
00494 //    h1_hcalDepth1TowerSumEt_dr03->Fill(gsfIter->dr03HcalDepth1TowerSumEt());
00495 //    h1_hcalDepth2TowerSumEt_dr03->Fill(gsfIter->dr03HcalDepth2TowerSumEt());
00496 //    h1_tkSumPt_dr04->Fill(gsfIter->dr04TkSumPt());
00497 //    h1_ecalRecHitSumEt_dr04->Fill(gsfIter->dr04EcalRecHitSumEt());
00498 //    h1_hcalTowerSumEt_dr04->Fill(gsfIter->dr04HcalTowerSumEt());
00501 
00502    }
00503 
00504   // association matching object-reco electrons
00505   int matchingObjectNum=0;
00506   reco::SuperClusterCollection::const_iterator moIter ;
00507   for
00508    ( moIter=recoClusters->begin() ;
00509      moIter!=recoClusters->end() ;
00510      moIter++ )
00511    {
00512 //    // number of matching objects
00513      matchingObjectNum++;
00514 
00515     if
00516      ( moIter->energy()/cosh(moIter->eta())>maxPtMatchingObject_ ||
00517        std::abs(moIter->eta())> maxAbsEtaMatchingObject_ )
00518      { continue ; }
00519 
00520 //    // suppress the endcaps
00521 //    //if (std::abs(moIter->eta()) > 1.5) continue;
00522 //    // select central z
00523 //    //if ( std::abs((*mcIter)->production_vertex()->position().z())>50.) continue;
00524 
00525     h1_matchingObject_Eta->Fill( moIter->eta() );
00526 //    h1_matchingObject_AbsEta->Fill( std::abs(moIter->eta()) );
00527 //    h1_matchingObject_P->Fill( moIter->energy() );
00528     h1_matchingObject_Pt->Fill( moIter->energy()/cosh(moIter->eta()) );
00529     h1_matchingObject_Phi->Fill( moIter->phi() );
00530 //    h1_matchingObject_Z->Fill(  moIter->z() );
00531 
00532     bool okGsfFound = false ;
00533     double gsfOkRatio = 999999999. ;
00534     reco::GsfElectron bestGsfElectron ;
00535     reco::GsfElectronCollection::const_iterator gsfIter ;
00536     for
00537      ( gsfIter=gsfElectrons->begin() ;
00538        gsfIter!=gsfElectrons->end() ;
00539        gsfIter++ )
00540      {
00541       reco::GsfElectronCollection::const_iterator gsfIter2 ;
00542       for
00543        ( gsfIter2=gsfIter+1;
00544          gsfIter2!=gsfElectrons->end() ;
00545          gsfIter2++ )
00546        {
00547         float invMass = computeInvMass(*gsfIter,*gsfIter2) ;
00548         if(matchingObjectNum == 1){h1_mee->Fill(invMass) ;}
00549         if ((matchingObjectNum == 1) && (((gsfIter->charge())*(gsfIter2->charge()))<0.))
00550          { h1_mee_os->Fill(invMass) ; }
00551        }
00552 
00553       double vertexTIP =
00554        (gsfIter->vertex().x()-bs.position().x()) * (gsfIter->vertex().x()-bs.position().x()) +
00555        (gsfIter->vertex().y()-bs.position().y()) * (gsfIter->vertex().y()-bs.position().y()) ;
00556       vertexTIP = sqrt(vertexTIP) ;
00557 
00558       // select electrons
00559       if (!selected(gsfIter,vertexTIP)) continue ;
00560 
00561       // matching with a cone in eta phi
00562       if ( matchingCondition_ == "Cone" )
00563        {
00564         double dphi = gsfIter->phi()-moIter->phi() ;
00565         if (std::abs(dphi)>CLHEP::pi)
00566          { dphi = dphi < 0? (CLHEP::twopi) + dphi : dphi - CLHEP::twopi ; }
00567         double deltaR = sqrt(pow((moIter->eta()-gsfIter->eta()),2) + pow(dphi,2)) ;
00568         if ( deltaR < deltaR_ )
00569          {
00570           //if ( (genPc->pdg_id() == 11) && (gsfIter->charge() < 0.) || (genPc->pdg_id() == -11) &&
00571           //(gsfIter->charge() > 0.) ){
00572           double tmpGsfRatio = gsfIter->p()/moIter->energy() ;
00573           if ( std::abs(tmpGsfRatio-1) < std::abs(gsfOkRatio-1) )
00574            {
00575             gsfOkRatio = tmpGsfRatio;
00576             bestGsfElectron=*gsfIter;
00577             okGsfFound = true;
00578            }
00579           //}
00580          }
00581        }
00582      } // loop over rec ele to look for the best one
00583     if (okGsfFound)
00584      {
00585       // generated distributions for matched electrons
00586       h1_matchedObject_Eta->Fill( moIter->eta() );
00587     //  h1_matchedObject_AbsEta->Fill( std::abs(moIter->eta()) );
00588       h1_matchedObject_Pt->Fill( moIter->energy()/cosh(moIter->eta()) );
00589       h1_matchedObject_Phi->Fill( moIter->phi() );
00590     //  h1_matchedObject_Z->Fill( moIter->z() );
00591 
00592       //classes
00593     //  int eleClass = bestGsfElectron.classification() ;
00594     //  h_classes->Fill(eleClass) ;
00595     //  h_matchedEle_eta->Fill(std::abs(bestGsfElectron.eta()));
00596     //  if (bestGsfElectron.classification() == GsfElectron::GOLDEN) h_matchedEle_eta_golden->Fill(std::abs(bestGsfElectron.eta()));
00597     //  if (bestGsfElectron.classification() == GsfElectron::SHOWERING) h_matchedEle_eta_shower->Fill(std::abs(bestGsfElectron.eta()));
00598     //  //if (bestGsfElectron.classification() == GsfElectron::BIGBREM) h_matchedEle_eta_bbrem->Fill(std::abs(bestGsfElectron.eta()));
00599     //  //if (bestGsfElectron.classification() == GsfElectron::OLDNARROW) h_matchedEle_eta_narrow->Fill(std::abs(bestGsfElectron.eta()));
00600      }
00601 
00602    } // loop overmatching object
00603 
00604 //  h_matchingObject_Num->Fill(matchingObjectNum) ;
00605 
00606  }
00607 
00608 float ElectronAnalyzer::computeInvMass
00609  ( const reco::GsfElectron & e1,
00610    const reco::GsfElectron & e2 )
00611  {
00612   math::XYZTLorentzVector p12 = e1.p4()+e2.p4() ;
00613   float mee2 = p12.Dot(p12) ;
00614   float invMass = sqrt(mee2) ;
00615   return invMass ;
00616  }
00617 
00618 //bool ElectronAnalyzer::trigger( const edm::Event & e )
00619 // {
00620 //  // retreive TriggerResults from the event
00621 //  edm::Handle<edm::TriggerResults> triggerResults ;
00622 //  e.getByLabel(triggerResults_,triggerResults) ;
00623 //
00624 //  bool accept = false ;
00625 //
00626 //  if (triggerResults.isValid())
00627 //   {
00628 //    //std::cout << "TriggerResults found, number of HLT paths: " << triggerResults->size() << std::endl;
00629 //    // get trigger names
00630 //    const edm::TriggerNames & triggerNames_ = e.triggerNames(*triggerResults);
00636 //
00637 //    unsigned int n = HLTPathsByName_.size() ;
00638 //    for (unsigned int i=0; i!=n; i++)
00639 //     {
00640 //      HLTPathsByIndex_[i]=triggerNames_.triggerIndex(HLTPathsByName_[i]) ;
00641 //     }
00642 //
00643 //    // empty input vectors (n==0) means any trigger paths
00644 //    if (n==0)
00645 //     {
00646 //      n=triggerResults->size() ;
00647 //      HLTPathsByName_.resize(n) ;
00648 //      HLTPathsByIndex_.resize(n) ;
00649 //      for ( unsigned int i=0 ; i!=n ; i++)
00650 //       {
00651 //        HLTPathsByName_[i]=triggerNames_.triggerName(i) ;
00652 //        HLTPathsByIndex_[i]=i ;
00653 //       }
00654 //     }
00655 //
00671 //
00672 //    // count number of requested HLT paths which have fired
00673 //    unsigned int fired=0 ;
00674 //    for ( unsigned int i=0 ; i!=n ; i++ )
00675 //     {
00676 //      if (HLTPathsByIndex_[i]<triggerResults->size())
00677 //       {
00678 //        if (triggerResults->accept(HLTPathsByIndex_[i]))
00679 //         {
00680 //          fired++ ;
00681 //          h1_triggers->Fill(float(HLTPathsByIndex_[i]));
00682 //          //std::cout << "Fired HLT path= " << HLTPathsByName_[i] << std::endl ;
00683 //          accept = true ;
00684 //         }
00685 //       }
00686 //     }
00687 //
00688 //   }
00689 //
00690 //  return accept ;
00691 // }
00692 
00693 bool ElectronAnalyzer::selected( const reco::GsfElectronCollection::const_iterator & gsfIter , double vertexTIP )
00694  {
00695   if ((Selection_>0)&&generalCut(gsfIter)) return false ;
00696   if ((Selection_>=1)&&etCut(gsfIter)) return false ;
00697   if ((Selection_>=2)&&isolationCut(gsfIter,vertexTIP)) return false ;
00698   if ((Selection_>=3)&&idCut(gsfIter)) return false ;
00699   return true ;
00700  }
00701 
00702 bool ElectronAnalyzer::generalCut( const reco::GsfElectronCollection::const_iterator & gsfIter)
00703  {
00704   if (std::abs(gsfIter->eta())>maxAbsEta_) return true ;
00705   if (gsfIter->pt()<minPt_) return true ;
00706 
00707   if (gsfIter->isEB() && isEE_) return true ;
00708   if (gsfIter->isEE() && isEB_) return true ;
00709   if (gsfIter->isEBEEGap() && isNotEBEEGap_) return true ;
00710 
00711   if (gsfIter->ecalDrivenSeed() && isTrackerDriven_) return true ;
00712   if (gsfIter->trackerDrivenSeed() && isEcalDriven_) return true ;
00713 
00714   return false ;
00715  }
00716 
00717 bool ElectronAnalyzer::etCut( const reco::GsfElectronCollection::const_iterator & gsfIter )
00718  {
00719   if (gsfIter->superCluster()->energy()/cosh(gsfIter->superCluster()->eta())<minEt_) return true ;
00720 
00721   return false ;
00722  }
00723 
00724 bool ElectronAnalyzer::isolationCut( const reco::GsfElectronCollection::const_iterator & gsfIter, double vertexTIP )
00725  {
00726   if (gsfIter->isEB() && vertexTIP > tipMaxBarrel_) return true ;
00727   if (gsfIter->isEE() && vertexTIP > tipMaxEndcaps_) return true ;
00728 
00729   if (gsfIter->dr03TkSumPt() > tkIso03Max_) return true ;
00730   if (gsfIter->isEB() && gsfIter->dr03HcalDepth1TowerSumEt() > hcalIso03Depth1MaxBarrel_) return true ;
00731   if (gsfIter->isEE() && gsfIter->dr03HcalDepth1TowerSumEt() > hcalIso03Depth1MaxEndcaps_) return true ;
00732   if (gsfIter->isEE() && gsfIter->dr03HcalDepth2TowerSumEt() > hcalIso03Depth2MaxEndcaps_) return true ;
00733   if (gsfIter->isEB() && gsfIter->dr03EcalRecHitSumEt() > ecalIso03MaxBarrel_) return true ;
00734   if (gsfIter->isEE() && gsfIter->dr03EcalRecHitSumEt() > ecalIso03MaxEndcaps_) return true ;
00735 
00736   return false ;
00737  }
00738 
00739 bool ElectronAnalyzer::idCut( const reco::GsfElectronCollection::const_iterator & gsfIter )
00740  {
00741   if (gsfIter->isEB() && gsfIter->eSuperClusterOverP() < eOverPMinBarrel_) return true ;
00742   if (gsfIter->isEB() && gsfIter->eSuperClusterOverP() > eOverPMaxBarrel_) return true ;
00743   if (gsfIter->isEE() && gsfIter->eSuperClusterOverP() < eOverPMinEndcaps_) return true ;
00744   if (gsfIter->isEE() && gsfIter->eSuperClusterOverP() > eOverPMaxEndcaps_) return true ;
00745   if (gsfIter->isEB() && std::abs(gsfIter->deltaEtaSuperClusterTrackAtVtx()) < dEtaMinBarrel_) return true ;
00746   if (gsfIter->isEB() && std::abs(gsfIter->deltaEtaSuperClusterTrackAtVtx()) > dEtaMaxBarrel_) return true ;
00747   if (gsfIter->isEE() && std::abs(gsfIter->deltaEtaSuperClusterTrackAtVtx()) < dEtaMinEndcaps_) return true ;
00748   if (gsfIter->isEE() && std::abs(gsfIter->deltaEtaSuperClusterTrackAtVtx()) > dEtaMaxEndcaps_) return true ;
00749   if (gsfIter->isEB() && std::abs(gsfIter->deltaPhiSuperClusterTrackAtVtx()) < dPhiMinBarrel_) return true ;
00750   if (gsfIter->isEB() && std::abs(gsfIter->deltaPhiSuperClusterTrackAtVtx()) > dPhiMaxBarrel_) return true ;
00751   if (gsfIter->isEE() && std::abs(gsfIter->deltaPhiSuperClusterTrackAtVtx()) < dPhiMinEndcaps_) return true ;
00752   if (gsfIter->isEE() && std::abs(gsfIter->deltaPhiSuperClusterTrackAtVtx()) > dPhiMaxEndcaps_) return true ;
00753   if (gsfIter->isEB() && gsfIter->scSigmaIEtaIEta() < sigIetaIetaMinBarrel_) return true ;
00754   if (gsfIter->isEB() && gsfIter->scSigmaIEtaIEta() > sigIetaIetaMaxBarrel_) return true ;
00755   if (gsfIter->isEE() && gsfIter->scSigmaIEtaIEta() < sigIetaIetaMinEndcaps_) return true ;
00756   if (gsfIter->isEE() && gsfIter->scSigmaIEtaIEta() > sigIetaIetaMaxEndcaps_) return true ;
00757   if (gsfIter->isEB() && gsfIter->hadronicOverEm() > hadronicOverEmMaxBarrel_) return true ;
00758   if (gsfIter->isEE() && gsfIter->hadronicOverEm() > hadronicOverEmMaxEndcaps_) return true ;
00759 
00760   return false ;
00761  }