test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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

virtual DivisiveClusterizer1Dclone () const
 
 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
 
void setBeamSpot (const math::XYZPoint &bs)
 
 ~DivisiveClusterizer1D ()
 
- 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

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

References pixeltemp::DivisiveClusterizer1D< T >::theCleaner, pixeltemp::DivisiveClusterizer1D< T >::theMerger, pixeltemp::DivisiveClusterizer1D< T >::theUseError, and pixeltemp::DivisiveClusterizer1D< T >::theZOffSet.

78  :theZOffSet(zoffset), theNTkMin(ntkmin),
79  theUseError(useError), theZSeparation(zsep), theWei(wei)
80 {
81  // theDiscardedTracks.clear();
82  // theTotalDiscardedTracks.clear();
83  // theCluster1Ds.clear();
84  TrivialWeightEstimator<T> weightEstimator;
85  theMerger = new pixeltemp::Cluster1DMerger<T>( weightEstimator );
87 }
pixeltemp::Cluster1DMerger< T > * theMerger
pixeltemp::Cluster1DCleaner< T > * theCleaner
template<class T >
DivisiveClusterizer1D< T >::~DivisiveClusterizer1D ( )

Definition at line 90 of file DivisiveClusterizer1D.h.

91 {
92  delete theMerger;
93  delete theCleaner;
94 }
pixeltemp::Cluster1DMerger< T > * theMerger
pixeltemp::Cluster1DCleaner< T > * theCleaner

Member Function Documentation

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

Implements Clusterizer1D< T >.

Definition at line 109 of file DivisiveClusterizer1D.h.

110 {
111  return new DivisiveClusterizer1D<T> ( * this );
112 }
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 116 of file DivisiveClusterizer1D.h.

References HLT_25ns10e33_v2_cff::clusters, and input.

119 {
120  using namespace Clusterizer1DCommons;
121 
122  std::vector < Cluster1D<T> > input = inputo;
123  std::vector < Cluster1D<T> > discardedTracks;
124  if ( input.size() < (unsigned int)theNTkMin)
125  {
126  insertTracks( input, totDiscardedTracks);
127  return;
128  }
129  sort( input.begin(), input.end(), ComparePairs<T>());
130  int ncount =0;
131  std::vector < Cluster1D<T> > partOfPTracks;
132  partOfPTracks.push_back(input.front());
133  for( typename std::vector < Cluster1D<T> >::const_iterator ic=(input.begin())+1;
134  ic != input.end(); ic++)
135  {
136  ncount++;
137  if ( fabs( (*ic).position().value()-(*(ic-1)).position().value() )
138  < (double) theZSeparation )
139  {
140  partOfPTracks.push_back((*ic));
141  }
142  else
143  {
144  if(partOfPTracks.size() >= (unsigned int)theNTkMin)
145  {
146  std::vector< Cluster1D<T> > clusters = makeCluster1Ds(partOfPTracks,
147  discardedTracks);
148  for (typename std::vector< Cluster1D<T> >::const_iterator iclus=clusters.begin();
149  iclus != clusters.end(); iclus++)
150  {
151  finalCluster1Ds.push_back(*iclus);
152  }
153  insertTracks(discardedTracks,totDiscardedTracks);
154  }
155  else
156  {
157  insertTracks(partOfPTracks,totDiscardedTracks);
158  }
159  partOfPTracks.clear();
160  partOfPTracks.push_back((*ic));
161  }
162  }
163  if (partOfPTracks.size() >= (unsigned int)theNTkMin)
164  {
165  std::vector < Cluster1D<T> > clusters = makeCluster1Ds(partOfPTracks,
166  discardedTracks);
167  for (typename std::vector< Cluster1D<T> >::const_iterator iclus = clusters.begin();
168  iclus != clusters.end(); iclus++)
169  {
170  finalCluster1Ds.push_back(*iclus);
171  }
172  insertTracks(discardedTracks,totDiscardedTracks);
173  }
174  else
175  {
176  insertTracks(partOfPTracks,totDiscardedTracks);
177  }
178 
179  sort(finalCluster1Ds.begin(), finalCluster1Ds.end(),
180  ComparePairs<T>() );
181  // reverse(theCluster1Ds.begin(), theCluster1Ds.end());
182 
183  return;
184 }
std::vector< Cluster1D< T > > makeCluster1Ds(std::vector< Cluster1D< T > > &, std::vector< Cluster1D< T > > &) const
void insertTracks(std::vector< Cluster1D< T > > &, std::vector< Cluster1D< T > > &) const
static std::string const input
Definition: EdmProvDump.cc:44
template<class T>
void DivisiveClusterizer1D< T >::insertTracks ( std::vector< Cluster1D< T > > &  clusou,
std::vector< Cluster1D< T > > &  cludest 
) const
private

Definition at line 240 of file DivisiveClusterizer1D.h.

242 {
243  if (clusou.size() == 0)
244  return;
245  for ( typename std::vector< Cluster1D<T> >::const_iterator iclu = clusou.begin();
246  iclu != clusou.end(); iclu++)
247  {
248  cludest.push_back(*iclu);
249  }
250  /*
251  for ( typename std::vector< Cluster1D<T> >::const_iterator iclu = clu.begin();
252  iclu != clu.end(); iclu++){
253  if (total) {
254  theTotalDiscardedTracks.push_back(*iclu);
255  }else {
256  theDiscardedTracks.push_back(*iclu);
257  }
258  }
259  */
260  return;
261 }
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 188 of file DivisiveClusterizer1D.h.

