CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Attributes
SeedFinder Class Reference

#include <SeedFinder.h>

Public Types

typedef std::function< bool(const
std::vector< const
FastTrackerRecHit * > &hits)> 
Selector
 

Public Member Functions

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)
 
void setHitSelector (Selector selector)
 

Private Attributes

const SeedingTree
< TrackingLayer > & 
_seedingTree
 
Selector _selector
 
const TrackerTopology_trackerTopology
 

Detailed Description

Definition at line 15 of file SeedFinder.h.

Member Typedef Documentation

typedef std::function<bool(const std::vector<const FastTrackerRecHit *>& hits)> SeedFinder::Selector

Definition at line 19 of file SeedFinder.h.

Constructor & Destructor Documentation

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

Definition at line 26 of file SeedFinder.h.

References _selector.

27  : _seedingTree(seedingTree)
28  , _trackerTopology(&trackerTopology)
29  {
30  _selector=[](const std::vector<const FastTrackerRecHit*>& hits) -> bool
31  {
32  return true;
33  };
34  }
Selector _selector
Definition: SeedFinder.h:21
const SeedingTree< TrackingLayer > & _seedingTree
Definition: SeedFinder.h:22
const TrackerTopology * _trackerTopology
Definition: SeedFinder.h:23

Member Function Documentation

std::vector<unsigned int> SeedFinder::getSeed ( const std::vector< const FastTrackerRecHit * > &  trackerRecHits) const
inline

Definition at line 41 of file SeedFinder.h.

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

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

References _selector, SeedingNode< DATA >::getChild(), SeedingNode< DATA >::getChildrenSize(), SeedingNode< DATA >::getData(), SeedingNode< DATA >::getDepth(), SeedingNode< DATA >::getIndex(), SeedingNode< DATA >::getParent(), TrajectorySeedHitCandidate::getTrackingLayer(), TrajectorySeedHitCandidate::hit(), and fileCollector::seed.

Referenced by iterateHits().

71  {
72  if (!node->getParent() || hitIndicesInTree[node->getParent()->getIndex()]>=0)
73  {
74  if (hitIndicesInTree[node->getIndex()]<0)
75  {
76  const TrajectorySeedHitCandidate& currentTrackerHit = trackerRecHits[trackerHit];
77  if (currentTrackerHit.getTrackingLayer()!=node->getData())
78  {
79  return nullptr;
80  }
81 
82  //fill vector of Hits from node to root to be passed to the selector function
83  std::vector<const FastTrackerRecHit*> seedCandidateHitList(node->getDepth()+1);
84  seedCandidateHitList[node->getDepth()]=currentTrackerHit.hit();
85  const SeedingNode<TrackingLayer>* parentNode = node->getParent();
86  while (parentNode!=nullptr)
87  {
88  seedCandidateHitList[parentNode->getDepth()]=trackerRecHits[hitIndicesInTree[parentNode->getIndex()]].hit();
89  parentNode = parentNode->getParent();
90  }
91 
92  if (!_selector(seedCandidateHitList))
93  {
94  return nullptr;
95  }
96 
97  hitIndicesInTree[node->getIndex()]=trackerHit;
98  if (node->getChildrenSize()==0)
99  {
100  return node;
101  }
102 
103  return nullptr;
104  }
105  else
106  {
107  for (unsigned int ichild = 0; ichild<node->getChildrenSize(); ++ichild)
108  {
109  const SeedingNode<TrackingLayer>* seed = insertHit(trackerRecHits,hitIndicesInTree,node->getChild(ichild),trackerHit);
110  if (seed)
111  {
112  return seed;
113  }
114  }
115  }
116  }
117  return nullptr;
118  }
Selector _selector
Definition: SeedFinder.h:21
const DATA & getData() const
Definition: SeedingTree.h:136
unsigned int getChildrenSize() const
Definition: SeedingTree.h:121
const SeedingNode< TrackingLayer > * insertHit(const std::vector< TrajectorySeedHitCandidate > &trackerRecHits, std::vector< int > &hitIndicesInTree, const SeedingNode< TrackingLayer > *node, unsigned int trackerHit) const
Definition: SeedFinder.h:67
unsigned int getDepth() const
Definition: SeedingTree.h:84
const SeedingNode * getParent() const
Definition: SeedingTree.h:112
const FastTrackerRecHit * hit() const
The Hit itself.
unsigned int getIndex() const
Definition: SeedingTree.h:107
const TrackingLayer & getTrackingLayer() const
const SeedingNode< DATA > * getChild(unsigned int ichild) const
Definition: SeedingTree.h:126
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 120 of file SeedFinder.h.

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

