CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalUncalibratedRecHit.cc
Go to the documentation of this file.
3 #include <cmath>
4 
5 
6 
9 }
10 
11 
13 {
14  // stored in ps, but return BXs to match with jitter units
15  uint32_t jitterErrorBits = 0xFF & aux_;
16  // all bits off --> time reco bailed out (return negative value)
17  if( (0xFF & jitterErrorBits) == 0x00)
18  return -1;
19  // all bits on --> time error over 5 ns (return large value)
20  if( (0xFF & jitterErrorBits) == 0xFF)
21  return 10000;
22 
23  float LSB = 1.26008;
24  uint8_t exponent = jitterErrorBits>>5;
25  uint8_t significand = jitterErrorBits & ~(0x7<<5);
26  return (float)(std::pow(2,exponent)*significand*LSB)/(25.*1000);
27 }
28 
30 {
31  // use 8 bits (3 exp, 5 mant) and store in ps
32  // has range of 5 ps - 5000 ps
33  // expect input in BX units
34  // all bits off --> time reco bailed out
35  if(jitterErr < 0)
36  {
37  aux_ = (~0xFF & aux_);
38  return;
39  }
40  // all bits on --> time error over 5 ns
41  if(25*jitterErr >= 5)
42  {
43  aux_ = (0xFF | aux_);
44  return;
45  }
46 
47  float LSB = 1.26008;
48  float quantityInLSB = (1000*25*jitterErr)/LSB;
49  int log2OfQuantity = (int) (log2( quantityInLSB ));
50  int exponentTmp = log2OfQuantity - 4;
51  uint8_t exponent=0;
52  if (exponentTmp>0) exponent = exponentTmp;
53  uint8_t significand = (int) ( std::lround( quantityInLSB / std::pow(2,exponent) ) );
54  uint32_t jitterErrorBits = exponent<<5 | significand;
55 
56  if( (0xFF & jitterErrorBits) == 0xFF)
57  jitterErrorBits = 0xFE;
58  if( (0xFF & jitterErrorBits) == 0x00)
59  jitterErrorBits = 0x01;
60 
61  aux_ = (~0xFF & aux_) | (jitterErrorBits & 0xFF);
62 
63 }
64 
66 {
67  if(jitterError() <= 0)
68  return false;
69  else
70  return true;
71 }
72 
74 {
75  if(!isJitterValid())
76  return false;
77  if(jitterError() >= 10000)
78  return false;
79 
80  return true;
81 }
82 
84 {
85  uint8_t jitterErrorBits = 0xFF & aux_;
86  return jitterErrorBits;
87 }
88 
89 
91  if (flag == kGood) {
92  //then set all bits to zero;
93  flags_ = 0;
94  return;
95  }
96  // else set the flagbit
97  flags_|= 0x1 << flag;
98 }
99 
100 
102  if(flag == kGood){ if ( ! flags_ ) return true;else return false;} // if all flags are unset, then hit is good
103  return flags_ & ( 0x1<<flag);
104 }
105 
void setJitterError(float jitterErr)
bool checkFlag(Flags flag) const
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40