References HLT_25ns10e33_v2_cff::clusters.

190 {
191 
192  std::vector < Cluster1D<T> > finalCluster1Ds;
193  discardedTracks.clear();
194  std::vector<Cluster1D<T> > pvClu0 = clusters;
195  std::vector<Cluster1D<T> > pvCluNew = pvClu0;
196  bool stop = false;
197  while (!stop)
198  {
199  int nDiscardedAtIteration = 100;
200  while ( nDiscardedAtIteration !=0 )
201  {
202  pvCluNew = theCleaner->clusters(pvClu0);
203  std::vector<Cluster1D<T> >
204  tracksAtIteration = theCleaner->discardedCluster1Ds();
205  nDiscardedAtIteration = tracksAtIteration.size();
206  if ( nDiscardedAtIteration!=0 )
207  {
208  insertTracks(tracksAtIteration,discardedTracks);
209  pvClu0 = pvCluNew;
210  }
211  } // while nDiscardedAtIteration
212  unsigned ntkclus = pvCluNew.size();
213  unsigned ndiscard = discardedTracks.size();
214 
215  if ( ntkclus >= theNTkMin )
216  {
217  //save the cluster
218  finalCluster1Ds.push_back( mergeCluster1Ds(pvCluNew) );
219  if ( ndiscard >= theNTkMin )
220  { //make a new cluster and reset
221  pvClu0 = discardedTracks;
222  discardedTracks.clear();
223  }
224  else
225  { //out of loop
226  stop = true;
227  }
228  }
229  else
230  {
231  insertTracks(pvCluNew, discardedTracks);
232  stop = true;
233  }
234  }// while stop
235  return finalCluster1Ds;
236 }
void insertTracks(std::vector< Cluster1D< T > > &, std::vector< Cluster1D< T > > &) const
Cluster1D< T > mergeCluster1Ds(std::vector< Cluster1D< T > > &) const
pixeltemp::Cluster1DCleaner< T > * theCleaner
template<class T>
Cluster1D< T > DivisiveClusterizer1D< T >::mergeCluster1Ds ( std::vector< Cluster1D< T > > &  clusters) const
private

Definition at line 283 of file DivisiveClusterizer1D.h.

References HLT_25ns10e33_v2_cff::clusters, and mps_fire::result.

284 {
285 
286  Cluster1D<T> result = clusters.front();
287  for ( typename std::vector< Cluster1D<T> >::iterator iclu = (clusters.begin())+1;
288  iclu != clusters.end(); iclu++)
289  {
290  Cluster1D<T> old = result;
291  result = (*theMerger)( old , *iclu );
292  }
293  return result;
294 }
tuple result
Definition: mps_fire.py:84
template<class T>
std::pair< std::vector< Cluster1D< T > >, std::vector< const T * > > DivisiveClusterizer1D< T >::operator() ( const std::vector< Cluster1D< T > > &  input) const
virtual

Implements Clusterizer1D< T >.

Definition at line 99 of file DivisiveClusterizer1D.h.

References input, and convertSQLitetoXML_cfg::output.

100 {
101  std::vector < Cluster1D<T> > discardedCluster1Ds;
102  std::vector < Cluster1D<T> > output;
103  findCandidates ( input, output, discardedCluster1Ds );
104  return std::pair < std::vector < Cluster1D<T> >, std::vector < const T * > >
105  ( output, takeTracks(discardedCluster1Ds) );
106 }
static std::string const input
Definition: EdmProvDump.cc:44
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
template<class T>
void pixeltemp::DivisiveClusterizer1D< T >::setBeamSpot ( const math::XYZPoint bs)
inline

Definition at line 42 of file DivisiveClusterizer1D.h.

Referenced by DivisiveVertexFinder::findVertexesAlt().

42 {theMerger->setBeamSpot(bs); }
pixeltemp::Cluster1DMerger< T > * theMerger
template<class T>
std::vector< const T * > DivisiveClusterizer1D< T >::takeTracks ( const std::vector< Cluster1D< T > > &  clu) const
private

Definition at line 265 of file DivisiveClusterizer1D.h.

References i, and testEve_cfg::tracks.

266 {
267  std::vector<const T* > tracks;
268  for ( typename std::vector< Cluster1D<T> >::const_iterator iclu = clu.begin();
269  iclu != clu.end(); iclu++)
270  {
271  std::vector < const T * > clutks = iclu->tracks();
272  for ( typename std::vector< const T * >::const_iterator i=clutks.begin();
273  i!=clutks.end() ; ++i )
274  {
275  tracks.push_back ( *i );
276  }
277  }
278  return tracks;
279 }
int i
Definition: DBlmapReader.cc:9
tuple tracks
Definition: testEve_cfg.py:39

Member Data Documentation

template<class T>
pixeltemp::Cluster1DCleaner<T>* pixeltemp::DivisiveClusterizer1D< T >::theCleaner
private
template<class T>
pixeltemp::Cluster1DMerger<T>* pixeltemp::DivisiveClusterizer1D< T >::theMerger
private
template<class T>
unsigned int pixeltemp::DivisiveClusterizer1D< T >::theNTkMin
private

Definition at line 62 of file DivisiveClusterizer1D.h.

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

Definition at line 65 of file DivisiveClusterizer1D.h.

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

Definition at line 64 of file DivisiveClusterizer1D.h.