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  int ncount = 0;
114  std::vector<Cluster1D<T> > partOfPTracks;
115  partOfPTracks.push_back(input.front());
116  for (typename std::vector<Cluster1D<T> >::const_iterator ic = (input.begin()) + 1; ic != input.end(); ic++) {
117  ncount++;
118  if (fabs((*ic).position().value() - (*(ic - 1)).position().value()) < (double)theZSeparation) {
119  partOfPTracks.push_back((*ic));
120  } else {
121  if (partOfPTracks.size() >= (unsigned int)theNTkMin) {
122  std::vector<Cluster1D<T> > clusters = makeCluster1Ds(partOfPTracks, discardedTracks);
123  for (typename std::vector<Cluster1D<T> >::const_iterator iclus = clusters.begin(); iclus != clusters.end();
124  iclus++) {
125  finalCluster1Ds.push_back(*iclus);
126  }
127  insertTracks(discardedTracks, totDiscardedTracks);
128  } else {
129  insertTracks(partOfPTracks, totDiscardedTracks);
130  }
131  partOfPTracks.clear();
132  partOfPTracks.push_back((*ic));
133  }
134  }
135  if (partOfPTracks.size() >= (unsigned int)theNTkMin) {
136  std::vector<Cluster1D<T> > clusters = makeCluster1Ds(partOfPTracks, discardedTracks);
137  for (typename std::vector<Cluster1D<T> >::const_iterator iclus = clusters.begin(); iclus != clusters.end();
138  iclus++) {
139  finalCluster1Ds.push_back(*iclus);
140  }
141  insertTracks(discardedTracks, totDiscardedTracks);
142  } else {
143  insertTracks(partOfPTracks, totDiscardedTracks);
144  }
145 
146  sort(finalCluster1Ds.begin(), finalCluster1Ds.end(), ComparePairs<T>());
147  // reverse(theCluster1Ds.begin(), theCluster1Ds.end());
148 
149  return;
150  }
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 192 of file DivisiveClusterizer1D.h.

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

◆ 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 153 of file DivisiveClusterizer1D.h.

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

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

◆ 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 213 of file DivisiveClusterizer1D.h.

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

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.