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