CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
pixeltemp::DivisiveClusterizer1D< T > Class Template Reference

#include <DivisiveClusterizer1D.h>

Inheritance diagram for pixeltemp::DivisiveClusterizer1D< T >:
Clusterizer1D< T >

Public Member Functions

DivisiveClusterizer1Dclone () const override
 
 DivisiveClusterizer1D (float zoffset=5., int ntkmin=5, bool useError=true, float zsep=0.05, bool wei=true)
 
std::pair< std::vector< Cluster1D< T > >, std::vector< const T * > > operator() (const std::vector< Cluster1D< T > > &) const override
 
void setBeamSpot (const math::XYZPoint &bs)
 
 ~DivisiveClusterizer1D () override
 
- Public Member Functions inherited from Clusterizer1D< T >
virtual ~Clusterizer1D ()
 

Private Member Functions

void findCandidates (const std::vector< Cluster1D< T > > &, std::vector< Cluster1D< T > > &, std::vector< Cluster1D< T > > &) const
 
void insertTracks (std::vector< Cluster1D< T > > &, std::vector< Cluster1D< T > > &) const
 
std::vector< Cluster1D< T > > makeCluster1Ds (std::vector< Cluster1D< T > > &, std::vector< Cluster1D< T > > &) const
 
Cluster1D< TmergeCluster1Ds (std::vector< Cluster1D< T > > &) const
 
std::vector< const T * > takeTracks (const std::vector< Cluster1D< T > > &) const
 

Private Attributes

pixeltemp::Cluster1DCleaner< T > * theCleaner
 
pixeltemp::Cluster1DMerger< T > * theMerger
 
unsigned int theNTkMin
 
bool theUseError
 
bool theWei
 
float theZOffSet
 
float theZSeparation
 

Detailed Description

template<class T>
class pixeltemp::DivisiveClusterizer1D< T >

Definition at line 19 of file DivisiveClusterizer1D.h.

Constructor & Destructor Documentation

◆ DivisiveClusterizer1D()

template<class T >
DivisiveClusterizer1D< T >::DivisiveClusterizer1D ( float  zoffset = 5.,
int  ntkmin = 5,
bool  useError = true,
float  zsep = 0.05,
bool  wei = true 
)
Parameters
zoffsetmaximum distance between track position and position of its cluster (depending on useError its either weighted or physical distance)
ntkminMinimum number of tracks required to form a cluster.
useErrorphysical distances or weighted distances.
zsepMaximum distance between two adjacent tracks that belong to the same initial cluster.
weiCompute the cluster "center" with an unweighted or a weighted average of the tracks. Weighted means weighted with the error of the data point.

Definition at line 70 of file DivisiveClusterizer1D.h.

71  : theZOffSet(zoffset), theNTkMin(ntkmin), theUseError(useError), theZSeparation(zsep), theWei(wei) {
72  // theDiscardedTracks.clear();
73  // theTotalDiscardedTracks.clear();
74  // theCluster1Ds.clear();
75  TrivialWeightEstimator<T> weightEstimator;
76  theMerger = new pixeltemp::Cluster1DMerger<T>(weightEstimator);
78  }
pixeltemp::Cluster1DMerger< T > * theMerger
pixeltemp::Cluster1DCleaner< T > * theCleaner

◆ ~DivisiveClusterizer1D()

template<class T >
DivisiveClusterizer1D< T >::~DivisiveClusterizer1D ( )
override

Definition at line 81 of file DivisiveClusterizer1D.h.

81  {
82  delete theMerger;
83  delete theCleaner;
84  }
pixeltemp::Cluster1DMerger< T > * theMerger
pixeltemp::Cluster1DCleaner< T > * theCleaner

Member Function Documentation

◆ clone()

template<class T >
DivisiveClusterizer1D< T > * DivisiveClusterizer1D< T >::clone ( void  ) const
overridevirtual

Implements Clusterizer1D< T >.

Definition at line 96 of file DivisiveClusterizer1D.h.

96  {
97  return new DivisiveClusterizer1D<T>(*this);
98  }

◆ findCandidates()

template<class T>
void DivisiveClusterizer1D< T >::findCandidates ( const std::vector< Cluster1D< T > > &  inputo,
std::vector< Cluster1D< T > > &  finalCluster1Ds,
std::vector< Cluster1D< T > > &  totDiscardedTracks 
) const
private

Definition at line 101 of file DivisiveClusterizer1D.h.

