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