CMS 3D CMS Logo

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

#include <Cluster1DCleaner.h>

Public Member Functions

 Cluster1DCleaner (const float zoffset, bool useErr)
 
std::vector< Cluster1D< T > > clusters (const std::vector< Cluster1D< T > > &)
 
std::vector< Cluster1D< T > > discardedCluster1Ds () const
 

Private Member Functions

float average (const std::vector< Cluster1D< T > > &)
 
void cleanCluster1Ds (const std::vector< Cluster1D< T > > &)
 

Private Attributes

std::vector< Cluster1D< T > > theCleanedCluster1Ds
 
std::vector< Cluster1D< T > > theDiscardedCluster1Ds
 
bool theUseError
 
float theZOffSet
 

Detailed Description

template<class T>
class pixeltemp::Cluster1DCleaner< T >

Definition at line 16 of file Cluster1DCleaner.h.

Constructor & Destructor Documentation

◆ Cluster1DCleaner()

template<class T>
pixeltemp::Cluster1DCleaner< T >::Cluster1DCleaner ( const float  zoffset,
bool  useErr 
)
inline

Definition at line 18 of file Cluster1DCleaner.h.

18  : theZOffSet(zoffset), theUseError(useErr) {
19  theCleanedCluster1Ds.clear();
20  theDiscardedCluster1Ds.clear();
21  }
std::vector< Cluster1D< T > > theDiscardedCluster1Ds
std::vector< Cluster1D< T > > theCleanedCluster1Ds

Member Function Documentation

◆ average()

template<class T>
float Cluster1DCleaner< T >::average ( const std::vector< Cluster1D< T > > &  clust)
private

Definition at line 71 of file Cluster1DCleaner.h.

71  {
72  // float ave = clust.front().position().value();
73  // float err = clust.front().position().error();
74  // for( typename std::vector < Cluster1D<T> >::const_iterator ic=(clust.begin())+1;
75  // ic != clust.end(); ic++)
76  // {
77  // float oldave = ave;
78  // float olderr = err;
79  // ave = ( oldave/olderr/olderr +
80  // ic->position().value()/ic->position().error()/ic->position().error()) /
81  // (1./olderr/olderr + 1./ic->position().error()/ic->position().error());
82  // err = sqrt(olderr*olderr + ic->position().error()*ic->position().error());
83  // }
84  float sumUp = 0;
85  float sumDown = 0;
86  for (typename std::vector<Cluster1D<T> >::const_iterator ic = (clust.begin()) + 1; ic != clust.end(); ic++) {
87  float err2 = ic->position().error();
88  err2 *= err2;
89  if (err2 != 0) {
90  sumUp += ic->position().value() / err2; // error-weighted average of Z at IP
91  sumDown += 1 / err2;
92  }
93  }
94  return (sumDown > 0) ? sumUp / sumDown : 0;
95  }

◆ cleanCluster1Ds()

template<class T>
void Cluster1DCleaner< T >::cleanCluster1Ds ( const std::vector< Cluster1D< T > > &  clust)
private

Definition at line 51 of file Cluster1DCleaner.h.

51  {
52  theCleanedCluster1Ds.clear();
53  theDiscardedCluster1Ds.clear();
54  if (clust.empty())
55  return;
56  float oldPos = average(clust);
57  for (typename std::vector<Cluster1D<T> >::const_iterator ic = clust.begin(); ic != clust.end(); ic++) {
58  float discr = theUseError ? fabs(((*ic).position().value() - oldPos) / (*ic).position().error())
59  : fabs(((*ic).position().value() - oldPos));
60  if (discr < theZOffSet) {
61  theCleanedCluster1Ds.push_back(*ic);
62  } else {
63  theDiscardedCluster1Ds.push_back(*ic);
64  }
65  }
66  return;
67  }
std::vector< Cluster1D< T > > theDiscardedCluster1Ds
std::vector< Cluster1D< T > > theCleanedCluster1Ds
float average(const std::vector< Cluster1D< T > > &)

◆ clusters()

template<class T>
std::vector< Cluster1D< T > > Cluster1DCleaner< T >::clusters ( const std::vector< Cluster1D< T > > &  clust)

Definition at line 45 of file Cluster1DCleaner.h.

45  {
46  cleanCluster1Ds(clust);
47  return theCleanedCluster1Ds;
48  }
std::vector< Cluster1D< T > > theCleanedCluster1Ds
void cleanCluster1Ds(const std::vector< Cluster1D< T > > &)

◆ discardedCluster1Ds()

template<class T>
std::vector<Cluster1D<T> > pixeltemp::Cluster1DCleaner< T >::discardedCluster1Ds ( ) const
inline

Definition at line 29 of file Cluster1DCleaner.h.

29 { return theDiscardedCluster1Ds; }
std::vector< Cluster1D< T > > theDiscardedCluster1Ds

Member Data Documentation

◆ theCleanedCluster1Ds

template<class T>
std::vector<Cluster1D<T> > pixeltemp::Cluster1DCleaner< T >::theCleanedCluster1Ds
private

◆ theDiscardedCluster1Ds

template<class T>
std::vector<Cluster1D<T> > pixeltemp::Cluster1DCleaner< T >::theDiscardedCluster1Ds
private

◆ theUseError

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

Definition at line 37 of file Cluster1DCleaner.h.

◆ theZOffSet

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

Definition at line 36 of file Cluster1DCleaner.h.