103  {
104  using namespace Clusterizer1DCommons;
105 
106  std::vector<Cluster1D<T> > input = inputo;
107  std::vector<Cluster1D<T> > discardedTracks;
108  if (input.size() < (unsigned int)theNTkMin) {
109  insertTracks(input, totDiscardedTracks);
110  return;
111  }
112  sort(input.begin(), input.end(), ComparePairs<T>());
113  std::vector<Cluster1D<T> > partOfPTracks;
114  partOfPTracks.push_back(input.front());
115  for (typename std::vector<Cluster1D<T> >::const_iterator ic = (input.begin()) + 1; ic != input.end(); ic++) {
116  if (fabs((*ic).position().value() - (*(ic - 1)).position().value()) < (double)theZSeparation) {
117  partOfPTracks.push_back((*ic));
118  } else {
119  if (partOfPTracks.size() >= (unsigned int)theNTkMin) {
120  std::vector<Cluster1D<T> > clusters = makeCluster1Ds(partOfPTracks, discardedTracks);
121  for (typename std::vector<Cluster1D<T> >::const_iterator iclus = clusters.begin(); iclus != clusters.end();
122  iclus++) {
123  finalCluster1Ds.push_back(*iclus);
124  }
125  insertTracks(discardedTracks, totDiscardedTracks);
126  } else {
127  insertTracks(partOfPTracks, totDiscardedTracks);
128  }
129  partOfPTracks.clear();
130  partOfPTracks.push_back((*ic));
131  }
132  }
133  if (partOfPTracks.size() >= (unsigned int)theNTkMin) {
134  std::vector<Cluster1D<T> > clusters = makeCluster1Ds(partOfPTracks, discardedTracks);
135  for (typename std::vector<Cluster1D<T> >::const_iterator iclus = clusters.begin(); iclus != clusters.end();
136  iclus++) {
137  finalCluster1Ds.push_back(*iclus);
138  }
139  insertTracks(discardedTracks, totDiscardedTracks);
140  } else {
141  insertTracks(partOfPTracks, totDiscardedTracks);
142  }
143 
144  sort(finalCluster1Ds.begin(), finalCluster1Ds.end(), ComparePairs<T>());
145  // reverse(theCluster1Ds.begin(), theCluster1Ds.end());
146 
147  return;
148  }
static std::string const input
Definition: EdmProvDump.cc:50
void insertTracks(std::vector< Cluster1D< T > > &, std::vector< Cluster1D< T > > &) const
std::vector< Cluster1D< T > > makeCluster1Ds(std::vector< Cluster1D< T > > &, std::vector< Cluster1D< T > > &) const

◆ insertTracks()

template<class T>
void DivisiveClusterizer1D< T >::insertTracks ( std::vector< Cluster1D< T > > &  clusou,
std::vector< Cluster1D< T > > &  cludest 
) const
private

Definition at line 190 of file DivisiveClusterizer1D.h.

191  {
192  if (clusou.empty())
193  return;
194  for (typename std::vector<Cluster1D<T> >::const_iterator iclu = clusou.begin(); iclu != clusou.end(); iclu++) {
195  cludest.push_back(*iclu);
196  }
197  /*
198  for ( typename std::vector< Cluster1D<T> >::const_iterator iclu = clu.begin();
199  iclu != clu.end(); iclu++){
200  if (total) {
201  theTotalDiscardedTracks.push_back(*iclu);
202  }else {
203  theDiscardedTracks.push_back(*iclu);
204  }
205  }
206  */
207  return;
208  }

◆ makeCluster1Ds()

template<class T>
std::vector< Cluster1D< T > > DivisiveClusterizer1D< T >::makeCluster1Ds ( std::vector< Cluster1D< T > > &  clusters,
std::vector< Cluster1D< T > > &  discardedTracks 
) const
private

Definition at line 151 of file DivisiveClusterizer1D.h.

152  {
153  std::vector<Cluster1D<T> > finalCluster1Ds;
154  discardedTracks.clear();
155  std::vector<Cluster1D<T> > pvClu0 = clusters;
156  std::vector<Cluster1D<T> > pvCluNew = pvClu0;
157  bool stop = false;
158  while (!stop) {
159  int nDiscardedAtIteration = 100;
160  while (nDiscardedAtIteration != 0) {
161  pvCluNew = theCleaner->clusters(pvClu0);
162  std::vector<Cluster1D<T> > tracksAtIteration = theCleaner->discardedCluster1Ds();
163  nDiscardedAtIteration = tracksAtIteration.size();
164  if (nDiscardedAtIteration != 0) {
165  insertTracks(tracksAtIteration, discardedTracks);
166  pvClu0 = pvCluNew;
167  }
168  } // while nDiscardedAtIteration
169  unsigned ntkclus = pvCluNew.size();
170  unsigned ndiscard = discardedTracks.size();
171 
172  if (ntkclus >= theNTkMin) {
173  //save the cluster
174  finalCluster1Ds.push_back(mergeCluster1Ds(pvCluNew));
175  if (ndiscard >= theNTkMin) { //make a new cluster and reset
176  pvClu0 = discardedTracks;
177  discardedTracks.clear();
178  } else { //out of loop
179  stop = true;
180  }
181  } else {
182  insertTracks(pvCluNew, discardedTracks);
183  stop = true;
184  }
185  } // while stop
186  return finalCluster1Ds;
187  }
void insertTracks(std::vector< Cluster1D< T > > &, std::vector< Cluster1D< T > > &) const
Cluster1D< T > mergeCluster1Ds(std::vector< Cluster1D< T > > &) const
pixeltemp::Cluster1DCleaner< T > * theCleaner

