CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_2_9_HLT1_bphpatch4/src/DQMOffline/EGamma/plugins/ElectronAnalyzer.cc

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