CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ElectronAnalyzer.cc
Go to the documentation of this file.
1 
3 
5 
15 
22 //#include "FWCore/Framework/interface/EDAnalyzer.h"
24 
25 #include "CLHEP/Units/GlobalPhysicalConstants.h"
26 #include "TMath.h"
27 
28 #include <iostream>
29 
30 using namespace reco ;
31 
34  {
35  // general, collections
36  Selection_ = conf.getParameter<int>("Selection");
37  electronCollection_ = conf.getParameter<edm::InputTag>("ElectronCollection");
38  matchingObjectCollection_ = conf.getParameter<edm::InputTag>("MatchingObjectCollection");
39  trackCollection_ = conf.getParameter<edm::InputTag>("TrackCollection");
40  vertexCollection_ = conf.getParameter<edm::InputTag>("VertexCollection");
41  gsftrackCollection_ = conf.getParameter<edm::InputTag>("GsfTrackCollection");
42  beamSpotTag_ = conf.getParameter<edm::InputTag>("BeamSpot");
43  readAOD_ = conf.getParameter<bool>("ReadAOD");
44 
45  // matching
46  matchingCondition_ = conf.getParameter<std::string>("MatchingCondition");
47  assert (matchingCondition_=="Cone") ;
48  maxPtMatchingObject_ = conf.getParameter<double>("MaxPtMatchingObject");
49  maxAbsEtaMatchingObject_ = conf.getParameter<double>("MaxAbsEtaMatchingObject");
50  deltaR_ = conf.getParameter<double>("DeltaR");
51 
52  // electron selection
53  minEt_ = conf.getParameter<double>("MinEt");
54  minPt_ = conf.getParameter<double>("MinPt");
55  maxAbsEta_ = conf.getParameter<double>("MaxAbsEta");
56  isEB_ = conf.getParameter<bool>("SelectEb");
57  isEE_ = conf.getParameter<bool>("SelectEe");
58  isNotEBEEGap_ = conf.getParameter<bool>("SelectNotEbEeGap");
59  isEcalDriven_ = conf.getParameter<bool>("SelectEcalDriven");
60  isTrackerDriven_ = conf.getParameter<bool>("SelectTrackerDriven");
61  eOverPMinBarrel_ = conf.getParameter<double>("MinEopBarrel");
62  eOverPMaxBarrel_ = conf.getParameter<double>("MaxEopBarrel");
63  eOverPMinEndcaps_ = conf.getParameter<double>("MinEopEndcaps");
64  eOverPMaxEndcaps_ = conf.getParameter<double>("MaxEopEndcaps");
65  dEtaMinBarrel_ = conf.getParameter<double>("MinDetaBarrel");
66  dEtaMaxBarrel_ = conf.getParameter<double>("MaxDetaBarrel");
67  dEtaMinEndcaps_ = conf.getParameter<double>("MinDetaEndcaps");
68  dEtaMaxEndcaps_ = conf.getParameter<double>("MaxDetaEndcaps");
69  dPhiMinBarrel_ = conf.getParameter<double>("MinDphiBarrel");
70  dPhiMaxBarrel_ = conf.getParameter<double>("MaxDphiBarrel");
71  dPhiMinEndcaps_ = conf.getParameter<double>("MinDphiEndcaps");
72  dPhiMaxEndcaps_ = conf.getParameter<double>("MaxDphiEndcaps");
73  sigIetaIetaMinBarrel_ = conf.getParameter<double>("MinSigIetaIetaBarrel");
74  sigIetaIetaMaxBarrel_ = conf.getParameter<double>("MaxSigIetaIetaBarrel");
75  sigIetaIetaMinEndcaps_ = conf.getParameter<double>("MinSigIetaIetaEndcaps");
76  sigIetaIetaMaxEndcaps_ = conf.getParameter<double>("MaxSigIetaIetaEndcaps");
77  hadronicOverEmMaxBarrel_ = conf.getParameter<double>("MaxHoeBarrel");
78  hadronicOverEmMaxEndcaps_ = conf.getParameter<double>("MaxHoeEndcaps");
79  mvaMin_ = conf.getParameter<double>("MinMva");
80  tipMaxBarrel_ = conf.getParameter<double>("MaxTipBarrel");
81  tipMaxEndcaps_ = conf.getParameter<double>("MaxTipEndcaps");
82  tkIso03Max_ = conf.getParameter<double>("MaxTkIso03");
83  hcalIso03Depth1MaxBarrel_ = conf.getParameter<double>("MaxHcalIso03Depth1Barrel");
84  hcalIso03Depth1MaxEndcaps_ = conf.getParameter<double>("MaxHcalIso03Depth1Endcaps");
85  hcalIso03Depth2MaxEndcaps_ = conf.getParameter<double>("MaxHcalIso03Depth2Endcaps");
86  ecalIso03MaxBarrel_ = conf.getParameter<double>("MaxEcalIso03Barrel");
87  ecalIso03MaxEndcaps_ = conf.getParameter<double>("MaxEcalIso03Endcaps");
88 
89  // for trigger
90  triggerResults_ = conf.getParameter<edm::InputTag>("TriggerResults");
91 // HLTPathsByName_= conf.getParameter<std::vector<std::string > >("HltPaths");
92 // HLTPathsByIndex_.resize(HLTPathsByName_.size());
93 
94  // histos limits and binning
95  nbineta=conf.getParameter<int>("NbinEta");
96  nbineta2D=conf.getParameter<int>("NbinEta2D");
97  etamin=conf.getParameter<double>("EtaMin");
98  etamax=conf.getParameter<double>("EtaMax");
99  //
100  nbinphi=conf.getParameter<int>("NbinPhi");
101  nbinphi2D=conf.getParameter<int>("NbinPhi2D");
102  phimin=conf.getParameter<double>("PhiMin");
103  phimax=conf.getParameter<double>("PhiMax");
104  //
105  nbinpt=conf.getParameter<int>("NbinPt");
106  nbinpteff=conf.getParameter<int>("NbinPtEff");
107  nbinpt2D=conf.getParameter<int>("NbinPt2D");
108  ptmax=conf.getParameter<double>("PtMax");
109  //
110  nbinp=conf.getParameter<int>("NbinP");
111  nbinp2D=conf.getParameter<int>("NbinP2D");
112  pmax=conf.getParameter<double>("PMax");
113  //
114  nbineop=conf.getParameter<int>("NbinEop");
115  nbineop2D=conf.getParameter<int>("NbinEop2D");
116  eopmax=conf.getParameter<double>("EopMax");
117  eopmaxsht=conf.getParameter<double>("EopMaxSht");
118  //
119  nbindeta=conf.getParameter<int>("NbinDeta");
120  detamin=conf.getParameter<double>("DetaMin");
121  detamax=conf.getParameter<double>("DetaMax");
122  //
123  nbindphi=conf.getParameter<int>("NbinDphi");
124  dphimin=conf.getParameter<double>("DphiMin");
125  dphimax=conf.getParameter<double>("DphiMax");
126  //
127  nbindetamatch=conf.getParameter<int>("NbinDetaMatch");
128  nbindetamatch2D=conf.getParameter<int>("NbinDetaMatch2D");
129  detamatchmin=conf.getParameter<double>("DetaMatchMin");
130  detamatchmax=conf.getParameter<double>("DetaMatchMax");
131  //
132  nbindphimatch=conf.getParameter<int>("NbinDphiMatch");
133  nbindphimatch2D=conf.getParameter<int>("NbinDphiMatch2D");
134  dphimatchmin=conf.getParameter<double>("DphiMatchMin");
135  dphimatchmax=conf.getParameter<double>("DphiMatchMax");
136  //
137  nbinfhits=conf.getParameter<int>("NbinFhits");
138  fhitsmax=conf.getParameter<double>("FhitsMax");
139  //
140  nbinlhits=conf.getParameter<int>("NbinLhits");
141  lhitsmax=conf.getParameter<double>("LhitsMax");
142  //
143  nbinxyz=conf.getParameter<int>("NbinXyz");
144  nbinxyz2D=conf.getParameter<int>("NbinXyz2D");
145  //
146  nbinpoptrue= conf.getParameter<int>("NbinPopTrue");
147  poptruemin=conf.getParameter<double>("PopTrueMin");
148  poptruemax=conf.getParameter<double>("PopTrueMax");
149  //
150  nbinmee= conf.getParameter<int>("NbinMee");
151  meemin=conf.getParameter<double>("MeeMin");
152  meemax=conf.getParameter<double>("MeeMax");
153  //
154  nbinhoe= conf.getParameter<int>("NbinHoe");
155  hoemin=conf.getParameter<double>("HoeMin");
156  hoemax=conf.getParameter<double>("HoeMax");
157  }
158 
160  {}
161 
163  {
164  nEvents_ = 0 ;
165  //nAfterTrigger_ = 0 ;
166 
167 
168  // basic quantities
169 // h1_num_= bookH1("num","# rec electrons",20, 0.,20.,"N_{ele}");
170 // h1_vertexP = bookH1("vertexP", "ele p at vertex", nbinp,0.,pmax,"p_{vertex} (GeV/c)");
171 // h1_Et = bookH1("Et","ele SC transverse energy", nbinpt,0.,ptmax,"E_{T} (GeV)");
172 // h1_vertexTIP = bookH1("vertexTIP","ele transverse impact parameter (wrt bs)",90,0.,0.15,"TIP (cm)");
173 // h1_charge = bookH1("charge","ele charge",5,-2.,2.,"charge");
174  h1_vertexPt_barrel = bookH1("vertexPt_barrel","ele transverse momentum in barrel",nbinpt,0.,ptmax,"p_{T vertex} (GeV/c)");
175  h1_vertexPt_endcaps = bookH1("vertexPt_endcaps","ele transverse momentum in endcaps",nbinpt,0.,ptmax,"p_{T vertex} (GeV/c)");
176 // h1_vertexEta = bookH1("vertexEta","ele momentum #eta",nbineta,etamin,etamax,"#eta");
177 // h1_vertexPhi = bookH1("vertexPhi","ele momentum #phi",nbinphi,phimin,phimax,"#phi (rad)");
178  h2_vertexEtaVsPhi = bookH2("vertexEtaVsPhi","ele momentum #eta vs #phi",nbineta2D,etamin,etamax,nbinphi2D,phimin,phimax,"#eta","#phi (rad)");
179 // h1_vertexX = bookH1("vertexX","ele vertex x",nbinxyz,-0.1,0.1,"x (cm)");
180 // h1_vertexY = bookH1("vertexY","ele vertex y",nbinxyz,-0.1,0.1,"y (cm)");
181  h2_vertexXvsY = bookH2("vertexXvsY","ele vertex x vs y",nbinxyz2D,-0.1,0.1,nbinxyz2D,-0.1,0.1,"x (cm)","y (cm)");
182  h1_vertexZ = bookH1("vertexZ","ele vertex z",nbinxyz,-25, 25,"z (cm)");
183 
184  // super-clusters
185 // h1_sclEn = bookH1("sclEnergy","ele supercluster energy",nbinp,0.,pmax,"E (GeV)");
186 // h1_sclEta = bookH1("sclEta","ele supercluster #eta",nbineta,etamin,etamax,"#eta");
187 // h1_sclPhi = bookH1("sclPhi","ele supercluster #phi",nbinphi,phimin,phimax,"#phi (rad)");
188  h1_sclEt = bookH1("sclEt","ele supercluster transverse energy",nbinpt,0.,ptmax,"E_{T} (GeV)");
189 
190  // electron track
191 // h1_ambiguousTracks = bookH1("ambiguousTracks","ele # ambiguous tracks", 5,0.,5.,"N_{amb. tk}");
192 // h2_ambiguousTracksVsEta = bookH2("ambiguousTracksVsEta","ele # ambiguous tracks vs #eta", nbineta2D,etamin,etamax,5,0.,5.,"#eta","N_{amb. tk}");
193 // h2_ambiguousTracksVsPhi = bookH2("ambiguousTracksVsPhi","ele # ambiguous tracks vs #phi", nbinphi2D,phimin,phimax,5,0.,5.,"#phi(rad)","N_{amb. tk}");
194 // h2_ambiguousTracksVsPt = bookH2("ambiguousTracksVsPt","ele # ambiguous tracks vs pt", nbinpt2D,0.,ptmax,5,0.,5.,"p_{T} (GeV/c),"N_{amb. tk}");
195  h1_chi2 = bookH1("chi2","ele track #chi^{2}",100,0.,15.,"#Chi^{2}");
196  py_chi2VsEta = bookP1("chi2VsEta","ele track #chi^{2} vs #eta",nbineta2D,etamin,etamax,0.,15.,"#eta","<#chi^{2}>");
197  py_chi2VsPhi = bookP1("chi2VsPhi","ele track #chi^{2} vs #phi",nbinphi2D,phimin,phimax,0.,15.,"#phi (rad)","<#chi^{2}>");
198  //h2_chi2VsPt = bookH2("chi2VsPt","ele track #chi^{2} vs pt",nbinpt2D,0.,ptmax,50,0.,15.,"p_{T} (GeV/c)","<#chi^{2}>");
199  h1_foundHits = bookH1("foundHits","ele track # found hits",nbinfhits,0.,fhitsmax,"N_{hits}");
200  py_foundHitsVsEta = bookP1("foundHitsVsEta","ele track # found hits vs #eta",nbineta2D,etamin,etamax,0.,fhitsmax,"#eta","<# hits>");
201  py_foundHitsVsPhi = bookP1("foundHitsVsPhi","ele track # found hits vs #phi",nbinphi2D,phimin,phimax,0.,fhitsmax,"#phi (rad)","<# hits>");
202 // h2_foundHitsVsPt = bookH2("foundHitsVsPt","ele track # found hits vs pt",nbinpt2D,0.,ptmax,nbinfhits,0.,fhitsmax,"p_{T} (GeV/c)","<# hits>");
203  h1_lostHits = bookH1("lostHits","ele track # lost hits",5,0.,5.,"N_{lost hits}");
204  py_lostHitsVsEta = bookP1("lostHitsVsEta","ele track # lost hits vs #eta",nbineta2D,etamin,etamax,0.,lhitsmax,"#eta","<# hits>");
205  py_lostHitsVsPhi = bookP1("lostHitsVsPhi","ele track # lost hits vs #eta",nbinphi2D,phimin,phimax,0.,lhitsmax,"#phi (rad)","<# hits>");
206 // h2_lostHitsVsPt = bookH2("lostHitsVsPt","ele track # lost hits vs #eta",nbinpt2D,0.,ptmax,nbinlhits,0.,lhitsmax,"p_{T} (GeV/c)","<# hits>");
207 
208  // electron matching and ID
209  //h1_EoPout = bookH1( "EoPout","ele E/P_{out}",nbineop,0.,eopmax,"E_{seed}/P_{out}");
210  //h1_dEtaCl_propOut = bookH1( "dEtaCl_propOut","ele #eta_{cl} - #eta_{tr}, prop from outermost",nbindetamatch,detamatchmin,detamatchmax,"#eta_{seedcl} - #eta_{tr}");
211  //h1_dPhiCl_propOut = bookH1( "dPhiCl_propOut","ele #phi_{cl} - #phi_{tr}, prop from outermost",nbindphimatch,dphimatchmin,dphimatchmax,"#phi_{seedcl} - #phi_{tr} (rad)");
212  //h1_outerP = bookH1( "outerP","ele track outer p, mean",nbinp,0.,pmax,"P_{out} (GeV/c)");
213  //h1_outerP_mode = bookH1( "outerP_mode","ele track outer p, mode",nbinp,0.,pmax,"P_{out} (GeV/c)");
214  h1_Eop_barrel = bookH1( "Eop_barrel","ele E/P_{vertex} in barrel",nbineop,0.,eopmax,"E/P_{vertex}");
215  h1_Eop_endcaps = bookH1( "Eop_endcaps","ele E/P_{vertex} in endcaps",nbineop,0.,eopmax,"E/P_{vertex}");
216  py_EopVsPhi = bookP1("EopVsPhi","ele E/P_{vertex} vs #phi",nbinphi2D,phimin,phimax,0.,eopmax,"#phi (rad)","<E/P_{vertex}>");
217 // h2_EopVsPt = bookH2("EopVsPt","ele E/P_{vertex} vs pt",nbinpt2D,0.,ptmax,nbineop,0.,eopmax,"p_{T} (GeV/c)","E/P_{vertex}");
218  h1_EeleOPout_barrel = bookH1( "EeleOPout_barrel","ele E_{ele}/P_{out} in barrel",nbineop,0.,eopmax,"E_{ele}/P_{out}");
219  h1_EeleOPout_endcaps = bookH1( "EeleOPout_endcaps","ele E_{ele}/P_{out} in endcaps",nbineop,0.,eopmax,"E_{ele}/P_{out}");
220 // h2_EeleOPoutVsPhi = bookH2("EeleOPoutVsPhi","ele E_{ele}/P_{out} vs #phi",nbinphi2D,phimin,phimax,nbineop,0.,eopmax,"#phi","E_{ele}/P_{out}");
221 // 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}");
222  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}");
223  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}");
224  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}>");
225 // 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}");
226  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}");
227  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}");
228 // 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}");
229 // 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}");
230  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)");
231  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)");
232  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)");
233 // 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)");
234  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)");
235  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)");
236 // 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)");
237 // 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)");
238  h1_Hoe_barrel = bookH1("Hoe_barrel","ele hadronic energy / em energy, in barrel", nbinhoe, hoemin, hoemax,"H/E","Events","ELE_LOGY E1 P") ;
239  h1_Hoe_endcaps = bookH1("Hoe_endcaps","ele hadronic energy / em energy, in endcaps", nbinhoe, hoemin, hoemax,"H/E","Events","ELE_LOGY E1 P") ;
240  py_HoeVsPhi = bookP1("HoeVsPhi","ele hadronic energy / em energy vs #phi",nbinphi2D,phimin,phimax,hoemin,hoemax,"#phi (rad)","<H/E>","ELE_LOGY E1 P") ;
241 // 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") ;
242  h1_sclSigEtaEta_barrel = bookH1("sclSigEtaEta_barrel","ele supercluster sigma ieta ieta in barrel",100,0.,0.05,"sietaieta");
243  h1_sclSigEtaEta_endcaps = bookH1("sclSigEtaEta_endcaps","ele supercluster sigma ieta ieta in endcaps",100,0.,0.05,"sietaieta");
244 
245  // fbrem
246 // h1_innerPt_mean = bookH1( "innerPt_mean","ele track inner p_{T}, mean",nbinpt,0.,ptmax,"P_{T in} (GeV/c)");
247 // h1_outerPt_mean = bookH1( "outerPt_mean","ele track outer p_{T}, mean",nbinpt,0.,ptmax,"P_{T out} (GeV/c)");
248 // h1_outerPt_mode = bookH1( "outerPt_mode","ele track outer p_{T}, mode",nbinpt,0.,ptmax,"P_{T out} (GeV/c)");
249 // //h_PinMnPout_mode = bookH1( "PinMnPout_mode","ele track inner p - outer p, mode" ,nbinp,0.,100.,"P_{in} - P_{out} (GeV/c)");
250 // h1_PinMnPout = bookH1( "PinMnPout","ele track inner p - outer p, mean" ,nbinp,0.,200.,"P_{in} - P_{out} (GeV/c)");
251 // h1_PinMnPout_mode = bookH1( "PinMnPout_mode","ele track inner p - outer p, mode",nbinp,0.,100.,"P_{in} - P_{out}, mode (GeV/c)");
252  h1_fbrem = bookH1("fbrem","ele brem fraction",100,0.,1.,"P_{in} - P_{out} / P_{in}") ;
253  py_fbremVsEta = bookP1("fbremVsEta","ele brem fraction vs #eta",nbineta2D,etamin,etamax,0.,1.,"#eta","<P_{in} - P_{out} / P_{in}>") ;
254  py_fbremVsPhi = bookP1("fbremVsPhi","ele brem fraction vs #phi",nbinphi2D,phimin,phimax,0.,1.,"#phi (rad)","<P_{in} - P_{out} / P_{in}>") ;
255 // 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}>") ;
256  h1_classes = bookH1("classes","ele electron classes",10,0.0,10.);
257 
258  // pflow
259  h1_mva = bookH1( "mva","ele identification mva",100,-1.,1.,"mva");
260  h1_provenance = bookH1( "provenance","ele provenance",5,-2.,3.,"provenance");
261 
262  // isolation
263  h1_tkSumPt_dr03 = bookH1("tkSumPt_dr03","tk isolation sum, dR=0.3",100,0.0,20.,"TkIsoSum (GeV/c)","Events","ELE_LOGY E1 P");
264  h1_ecalRecHitSumEt_dr03 = bookH1("ecalRecHitSumEt_dr03","ecal isolation sum, dR=0.3",100,0.0,20.,"EcalIsoSum (GeV)","Events","ELE_LOGY E1 P");
265  h1_hcalTowerSumEt_dr03 = bookH1("hcalTowerSumEt_dr03","hcal isolation sum, dR=0.3",100,0.0,20.,"HcalIsoSum (GeV)","Events","ELE_LOGY E1 P");
266 // h1_hcalDepth1TowerSumEt_dr03 = bookH1("hcalDepth1TowerSumEt_dr03","hcal depth1 isolation sum, dR=0.3",100,0.0,20.,"Hcal1IsoSum (GeV)","Events","ELE_LOGY E1 P");
267 // h1_hcalDepth2TowerSumEt_dr03 = bookH1("hcalDepth2TowerSumEt_dr03","hcal depth2 isolation sum, dR=0.3",100,0.0,20.,"Hcal2IsoSum (GeV)","Events","ELE_LOGY E1 P");
268 // h1_tkSumPt_dr04 = bookH1("tkSumPt_dr04","hcal isolation sum",100,0.0,20.,"TkIsoSum (GeV/c)","Events","ELE_LOGY E1 P");
269 // h1_ecalRecHitSumEt_dr04 = bookH1("ecalRecHitSumEt_dr04","ecal isolation sum, dR=0.4",100,0.0,20.,"EcalIsoSum (GeV)","Events","ELE_LOGY E1 P");
270 // h1_hcalTowerSumEt_dr04 = bookH1("hcalTowerSumEt_dr04","hcal isolation sum, dR=0.4",100,0.0,20.,"HcalIsoSum (GeV)","Events","ELE_LOGY E1 P");
273 
274  // di-electron mass
275  setBookIndex(200) ;
276  h1_mee = bookH1("mee","ele pairs invariant mass", nbinmee, meemin, meemax,"m_{ee} (GeV/c^{2})");
277  h1_mee_os = bookH1("mee_os","ele pairs invariant mass, opposite sign", nbinmee, meemin, meemax,"m_{e^{+}e^{-}} (GeV/c^{2})");
278 
279 
280 
281  //===========================
282  // histos for matching and matched matched objects
283  //===========================
284 
285  // matching object
286  std::string matchingObjectType ;
287  if (std::string::npos!=matchingObjectCollection_.label().find("SuperCluster",0))
288  { matchingObjectType = "SC" ; }
289  if (matchingObjectType=="")
290  { edm::LogError("ElectronMcFakeValidator::beginJob")<<"Unknown matching object type !" ; }
291  else
292  { edm::LogInfo("ElectronMcFakeValidator::beginJob")<<"Matching object type: "<<matchingObjectType ; }
293 // std::string htitle = "# "+matchingObjectType+"s", xtitle = "N_{"+matchingObjectType+"}" ;
294 // h1_matchingObject_Num = bookH1withSumw2("matchingObject_Num",htitle,nbinfhits,0.,fhitsmax,xtitle) ;
295 
296  // matching object distributions
297  h1_matchingObject_Eta = bookH1withSumw2("matchingObject_Eta",matchingObjectType+" #eta",nbineta,etamin,etamax,"#eta_{SC}");
298 // h1_matchingObject_AbsEta = bookH1withSumw2("matchingObject_AbsEta",matchingObjectType+" |#eta|",nbineta/2,0.,etamax,"|#eta|_{SC}");
299 // h1_matchingObject_P = bookH1withSumw2("matchingObject_P",matchingObjectType+" p",nbinp,0.,pmax,"E_{SC} (GeV)");
300  h1_matchingObject_Pt = bookH1withSumw2("matchingObject_Pt",matchingObjectType+" pt",nbinpteff,5.,ptmax,"pt_{SC} (GeV/c)");
301  h1_matchingObject_Phi = bookH1withSumw2("matchingObject_Phi",matchingObjectType+" #phi",nbinphi,phimin,phimax,"#phi (rad)");
302  h1_matchingObject_Z = bookH1withSumw2("matchingObject_Z",matchingObjectType+" z",nbinxyz,-25,25,"z (cm)");
303 
304  h1_matchedObject_Eta = bookH1withSumw2("matchedObject_Eta","Efficiency vs matching SC #eta",nbineta,etamin,etamax,"#eta_{SC}");
305 // h1_matchedObject_AbsEta = bookH1withSumw2("matchedObject_AbsEta","Efficiency vs matching SC |#eta|",nbineta/2,0.,2.5,"|#eta|_{SC}");
306  h1_matchedObject_Pt = bookH1withSumw2("matchedObject_Pt","Efficiency vs matching SC E_{T}",nbinpteff,5.,ptmax,"pt_{SC} (GeV/c)");
307  h1_matchedObject_Phi = bookH1withSumw2("matchedObject_Phi","Efficiency vs matching SC #phi",nbinphi,phimin,phimax,"#phi (rad)");
308  h1_matchedObject_Z = bookH1withSumw2("matchedObject_Z","Efficiency vs matching SC z",nbinxyz,-25,25,"z (cm)");
309 
310 // // classes
311 // h1_matchedEle_eta = bookH1( "matchedEle_eta", "ele electron #eta", nbineta/2,0.0,etamax,"#eta");
312 // h1_matchedEle_eta_golden = bookH1( "matchedEle_eta_golden", "ele electron #eta golden", nbineta/2,0.0,etamax,"#eta");
313 // h1_matchedEle_eta_shower = bookH1( "matchedEle_eta_shower", "ele electron #eta showering", nbineta/2,0.0,etamax,"#eta");
314 // //h1_matchedEle_eta_bbrem = bookH1( "matchedEle_eta_bbrem", "ele electron #eta bbrem", nbineta/2,0.0,etamax,"#eta");
315 // //h1_matchedEle_eta_narrow = bookH1( "matchedEle_eta_narrow", "ele electron #eta narrow", nbineta/2,0.0,etamax,"#eta");
316 //
317  }
318 
320 {
321  nEvents_++ ;
322 // if (!trigger(iEvent)) return ;
323 // nAfterTrigger_++ ;
324 
325 // edm::Handle<SuperClusterCollection> barrelSCs ;
326 // iEvent.getByLabel("correctedHybridSuperClusters",barrelSCs) ;
327 // edm::Handle<SuperClusterCollection> endcapsSCs ;
328 // iEvent.getByLabel("correctedMulti5x5SuperClustersWithPreshower",endcapsSCs) ;
329 // std::cout<<"[ElectronMcSignalValidator::analyze]"
330 // <<"Event "<<iEvent.id()
331 // <<" has "<<barrelSCs.product()->size()<<" barrel superclusters"
332 // <<" and "<<endcapsSCs.product()->size()<<" endcaps superclusters" ;
333 //
335  iEvent.getByLabel(electronCollection_,gsfElectrons) ;
337  iEvent.getByLabel(matchingObjectCollection_,recoClusters) ;
339  iEvent.getByLabel(trackCollection_,tracks);
341  iEvent.getByLabel(gsftrackCollection_,gsfTracks);
343  iEvent.getByLabel(vertexCollection_,vertices);
344  edm::Handle<reco::BeamSpot> recoBeamSpotHandle ;
345  iEvent.getByLabel(beamSpotTag_,recoBeamSpotHandle) ;
346  const BeamSpot bs = *recoBeamSpotHandle ;
347 
348  int ievt = iEvent.id().event();
349  int irun = iEvent.id().run();
350  int ils = iEvent.luminosityBlock();
351 
352  edm::LogInfo("ElectronAnalyzer::analyze")
353  <<"Treating "<<gsfElectrons.product()->size()<<" electrons"
354  <<" from event "<<ievt<<" in run "<<irun<<" and lumiblock "<<ils ;
355  //h1_num_->Fill((*gsfElectrons).size()) ;
356 
357  // selected rec electrons
358  reco::GsfElectronCollection::const_iterator gsfIter ;
359  for
360  ( gsfIter=gsfElectrons->begin() ;
361  gsfIter!=gsfElectrons->end();
362  gsfIter++ )
363  {
364  // vertex TIP
365  double vertexTIP =
366  (gsfIter->vertex().x()-bs.position().x()) * (gsfIter->vertex().x()-bs.position().x()) +
367  (gsfIter->vertex().y()-bs.position().y()) * (gsfIter->vertex().y()-bs.position().y()) ;
368  vertexTIP = sqrt(vertexTIP) ;
369 
370  // select electrons
371  if (!selected(gsfIter,vertexTIP)) continue ;
372 
373  // basic quantities
374  if (gsfIter->isEB()) h1_vertexPt_barrel->Fill( gsfIter->pt() );
375  if (gsfIter->isEE()) h1_vertexPt_endcaps->Fill( gsfIter->pt() );
376 // h1_vertexEta->Fill( gsfIter->eta() );
377 // h1_vertexPhi->Fill( gsfIter->phi() );
378  h2_vertexEtaVsPhi->Fill( gsfIter->eta(), gsfIter->phi() );
379 // h1_vertexX->Fill( gsfIter->vertex().x() );
380 // h1_vertexY->Fill( gsfIter->vertex().y() );
381  h2_vertexXvsY->Fill( gsfIter->vertex().x(), gsfIter->vertex().y() );
382  h1_vertexZ->Fill( gsfIter->vertex().z() );
383 // h1_vertexP->Fill( gsfIter->p() );
384 // h1_Et->Fill( gsfIter->superCluster()->energy()/cosh( gsfIter->superCluster()->eta()) );
385 // h1_vertexTIP->Fill( vertexTIP );
386 // h1_charge->Fill( gsfIter->charge() );
387 
388  // supercluster related distributions
389  reco::SuperClusterRef sclRef = gsfIter->superCluster() ;
390  // ALREADY DONE IN GSF ELECTRON CORE
391  // if (!gsfIter->ecalDrivenSeed()&&gsfIter->trackerDrivenSeed())
392  // sclRef = gsfIter->pflowSuperCluster() ;
393 // h1_sclEn->Fill(sclRef->energy());
394 // h1_sclEta->Fill(sclRef->eta());
395 // h1_sclPhi->Fill(sclRef->phi());
396  double R=TMath::Sqrt(sclRef->x()*sclRef->x() + sclRef->y()*sclRef->y() +sclRef->z()*sclRef->z());
397  double Rt=TMath::Sqrt(sclRef->x()*sclRef->x() + sclRef->y()*sclRef->y());
398  h1_sclEt->Fill(sclRef->energy()*(Rt/R));
399 
400  // track related distributions
401 // h1_ambiguousTracks->Fill( gsfIter->ambiguousGsfTracksSize() );
402 // h2_ambiguousTracksVsEta->Fill( gsfIter->eta(), gsfIter->ambiguousGsfTracksSize() );
403 // h2_ambiguousTracksVsPhi->Fill( gsfIter->phi(), gsfIter->ambiguousGsfTracksSize() );
404 // h2_ambiguousTracksVsPt->Fill( gsfIter->pt(), gsfIter->ambiguousGsfTracksSize() );
405  if (!readAOD_)
406  { // track extra does not exist in AOD
407  h1_foundHits->Fill( gsfIter->gsfTrack()->numberOfValidHits() );
408  py_foundHitsVsEta->Fill( gsfIter->eta(), gsfIter->gsfTrack()->numberOfValidHits() );
409  py_foundHitsVsPhi->Fill( gsfIter->phi(), gsfIter->gsfTrack()->numberOfValidHits() );
410  //h2_foundHitsVsPt->Fill( gsfIter->pt(), gsfIter->gsfTrack()->numberOfValidHits() );
411  h1_lostHits->Fill( gsfIter->gsfTrack()->numberOfLostHits() );
412  py_lostHitsVsEta->Fill( gsfIter->eta(), gsfIter->gsfTrack()->numberOfLostHits() );
413  py_lostHitsVsPhi->Fill( gsfIter->phi(), gsfIter->gsfTrack()->numberOfLostHits() );
414  //h2_lostHitsVsPt->Fill( gsfIter->pt(), gsfIter->gsfTrack()->numberOfLostHits() );
415  h1_chi2->Fill( gsfIter->gsfTrack()->normalizedChi2() );
416  py_chi2VsEta->Fill( gsfIter->eta(), gsfIter->gsfTrack()->normalizedChi2() );
417  py_chi2VsPhi->Fill( gsfIter->phi(), gsfIter->gsfTrack()->normalizedChi2() );
418  //h2_chi2VsPt->Fill( gsfIter->pt(), gsfIter->gsfTrack()->normalizedChi2() );
419  }
420 
421  // match distributions
422  if (gsfIter->isEB())
423  {
424  h1_Eop_barrel->Fill( gsfIter->eSuperClusterOverP() );
425  h1_EeleOPout_barrel->Fill( gsfIter->eEleClusterOverPout() );
426  h1_dEtaSc_propVtx_barrel->Fill(gsfIter->deltaEtaSuperClusterTrackAtVtx());
427  h1_dEtaEleCl_propOut_barrel->Fill(gsfIter->deltaEtaEleClusterTrackAtCalo());
428  h1_dPhiSc_propVtx_barrel->Fill(gsfIter->deltaPhiSuperClusterTrackAtVtx());
429  h1_dPhiEleCl_propOut_barrel->Fill(gsfIter->deltaPhiEleClusterTrackAtCalo());
430  h1_Hoe_barrel->Fill(gsfIter->hadronicOverEm());
431  h1_sclSigEtaEta_barrel->Fill( gsfIter->scSigmaEtaEta() );
432  }
433  if (gsfIter->isEE())
434  {
435  h1_Eop_endcaps->Fill( gsfIter->eSuperClusterOverP() );
436  h1_EeleOPout_endcaps->Fill( gsfIter->eEleClusterOverPout() );
437  h1_dEtaSc_propVtx_endcaps->Fill(gsfIter->deltaEtaSuperClusterTrackAtVtx());
438  h1_dEtaEleCl_propOut_endcaps->Fill(gsfIter->deltaEtaEleClusterTrackAtCalo());
439  h1_dPhiSc_propVtx_endcaps->Fill(gsfIter->deltaPhiSuperClusterTrackAtVtx());
440  h1_dPhiEleCl_propOut_endcaps->Fill(gsfIter->deltaPhiEleClusterTrackAtCalo());
441  h1_Hoe_endcaps->Fill(gsfIter->hadronicOverEm());
442  h1_sclSigEtaEta_endcaps->Fill( gsfIter->scSigmaEtaEta() );
443  }
444  py_EopVsPhi->Fill( gsfIter->phi(), gsfIter->eSuperClusterOverP() );
445 // h2_EopVsPt->Fill( gsfIter->pt(), gsfIter->eSuperClusterOverP() );
446 // h2_EeleOPoutVsPhi->Fill( gsfIter->phi(), gsfIter->eEleClusterOverPout() );
447 // h2_EeleOPoutVsPt->Fill( gsfIter->pt(), gsfIter->eEleClusterOverPout() );
448  py_dEtaSc_propVtxVsPhi->Fill(gsfIter->phi(), gsfIter->deltaEtaSuperClusterTrackAtVtx());
449 // h2_dEtaSc_propVtxVsPt->Fill(gsfIter->pt(), gsfIter->deltaEtaSuperClusterTrackAtVtx());
450 // h2_dEtaEleCl_propOutVsPhi->Fill(gsfIter->phi(), gsfIter->deltaEtaEleClusterTrackAtCalo());
451 // h2_dEtaEleCl_propOutVsPt->Fill(gsfIter->pt(), gsfIter->deltaEtaEleClusterTrackAtCalo());
452  py_dPhiSc_propVtxVsPhi->Fill(gsfIter->phi(), gsfIter->deltaPhiSuperClusterTrackAtVtx());
453 // h2_dPhiSc_propVtxVsPt->Fill(gsfIter->pt(), gsfIter->deltaPhiSuperClusterTrackAtVtx());
454 // h2_dPhiEleCl_propOutVsPhi->Fill(gsfIter->phi(), gsfIter->deltaPhiEleClusterTrackAtCalo());
455 // h2_dPhiEleCl_propOutVsPt->Fill(gsfIter->pt(), gsfIter->deltaPhiEleClusterTrackAtCalo());
456  py_HoeVsPhi->Fill(gsfIter->phi(), gsfIter->hadronicOverEm());
457 // h2_HoeVsPt->Fill(gsfIter->pt(), gsfIter->hadronicOverEm());
458 
459 // // from gsf track interface, hence using mean
460 // if (!readAOD_)
461 // { // track extra does not exist in AOD
462 // h_PinMnPout->Fill( gsfIter->gsfTrack()->innerMomentum().R() - gsfIter->gsfTrack()->outerMomentum().R() );
463 // //h_outerP->Fill( gsfIter->gsfTrack()->outerMomentum().R() );
464 // h_innerPt_mean->Fill( gsfIter->gsfTrack()->innerMomentum().Rho() );
465 // h_outerPt_mean->Fill( gsfIter->gsfTrack()->outerMomentum().Rho() );
466 // }
467 //
468 // // from electron interface, hence using mode
469 // h_PinMnPout_mode->Fill( gsfIter->trackMomentumAtVtx().R() - gsfIter->trackMomentumOut().R() );
470 // //h_outerP_mode->Fill( gsfIter->trackMomentumOut().R() );
471 // h_outerPt_mode->Fill( gsfIter->trackMomentumOut().Rho() );
472 //
473 
474  // fbrem, classes
475  h1_fbrem->Fill(gsfIter->fbrem()) ;
476  py_fbremVsEta->Fill(gsfIter->eta(),gsfIter->fbrem()) ;
477  py_fbremVsPhi->Fill(gsfIter->phi(),gsfIter->fbrem()) ;
478 // h2_fbremVsPt->Fill(gsfIter->pt(),gsfIter->fbrem()) ;
479  int eleClass = gsfIter->classification() ;
480  if (gsfIter->isEE()) eleClass+=5;
481  h1_classes->Fill(eleClass) ;
482 
483 
484  // pflow
485  h1_mva->Fill(gsfIter->mva()) ;
486  if (gsfIter->ecalDrivenSeed()) h1_provenance->Fill(1.) ;
487  if (gsfIter->trackerDrivenSeed()) h1_provenance->Fill(-1.) ;
488  if (gsfIter->trackerDrivenSeed()||gsfIter->ecalDrivenSeed()) h1_provenance->Fill(0.);
489  if (gsfIter->trackerDrivenSeed()&&!gsfIter->ecalDrivenSeed()) h1_provenance->Fill(-2.);
490  if (!gsfIter->trackerDrivenSeed()&&gsfIter->ecalDrivenSeed()) h1_provenance->Fill(2.);
491 
492  // isolation
493  h1_tkSumPt_dr03->Fill(gsfIter->dr03TkSumPt());
494  h1_ecalRecHitSumEt_dr03->Fill(gsfIter->dr03EcalRecHitSumEt());
495  h1_hcalTowerSumEt_dr03->Fill(gsfIter->dr03HcalTowerSumEt());
496 // h1_hcalDepth1TowerSumEt_dr03->Fill(gsfIter->dr03HcalDepth1TowerSumEt());
497 // h1_hcalDepth2TowerSumEt_dr03->Fill(gsfIter->dr03HcalDepth2TowerSumEt());
498 // h1_tkSumPt_dr04->Fill(gsfIter->dr04TkSumPt());
499 // h1_ecalRecHitSumEt_dr04->Fill(gsfIter->dr04EcalRecHitSumEt());
500 // h1_hcalTowerSumEt_dr04->Fill(gsfIter->dr04HcalTowerSumEt());
503 
504  }
505 
506  // association matching object-reco electrons
507 // int matchingObjectNum=0;
508  reco::SuperClusterCollection::const_iterator moIter ;
509  for
510  ( moIter=recoClusters->begin() ;
511  moIter!=recoClusters->end() ;
512  moIter++ )
513  {
514 // // number of matching objects
515 // matchingObjectNum++;
516 
517  if
518  ( moIter->energy()/cosh(moIter->eta())>maxPtMatchingObject_ ||
519  std::abs(moIter->eta())> maxAbsEtaMatchingObject_ )
520  { continue ; }
521 
522 // // suppress the endcaps
523 // //if (std::abs(moIter->eta()) > 1.5) continue;
524 // // select central z
525 // //if ( std::abs((*mcIter)->production_vertex()->position().z())>50.) continue;
526 
527  h1_matchingObject_Eta->Fill( moIter->eta() );
528 // h1_matchingObject_AbsEta->Fill( std::abs(moIter->eta()) );
529 // h1_matchingObject_P->Fill( moIter->energy() );
530  h1_matchingObject_Pt->Fill( moIter->energy()/cosh(moIter->eta()) );
531  h1_matchingObject_Phi->Fill( moIter->phi() );
532  h1_matchingObject_Z->Fill( moIter->z() );
533 
534  bool okGsfFound = false ;
535  double gsfOkRatio = 999999999. ;
536  reco::GsfElectron bestGsfElectron ;
537  reco::GsfElectronCollection::const_iterator gsfIter ;
538  for
539  ( gsfIter=gsfElectrons->begin() ;
540  gsfIter!=gsfElectrons->end() ;
541  gsfIter++ )
542  {
543  reco::GsfElectronCollection::const_iterator gsfIter2 ;
544  for
545  ( gsfIter2=gsfIter+1;
546  gsfIter2!=gsfElectrons->end() ;
547  gsfIter2++ )
548  {
549  float invMass = computeInvMass(*gsfIter,*gsfIter2) ;
550  h1_mee->Fill(invMass) ;
551  if (((gsfIter->charge())*(gsfIter2->charge()))<0.)
552  { h1_mee_os->Fill(invMass) ; }
553  }
554 
555  double vertexTIP =
556  (gsfIter->vertex().x()-bs.position().x()) * (gsfIter->vertex().x()-bs.position().x()) +
557  (gsfIter->vertex().y()-bs.position().y()) * (gsfIter->vertex().y()-bs.position().y()) ;
558  vertexTIP = sqrt(vertexTIP) ;
559 
560  // select electrons
561  if (!selected(gsfIter,vertexTIP)) continue ;
562 
563  // matching with a cone in eta phi
564  if ( matchingCondition_ == "Cone" )
565  {
566  double dphi = gsfIter->phi()-moIter->phi() ;
567  if (std::abs(dphi)>CLHEP::pi)
568  { dphi = dphi < 0? (CLHEP::twopi) + dphi : dphi - CLHEP::twopi ; }
569  double deltaR = sqrt(pow((moIter->eta()-gsfIter->eta()),2) + pow(dphi,2)) ;
570  if ( deltaR < deltaR_ )
571  {
572  //if ( (genPc->pdg_id() == 11) && (gsfIter->charge() < 0.) || (genPc->pdg_id() == -11) &&
573  //(gsfIter->charge() > 0.) ){
574  double tmpGsfRatio = gsfIter->p()/moIter->energy() ;
575  if ( std::abs(tmpGsfRatio-1) < std::abs(gsfOkRatio-1) )
576  {
577  gsfOkRatio = tmpGsfRatio;
578  bestGsfElectron=*gsfIter;
579  okGsfFound = true;
580  }
581  //}
582  }
583  }
584  } // loop over rec ele to look for the best one
585  if (okGsfFound)
586  {
587  // generated distributions for matched electrons
588  h1_matchedObject_Eta->Fill( moIter->eta() );
589  // h1_matchedObject_AbsEta->Fill( std::abs(moIter->eta()) );
590  h1_matchedObject_Pt->Fill( moIter->energy()/cosh(moIter->eta()) );
591  h1_matchedObject_Phi->Fill( moIter->phi() );
592  h1_matchedObject_Z->Fill( moIter->z() );
593 
594  //classes
595  // int eleClass = bestGsfElectron.classification() ;
596  // h_classes->Fill(eleClass) ;
597  // h_matchedEle_eta->Fill(std::abs(bestGsfElectron.eta()));
598  // if (bestGsfElectron.classification() == GsfElectron::GOLDEN) h_matchedEle_eta_golden->Fill(std::abs(bestGsfElectron.eta()));
599  // if (bestGsfElectron.classification() == GsfElectron::SHOWERING) h_matchedEle_eta_shower->Fill(std::abs(bestGsfElectron.eta()));
600  // //if (bestGsfElectron.classification() == GsfElectron::BIGBREM) h_matchedEle_eta_bbrem->Fill(std::abs(bestGsfElectron.eta()));
601  // //if (bestGsfElectron.classification() == GsfElectron::OLDNARROW) h_matchedEle_eta_narrow->Fill(std::abs(bestGsfElectron.eta()));
602  }
603 
604  } // loop overmatching object
605 
606 // h_matchingObject_Num->Fill(matchingObjectNum) ;
607 
608  }
609 
611  ( const reco::GsfElectron & e1,
612  const reco::GsfElectron & e2 )
613  {
614  math::XYZTLorentzVector p12 = e1.p4()+e2.p4() ;
615  float mee2 = p12.Dot(p12) ;
616  float invMass = sqrt(mee2) ;
617  return invMass ;
618  }
619 
620 //bool ElectronAnalyzer::trigger( const edm::Event & e )
621 // {
622 // // retreive TriggerResults from the event
623 // edm::Handle<edm::TriggerResults> triggerResults ;
624 // e.getByLabel(triggerResults_,triggerResults) ;
625 //
626 // bool accept = false ;
627 //
628 // if (triggerResults.isValid())
629 // {
630 // //std::cout << "TriggerResults found, number of HLT paths: " << triggerResults->size() << std::endl;
631 // // get trigger names
632 // const edm::TriggerNames & triggerNames_ = e.triggerNames(*triggerResults);
638 //
639 // unsigned int n = HLTPathsByName_.size() ;
640 // for (unsigned int i=0; i!=n; i++)
641 // {
642 // HLTPathsByIndex_[i]=triggerNames_.triggerIndex(HLTPathsByName_[i]) ;
643 // }
644 //
645 // // empty input vectors (n==0) means any trigger paths
646 // if (n==0)
647 // {
648 // n=triggerResults->size() ;
649 // HLTPathsByName_.resize(n) ;
650 // HLTPathsByIndex_.resize(n) ;
651 // for ( unsigned int i=0 ; i!=n ; i++)
652 // {
653 // HLTPathsByName_[i]=triggerNames_.triggerName(i) ;
654 // HLTPathsByIndex_[i]=i ;
655 // }
656 // }
657 //
673 //
674 // // count number of requested HLT paths which have fired
675 // unsigned int fired=0 ;
676 // for ( unsigned int i=0 ; i!=n ; i++ )
677 // {
678 // if (HLTPathsByIndex_[i]<triggerResults->size())
679 // {
680 // if (triggerResults->accept(HLTPathsByIndex_[i]))
681 // {
682 // fired++ ;
683 // h1_triggers->Fill(float(HLTPathsByIndex_[i]));
684 // //std::cout << "Fired HLT path= " << HLTPathsByName_[i] << std::endl ;
685 // accept = true ;
686 // }
687 // }
688 // }
689 //
690 // }
691 //
692 // return accept ;
693 // }
694 
695 bool ElectronAnalyzer::selected( const reco::GsfElectronCollection::const_iterator & gsfIter , double vertexTIP )
696  {
697  if ((Selection_>0)&&generalCut(gsfIter)) return false ;
698  if ((Selection_>=1)&&etCut(gsfIter)) return false ;
699  if ((Selection_>=2)&&isolationCut(gsfIter,vertexTIP)) return false ;
700  if ((Selection_>=3)&&idCut(gsfIter)) return false ;
701  return true ;
702  }
703 
704 bool ElectronAnalyzer::generalCut( const reco::GsfElectronCollection::const_iterator & gsfIter)
705  {
706  if (std::abs(gsfIter->eta())>maxAbsEta_) return true ;
707  if (gsfIter->pt()<minPt_) return true ;
708 
709  if (gsfIter->isEB() && isEE_) return true ;
710  if (gsfIter->isEE() && isEB_) return true ;
711  if (gsfIter->isEBEEGap() && isNotEBEEGap_) return true ;
712 
713  if (gsfIter->ecalDrivenSeed() && isTrackerDriven_) return true ;
714  if (gsfIter->trackerDrivenSeed() && isEcalDriven_) return true ;
715 
716  return false ;
717  }
718 
719 bool ElectronAnalyzer::etCut( const reco::GsfElectronCollection::const_iterator & gsfIter )
720  {
721  if (gsfIter->superCluster()->energy()/cosh(gsfIter->superCluster()->eta())<minEt_) return true ;
722 
723  return false ;
724  }
725 
726 bool ElectronAnalyzer::isolationCut( const reco::GsfElectronCollection::const_iterator & gsfIter, double vertexTIP )
727  {
728  if (gsfIter->isEB() && vertexTIP > tipMaxBarrel_) return true ;
729  if (gsfIter->isEE() && vertexTIP > tipMaxEndcaps_) return true ;
730 
731  if (gsfIter->dr03TkSumPt() > tkIso03Max_) return true ;
732  if (gsfIter->isEB() && gsfIter->dr03HcalDepth1TowerSumEt() > hcalIso03Depth1MaxBarrel_) return true ;
733  if (gsfIter->isEE() && gsfIter->dr03HcalDepth1TowerSumEt() > hcalIso03Depth1MaxEndcaps_) return true ;
734  if (gsfIter->isEE() && gsfIter->dr03HcalDepth2TowerSumEt() > hcalIso03Depth2MaxEndcaps_) return true ;
735  if (gsfIter->isEB() && gsfIter->dr03EcalRecHitSumEt() > ecalIso03MaxBarrel_) return true ;
736  if (gsfIter->isEE() && gsfIter->dr03EcalRecHitSumEt() > ecalIso03MaxEndcaps_) return true ;
737 
738  return false ;
739  }
740 
741 bool ElectronAnalyzer::idCut( const reco::GsfElectronCollection::const_iterator & gsfIter )
742  {
743  if (gsfIter->isEB() && gsfIter->eSuperClusterOverP() < eOverPMinBarrel_) return true ;
744  if (gsfIter->isEB() && gsfIter->eSuperClusterOverP() > eOverPMaxBarrel_) return true ;
745  if (gsfIter->isEE() && gsfIter->eSuperClusterOverP() < eOverPMinEndcaps_) return true ;
746  if (gsfIter->isEE() && gsfIter->eSuperClusterOverP() > eOverPMaxEndcaps_) return true ;
747  if (gsfIter->isEB() && std::abs(gsfIter->deltaEtaSuperClusterTrackAtVtx()) < dEtaMinBarrel_) return true ;
748  if (gsfIter->isEB() && std::abs(gsfIter->deltaEtaSuperClusterTrackAtVtx()) > dEtaMaxBarrel_) return true ;
749  if (gsfIter->isEE() && std::abs(gsfIter->deltaEtaSuperClusterTrackAtVtx()) < dEtaMinEndcaps_) return true ;
750  if (gsfIter->isEE() && std::abs(gsfIter->deltaEtaSuperClusterTrackAtVtx()) > dEtaMaxEndcaps_) return true ;
751  if (gsfIter->isEB() && std::abs(gsfIter->deltaPhiSuperClusterTrackAtVtx()) < dPhiMinBarrel_) return true ;
752  if (gsfIter->isEB() && std::abs(gsfIter->deltaPhiSuperClusterTrackAtVtx()) > dPhiMaxBarrel_) return true ;
753  if (gsfIter->isEE() && std::abs(gsfIter->deltaPhiSuperClusterTrackAtVtx()) < dPhiMinEndcaps_) return true ;
754  if (gsfIter->isEE() && std::abs(gsfIter->deltaPhiSuperClusterTrackAtVtx()) > dPhiMaxEndcaps_) return true ;
755  if (gsfIter->isEB() && gsfIter->scSigmaIEtaIEta() < sigIetaIetaMinBarrel_) return true ;
756  if (gsfIter->isEB() && gsfIter->scSigmaIEtaIEta() > sigIetaIetaMaxBarrel_) return true ;
757  if (gsfIter->isEE() && gsfIter->scSigmaIEtaIEta() < sigIetaIetaMinEndcaps_) return true ;
758  if (gsfIter->isEE() && gsfIter->scSigmaIEtaIEta() > sigIetaIetaMaxEndcaps_) return true ;
759  if (gsfIter->isEB() && gsfIter->hadronicOverEm() > hadronicOverEmMaxBarrel_) return true ;
760  if (gsfIter->isEE() && gsfIter->hadronicOverEm() > hadronicOverEmMaxEndcaps_) return true ;
761 
762  return false ;
763  }
RunNumber_t run() const
Definition: EventID.h:42
MonitorElement * h1_foundHits
virtual void book()
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:44
MonitorElement * bookP1(const std::string &name, const std::string &title, int nchX, double lowX, double highX, double lowY, double highY, const std::string &titleX="", const std::string &titleY="", Option_t *option="E1 P")
MonitorElement * bookH1(const std::string &name, const std::string &title, int nchX, double lowX, double highX, const std::string &titleX="", const std::string &titleY="Events", Option_t *option="E1 P")
double hadronicOverEmMaxEndcaps_
MonitorElement * h1_mee_os
bool selected(const reco::GsfElectronCollection::const_iterator &gsfIter, double vertexTIP)
MonitorElement * h1_dPhiSc_propVtx_barrel
edm::InputTag vertexCollection_
unsigned int nEvents_
MonitorElement * h1_vertexPt_barrel
MonitorElement * py_lostHitsVsEta
MonitorElement * h1_sclSigEtaEta_barrel
MonitorElement * py_chi2VsEta
MonitorElement * py_chi2VsPhi
MonitorElement * h1_Eop_endcaps
MonitorElement * h1_ecalRecHitSumEt_dr03
#define abs(x)
Definition: mlp_lapack.h:159
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:59
MonitorElement * h1_hcalTowerSumEt_dr03
MonitorElement * h1_matchingObject_Eta
MonitorElement * h1_Hoe_barrel
edm::InputTag triggerResults_
MonitorElement * py_HoeVsPhi
MonitorElement * h1_matchedObject_Pt
double sigIetaIetaMinBarrel_
MonitorElement * bookH1withSumw2(const std::string &name, const std::string &title, int nchX, double lowX, double highX, const std::string &titleX="", const std::string &titleY="Events", Option_t *option="E1 P")
MonitorElement * h1_matchedObject_Phi
void Fill(long long x)
MonitorElement * h1_tkSumPt_dr03
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:30
double sigIetaIetaMaxBarrel_
int iEvent
Definition: GenABIO.cc:243
edm::InputTag gsftrackCollection_
MonitorElement * h2_vertexXvsY
MonitorElement * py_fbremVsEta
MonitorElement * h1_provenance
MonitorElement * h1_dEtaEleCl_propOut_barrel
MonitorElement * py_EopVsPhi
edm::InputTag matchingObjectCollection_
MonitorElement * h1_Eop_barrel
T sqrt(T t)
Definition: SSEVec.h:28
edm::InputTag electronCollection_
double sigIetaIetaMinEndcaps_
MonitorElement * py_dEtaSc_propVtxVsPhi
double sigIetaIetaMaxEndcaps_
std::string matchingCondition_
double hcalIso03Depth1MaxBarrel_
MonitorElement * h1_dEtaEleCl_propOut_endcaps
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
MonitorElement * h1_Hoe_endcaps
tuple conf
Definition: dbtoconf.py:185
ElectronAnalyzer(const edm::ParameterSet &conf)
MonitorElement * h1_vertexPt_endcaps
MonitorElement * py_lostHitsVsPhi
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
MonitorElement * h1_vertexZ
MonitorElement * py_dPhiSc_propVtxVsPhi
double hcalIso03Depth1MaxEndcaps_
MonitorElement * h1_dPhiEleCl_propOut_endcaps
virtual void analyze(const edm::Event &e, const edm::EventSetup &c)
MonitorElement * py_fbremVsPhi
MonitorElement * py_foundHitsVsPhi
bool etCut(const reco::GsfElectronCollection::const_iterator &gsfIter)
tuple tracks
Definition: testEve_cfg.py:39
MonitorElement * h1_fbrem
MonitorElement * h1_chi2
double maxAbsEtaMatchingObject_
MonitorElement * h1_lostHits
MonitorElement * h2_vertexEtaVsPhi
MonitorElement * h1_EeleOPout_endcaps
edm::InputTag beamSpotTag_
MonitorElement * h1_mee
T const * product() const
Definition: Handle.h:74
MonitorElement * bookH2(const std::string &name, const std::string &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, const std::string &titleX="", const std::string &titleY="", Option_t *option="COLZ")
MonitorElement * h1_classes
MonitorElement * h1_sclEt
std::string const & label() const
Definition: InputTag.h:25
MonitorElement * h1_EeleOPout_barrel
edm::EventID id() const
Definition: EventBase.h:56
bool generalCut(const reco::GsfElectronCollection::const_iterator &gsfIter)
MonitorElement * h1_dEtaSc_propVtx_barrel
float computeInvMass(const reco::GsfElectron &e1, const reco::GsfElectron &e2)
MonitorElement * h1_matchingObject_Phi
MonitorElement * h1_matchedObject_Z
MonitorElement * h1_dPhiSc_propVtx_endcaps
MonitorElement * h1_matchingObject_Z
edm::InputTag trackCollection_
virtual ~ElectronAnalyzer()
MonitorElement * h1_sclSigEtaEta_endcaps
const Point & position() const
position
Definition: BeamSpot.h:63
double pi
MonitorElement * py_foundHitsVsEta
bool idCut(const reco::GsfElectronCollection::const_iterator &gsfIter)
double hcalIso03Depth2MaxEndcaps_
double hadronicOverEmMaxBarrel_
virtual const LorentzVector & p4() const
four-momentum Lorentz vector
MonitorElement * h1_matchedObject_Eta
MonitorElement * h1_matchingObject_Pt
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
MonitorElement * h1_dPhiEleCl_propOut_barrel
MonitorElement * h1_dEtaSc_propVtx_endcaps
MonitorElement * h1_mva
bool isolationCut(const reco::GsfElectronCollection::const_iterator &gsfIter, double vertexTIP)