CMS 3D CMS Logo

GsfElectronTools.cc
Go to the documentation of this file.
8 
9 namespace egamma {
10 
11  using namespace reco;
12 
13  //=======================================================================================
14  // Code from Puneeth Kalavase
15  //=======================================================================================
16 
17  std::pair<TrackRef, float> getClosestCtfToGsf(GsfTrackRef const& gsfTrackRef,
18  edm::Handle<reco::TrackCollection> const& ctfTracksH) {
19  float maxFracShared = 0;
20  TrackRef ctfTrackRef = TrackRef();
21  const TrackCollection* ctfTrackCollection = ctfTracksH.product();
22 
23  // get the Hit Pattern for the gsfTrack
24  const HitPattern& gsfHitPattern = gsfTrackRef->hitPattern();
25 
26  unsigned int counter = 0;
27  for (auto ctfTkIter = ctfTrackCollection->begin(); ctfTkIter != ctfTrackCollection->end(); ctfTkIter++, counter++) {
28  double dEta = gsfTrackRef->eta() - ctfTkIter->eta();
29  double dPhi = gsfTrackRef->phi() - ctfTkIter->phi();
30  double pi = acos(-1.);
31  if (std::abs(dPhi) > pi)
32  dPhi = 2 * pi - std::abs(dPhi);
33 
34  // dont want to look at every single track in the event!
35  if (sqrt(dEta * dEta + dPhi * dPhi) > 0.3)
36  continue;
37 
38  unsigned int shared = 0;
39  int gsfHitCounter = 0;
40  int numGsfInnerHits = 0;
41  int numCtfInnerHits = 0;
42  // get the CTF Track Hit Pattern
43  const HitPattern& ctfHitPattern = ctfTkIter->hitPattern();
44 
45  for (auto elHitsIt = gsfTrackRef->recHitsBegin(); elHitsIt != gsfTrackRef->recHitsEnd();
46  elHitsIt++, gsfHitCounter++) {
47  if (!((**elHitsIt).isValid())) //count only valid Hits
48  {
49  continue;
50  }
51 
52  // look only in the pixels/TIB/TID
53  uint32_t gsfHit = gsfHitPattern.getHitPattern(HitPattern::TRACK_HITS, gsfHitCounter);
56  continue;
57  }
58 
59  numGsfInnerHits++;
60 
61  int ctfHitsCounter = 0;
62  numCtfInnerHits = 0;
63  for (auto ctfHitsIt = ctfTkIter->recHitsBegin(); ctfHitsIt != ctfTkIter->recHitsEnd();
64  ctfHitsIt++, ctfHitsCounter++) {
65  if (!((**ctfHitsIt).isValid())) //count only valid Hits!
66  {
67  continue;
68  }
69 
70  uint32_t ctfHit = ctfHitPattern.getHitPattern(HitPattern::TRACK_HITS, ctfHitsCounter);
73  continue;
74  }
75 
76  numCtfInnerHits++;
77 
78  if ((**elHitsIt).sharesInput(&(**ctfHitsIt), TrackingRecHit::all)) {
79  shared++;
80  break;
81  }
82 
83  } //ctfHits iterator
84 
85  } //gsfHits iterator
86 
87  if ((numGsfInnerHits == 0) || (numCtfInnerHits == 0)) {
88  continue;
89  }
90 
91  if (static_cast<float>(shared) / std::min(numGsfInnerHits, numCtfInnerHits) > maxFracShared) {
92  maxFracShared = static_cast<float>(shared) / std::min(numGsfInnerHits, numCtfInnerHits);
93  ctfTrackRef = TrackRef(ctfTracksH, counter);
94  }
95 
96  } //ctfTrack iterator
97 
98  return make_pair(ctfTrackRef, maxFracShared);
99  }
100 
101 } // namespace egamma
reco::HitPattern::getHitPattern
uint16_t getHitPattern(HitCategory category, int position) const
Definition: HitPattern.h:530
GsfElectronCore.h
counter
Definition: counter.py:1
edm::Handle::product
T const * product() const
Definition: Handle.h:70
GsfElectronTools.h
min
T min(T a, T b)
Definition: MathUtil.h:58
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::Handle< reco::TrackCollection >
reco::HitPattern::stripTIBHitFilter
static bool stripTIBHitFilter(uint16_t pattern)
Definition: HitPattern.h:608
HLT_2018_cff.dEta
dEta
Definition: HLT_2018_cff.py:12289
ElectronSeedFwd.h
edm::Ref< GsfTrackCollection >
reco::HitPattern
Definition: HitPattern.h:147
reco::HitPattern::stripTIDHitFilter
static bool stripTIDHitFilter(uint16_t pattern)
Definition: HitPattern.h:612
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
HLT_2018_cff.dPhi
dPhi
Definition: HLT_2018_cff.py:12290
GsfElectronCoreFwd.h
reco::TrackRef
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
reco::HitPattern::pixelHitFilter
static bool pixelHitFilter(uint16_t pattern)
Definition: HitPattern.h:573
TrackingRecHit::all
Definition: TrackingRecHit.h:59
GsfTrack.h
reco::HitPattern::TRACK_HITS
Definition: HitPattern.h:155
egamma
Definition: EgAmbiguityTools.h:10
pi
const Double_t pi
Definition: trackSplitPlot.h:36
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
GsfPFRecTrack.h
reco::HitPattern::hitPattern
uint16_t hitPattern[ARRAY_LENGTH]
Definition: HitPattern.h:490
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
ElectronSeed.h
egamma::getClosestCtfToGsf
std::pair< reco::TrackRef, float > getClosestCtfToGsf(reco::GsfTrackRef const &, edm::Handle< reco::TrackCollection > const &ctfTracksH)
Definition: GsfElectronTools.cc:17