CMS 3D CMS Logo

ElectronTagProbeAnalyzer.cc
Go to the documentation of this file.
2 
4 
13 
21 
22 #include "CLHEP/Units/GlobalPhysicalConstants.h"
23 #include "TMath.h"
24 
25 #include <iostream>
26 #include <vector>
27 
28 using namespace reco ;
29 
32  {
33  // general, collections
34  Selection_ = conf.getParameter<int>("Selection");
35  electronCollection_ = consumes<GsfElectronCollection>(conf.getParameter<edm::InputTag>("ElectronCollection"));
36  matchingObjectCollection_ = consumes<SuperClusterCollection>(conf.getParameter<edm::InputTag>("MatchingObjectCollection"));
37  trackCollection_ = consumes<TrackCollection>(conf.getParameter<edm::InputTag>("TrackCollection"));
38  vertexCollection_ = consumes<VertexCollection>(conf.getParameter<edm::InputTag>("VertexCollection"));
39  gsftrackCollection_ = consumes<GsfTrackCollection>(conf.getParameter<edm::InputTag>("GsfTrackCollection"));
40  beamSpotTag_ = consumes<BeamSpot>(conf.getParameter<edm::InputTag>("BeamSpot"));
41  readAOD_ = conf.getParameter<bool>("ReadAOD");
42 
43  // tag and probe
44  massLow_ = conf.getParameter< double >("MassLow");
45  massHigh_ = conf.getParameter< double >("MassHigh");
46  TPchecksign_ = conf.getParameter<bool>("TpCheckSign");
47  TAGcheckclass_ = conf.getParameter<bool>("TagCheckClass");
48  PROBEetcut_ = conf.getParameter<bool>("ProbeEtCut");
49  PROBEcheckclass_ = conf.getParameter<bool>("ProbeCheckClass");
50 
51  // electron selection
52  minEt_ = conf.getParameter<double>("MinEt");
53  minPt_ = conf.getParameter<double>("MinPt");
54  maxAbsEta_ = conf.getParameter<double>("MaxAbsEta");
55  isEB_ = conf.getParameter<bool>("SelectEb");
56  isEE_ = conf.getParameter<bool>("SelectEe");
57  isNotEBEEGap_ = conf.getParameter<bool>("SelectNotEbEeGap");
58  isEcalDriven_ = conf.getParameter<bool>("SelectEcalDriven");
59  isTrackerDriven_ = conf.getParameter<bool>("SelectTrackerDriven");
60  eOverPMinBarrel_ = conf.getParameter<double>("MinEopBarrel");
61  eOverPMaxBarrel_ = conf.getParameter<double>("MaxEopBarrel");
62  eOverPMinEndcaps_ = conf.getParameter<double>("MinEopEndcaps");
63  eOverPMaxEndcaps_ = conf.getParameter<double>("MaxEopEndcaps");
64  dEtaMinBarrel_ = conf.getParameter<double>("MinDetaBarrel");
65  dEtaMaxBarrel_ = conf.getParameter<double>("MaxDetaBarrel");
66  dEtaMinEndcaps_ = conf.getParameter<double>("MinDetaEndcaps");
67  dEtaMaxEndcaps_ = conf.getParameter<double>("MaxDetaEndcaps");
68  dPhiMinBarrel_ = conf.getParameter<double>("MinDphiBarrel");
69  dPhiMaxBarrel_ = conf.getParameter<double>("MaxDphiBarrel");
70  dPhiMinEndcaps_ = conf.getParameter<double>("MinDphiEndcaps");
71  dPhiMaxEndcaps_ = conf.getParameter<double>("MaxDphiEndcaps");
72  sigIetaIetaMinBarrel_ = conf.getParameter<double>("MinSigIetaIetaBarrel");
73  sigIetaIetaMaxBarrel_ = conf.getParameter<double>("MaxSigIetaIetaBarrel");
74  sigIetaIetaMinEndcaps_ = conf.getParameter<double>("MinSigIetaIetaEndcaps");
75  sigIetaIetaMaxEndcaps_ = conf.getParameter<double>("MaxSigIetaIetaEndcaps");
76  hadronicOverEmMaxBarrel_ = conf.getParameter<double>("MaxHoeBarrel");
77  hadronicOverEmMaxEndcaps_ = conf.getParameter<double>("MaxHoeEndcaps");
78  mvaMin_ = conf.getParameter<double>("MinMva");
79  tipMaxBarrel_ = conf.getParameter<double>("MaxTipBarrel");
80  tipMaxEndcaps_ = conf.getParameter<double>("MaxTipEndcaps");
81  tkIso03Max_ = conf.getParameter<double>("MaxTkIso03");
82  hcalIso03Depth1MaxBarrel_ = conf.getParameter<double>("MaxHcalIso03Depth1Barrel");
83  hcalIso03Depth1MaxEndcaps_ = conf.getParameter<double>("MaxHcalIso03Depth1Endcaps");
84  hcalIso03Depth2MaxEndcaps_ = conf.getParameter<double>("MaxHcalIso03Depth2Endcaps");
85  ecalIso03MaxBarrel_ = conf.getParameter<double>("MaxEcalIso03Barrel");
86  ecalIso03MaxEndcaps_ = conf.getParameter<double>("MaxEcalIso03Endcaps");
87 
88  // for trigger
89  triggerResults_ = conf.getParameter<edm::InputTag>("TriggerResults");
90 // HLTPathsByName_= conf.getParameter<std::vector<std::string > >("HltPaths");
91 // HLTPathsByIndex_.resize(HLTPathsByName_.size());
92 
93  // histos limits and binning
94  nbineta=conf.getParameter<int>("NbinEta");
95  nbineta2D=conf.getParameter<int>("NbinEta2D");
96  etamin=conf.getParameter<double>("EtaMin");
97  etamax=conf.getParameter<double>("EtaMax");
98  //
99  nbinphi=conf.getParameter<int>("NbinPhi");
100  nbinphi2D=conf.getParameter<int>("NbinPhi2D");
101  phimin=conf.getParameter<double>("PhiMin");
102  phimax=conf.getParameter<double>("PhiMax");
103  //
104  nbinpt=conf.getParameter<int>("NbinPt");
105  nbinpteff=conf.getParameter<int>("NbinPtEff");
106  nbinpt2D=conf.getParameter<int>("NbinPt2D");
107  ptmax=conf.getParameter<double>("PtMax");
108  //
109  nbinp=conf.getParameter<int>("NbinP");
110  nbinp2D=conf.getParameter<int>("NbinP2D");
111  pmax=conf.getParameter<double>("PMax");
112  //
113  nbineop=conf.getParameter<int>("NbinEop");
114  nbineop2D=conf.getParameter<int>("NbinEop2D");
115  eopmax=conf.getParameter<double>("EopMax");
116  eopmaxsht=conf.getParameter<double>("EopMaxSht");
117  //
118  nbindeta=conf.getParameter<int>("NbinDeta");
119  detamin=conf.getParameter<double>("DetaMin");
120  detamax=conf.getParameter<double>("DetaMax");
121  //
122  nbindphi=conf.getParameter<int>("NbinDphi");
123  dphimin=conf.getParameter<double>("DphiMin");
124  dphimax=conf.getParameter<double>("DphiMax");
125  //
126  nbindetamatch=conf.getParameter<int>("NbinDetaMatch");
127  nbindetamatch2D=conf.getParameter<int>("NbinDetaMatch2D");
128  detamatchmin=conf.getParameter<double>("DetaMatchMin");
129  detamatchmax=conf.getParameter<double>("DetaMatchMax");
130  //
131  nbindphimatch=conf.getParameter<int>("NbinDphiMatch");
132  nbindphimatch2D=conf.getParameter<int>("NbinDphiMatch2D");
133  dphimatchmin=conf.getParameter<double>("DphiMatchMin");
134  dphimatchmax=conf.getParameter<double>("DphiMatchMax");
135  //
136  nbinfhits=conf.getParameter<int>("NbinFhits");
137  fhitsmax=conf.getParameter<double>("FhitsMax");
138  //
139  nbinlhits=conf.getParameter<int>("NbinLhits");
140  lhitsmax=conf.getParameter<double>("LhitsMax");
141  //
142  nbinxyz=conf.getParameter<int>("NbinXyz");
143  nbinxyz2D=conf.getParameter<int>("NbinXyz2D");
144  //
145  nbinpoptrue= conf.getParameter<int>("NbinPopTrue");
146  poptruemin=conf.getParameter<double>("PopTrueMin");
147  poptruemax=conf.getParameter<double>("PopTrueMax");
148  //
149  nbinmee= conf.getParameter<int>("NbinMee");
150  meemin=conf.getParameter<double>("MeeMin");
151  meemax=conf.getParameter<double>("MeeMax");
152  //
153  nbinhoe= conf.getParameter<int>("NbinHoe");
154  hoemin=conf.getParameter<double>("HoeMin");
155  hoemax=conf.getParameter<double>("HoeMax");
156  }
157 
159  {}
160 
162  {
164  nEvents_ = 0 ;
165  //nAfterTrigger_ = 0 ;
166 
167  // basic quantities
168  h1_vertexPt_barrel = bookH1(iBooker, "vertexPt_barrel","ele transverse momentum in barrel",nbinpt,0.,ptmax,"p_{T vertex} (GeV/c)");
169  h1_vertexPt_endcaps = bookH1(iBooker, "vertexPt_endcaps","ele transverse momentum in endcaps",nbinpt,0.,ptmax,"p_{T vertex} (GeV/c)");
170  h1_vertexEta = bookH1(iBooker, "vertexEta","ele momentum #eta",nbineta,etamin,etamax,"#eta");
171  h2_vertexEtaVsPhi = bookH2(iBooker, "vertexEtaVsPhi","ele momentum #eta vs #phi",nbineta2D,etamin,etamax,nbinphi2D,phimin,phimax,"#eta","#phi (rad)");
172  h2_vertexXvsY = bookH2(iBooker, "vertexXvsY","ele vertex x vs y",nbinxyz2D,-0.1,0.1,nbinxyz2D,-0.1,0.1,"x (cm)","y (cm)" );
173  h1_vertexZ = bookH1(iBooker, "vertexZ","ele vertex z",nbinxyz,-25, 25,"z (cm)" );
174 
175  // super-clusters
176 // h1_sclPhi = bookH1(iBooker, "sclPhi","ele supercluster phi",nbinphi,phimin,phimax);
177  h1_sclEt = bookH1(iBooker, "sclEt","ele supercluster transverse energy",nbinpt,0.,ptmax);
178 
179  // electron track
180  h1_chi2 = bookH1(iBooker, "chi2","ele track #chi^{2}",100,0.,15.,"#Chi^{2}");
181  h1_foundHits = bookH1(iBooker, "foundHits","ele track # found hits",nbinfhits,0.,fhitsmax,"N_{hits}");
182  h1_lostHits = bookH1(iBooker, "lostHits","ele track # lost hits",5,0.,5.,"N_{lost hits}");
183 
184  // electron matching and ID
185  h1_Eop_barrel = bookH1(iBooker, "Eop_barrel","ele E/P_{vertex} in barrel",nbineop,0.,eopmax,"E/P_{vertex}");
186  h1_Eop_endcaps = bookH1(iBooker, "Eop_endcaps","ele E/P_{vertex} in endcaps",nbineop,0.,eopmax,"E/P_{vertex}");
187  h1_EeleOPout_barrel = bookH1(iBooker, "EeleOPout_barrel","ele E_{ele}/P_{out} in barrel",nbineop,0.,eopmax,"E_{ele}/P_{out}");
188  h1_EeleOPout_endcaps = bookH1(iBooker, "EeleOPout_endcaps","ele E_{ele}/P_{out} in endcaps",nbineop,0.,eopmax,"E_{ele}/P_{out}");
189  h1_dEtaSc_propVtx_barrel = bookH1(iBooker, "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(iBooker, "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(iBooker, "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(iBooker, "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(iBooker, "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(iBooker, "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(iBooker, "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(iBooker, "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(iBooker, "Hoe_barrel","ele hadronic energy / em energy, in barrel", nbinhoe, hoemin, hoemax,"H/E","Events","ELE_LOGY E1 P") ;
198  h1_Hoe_endcaps = bookH1(iBooker, "Hoe_endcaps","ele hadronic energy / em energy, in endcaps", nbinhoe, hoemin, hoemax,"H/E","Events","ELE_LOGY E1 P") ;
199  h1_sclSigEtaEta_barrel = bookH1(iBooker, "sclSigEtaEta_barrel","ele supercluster sigma eta eta in barrel",100,0.,0.05);
200  h1_sclSigEtaEta_endcaps = bookH1(iBooker, "sclSigEtaEta_endcaps","ele supercluster sigma eta eta in endcaps",100,0.,0.05);
201 
202  // fbrem
203  h1_fbrem = bookH1(iBooker, "fbrem","ele brem fraction",100,0.,1.,"P_{in} - P_{out} / P_{in}") ;
204  h1_classes = bookH1(iBooker, "classes","ele electron classes",10,0.0,10.);
205 
206  // pflow
207  h1_mva = bookH1(iBooker, "mva","ele identification mva",100,-1.,1.);
208  h1_provenance = bookH1(iBooker, "provenance","ele provenance",5,-2.,3.);
209 
210  // isolation
211  h1_tkSumPt_dr03 = bookH1(iBooker, "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(iBooker, "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(iBooker, "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(iBooker, "mesc","Tag ele Probe SC invariant mass", nbinmee, meemin, meemax,"m_{eSC} (GeV/c^{2})");
218  h1_mee_os = bookH1(iBooker, "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  Labels l;
229  labelsForToken(matchingObjectCollection_,l);
230  if (std::string::npos != std::string(l.module).find("SuperCluster",0))
231  { matchingObjectType = "SC" ; }
232  if (matchingObjectType=="")
233  { edm::LogError("ElectronMcFakeValidator::beginJob")<<"Unknown matching object type !" ; }
234  else
235  { edm::LogInfo("ElectronMcFakeValidator::beginJob")<<"Matching object type: "<<matchingObjectType ; }
236 
237  // matching object distributions
238  h1_matchingObject_Eta = bookH1withSumw2(iBooker, "matchingObject_Eta",matchingObjectType+" #eta",nbineta,etamin,etamax,"#eta_{SC}");
239  h1_matchingObject_Pt = bookH1withSumw2(iBooker, "matchingObject_Pt",matchingObjectType+" pt",nbinpteff,5.,ptmax);
240  h1_matchingObject_Phi = bookH1withSumw2(iBooker, "matchingObject_Phi",matchingObjectType+" phi",nbinphi,phimin,phimax);
241  //h1_matchingObject_Z = bookH1withSumw2(iBooker, "matchingObject_Z",matchingObjectType+" z",nbinxyz,-25,25);
242 
243  h1_matchedObject_Eta = bookH1withSumw2(iBooker, "matchedObject_Eta","Efficiency vs matching SC #eta",nbineta,etamin,etamax);
244  h1_matchedObject_Pt = bookH1withSumw2(iBooker, "matchedObject_Pt","Efficiency vs matching SC E_{T}",nbinpteff,5.,ptmax);
245  h1_matchedObject_Phi = bookH1withSumw2(iBooker, "matchedObject_Phi","Efficiency vs matching SC phi",nbinphi,phimin,phimax);
246  //h1_matchedObject_Z = bookH1withSumw2(iBooker, "matchedObject_Z","Efficiency vs matching SC z",nbinxyz,-25,25);
247 
248  }
249 
251  {
252  nEvents_++ ;
253 
255  iEvent.getByToken(electronCollection_,gsfElectrons) ;
257  iEvent.getByToken(matchingObjectCollection_,recoClusters) ;
259  iEvent.getByToken(trackCollection_,tracks);
261  iEvent.getByToken(gsftrackCollection_,gsfTracks);
263  iEvent.getByToken(vertexCollection_,vertices);
264  edm::Handle<reco::BeamSpot> recoBeamSpotHandle ;
265  iEvent.getByToken(beamSpotTag_,recoBeamSpotHandle) ;
266  const BeamSpot bs = *recoBeamSpotHandle ;
267 
268  edm::EventNumber_t ievt = iEvent.id().event();
269  edm::RunNumber_t irun = iEvent.id().run();
271 
272  edm::LogInfo("ElectronMcSignalValidator::analyze")
273  <<"Treating "<<gsfElectrons.product()->size()<<" electrons"
274  <<" from event "<<ievt<<" in run "<<irun<<" and lumiblock "<<ils ;
275  //h1_num_->Fill((*gsfElectrons).size()) ;
276 
277  std::vector<std::pair<double,double> > TTCheck;
278  std::vector<std::pair<double,double> > TTscCheck;
279 
280  // selected rec electrons
281  reco::GsfElectronCollection::const_iterator gsfIter ;
282  for
283  ( gsfIter=gsfElectrons->begin() ;
284  gsfIter!=gsfElectrons->end();
285  gsfIter++ )
286  {
287  // vertex TIP
288  double vertexTIP =
289  (gsfIter->vertex().x()-bs.position().x()) * (gsfIter->vertex().x()-bs.position().x()) +
290  (gsfIter->vertex().y()-bs.position().y()) * (gsfIter->vertex().y()-bs.position().y()) ;
291  vertexTIP = sqrt(vertexTIP) ;
292 
293  // select electrons
294  if (!selected(gsfIter,vertexTIP)) continue ;
295 
296  reco::SuperClusterRef sclTagRef = gsfIter->superCluster() ;
297  reco::SuperClusterCollection::const_iterator moIter ;
298  for
299  ( moIter=recoClusters->begin() ;
300  moIter!=recoClusters->end() ;
301  moIter++ )
302  {
303  if (moIter->eta()==sclTagRef->eta()) continue ;
304 
305  /*
306  if
307  ( moIter->energy()/cosh(moIter->eta())>maxPtMatchingObject_ ||
308  std::abs(moIter->eta())> maxAbsEtaMatchingObject_ )
309  { continue ; }
310  */
311 
312  // Additional cuts on Tag
313 
314  // Additional cuts on Probe
315  if(PROBEetcut_ && (moIter->energy()/cosh(moIter->eta())<minEt_)) continue ;
316 
317  float SCenergy = moIter->energy();
318  math::XYZPoint caloposition = moIter->position();
319  float theta = caloposition.Theta();
320  math::XYZVector momentum;
321  float SCmomentumX = SCenergy*sin(theta)*cos(moIter->phi());
322  float SCmomentumY = SCenergy*sin(theta)*sin(moIter->phi());
323  float SCmomentumZ = SCenergy*cos(theta);
324  const reco::Particle::LorentzVector pSCprobecandidate(SCmomentumX,SCmomentumY,SCmomentumZ,SCenergy);
325 
326  math::XYZTLorentzVector p12 = (*gsfIter).p4()+ pSCprobecandidate;
327  float mee2 = p12.Dot(p12);
328  float invMass = mee2 > 0. ? sqrt(mee2) : 0.;
329 
330  if( invMass < massLow_ || invMass > massHigh_ ) continue ;
331 
332 
333  h1_matchingObject_Eta->Fill( moIter->eta() );
334  h1_matchingObject_Pt->Fill( moIter->energy()/cosh(moIter->eta()) );
335  h1_matchingObject_Phi->Fill( moIter->phi() );
336  //h1_matchingObject_Z->Fill( moIter->z() );
337 
338  reco::GsfElectron bestGsfElectron;
339  reco::SuperClusterRef sclProbeRef;
340  bool okGsfFound = false;
341  //double gsfOkRatio = 999999.;
342  reco::GsfElectronCollection::const_iterator gsfIter2 ;
343 
344  for
345  ( gsfIter2=gsfElectrons->begin();
346  gsfIter2!=gsfElectrons->end() ;
347  gsfIter2++ )
348  {
349  // matching with ref
350  sclProbeRef = gsfIter2->superCluster();
351 
352  if (sclProbeRef->eta() == moIter->eta())
353  {
354  //std::cout << "les deux ref SC sont egales : " << std::endl;
355  bestGsfElectron=*gsfIter2;
356 
357  // opposite sign checking
358  bool opsign = (((gsfIter->charge())*(bestGsfElectron.charge()))<0.) ;
359  if ( TPchecksign_ && !opsign )
360  { okGsfFound = false ;
361  h1_mee->Fill(invMass) ;
362  break ; }
363  else
364  { okGsfFound = true ; }
365  } //fi on gsfEleSC.eta == probeSC.eta
366 
367 // // matching with cone
368 // double dphi = gsfIter2->phi()-moIter->phi();
369 // if (std::abs(dphi)>CLHEP::pi)
370 // dphi = dphi < 0? (CLHEP::twopi) + dphi : dphi - CLHEP::twopi;
371 // double deltaR = sqrt(pow((moIter->eta()-gsfIter2->eta()),2) + pow(dphi,2));
372 // if ( deltaR < deltaR_ )
373 // {
374 // double tmpGsfRatio = gsfIter2->p()/moIter->energy();
375 // if ( std::abs(tmpGsfRatio-1) < std::abs(gsfOkRatio-1))
376 // {
377 // gsfOkRatio = tmpGsfRatio;
378 // bestGsfElectron=*gsfIter2;
379 // okGsfFound = true;
380 // }
381 // } // fi on deltaR
382 
383  }// end of loop on gsfEle to find the best one which matches with probe SC
384 
385  if (okGsfFound)
386  {
387  // fill matched histos for eff
388  fillMatchedHistos(moIter,bestGsfElectron) ;
389 
390  // basic quantities
391  if (bestGsfElectron.isEB()) h1_vertexPt_barrel->Fill( bestGsfElectron.pt() );
392  if (bestGsfElectron.isEE()) h1_vertexPt_endcaps->Fill( bestGsfElectron.pt() );
393  h1_vertexEta->Fill( bestGsfElectron.eta() );
394  h2_vertexEtaVsPhi->Fill( bestGsfElectron.eta(), bestGsfElectron.phi() );
395  h2_vertexXvsY->Fill( bestGsfElectron.vertex().x(), bestGsfElectron.vertex().y() );
396  h1_vertexZ->Fill( bestGsfElectron.vertex().z() );
397 
398  // supercluster related distributions
399  reco::SuperClusterRef sclRef = bestGsfElectron.superCluster() ;
400  double R=TMath::Sqrt(sclRef->x()*sclRef->x() + sclRef->y()*sclRef->y() +sclRef->z()*sclRef->z());
401  double Rt=TMath::Sqrt(sclRef->x()*sclRef->x() + sclRef->y()*sclRef->y());
402  h1_sclEt->Fill(sclRef->energy()*(Rt/R));
403 
404  if (!readAOD_)
405  { // track extra does not exist in AOD
406  h1_foundHits->Fill( bestGsfElectron.gsfTrack()->numberOfValidHits() );
407  h1_lostHits->Fill( bestGsfElectron.gsfTrack()->numberOfLostHits() );
408  h1_chi2->Fill( bestGsfElectron.gsfTrack()->normalizedChi2() );
409  }
410 
411  // match distributions
412  if (bestGsfElectron.isEB())
413  {
414  h1_Eop_barrel->Fill( bestGsfElectron.eSuperClusterOverP() );
415  h1_EeleOPout_barrel->Fill( bestGsfElectron.eEleClusterOverPout() );
420  h1_Hoe_barrel->Fill(bestGsfElectron.hadronicOverEm());
421  h1_sclSigEtaEta_barrel->Fill( bestGsfElectron.scSigmaEtaEta() );
422  }
423  if (bestGsfElectron.isEE())
424  {
425  h1_Eop_endcaps->Fill( bestGsfElectron.eSuperClusterOverP() );
426  h1_EeleOPout_endcaps->Fill( bestGsfElectron.eEleClusterOverPout() );
431  h1_Hoe_endcaps->Fill(bestGsfElectron.hadronicOverEm());
432  h1_sclSigEtaEta_endcaps->Fill( bestGsfElectron.scSigmaEtaEta() );
433  }
434 
435  // fbrem
436  h1_fbrem->Fill(bestGsfElectron.fbrem()) ;
437  int eleClass = bestGsfElectron.classification() ;
438  if (bestGsfElectron.isEE()) eleClass+=5;
439  h1_classes->Fill(eleClass);
440 
441  // pflow
442  h1_mva->Fill(bestGsfElectron.mva_e_pi()) ;
443  if (bestGsfElectron.ecalDrivenSeed()) h1_provenance->Fill(1.) ;
444  if (bestGsfElectron.trackerDrivenSeed()) h1_provenance->Fill(-1.) ;
445  if (bestGsfElectron.trackerDrivenSeed()||bestGsfElectron.ecalDrivenSeed()) h1_provenance->Fill(0.);
446  if (bestGsfElectron.trackerDrivenSeed()&&!bestGsfElectron.ecalDrivenSeed()) h1_provenance->Fill(-2.);
447  if (!bestGsfElectron.trackerDrivenSeed()&&bestGsfElectron.ecalDrivenSeed()) h1_provenance->Fill(2.);
448 
449  // isolation
450  h1_tkSumPt_dr03->Fill(bestGsfElectron.dr03TkSumPt());
452  h1_hcalTowerSumEt_dr03->Fill(bestGsfElectron.dr03HcalTowerSumEt());
453 
454  // inv Mass with opposite sign
455  bool invMassTTAlreadyFilled = false;
456  if(!TTCheck.empty()){
457  int TTCheckDim = TTCheck.size();
458  for(int i=0 ;i<TTCheckDim;i++){
459  if((bestGsfElectron.eta() == TTCheck.at(i).first) && (gsfIter->eta() == TTCheck.at(i).second)){
460  invMassTTAlreadyFilled=true;
461  }
462  }
463  }
464 
465 
466  if (!invMassTTAlreadyFilled && (((gsfIter->charge())*(bestGsfElectron.charge()))<0.))
467  {
468  h1_mee->Fill(invMass);
469  math::XYZTLorentzVector p12bis = (*gsfIter).p4()+ bestGsfElectron.p4() ;
470  float mee2bis = p12.Dot(p12bis);
471  float invMassEE = mee2bis > 0. ? sqrt(mee2bis) : 0.;
472  if(invMassEE >= massLow_ && invMassEE <= massHigh_){h1_mee_os->Fill(invMassEE);}
473  std::pair<double,double> p(gsfIter->eta(),bestGsfElectron.eta());
474  TTCheck.push_back(p);
475  }
476 
477  }// fi on OkGsfFound
478  else{
479  h1_mee->Fill(invMass) ;
480  }
481 
482  } // end of loop on SC to find probe SC
483 
484  }// end of loop on Tag gsfEle
485 
486  }
487 
489  ( const reco::GsfElectron & e1,
490  const reco::GsfElectron & e2 )
491  {
492  math::XYZTLorentzVector p12 = e1.p4()+e2.p4() ;
493  float mee2 = p12.Dot(p12) ;
494  float invMass = mee2 > 0. ? sqrt(mee2) : 0.;
495  return invMass ;
496  }
497 
499  ( const reco::SuperClusterCollection::const_iterator & moIter,
500  const reco::GsfElectron & electron )
501  {
502  // generated distributions for matched electrons
503  h1_matchedObject_Eta->Fill( moIter->eta() );
504 // h1_matchedObject_AbsEta->Fill( std::abs(moIter->eta()) );
505  h1_matchedObject_Pt->Fill( moIter->energy()/cosh(moIter->eta()) );
506  h1_matchedObject_Phi->Fill( moIter->phi() );
507  //h1_matchedObject_Z->Fill( moIter->z() );
508 
509  //classes
510 // int eleClass = electron.classification() ;
511 // h_classes->Fill(eleClass) ;
512 // h_matchedEle_eta->Fill(std::abs(electron.eta()));
513 // if (electron.classification() == GsfElectron::GOLDEN) h_matchedEle_eta_golden->Fill(std::abs(electron.eta()));
514 // if (electron.classification() == GsfElectron::SHOWERING) h_matchedEle_eta_shower->Fill(std::abs(electron.eta()));
515 // //if (electron.classification() == GsfElectron::BIGBREM) h_matchedEle_eta_bbrem->Fill(std::abs(electron.eta()));
516 // //if (electron.classification() == GsfElectron::OLDNARROW) h_matchedEle_eta_narrow->Fill(std::abs(electron.eta()));
517  }
518 
519 bool ElectronTagProbeAnalyzer::selected( const reco::GsfElectronCollection::const_iterator & gsfIter , double vertexTIP )
520  {
521  if ((Selection_>0)&&generalCut(gsfIter)) return false ;
522  if ((Selection_>=1)&&etCut(gsfIter)) return false ;
523  if ((Selection_>=2)&&isolationCut(gsfIter,vertexTIP)) return false ;
524  if ((Selection_>=3)&&idCut(gsfIter)) return false ;
525  return true ;
526  }
527 
528 bool ElectronTagProbeAnalyzer::generalCut( const reco::GsfElectronCollection::const_iterator & gsfIter)
529  {
530  if (std::abs(gsfIter->eta())>maxAbsEta_) return true ;
531  if (gsfIter->pt()<minPt_) return true ;
532 
533  if (gsfIter->isEB() && isEE_) return true ;
534  if (gsfIter->isEE() && isEB_) return true ;
535  if (gsfIter->isEBEEGap() && isNotEBEEGap_) return true ;
536 
537  if (gsfIter->ecalDrivenSeed() && isTrackerDriven_) return true ;
538  if (gsfIter->trackerDrivenSeed() && isEcalDriven_) return true ;
539 
540  return false ;
541  }
542 
543 bool ElectronTagProbeAnalyzer::etCut( const reco::GsfElectronCollection::const_iterator & gsfIter )
544  {
545  if (gsfIter->superCluster()->energy()/cosh(gsfIter->superCluster()->eta())<minEt_) return true ;
546 
547  return false ;
548  }
549 
550 bool ElectronTagProbeAnalyzer::isolationCut( const reco::GsfElectronCollection::const_iterator & gsfIter, double vertexTIP )
551  {
552  if (gsfIter->isEB() && vertexTIP > tipMaxBarrel_) return true ;
553  if (gsfIter->isEE() && vertexTIP > tipMaxEndcaps_) return true ;
554 
555  if (gsfIter->dr03TkSumPt() > tkIso03Max_) return true ;
556  if (gsfIter->isEB() && gsfIter->dr03HcalDepth1TowerSumEt() > hcalIso03Depth1MaxBarrel_) return true ;
557  if (gsfIter->isEE() && gsfIter->dr03HcalDepth1TowerSumEt() > hcalIso03Depth1MaxEndcaps_) return true ;
558  if (gsfIter->isEE() && gsfIter->dr03HcalDepth2TowerSumEt() > hcalIso03Depth2MaxEndcaps_) return true ;
559  if (gsfIter->isEB() && gsfIter->dr03EcalRecHitSumEt() > ecalIso03MaxBarrel_) return true ;
560  if (gsfIter->isEE() && gsfIter->dr03EcalRecHitSumEt() > ecalIso03MaxEndcaps_) return true ;
561 
562  return false ;
563  }
564 
565 bool ElectronTagProbeAnalyzer::idCut( const reco::GsfElectronCollection::const_iterator & gsfIter )
566  {
567  if (gsfIter->isEB() && gsfIter->eSuperClusterOverP() < eOverPMinBarrel_) return true ;
568  if (gsfIter->isEB() && gsfIter->eSuperClusterOverP() > eOverPMaxBarrel_) return true ;
569  if (gsfIter->isEE() && gsfIter->eSuperClusterOverP() < eOverPMinEndcaps_) return true ;
570  if (gsfIter->isEE() && gsfIter->eSuperClusterOverP() > eOverPMaxEndcaps_) return true ;
571  if (gsfIter->isEB() && std::abs(gsfIter->deltaEtaSuperClusterTrackAtVtx()) < dEtaMinBarrel_) return true ;
572  if (gsfIter->isEB() && std::abs(gsfIter->deltaEtaSuperClusterTrackAtVtx()) > dEtaMaxBarrel_) return true ;
573  if (gsfIter->isEE() && std::abs(gsfIter->deltaEtaSuperClusterTrackAtVtx()) < dEtaMinEndcaps_) return true ;
574  if (gsfIter->isEE() && std::abs(gsfIter->deltaEtaSuperClusterTrackAtVtx()) > dEtaMaxEndcaps_) return true ;
575  if (gsfIter->isEB() && std::abs(gsfIter->deltaPhiSuperClusterTrackAtVtx()) < dPhiMinBarrel_) return true ;
576  if (gsfIter->isEB() && std::abs(gsfIter->deltaPhiSuperClusterTrackAtVtx()) > dPhiMaxBarrel_) return true ;
577  if (gsfIter->isEE() && std::abs(gsfIter->deltaPhiSuperClusterTrackAtVtx()) < dPhiMinEndcaps_) return true ;
578  if (gsfIter->isEE() && std::abs(gsfIter->deltaPhiSuperClusterTrackAtVtx()) > dPhiMaxEndcaps_) return true ;
579  if (gsfIter->isEB() && gsfIter->scSigmaIEtaIEta() < sigIetaIetaMinBarrel_) return true ;
580  if (gsfIter->isEB() && gsfIter->scSigmaIEtaIEta() > sigIetaIetaMaxBarrel_) return true ;
581  if (gsfIter->isEE() && gsfIter->scSigmaIEtaIEta() < sigIetaIetaMinEndcaps_) return true ;
582  if (gsfIter->isEE() && gsfIter->scSigmaIEtaIEta() > sigIetaIetaMaxEndcaps_) return true ;
583  if (gsfIter->isEB() && gsfIter->hadronicOverEm() > hadronicOverEmMaxBarrel_) return true ;
584  if (gsfIter->isEE() && gsfIter->hadronicOverEm() > hadronicOverEmMaxEndcaps_) return true ;
585 
586  return false ;
587  }
RunNumber_t run() const
Definition: EventID.h:39
void fillMatchedHistos(const reco::SuperClusterCollection::const_iterator &moIter, const reco::GsfElectron &electron)
T getParameter(std::string const &) const
GsfTrackRef gsfTrack() const override
reference to a GsfTrack
Definition: GsfElectron.h:186
EventNumber_t event() const
Definition: EventID.h:41
MonitorElement * h1_dEtaEleCl_propOut_endcaps
MonitorElement * h1_dEtaSc_propVtx_endcaps
double eta() const final
momentum pseudorapidity
float scSigmaEtaEta() const
Definition: GsfElectron.h:490
const LorentzVector & p4(P4Kind kind) const
Definition: GsfElectron.cc:228
float eSuperClusterOverP() const
Definition: GsfElectron.h:249
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
float computeInvMass(const reco::GsfElectron &e1, const reco::GsfElectron &e2)
MonitorElement * bookH1withSumw2(DQMStore::IBooker &, 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")
Geom::Theta< T > theta() const
edm::EDGetTokenT< reco::GsfElectronCollection > electronCollection_
unsigned long long EventNumber_t
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:61
edm::EDGetTokenT< reco::VertexCollection > vertexCollection_
double pt() const final
transverse momentum
MonitorElement * h1_dPhiEleCl_propOut_barrel
int charge() const final
electric charge
Definition: LeafCandidate.h:91
MonitorElement * bookH2(DQMStore::IBooker &, 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 fbrem() const
Definition: GsfElectron.h:772
unsigned int LuminosityBlockNumber_t
bool isEE() const
Definition: GsfElectron.h:357
bool isEB() const
Definition: GsfElectron.h:356
ElectronTagProbeAnalyzer(const edm::ParameterSet &conf)
void Fill(long long x)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
float deltaEtaSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:253
int iEvent
Definition: GenABIO.cc:224
float hadronicOverEm() const
Definition: GsfElectron.h:495
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
MonitorElement * h1_dPhiSc_propVtx_endcaps
edm::EDGetTokenT< reco::SuperClusterCollection > matchingObjectCollection_
T sqrt(T t)
Definition: SSEVec.h:18
float deltaPhiSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:256
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
const Point & vertex() const override
vertex position (overwritten by PF...)
float dr03TkSumPt() const
Definition: GsfElectron.h:552
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool isolationCut(const reco::GsfElectronCollection::const_iterator &gsfIter, double vertexTIP)
edm::EDGetTokenT< reco::BeamSpot > beamSpotTag_
float eEleClusterOverPout() const
Definition: GsfElectron.h:252
float deltaPhiEleClusterTrackAtCalo() const
Definition: GsfElectron.h:258
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
edm::EDGetTokenT< reco::TrackCollection > trackCollection_
void analyze(const edm::Event &e, const edm::EventSetup &c) override
T const * product() const
Definition: Handle.h:74
float deltaEtaEleClusterTrackAtCalo() const
Definition: GsfElectron.h:255
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
Classification classification() const
Definition: GsfElectron.h:768
MonitorElement * h1_dEtaEleCl_propOut_barrel
float dr03EcalRecHitSumEt() const
Definition: GsfElectron.h:554
MonitorElement * h1_dPhiEleCl_propOut_endcaps
float mva_e_pi() const
Definition: GsfElectron.h:702
edm::EDGetTokenT< reco::GsfTrackCollection > gsftrackCollection_
edm::EventID id() const
Definition: EventBase.h:59
fixed size matrix
SuperClusterRef superCluster() const override
reference to a SuperCluster
Definition: GsfElectron.h:185
bool generalCut(const reco::GsfElectronCollection::const_iterator &gsfIter)
bool trackerDrivenSeed() const
Definition: GsfElectron.h:189
float dr03HcalTowerSumEt() const
Definition: GsfElectron.h:557
const Point & position() const
position
Definition: BeamSpot.h:62
MonitorElement * bookH1(DQMStore::IBooker &, 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")
unsigned int RunNumber_t
bool etCut(const reco::GsfElectronCollection::const_iterator &gsfIter)
double phi() const final
momentum azimuthal angle
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:21
bool selected(const reco::GsfElectronCollection::const_iterator &gsfIter, double vertexTIP)
Definition: Run.h:45
bool ecalDrivenSeed() const
Definition: GsfElectron.h:188
bool idCut(const reco::GsfElectronCollection::const_iterator &gsfIter)