CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TrackResiduals.cc
Go to the documentation of this file.
1 #include <cmath>
2 #include <limits>
4 
5 namespace reco {
6 
7  namespace {
8 
9  inline TrackResiduals::StorageType pack(float x, float min, float fact) {
11  return std::min(std::round(fact * (x - min)), amax);
12  }
13 
14  inline float unpack(TrackResiduals::StorageType x, float min, float fact) { return fact * x + min; }
15 
16  constexpr float pmin = -32; // overkill
17  constexpr float pmult = 1000; // overkill
18  constexpr float pdiv = 1. / pmult;
19  constexpr float rmin = -3.2; // (in cm)
20  constexpr float rmult = 10000; // micron
21  constexpr float rdiv = 1. / rmult;
22 
23  } // namespace
24 
25  float TrackResiduals::unpack_pull(StorageType x) { return unpack(x, pmin, pdiv); }
26  TrackResiduals::StorageType TrackResiduals::pack_pull(float x) { return pack(x, pmin, pmult); }
27  float TrackResiduals::unpack_residual(StorageType x) { return unpack(x, rmin, rdiv); }
28  TrackResiduals::StorageType TrackResiduals::pack_residual(float x) { return pack(x, rmin, rmult); }
29 
30  void TrackResiduals::setResidualXY(int idx, float residualX, float residualY) {
31  m_storage[4 * idx] = pack_residual(residualX);
32  m_storage[4 * idx + 1] = pack_residual(residualY);
33  }
34  void TrackResiduals::setPullXY(int idx, float pullX, float pullY) {
35  m_storage[4 * idx + 2] = pack_pull(pullX);
36  m_storage[4 * idx + 3] = pack_pull(pullY);
37  }
38 
39 } // namespace reco
std::pair< unsigned int, unsigned int > unpack(cond::Time_t since)
std::vector< StorageType > m_storage
static StorageType pack_pull(float)
void setResidualXY(int idx, float residualX, float residualY)
static float unpack_residual(StorageType)
static float unpack_pull(StorageType)
T min(T a, T b)
Definition: MathUtil.h:58
static StorageType pack_residual(float)
unsigned short StorageType
const double fact
void setPullXY(int idx, float pullX, float pullY)