CMS 3D CMS Logo

Public Types | Public Member Functions | Protected Types | Static Protected Member Functions | Private Attributes | Friends

reco::TrackResiduals Class Reference

#include <DataFormats/TrackReco/interface/TrackResiduals.h>

List of all members.

Public Types

enum  ResidualType { X_Y_RESIDUALS, X_Y_PULLS }

Public Member Functions

void print (std::ostream &stream=std::cout) const
void print (const HitPattern &, std::ostream &stream=std::cout) const
double residualX (int i, const HitPattern &) const
double residualX (int i) const
double residualY (int i, const HitPattern &) const
double residualY (int i) const
void setPullXY (int idx, double pullX, double pullY)
void setResidualType (enum ResidualType)
void setResidualXY (int idx, double residualX, double residualY)
 TrackResiduals ()
 TrackResiduals (enum ResidualType)

Protected Types

enum  { numResiduals = 0x40 }
 

number of residuals stored

More...

Static Protected Member Functions

static unsigned char pack_pull (double)
static unsigned char pack_residual (double)
static double unpack_pull (unsigned char)
static double unpack_residual (unsigned char)

Private Attributes

unsigned char residuals_ [numResiduals]
 residuals, bitpacked two hits to a char
char residualType

Friends

class Trajectory

Detailed Description

Author:
Version:
Id:
TrackResiduals.h,v 1.2 2008/05/05 22:56:59 jmuelmen Exp

Definition at line 18 of file TrackResiduals.h.


Member Enumeration Documentation

anonymous enum [protected]

number of residuals stored

Enumerator:
numResiduals 

Definition at line 25 of file TrackResiduals.h.

{ numResiduals = 0x40 };
Enumerator:
X_Y_RESIDUALS 
X_Y_PULLS 

Definition at line 21 of file TrackResiduals.h.


Constructor & Destructor Documentation

TrackResiduals::TrackResiduals ( )

Definition at line 11 of file TrackResiduals.cc.

References residuals_.

                                : residualType(X_Y_RESIDUALS)
{
     memset(residuals_, 0, sizeof(residuals_));
}
TrackResiduals::TrackResiduals ( enum ResidualType  type)

Definition at line 16 of file TrackResiduals.cc.

References residuals_.

                                                      : residualType(type)
{
     memset(residuals_, 0, sizeof(residuals_));
}

Member Function Documentation

unsigned char TrackResiduals::pack_pull ( double  pull) [static, protected]

Definition at line 121 of file TrackResiduals.cc.

References mag(), pull_char_to_double, and FWPFMaths::sgn().

Referenced by setPullXY().

{
     unsigned char sgn = (pull < 0) * 0x08; // 1xxx is -abs(0xxx)
     int mag = -1;
     while (++mag < 8 && pull_char_to_double[mag][1] < fabs(pull));
     return sgn + mag;
}
unsigned char TrackResiduals::pack_residual ( double  pull) [static, protected]

Definition at line 148 of file TrackResiduals.cc.

References mag(), pull_char_to_double, and FWPFMaths::sgn().

Referenced by setResidualXY().

{
     unsigned char sgn = (pull < 0) * 0x08; // 1xxx is -abs(0xxx)
     int mag = -1;
     while (++mag < 8 && pull_char_to_double[mag][1] < fabs(pull));
     return sgn + mag;
}
void TrackResiduals::print ( std::ostream &  stream = std::cout) const

Definition at line 156 of file TrackResiduals.cc.

References flags, i, numResiduals, and residuals_.

{
     stream << "TrackResiduals" << std::endl;
     std::ios_base::fmtflags flags = stream.flags();
     stream.setf ( std::ios_base::hex, std::ios_base::basefield );  
     stream.setf ( std::ios_base::showbase );               
     for (int i = 0; i < numResiduals; i++) {
          unsigned char residual = residuals_[i];
          printf("0x%x\n", residual);
//        stream << residual << std::endl;
     }
     stream.flags(flags);
}
void TrackResiduals::print ( const HitPattern h,
std::ostream &  stream = std::cout 
) const

Definition at line 170 of file TrackResiduals.cc.

References reco::HitPattern::getHitPattern(), i, reco::HitPattern::numberOfHits(), residualX(), residualY(), and reco::HitPattern::validHitFilter().

{
     stream << "TrackResiduals" << std::endl;
     for (int i = 0; i < h.numberOfHits(); i++) {
          stream << (h.validHitFilter(h.getHitPattern(i)) ? 
                     "valid hit:   " : "invalid hit: ") << 
               "( " << residualX(i, h) << " , " << residualY(i, h) << " )" << 
               std::endl;
     }
}
double TrackResiduals::residualX ( int  i) const

