CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Protected Types | Static Protected Member Functions | Private Attributes | Friends
reco::TrackResiduals Class Reference

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

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 More...
 
char residualType
 

Friends

class Trajectory
 

Detailed Description

Author

Definition at line 17 of file TrackResiduals.h.

Member Enumeration Documentation

anonymous enum
protected

number of residuals stored

Enumerator
numResiduals 

Definition at line 24 of file TrackResiduals.h.

Enumerator
X_Y_RESIDUALS 
X_Y_PULLS 

Definition at line 20 of file TrackResiduals.h.

Constructor & Destructor Documentation

TrackResiduals::TrackResiduals ( )

Definition at line 11 of file TrackResiduals.cc.

References residuals_.

12 {
13  memset(residuals_, 0, sizeof(residuals_));
14 }
unsigned char residuals_[numResiduals]
residuals, bitpacked two hits to a char
TrackResiduals::TrackResiduals ( enum ResidualType  type)

Definition at line 16 of file TrackResiduals.cc.

References residuals_.

17 {
18  memset(residuals_, 0, sizeof(residuals_));
19 }
type
Definition: HCALResponse.h:21
unsigned char residuals_[numResiduals]
residuals, bitpacked two hits to a char

Member Function Documentation

unsigned char TrackResiduals::pack_pull ( double  pull)
staticprotected

Definition at line 121 of file TrackResiduals.cc.

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

Referenced by setPullXY().

122 {
123  unsigned char sgn = (pull < 0) * 0x08; // 1xxx is -abs(0xxx)
124  int mag = -1;
125  while (++mag < 8 && pull_char_to_double[mag][1] < fabs(pull));
126  return sgn + mag;
127 }
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
float sgn(float val)
Definition: FWPFMaths.cc:9
static const double pull_char_to_double[8][2]
unsigned char TrackResiduals::pack_residual ( double  pull)
staticprotected

Definition at line 148 of file TrackResiduals.cc.

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

Referenced by setResidualXY().

149 {
150  unsigned char sgn = (pull < 0) * 0x08; // 1xxx is -abs(0xxx)
151  int mag = -1;
152  while (++mag < 8 && pull_char_to_double[mag][1] < fabs(pull));
153  return sgn + mag;
154 }
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
float sgn(float val)
Definition: FWPFMaths.cc:9
static const double pull_char_to_double[8][2]
void TrackResiduals::print ( std::ostream &  stream = std::cout) const

Definition at line 156 of file TrackResiduals.cc.

References flags, i, numResiduals, and residuals_.

157 {
158  stream << "TrackResiduals" << std::endl;
159  std::ios_base::fmtflags flags = stream.flags();
160  stream.setf ( std::ios_base::hex, std::ios_base::basefield );
161  stream.setf ( std::ios_base::showbase );
162  for (int i = 0; i < numResiduals; i++) {
163  unsigned char residual = residuals_[i];
164  printf("0x%x\n", residual);
165 // stream << residual << std::endl;
166  }
167  stream.flags(flags);
168 }
int i
Definition: DBlmapReader.cc:9
std::vector< Variable::Flags > flags
Definition: MVATrainer.cc:135
unsigned char residuals_[numResiduals]
residuals, bitpacked two hits to a char
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().

171 {
172  stream << "TrackResiduals" << std::endl;
173  for (int i = 0; i < h.numberOfHits(); i++) {
174  stream << (h.validHitFilter(h.getHitPattern(i)) ?
175  "valid hit: " : "invalid hit: ") <<
176  "( " << residualX(i, h) << " , " << residualY(i, h) << " )" <<
177  std::endl;
178  }
179 }
int i
Definition: DBlmapReader.cc:9
double residualY(int i, const HitPattern &) const
int numberOfHits() const
Definition: HitPattern.cc:211
static bool validHitFilter(uint32_t pattern)
Definition: HitPattern.h:564
double residualX(int i, const HitPattern &) const
uint32_t getHitPattern(int position) const
Definition: HitPattern.cc:142
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 customizeTrackingMonitorSeedNumber::idx, and index_to_hitpattern().

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

77 {
78  int idx = index_to_hitpattern(i, h);
79  if (idx == -999)
80  return -999;
81  return residualX(idx);
82 }
int i
Definition: DBlmapReader.cc:9
static int index_to_hitpattern(int i_hitpattern, const HitPattern &h)
double residualX(int i, const HitPattern &) const
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
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.

