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.), flags_(0), aux_(0) { }
7 
8 EcalUncalibratedRecHit::EcalUncalibratedRecHit(const DetId& id, double ampl, double ped,
9  double jit, double chi2, uint32_t flags, uint32_t aux) :
10  amplitude_(ampl), pedestal_(ped), jitter_(jit), chi2_(chi2), flags_(flags), aux_(aux), id_(id) { }
11 
13 }
14 
16  return ( recoFlag() == kSaturated );
17 }
18 
20 {
21  uint32_t rawEnergy = (0x1FFF & flags_>>4);
22  uint16_t exponent = rawEnergy>>10;
23  uint16_t significand = ~(0xE<<9) & rawEnergy;
24  return (float) significand*pow(10,exponent-5);
25 }
26 
28 {
29  flags_ = (~0xF & flags_) | (flag & 0xF);
30 }
31 
33 {
34  if ( energy > 0.001 ) {
35  uint16_t exponent = lround(floor(log10(energy)))+3;
36  uint16_t significand = lround(energy/pow(10,exponent-5));
37  uint32_t rawEnergy = exponent<<10 | significand;
38  setFlags( ( ~(0x1FFF<<4) & flags_) | ((rawEnergy & 0x1FFF)<<4) );
39  }
40 }
41 
43 {
44  // use 7 bits
45  if ( chi2 > 64. ) chi2 = 64.;
46  uint32_t rawChi2 = lround( chi2 / 64. * ((1<<7)-1) );
47  // shift by 17 bits (recoFlag + outOfTimeEnergy)
48  setFlags( (~(0x7F<<17) & flags_) | ((rawChi2 & 0x7F)<<17) );
49 }
50 
52 {
53  uint32_t rawChi2 = 0x7F & (flags_>>17);
54  return (float)rawChi2 / (float)((1<<7)-1) * 64.;
55 }
56 
58 {
59  // stored in ps, but return BXs to match with jitter units
60  uint32_t jitterErrorBits = 0xFF & aux_;
61  // all bits off --> time reco bailed out (return negative value)
62  if( (0xFF & jitterErrorBits) == 0x00)
63  return -1;
64  // all bits on --> time error over 5 ns (return large value)
65  if( (0xFF & jitterErrorBits) == 0xFF)
66  return 10000;
67 
68  float LSB = 1.26008;
69  uint8_t exponent = jitterErrorBits>>5;
70  uint8_t significand = jitterErrorBits & ~(0x7<<5);
71  return (float)(pow(2.,exponent)*significand*LSB)/(25.*1000);
72 }
73 
75 {
76  // use 8 bits (3 exp, 5 mant) and store in ps
77  // has range of 5 ps - 5000 ps
78  // expect input in BX units
79  // all bits off --> time reco bailed out
80  if(jitterErr < 0)
81  {
82  aux_ = (~0xFF & aux_);
83  return;
84  }
85  // all bits on --> time error over 5 ns
86  if(25*jitterErr >= 5)
87  {
88  aux_ = (0xFF | aux_);
89  return;
90  }
91 
92  float LSB = 1.26008;
93  float quantityInLSB = (1000*25*jitterErr)/LSB;
94  int log2OfQuantity = (int) (log2( quantityInLSB ));
95  int exponentTmp = log2OfQuantity - 4;
96  uint8_t exponent=0;
97  if (exponentTmp>0) exponent = exponentTmp;
98  uint8_t significand = (int) ( lround( quantityInLSB / pow(2.,exponent) ) );
99  uint32_t jitterErrorBits = exponent<<5 | significand;
100 
101  if( (0xFF & jitterErrorBits) == 0xFF)
102  jitterErrorBits = 0xFE;
103  if( (0xFF & jitterErrorBits) == 0x00)
104  jitterErrorBits = 0x01;
105 
106  aux_ = (~0xFF & aux_) | (jitterErrorBits & 0xFF);
107 
108 }
109 
111 {
112  if(jitterError() <= 0)
113  return false;
114  else
115  return true;
116 }
117 
119 {
120  if(!isJitterValid())
121  return false;
122  if(jitterError() >= 10000)
123  return false;
124 
125  return true;
126 }
127 
129 {
130  uint8_t jitterErrorBits = 0xFF & aux_;
131  return jitterErrorBits;
132 }
long int flag
Definition: mlp_lapack.h:47
void setRecoFlag(uint32_t flags)
std::vector< Variable::Flags > flags
Definition: MVATrainer.cc:135
void setJitterError(float jitterErr)
void setFlags(uint32_t flags)
Definition: DetId.h:20
void setOutOfTimeEnergy(float energy)
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40