CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PTrajectoryStateOnDet.h
Go to the documentation of this file.
1 #ifndef PTrajectoryStateOnDet_H
2 #define PTrajectoryStateOnDet_H
3 
5 #include <cassert>
11 public:
12  // little endian...
13  struct Packing {
14  unsigned int rest : 30;
15  unsigned char ss : 2;
16  };
17  struct DetPack {
18  unsigned int loc : 25;
19  unsigned char sub : 3;
20  unsigned char det : 4;
21  };
22 
23 private:
24  // we assume that id cannot be calo! (i.e. det<4)
25  static const unsigned int idMask = 0x3fffffff;
26  union Pack {
27  Pack() {}
28  Pack(unsigned int pack) : packed(pack) {}
29  Pack(unsigned int id, int surfaceSide) : packed(id) {
31  assert(surfaceSide < 3);
32  assert((id >> 28) < 4);
33  }
34  int side() const { return bytes.ss; }
35  unsigned int id() const { return packed & idMask; }
36  unsigned int packed;
39  };
40 
41 public:
43 
44  PTrajectoryStateOnDet(const LocalTrajectoryParameters& param, float ipt, unsigned int id, int surfaceSide)
45  : theLocalParameters(param), thePt(ipt) {
46  Pack p(id, surfaceSide);
47  thePack = p.packed;
48  theLocalErrors[0] = -99999.e10;
49  }
50 
52  const LocalTrajectoryParameters& param, float ipt, float errmatrix[15], unsigned int id, int surfaceSide)
53  : theLocalParameters(param), thePt(ipt) {
54  Pack p(id, surfaceSide);
55  thePack = p.packed;
56  for (int i = 0; i < 15; i++)
57  theLocalErrors[i] = errmatrix[i];
58  }
59 
61  float pt() const { return thePt; }
62  bool hasError() const { return theLocalErrors[0] > -1.e10; }
63  float& error(int i) { return theLocalErrors[i]; }
64  float error(int i) const { return theLocalErrors[i]; }
65  unsigned int detId() const { return thePack & idMask; }
66  int surfaceSide() const {
67  Pack p(thePack);
68  return p.side();
69  }
70 
71 private:
73  float theLocalErrors[15] = {};
74  float thePt = 0;
75  unsigned int thePack = 0;
76 };
77 
78 #endif
float error(int i) const
assert(be >=bs)
Pack(unsigned int id, int surfaceSide)
PTrajectoryStateOnDet(const LocalTrajectoryParameters &param, float ipt, unsigned int id, int surfaceSide)
PTrajectoryStateOnDet(const LocalTrajectoryParameters &param, float ipt, float errmatrix[15], unsigned int id, int surfaceSide)
unsigned int detId() const
const LocalTrajectoryParameters & parameters() const
static const unsigned int idMask
LocalTrajectoryParameters theLocalParameters