Classes | Typedefs | Functions
gar::rec::alg Namespace Reference

Classes

class  AlgCluster
 
class  EnergyCut
 
class  GenericCluster
 
class  GenericClusterVec
 
class  GenericHit
 
class  GenericHitVec
 
class  KNNClusterAlg
 
class  NNDistance
 
class  StripSplitterAlg
 
class  XIndex
 

Typedefs

typedef std::vector< gar::rec::CaloHit * > CaloHitVec
 
typedef std::vector< gar::rec::Track * > TrackVec
 
typedef std::vector< gar::rec::Cluster * > ClusterVec
 

Functions

template<class In , class Out , class Pred >
void cluster (In first, In last, Out result, Pred *pred)
 
template<class T , class Pred >
void addToGenericHitVec (GenericHitVec< T > &v, CaloHitVec vec, Pred pred)
 
template<class T , class Pred , class Order >
void addToGenericHitVec (GenericHitVec< T > &v, CaloHitVec vec, Pred pred, Order order)
 

Typedef Documentation

Definition at line 36 of file KNNClusterAlg.h.

Definition at line 38 of file KNNClusterAlg.h.

Definition at line 37 of file KNNClusterAlg.h.

Function Documentation

template<class T , class Pred >
void gar::rec::alg::addToGenericHitVec ( GenericHitVec< T > &  v,
CaloHitVec  vec,
Pred  pred 
)

Helper method that copies all hit pointers from an LCIO collection that fullfill the predicate to a GenericHitVec. The predicate can either be a bool funtion or functor that takes a T*, e.g.

See also
EnergyCut

Definition at line 208 of file NNClusters.h.

208  {
209 
210  for( unsigned int i=0 ; i < vec.size() ; i++ ){
211 
212  T* hit = dynamic_cast<T*>( vec.at(i) ) ;
213 
214  if( pred( hit ) ){
215 
216  v.push_back( new GenericHit<T>( hit ) ) ;
217  }
218  }
219  }
Detector simulation of raw signals on wires.
template<class T , class Pred , class Order >
void gar::rec::alg::addToGenericHitVec ( GenericHitVec< T > &  v,
CaloHitVec  vec,
Pred  pred,
Order  order 
)

Same as addToGenericHitVec(GenericHitVec<T>& v, CaloHitList vec, Pred pred ) except that an additional order function/functor can be given that defines the index of the hit, e.g.

See also
ZIndex.

Definition at line 226 of file NNClusters.h.

226  {
227 
228  for( unsigned int i=0 ; i < vec.size() ; i++ ){
229 
230  T* hit = dynamic_cast<T*>( vec.at(i) ) ;
231 
232  if( pred( hit ) ){
233 
234  v.push_back( new GenericHit<T>( hit , order(hit) ) ) ;
235  }
236  }
237  }
Detector simulation of raw signals on wires.
template<class In , class Out , class Pred >
void gar::rec::alg::cluster ( In  first,
In  last,
Out  result,
Pred *  pred 
)

Simple nearest neighbour (NN) clustering algorithm. Users have to provide an input iterator of GenericHit objects and an output iterator for the clusters found. The predicate has to have a method with the following signature: bool mergeHits( GenericHit<T>*, GenericHit<T>*) where T is the original (LCIO) type of the hit objects. All pairs of hits for which this method returns 'true' will be merged into one output cluster - all other pairs of hits will be in distinct clusters.

$see GenericCluster

See also
GenericHit
NNDistance
Author
F.Gaede (DESY)
Version
Id
NNClusters.h,v 1.5 2007-06-05 15:35:49 engels Exp

Definition at line 41 of file NNClusters.h.

41  {
42 
43  //unused clang caught it: typedef typename In::value_type GenericHitPtr ;
44  typedef typename Pred::hit_type HitType ;
45 
46  typedef std::vector< GenericCluster<HitType >* > ClusterList ;
47 
48  ClusterList tmp ;
49  tmp.reserve( 1024 ) ;
50 
51  // int i(0),j(0) ;
52 
53  while( first != last ) {
54 
55  // j=i+1 ;
56 
57  for( In other = first+1 ; other != last ; other ++ ) {
58 
59  // std::cout << " in nested loop " << i << " , " << j << std::endl ;
60 
61  if( pred->mergeHits( (*first) , (*other) ) ) {
62 
63  if( (*first)->second == 0 && (*other)->second == 0 ) { // no cluster exists
64 
65  GenericCluster<HitType >* cl = new GenericCluster<HitType >( (*first) ) ;
66 
67  cl->addHit( (*other) ) ;
68 
69  tmp.push_back( cl ) ;
70 
71  }
72  else if( (*first)->second != 0 && (*other)->second != 0 ) { // two clusters
73 
74  // if( (*first)->second == (*other)->second )
75  // std::cout << " Merging identical clusters !? " << std::endl ;
76 
77  if( (*first)->second != (*other)->second ) // this is a bug fix for old gcc 3.2 compiler !
78  (*first)->second->mergeClusters( (*other)->second ) ;
79 
80  } else { // one cluster exists
81 
82  if( (*first)->second != 0 ) {
83 
84  (*first)->second->addHit( (*other) ) ;
85 
86  } else {
87 
88  (*other)->second->addHit( (*first) ) ;
89  }
90  }
91 
92  } // dCut
93  // ++j ;
94  }
95  // ++i ;
96  ++first ;
97  }
98 
99  // remove empty clusters
100  // std::remove_copy_if( tmp.begin() , tmp.end() , result , &empty_list< GenericCluster<HitType > > ) ;
101 
102  for( typename ClusterList::iterator i = tmp.begin(); i != tmp.end() ; i++ ){
103 
104  if( (*i)->size() > 0 ) {
105 
106  result++ = *i ;
107  }
108  else { delete *i ; }
109  }
110  }
intermediate_table::iterator iterator
static QCString result
enum cvn::HType HitType
QAsciiDict< Entry > cl
string tmp
Definition: languages.py:63