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  case TrackBase::iter7:
504  case TrackBase::iter9:
505  case TrackBase::iter10:
506  Algo = 0;
507  break;
508  case TrackBase::iter3:
509  Algo = 1;
510  break;
511  case TrackBase::iter4:
512  Algo = 2;
513  break;
514  case TrackBase::iter5:
515  Algo = 3;
516  break;
517  case TrackBase::iter6:
518  Algo = 4;
519  break;
520  default:
521  Algo = 5;
522  break;
523  }
524  if ( Algo >= 4 ) {
525  isFithStep = true;
526  }
527 
528  return isFithStep;
529 }
530 // -- method to apply gsf electron selection to EcalDriven seeds
531 bool
533  if (&(*gsftk.seedRef())==0) return false;
534  ElectronSeedRef ElSeedRef=gsftk.extra()->seedRef().castTo<ElectronSeedRef>();
535 
536  bool passCut = false;
537  if (ElSeedRef->ctfTrack().isNull()){
538  if(ElSeedRef->caloCluster().isNull()) return passCut;
539  SuperClusterRef scRef = ElSeedRef->caloCluster().castTo<SuperClusterRef>();
540  //do this just to know if exist a SC?
541  if(scRef.isNonnull()) {
542  float caloEne = scRef->energy();
543  float feta = fabs(scRef->eta()-gsftk.etaMode());
544  float fphi = fabs(scRef->phi()-gsftk.phiMode());
545  if (fphi>TMath::Pi()) fphi-= TMath::TwoPi();
546  if(caloEne > SCEne_ && feta < detaGsfSC_ && fabs(fphi) < dphiGsfSC_)
547  passCut = true;
548  }
549  }
550  else {
551  // get all the gsf found by tracker driven
552  passCut = true;
553  }
554  return passCut;
555 }
556 bool
557 PFElecTkProducer::resolveGsfTracks(const vector<reco::GsfPFRecTrack> & GsfPFVec,
558  unsigned int ngsf,
559  vector<unsigned int> &secondaries,
560  const reco::PFClusterCollection & theEClus) {
561  bool debugCleaning = debugGsfCleaning_;
562  bool n_keepGsf = true;
563 
564  reco::GsfTrackRef nGsfTrack = GsfPFVec[ngsf].gsfTrackRef();
565 
566  if (&(*nGsfTrack->seedRef())==0) return false;
567  ElectronSeedRef nElSeedRef=nGsfTrack->extra()->seedRef().castTo<ElectronSeedRef>();
568 
569 
571  GlobalVector ninnMom;
572  float nPin = nGsfTrack->pMode();
573  if(inTSOS.isValid()){
574  mtsMode_->momentumFromModeCartesian(inTSOS,ninnMom);
575  nPin = ninnMom.mag();
576  }
577 
578  float neta = nGsfTrack->innerMomentum().eta();
579  float nphi = nGsfTrack->innerMomentum().phi();
580 
581 
582 
583 
584  if(debugCleaning)
585  cout << " PFElecTkProducer:: considering track " << nGsfTrack->pt()
586  << " eta,phi " << nGsfTrack->eta() << ", " << nGsfTrack->phi() << endl;
587 
588 
589  for (unsigned int igsf=0; igsf< GsfPFVec.size();igsf++) {
590  if(igsf != ngsf ) {
591  reco::GsfTrackRef iGsfTrack = GsfPFVec[igsf].gsfTrackRef();
592 
593  if(debugCleaning)
594  cout << " PFElecTkProducer:: and comparing with track " << iGsfTrack->pt()
595  << " eta,phi " << iGsfTrack->eta() << ", " << iGsfTrack->phi() << endl;
596 
597  float ieta = iGsfTrack->innerMomentum().eta();
598  float iphi = iGsfTrack->innerMomentum().phi();
599  float feta = fabs(neta - ieta);
600  float fphi = fabs(nphi - iphi);
601  if (fphi>TMath::Pi()) fphi-= TMath::TwoPi();
602 
603 
604  // apply a superloose preselection only to avoid un-useful cpu time: hard-coded for this reason
605  if(feta < 0.5 && fabs(fphi) < 1.0) {
606  if(debugCleaning)
607  cout << " Entering angular superloose preselection " << endl;
608 
610  GlobalVector i_innMom;
611  float iPin = iGsfTrack->pMode();
612  if(i_inTSOS.isValid()){
613  mtsMode_->momentumFromModeCartesian(i_inTSOS,i_innMom);
614  iPin = i_innMom.mag();
615  }
616 
617  if (&(*iGsfTrack->seedRef())==0) continue;
618  ElectronSeedRef iElSeedRef=iGsfTrack->extra()->seedRef().castTo<ElectronSeedRef>();
619 
620  float SCEnergy = -1.;
621  // Check if two tracks match the same SC
622  bool areBothGsfEcalDriven = false;;
623  bool isSameSC = isSameEgSC(nElSeedRef,iElSeedRef,areBothGsfEcalDriven,SCEnergy);
624 
625  // CASE1 both GsfTracks ecalDriven and match the same SC
626  if(areBothGsfEcalDriven ) {
627  if(isSameSC) {
628  float nEP = SCEnergy/nPin;
629  float iEP = SCEnergy/iPin;
630  if(debugCleaning)
631  cout << " Entering SAME supercluster case "
632  << " nEP " << nEP
633  << " iEP " << iEP << endl;
634 
635 
636 
637  // if same SC take the closest or if same
638  // distance the best E/p
639 
640  // Innermost using LostHits technology
641  bool isSameLayer = false;
642  bool iGsfInnermostWithLostHits =
643  isInnerMostWithLostHits(nGsfTrack,iGsfTrack,isSameLayer);
644 
645 
646  if(debugCleaning)
647  cout << " iGsf is InnerMostWithLostHits " << iGsfInnermostWithLostHits
648  << " isSameLayer " << isSameLayer << endl;
649 
650  if (iGsfInnermostWithLostHits) {
651  n_keepGsf = false;
652  return n_keepGsf;
653  }
654  else if(isSameLayer){
655  if(fabs(iEP-1) < fabs(nEP-1)) {
656  n_keepGsf = false;
657  return n_keepGsf;
658  }
659  else{
660  secondaries.push_back(igsf);
661  }
662  }
663  else {
664  // save secondaries gsf track (put selection)
665  secondaries.push_back(igsf);
666  }
667  } // end same SC case
668  }
669  else {
670  // enter in the condition where at least one track is trackerDriven
671  float minBremDphi = minTangDist(GsfPFVec[ngsf],GsfPFVec[igsf]);
672  float nETot = 0.;
673  float iETot = 0.;
674  bool isBothGsfTrackerDriven = false;
675  bool nEcalDriven = false;
676  bool iEcalDriven = false;
677  bool isSameScEgPf = isSharingEcalEnergyWithEgSC(GsfPFVec[ngsf],
678  GsfPFVec[igsf],
679  nElSeedRef,
680  iElSeedRef,
681  theEClus,
682  isBothGsfTrackerDriven,
683  nEcalDriven,
684  iEcalDriven,
685  nETot,
686  iETot);
687 
688  // check if the first hit of iGsfTrack < nGsfTrack
689  bool isSameLayer = false;
690  bool iGsfInnermostWithLostHits =
691  isInnerMostWithLostHits(nGsfTrack,iGsfTrack,isSameLayer);
692 
693  if(isSameScEgPf) {
694  // CASE 2 : One Gsf has reference to a SC and the other one not or both not
695 
696  if(debugCleaning) {
697  cout << " Sharing ECAL energy passed "
698  << " nEtot " << nETot
699  << " iEtot " << iETot << endl;
700  if(isBothGsfTrackerDriven)
701  cout << " Both Track are trackerDriven " << endl;
702  }
703 
704  // Innermost using LostHits technology
705  if (iGsfInnermostWithLostHits) {
706  n_keepGsf = false;
707  return n_keepGsf;
708  }
709  else if(isSameLayer){
710  // Thirt Case: One Gsf has reference to a SC and the other one not or both not
711  // gsf tracks starts from the same layer
712  // check number of sharing modules (at least 50%)
713  // check number of sharing hits (at least 2)
714  // check charge flip inner/outer
715 
716 
717  // they share energy
718  if(isBothGsfTrackerDriven == false) {
719  // if at least one Gsf track is EcalDriven choose that one.
720  if(iEcalDriven) {
721  n_keepGsf = false;
722  return n_keepGsf;
723  }
724  else {
725  secondaries.push_back(igsf);
726  }
727  }
728  else {
729  // if both tracks are tracker driven choose that one with the best E/p
730  // with ETot = max(En,Ei)
731 
732  float ETot = -1;
733  if(nETot != iETot) {
734  if(nETot > iETot)
735  ETot = nETot;
736  else
737  ETot = iETot;
738  }
739  else {
740  ETot = nETot;
741  }
742  float nEP = ETot/nPin;
743  float iEP = ETot/iPin;
744 
745 
746  if(debugCleaning)
747  cout << " nETot " << nETot
748  << " iETot " << iETot
749  << " ETot " << ETot << endl
750  << " nPin " << nPin
751  << " iPin " << iPin
752  << " nEP " << nEP
753  << " iEP " << iEP << endl;
754 
755 
756  if(fabs(iEP-1) < fabs(nEP-1)) {
757  n_keepGsf = false;
758  return n_keepGsf;
759  }
760  else{
761  secondaries.push_back(igsf);
762  }
763  }
764  }
765  else {
766  secondaries.push_back(igsf);
767  }
768  }
769  else if(feta < detaCutGsfClean_ && minBremDphi < dphiCutGsfClean_) {
770  // very close tracks
771  bool secPushedBack = false;
772  if(nEcalDriven == false && nETot == 0.) {
773  n_keepGsf = false;
774  return n_keepGsf;
775  }
776  else if(iEcalDriven == false && iETot == 0.) {
777  secondaries.push_back(igsf);
778  secPushedBack = true;
779  }
780  if(debugCleaning)
781  cout << " Close Tracks "
782  << " feta " << feta << " fabs(fphi) " << fabs(fphi)
783  << " minBremDphi " << minBremDphi
784  << " nETot " << nETot
785  << " iETot " << iETot
786  << " nLostHits " << nGsfTrack->hitPattern().numberOfLostHits(HitPattern::MISSING_INNER_HITS)
787  << " iLostHits " << iGsfTrack->hitPattern().numberOfLostHits(HitPattern::MISSING_INNER_HITS) << endl;
788 
789  // apply selection only if one track has lost hits
791  if (iGsfInnermostWithLostHits) {
792  n_keepGsf = false;
793  return n_keepGsf;
794  }
795  else if(isSameLayer == false) {
796  if(secPushedBack == false)
797  secondaries.push_back(igsf);
798  }
799  }
800  }
801  else if(feta < 0.1 && minBremDphi < 0.2){
802  // failed all the conditions, discard only tracker driven tracks
803  // with no PFClusters linked.
804  if(debugCleaning)
805  cout << " Close Tracks and failed all the conditions "
806  << " feta " << feta << " fabs(fphi) " << fabs(fphi)
807  << " minBremDphi " << minBremDphi
808  << " nETot " << nETot
809  << " iETot " << iETot
810  << " nLostHits " << nGsfTrack->hitPattern().numberOfLostHits(HitPattern::MISSING_INNER_HITS)
811  << " iLostHits " << iGsfTrack->hitPattern().numberOfLostHits(HitPattern::MISSING_INNER_HITS) << endl;
812 
813  if(nEcalDriven == false && nETot == 0.) {
814  n_keepGsf = false;
815  return n_keepGsf;
816  }
817  // Here I do not push back the secondary because considered fakes...
818  }
819  }
820  }
821  }
822  }
823 
824  return n_keepGsf;
825 }
826 float
828  const reco::GsfPFRecTrack& secGsf) {
829 
830  float minDphi = 1000.;
831 
832 
833  std::vector<reco::PFBrem> primPFBrem = primGsf.PFRecBrem();
834  std::vector<reco::PFBrem> secPFBrem = secGsf.PFRecBrem();
835 
836 
837  unsigned int cbrem = 0;
838  for (unsigned isbrem = 0; isbrem < secPFBrem.size(); isbrem++) {
839  if(secPFBrem[isbrem].indTrajPoint() == 99) continue;
840  const reco::PFTrajectoryPoint& atSecECAL
841  = secPFBrem[isbrem].extrapolatedPoint( reco::PFTrajectoryPoint::ECALEntrance );
842  if( ! atSecECAL.isValid() ) continue;
843  float secPhi = atSecECAL.positionREP().Phi();
844 
845  unsigned int sbrem = 0;
846  for(unsigned ipbrem = 0; ipbrem < primPFBrem.size(); ipbrem++) {
847  if(primPFBrem[ipbrem].indTrajPoint() == 99) continue;
848  const reco::PFTrajectoryPoint& atPrimECAL
849  = primPFBrem[ipbrem].extrapolatedPoint( reco::PFTrajectoryPoint::ECALEntrance );
850  if( ! atPrimECAL.isValid() ) continue;
851  sbrem++;
852  if(sbrem <= 3) {
853  float primPhi = atPrimECAL.positionREP().Phi();
854 
855  float dphi = fabs(primPhi - secPhi);
856  if (dphi>TMath::Pi()) dphi-= TMath::TwoPi();
857  if(fabs(dphi) < minDphi) {
858  minDphi = fabs(dphi);
859  }
860  }
861  }
862 
863 
864  cbrem++;
865  if(cbrem == 3)
866  break;
867  }
868  return minDphi;
869 }
870 bool
872  const reco::ElectronSeedRef& iSeedRef,
873  bool& bothGsfEcalDriven,
874  float& SCEnergy) {
875 
876  bool isSameSC = false;
877 
878  if(nSeedRef->caloCluster().isNonnull() && iSeedRef->caloCluster().isNonnull()) {
879  SuperClusterRef nscRef = nSeedRef->caloCluster().castTo<SuperClusterRef>();
880  SuperClusterRef iscRef = iSeedRef->caloCluster().castTo<SuperClusterRef>();
881 
882  if(nscRef.isNonnull() && iscRef.isNonnull()) {
883  bothGsfEcalDriven = true;
884  if(nscRef == iscRef) {
885  isSameSC = true;
886  // retrieve the supercluster energy
887  SCEnergy = nscRef->energy();
888  }
889  }
890  }
891  return isSameSC;
892 }
893 bool
895  const reco::GsfPFRecTrack& iGsfPFRecTrack,
896  const reco::ElectronSeedRef& nSeedRef,
897  const reco::ElectronSeedRef& iSeedRef,
898  const reco::PFClusterCollection& theEClus,
899  bool& bothGsfTrackerDriven,
900  bool& nEcalDriven,
901  bool& iEcalDriven,
902  float& nEnergy,
903  float& iEnergy) {
904 
905  bool isSharingEnergy = false;
906 
907  //which is EcalDriven?
908  bool oneEcalDriven = true;
909  SuperClusterRef scRef;
910  GsfPFRecTrack gsfPfTrack;
911 
912  if(nSeedRef->caloCluster().isNonnull()) {
913  scRef = nSeedRef->caloCluster().castTo<SuperClusterRef>();
914  nEnergy = scRef->energy();
915  nEcalDriven = true;
916  gsfPfTrack = iGsfPFRecTrack;
917  }
918  else if(iSeedRef->caloCluster().isNonnull()){
919  scRef = iSeedRef->caloCluster().castTo<SuperClusterRef>();
920  iEnergy = scRef->energy();
921  iEcalDriven = true;
922  gsfPfTrack = nGsfPFRecTrack;
923  }
924  else{
925  oneEcalDriven = false;
926  }
927 
928  if(oneEcalDriven) {
929  //run a basic reconstruction for the particle flow
930 
931  vector<PFCluster> vecPFClusters;
932  vecPFClusters.clear();
933 
934  for (PFClusterCollection::const_iterator clus = theEClus.begin();
935  clus != theEClus.end();
936  clus++ ) {
937  PFCluster clust = *clus;
938  clust.calculatePositionREP();
939 
940  float deta = fabs(scRef->position().eta() - clust.position().eta());
941  float dphi = fabs(scRef->position().phi() - clust.position().phi());
942  if (dphi>TMath::Pi()) dphi-= TMath::TwoPi();
943 
944  // Angle preselection between the supercluster and pfclusters
945  // this is needed just to save some cpu-time for this is hard-coded
946  if(deta < 0.5 && fabs(dphi) < 1.0) {
947  bool foundLink = false;
948  double distGsf = gsfPfTrack.extrapolatedPoint( reco::PFTrajectoryPoint::ECALShowerMax ).isValid() ?
949  LinkByRecHit::testTrackAndClusterByRecHit(gsfPfTrack , clust ) : -1.;
950  // check if it touch the GsfTrack
951  if(distGsf > 0.) {
952  if(nEcalDriven)
953  iEnergy += clust.energy();
954  else
955  nEnergy += clust.energy();
956  vecPFClusters.push_back(clust);
957  foundLink = true;
958  }
959  // check if it touch the Brem-tangents
960  if(foundLink == false) {
961  vector<PFBrem> primPFBrem = gsfPfTrack.PFRecBrem();
962  for(unsigned ipbrem = 0; ipbrem < primPFBrem.size(); ipbrem++) {
963  if(primPFBrem[ipbrem].indTrajPoint() == 99) continue;
964  const reco::PFRecTrack& pfBremTrack = primPFBrem[ipbrem];
965  double dist = pfBremTrack.extrapolatedPoint( reco::PFTrajectoryPoint::ECALShowerMax ).isValid() ?
966  LinkByRecHit::testTrackAndClusterByRecHit(pfBremTrack , clust, true ) : -1.;
967  if(dist > 0.) {
968  if(nEcalDriven)
969  iEnergy += clust.energy();
970  else
971  nEnergy += clust.energy();
972  vecPFClusters.push_back(clust);
973  foundLink = true;
974  }
975  }
976  }
977  } // END if anble preselection
978  } // PFClusters Loop
979  if(vecPFClusters.size() > 0 ) {
980  for(unsigned int pf = 0; pf < vecPFClusters.size(); pf++) {
981  bool isCommon = ClusterClusterMapping::overlap(vecPFClusters[pf],*scRef);
982  if(isCommon) {
983  isSharingEnergy = true;
984  }
985  break;
986  }
987  }
988  }
989  else {
990  // both tracks are trackerDriven, try ECAL energy matching also in this case.
991 
992  bothGsfTrackerDriven = true;
993  vector<PFCluster> nPFCluster;
994  vector<PFCluster> iPFCluster;
995 
996  nPFCluster.clear();
997  iPFCluster.clear();
998 
999  for (PFClusterCollection::const_iterator clus = theEClus.begin();
1000  clus != theEClus.end();
1001  clus++ ) {
1002  PFCluster clust = *clus;
1003  clust.calculatePositionREP();
1004 
1005  float ndeta = fabs(nGsfPFRecTrack.gsfTrackRef()->eta() - clust.position().eta());
1006  float ndphi = fabs(nGsfPFRecTrack.gsfTrackRef()->phi() - clust.position().phi());
1007  if (ndphi>TMath::Pi()) ndphi-= TMath::TwoPi();
1008  // Apply loose preselection with the track
1009  // just to save cpu time, for this hard-coded
1010  if(ndeta < 0.5 && fabs(ndphi) < 1.0) {
1011  bool foundNLink = false;
1012 
1013  double distGsf = nGsfPFRecTrack.extrapolatedPoint( reco::PFTrajectoryPoint::ECALShowerMax ).isValid() ?
1014  LinkByRecHit::testTrackAndClusterByRecHit(nGsfPFRecTrack , clust ) : -1.;
1015  if(distGsf > 0.) {
1016  nPFCluster.push_back(clust);
1017  nEnergy += clust.energy();
1018  foundNLink = true;
1019  }
1020  if(foundNLink == false) {
1021  const vector<PFBrem>& primPFBrem = nGsfPFRecTrack.PFRecBrem();
1022  for(unsigned ipbrem = 0; ipbrem < primPFBrem.size(); ipbrem++) {
1023  if(primPFBrem[ipbrem].indTrajPoint() == 99) continue;
1024  const reco::PFRecTrack& pfBremTrack = primPFBrem[ipbrem];
1025  if(foundNLink == false) {
1026  double dist = pfBremTrack.extrapolatedPoint( reco::PFTrajectoryPoint::ECALShowerMax ).isValid() ?
1027  LinkByRecHit::testTrackAndClusterByRecHit(pfBremTrack , clust, true ) : -1.;
1028  if(dist > 0.) {
1029  nPFCluster.push_back(clust);
1030  nEnergy += clust.energy();
1031  foundNLink = true;
1032  }
1033  }
1034  }
1035  }
1036  }
1037 
1038  float ideta = fabs(iGsfPFRecTrack.gsfTrackRef()->eta() - clust.position().eta());
1039  float idphi = fabs(iGsfPFRecTrack.gsfTrackRef()->phi() - clust.position().phi());
1040  if (idphi>TMath::Pi()) idphi-= TMath::TwoPi();
1041  // Apply loose preselection with the track
1042  // just to save cpu time, for this hard-coded
1043  if(ideta < 0.5 && fabs(idphi) < 1.0) {
1044  bool foundILink = false;
1045  double dist = iGsfPFRecTrack.extrapolatedPoint( reco::PFTrajectoryPoint::ECALShowerMax ).isValid() ?
1046  LinkByRecHit::testTrackAndClusterByRecHit(iGsfPFRecTrack , clust ) : -1.;
1047  if(dist > 0.) {
1048  iPFCluster.push_back(clust);
1049  iEnergy += clust.energy();
1050  foundILink = true;
1051  }
1052  if(foundILink == false) {
1053  vector<PFBrem> primPFBrem = iGsfPFRecTrack.PFRecBrem();
1054  for(unsigned ipbrem = 0; ipbrem < primPFBrem.size(); ipbrem++) {
1055  if(primPFBrem[ipbrem].indTrajPoint() == 99) continue;
1056  const reco::PFRecTrack& pfBremTrack = primPFBrem[ipbrem];
1057  if(foundILink == false) {
1058  double dist = LinkByRecHit::testTrackAndClusterByRecHit(pfBremTrack , clust, true );
1059  if(dist > 0.) {
1060  iPFCluster.push_back(clust);
1061  iEnergy += clust.energy();
1062  foundILink = true;
1063  }
1064  }
1065  }
1066  }
1067  }
1068  }
1069 
1070 
1071  if(nPFCluster.size() > 0 && iPFCluster.size() > 0) {
1072  for(unsigned int npf = 0; npf < nPFCluster.size(); npf++) {
1073  for(unsigned int ipf = 0; ipf < iPFCluster.size(); ipf++) {
1074  bool isCommon = ClusterClusterMapping::overlap(nPFCluster[npf],iPFCluster[ipf]);
1075  if(isCommon) {
1076  isSharingEnergy = true;
1077  break;
1078  }
1079  }
1080  if(isSharingEnergy)
1081  break;
1082  }
1083  }
1084  }
1085 
1086  return isSharingEnergy;
1087 }
1089  const reco::GsfTrackRef& iGsfTrack,
1090  bool& sameLayer) {
1091 
1092  // copied by the class RecoEgamma/EgammaElectronAlgos/src/EgAmbiguityTools.cc
1093  // obsolete but the code is kept: now using lost hits method
1094 
1095  const reco::HitPattern &gsfHitPattern1 = nGsfTrack->hitPattern();
1096  const reco::HitPattern &gsfHitPattern2 = iGsfTrack->hitPattern();
1097 
1098  // retrieve first valid hit
1099  int gsfHitCounter1 = 0 ;
1100  trackingRecHit_iterator elHitsIt1 ;
1101  for
1102  ( elHitsIt1 = nGsfTrack->recHitsBegin() ;
1103  elHitsIt1 != nGsfTrack->recHitsEnd() ;
1104  elHitsIt1++, gsfHitCounter1++ )
1105  { if (((**elHitsIt1).isValid())) break ; }
1106 
1107  int gsfHitCounter2 = 0 ;
1108  trackingRecHit_iterator elHitsIt2 ;
1109  for
1110  ( elHitsIt2 = iGsfTrack->recHitsBegin() ;
1111  elHitsIt2 != iGsfTrack->recHitsEnd() ;
1112  elHitsIt2++, gsfHitCounter2++ )
1113  { if (((**elHitsIt2).isValid())) break ; }
1114 
1115  uint32_t gsfHit1 = gsfHitPattern1.getHitPattern(HitPattern::TRACK_HITS, gsfHitCounter1) ;
1116  uint32_t gsfHit2 = gsfHitPattern2.getHitPattern(HitPattern::TRACK_HITS, gsfHitCounter2) ;
1117 
1118 
1119  if (gsfHitPattern1.getSubStructure(gsfHit1)!=gsfHitPattern2.getSubStructure(gsfHit2))
1120  {
1121  return (gsfHitPattern2.getSubStructure(gsfHit2)<gsfHitPattern1.getSubStructure(gsfHit1));
1122  }
1123  else if (gsfHitPattern1.getLayer(gsfHit1)!=gsfHitPattern2.getLayer(gsfHit2))
1124  {
1125  return (gsfHitPattern2.getLayer(gsfHit2)<gsfHitPattern1.getLayer(gsfHit1));
1126  }
1127  else
1128  {
1129  sameLayer = true;
1130  return false;
1131  }
1132 }
1134  const reco::GsfTrackRef& iGsfTrack,
1135  bool& sameLayer) {
1136 
1137  // define closest using the lost hits on the expectedhitsineer
1138  unsigned int nLostHits = nGsfTrack->hitPattern().numberOfLostHits(HitPattern::MISSING_INNER_HITS);
1139  unsigned int iLostHits = iGsfTrack->hitPattern().numberOfLostHits(HitPattern::MISSING_INNER_HITS);
1140 
1141  if (nLostHits!=iLostHits) {
1142  return (nLostHits > iLostHits);
1143  }
1144  else {
1145  sameLayer = true;
1146  return false;
1147  }
1148 }
1149 
1150 
1151 
1152 // ------------ method called once each job just before starting event loop ------------
1153 void
1155  const EventSetup& iSetup)
1156 {
1157  ESHandle<MagneticField> magneticField;
1158  iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
1159 
1161  iSetup.get<TrackerDigiGeometryRecord>().get(tracker);
1162 
1163 
1164  mtsTransform_ = MultiTrajectoryStateTransform(tracker.product(),magneticField.product());
1165 
1166 
1167  pfTransformer_= new PFTrackTransformer(math::XYZVector(magneticField->inTesla(GlobalPoint(0,0,0))));
1168 
1169 
1171  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder", builder);
1172  TransientTrackBuilder thebuilder = *(builder.product());
1173 
1174 
1175  if(useConvBremFinder_) {
1176  vector <TString> weightfiles;
1177  weightfiles.push_back(path_mvaWeightFileConvBremBarrelLowPt_.c_str());
1178  weightfiles.push_back(path_mvaWeightFileConvBremBarrelHighPt_.c_str());
1179  weightfiles.push_back(path_mvaWeightFileConvBremEndcapsLowPt_.c_str());
1180  weightfiles.push_back(path_mvaWeightFileConvBremEndcapsHighPt_.c_str());
1181  for(uint iter = 0;iter<weightfiles.size();iter++){
1182  FILE * fileConvBremID = fopen(weightfiles[iter],"r");
1183  if (fileConvBremID) {
1184  fclose(fileConvBremID);
1185  }
1186  else {
1187  string err = "PFElecTkProducer: cannot open weight file '";
1188  err += weightfiles[iter];
1189  err += "'";
1190  throw invalid_argument( err );
1191  }
1192  }
1193 
1194  }
1195  convBremFinder_ = new ConvBremPFTrackFinder(thebuilder,
1204 
1205 }
1206 
1207 // ------------ method called once each job just after ending the event loop ------------
1208 void
1210  const EventSetup& iSetup) {
1211  delete pfTransformer_;
1212  pfTransformer_=nullptr;
1213  delete convBremFinder_;
1214  convBremFinder_=nullptr;
1215 }
1216 
1217 //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 uint32_t getLayer(uint16_t pattern)
Definition: HitPattern.h:627
static bool overlap(const reco::CaloCluster &sc1, const reco::CaloCluster &sc, float minfrac=0.01, bool debug=false)
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
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)
tuple pfV0
Definition: pfV0_cfi.py:3
const TrackExtraRef & extra() const
reference to &quot;extra&quot; object
Definition: Track.h:189
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:446
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:621
bool applySelection(const reco::GsfTrack &)
~PFElecTkProducer()
Destructor.
bool momentumFromModeCartesian(const TrajectoryStateOnSurface tsos, GlobalVector &momentum) const
reco::GsfPFRecTrack secpftrack_
int ii
Definition: cuy.py:588
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)
PFElecTkProducer(const edm::ParameterSet &)
Constructor.
int iEvent
Definition: GenABIO.cc:230
T mag() const
Definition: PV3DBase.h:67
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:627
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:93
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
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
edm::EDGetTokenT< reco::PFDisplacedTrackerVertexCollection > pfNuclear_
const reco::PFTrajectoryPoint & extrapolatedPoint(unsigned layerid) const
Definition: PFTrack.cc:76
bool isNull() const
Checks for null.
Definition: Ref.h:247
static uint32_t getSubStructure(uint16_t pattern)
Definition: HitPattern.h:618
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:213
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 ?
T const * product() const
Definition: Handle.h:81
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:86
range recHits() const
double mvaConvBremFinderIDBarrelHighPt_
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...
uint16_t getHitPattern(HitCategory category, int position) const
Definition: HitPattern.h:448
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)