CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
SeedFinder Class Reference

#include <SeedFinder.h>

Public Member Functions

void addHitSelector (SeedFinderSelector *seedFinderSelector, unsigned int nHits)
 
std::vector< unsigned int > getSeed (const std::vector< const FastTrackerRecHit * > &trackerRecHits) const
 
const SeedingNode< TrackingLayer > * insertHit (const std::vector< TrajectorySeedHitCandidate > &trackerRecHits, std::vector< int > &hitIndicesInTree, const SeedingNode< TrackingLayer > *node, unsigned int trackerHit) const
 
std::vector< unsigned int > iterateHits (unsigned int start, const std::vector< TrajectorySeedHitCandidate > &trackerRecHits, std::vector< int > hitIndicesInTree, bool processSkippedHits) const
 
 SeedFinder (const SeedingTree< TrackingLayer > &seedingTree, const TrackerTopology &trackerTopology)
 

Private Attributes

const SeedingTree< TrackingLayer > & _seedingTree
 
std::vector< std::vector< SeedFinderSelector * > > _selectorFunctionsByHits
 
const TrackerTopology_trackerTopology
 

Detailed Description

Definition at line 19 of file SeedFinder.h.

Constructor & Destructor Documentation

SeedFinder::SeedFinder ( const SeedingTree< TrackingLayer > &  seedingTree,
const TrackerTopology trackerTopology 
)
inline

Definition at line 29 of file SeedFinder.h.

29  :
30  _seedingTree(seedingTree),
31  _trackerTopology(&trackerTopology)
32  {
33  }
const SeedingTree< TrackingLayer > & _seedingTree
Definition: SeedFinder.h:25
const TrackerTopology * _trackerTopology
Definition: SeedFinder.h:26

Member Function Documentation

void SeedFinder::addHitSelector ( SeedFinderSelector seedFinderSelector,
unsigned int  nHits 
)
inline

Definition at line 35 of file SeedFinder.h.

36  {
37  if (_selectorFunctionsByHits.size()<nHits)
38  {
39  _selectorFunctionsByHits.resize(nHits);
40  _selectorFunctionsByHits.reserve(nHits);
41  }
42  //shift indices by -1 so that _selectorFunctionsByHits[0] tests 1 hit
43  _selectorFunctionsByHits[nHits-1].push_back(seedFinderSelector);
44  }
std::vector< std::vector< SeedFinderSelector * > > _selectorFunctionsByHits
Definition: SeedFinder.h:24
std::vector<unsigned int> SeedFinder::getSeed ( const std::vector< const FastTrackerRecHit * > &  trackerRecHits) const
inline

Definition at line 46 of file SeedFinder.h.

References iterateHits(), eostools::move(), and SeedingTree< DATA >::numberOfNodes().

47  {
48  std::vector<int> hitIndicesInTree(_seedingTree.numberOfNodes(),-1);
49  //A SeedingNode is associated by its index to this list. The list stores the indices of the hits in 'trackerRecHits'
50  /* example
51  SeedingNode | hit index | hit
52  -------------------------------------------------------------------------------
53  index= 0: [BPix1] | hitIndicesInTree[0] (=1) | trackerRecHits[1]
54  index= 1: -- [BPix2] | hitIndicesInTree[1] (=3) | trackerRecHits[3]
55  index= 2: -- -- [BPix3] | hitIndicesInTree[2] (=4) | trackerRecHits[4]
56  index= 3: -- -- [FPix1_pos] | hitIndicesInTree[3] (=6) | trackerRecHits[6]
57  index= 4: -- -- [FPix1_neg] | hitIndicesInTree[4] (=7) | trackerRecHits[7]
58 
59  The implementation has been chosen such that the tree only needs to be build once upon construction.
60  */
61  std::vector<TrajectorySeedHitCandidate> seedHitCandidates;
62  for(const FastTrackerRecHit * trackerRecHit : trackerRecHits)
63  {
64  TrajectorySeedHitCandidate seedHitCandidate(trackerRecHit,_trackerTopology);
65  seedHitCandidates.push_back(std::move(seedHitCandidate));
66  }
67  return iterateHits(0,seedHitCandidates,hitIndicesInTree,true);
68 
69  //TODO: create pairs of TrackingLayer -> remove TrajectorySeedHitCandidate class
70  }
unsigned int numberOfNodes() const
Definition: SeedingTree.h:218
std::vector< unsigned int > iterateHits(unsigned int start, const std::vector< TrajectorySeedHitCandidate > &trackerRecHits, std::vector< int > hitIndicesInTree, bool processSkippedHits) const
Definition: SeedFinder.h:140
const SeedingTree< TrackingLayer > & _seedingTree
Definition: SeedFinder.h:25
def move(src, dest)
Definition: eostools.py:510
const TrackerTopology * _trackerTopology
Definition: SeedFinder.h:26
const SeedingNode<TrackingLayer>* SeedFinder::insertHit ( const std::vector< TrajectorySeedHitCandidate > &  trackerRecHits,
std::vector< int > &  hitIndicesInTree,
const SeedingNode< TrackingLayer > *  node,
unsigned int  trackerHit 
) const
inline

