CMS 3D CMS Logo

GsfElectronTools.cc
Go to the documentation of this file.
7 
8 namespace egamma {
9 
10  using namespace reco;
11 
12  //=======================================================================================
13  // Code from Puneeth Kalavase
14  //=======================================================================================
15 
16  std::pair<TrackRef, float> getClosestCtfToGsf(GsfTrackRef const& gsfTrackRef,
17  edm::Handle<reco::TrackCollection> const& ctfTracksH,
18  edm::soa::EtaPhiTableView trackTable) {
19  float maxFracShared = 0;
20  TrackRef ctfTrackRef = TrackRef();
21  const TrackCollection* ctfTrackCollection = ctfTracksH.product();
22 
23  float gsfEta = gsfTrackRef->eta();
24  float gsfPhi = gsfTrackRef->phi();
25  const HitPattern& gsfHitPattern = gsfTrackRef->hitPattern();
26 
27  constexpr float dR2 = 0.3 * 0.3;
28 
29  unsigned int counter = 0;
30  for (auto ctfTkIter = ctfTrackCollection->begin(); ctfTkIter != ctfTrackCollection->end(); ctfTkIter++, counter++) {
31  // dont want to look at every single track in the event!
32  using namespace edm::soa::col;
33  if (reco::deltaR2(gsfEta, gsfPhi, trackTable.get<Eta>(counter), trackTable.get<Phi>(counter)) > dR2)
34  continue;
35 
36  unsigned int shared = 0;
37  int gsfHitCounter = 0;
38  int numGsfInnerHits = 0;
39  int numCtfInnerHits = 0;
40  // get the CTF Track Hit Pattern
41  const HitPattern& ctfHitPattern = ctfTkIter->hitPattern();
42 
43  for (auto elHitsIt = gsfTrackRef->recHitsBegin(); elHitsIt != gsfTrackRef->recHitsEnd();
44  elHitsIt++, gsfHitCounter++) {
45  if (!((**elHitsIt).isValid())) //count only valid Hits
46  {
47  continue;
48  }
49 
50  // look only in the pixels/TIB/TID
51  uint32_t gsfHit = gsfHitPattern.getHitPattern(HitPattern::TRACK_HITS, gsfHitCounter);
54  continue;
55  }
56 
57  numGsfInnerHits++;
58 
59  int ctfHitsCounter = 0;
60  numCtfInnerHits = 0;
61  for (auto ctfHitsIt = ctfTkIter->recHitsBegin(); ctfHitsIt != ctfTkIter->recHitsEnd();
62  ctfHitsIt++, ctfHitsCounter++) {
63  if (!((**ctfHitsIt).isValid())) //count only valid Hits!
64  {
65  continue;
66  }
67 
68  uint32_t ctfHit = ctfHitPattern.getHitPattern(HitPattern::TRACK_HITS, ctfHitsCounter);
71  continue;
72  }
73 
74  numCtfInnerHits++;
75 
76  if ((**elHitsIt).sharesInput(&(**ctfHitsIt), TrackingRecHit::all)) {
77  shared++;
78  break;
79  }
80 
81  } //ctfHits iterator
82 
83  } //gsfHits iterator
84 
85  if ((numGsfInnerHits == 0) || (numCtfInnerHits == 0)) {
86  continue;
87  }
88 
89  if (static_cast<float>(shared) / std::min(numGsfInnerHits, numCtfInnerHits) > maxFracShared) {
90  maxFracShared = static_cast<float>(shared) / std::min(numGsfInnerHits, numCtfInnerHits);
91  ctfTrackRef = TrackRef(ctfTracksH, counter);
92  }
93 
94  } //ctfTrack iterator
95 
96  return {ctfTrackRef, maxFracShared};
97  }
98 
99 } // namespace egamma
reco::HitPattern::getHitPattern
uint16_t getHitPattern(HitCategory category, int position) const
Definition: HitPattern.h:531
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:46
edm::Handle< reco::TrackCollection >
reco::HitPattern::stripTIBHitFilter
static bool stripTIBHitFilter(uint16_t pattern)
Definition: HitPattern.h:614
edm::soa::EtaPhiTableView
edm::soa::ViewFromTable_t< EtaPhiTable > EtaPhiTableView
Definition: KinematicTables.h:11
edm::Ref< GsfTrackCollection >
reco::HitPattern
Definition: HitPattern.h:147
edm::soa::col
Definition: KinematicColumns.h:8
reco::HitPattern::stripTIDHitFilter
static bool stripTIDHitFilter(uint16_t pattern)
Definition: HitPattern.h:618
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:575
TrackingRecHit::all
Definition: TrackingRecHit.h:59
deltaR.h
reco::deltaR2
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
edm::soa::col::Eta
Definition: KinematicColumns.h:10
GsfTrack.h
reco::HitPattern::TRACK_HITS
Definition: HitPattern.h:155
egamma
Definition: ConversionFinder.h:29
egamma::getClosestCtfToGsf
std::pair< reco::TrackRef, float > getClosestCtfToGsf(reco::GsfTrackRef const &, edm::Handle< reco::TrackCollection > const &ctfTracksH, edm::soa::EtaPhiTableView trackEtaPhiTable)
Definition: GsfElectronTools.cc:16
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
edm::soa::col::Phi
Definition: KinematicColumns.h:11