Referenced by getSeed().

125  {
126  for (unsigned int irecHit = start; irecHit<trackerRecHits.size(); ++irecHit)
127  {
128 
129  // only accept hits that are on one of the requested layers
130  if(_seedingTree.getSingleSet().find(trackerRecHits[irecHit].getTrackingLayer())==_seedingTree.getSingleSet().end())
131  {
132  continue;
133  }
134 
135  unsigned int currentHitIndex=irecHit;
136 
137  for (unsigned int inext=currentHitIndex+1; inext< trackerRecHits.size(); ++inext)
138  {
139  //if multiple hits are on the same layer -> follow all possibilities by recusion
140  if (trackerRecHits[currentHitIndex].getTrackingLayer()==trackerRecHits[inext].getTrackingLayer())
141  {
142  if (processSkippedHits)
143  {
144  //recusively call the method again with hit 'inext' but skip all following on the same layer though 'processSkippedHits=false'
145  std::vector<unsigned int> seedHits = iterateHits(
146  inext,
147  trackerRecHits,
148  hitIndicesInTree,
149  false
150  );
151  if (seedHits.size()>0)
152  {
153  return seedHits;
154  }
155  }
156  irecHit+=1;
157  }
158  else
159  {
160  break;
161  }
162  }
163 
164  //processSkippedHits=true
165 
166  const SeedingNode<TrackingLayer>* seedNode = nullptr;
167  for (unsigned int iroot=0; seedNode==nullptr && iroot<_seedingTree.numberOfRoots(); ++iroot)
168  {
169  seedNode=insertHit(trackerRecHits,hitIndicesInTree,_seedingTree.getRoot(iroot), currentHitIndex);
170  }
171  if (seedNode)
172  {
173  std::vector<unsigned int> seedIndices(seedNode->getDepth()+1);
174  while (seedNode)
175  {
176  seedIndices[seedNode->getDepth()]=hitIndicesInTree[seedNode->getIndex()];
177  seedNode=seedNode->getParent();
178  }
179  return seedIndices;
180  }
181 
182  }
183 
184  return std::vector<unsigned int>();
185  }
tuple start
Check for commandline option errors.
Definition: dqm_diff.py:58
const SingleSet & getSingleSet() const
Definition: SeedingTree.h:203
const SeedingNode< TrackingLayer > * insertHit(const std::vector< TrajectorySeedHitCandidate > &trackerRecHits, std::vector< int > &hitIndicesInTree, const SeedingNode< TrackingLayer > *node, unsigned int trackerHit) const
Definition: SeedFinder.h:67
unsigned int getDepth() const
Definition: SeedingTree.h:84
const SeedingNode * getParent() const
Definition: SeedingTree.h:112
unsigned int numberOfRoots() const
Definition: SeedingTree.h:221
std::vector< unsigned int > iterateHits(unsigned int start, const std::vector< TrajectorySeedHitCandidate > &trackerRecHits, std::vector< int > hitIndicesInTree, bool processSkippedHits) const
Definition: SeedFinder.h:120
const SeedingTree< TrackingLayer > & _seedingTree
Definition: SeedFinder.h:22
const SeedingNode< DATA > * getRoot(unsigned int i) const
Definition: SeedingTree.h:231
unsigned int getIndex() const
Definition: SeedingTree.h:107
void SeedFinder::setHitSelector ( Selector  selector)
inline

Definition at line 36 of file SeedFinder.h.

References _selector.

37  {
38  _selector = selector;
39  }
Selector _selector
Definition: SeedFinder.h:21

Member Data Documentation

const SeedingTree<TrackingLayer>& SeedFinder::_seedingTree
private

Definition at line 22 of file SeedFinder.h.

Referenced by getSeed(), and iterateHits().

Selector SeedFinder::_selector
private

Definition at line 21 of file SeedFinder.h.

Referenced by insertHit(), SeedFinder(), and setHitSelector().

const TrackerTopology* SeedFinder::_trackerTopology
private

Definition at line 23 of file SeedFinder.h.

Referenced by getSeed().