Definition at line 74 of file SeedFinder.h.

References SeedingNode< DATA >::getChild(), SeedingNode< DATA >::getChildrenSize(), SeedingNode< DATA >::getData(), SeedingNode< DATA >::getDepth(), SeedingNode< DATA >::getIndex(), SeedingNode< DATA >::getParent(), TrajectorySeedHitCandidate::getTrackingLayer(), TrajectorySeedHitCandidate::hit(), wplusjetsAnalysis_cfi::NHits, SurveyInfoScenario_cff::seed, and findQualityFiles::size.

Referenced by iterateHits().

78  {
79  if (!node->getParent() || hitIndicesInTree[node->getParent()->getIndex()]>=0)
80  {
81  if (hitIndicesInTree[node->getIndex()]<0)
82  {
83  const TrajectorySeedHitCandidate& currentTrackerHit = trackerRecHits[trackerHit];
84  if (currentTrackerHit.getTrackingLayer()!=node->getData())
85  {
86  return nullptr;
87  }
88 
89  const unsigned int NHits = node->getDepth()+1;
90  if (_selectorFunctionsByHits.size()>=NHits)
91  {
92  //are there any selector functions stored for NHits?
93  if (_selectorFunctionsByHits[NHits-1].size()>0)
94  {
95  //fill vector of Hits from node to root to be passed to the selector function
96  std::vector<const FastTrackerRecHit*> seedCandidateHitList(node->getDepth()+1);
97  seedCandidateHitList[node->getDepth()]=currentTrackerHit.hit();
98  const SeedingNode<TrackingLayer>* parentNode = node->getParent();
99  while (parentNode!=nullptr)
100  {
101  seedCandidateHitList[parentNode->getDepth()]=trackerRecHits[hitIndicesInTree[parentNode->getIndex()]].hit();
102  parentNode = parentNode->getParent();
103  }
104 
105  //loop over selector functions
106  for (SeedFinderSelector * selectorFunction: _selectorFunctionsByHits[NHits-1])
107  {
108  if (!selectorFunction->pass(seedCandidateHitList))
109  {
110  return nullptr;
111  }
112  }
113  }
114  }
115 
116  //the hit was not rejected by all selector functions -> insert it into the tree
117  hitIndicesInTree[node->getIndex()]=trackerHit;
118  if (node->getChildrenSize()==0)
119  {
120  return node;
121  }
122 
123  return nullptr;
124  }
125  else
126  {
127  for (unsigned int ichild = 0; ichild<node->getChildrenSize(); ++ichild)
128  {
129  const SeedingNode<TrackingLayer>* seed = insertHit(trackerRecHits,hitIndicesInTree,node->getChild(ichild),trackerHit);
130  if (seed)
131  {
132  return seed;
133  }
134  }
135  }
136  }
137  return nullptr;
138  }
size
Write out results.
const DATA & getData() const
Definition: SeedingTree.h:133
unsigned int getChildrenSize() const
Definition: SeedingTree.h:118
const SeedingNode< TrackingLayer > * insertHit(const std::vector< TrajectorySeedHitCandidate > &trackerRecHits, std::vector< int > &hitIndicesInTree, const SeedingNode< TrackingLayer > *node, unsigned int trackerHit) const
Definition: SeedFinder.h:74
unsigned int getDepth() const
Definition: SeedingTree.h:81
const SeedingNode * getParent() const
Definition: SeedingTree.h:109
const FastTrackerRecHit * hit() const
The Hit itself.
unsigned int getIndex() const
Definition: SeedingTree.h:104
const TrackingLayer & getTrackingLayer() const
const SeedingNode< DATA > * getChild(unsigned int ichild) const
Definition: SeedingTree.h:123
std::vector< std::vector< SeedFinderSelector * > > _selectorFunctionsByHits
Definition: SeedFinder.h:24
std::vector<unsigned int> SeedFinder::iterateHits ( unsigned int  start,
const std::vector< TrajectorySeedHitCandidate > &  trackerRecHits,
std::vector< int >  hitIndicesInTree,
bool  processSkippedHits 
) const
inline

