CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
std::pair< reco::TrackRef, float > getClosestCtfToGsf(reco::GsfTrackRef const &, edm::Handle< reco::TrackCollection > const &ctfTracksH, edm::soa::EtaPhiTableView trackEtaPhiTable)
static bool pixelHitFilter(uint16_t pattern)
Definition: HitPattern.h:575
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
uint16_t hitPattern[ARRAY_LENGTH]
Definition: HitPattern.h:490
T min(T a, T b)
Definition: MathUtil.h:58
edm::soa::ViewFromTable_t< EtaPhiTable > EtaPhiTableView
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
T const * product() const
Definition: Handle.h:70
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
static bool stripTIBHitFilter(uint16_t pattern)
Definition: HitPattern.h:614
static std::atomic< unsigned int > counter
uint16_t getHitPattern(HitCategory category, int position) const
Definition: HitPattern.h:531
static bool stripTIDHitFilter(uint16_t pattern)
Definition: HitPattern.h:618
int col
Definition: cuy.py:1009