#include <DataFormats/TrackReco/interface/TrackResiduals.h>
Public Types | |
enum | ResidualType { X_Y_RESIDUALS, X_Y_PULLS } |
Public Member Functions | |
void | print (const HitPattern &, std::ostream &stream=std::cout) const |
void | print (std::ostream &stream=std::cout) const |
double | residualX (int i) const |
get the residual of the ith valid hit, with no regard for alignment with the HitPattern | |
double | residualX (int i, const HitPattern &) const |
get the residual of the ith hit (needs the hit pattern to figure out which hits are valid) | |
double | residualY (int i) const |
double | residualY (int i, const HitPattern &) const |
void | setPullXY (int idx, double pullX, double pullY) |
void | setResidualType (enum ResidualType) |
void | setResidualXY (int idx, double residualX, double residualY) |
TrackResiduals (enum ResidualType) | |
TrackResiduals () | |
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 |
Definition at line 18 of file TrackResiduals.h.
anonymous enum [protected] |
number of residuals stored
Definition at line 25 of file TrackResiduals.h.
00025 { numResiduals = 0x40 };
TrackResiduals::TrackResiduals | ( | ) |
Definition at line 6 of file TrackResiduals.cc.
References residuals_.
00006 : residualType(X_Y_RESIDUALS) 00007 { 00008 memset(residuals_, 0, sizeof(residuals_)); 00009 }
TrackResiduals::TrackResiduals | ( | enum ResidualType | type | ) |
Definition at line 11 of file TrackResiduals.cc.
References residuals_.
00011 : residualType(type) 00012 { 00013 memset(residuals_, 0, sizeof(residuals_)); 00014 }
unsigned char TrackResiduals::pack_pull | ( | double | pull | ) | [static, protected] |
Definition at line 109 of file TrackResiduals.cc.
References muonGeometry::mag(), pull_char_to_double, and funct::sgn().
Referenced by setPullXY().
00110 { 00111 unsigned char sgn = (pull < 0) * 0x08; // 1xxx is -abs(0xxx) 00112 int mag = -1; 00113 while (++mag < 8 && pull_char_to_double[mag][1] < fabs(pull)); 00114 return sgn + mag; 00115 }
unsigned char TrackResiduals::pack_residual | ( | double | pull | ) | [static, protected] |
Definition at line 136 of file TrackResiduals.cc.
References muonGeometry::mag(), pull_char_to_double, and funct::sgn().
Referenced by setResidualXY().
00137 { 00138 unsigned char sgn = (pull < 0) * 0x08; // 1xxx is -abs(0xxx) 00139 int mag = -1; 00140 while (++mag < 8 && pull_char_to_double[mag][1] < fabs(pull)); 00141 return sgn + mag; 00142 }
void TrackResiduals::print | ( | const HitPattern & | h, | |
std::ostream & | stream = std::cout | |||
) | const |
Definition at line 158 of file TrackResiduals.cc.
References lat::endl(), reco::HitPattern::getHitPattern(), i, reco::HitPattern::numberOfHits(), residualX(), residualY(), and reco::HitPattern::validHitFilter().
00159 { 00160 stream << "TrackResiduals" << std::endl; 00161 for (int i = 0; i < h.numberOfHits(); i++) { 00162 stream << (h.validHitFilter(h.getHitPattern(i)) ? 00163 "valid hit: " : "invalid hit: ") << 00164 "( " << residualX(i, h) << " , " << residualY(i, h) << " )" << 00165 std::endl; 00166 } 00167 }
void TrackResiduals::print | ( | std::ostream & | stream = std::cout |
) | const |
Definition at line 144 of file TrackResiduals.cc.
References lat::endl(), flags, i, numResiduals, and residuals_.
00145 { 00146 stream << "TrackResiduals" << std::endl; 00147 std::ios_base::fmtflags flags = stream.flags(); 00148 stream.setf ( std::ios_base::hex, std::ios_base::basefield ); 00149 stream.setf ( std::ios_base::showbase ); 00150 for (int i = 0; i < numResiduals; i++) { 00151 unsigned char residual = residuals_[i]; 00152 printf("0x%x\n", residual); 00153 // stream << residual << std::endl; 00154 } 00155 stream.flags(flags); 00156 }
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 27 of file TrackResiduals.cc.
References residuals_, residualType, unpack_pull(), unpack_residual(), X_Y_PULLS, and X_Y_RESIDUALS.
00028 { 00029 switch (residualType) { 00030 case X_Y_RESIDUALS: 00031 return unpack_residual(residuals_[i] >> 4); 00032 case X_Y_PULLS: 00033 return unpack_pull(residuals_[i] >> 4); 00034 default: 00035 assert(0); 00036 } 00037 return 0; 00038 }
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 68 of file TrackResiduals.cc.
References index_to_hitpattern().
Referenced by print().
00069 { 00070 int idx = index_to_hitpattern(i, h); 00071 if (idx == -999) 00072 return -999; 00073 return residualX(idx); 00074 }
double TrackResiduals::residualY | ( | int | i | ) | const |
Definition at line 40 of file TrackResiduals.cc.
References residuals_, residualType, unpack_pull(), unpack_residual(), X_Y_PULLS, and X_Y_RESIDUALS.
00041 { 00042 switch (residualType) { 00043 case X_Y_RESIDUALS: 00044 return unpack_residual(residuals_[i] & 0x0f); 00045 case X_Y_PULLS: 00046 return unpack_pull(residuals_[i] & 0x0f); 00047 default: 00048 assert(0); 00049 } 00050 return 0; 00051 }
double TrackResiduals::residualY | ( | int | i, | |
const HitPattern & | h | |||
) | const |
Definition at line 76 of file TrackResiduals.cc.
References index_to_hitpattern().
Referenced by print().
00077 { 00078 int idx = index_to_hitpattern(i, h); 00079 if (idx == -999) 00080 return -999; 00081 return residualY(idx); 00082 }
Definition at line 84 of file TrackResiduals.cc.
References pack_pull(), residuals_, residualType, and X_Y_PULLS.
Referenced by trajectoryToResiduals().
00085 { 00086 assert(residualType == X_Y_PULLS); 00087 residuals_[idx] = (pack_pull(pullX) << 4) | pack_pull(pullY); 00088 }
void TrackResiduals::setResidualType | ( | enum ResidualType | type | ) |
Definition at line 16 of file TrackResiduals.cc.
References residualType.
00017 { 00018 residualType = type; 00019 }
Definition at line 21 of file TrackResiduals.cc.
References pack_residual(), residuals_, residualType, and X_Y_RESIDUALS.
Referenced by trajectoryToResiduals().
00022 { 00023 assert(residualType == X_Y_RESIDUALS); 00024 residuals_[idx] = (pack_residual(residualX) << 4) | pack_residual(residualY); 00025 }
double TrackResiduals::unpack_pull | ( | unsigned char | pull | ) | [static, protected] |
Definition at line 101 of file TrackResiduals.cc.
References muonGeometry::mag(), pull_char_to_double, and funct::sgn().
Referenced by residualX(), and residualY().
00102 { 00103 int sgn = 1 - 2 * ((pull & 0x08) >> 3); 00104 unsigned char mag = pull & 0x07; 00105 return sgn * 00106 (pull_char_to_double[mag][0] + pull_char_to_double[mag][1]) / 2; 00107 }
double TrackResiduals::unpack_residual | ( | unsigned char | pull | ) | [static, protected] |
Definition at line 128 of file TrackResiduals.cc.
References muonGeometry::mag(), pull_char_to_double, and funct::sgn().
Referenced by residualX(), and residualY().
00129 { 00130 int sgn = 1 - 2 * ((pull & 0x08) >> 3); 00131 unsigned char mag = pull & 0x07; 00132 return sgn * 00133 (pull_char_to_double[mag][0] + pull_char_to_double[mag][1]) / 2; 00134 }
friend class Trajectory [friend] |
Definition at line 19 of file TrackResiduals.h.
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().
char reco::TrackResiduals::residualType [private] |
Definition at line 72 of file TrackResiduals.h.
Referenced by residualX(), residualY(), setPullXY(), setResidualType(), and setResidualXY().