CMS 3D CMS Logo

Public Member Functions | Public Attributes | Private Attributes

pftools::CaloEllipse Class Reference

#include <CaloEllipse.h>

List of all members.

Public Member Functions

void addPoint (double x, double y)
 CaloEllipse ()
void clearPoints ()
double getEccentricity () const
Point getMajorMinorAxes (double sigma=1.0) const
Point getPosition () const
double getTheta () const
void makeCaches ()
void reset ()
void resetCaches ()
virtual ~CaloEllipse ()

Public Attributes

double cachedEccentricity_
double cachedMajor_
double cachedMinor_
double cachedTheta_

Private Attributes

std::vector< PointdataPoints_

Detailed Description

Definition at line 23 of file CaloEllipse.h.


Constructor & Destructor Documentation

CaloEllipse::CaloEllipse ( )

Definition at line 15 of file CaloEllipse.cc.

                         {


}
CaloEllipse::~CaloEllipse ( ) [virtual]

Definition at line 20 of file CaloEllipse.cc.

                          {

}

Member Function Documentation

void pftools::CaloEllipse::addPoint ( double  x,
double  y 
) [inline]

Definition at line 29 of file CaloEllipse.h.

References dataPoints_, and point.

                                          {
                std::pair<double, double> point(x, y);
                dataPoints_.push_back(point);
        }
void pftools::CaloEllipse::clearPoints ( ) [inline]

Definition at line 34 of file CaloEllipse.h.

References dataPoints_.

                           {
                dataPoints_.clear();
        }
double CaloEllipse::getEccentricity ( ) const

Definition at line 87 of file CaloEllipse.cc.

References a, b, getMajorMinorAxes(), AlCaHLTBitMon_ParallelJobs::p, and mathSSE::sqrt().

Referenced by pftools::operator<<().

                                          {
        Point p = getMajorMinorAxes();
        double a = p.first;
        double b = p.second;
        if(a == 0)
                return 0;
        double ecc = sqrt((a * a - b * b) / (a * a));
        return ecc;
}
Point CaloEllipse::getMajorMinorAxes ( double  sigma = 1.0) const

Definition at line 48 of file CaloEllipse.cc.

References a, b, funct::cos(), dataPoints_, getPosition(), getTheta(), timingPdfMaker::mean, AlCaHLTBitMon_ParallelJobs::p, funct::sin(), mathSSE::sqrt(), theta(), and X.

Referenced by getEccentricity(), makeCaches(), and pftools::operator<<().

                                                       {

        if (dataPoints_.size() < 2) {
                return Point(0, 0);
        }

        Point mean = getPosition();

        PointCit it = dataPoints_.begin();
        double sum_xx(0.0);
        double sum_yy(0.0);
        double theta = getTheta();

        for (; it != dataPoints_.end(); ++it) {
                const Point& p = *it;
                double X = cos(theta) * (p.first - mean.first) - sin(theta) * (p.second
                                - mean.second);
                double Y = sin(theta) * (p.first - mean.first) + cos(theta) * (p.second
                                - mean.second);
                sum_xx += X * X;
                sum_yy += Y * Y;
        }

        double a = sigma * sqrt(sum_xx / dataPoints_.size());
        double b = sigma * sqrt(sum_yy / dataPoints_.size());

        double major, minor;

        if(a > b) {
                major = a;
                minor = b;
        } else {
                major = b;
                minor = a;
        }

        return Point(major, minor);
}
Point CaloEllipse::getPosition ( ) const

Definition at line 97 of file CaloEllipse.cc.

References dataPoints_, and AlCaHLTBitMon_ParallelJobs::p.

Referenced by getMajorMinorAxes(), getTheta(), and pftools::operator<<().

                                     {

        if (dataPoints_.size() < 1) {
                return Point(0, 0);
        }

        double x_tot(0.0);
        double y_tot(0.0);
        PointCit it = dataPoints_.begin();
        for (; it != dataPoints_.end(); ++it) {
                const Point& p = *it;
                x_tot += p.first;
                y_tot += p.second;

        }

        return Point(x_tot / dataPoints_.size(), y_tot / dataPoints_.size());
}
double CaloEllipse::getTheta ( ) const

Definition at line 23 of file CaloEllipse.cc.

References dataPoints_, getPosition(), timingPdfMaker::mean, AlCaHLTBitMon_ParallelJobs::p, lumiQueryAPI::q, and theta().

Referenced by getMajorMinorAxes(), makeCaches(), and pftools::operator<<().

                                   {
        if (dataPoints_.size() < 2) {
                return 0.0;
        }

        PointVector meanAdj;

        Point mean = getPosition();

        double sum_dxdx(0.0);
        double sum_dydy(0.0);
        double sum_dxdy(0.0);
        PointCit it = dataPoints_.begin();
        for (; it != dataPoints_.end(); ++it) {
                const Point& p = *it;
                Point q(p.first - mean.first, p.second - mean.second);
                meanAdj.push_back(q);
                sum_dxdx += q.first * q.first;
                sum_dydy += q.second * q.second;
                sum_dxdy += q.first * q.second;
        }
        double theta = 0.5 * atan(2.0 * sum_dxdy / (sum_dydy - sum_dxdx));
        return theta;
}
void CaloEllipse::makeCaches ( )

Definition at line 123 of file CaloEllipse.cc.

References cachedMajor_, cachedMinor_, cachedTheta_, getMajorMinorAxes(), and getTheta().

Referenced by pftools::CandidateWrapper::recompute().

                             {
        cachedTheta_ = getTheta();
        Point axes = getMajorMinorAxes();
        cachedMajor_ = axes.first;
        cachedMinor_ = axes.second;
}
void CaloEllipse::reset ( void  )
void CaloEllipse::resetCaches ( )

Definition at line 116 of file CaloEllipse.cc.

References cachedMajor_, cachedMinor_, and cachedTheta_.

Referenced by reset().

                              {
        cachedTheta_ = 0.0;
        cachedMinor_ = 0.0;
        cachedMajor_ = 0.0;

}

Member Data Documentation

Definition at line 49 of file CaloEllipse.h.

Definition at line 47 of file CaloEllipse.h.

Referenced by makeCaches(), and resetCaches().

Definition at line 48 of file CaloEllipse.h.

Referenced by makeCaches(), and resetCaches().

Definition at line 46 of file CaloEllipse.h.

Referenced by makeCaches(), and resetCaches().

std::vector<Point> pftools::CaloEllipse::dataPoints_ [private]

Definition at line 59 of file CaloEllipse.h.

Referenced by addPoint(), clearPoints(), getMajorMinorAxes(), getPosition(), getTheta(), and reset().