CMS 3D CMS Logo

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