Definition at line 140 of file SeedFinder.h.

References SeedingNode< DATA >::getDepth(), SeedingNode< DATA >::getIndex(), SeedingNode< DATA >::getParent(), SeedingTree< DATA >::getRoot(), SeedingTree< DATA >::getSingleSet(), insertHit(), and SeedingTree< DATA >::numberOfRoots().

Referenced by getSeed().

145  {
146  for (unsigned int irecHit = start; irecHit<trackerRecHits.size(); ++irecHit)
147  {
148 
149  // only accept hits that are on one of the requested layers
150  if(_seedingTree.getSingleSet().find(trackerRecHits[irecHit].getTrackingLayer())==_seedingTree.getSingleSet().end())
151  {
152  continue;
153  }
154 
155  unsigned int currentHitIndex=irecHit;
156 
157  for (unsigned int inext=currentHitIndex+1; inext< trackerRecHits.size(); ++inext)
158  {
159  //if multiple hits are on the same layer -> follow all possibilities by recusion
160  if (trackerRecHits[currentHitIndex].getTrackingLayer()==trackerRecHits[inext].getTrackingLayer())
161  {
162  if (processSkippedHits)
163  {
164  //recusively call the method again with hit 'inext' but skip all following on the same layer though 'processSkippedHits=false'
165  std::vector<unsigned int> seedHits = iterateHits(
166  inext,
167  trackerRecHits,
168  hitIndicesInTree,
169  false
170  );
171  if (seedHits.size()>0)
172  {
173  return seedHits;
174  }
175  }
176  irecHit+=1;
177  }
178  else
179  {
180  break;
181  }
182  }
183 
184  //processSkippedHits=true
185 
186  const SeedingNode<TrackingLayer>* seedNode = nullptr;
187  for (unsigned int iroot=0; seedNode==nullptr && iroot<_seedingTree.numberOfRoots(); ++iroot)
188  {
189  seedNode=insertHit(trackerRecHits,hitIndicesInTree,_seedingTree.getRoot(iroot), currentHitIndex);
190  }
191  if (seedNode)
192  {
193  std::vector<unsigned int> seedIndices(seedNode->getDepth()+1);
194  while (seedNode)
195  {
196  seedIndices[seedNode->getDepth()]=hitIndicesInTree[seedNode->getIndex()];
197  seedNode=seedNode->getParent();
198  }
199  return seedIndices;
200  }
201 
202  }
203 
204  return std::vector<unsigned int>();
205  }
Definition: start.py:1
const SingleSet & getSingleSet() const
Definition: SeedingTree.h:195
const SeedingNode< TrackingLayer > * insertHit(const std::vector< TrajectorySeedHitCandidate > &trackerRecHits, std::vector< int > &hitIndicesInTree, const SeedingNode< TrackingLayer > *node, unsigned int trackerHit) const
Definition: SeedFinder.h:74
unsigned int getDepth() const
Definition: SeedingTree.h:81
const SeedingNode * getParent() const
Definition: SeedingTree.h:109
unsigned int numberOfRoots() const
Definition: SeedingTree.h:213
std::vector< unsigned int > iterateHits(unsigned int start, const std::vector< TrajectorySeedHitCandidate > &trackerRecHits, std::vector< int > hitIndicesInTree, bool processSkippedHits) const
Definition: SeedFinder.h:140
const SeedingTree< TrackingLayer > & _seedingTree
Definition: SeedFinder.h:25
const SeedingNode< DATA > * getRoot(unsigned int i) const
Definition: SeedingTree.h:223
unsigned int getIndex() const
Definition: SeedingTree.h:104

Member Data Documentation

const SeedingTree<TrackingLayer>& SeedFinder::_seedingTree
private

Definition at line 25 of file SeedFinder.h.

std::vector<std::vector<SeedFinderSelector*> > SeedFinder::_selectorFunctionsByHits
private

Definition at line 24 of file SeedFinder.h.

const TrackerTopology* SeedFinder::_trackerTopology
private

Definition at line 26 of file SeedFinder.h.