CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFElecTkProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: PFTracking
4 // Class: PFElecTkProducer
5 //
6 // Original Author: Michele Pioppi
7 // Created: Tue Jan 23 15:26:39 CET 2007
8 
9 
10 
11 // system include files
12 #include <memory>
13 
14 // user include files
35 
36 #include "TMath.h"
37 using namespace std;
38 using namespace edm;
39 using namespace reco;
41  conf_(iConfig),
42  pfTransformer_(0),
43  convBremFinder_(0)
44 {
45 
46 
47  gsfTrackLabel_ = consumes<reco::GsfTrackCollection>(iConfig.getParameter<InputTag>
48  ("GsfTrackModuleLabel"));
49 
50  pfTrackLabel_ = consumes<reco::PFRecTrackCollection>(iConfig.getParameter<InputTag>
51  ("PFRecTrackLabel"));
52 
53  primVtxLabel_ = consumes<reco::VertexCollection>(iConfig.getParameter<InputTag>
54  ("PrimaryVertexLabel"));
55 
56  pfEcalClusters_ = consumes<reco::PFClusterCollection>(iConfig.getParameter<InputTag>
57  ("PFEcalClusters"));
58 
59  pfNuclear_ = consumes<reco::PFDisplacedTrackerVertexCollection>(iConfig.getParameter<InputTag>
60  ("PFNuclear"));
61 
62  pfConv_ = consumes<reco::PFConversionCollection>(iConfig.getParameter<InputTag>
63  ("PFConversions"));
64 
65  pfV0_ = consumes<reco::PFV0Collection>(iConfig.getParameter<InputTag>
66  ("PFV0"));
67 
68  useNuclear_ = iConfig.getParameter<bool>("useNuclear");
69  useConversions_ = iConfig.getParameter<bool>("useConversions");
70  useV0_ = iConfig.getParameter<bool>("useV0");
71  debugGsfCleaning_ = iConfig.getParameter<bool>("debugGsfCleaning");
72 
73  produces<GsfPFRecTrackCollection>();
74  produces<GsfPFRecTrackCollection>( "Secondary" ).setBranchAlias( "secondary" );
75 
76 
77  trajinev_ = iConfig.getParameter<bool>("TrajInEvents");
78  modemomentum_ = iConfig.getParameter<bool>("ModeMomentum");
79  applySel_ = iConfig.getParameter<bool>("applyEGSelection");
80  applyGsfClean_ = iConfig.getParameter<bool>("applyGsfTrackCleaning");
81  applyAngularGsfClean_ = iConfig.getParameter<bool>("applyAlsoGsfAngularCleaning");
82  detaCutGsfClean_ = iConfig.getParameter<double>("maxDEtaGsfAngularCleaning");
83  dphiCutGsfClean_ = iConfig.getParameter<double>("maxDPhiBremTangGsfAngularCleaning");
84  useFifthStepForTrackDriven_ = iConfig.getParameter<bool>("useFifthStepForTrackerDrivenGsf");
85  useFifthStepForEcalDriven_ = iConfig.getParameter<bool>("useFifthStepForEcalDrivenGsf");
86  maxPtConvReco_ = iConfig.getParameter<double>("MaxConvBremRecoPT");
87  detaGsfSC_ = iConfig.getParameter<double>("MinDEtaGsfSC");
88  dphiGsfSC_ = iConfig.getParameter<double>("MinDPhiGsfSC");
89  SCEne_ = iConfig.getParameter<double>("MinSCEnergy");
90 
91  // set parameter for convBremFinder
92  useConvBremFinder_ = iConfig.getParameter<bool>("useConvBremFinder");
93 
94  mvaConvBremFinderIDBarrelLowPt_ = iConfig.getParameter<double>("pf_convBremFinderID_mvaCutBarrelLowPt");
95  mvaConvBremFinderIDBarrelHighPt_ = iConfig.getParameter<double>("pf_convBremFinderID_mvaCutBarrelHighPt");
96  mvaConvBremFinderIDEndcapsLowPt_ = iConfig.getParameter<double>("pf_convBremFinderID_mvaCutEndcapsLowPt");
97  mvaConvBremFinderIDEndcapsHighPt_ = iConfig.getParameter<double>("pf_convBremFinderID_mvaCutEndcapsHighPt");
98 
99  string mvaWeightFileConvBremBarrelLowPt = iConfig.getParameter<string>("pf_convBremFinderID_mvaWeightFileBarrelLowPt");
100  string mvaWeightFileConvBremBarrelHighPt = iConfig.getParameter<string>("pf_convBremFinderID_mvaWeightFileBarrelHighPt");
101  string mvaWeightFileConvBremEndcapsLowPt = iConfig.getParameter<string>("pf_convBremFinderID_mvaWeightFileEndcapsLowPt");
102  string mvaWeightFileConvBremEndcapsHighPt = iConfig.getParameter<string>("pf_convBremFinderID_mvaWeightFileEndcapsHighPt");
103 
104  if(useConvBremFinder_) {
105  path_mvaWeightFileConvBremBarrelLowPt_ = edm::FileInPath ( mvaWeightFileConvBremBarrelLowPt.c_str() ).fullPath();
106  path_mvaWeightFileConvBremBarrelHighPt_ = edm::FileInPath ( mvaWeightFileConvBremBarrelHighPt.c_str() ).fullPath();
107  path_mvaWeightFileConvBremEndcapsLowPt_ = edm::FileInPath ( mvaWeightFileConvBremEndcapsLowPt.c_str() ).fullPath();
108  path_mvaWeightFileConvBremEndcapsHighPt_ = edm::FileInPath ( mvaWeightFileConvBremEndcapsHighPt.c_str() ).fullPath();
109  }
110 }
111 
112 
114 {
115 
116  delete pfTransformer_;
117  delete convBremFinder_;
118 }
119 
120 
121 //
122 // member functions
123 //
124 
125 // ------------ method called to produce the data ------------
126 void
128 {
129 
130 
131  //create the empty collections
132  auto_ptr< GsfPFRecTrackCollection >
133  gsfPFRecTrackCollection(new GsfPFRecTrackCollection);
134 
135 
136  auto_ptr< GsfPFRecTrackCollection >
137  gsfPFRecTrackCollectionSecondary(new GsfPFRecTrackCollection);
138 
139  //read collections of tracks
140  Handle<GsfTrackCollection> gsftrackscoll;
141  iEvent.getByToken(gsfTrackLabel_,gsftrackscoll);
142 
143  //read collections of trajectories
145 
146  //read pfrectrack collection
147  Handle<PFRecTrackCollection> thePfRecTrackCollection;
148  iEvent.getByToken(pfTrackLabel_,thePfRecTrackCollection);
149  const PFRecTrackCollection& PfRTkColl = *(thePfRecTrackCollection.product());
150 
151  // PFClusters
152  Handle<PFClusterCollection> theECPfClustCollection;
153  iEvent.getByToken(pfEcalClusters_,theECPfClustCollection);
154  const PFClusterCollection& theEcalClusters = *(theECPfClustCollection.product());
155 
156  //Primary Vertexes
157  Handle<reco::VertexCollection> thePrimaryVertexColl;
158  iEvent.getByToken(primVtxLabel_,thePrimaryVertexColl);
159 
160 
161 
162  // Displaced Vertex
164  if( useNuclear_ )
165  iEvent.getByToken(pfNuclear_, pfNuclears);
166 
167 
168 
169  // Conversions
171  if( useConversions_ )
172  iEvent.getByToken(pfConv_,pfConversions);
173 
174  // V0
176  if( useV0_ )
177  iEvent.getByToken(pfV0_, pfV0);
178 
179 
180 
181 
182  GsfTrackCollection gsftracks = *(gsftrackscoll.product());
183  vector<Trajectory> tjvec(0);
184  if (trajinev_){
185  iEvent.getByToken(gsfTrackLabel_,TrajectoryCollection);
186 
187  tjvec= *(TrajectoryCollection.product());
188  }
189 
190 
191  vector<reco::GsfPFRecTrack> selGsfPFRecTracks;
192  vector<reco::GsfPFRecTrack> primaryGsfPFRecTracks;
193  std::map<unsigned int, std::vector<reco::GsfPFRecTrack> > GsfPFMap;
194 
195 
196  for (unsigned int igsf=0; igsf<gsftracks.size();igsf++) {
197 
198  GsfTrackRef trackRef(gsftrackscoll, igsf);
199 
200  int kf_ind=FindPfRef(PfRTkColl,gsftracks[igsf],false);
201 
202  if (kf_ind>=0) {
203 
204  PFRecTrackRef kf_ref(thePfRecTrackCollection,
205  kf_ind);
206 
207  // remove fifth step tracks
208  if( useFifthStepForEcalDriven_ == false
209  || useFifthStepForTrackDriven_ == false) {
210  bool isFifthStepTrack = isFifthStep(kf_ref);
211  bool isEcalDriven = true;
212  bool isTrackerDriven = true;
213 
214  if (&(*trackRef->seedRef())==0) {
215  isEcalDriven = false;
216  isTrackerDriven = false;
217  }
218  else {
219  ElectronSeedRef SeedRef= trackRef->extra()->seedRef().castTo<ElectronSeedRef>();
220  if(SeedRef->caloCluster().isNull())
221  isEcalDriven = false;
222  if(SeedRef->ctfTrack().isNull())
223  isTrackerDriven = false;
224  }
225  //note: the same track could be both ecalDriven and trackerDriven
226  if(isFifthStepTrack &&
227  isEcalDriven &&
228  isTrackerDriven == false &&
229  useFifthStepForEcalDriven_ == false) {
230  continue;
231  }
232 
233  if(isFifthStepTrack &&
234  isTrackerDriven &&
235  isEcalDriven == false &&
236  useFifthStepForTrackDriven_ == false) {
237  continue;
238  }
239 
240  if(isFifthStepTrack &&
241  isTrackerDriven &&
242  isEcalDriven &&
243  useFifthStepForTrackDriven_ == false &&
244  useFifthStepForEcalDriven_ == false) {
245  continue;
246  }
247  }
248 
249  pftrack_=GsfPFRecTrack( gsftracks[igsf].charge(),
251  igsf, trackRef,
252  kf_ref);
253  } else {
254  PFRecTrackRef dummyRef;
255  pftrack_=GsfPFRecTrack( gsftracks[igsf].charge(),
257  igsf, trackRef,
258  dummyRef);
259  }
260 
261 
262  bool validgsfbrem = false;
263  if(trajinev_) {
264  validgsfbrem = pfTransformer_->addPointsAndBrems(pftrack_,
265  gsftracks[igsf],
266  tjvec[igsf],
267  modemomentum_);
268  } else {
269  validgsfbrem = pfTransformer_->addPointsAndBrems(pftrack_,
270  gsftracks[igsf],
271  mtsTransform_);
272  }
273 
274  bool passSel = true;
275  if(applySel_)
276  passSel = applySelection(gsftracks[igsf]);
277 
278  if(validgsfbrem && passSel)
279  selGsfPFRecTracks.push_back(pftrack_);
280  }
281 
282 
283  unsigned int count_primary = 0;
284  if(selGsfPFRecTracks.size() > 0) {
285  for(unsigned int ipfgsf=0; ipfgsf<selGsfPFRecTracks.size();ipfgsf++) {
286 
287  vector<unsigned int> secondaries(0);
288  secondaries.clear();
289  bool keepGsf = true;
290 
291  if(applyGsfClean_) {
292  keepGsf = resolveGsfTracks(selGsfPFRecTracks,ipfgsf,secondaries,theEcalClusters);
293  }
294 
295  //is primary?
296  if(keepGsf == true) {
297 
298  // Find kf tracks from converted brem photons
299  if(convBremFinder_->foundConvBremPFRecTrack(thePfRecTrackCollection,thePrimaryVertexColl,
300  pfNuclears,pfConversions,pfV0,
302  theEcalClusters,selGsfPFRecTracks[ipfgsf])) {
303  const vector<PFRecTrackRef>& convBremPFRecTracks(convBremFinder_->getConvBremPFRecTracks());
304  for(unsigned int ii = 0; ii<convBremPFRecTracks.size(); ii++) {
305  selGsfPFRecTracks[ipfgsf].addConvBremPFRecTrackRef(convBremPFRecTracks[ii]);
306  }
307  }
308 
309  // save primaries gsf tracks
310  // gsfPFRecTrackCollection->push_back(selGsfPFRecTracks[ipfgsf]);
311  primaryGsfPFRecTracks.push_back(selGsfPFRecTracks[ipfgsf]);
312 
313 
314  // NOTE:: THE TRACKID IS USED TO LINK THE PRIMARY GSF TRACK. THIS NEEDS
315  // TO BE CHANGED AS SOON AS IT IS POSSIBLE TO CHANGE DATAFORMATS
316  // A MODIFICATION HERE IMPLIES A MODIFICATION IN PFBLOCKALGO.CC/H
317  unsigned int primGsfIndex = selGsfPFRecTracks[ipfgsf].trackId();
318  vector<reco::GsfPFRecTrack> trueGsfPFRecTracks;
319  if(secondaries.size() > 0) {
320  // loop on secondaries gsf tracks (from converted brems)
321  for(unsigned int isecpfgsf=0; isecpfgsf<secondaries.size();isecpfgsf++) {
322 
323  PFRecTrackRef refsecKF = selGsfPFRecTracks[(secondaries[isecpfgsf])].kfPFRecTrackRef();
324 
325  unsigned int secGsfIndex = selGsfPFRecTracks[(secondaries[isecpfgsf])].trackId();
326  GsfTrackRef secGsfRef = selGsfPFRecTracks[(secondaries[isecpfgsf])].gsfTrackRef();
327 
328  if(refsecKF.isNonnull()) {
329  // NOTE::IT SAVED THE TRACKID OF THE PRIMARY!!! THIS IS USED IN PFBLOCKALGO.CC/H
330  secpftrack_= GsfPFRecTrack( gsftracks[secGsfIndex].charge(),
332  primGsfIndex, secGsfRef,
333  refsecKF);
334  }
335  else{
336  PFRecTrackRef dummyRef;
337  // NOTE::IT SAVED THE TRACKID OF THE PRIMARY!!! THIS IS USED IN PFBLOCKALGO.CC/H
338  secpftrack_= GsfPFRecTrack( gsftracks[secGsfIndex].charge(),
340  primGsfIndex, secGsfRef,
341  dummyRef);
342  }
343 
344  bool validgsfbrem = false;
345  if(trajinev_) {
347  gsftracks[secGsfIndex],
348  tjvec[secGsfIndex],
349  modemomentum_);
350  } else {
352  gsftracks[secGsfIndex],
353  mtsTransform_);
354  }
355 
356  if(validgsfbrem) {
357  gsfPFRecTrackCollectionSecondary->push_back(secpftrack_);
358  trueGsfPFRecTracks.push_back(secpftrack_);
359  }
360  }
361  }
362  GsfPFMap.insert(pair<unsigned int,std::vector<reco::GsfPFRecTrack> >(count_primary,trueGsfPFRecTracks));
363  trueGsfPFRecTracks.clear();
364  count_primary++;
365  }
366  }
367  }
368 
369 
370  const edm::OrphanHandle<GsfPFRecTrackCollection> gsfPfRefProd =
371  iEvent.put(gsfPFRecTrackCollectionSecondary,"Secondary");
372 
373 
374  //now the secondary GsfPFRecTracks are in the event, the Ref can be created
375  createGsfPFRecTrackRef(gsfPfRefProd,primaryGsfPFRecTracks,GsfPFMap);
376 
377  for(unsigned int iGSF = 0; iGSF<primaryGsfPFRecTracks.size();iGSF++){
378  gsfPFRecTrackCollection->push_back(primaryGsfPFRecTracks[iGSF]);
379  }
380  iEvent.put(gsfPFRecTrackCollection);
381 
382  selGsfPFRecTracks.clear();
383  GsfPFMap.clear();
384  primaryGsfPFRecTracks.clear();
385 }
386 
387 // create the secondary GsfPFRecTracks Ref
388 void
390  std::vector<reco::GsfPFRecTrack>& gsfPFRecTrackPrimary,
391  const std::map<unsigned int, std::vector<reco::GsfPFRecTrack> >& MapPrimSec) {
392  unsigned int cgsf=0;
393  unsigned int csecgsf=0;
394  for (std::map<unsigned int, std::vector<reco::GsfPFRecTrack> >::const_iterator igsf = MapPrimSec.begin();
395  igsf != MapPrimSec.end(); igsf++,cgsf++) {
396  vector<reco::GsfPFRecTrack> SecGsfPF = igsf->second;
397  for (unsigned int iSecGsf=0; iSecGsf < SecGsfPF.size(); iSecGsf++) {
398  edm::Ref<reco::GsfPFRecTrackCollection> refgprt(gsfPfHandle,csecgsf);
399  gsfPFRecTrackPrimary[cgsf].addConvBremGsfPFRecTrackRef(refgprt);
400  ++csecgsf;
401  }
402  }
403 
404  return;
405 }
406 // ------------- method for find the corresponding kf pfrectrack ---------------------
407 int
409  const reco::GsfTrack& gsftk,
410  bool otherColl){
411 
412 
413  if (&(*gsftk.seedRef())==0) return -1;
414  ElectronSeedRef ElSeedRef=gsftk.extra()->seedRef().castTo<ElectronSeedRef>();
415  //CASE 1 ELECTRONSEED DOES NOT HAVE A REF TO THE CKFTRACK
416  if (ElSeedRef->ctfTrack().isNull()){
417  reco::PFRecTrackCollection::const_iterator pft=PfRTkColl.begin();
418  reco::PFRecTrackCollection::const_iterator pftend=PfRTkColl.end();
419  unsigned int i_pf=0;
420  int ibest=-1;
421  unsigned int ish_max=0;
422  float dr_min=1000;
423  //SEARCH THE PFRECTRACK THAT SHARES HITS WITH THE ELECTRON SEED
424  // Here the cpu time can be improved.
425  for(;pft!=pftend;++pft){
426  unsigned int ish=0;
427 
428  float dph= fabs(pft->trackRef()->phi()-gsftk.phi());
429  if (dph>TMath::Pi()) dph-= TMath::TwoPi();
430  float det=fabs(pft->trackRef()->eta()-gsftk.eta());
431  float dr =sqrt(dph*dph+det*det);
432 
434  pft->trackRef()->recHitsBegin();
435  trackingRecHit_iterator hhit_end=
436  pft->trackRef()->recHitsEnd();
437 
438 
439 
440  for(;hhit!=hhit_end;++hhit){
441  if (!(*hhit)->isValid()) continue;
443  gsftk.seedRef()->recHits().first;
445  gsftk.seedRef()->recHits().second;
446  for(;hit!=hit_end;++hit){
447  if (!(hit->isValid())) continue;
448  if((*hhit)->sharesInput(&*(hit),TrackingRecHit::all)) ish++;
449  // if((hit->geographicalId()==(*hhit)->geographicalId())&&
450  // (((*hhit)->localPosition()-hit->localPosition()).mag()<0.01)) ish++;
451  }
452 
453  }
454 
455 
456  if ((ish>ish_max)||
457  ((ish==ish_max)&&(dr<dr_min))){
458  ish_max=ish;
459  dr_min=dr;
460  ibest=i_pf;
461  }
462 
463 
464 
465  i_pf++;
466  }
467  if (ibest<0) return -1;
468 
469  if((ish_max==0) || (dr_min>0.05))return -1;
470  if(otherColl && (ish_max==0)) return -1;
471  return ibest;
472  }
473  else{
474  //ELECTRON SEED HAS A REFERENCE
475 
476  reco::PFRecTrackCollection::const_iterator pft=PfRTkColl.begin();
477  reco::PFRecTrackCollection::const_iterator pftend=PfRTkColl.end();
478  unsigned int i_pf=0;
479 
480  for(;pft!=pftend;++pft){
481  //REF COMPARISON
482  if (pft->trackRef()==ElSeedRef->ctfTrack()){
483  return i_pf;
484  }
485  i_pf++;
486  }
487  }
488  return -1;
489 }
491 
492  bool isFithStep = false;
493 
494 
495  TrackRef kfref = pfKfTrack->trackRef();
496  unsigned int Algo = 0;
497  switch (kfref->algo()) {
498  case TrackBase::undefAlgorithm:
499  case TrackBase::ctf:
500  case TrackBase::iter0:
501  case TrackBase::iter1:
502  case TrackBase::iter2:
503  Algo = 0;
504  break;
505  case TrackBase::iter3:
506  Algo = 1;
507  break;
508  case TrackBase::iter4:
509  Algo = 2;
510  break;
511  case TrackBase::iter5:
512  Algo = 3;
513  break;
514  case TrackBase::iter6:
515  Algo = 4;
516  break;
517  default:
518  Algo = 5;
519  break;
520  }
521  if ( Algo >= 4 ) {
522  isFithStep = true;
523  }
524 
525  return isFithStep;
526 }
527 // -- method to apply gsf electron selection to EcalDriven seeds
528 bool
530  if (&(*gsftk.seedRef())==0) return false;
531  ElectronSeedRef ElSeedRef=gsftk.extra()->seedRef().castTo<ElectronSeedRef>();
532 
533  bool passCut = false;
534  if (ElSeedRef->ctfTrack().isNull()){
535  if(ElSeedRef->caloCluster().isNull()) return passCut;
536  SuperClusterRef scRef = ElSeedRef->caloCluster().castTo<SuperClusterRef>();
537  //do this just to know if exist a SC?
538  if(scRef.isNonnull()) {
539  float caloEne = scRef->energy();
540  float feta = fabs(scRef->eta()-gsftk.etaMode());
541  float fphi = fabs(scRef->phi()-gsftk.phiMode());
542  if (fphi>TMath::Pi()) fphi-= TMath::TwoPi();
543  if(caloEne > SCEne_ && feta < detaGsfSC_ && fabs(fphi) < dphiGsfSC_)
544  passCut = true;
545  }
546  }
547  else {
548  // get all the gsf found by tracker driven
549  passCut = true;
550  }
551  return passCut;
552 }
553 bool
554 PFElecTkProducer::resolveGsfTracks(const vector<reco::GsfPFRecTrack> & GsfPFVec,
555  unsigned int ngsf,
556  vector<unsigned int> &secondaries,
557  const reco::PFClusterCollection & theEClus) {
558  bool debugCleaning = debugGsfCleaning_;
559  bool n_keepGsf = true;
560 
561  reco::GsfTrackRef nGsfTrack = GsfPFVec[ngsf].gsfTrackRef();
562 
563  if (&(*nGsfTrack->seedRef())==0) return false;
564  ElectronSeedRef nElSeedRef=nGsfTrack->extra()->seedRef().castTo<ElectronSeedRef>();
565 
566 
568  GlobalVector ninnMom;
569  float nPin = nGsfTrack->pMode();
570  if(inTSOS.isValid()){
571  mtsMode_->momentumFromModeCartesian(inTSOS,ninnMom);
572  nPin = ninnMom.mag();
573  }
574 
575  float neta = nGsfTrack->innerMomentum().eta();
576  float nphi = nGsfTrack->innerMomentum().phi();
577 
578 
579 
580 
581  if(debugCleaning)
582  cout << " PFElecTkProducer:: considering track " << nGsfTrack->pt()
583  << " eta,phi " << nGsfTrack->eta() << ", " << nGsfTrack->phi() << endl;
584 
585 
586  for (unsigned int igsf=0; igsf< GsfPFVec.size();igsf++) {
587  if(igsf != ngsf ) {
588  reco::GsfTrackRef iGsfTrack = GsfPFVec[igsf].gsfTrackRef();
589 
590  if(debugCleaning)
591  cout << " PFElecTkProducer:: and comparing with track " << iGsfTrack->pt()
592  << " eta,phi " << iGsfTrack->eta() << ", " << iGsfTrack->phi() << endl;
593 
594  float ieta = iGsfTrack->innerMomentum().eta();
595  float iphi = iGsfTrack->innerMomentum().phi();
596  float feta = fabs(neta - ieta);
597  float fphi = fabs(nphi - iphi);
598  if (fphi>TMath::Pi()) fphi-= TMath::TwoPi();
599 
600 
601  // apply a superloose preselection only to avoid un-useful cpu time: hard-coded for this reason
602  if(feta < 0.5 && fabs(fphi) < 1.0) {
603  if(debugCleaning)
604  cout << " Entering angular superloose preselection " << endl;
605 
607  GlobalVector i_innMom;
608  float iPin = iGsfTrack->pMode();
609  if(i_inTSOS.isValid()){
610  mtsMode_->momentumFromModeCartesian(i_inTSOS,i_innMom);
611  iPin = i_innMom.mag();
612  }
613 
614  if (&(*iGsfTrack->seedRef())==0) continue;
615  ElectronSeedRef iElSeedRef=iGsfTrack->extra()->seedRef().castTo<ElectronSeedRef>();
616 
617  float SCEnergy = -1.;
618  // Check if two tracks match the same SC
619  bool areBothGsfEcalDriven = false;;
620  bool isSameSC = isSameEgSC(nElSeedRef,iElSeedRef,areBothGsfEcalDriven,SCEnergy);
621 
622  // CASE1 both GsfTracks ecalDriven and match the same SC
623  if(areBothGsfEcalDriven ) {
624  if(isSameSC) {
625  float nEP = SCEnergy/nPin;
626  float iEP = SCEnergy/iPin;
627  if(debugCleaning)
628  cout << " Entering SAME supercluster case "
629  << " nEP " << nEP
630  << " iEP " << iEP << endl;
631 
632 
633 
634  // if same SC take the closest or if same
635  // distance the best E/p
636 
637  // Innermost using LostHits technology
638  bool isSameLayer = false;
639  bool iGsfInnermostWithLostHits =
640  isInnerMostWithLostHits(nGsfTrack,iGsfTrack,isSameLayer);
641 
642 
643  if(debugCleaning)
644  cout << " iGsf is InnerMostWithLostHits " << iGsfInnermostWithLostHits
645  << " isSameLayer " << isSameLayer << endl;
646 
647  if (iGsfInnermostWithLostHits) {
648  n_keepGsf = false;
649  return n_keepGsf;
650  }
651  else if(isSameLayer){
652  if(fabs(iEP-1) < fabs(nEP-1)) {
653  n_keepGsf = false;
654  return n_keepGsf;
655  }
656  else{
657  secondaries.push_back(igsf);
658  }
659  }
660  else {
661  // save secondaries gsf track (put selection)
662  secondaries.push_back(igsf);
663  }
664  } // end same SC case
665  }
666  else {
667  // enter in the condition where at least one track is trackerDriven
668  float minBremDphi = minTangDist(GsfPFVec[ngsf],GsfPFVec[igsf]);
669  float nETot = 0.;
670  float iETot = 0.;
671  bool isBothGsfTrackerDriven = false;
672  bool nEcalDriven = false;
673  bool iEcalDriven = false;
674  bool isSameScEgPf = isSharingEcalEnergyWithEgSC(GsfPFVec[ngsf],
675  GsfPFVec[igsf],
676  nElSeedRef,
677  iElSeedRef,
678  theEClus,
679  isBothGsfTrackerDriven,
680  nEcalDriven,
681  iEcalDriven,
682  nETot,
683  iETot);
684 
685  // check if the first hit of iGsfTrack < nGsfTrack
686  bool isSameLayer = false;
687  bool iGsfInnermostWithLostHits =
688  isInnerMostWithLostHits(nGsfTrack,iGsfTrack,isSameLayer);
689 
690  if(isSameScEgPf) {
691  // CASE 2 : One Gsf has reference to a SC and the other one not or both not
692 
693  if(debugCleaning) {
694  cout << " Sharing ECAL energy passed "
695  << " nEtot " << nETot
696  << " iEtot " << iETot << endl;
697  if(isBothGsfTrackerDriven)
698  cout << " Both Track are trackerDriven " << endl;
699  }
700 
701  // Innermost using LostHits technology
702  if (iGsfInnermostWithLostHits) {
703  n_keepGsf = false;
704  return n_keepGsf;
705  }
706  else if(isSameLayer){
707  // Thirt Case: One Gsf has reference to a SC and the other one not or both not
708  // gsf tracks starts from the same layer
709  // check number of sharing modules (at least 50%)
710  // check number of sharing hits (at least 2)
711  // check charge flip inner/outer
712 
713 
714  // they share energy
715  if(isBothGsfTrackerDriven == false) {
716  // if at least one Gsf track is EcalDriven choose that one.
717  if(iEcalDriven) {
718  n_keepGsf = false;
719  return n_keepGsf;
720  }
721  else {
722  secondaries.push_back(igsf);
723  }
724  }
725  else {
726  // if both tracks are tracker driven choose that one with the best E/p
727  // with ETot = max(En,Ei)
728 
729  float ETot = -1;
730  if(nETot != iETot) {
731  if(nETot > iETot)
732  ETot = nETot;
733  else
734  ETot = iETot;
735  }
736  else {
737  ETot = nETot;
738  }
739  float nEP = ETot/nPin;
740  float iEP = ETot/iPin;
741 
742 
743  if(debugCleaning)
744  cout << " nETot " << nETot
745  << " iETot " << iETot
746  << " ETot " << ETot << endl
747  << " nPin " << nPin
748  << " iPin " << iPin
749  << " nEP " << nEP
750  << " iEP " << iEP << endl;
751 
752 
753  if(fabs(iEP-1) < fabs(nEP-1)) {
754  n_keepGsf = false;
755  return n_keepGsf;
756  }
757  else{
758  secondaries.push_back(igsf);
759  }
760  }
761  }
762  else {
763  secondaries.push_back(igsf);
764  }
765  }
766  else if(feta < detaCutGsfClean_ && minBremDphi < dphiCutGsfClean_) {
767  // very close tracks
768  bool secPushedBack = false;
769  if(nEcalDriven == false && nETot == 0.) {
770  n_keepGsf = false;
771  return n_keepGsf;
772  }
773  else if(iEcalDriven == false && iETot == 0.) {
774  secondaries.push_back(igsf);
775  secPushedBack = true;
776  }
777  if(debugCleaning)
778  cout << " Close Tracks "
779  << " feta " << feta << " fabs(fphi) " << fabs(fphi)
780  << " minBremDphi " << minBremDphi
781  << " nETot " << nETot
782  << " iETot " << iETot
783  << " nLostHits " << nGsfTrack->trackerExpectedHitsInner().numberOfLostHits()
784  << " iLostHits " << iGsfTrack->trackerExpectedHitsInner().numberOfLostHits() << endl;
785 
786  // apply selection only if one track has lost hits
788  if (iGsfInnermostWithLostHits) {
789  n_keepGsf = false;
790  return n_keepGsf;
791  }
792  else if(isSameLayer == false) {
793  if(secPushedBack == false)
794  secondaries.push_back(igsf);
795  }
796  }
797  }
798  else if(feta < 0.1 && minBremDphi < 0.2){
799  // failed all the conditions, discard only tracker driven tracks
800  // with no PFClusters linked.
801  if(debugCleaning)
802  cout << " Close Tracks and failed all the conditions "
803  << " feta " << feta << " fabs(fphi) " << fabs(fphi)
804  << " minBremDphi " << minBremDphi
805  << " nETot " << nETot
806  << " iETot " << iETot
807  << " nLostHits " << nGsfTrack->trackerExpectedHitsInner().numberOfLostHits()
808  << " iLostHits " << iGsfTrack->trackerExpectedHitsInner().numberOfLostHits() << endl;
809 
810  if(nEcalDriven == false && nETot == 0.) {
811  n_keepGsf = false;
812  return n_keepGsf;
813  }
814  // Here I do not push back the secondary because considered fakes...
815  }
816  }
817  }
818  }
819  }
820 
821  return n_keepGsf;
822 }
823 float
825  const reco::GsfPFRecTrack& secGsf) {
826 
827  float minDphi = 1000.;
828 
829 
830  std::vector<reco::PFBrem> primPFBrem = primGsf.PFRecBrem();
831  std::vector<reco::PFBrem> secPFBrem = secGsf.PFRecBrem();
832 
833 
834  unsigned int cbrem = 0;
835  for (unsigned isbrem = 0; isbrem < secPFBrem.size(); isbrem++) {
836  if(secPFBrem[isbrem].indTrajPoint() == 99) continue;
837  const reco::PFTrajectoryPoint& atSecECAL
838  = secPFBrem[isbrem].extrapolatedPoint( reco::PFTrajectoryPoint::ECALEntrance );
839  if( ! atSecECAL.isValid() ) continue;
840  float secPhi = atSecECAL.positionREP().Phi();
841 
842  unsigned int sbrem = 0;
843  for(unsigned ipbrem = 0; ipbrem < primPFBrem.size(); ipbrem++) {
844  if(primPFBrem[ipbrem].indTrajPoint() == 99) continue;
845  const reco::PFTrajectoryPoint& atPrimECAL
846  = primPFBrem[ipbrem].extrapolatedPoint( reco::PFTrajectoryPoint::ECALEntrance );
847  if( ! atPrimECAL.isValid() ) continue;
848  sbrem++;
849  if(sbrem <= 3) {
850  float primPhi = atPrimECAL.positionREP().Phi();
851 
852  float dphi = fabs(primPhi - secPhi);
853  if (dphi>TMath::Pi()) dphi-= TMath::TwoPi();
854  if(fabs(dphi) < minDphi) {
855  minDphi = fabs(dphi);
856  }
857  }
858  }
859 
860 
861  cbrem++;
862  if(cbrem == 3)
863  break;
864  }
865  return minDphi;
866 }
867 bool
869  const reco::ElectronSeedRef& iSeedRef,
870  bool& bothGsfEcalDriven,
871  float& SCEnergy) {
872 
873  bool isSameSC = false;
874 
875  if(nSeedRef->caloCluster().isNonnull() && iSeedRef->caloCluster().isNonnull()) {
876  SuperClusterRef nscRef = nSeedRef->caloCluster().castTo<SuperClusterRef>();
877  SuperClusterRef iscRef = iSeedRef->caloCluster().castTo<SuperClusterRef>();
878 
879  if(nscRef.isNonnull() && iscRef.isNonnull()) {
880  bothGsfEcalDriven = true;
881  if(nscRef == iscRef) {
882  isSameSC = true;
883  // retrieve the supercluster energy
884  SCEnergy = nscRef->energy();
885  }
886  }
887  }
888  return isSameSC;
889 }
890 bool
892  const reco::GsfPFRecTrack& iGsfPFRecTrack,
893  const reco::ElectronSeedRef& nSeedRef,
894  const reco::ElectronSeedRef& iSeedRef,
895  const reco::PFClusterCollection& theEClus,
896  bool& bothGsfTrackerDriven,
897  bool& nEcalDriven,
898  bool& iEcalDriven,
899  float& nEnergy,
900  float& iEnergy) {
901 
902  bool isSharingEnergy = false;
903 
904  //which is EcalDriven?
905  bool oneEcalDriven = true;
906  SuperClusterRef scRef;
907  GsfPFRecTrack gsfPfTrack;
908 
909  if(nSeedRef->caloCluster().isNonnull()) {
910  scRef = nSeedRef->caloCluster().castTo<SuperClusterRef>();
911  nEnergy = scRef->energy();
912  nEcalDriven = true;
913  gsfPfTrack = iGsfPFRecTrack;
914  }
915  else if(iSeedRef->caloCluster().isNonnull()){
916  scRef = iSeedRef->caloCluster().castTo<SuperClusterRef>();
917  iEnergy = scRef->energy();
918  iEcalDriven = true;
919  gsfPfTrack = nGsfPFRecTrack;
920  }
921  else{
922  oneEcalDriven = false;
923  }
924 
925  if(oneEcalDriven) {
926  //run a basic reconstruction for the particle flow
927 
928  vector<PFCluster> vecPFClusters;
929  vecPFClusters.clear();
930 
931  for (PFClusterCollection::const_iterator clus = theEClus.begin();
932  clus != theEClus.end();
933  clus++ ) {
934  PFCluster clust = *clus;
935  clust.calculatePositionREP();
936 
937  float deta = fabs(scRef->position().eta() - clust.position().eta());
938  float dphi = fabs(scRef->position().phi() - clust.position().phi());
939  if (dphi>TMath::Pi()) dphi-= TMath::TwoPi();
940 
941  // Angle preselection between the supercluster and pfclusters
942  // this is needed just to save some cpu-time for this is hard-coded
943  if(deta < 0.5 && fabs(dphi) < 1.0) {
944  bool foundLink = false;
945  double distGsf = gsfPfTrack.extrapolatedPoint( reco::PFTrajectoryPoint::ECALShowerMax ).isValid() ?
946  LinkByRecHit::testTrackAndClusterByRecHit(gsfPfTrack , clust ) : -1.;
947  // check if it touch the GsfTrack
948  if(distGsf > 0.) {
949  if(nEcalDriven)
950  iEnergy += clust.energy();
951  else
952  nEnergy += clust.energy();
953  vecPFClusters.push_back(clust);
954  foundLink = true;
955  }
956  // check if it touch the Brem-tangents
957  if(foundLink == false) {
958  vector<PFBrem> primPFBrem = gsfPfTrack.PFRecBrem();
959  for(unsigned ipbrem = 0; ipbrem < primPFBrem.size(); ipbrem++) {
960  if(primPFBrem[ipbrem].indTrajPoint() == 99) continue;
961  const reco::PFRecTrack& pfBremTrack = primPFBrem[ipbrem];
962  double dist = pfBremTrack.extrapolatedPoint( reco::PFTrajectoryPoint::ECALShowerMax ).isValid() ?
963  LinkByRecHit::testTrackAndClusterByRecHit(pfBremTrack , clust, true ) : -1.;
964  if(dist > 0.) {
965  if(nEcalDriven)
966  iEnergy += clust.energy();
967  else
968  nEnergy += clust.energy();
969  vecPFClusters.push_back(clust);
970  foundLink = true;
971  }
972  }
973  }
974  } // END if anble preselection
975  } // PFClusters Loop
976  if(vecPFClusters.size() > 0 ) {
977  for(unsigned int pf = 0; pf < vecPFClusters.size(); pf++) {
978  bool isCommon = ClusterClusterMapping::overlap(vecPFClusters[pf],*scRef);
979  if(isCommon) {
980  isSharingEnergy = true;
981  }
982  break;
983  }
984  }
985  }
986  else {
987  // both tracks are trackerDriven, try ECAL energy matching also in this case.
988 
989  bothGsfTrackerDriven = true;
990  vector<PFCluster> nPFCluster;
991  vector<PFCluster> iPFCluster;
992 
993  nPFCluster.clear();
994  iPFCluster.clear();
995 
996  for (PFClusterCollection::const_iterator clus = theEClus.begin();
997  clus != theEClus.end();
998  clus++ ) {
999  PFCluster clust = *clus;
1000  clust.calculatePositionREP();
1001 
1002  float ndeta = fabs(nGsfPFRecTrack.gsfTrackRef()->eta() - clust.position().eta());
1003  float ndphi = fabs(nGsfPFRecTrack.gsfTrackRef()->phi() - clust.position().phi());
1004  if (ndphi>TMath::Pi()) ndphi-= TMath::TwoPi();
1005  // Apply loose preselection with the track
1006  // just to save cpu time, for this hard-coded
1007  if(ndeta < 0.5 && fabs(ndphi) < 1.0) {
1008  bool foundNLink = false;
1009 
1010  double distGsf = nGsfPFRecTrack.extrapolatedPoint( reco::PFTrajectoryPoint::ECALShowerMax ).isValid() ?
1011  LinkByRecHit::testTrackAndClusterByRecHit(nGsfPFRecTrack , clust ) : -1.;
1012  if(distGsf > 0.) {
1013  nPFCluster.push_back(clust);
1014  nEnergy += clust.energy();
1015  foundNLink = true;
1016  }
1017  if(foundNLink == false) {
1018  const vector<PFBrem>& primPFBrem = nGsfPFRecTrack.PFRecBrem();
1019  for(unsigned ipbrem = 0; ipbrem < primPFBrem.size(); ipbrem++) {
1020  if(primPFBrem[ipbrem].indTrajPoint() == 99) continue;
1021  const reco::PFRecTrack& pfBremTrack = primPFBrem[ipbrem];
1022  if(foundNLink == false) {
1023  double dist = pfBremTrack.extrapolatedPoint( reco::PFTrajectoryPoint::ECALShowerMax ).isValid() ?
1024  LinkByRecHit::testTrackAndClusterByRecHit(pfBremTrack , clust, true ) : -1.;
1025  if(dist > 0.) {
1026  nPFCluster.push_back(clust);
1027  nEnergy += clust.energy();
1028  foundNLink = true;
1029  }
1030  }
1031  }
1032  }
1033  }
1034 
1035  float ideta = fabs(iGsfPFRecTrack.gsfTrackRef()->eta() - clust.position().eta());
1036  float idphi = fabs(iGsfPFRecTrack.gsfTrackRef()->phi() - clust.position().phi());
1037  if (idphi>TMath::Pi()) idphi-= TMath::TwoPi();
1038  // Apply loose preselection with the track
1039  // just to save cpu time, for this hard-coded
1040  if(ideta < 0.5 && fabs(idphi) < 1.0) {
1041  bool foundILink = false;
1042  double dist = iGsfPFRecTrack.extrapolatedPoint( reco::PFTrajectoryPoint::ECALShowerMax ).isValid() ?
1043  LinkByRecHit::testTrackAndClusterByRecHit(iGsfPFRecTrack , clust ) : -1.;
1044  if(dist > 0.) {
1045  iPFCluster.push_back(clust);
1046  iEnergy += clust.energy();
1047  foundILink = true;
1048  }
1049  if(foundILink == false) {
1050  vector<PFBrem> primPFBrem = iGsfPFRecTrack.PFRecBrem();
1051  for(unsigned ipbrem = 0; ipbrem < primPFBrem.size(); ipbrem++) {
1052  if(primPFBrem[ipbrem].indTrajPoint() == 99) continue;
1053  const reco::PFRecTrack& pfBremTrack = primPFBrem[ipbrem];
1054  if(foundILink == false) {
1055  double dist = LinkByRecHit::testTrackAndClusterByRecHit(pfBremTrack , clust, true );
1056  if(dist > 0.) {
1057  iPFCluster.push_back(clust);
1058  iEnergy += clust.energy();
1059  foundILink = true;
1060  }
1061  }
1062  }
1063  }
1064  }
1065  }
1066 
1067 
1068  if(nPFCluster.size() > 0 && iPFCluster.size() > 0) {
1069  for(unsigned int npf = 0; npf < nPFCluster.size(); npf++) {
1070  for(unsigned int ipf = 0; ipf < iPFCluster.size(); ipf++) {
1071  bool isCommon = ClusterClusterMapping::overlap(nPFCluster[npf],iPFCluster[ipf]);
1072  if(isCommon) {
1073  isSharingEnergy = true;
1074  break;
1075  }
1076  }
1077  if(isSharingEnergy)
1078  break;
1079  }
1080  }
1081  }
1082 
1083  return isSharingEnergy;
1084 }
1086  const reco::GsfTrackRef& iGsfTrack,
1087  bool& sameLayer) {
1088 
1089  // copied by the class RecoEgamma/EgammaElectronAlgos/src/EgAmbiguityTools.cc
1090  // obsolete but the code is kept: now using lost hits method
1091 
1092  reco::HitPattern gsfHitPattern1 = nGsfTrack->hitPattern();
1093  reco::HitPattern gsfHitPattern2 = iGsfTrack->hitPattern();
1094 
1095  // retrieve first valid hit
1096  int gsfHitCounter1 = 0 ;
1097  trackingRecHit_iterator elHitsIt1 ;
1098  for
1099  ( elHitsIt1 = nGsfTrack->recHitsBegin() ;
1100  elHitsIt1 != nGsfTrack->recHitsEnd() ;
1101  elHitsIt1++, gsfHitCounter1++ )
1102  { if (((**elHitsIt1).isValid())) break ; }
1103 
1104  int gsfHitCounter2 = 0 ;
1105  trackingRecHit_iterator elHitsIt2 ;
1106  for
1107  ( elHitsIt2 = iGsfTrack->recHitsBegin() ;
1108  elHitsIt2 != iGsfTrack->recHitsEnd() ;
1109  elHitsIt2++, gsfHitCounter2++ )
1110  { if (((**elHitsIt2).isValid())) break ; }
1111 
1112  uint32_t gsfHit1 = gsfHitPattern1.getHitPattern(gsfHitCounter1) ;
1113  uint32_t gsfHit2 = gsfHitPattern2.getHitPattern(gsfHitCounter2) ;
1114 
1115 
1116  if (gsfHitPattern1.getSubStructure(gsfHit1)!=gsfHitPattern2.getSubStructure(gsfHit2))
1117  {
1118  return (gsfHitPattern2.getSubStructure(gsfHit2)<gsfHitPattern1.getSubStructure(gsfHit1));
1119  }
1120  else if (gsfHitPattern1.getLayer(gsfHit1)!=gsfHitPattern2.getLayer(gsfHit2))
1121  {
1122  return (gsfHitPattern2.getLayer(gsfHit2)<gsfHitPattern1.getLayer(gsfHit1));
1123  }
1124  else
1125  {
1126  sameLayer = true;
1127  return false;
1128  }
1129 }
1131  const reco::GsfTrackRef& iGsfTrack,
1132  bool& sameLayer) {
1133 
1134  // define closest using the lost hits on the expectedhitsineer
1135  unsigned int nLostHits = nGsfTrack->trackerExpectedHitsInner().numberOfLostHits();
1136  unsigned int iLostHits = iGsfTrack->trackerExpectedHitsInner().numberOfLostHits();
1137 
1138  if (nLostHits!=iLostHits) {
1139  return (nLostHits > iLostHits);
1140  }
1141  else {
1142  sameLayer = true;
1143  return false;
1144  }
1145 }
1146 
1147 
1148 
1149 // ------------ method called once each job just before starting event loop ------------
1150 void
1152  const EventSetup& iSetup)
1153 {
1154  ESHandle<MagneticField> magneticField;
1155  iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
1156 
1158  iSetup.get<TrackerDigiGeometryRecord>().get(tracker);
1159 
1160 
1161  mtsTransform_ = MultiTrajectoryStateTransform(tracker.product(),magneticField.product());
1162 
1163 
1164  pfTransformer_= new PFTrackTransformer(math::XYZVector(magneticField->inTesla(GlobalPoint(0,0,0))));
1165 
1166 
1168  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder", builder);
1169  TransientTrackBuilder thebuilder = *(builder.product());
1170 
1171 
1172  if(useConvBremFinder_) {
1173  vector <TString> weightfiles;
1174  weightfiles.push_back(path_mvaWeightFileConvBremBarrelLowPt_.c_str());
1175  weightfiles.push_back(path_mvaWeightFileConvBremBarrelHighPt_.c_str());
1176  weightfiles.push_back(path_mvaWeightFileConvBremEndcapsLowPt_.c_str());
1177  weightfiles.push_back(path_mvaWeightFileConvBremEndcapsHighPt_.c_str());
1178  for(uint iter = 0;iter<weightfiles.size();iter++){
1179  FILE * fileConvBremID = fopen(weightfiles[iter],"r");
1180  if (fileConvBremID) {
1181  fclose(fileConvBremID);
1182  }
1183  else {
1184  string err = "PFElecTkProducer: cannot open weight file '";
1185  err += weightfiles[iter];
1186  err += "'";
1187  throw invalid_argument( err );
1188  }
1189  }
1190 
1191  }
1192  convBremFinder_ = new ConvBremPFTrackFinder(thebuilder,
1201 
1202 }
1203 
1204 // ------------ method called once each job just after ending the event loop ------------
1205 void
1207  const EventSetup& iSetup) {
1208  delete pfTransformer_;
1209  pfTransformer_=nullptr;
1210  delete convBremFinder_;
1211  convBremFinder_=nullptr;
1212 }
1213 
1214 //define this as a plug-in
const REPPoint & positionREP() const
trajectory position in (rho, eta, phi) base
bool trajinev_
Trajectory of GSfTracks in the event?
const double TwoPi
const double Pi
T getParameter(std::string const &) const
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:124
reconstructed track used as an input to particle flow
Definition: PFRecTrack.h:22
edm::EDGetTokenT< reco::PFRecTrackCollection > pfTrackLabel_
static bool overlap(const reco::CaloCluster &sc1, const reco::CaloCluster &sc, float minfrac=0.01, bool debug=false)
edm::EDGetTokenT< reco::GsfTrackCollection > gsfTrackLabel_
void createGsfPFRecTrackRef(const edm::OrphanHandle< reco::GsfPFRecTrackCollection > &gsfPfHandle, std::vector< reco::GsfPFRecTrack > &gsfPFRecTrackPrimary, const std::map< unsigned int, std::vector< reco::GsfPFRecTrack > > &MapPrimSec)
static uint32_t getLayer(uint32_t pattern)
Definition: HitPattern.h:520
tuple pfV0
Definition: pfV0_cfi.py:3
const TrackExtraRef & extra() const
reference to &quot;extra&quot; object
Definition: Track.h:97
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
Definition: PFCluster.h:47
double mvaConvBremFinderIDEndcapsLowPt_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
std::string path_mvaWeightFileConvBremEndcapsLowPt_
bool addPointsAndBrems(reco::GsfPFRecTrack &pftrack, const reco::Track &track, const Trajectory &traj, const bool &GetMode) const
ConvBremPFTrackFinder * convBremFinder_
bool isFifthStep(reco::PFRecTrackRef pfKfTrack)
const std::vector< reco::PFBrem > & PFRecBrem() const
Definition: GsfPFRecTrack.h:51
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:137
bool applySelection(const reco::GsfTrack &)
~PFElecTkProducer()
Destructor.
bool momentumFromModeCartesian(const TrajectoryStateOnSurface tsos, GlobalVector &momentum) const
reco::GsfPFRecTrack secpftrack_
int ii
Definition: cuy.py:588
double charge(const std::vector< uint8_t > &Ampls)
edm::EDGetTokenT< reco::VertexCollection > primVtxLabel_
std::string path_mvaWeightFileConvBremBarrelHighPt_
PFTrackTransformer * pfTransformer_
PFTrackTransformer.
const MultiTrajectoryStateMode * mtsMode_
double mvaConvBremFinderIDBarrelLowPt_
const std::vector< reco::PFRecTrackRef > & getConvBremPFRecTracks()
bool isSameEgSC(const reco::ElectronSeedRef &nSeedRef, const reco::ElectronSeedRef &iSeedRef, bool &bothGsfEcalDriven, float &SCEnergy)
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
PFElecTkProducer(const edm::ParameterSet &)
Constructor.
int iEvent
Definition: GenABIO.cc:230
bool isNull() const
Checks for null.
Definition: Ref.h:247
T mag() const
Definition: PV3DBase.h:67
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:139
bool foundConvBremPFRecTrack(const edm::Handle< reco::PFRecTrackCollection > &thePfRecTrackCol, const edm::Handle< reco::VertexCollection > &primaryVertex, const edm::Handle< reco::PFDisplacedTrackerVertexCollection > &pfNuclears, const edm::Handle< reco::PFConversionCollection > &pfConversions, const edm::Handle< reco::PFV0Collection > &pfV0, bool useNuclear, bool useConversions, bool useV0, const reco::PFClusterCollection &theEClus, const reco::GsfPFRecTrack &gsfpfrectk)
std::vector< GsfPFRecTrack > GsfPFRecTrackCollection
collection of GsfPFRecTrack objects
void calculatePositionREP()
computes posrep_ once and for all
Definition: PFCluster.h:90
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
edm::EDGetTokenT< reco::PFV0Collection > pfV0_
const reco::GsfTrackRef & gsfTrackRef() const
Definition: GsfPFRecTrack.h:39
recHitContainer::const_iterator const_iterator
T sqrt(T t)
Definition: SSEVec.h:48
std::string path_mvaWeightFileConvBremEndcapsHighPt_
std::vector< GsfTrack > GsfTrackCollection
collection of GsfTracks
Definition: GsfTrackFwd.h:9
static uint32_t getSubStructure(uint32_t pattern)
Definition: HitPattern.h:514
edm::EDGetTokenT< reco::PFDisplacedTrackerVertexCollection > pfNuclear_
const reco::PFTrajectoryPoint & extrapolatedPoint(unsigned layerid) const
Definition: PFTrack.cc:76
double energy() const
cluster energy
Definition: PFCluster.h:79
bool isInnerMostWithLostHits(const reco::GsfTrackRef &nGsfTrack, const reco::GsfTrackRef &iGsfTrack, bool &sameLayer)
virtual void endRun(const edm::Run &, const edm::EventSetup &) override
int FindPfRef(const reco::PFRecTrackCollection &PfRTkColl, const reco::GsfTrack &, bool)
edm::RefToBase< TrajectorySeed > seedRef() const
Definition: Track.h:112
std::string path_mvaWeightFileConvBremBarrelLowPt_
bool resolveGsfTracks(const std::vector< reco::GsfPFRecTrack > &GsfPFVec, unsigned int ngsf, std::vector< unsigned int > &secondaries, const reco::PFClusterCollection &theEClus)
bool isValid() const
is this point valid ?
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
range recHits() const
double mvaConvBremFinderIDBarrelHighPt_
T const * product() const
Definition: Handle.h:81
double mvaConvBremFinderIDEndcapsHighPt_
edm::EDGetTokenT< reco::PFConversionCollection > pfConv_
std::vector< Trajectory > TrajectoryCollection
TrajectoryStateOnSurface innerStateOnSurface(const reco::GsfTrack &tk) const
virtual void beginRun(const edm::Run &, const edm::EventSetup &) override
double etaMode() const
pseudorapidity of momentum vector from mode
Definition: GsfTrack.h:59
reco::GsfPFRecTrack pftrack_
virtual void produce(edm::Event &, const edm::EventSetup &) override
Produce the PFRecTrack collection.
double phiMode() const
azimuthal angle of momentum vector from mode
Definition: GsfTrack.h:57
bool useConvBremFinder_
Conv Brem Finder.
std::vector< PFCluster > PFClusterCollection
collection of PFCluster objects
Definition: PFClusterFwd.h:9
bool isSharingEcalEnergyWithEgSC(const reco::GsfPFRecTrack &nGsfPFRecTrack, const reco::GsfPFRecTrack &iGsfPFRecTrack, const reco::ElectronSeedRef &nSeedRef, const reco::ElectronSeedRef &iSeedRef, const reco::PFClusterCollection &theEClus, bool &bothGsfTrackerDriven, bool &nEcalDriven, bool &iEcalDriven, float &nEnergy, float &iEnergy)
tuple cout
Definition: gather_cfg.py:121
A PFTrack holds several trajectory points, which basically contain the position and momentum of a tra...
uint32_t getHitPattern(int position) const
Definition: HitPattern.cc:142
static double testTrackAndClusterByRecHit(const reco::PFRecTrack &track, const reco::PFCluster &cluster, bool isBrem=false, bool debug=false)
Definition: LinkByRecHit.cc:10
float minTangDist(const reco::GsfPFRecTrack &primGsf, const reco::GsfPFRecTrack &secGsf)
std::vector< PFRecTrack > PFRecTrackCollection
collection of PFRecTrack objects
Definition: PFRecTrackFwd.h:9
edm::EDGetTokenT< reco::PFClusterCollection > pfEcalClusters_
Definition: fakeMenu.h:6
Definition: Run.h:41
MultiTrajectoryStateTransform mtsTransform_
bool isInnerMost(const reco::GsfTrackRef &nGsfTrack, const reco::GsfTrackRef &iGsfTrack, bool &sameLayer)