◆ mergeCluster1Ds()

template<class T>
Cluster1D< T > DivisiveClusterizer1D< T >::mergeCluster1Ds ( std::vector< Cluster1D< T > > &  clusters) const
private

Definition at line 223 of file DivisiveClusterizer1D.h.

223  {
224  Cluster1D<T> result = clusters.front();
225  for (typename std::vector<Cluster1D<T> >::iterator iclu = (clusters.begin()) + 1; iclu != clusters.end(); iclu++) {
226  Cluster1D<T> old = result;
227  result = (*theMerger)(old, *iclu);
228  }
229  return result;
230  }

◆ operator()()

template<class T>
std::pair< std::vector< Cluster1D< T > >, std::vector< const T * > > DivisiveClusterizer1D< T >::operator() ( const std::vector< Cluster1D< T > > &  input) const
overridevirtual

Implements Clusterizer1D< T >.

Definition at line 87 of file DivisiveClusterizer1D.h.

88  {
89  std::vector<Cluster1D<T> > discardedCluster1Ds;
90  std::vector<Cluster1D<T> > output;
91  findCandidates(input, output, discardedCluster1Ds);
92  return std::pair<std::vector<Cluster1D<T> >, std::vector<const T*> >(output, takeTracks(discardedCluster1Ds));
93  }
void findCandidates(const std::vector< Cluster1D< T > > &, std::vector< Cluster1D< T > > &, std::vector< Cluster1D< T > > &) const
std::vector< const T * > takeTracks(const std::vector< Cluster1D< T > > &) const
static std::string const input
Definition: EdmProvDump.cc:50

◆ setBeamSpot()

template<class T>
void pixeltemp::DivisiveClusterizer1D< T >::setBeamSpot ( const math::XYZPoint bs)
inline

Definition at line 40 of file DivisiveClusterizer1D.h.

Referenced by DivisiveVertexFinder::findVertexesAlt().

40 { theMerger->setBeamSpot(bs); }
pixeltemp::Cluster1DMerger< T > * theMerger

◆ takeTracks()

template<class T>
std::vector< const T * > DivisiveClusterizer1D< T >::takeTracks ( const std::vector< Cluster1D< T > > &  clu) const
private

Definition at line 211 of file DivisiveClusterizer1D.h.

211  {
212  std::vector<const T*> tracks;
213  for (typename std::vector<Cluster1D<T> >::const_iterator iclu = clu.begin(); iclu != clu.end(); iclu++) {
214  std::vector<const T*> clutks = iclu->tracks();
215  for (typename std::vector<const T*>::const_iterator i = clutks.begin(); i != clutks.end(); ++i) {
216  tracks.push_back(*i);
217  }
218  }
219  return tracks;
220  }

Member Data Documentation

◆ theCleaner

template<class T>
pixeltemp::Cluster1DCleaner<T>* pixeltemp::DivisiveClusterizer1D< T >::theCleaner
private

Definition at line 56 of file DivisiveClusterizer1D.h.

◆ theMerger

template<class T>
pixeltemp::Cluster1DMerger<T>* pixeltemp::DivisiveClusterizer1D< T >::theMerger
private

◆ theNTkMin

template<class T>
unsigned int pixeltemp::DivisiveClusterizer1D< T >::theNTkMin
private

Definition at line 58 of file DivisiveClusterizer1D.h.

◆ theUseError

template<class T>
bool pixeltemp::DivisiveClusterizer1D< T >::theUseError
private

Definition at line 59 of file DivisiveClusterizer1D.h.

◆ theWei

template<class T>
bool pixeltemp::DivisiveClusterizer1D< T >::theWei
private

Definition at line 61 of file DivisiveClusterizer1D.h.

◆ theZOffSet

template<class T>
float pixeltemp::DivisiveClusterizer1D< T >::theZOffSet
private

Definition at line 57 of file DivisiveClusterizer1D.h.

◆ theZSeparation

template<class T>
float pixeltemp::DivisiveClusterizer1D< T >::theZSeparation
private

Definition at line 60 of file DivisiveClusterizer1D.h.