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  auto const& SeedFromRef= dynamic_cast<ElectronSeed const&>(*(trackRef->extra()->seedRef()) );
220  if(SeedFromRef.caloCluster().isNull())
221  isEcalDriven = false;
222  if(SeedFromRef.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  auto const & ElSeedFromRef=dynamic_cast<ElectronSeed const&>( *(gsftk.extra()->seedRef()) );
415  //CASE 1 ELECTRONSEED DOES NOT HAVE A REF TO THE CKFTRACK
416  if (ElSeedFromRef.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()==ElSeedFromRef.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:
501  case TrackBase::lowPtTripletStep:
502  case TrackBase::pixelPairStep:
503  case TrackBase::jetCoreRegionalStep:
504  case TrackBase::muonSeededStepInOut:
505  case TrackBase::muonSeededStepOutIn:
506  Algo = 0;
507  break;
509  Algo = 1;
510  break;
512  Algo = 2;
513  break;
515  Algo = 3;
516  break;
517  case TrackBase::tobTecStep:
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  auto const& ElSeedFromRef=dynamic_cast<ElectronSeed const&>( *(gsftk.extra()->seedRef()) );
535 
536  bool passCut = false;
537  if (ElSeedFromRef.ctfTrack().isNull()){
538  if(ElSeedFromRef.caloCluster().isNull()) return passCut;
539  auto const* scRef = dynamic_cast<SuperCluster const*>(ElSeedFromRef.caloCluster().get());
540  //do this just to know if exist a SC?
541  if(scRef) {
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  auto const& nElSeedFromRef=dynamic_cast<ElectronSeed const&>( *(nGsfTrack->extra()->seedRef()) );
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  auto const& iElSeedFromRef=dynamic_cast<ElectronSeed const&>( *(iGsfTrack->extra()->seedRef()) );
619 
620  float SCEnergy = -1.;
621  // Check if two tracks match the same SC
622  bool areBothGsfEcalDriven = false;;
623  bool isSameSC = isSameEgSC(nElSeedFromRef,iElSeedFromRef,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  nElSeedFromRef,
680  iElSeedFromRef,
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::ElectronSeed& iSeed,
873  bool& bothGsfEcalDriven,
874  float& SCEnergy) {
875 
876  bool isSameSC = false;
877 
878  if(nSeed.caloCluster().isNonnull() && iSeed.caloCluster().isNonnull()) {
879  auto const* nscRef = dynamic_cast<SuperCluster const*>(nSeed.caloCluster().get());
880  auto const* iscRef = dynamic_cast<SuperCluster const*>(iSeed.caloCluster().get());
881 
882  if(nscRef && iscRef) {
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::ElectronSeed& nSeed,
897  const reco::ElectronSeed& iSeed,
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  SuperCluster const* scRef = nullptr;
910  GsfPFRecTrack gsfPfTrack;
911 
912  if(nSeed.caloCluster().isNonnull()) {
913  scRef = dynamic_cast<SuperCluster const*>(nSeed.caloCluster().get());
914  assert(scRef);
915  nEnergy = scRef->energy();
916  nEcalDriven = true;
917  gsfPfTrack = iGsfPFRecTrack;
918  }
919  else if(iSeed.caloCluster().isNonnull()){
920  scRef = dynamic_cast<SuperCluster const*>(iSeed.caloCluster().get());
921  assert(scRef);
922  iEnergy = scRef->energy();
923  iEcalDriven = true;
924  gsfPfTrack = nGsfPFRecTrack;
925  }
926  else{
927  oneEcalDriven = false;
928  }
929 
930  if(oneEcalDriven) {
931  //run a basic reconstruction for the particle flow
932 
933  vector<PFCluster> vecPFClusters;
934  vecPFClusters.clear();
935 
936  for (PFClusterCollection::const_iterator clus = theEClus.begin();
937  clus != theEClus.end();
938  clus++ ) {
939  PFCluster clust = *clus;
940  clust.calculatePositionREP();
941 
942  float deta = fabs(scRef->position().eta() - clust.position().eta());
943  float dphi = fabs(scRef->position().phi() - clust.position().phi());
944  if (dphi>TMath::Pi()) dphi-= TMath::TwoPi();
945 
946  // Angle preselection between the supercluster and pfclusters
947  // this is needed just to save some cpu-time for this is hard-coded
948  if(deta < 0.5 && fabs(dphi) < 1.0) {
949  bool foundLink = false;
950  double distGsf = gsfPfTrack.extrapolatedPoint( reco::PFTrajectoryPoint::ECALShowerMax ).isValid() ?
951  LinkByRecHit::testTrackAndClusterByRecHit(gsfPfTrack , clust ) : -1.;
952  // check if it touch the GsfTrack
953  if(distGsf > 0.) {
954  if(nEcalDriven)
955  iEnergy += clust.energy();
956  else
957  nEnergy += clust.energy();
958  vecPFClusters.push_back(clust);
959  foundLink = true;
960  }
961  // check if it touch the Brem-tangents
962  if(foundLink == false) {
963  vector<PFBrem> primPFBrem = gsfPfTrack.PFRecBrem();
964  for(unsigned ipbrem = 0; ipbrem < primPFBrem.size(); ipbrem++) {
965  if(primPFBrem[ipbrem].indTrajPoint() == 99) continue;
966  const reco::PFRecTrack& pfBremTrack = primPFBrem[ipbrem];
967  double dist = pfBremTrack.extrapolatedPoint( reco::PFTrajectoryPoint::ECALShowerMax ).isValid() ?
968  LinkByRecHit::testTrackAndClusterByRecHit(pfBremTrack , clust, true ) : -1.;
969  if(dist > 0.) {
970  if(nEcalDriven)
971  iEnergy += clust.energy();
972  else
973  nEnergy += clust.energy();
974  vecPFClusters.push_back(clust);
975  foundLink = true;
976  }
977  }
978  }
979  } // END if anble preselection
980  } // PFClusters Loop
981  if(vecPFClusters.size() > 0 ) {
982  for(unsigned int pf = 0; pf < vecPFClusters.size(); pf++) {
983  bool isCommon = ClusterClusterMapping::overlap(vecPFClusters[pf],*scRef);
984  if(isCommon) {
985  isSharingEnergy = true;
986  }
987  break;
988  }
989  }
990  }
991  else {
992  // both tracks are trackerDriven, try ECAL energy matching also in this case.
993 
994  bothGsfTrackerDriven = true;
995  vector<PFCluster> nPFCluster;
996  vector<PFCluster> iPFCluster;
997 
998  nPFCluster.clear();
999  iPFCluster.clear();
1000 
1001  for (PFClusterCollection::const_iterator clus = theEClus.begin();
1002  clus != theEClus.end();
1003  clus++ ) {
1004  PFCluster clust = *clus;
1005  clust.calculatePositionREP();
1006 
1007  float ndeta = fabs(nGsfPFRecTrack.gsfTrackRef()->eta() - clust.position().eta());
1008  float ndphi = fabs(nGsfPFRecTrack.gsfTrackRef()->phi() - clust.position().phi());
1009  if (ndphi>TMath::Pi()) ndphi-= TMath::TwoPi();
1010  // Apply loose preselection with the track
1011  // just to save cpu time, for this hard-coded
1012  if(ndeta < 0.5 && fabs(ndphi) < 1.0) {
1013  bool foundNLink = false;
1014 
1015  double distGsf = nGsfPFRecTrack.extrapolatedPoint( reco::PFTrajectoryPoint::ECALShowerMax ).isValid() ?
1016  LinkByRecHit::testTrackAndClusterByRecHit(nGsfPFRecTrack , clust ) : -1.;
1017  if(distGsf > 0.) {
1018  nPFCluster.push_back(clust);
1019  nEnergy += clust.energy();
1020  foundNLink = true;
1021  }
1022  if(foundNLink == false) {
1023  const vector<PFBrem>& primPFBrem = nGsfPFRecTrack.PFRecBrem();
1024  for(unsigned ipbrem = 0; ipbrem < primPFBrem.size(); ipbrem++) {
1025  if(primPFBrem[ipbrem].indTrajPoint() == 99) continue;
1026  const reco::PFRecTrack& pfBremTrack = primPFBrem[ipbrem];
1027  if(foundNLink == false) {
1028  double dist = pfBremTrack.extrapolatedPoint( reco::PFTrajectoryPoint::ECALShowerMax ).isValid() ?
1029  LinkByRecHit::testTrackAndClusterByRecHit(pfBremTrack , clust, true ) : -1.;
1030  if(dist > 0.) {
1031  nPFCluster.push_back(clust);
1032  nEnergy += clust.energy();
1033  foundNLink = true;
1034  }
1035  }
1036  }
1037  }
1038  }
1039 
1040  float ideta = fabs(iGsfPFRecTrack.gsfTrackRef()->eta() - clust.position().eta());
1041  float idphi = fabs(iGsfPFRecTrack.gsfTrackRef()->phi() - clust.position().phi());
1042  if (idphi>TMath::Pi()) idphi-= TMath::TwoPi();
1043  // Apply loose preselection with the track
1044  // just to save cpu time, for this hard-coded
1045  if(ideta < 0.5 && fabs(idphi) < 1.0) {
1046  bool foundILink = false;
1047  double dist = iGsfPFRecTrack.extrapolatedPoint( reco::PFTrajectoryPoint::ECALShowerMax ).isValid() ?
1048  LinkByRecHit::testTrackAndClusterByRecHit(iGsfPFRecTrack , clust ) : -1.;
1049  if(dist > 0.) {
1050  iPFCluster.push_back(clust);
1051  iEnergy += clust.energy();
1052  foundILink = true;
1053  }
1054  if(foundILink == false) {
1055  vector<PFBrem> primPFBrem = iGsfPFRecTrack.PFRecBrem();
1056  for(unsigned ipbrem = 0; ipbrem < primPFBrem.size(); ipbrem++) {
1057  if(primPFBrem[ipbrem].indTrajPoint() == 99) continue;
1058  const reco::PFRecTrack& pfBremTrack = primPFBrem[ipbrem];
1059  if(foundILink == false) {
1060  double dist = LinkByRecHit::testTrackAndClusterByRecHit(pfBremTrack , clust, true );
1061  if(dist > 0.) {
1062  iPFCluster.push_back(clust);
1063  iEnergy += clust.energy();
1064  foundILink = true;
1065  }
1066  }
1067  }
1068  }
1069  }
1070  }
1071 
1072 
1073  if(nPFCluster.size() > 0 && iPFCluster.size() > 0) {
1074  for(unsigned int npf = 0; npf < nPFCluster.size(); npf++) {
1075  for(unsigned int ipf = 0; ipf < iPFCluster.size(); ipf++) {
1076  bool isCommon = ClusterClusterMapping::overlap(nPFCluster[npf],iPFCluster[ipf]);
1077  if(isCommon) {
1078  isSharingEnergy = true;
1079  break;
1080  }
1081  }
1082  if(isSharingEnergy)
1083  break;
1084  }
1085  }
1086  }
1087 
1088  return isSharingEnergy;
1089 }
1091  const reco::GsfTrackRef& iGsfTrack,
1092  bool& sameLayer) {
1093 
1094  // copied by the class RecoEgamma/EgammaElectronAlgos/src/EgAmbiguityTools.cc
1095  // obsolete but the code is kept: now using lost hits method
1096 
1097  const reco::HitPattern &gsfHitPattern1 = nGsfTrack->hitPattern();
1098  const reco::HitPattern &gsfHitPattern2 = iGsfTrack->hitPattern();
1099 
1100  // retrieve first valid hit
1101  int gsfHitCounter1 = 0 ;
1102  trackingRecHit_iterator elHitsIt1 ;
1103  for
1104  ( elHitsIt1 = nGsfTrack->recHitsBegin() ;
1105  elHitsIt1 != nGsfTrack->recHitsEnd() ;
1106  elHitsIt1++, gsfHitCounter1++ )
1107  { if (((**elHitsIt1).isValid())) break ; }
1108 
1109  int gsfHitCounter2 = 0 ;
1110  trackingRecHit_iterator elHitsIt2 ;
1111  for
1112  ( elHitsIt2 = iGsfTrack->recHitsBegin() ;
1113  elHitsIt2 != iGsfTrack->recHitsEnd() ;
1114  elHitsIt2++, gsfHitCounter2++ )
1115  { if (((**elHitsIt2).isValid())) break ; }
1116 
1117  uint32_t gsfHit1 = gsfHitPattern1.getHitPattern(HitPattern::TRACK_HITS, gsfHitCounter1) ;
1118  uint32_t gsfHit2 = gsfHitPattern2.getHitPattern(HitPattern::TRACK_HITS, gsfHitCounter2) ;
1119 
1120 
1121  if (gsfHitPattern1.getSubStructure(gsfHit1)!=gsfHitPattern2.getSubStructure(gsfHit2))
1122  {
1123  return (gsfHitPattern2.getSubStructure(gsfHit2)<gsfHitPattern1.getSubStructure(gsfHit1));
1124  }
1125  else if (gsfHitPattern1.getLayer(gsfHit1)!=gsfHitPattern2.getLayer(gsfHit2))
1126  {
1127  return (gsfHitPattern2.getLayer(gsfHit2)<gsfHitPattern1.getLayer(gsfHit1));
1128  }
1129  else
1130  {
1131  sameLayer = true;
1132  return false;
1133  }
1134 }
1136  const reco::GsfTrackRef& iGsfTrack,
1137  bool& sameLayer) {
1138 
1139  // define closest using the lost hits on the expectedhitsineer
1140  unsigned int nLostHits = nGsfTrack->hitPattern().numberOfLostHits(HitPattern::MISSING_INNER_HITS);
1141  unsigned int iLostHits = iGsfTrack->hitPattern().numberOfLostHits(HitPattern::MISSING_INNER_HITS);
1142 
1143  if (nLostHits!=iLostHits) {
1144  return (nLostHits > iLostHits);
1145  }
1146  else {
1147  sameLayer = true;
1148  return false;
1149  }
1150 }
1151 
1152 
1153 
1154 // ------------ method called once each job just before starting event loop ------------
1155 void
1157  const EventSetup& iSetup)
1158 {
1160  iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
1161 
1163  iSetup.get<TrackerDigiGeometryRecord>().get(tracker);
1164 
1165 
1166  mtsTransform_ = MultiTrajectoryStateTransform(tracker.product(),magneticField.product());
1167 
1168 
1169  pfTransformer_= new PFTrackTransformer(math::XYZVector(magneticField->inTesla(GlobalPoint(0,0,0))));
1170 
1171 
1173  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder", builder);
1174  TransientTrackBuilder thebuilder = *(builder.product());
1175 
1176 
1177  if(useConvBremFinder_) {
1178  vector <TString> weightfiles;
1179  weightfiles.push_back(path_mvaWeightFileConvBremBarrelLowPt_.c_str());
1180  weightfiles.push_back(path_mvaWeightFileConvBremBarrelHighPt_.c_str());
1181  weightfiles.push_back(path_mvaWeightFileConvBremEndcapsLowPt_.c_str());
1182  weightfiles.push_back(path_mvaWeightFileConvBremEndcapsHighPt_.c_str());
1183  for(uint iter = 0;iter<weightfiles.size();iter++){
1184  FILE * fileConvBremID = fopen(weightfiles[iter],"r");
1185  if (fileConvBremID) {
1186  fclose(fileConvBremID);
1187  }
1188  else {
1189  string err = "PFElecTkProducer: cannot open weight file '";
1190  err += weightfiles[iter];
1191  err += "'";
1192  throw invalid_argument( err );
1193  }
1194  }
1195 
1196  }
1197  convBremFinder_ = new ConvBremPFTrackFinder(thebuilder,
1206 
1207 }
1208 
1209 // ------------ method called once each job just after ending the event loop ------------
1210 void
1212  const EventSetup& iSetup) {
1213  delete pfTransformer_;
1214  pfTransformer_=nullptr;
1215  delete convBremFinder_;
1216  convBremFinder_=nullptr;
1217 }
1218 
1219 //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
value_type const * get() const
Definition: RefToBase.h:212
T getParameter(std::string const &) const
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:126
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:624
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:449
std::string path_mvaWeightFileConvBremEndcapsLowPt_
bool addPointsAndBrems(reco::GsfPFRecTrack &pftrack, const reco::Track &track, const Trajectory &traj, const bool &GetMode) const
ConvBremPFTrackFinder * convBremFinder_
assert(m_qm.get())
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:693
bool applySelection(const reco::GsfTrack &)
bool isNonnull() const
Checks for non-null.
Definition: RefToBase.h:279
~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_
CaloClusterRef caloCluster() const
Definition: ElectronSeed.h:70
const std::vector< reco::PFRecTrackRef > & getConvBremPFRecTracks()
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:699
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:96
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
double energy() const
cluster energy
Definition: CaloCluster.h:121
edm::EDGetTokenT< reco::PFDisplacedTrackerVertexCollection > pfNuclear_
const reco::PFTrajectoryPoint & extrapolatedPoint(unsigned layerid) const
Definition: PFTrack.cc:76
bool isSameEgSC(const reco::ElectronSeed &nSeed, const reco::ElectronSeed &iSeed, bool &bothGsfEcalDriven, float &SCEnergy)
static uint32_t getSubStructure(uint16_t pattern)
Definition: HitPattern.h:615
double energy() const
cluster energy
Definition: PFCluster.h:82
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
string const
Definition: compareJSON.py:14
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
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:456
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_
bool isSharingEcalEnergyWithEgSC(const reco::GsfPFRecTrack &nGsfPFRecTrack, const reco::GsfPFRecTrack &iGsfPFRecTrack, const reco::ElectronSeed &nSeed, const reco::ElectronSeed &iSeed, const reco::PFClusterCollection &theEClus, bool &bothGsfTrackerDriven, bool &nEcalDriven, bool &iEcalDriven, float &nEnergy, float &iEnergy)
Definition: fakeMenu.h:6
TrackingRecHitCollection::base::const_iterator trackingRecHit_iterator
iterator over a vector of reference to TrackingRecHit in the same collection
Definition: Run.h:41
MultiTrajectoryStateTransform mtsTransform_
bool isInnerMost(const reco::GsfTrackRef &nGsfTrack, const reco::GsfTrackRef &iGsfTrack, bool &sameLayer)