CMS 3D CMS Logo

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