CMS 3D CMS Logo

HGCUncalibratedRecHit.cc
Go to the documentation of this file.
2 #include <cmath>
3 
5  : amplitude_(0.),
6  pedestal_(0.),
7  jitter_(0.),
8  chi2_(10000.),
9  OOTamplitude_(0.),
10  OOTchi2_(10000.),
11  flags_(0),
12  aux_(0) {}
13 
15  const DetId& id, float ampl, float ped, float jit, float chi2, uint32_t flags, uint32_t aux)
16  : amplitude_(ampl),
17  pedestal_(ped),
18  jitter_(jit),
19  chi2_(chi2),
20  OOTamplitude_(0.),
21  OOTchi2_(10000.),
22  flags_(flags),
23  aux_(aux),
24  id_(id) {}
25 
27 
29 
31  // stored in ps, but return BXs to match with jitter units
32  uint32_t jitterErrorBits = 0xFF & aux_;
33  // all bits off --> time reco bailed out (return negative value)
34  if ((0xFF & jitterErrorBits) == 0x00)
35  return -1;
36  // all bits on --> time error over 5 ns (return large value)
37  if ((0xFF & jitterErrorBits) == 0xFF)
38  return 10000;
39 
40  float LSB = 1.26008;
41  uint8_t exponent = jitterErrorBits >> 5;
42  uint8_t significand = jitterErrorBits & ~(0x7 << 5);
43  return (float)(pow(2., exponent) * significand * LSB) / (25. * 1000);
44 }
45 
47  // use 8 bits (3 exp, 5 mant) and store in ps
48  // has range of 5 ps - 5000 ps
49  // expect input in BX units
50  // all bits off --> time reco bailed out
51  if (jitterErr < 0) {
52  aux_ = (~0xFF & aux_);
53  return;
54  }
55  // all bits on --> time error over 5 ns
56  if (25 * jitterErr >= 5) {
57  aux_ = (0xFF | aux_);
58  return;
59  }
60 
61  float LSB = 1.26008;
62  float quantityInLSB = (1000 * 25 * jitterErr) / LSB;
63  int log2OfQuantity = (int)(log2(quantityInLSB));
64  int exponentTmp = log2OfQuantity - 4;
65  uint8_t exponent = 0;
66  if (exponentTmp > 0)
67  exponent = exponentTmp;
68  uint8_t significand = (int)(lround(quantityInLSB / pow(2., exponent)));
69  uint32_t jitterErrorBits = exponent << 5 | significand;
70 
71  if ((0xFF & jitterErrorBits) == 0xFF)
72  jitterErrorBits = 0xFE;
73  if ((0xFF & jitterErrorBits) == 0x00)
74  jitterErrorBits = 0x01;
75 
76  aux_ = (~0xFF & aux_) | (jitterErrorBits & 0xFF);
77 }
78 
80  if (jitterError() <= 0)
81  return false;
82  else
83  return true;
84 }
85 
87  if (!isJitterValid())
88  return false;
89  if (jitterError() >= 10000)
90  return false;
91 
92  return true;
93 }
94 
96  uint8_t jitterErrorBits = 0xFF & aux_;
97  return jitterErrorBits;
98 }
99 
101  if (flag == kGood) {
102  //then set all bits to zero;
103  flags_ = 0;
104  return;
105  }
106  // else set the flagbit
107  flags_ |= 0x1 << flag;
108 }
109 
111  if (flag == kGood) {
112  if (!flags_)
113  return true;
114  else
115  return false;
116  } // if all flags are unset, then hit is good
117  return flags_ & (0x1 << flag);
118 }
uint8_t jitterErrorBits() const
bool checkFlag(Flags flag) const
Definition: DetId.h:17
void setJitterError(float jitterErr)
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30