get the residual of the ith valid hit, with no regard for alignment with the HitPattern

Definition at line 35 of file TrackResiduals.cc.

References residuals_, residualType, unpack_pull(), unpack_residual(), X_Y_PULLS, and X_Y_RESIDUALS.

{
     switch (residualType) {
     case X_Y_RESIDUALS:
          return unpack_residual(residuals_[i] >> 4);
     case X_Y_PULLS:
          return unpack_pull(residuals_[i] >> 4);
     default:
          assert(0);
     }
     return 0;
}
double TrackResiduals::residualX ( int  i,
const HitPattern h 
) const

get the residual of the ith hit (needs the hit pattern to figure out which hits are valid)

Definition at line 76 of file TrackResiduals.cc.

References index_to_hitpattern().

Referenced by FWTrackResidualDetailView::prepareData(), and print().

{
     int idx = index_to_hitpattern(i, h);
     if (idx == -999)
          return -999;
     return residualX(idx);
}
double TrackResiduals::residualY ( int  i) const

Definition at line 48 of file TrackResiduals.cc.

References residuals_, residualType, unpack_pull(), unpack_residual(), X_Y_PULLS, and X_Y_RESIDUALS.

{
     switch (residualType) {
     case X_Y_RESIDUALS:
          return unpack_residual(residuals_[i] & 0x0f);
     case X_Y_PULLS:
          return unpack_pull(residuals_[i] & 0x0f);
     default:
          assert(0);
     }
     return 0;
}
double TrackResiduals::residualY ( int  i,
const HitPattern h 
) const

Definition at line 84 of file TrackResiduals.cc.

References index_to_hitpattern().

Referenced by FWTrackResidualDetailView::prepareData(), and print().

{
     int idx = index_to_hitpattern(i, h);
     if (idx == -999)
          return -999;
     return residualY(idx);
}
void TrackResiduals::setPullXY ( int  idx,
double  pullX,
double  pullY 
)

Definition at line 92 of file TrackResiduals.cc.

References numResiduals, pack_pull(), residuals_, residualType, and X_Y_PULLS.

Referenced by trajectoryToResiduals().

{
     assert(residualType == X_Y_PULLS);
     if (idx>=numResiduals) {
       edm::LogWarning("TrackResiduals")<<" setting pulls over the array size.";
       return;}

     residuals_[idx] = (pack_pull(pullX) << 4) | pack_pull(pullY);
}
void TrackResiduals::setResidualType ( enum ResidualType  type)

Definition at line 21 of file TrackResiduals.cc.

References residualType.

void TrackResiduals::setResidualXY ( int  idx,
double  residualX,
double  residualY 
)

Definition at line 26 of file TrackResiduals.cc.

References numResiduals, pack_residual(), residuals_, residualType, and X_Y_RESIDUALS.

Referenced by trajectoryToResiduals().

{
     assert(residualType == X_Y_RESIDUALS);
     if (idx>=numResiduals) {
       edm::LogWarning("TrackResiduals")<<" setting residual over the array size.";
       return;}
     residuals_[idx] = (pack_residual(residualX) << 4) | pack_residual(residualY);
}
double TrackResiduals::unpack_pull ( unsigned char  pull) [static, protected]

Definition at line 113 of file TrackResiduals.cc.

References mag(), pull_char_to_double, and FWPFMaths::sgn().

Referenced by residualX(), and residualY().

{
     int sgn = 1 - 2 * ((pull & 0x08) >> 3);
     unsigned char mag = pull & 0x07;
     return sgn * 
          (pull_char_to_double[mag][0] + pull_char_to_double[mag][1]) / 2;
}
double TrackResiduals::unpack_residual ( unsigned char  pull) [static, protected]

Definition at line 140 of file TrackResiduals.cc.

References mag(), pull_char_to_double, and FWPFMaths::sgn().

Referenced by residualX(), and residualY().

{
     int sgn = 1 - 2 * ((pull & 0x08) >> 3);
     unsigned char mag = pull & 0x07;
     return sgn * 
          (pull_char_to_double[mag][0] + pull_char_to_double[mag][1]) / 2;
}

Friends And Related Function Documentation

friend class Trajectory [friend]

Definition at line 19 of file TrackResiduals.h.


Member Data Documentation

unsigned char reco::TrackResiduals::residuals_[numResiduals] [private]

residuals, bitpacked two hits to a char

Definition at line 71 of file TrackResiduals.h.

Referenced by print(), residualX(), residualY(), setPullXY(), setResidualXY(), and TrackResiduals().

Definition at line 72 of file TrackResiduals.h.

Referenced by residualX(), residualY(), setPullXY(), setResidualType(), and setResidualXY().