CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ElectronTagProbeAnalyzer.cc
Go to the documentation of this file.
2 
4 
13 
20 //#include "FWCore/Framework/interface/EDAnalyzer.h"
22 
23 #include "CLHEP/Units/GlobalPhysicalConstants.h"
24 #include "TMath.h"
25 
26 #include <iostream>
27 #include <vector>
28 
29 using namespace reco ;
30 
33  {
34  // general, collections
35  Selection_ = conf.getParameter<int>("Selection");
36  electronCollection_ = conf.getParameter<edm::InputTag>("ElectronCollection");
37  matchingObjectCollection_ = conf.getParameter<edm::InputTag>("MatchingObjectCollection");
38  trackCollection_ = conf.getParameter<edm::InputTag>("TrackCollection");
39  vertexCollection_ = conf.getParameter<edm::InputTag>("VertexCollection");
40  gsftrackCollection_ = conf.getParameter<edm::InputTag>("GsfTrackCollection");
41  beamSpotTag_ = conf.getParameter<edm::InputTag>("BeamSpot");
42  readAOD_ = conf.getParameter<bool>("ReadAOD");
43 
44  // tag and probe
45  massLow_ = conf.getParameter< double >("MassLow");
46  massHigh_ = conf.getParameter< double >("MassHigh");
47  TPchecksign_ = conf.getParameter<bool>("TpCheckSign");
48  TAGcheckclass_ = conf.getParameter<bool>("TagCheckClass");
49  PROBEetcut_ = conf.getParameter<bool>("ProbeEtCut");
50  PROBEcheckclass_ = conf.getParameter<bool>("ProbeCheckClass");
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  // basic quantities
168  h1_vertexPt_barrel = bookH1("vertexPt_barrel","ele transverse momentum in barrel",nbinpt,0.,ptmax,"p_{T vertex} (GeV/c)");
169  h1_vertexPt_endcaps = bookH1("vertexPt_endcaps","ele transverse momentum in endcaps",nbinpt,0.,ptmax,"p_{T vertex} (GeV/c)");
170  h1_vertexEta = bookH1("vertexEta","ele momentum #eta",nbineta,etamin,etamax,"#eta");
171  h2_vertexEtaVsPhi = bookH2("vertexEtaVsPhi","ele momentum #eta vs #phi",nbineta2D,etamin,etamax,nbinphi2D,phimin,phimax,"#eta","#phi (rad)");
172  h2_vertexXvsY = bookH2("vertexXvsY","ele vertex x vs y",nbinxyz2D,-0.1,0.1,nbinxyz2D,-0.1,0.1,"x (cm)","y (cm)" );
173  h1_vertexZ = bookH1("vertexZ","ele vertex z",nbinxyz,-25, 25,"z (cm)" );
174 
175  // super-clusters
176 // h1_sclPhi = bookH1("sclPhi","ele supercluster phi",nbinphi,phimin,phimax);
177  h1_sclEt = bookH1("sclEt","ele supercluster transverse energy",nbinpt,0.,ptmax);
178 
179  // electron track
180  h1_chi2 = bookH1("chi2","ele track #chi^{2}",100,0.,15.,"#Chi^{2}");
181  h1_foundHits = bookH1("foundHits","ele track # found hits",nbinfhits,0.,fhitsmax,"N_{hits}");
182  h1_lostHits = bookH1("lostHits","ele track # lost hits",5,0.,5.,"N_{lost hits}");
183 
184  // electron matching and ID
185  h1_Eop_barrel = bookH1( "Eop_barrel","ele E/P_{vertex} in barrel",nbineop,0.,eopmax,"E/P_{vertex}");
186  h1_Eop_endcaps = bookH1( "Eop_endcaps","ele E/P_{vertex} in endcaps",nbineop,0.,eopmax,"E/P_{vertex}");
187  h1_EeleOPout_barrel = bookH1( "EeleOPout_barrel","ele E_{ele}/P_{out} in barrel",nbineop,0.,eopmax,"E_{ele}/P_{out}");
188  h1_EeleOPout_endcaps = bookH1( "EeleOPout_endcaps","ele E_{ele}/P_{out} in endcaps",nbineop,0.,eopmax,"E_{ele}/P_{out}");
189  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}");
190  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}");
191  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}");
192  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}");
193  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)");
194  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)");
195  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)");
196  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)");
197  h1_Hoe_barrel = bookH1("Hoe_barrel","ele hadronic energy / em energy, in barrel", nbinhoe, hoemin, hoemax,"H/E","Events","ELE_LOGY E1 P") ;
198  h1_Hoe_endcaps = bookH1("Hoe_endcaps","ele hadronic energy / em energy, in endcaps", nbinhoe, hoemin, hoemax,"H/E","Events","ELE_LOGY E1 P") ;
199  h1_sclSigEtaEta_barrel = bookH1("sclSigEtaEta_barrel","ele supercluster sigma eta eta in barrel",100,0.,0.05);
200  h1_sclSigEtaEta_endcaps = bookH1("sclSigEtaEta_endcaps","ele supercluster sigma eta eta in endcaps",100,0.,0.05);
201 
202  // fbrem
203  h1_fbrem = bookH1("fbrem","ele brem fraction",100,0.,1.,"P_{in} - P_{out} / P_{in}") ;
204  h1_classes = bookH1("classes","ele electron classes",10,0.0,10.);
205 
206  // pflow
207  h1_mva = bookH1( "mva","ele identification mva",100,-1.,1.);
208  h1_provenance = bookH1( "provenance","ele provenance",5,-2.,3.);
209 
210  // isolation
211  h1_tkSumPt_dr03 = bookH1("tkSumPt_dr03","tk isolation sum, dR=0.3",100,0.0,20.,"TkIsoSum, cone 0.3 (GeV/c)","Events","ELE_LOGY E1 P");
212  h1_ecalRecHitSumEt_dr03 = bookH1("ecalRecHitSumEt_dr03","ecal isolation sum, dR=0.3",100,0.0,20.,"EcalIsoSum, cone 0.3 (GeV)","Events","ELE_LOGY E1 P");
213  h1_hcalTowerSumEt_dr03 = bookH1("hcalTowerSumEt_dr03","hcal isolation sum, dR=0.3",100,0.0,20.,"HcalIsoSum, cone 0.3 (GeV)","Events","ELE_LOGY E1 P");
214 
215  // di-electron mass
216  setBookIndex(200) ;
217  h1_mee = bookH1("mesc","Tag ele Probe SC invariant mass", nbinmee, meemin, meemax,"m_{eSC} (GeV/c^{2})");
218  h1_mee_os = bookH1("mee_os","ele pairs invariant mass, opposite sign", nbinmee, meemin, meemax,"m_{e^{+}e^{-}} (GeV/c^{2})");
219 
220 
221 
222  //===========================
223  // histos for matching and matched matched objects
224  //===========================
225 
226  // matching object
227  std::string matchingObjectType ;
228  if (std::string::npos!=matchingObjectCollection_.label().find("SuperCluster",0))
229  { matchingObjectType = "SC" ; }
230  if (matchingObjectType=="")
231  { edm::LogError("ElectronMcFakeValidator::beginJob")<<"Unknown matching object type !" ; }
232  else
233  { edm::LogInfo("ElectronMcFakeValidator::beginJob")<<"Matching object type: "<<matchingObjectType ; }
234 
235  // matching object distributions
236  h1_matchingObject_Eta = bookH1withSumw2("matchingObject_Eta",matchingObjectType+" #eta",nbineta,etamin,etamax,"#eta_{SC}");
237  h1_matchingObject_Pt = bookH1withSumw2("matchingObject_Pt",matchingObjectType+" pt",nbinpteff,5.,ptmax);
238  h1_matchingObject_Phi = bookH1withSumw2("matchingObject_Phi",matchingObjectType+" phi",nbinphi,phimin,phimax);
239  //h1_matchingObject_Z = bookH1withSumw2("matchingObject_Z",matchingObjectType+" z",nbinxyz,-25,25);
240 
241  h1_matchedObject_Eta = bookH1withSumw2("matchedObject_Eta","Efficiency vs matching SC #eta",nbineta,etamin,etamax);
242  h1_matchedObject_Pt = bookH1withSumw2("matchedObject_Pt","Efficiency vs matching SC E_{T}",nbinpteff,5.,ptmax);
243  h1_matchedObject_Phi = bookH1withSumw2("matchedObject_Phi","Efficiency vs matching SC phi",nbinphi,phimin,phimax);
244  //h1_matchedObject_Z = bookH1withSumw2("matchedObject_Z","Efficiency vs matching SC z",nbinxyz,-25,25);
245 
246  }
247 
249  {
250  nEvents_++ ;
251 
253  iEvent.getByLabel(electronCollection_,gsfElectrons) ;
255  iEvent.getByLabel(matchingObjectCollection_,recoClusters) ;
257  iEvent.getByLabel(trackCollection_,tracks);
259  iEvent.getByLabel(gsftrackCollection_,gsfTracks);
261  iEvent.getByLabel(vertexCollection_,vertices);
262  edm::Handle<reco::BeamSpot> recoBeamSpotHandle ;
263  iEvent.getByLabel(beamSpotTag_,recoBeamSpotHandle) ;
264  const BeamSpot bs = *recoBeamSpotHandle ;
265 
266  int ievt = iEvent.id().event();
267  int irun = iEvent.id().run();
268  int ils = iEvent.luminosityBlock();
269 
270  edm::LogInfo("ElectronMcSignalValidator::analyze")
271  <<"Treating "<<gsfElectrons.product()->size()<<" electrons"
272  <<" from event "<<ievt<<" in run "<<irun<<" and lumiblock "<<ils ;
273  //h1_num_->Fill((*gsfElectrons).size()) ;
274 
275  std::vector<std::pair<double,double> > TTCheck;
276  std::vector<std::pair<double,double> > TTscCheck;
277 
278  // selected rec electrons
279  reco::GsfElectronCollection::const_iterator gsfIter ;
280  for
281  ( gsfIter=gsfElectrons->begin() ;
282  gsfIter!=gsfElectrons->end();
283  gsfIter++ )
284  {
285  // vertex TIP
286  double vertexTIP =
287  (gsfIter->vertex().x()-bs.position().x()) * (gsfIter->vertex().x()-bs.position().x()) +
288  (gsfIter->vertex().y()-bs.position().y()) * (gsfIter->vertex().y()-bs.position().y()) ;
289  vertexTIP = sqrt(vertexTIP) ;
290 
291  // select electrons
292  if (!selected(gsfIter,vertexTIP)) continue ;
293 
294  reco::SuperClusterRef sclTagRef = gsfIter->superCluster() ;
295  reco::SuperClusterCollection::const_iterator moIter ;
296  for
297  ( moIter=recoClusters->begin() ;
298  moIter!=recoClusters->end() ;
299  moIter++ )
300  {
301  if (moIter->eta()==sclTagRef->eta()) continue ;
302 
303  /*
304  if
305  ( moIter->energy()/cosh(moIter->eta())>maxPtMatchingObject_ ||
306  std::abs(moIter->eta())> maxAbsEtaMatchingObject_ )
307  { continue ; }
308  */
309 
310  // Additional cuts on Tag
311 
312  // Additional cuts on Probe
313  if(PROBEetcut_ && (moIter->energy()/cosh(moIter->eta())<minEt_)) continue ;
314 
315  float SCenergy = moIter->energy();
316  math::XYZPoint caloposition = moIter->position();
317  float theta = caloposition.Theta();
318  math::XYZVector momentum;
319  float SCmomentumX = SCenergy*sin(theta)*cos(moIter->phi());
320  float SCmomentumY = SCenergy*sin(theta)*sin(moIter->phi());
321  float SCmomentumZ = SCenergy*cos(theta);
322  const reco::Particle::LorentzVector pSCprobecandidate(SCmomentumX,SCmomentumY,SCmomentumZ,SCenergy);
323 
324  math::XYZTLorentzVector p12 = (*gsfIter).p4()+ pSCprobecandidate;
325  float mee2 = p12.Dot(p12);
326  float invMass = sqrt(mee2);
327 
328  if( invMass < massLow_ || invMass > massHigh_ ) continue ;
329 
330 
331  h1_matchingObject_Eta->Fill( moIter->eta() );
332  h1_matchingObject_Pt->Fill( moIter->energy()/cosh(moIter->eta()) );
333  h1_matchingObject_Phi->Fill( moIter->phi() );
334  //h1_matchingObject_Z->Fill( moIter->z() );
335 
336  reco::GsfElectron bestGsfElectron;
337  reco::SuperClusterRef sclProbeRef;
338  bool okGsfFound = false;
339  //double gsfOkRatio = 999999.;
340  reco::GsfElectronCollection::const_iterator gsfIter2 ;
341 
342  for
343  ( gsfIter2=gsfElectrons->begin();
344  gsfIter2!=gsfElectrons->end() ;
345  gsfIter2++ )
346  {
347  // matching with ref
348  sclProbeRef = gsfIter2->superCluster();
349 
350  if (sclProbeRef->eta() == moIter->eta())
351  {
352  //std::cout << "les deux ref SC sont egales : " << std::endl;
353  bestGsfElectron=*gsfIter2;
354 
355  // opposite sign checking
356  bool opsign = (((gsfIter->charge())*(bestGsfElectron.charge()))<0.) ;
357  if ( TPchecksign_ && !opsign )
358  { okGsfFound = false ;
359  h1_mee->Fill(invMass) ;
360  break ; }
361  else
362  { okGsfFound = true ; }
363  } //fi on gsfEleSC.eta == probeSC.eta
364 
365 // // matching with cone
366 // double dphi = gsfIter2->phi()-moIter->phi();
367 // if (std::abs(dphi)>CLHEP::pi)
368 // dphi = dphi < 0? (CLHEP::twopi) + dphi : dphi - CLHEP::twopi;
369 // double deltaR = sqrt(pow((moIter->eta()-gsfIter2->eta()),2) + pow(dphi,2));
370 // if ( deltaR < deltaR_ )
371 // {
372 // double tmpGsfRatio = gsfIter2->p()/moIter->energy();
373 // if ( std::abs(tmpGsfRatio-1) < std::abs(gsfOkRatio-1))
374 // {
375 // gsfOkRatio = tmpGsfRatio;
376 // bestGsfElectron=*gsfIter2;
377 // okGsfFound = true;
378 // }
379 // } // fi on deltaR
380 
381  }// end of loop on gsfEle to find the best one which matches with probe SC
382 
383  if (okGsfFound)
384  {
385  // fill matched histos for eff
386  fillMatchedHistos(moIter,bestGsfElectron) ;
387 
388  // basic quantities
389  if (bestGsfElectron.isEB()) h1_vertexPt_barrel->Fill( bestGsfElectron.pt() );
390  if (bestGsfElectron.isEE()) h1_vertexPt_endcaps->Fill( bestGsfElectron.pt() );
391  h1_vertexEta->Fill( bestGsfElectron.eta() );
392  h2_vertexEtaVsPhi->Fill( bestGsfElectron.eta(), bestGsfElectron.phi() );
393  h2_vertexXvsY->Fill( bestGsfElectron.vertex().x(), bestGsfElectron.vertex().y() );
394  h1_vertexZ->Fill( bestGsfElectron.vertex().z() );
395 
396  // supercluster related distributions
397  reco::SuperClusterRef sclRef = bestGsfElectron.superCluster() ;
398  double R=TMath::Sqrt(sclRef->x()*sclRef->x() + sclRef->y()*sclRef->y() +sclRef->z()*sclRef->z());
399  double Rt=TMath::Sqrt(sclRef->x()*sclRef->x() + sclRef->y()*sclRef->y());
400  h1_sclEt->Fill(sclRef->energy()*(Rt/R));
401 
402  if (!readAOD_)
403  { // track extra does not exist in AOD
404  h1_foundHits->Fill( bestGsfElectron.gsfTrack()->numberOfValidHits() );
405  h1_lostHits->Fill( bestGsfElectron.gsfTrack()->numberOfLostHits() );
406  h1_chi2->Fill( bestGsfElectron.gsfTrack()->normalizedChi2() );
407  }
408 
409  // match distributions
410  if (bestGsfElectron.isEB())
411  {
412  h1_Eop_barrel->Fill( bestGsfElectron.eSuperClusterOverP() );
413  h1_EeleOPout_barrel->Fill( bestGsfElectron.eEleClusterOverPout() );
418  h1_Hoe_barrel->Fill(bestGsfElectron.hadronicOverEm());
419  h1_sclSigEtaEta_barrel->Fill( bestGsfElectron.scSigmaEtaEta() );
420  }
421  if (bestGsfElectron.isEE())
422  {
423  h1_Eop_endcaps->Fill( bestGsfElectron.eSuperClusterOverP() );
424  h1_EeleOPout_endcaps->Fill( bestGsfElectron.eEleClusterOverPout() );
429  h1_Hoe_endcaps->Fill(bestGsfElectron.hadronicOverEm());
430  h1_sclSigEtaEta_endcaps->Fill( bestGsfElectron.scSigmaEtaEta() );
431  }
432 
433  // fbrem
434  h1_fbrem->Fill(bestGsfElectron.fbrem()) ;
435  int eleClass = bestGsfElectron.classification() ;
436  if (bestGsfElectron.isEE()) eleClass+=5;
437  h1_classes->Fill(eleClass);
438 
439  // pflow
440  h1_mva->Fill(bestGsfElectron.mva()) ;
441  if (bestGsfElectron.ecalDrivenSeed()) h1_provenance->Fill(1.) ;
442  if (bestGsfElectron.trackerDrivenSeed()) h1_provenance->Fill(-1.) ;
443  if (bestGsfElectron.trackerDrivenSeed()||bestGsfElectron.ecalDrivenSeed()) h1_provenance->Fill(0.);
444  if (bestGsfElectron.trackerDrivenSeed()&&!bestGsfElectron.ecalDrivenSeed()) h1_provenance->Fill(-2.);
445  if (!bestGsfElectron.trackerDrivenSeed()&&bestGsfElectron.ecalDrivenSeed()) h1_provenance->Fill(2.);
446 
447  // isolation
448  h1_tkSumPt_dr03->Fill(bestGsfElectron.dr03TkSumPt());
450  h1_hcalTowerSumEt_dr03->Fill(bestGsfElectron.dr03HcalTowerSumEt());
451 
452  // inv Mass with opposite sign
453  bool invMassTTAlreadyFilled = false;
454  if(TTCheck.size() != 0){
455  int TTCheckDim = TTCheck.size();
456  for(int i=0 ;i<TTCheckDim;i++){
457  if((bestGsfElectron.eta() == TTCheck.at(i).first) && (gsfIter->eta() == TTCheck.at(i).second)){
458  invMassTTAlreadyFilled=true;
459  }
460  }
461  }
462 
463 
464  if (!invMassTTAlreadyFilled && (((gsfIter->charge())*(bestGsfElectron.charge()))<0.))
465  {
466  h1_mee->Fill(invMass);
467  math::XYZTLorentzVector p12bis = (*gsfIter).p4()+ bestGsfElectron.p4() ;
468  float mee2bis = p12.Dot(p12bis);
469  float invMassEE = sqrt(mee2bis);
470  if(invMassEE >= massLow_ && invMassEE <= massHigh_){h1_mee_os->Fill(invMassEE);}
471  std::pair<double,double> p(gsfIter->eta(),bestGsfElectron.eta());
472  TTCheck.push_back(p);
473  }
474 
475  }// fi on OkGsfFound
476  else{
477  h1_mee->Fill(invMass) ;
478  }
479 
480  } // end of loop on SC to find probe SC
481 
482  }// end of loop on Tag gsfEle
483 
484  }
485 
487  ( const reco::GsfElectron & e1,
488  const reco::GsfElectron & e2 )
489  {
490  math::XYZTLorentzVector p12 = e1.p4()+e2.p4() ;
491  float mee2 = p12.Dot(p12) ;
492  float invMass = sqrt(mee2) ;
493  return invMass ;
494  }
495 
497  ( const reco::SuperClusterCollection::const_iterator & moIter,
498  const reco::GsfElectron & electron )
499  {
500  // generated distributions for matched electrons
501  h1_matchedObject_Eta->Fill( moIter->eta() );
502 // h1_matchedObject_AbsEta->Fill( std::abs(moIter->eta()) );
503  h1_matchedObject_Pt->Fill( moIter->energy()/cosh(moIter->eta()) );
504  h1_matchedObject_Phi->Fill( moIter->phi() );
505  //h1_matchedObject_Z->Fill( moIter->z() );
506 
507  //classes
508 // int eleClass = electron.classification() ;
509 // h_classes->Fill(eleClass) ;
510 // h_matchedEle_eta->Fill(std::abs(electron.eta()));
511 // if (electron.classification() == GsfElectron::GOLDEN) h_matchedEle_eta_golden->Fill(std::abs(electron.eta()));
512 // if (electron.classification() == GsfElectron::SHOWERING) h_matchedEle_eta_shower->Fill(std::abs(electron.eta()));
513 // //if (electron.classification() == GsfElectron::BIGBREM) h_matchedEle_eta_bbrem->Fill(std::abs(electron.eta()));
514 // //if (electron.classification() == GsfElectron::OLDNARROW) h_matchedEle_eta_narrow->Fill(std::abs(electron.eta()));
515  }
516 
517 //bool ElectronTagProbeAnalyzer::trigger( const edm::Event & e )
518 // {
519 // // retreive TriggerResults from the event
520 // edm::Handle<edm::TriggerResults> triggerResults ;
521 // e.getByLabel(triggerResults_,triggerResults) ;
522 //
523 // bool accept = false ;
524 //
525 // if (triggerResults.isValid())
526 // {
527 // //std::cout << "TriggerResults found, number of HLT paths: " << triggerResults->size() << std::endl;
528 // // get trigger names
529 // const edm::TriggerNames & triggerNames = e.triggerNames(*triggerResults);
535 //
536 // unsigned int n = HLTPathsByName_.size() ;
537 // for (unsigned int i=0; i!=n; i++)
538 // {
539 // HLTPathsByIndex_[i]=triggerNames_.triggerIndex(HLTPathsByName_[i]) ;
540 // }
541 //
542 // // empty input vectors (n==0) means any trigger paths
543 // if (n==0)
544 // {
545 // n=triggerResults->size() ;
546 // HLTPathsByName_.resize(n) ;
547 // HLTPathsByIndex_.resize(n) ;
548 // for ( unsigned int i=0 ; i!=n ; i++)
549 // {
550 // HLTPathsByName_[i]=triggerNames_.triggerName(i) ;
551 // HLTPathsByIndex_[i]=i ;
552 // }
553 // }
554 //
570 //
571 // // count number of requested HLT paths which have fired
572 // unsigned int fired=0 ;
573 // for ( unsigned int i=0 ; i!=n ; i++ )
574 // {
575 // if (HLTPathsByIndex_[i]<triggerResults->size())
576 // {
577 // if (triggerResults->accept(HLTPathsByIndex_[i]))
578 // {
579 // fired++ ;
580 // h1_triggers->Fill(float(HLTPathsByIndex_[i]));
581 // //std::cout << "Fired HLT path= " << HLTPathsByName_[i] << std::endl ;
582 // accept = true ;
583 // }
584 // }
585 // }
586 //
587 // }
588 //
589 // return accept ;
590 // }
591 
592 bool ElectronTagProbeAnalyzer::selected( const reco::GsfElectronCollection::const_iterator & gsfIter , double vertexTIP )
593  {
594  if ((Selection_>0)&&generalCut(gsfIter)) return false ;
595  if ((Selection_>=1)&&etCut(gsfIter)) return false ;
596  if ((Selection_>=2)&&isolationCut(gsfIter,vertexTIP)) return false ;
597  if ((Selection_>=3)&&idCut(gsfIter)) return false ;
598  return true ;
599  }
600 
601 bool ElectronTagProbeAnalyzer::generalCut( const reco::GsfElectronCollection::const_iterator & gsfIter)
602  {
603  if (std::abs(gsfIter->eta())>maxAbsEta_) return true ;
604  if (gsfIter->pt()<minPt_) return true ;
605 
606  if (gsfIter->isEB() && isEE_) return true ;
607  if (gsfIter->isEE() && isEB_) return true ;
608  if (gsfIter->isEBEEGap() && isNotEBEEGap_) return true ;
609 
610  if (gsfIter->ecalDrivenSeed() && isTrackerDriven_) return true ;
611  if (gsfIter->trackerDrivenSeed() && isEcalDriven_) return true ;
612 
613  return false ;
614  }
615 
616 bool ElectronTagProbeAnalyzer::etCut( const reco::GsfElectronCollection::const_iterator & gsfIter )
617  {
618  if (gsfIter->superCluster()->energy()/cosh(gsfIter->superCluster()->eta())<minEt_) return true ;
619 
620  return false ;
621  }
622 
623 bool ElectronTagProbeAnalyzer::isolationCut( const reco::GsfElectronCollection::const_iterator & gsfIter, double vertexTIP )
624  {
625  if (gsfIter->isEB() && vertexTIP > tipMaxBarrel_) return true ;
626  if (gsfIter->isEE() && vertexTIP > tipMaxEndcaps_) return true ;
627 
628  if (gsfIter->dr03TkSumPt() > tkIso03Max_) return true ;
629  if (gsfIter->isEB() && gsfIter->dr03HcalDepth1TowerSumEt() > hcalIso03Depth1MaxBarrel_) return true ;
630  if (gsfIter->isEE() && gsfIter->dr03HcalDepth1TowerSumEt() > hcalIso03Depth1MaxEndcaps_) return true ;
631  if (gsfIter->isEE() && gsfIter->dr03HcalDepth2TowerSumEt() > hcalIso03Depth2MaxEndcaps_) return true ;
632  if (gsfIter->isEB() && gsfIter->dr03EcalRecHitSumEt() > ecalIso03MaxBarrel_) return true ;
633  if (gsfIter->isEE() && gsfIter->dr03EcalRecHitSumEt() > ecalIso03MaxEndcaps_) return true ;
634 
635  return false ;
636  }
637 
638 bool ElectronTagProbeAnalyzer::idCut( const reco::GsfElectronCollection::const_iterator & gsfIter )
639  {
640  if (gsfIter->isEB() && gsfIter->eSuperClusterOverP() < eOverPMinBarrel_) return true ;
641  if (gsfIter->isEB() && gsfIter->eSuperClusterOverP() > eOverPMaxBarrel_) return true ;
642  if (gsfIter->isEE() && gsfIter->eSuperClusterOverP() < eOverPMinEndcaps_) return true ;
643  if (gsfIter->isEE() && gsfIter->eSuperClusterOverP() > eOverPMaxEndcaps_) return true ;
644  if (gsfIter->isEB() && std::abs(gsfIter->deltaEtaSuperClusterTrackAtVtx()) < dEtaMinBarrel_) return true ;
645  if (gsfIter->isEB() && std::abs(gsfIter->deltaEtaSuperClusterTrackAtVtx()) > dEtaMaxBarrel_) return true ;
646  if (gsfIter->isEE() && std::abs(gsfIter->deltaEtaSuperClusterTrackAtVtx()) < dEtaMinEndcaps_) return true ;
647  if (gsfIter->isEE() && std::abs(gsfIter->deltaEtaSuperClusterTrackAtVtx()) > dEtaMaxEndcaps_) return true ;
648  if (gsfIter->isEB() && std::abs(gsfIter->deltaPhiSuperClusterTrackAtVtx()) < dPhiMinBarrel_) return true ;
649  if (gsfIter->isEB() && std::abs(gsfIter->deltaPhiSuperClusterTrackAtVtx()) > dPhiMaxBarrel_) return true ;
650  if (gsfIter->isEE() && std::abs(gsfIter->deltaPhiSuperClusterTrackAtVtx()) < dPhiMinEndcaps_) return true ;
651  if (gsfIter->isEE() && std::abs(gsfIter->deltaPhiSuperClusterTrackAtVtx()) > dPhiMaxEndcaps_) return true ;
652  if (gsfIter->isEB() && gsfIter->scSigmaIEtaIEta() < sigIetaIetaMinBarrel_) return true ;
653  if (gsfIter->isEB() && gsfIter->scSigmaIEtaIEta() > sigIetaIetaMaxBarrel_) return true ;
654  if (gsfIter->isEE() && gsfIter->scSigmaIEtaIEta() < sigIetaIetaMinEndcaps_) return true ;
655  if (gsfIter->isEE() && gsfIter->scSigmaIEtaIEta() > sigIetaIetaMaxEndcaps_) return true ;
656  if (gsfIter->isEB() && gsfIter->hadronicOverEm() > hadronicOverEmMaxBarrel_) return true ;
657  if (gsfIter->isEE() && gsfIter->hadronicOverEm() > hadronicOverEmMaxEndcaps_) return true ;
658 
659  return false ;
660  }
RunNumber_t run() const
Definition: EventID.h:42
void fillMatchedHistos(const reco::SuperClusterCollection::const_iterator &moIter, const reco::GsfElectron &electron)
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:44
MonitorElement * h1_dEtaEleCl_propOut_endcaps
int i
Definition: DBlmapReader.cc:9
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")
MonitorElement * h1_dEtaSc_propVtx_endcaps
float scSigmaEtaEta() const
Definition: GsfElectron.h:398
virtual void analyze(const edm::Event &e, const edm::EventSetup &c)
const LorentzVector & p4(P4Kind kind) const
Definition: GsfElectron.cc:204
float eSuperClusterOverP() const
Definition: GsfElectron.h:229
virtual const Point & vertex() const
vertex position
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
float computeInvMass(const reco::GsfElectron &e1, const reco::GsfElectron &e2)
Geom::Theta< T > theta() const
#define abs(x)
Definition: mlp_lapack.h:159
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:59
MonitorElement * h1_dPhiEleCl_propOut_barrel
float fbrem() const
Definition: GsfElectron.h:639
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")
virtual double eta() const
momentum pseudorapidity
bool isEE() const
Definition: GsfElectron.h:331
bool isEB() const
Definition: GsfElectron.h:330
ElectronTagProbeAnalyzer(const edm::ParameterSet &conf)
void Fill(long long x)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:30
float mva() const
Definition: GsfElectron.h:567
float deltaEtaSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:233
int iEvent
Definition: GenABIO.cc:243
float hadronicOverEm() const
Definition: GsfElectron.h:403
MonitorElement * h1_dPhiSc_propVtx_endcaps
T sqrt(T t)
Definition: SSEVec.h:46
virtual SuperClusterRef superCluster() const
reference to a SuperCluster
Definition: GsfElectron.h:168
float deltaPhiSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:236
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
virtual int charge() const
electric charge
float dr03TkSumPt() const
Definition: GsfElectron.h:436
bool isolationCut(const reco::GsfElectronCollection::const_iterator &gsfIter, double vertexTIP)
float eEleClusterOverPout() const
Definition: GsfElectron.h:232
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
float deltaPhiEleClusterTrackAtCalo() const
Definition: GsfElectron.h:238
tuple conf
Definition: dbtoconf.py:185
float deltaEtaEleClusterTrackAtCalo() const
Definition: GsfElectron.h:235
tuple tracks
Definition: testEve_cfg.py:39
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
virtual double pt() const
transverse momentum
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
Classification classification() const
Definition: GsfElectron.h:635
MonitorElement * h1_dEtaEleCl_propOut_barrel
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")
float dr03EcalRecHitSumEt() const
Definition: GsfElectron.h:437
MonitorElement * h1_dPhiEleCl_propOut_endcaps
std::string const & label() const
Definition: InputTag.h:25
edm::EventID id() const
Definition: EventBase.h:56
bool generalCut(const reco::GsfElectronCollection::const_iterator &gsfIter)
bool trackerDrivenSeed() const
Definition: GsfElectron.h:173
float dr03HcalTowerSumEt() const
Definition: GsfElectron.h:440
const Point & position() const
position
Definition: BeamSpot.h:63
bool etCut(const reco::GsfElectronCollection::const_iterator &gsfIter)
virtual double phi() const
momentum azimuthal angle
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:25
bool selected(const reco::GsfElectronCollection::const_iterator &gsfIter, double vertexTIP)
virtual GsfTrackRef gsfTrack() const
reference to a GsfTrack
Definition: GsfElectron.h:169
bool ecalDrivenSeed() const
Definition: GsfElectron.h:172
bool idCut(const reco::GsfElectronCollection::const_iterator &gsfIter)