36 {
37  switch (residualType) {
38  case X_Y_RESIDUALS:
39  return unpack_residual(residuals_[i] >> 4);
40  case X_Y_PULLS:
41  return unpack_pull(residuals_[i] >> 4);
42  default:
43  assert(0);
44  }
45  return 0;
46 }
int i
Definition: DBlmapReader.cc:9
static double unpack_residual(unsigned char)
unsigned char residuals_[numResiduals]
residuals, bitpacked two hits to a char
static double unpack_pull(unsigned char)
double TrackResiduals::residualY ( int  i,
const HitPattern h 
) const

Definition at line 84 of file TrackResiduals.cc.

References customizeTrackingMonitorSeedNumber::idx, and index_to_hitpattern().

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

85 {
86  int idx = index_to_hitpattern(i, h);
87  if (idx == -999)
88  return -999;
89  return residualY(idx);
90 }
int i
Definition: DBlmapReader.cc:9
double residualY(int i, const HitPattern &) const
static int index_to_hitpattern(int i_hitpattern, const HitPattern &h)
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
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.

49 {
50  switch (residualType) {
51  case X_Y_RESIDUALS:
52  return unpack_residual(residuals_[i] & 0x0f);
53  case X_Y_PULLS:
54  return unpack_pull(residuals_[i] & 0x0f);
55  default:
56  assert(0);
57  }
58  return 0;
59 }
int i
Definition: DBlmapReader.cc:9
static double unpack_residual(unsigned char)
unsigned char residuals_[numResiduals]
residuals, bitpacked two hits to a char
static double unpack_pull(unsigned char)
void TrackResiduals::setPullXY ( int  idx,
double  pullX,
double  pullY 
)

Definition at line 92 of file TrackResiduals.cc.

References customizeTrackingMonitorSeedNumber::idx, numResiduals, pack_pull(), residuals_, residualType, and X_Y_PULLS.

Referenced by trajectoryToResiduals().

93 {
94  assert(residualType == X_Y_PULLS);
95  if (idx>=numResiduals) {
96  edm::LogWarning("TrackResiduals")<<" setting pulls over the array size.";
97  return;}
98 
99  residuals_[idx] = (pack_pull(pullX) << 4) | pack_pull(pullY);
100 }
unsigned char residuals_[numResiduals]
residuals, bitpacked two hits to a char
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
static unsigned char pack_pull(double)
void TrackResiduals::setResidualType ( enum ResidualType  type)

Definition at line 21 of file TrackResiduals.cc.

References residualType.

22 {
24 }
type
Definition: HCALResponse.h:21
void TrackResiduals::setResidualXY ( int  idx,
double  residualX,
double  residualY 
)

Definition at line 26 of file TrackResiduals.cc.

References customizeTrackingMonitorSeedNumber::idx, numResiduals, pack_residual(), residuals_, residualType, and X_Y_RESIDUALS.

Referenced by trajectoryToResiduals().

27 {
28  assert(residualType == X_Y_RESIDUALS);
29  if (idx>=numResiduals) {
30  edm::LogWarning("TrackResiduals")<<" setting residual over the array size.";
31  return;}
33 }
double residualY(int i, const HitPattern &) const
unsigned char residuals_[numResiduals]
residuals, bitpacked two hits to a char
double residualX(int i, const HitPattern &) const
static unsigned char pack_residual(double)
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
double TrackResiduals::unpack_pull ( unsigned char  pull)
staticprotected

Definition at line 113 of file TrackResiduals.cc.

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

Referenced by residualX(), and residualY().

114 {
115  int sgn = 1 - 2 * ((pull & 0x08) >> 3);
116  unsigned char mag = pull & 0x07;
117  return sgn *
119 }
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
float sgn(float val)
Definition: FWPFMaths.cc:9
static const double pull_char_to_double[8][2]
double TrackResiduals::unpack_residual ( unsigned char  pull)
staticprotected

Definition at line 140 of file TrackResiduals.cc.

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

Referenced by residualX(), and residualY().

141 {
142  int sgn = 1 - 2 * ((pull & 0x08) >> 3);
143  unsigned char mag = pull & 0x07;
144  return sgn *
146 }
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
float sgn(float val)
Definition: FWPFMaths.cc:9
static const double pull_char_to_double[8][2]

Friends And Related Function Documentation

friend class Trajectory
friend

Definition at line 18 of file TrackResiduals.h.

Member Data Documentation

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

residuals, bitpacked two hits to a char

Definition at line 70 of file TrackResiduals.h.

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

char reco::TrackResiduals::residualType
private

Definition at line 71 of file TrackResiduals.h.

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