CMS 3D CMS Logo

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