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