CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

pixeltemp::Cluster1DCleaner< T > Class Template Reference

#include <Cluster1DCleaner.h>

List of all members.

Public Member Functions

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

Private Member Functions

float average (const std::vector< Cluster1D< T > > &)
void cleanCluster1Ds (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 14 of file Cluster1DCleaner.h.


Constructor & Destructor Documentation

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

Definition at line 18 of file Cluster1DCleaner.h.

                                                      :
        theZOffSet(zoffset), theUseError(useErr)
    {
        theCleanedCluster1Ds.clear();
        theDiscardedCluster1Ds.clear();
    }

Member Function Documentation

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

Definition at line 87 of file Cluster1DCleaner.h.

References mathSSE::sqrt().

{
//    float ave = clust.front().position().value();
//    float err = clust.front().position().error();
//    for( typename std::vector < Cluster1D<T> >::const_iterator ic=(clust.begin())+1;
//         ic != clust.end(); ic++)
//    {
//        float oldave = ave;
//        float olderr = err;
//        ave = ( oldave/olderr/olderr +
//                ic->position().value()/ic->position().error()/ic->position().error()) /
//              (1./olderr/olderr + 1./ic->position().error()/ic->position().error());
//        err = sqrt(olderr*olderr + ic->position().error()*ic->position().error());
//    }
  float sumUp = 0;
  float sumDown = 0;
  float err = 0;
  for( typename std::vector < Cluster1D<T> >::const_iterator ic=(clust.begin())+1;
       ic != clust.end(); ic++)
    {
      float err2 = ic->position().error();
      err2 *= err2;
      if (err2 != 0){
        sumUp += ic->position().value() / err2; // error-weighted average of Z at IP
        sumDown += 1/err2;
      }
      err += std::sqrt( err2 );
    }  
  return (sumDown>0) ? sumUp/sumDown : 0;
}
template<class T>
void Cluster1DCleaner< T >::cleanCluster1Ds ( std::vector< Cluster1D< T > >  clust) [private]

Definition at line 59 of file Cluster1DCleaner.h.

References PDRates::average.

{
    theCleanedCluster1Ds.clear();
    theDiscardedCluster1Ds.clear();
    if (clust.size() == 0)
        return;
    float oldPos = average(clust);
    for( typename std::vector < Cluster1D<T> >::const_iterator ic=clust.begin();
            ic != clust.end(); ic++)
    {
        float discr =
            theUseError ? fabs( ((*ic).position().value() - oldPos) / (*ic).position().error())
            : fabs( ((*ic).position().value() - oldPos) );
        if ( discr < theZOffSet )
        {
            theCleanedCluster1Ds.push_back(*ic);
        }
        else
        {
            theDiscardedCluster1Ds.push_back(*ic);
        }
    }
    return;
}
template<class T>
std::vector< Cluster1D< T > > Cluster1DCleaner< T >::clusters ( std::vector< Cluster1D< T > >  clust)

Definition at line 51 of file Cluster1DCleaner.h.

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

Definition at line 31 of file Cluster1DCleaner.h.


Member Data Documentation

template<class T>
std::vector<Cluster1D<T> > pixeltemp::Cluster1DCleaner< T >::theCleanedCluster1Ds [private]
template<class T>
std::vector<Cluster1D<T> > pixeltemp::Cluster1DCleaner< T >::theDiscardedCluster1Ds [private]
template<class T>
bool pixeltemp::Cluster1DCleaner< T >::theUseError [private]

Definition at line 42 of file Cluster1DCleaner.h.

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

Definition at line 41 of file Cluster1DCleaner.h.