CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CastorQIEShape.cc
Go to the documentation of this file.
1 
7 
8 namespace {
9  /*const float binMin [32] = {-1, 0, 1, 2, 3, 4, 5, 6, 7, 8,
10  9, 10, 11, 12, 13, 14, 16, 18, 20, 22,
11  24, 26, 28, 31, 34, 37, 40, 44, 48, 52,
12  57, 62}; */
13 
14 const float binMin [32] = {-3, -0.4, 2.2, 4.8, 7.4, 10, 12.6, 15.2,
15  17.8, 20.4, 23, 25.6, 28.2, 30.8 ,33.4, 36,
16  41.2, 46.4, 51.6, 56.8, 62, 67.2, 73, 80.8,
17  88.6, 96.4, 104, 114.4, 124.8, 135, 148, 161};
18 
19  }
20 
22 {
23  for (int i = 0; i < 32; i++) mValues [i] = binMin [i];
24  expand ();
25 }
26 
28 
30  int scale = 1;
31  for (unsigned range = 1; range < 4; range++) {
32  scale = scale * 5;
33  unsigned index = range * 32;
34  mValues [index] = mValues [index - 2]; // link to previous range
35  for (unsigned i = 1; i < 32; i++) {
36  mValues [index + i] = mValues [index + i - 1] + scale * (mValues [i] - mValues [i - 1]);
37  }
38  }
39  mValues [128] = 2 * mValues [127] - mValues [126]; // extrapolate
40 }
41 
42 float CastorQIEShape::lowEdge (unsigned fAdc) const {
43  if (fAdc < 128) return mValues [fAdc];
44  return 0.;
45 }
46 
47 float CastorQIEShape::center (unsigned fAdc) const {
48  if (fAdc < 128) {
49  if (fAdc % 32 == 31) return 0.5 * (3 * mValues [fAdc] - mValues [fAdc - 1]); // extrapolate
50  else return 0.5 * (mValues [fAdc] + mValues [fAdc + 1]); // interpolate
51  }
52  return 0.;
53 }
54 
55 float CastorQIEShape::highEdge (unsigned fAdc) const {
56  if (fAdc >= 128 ) return 0;
57  if (fAdc == 127 ) return mValues [fAdc+1];
58  if (fAdc % 32 == 31) return mValues [fAdc+3];
59  return mValues [fAdc+1];
60 }
61 
62 bool CastorQIEShape::setLowEdge (float fValue, unsigned fAdc) {
63  if (fAdc >= 32) return false;
64  mValues [fAdc] = fValue;
65  return true;
66 }
67 
68 bool CastorQIEShape::setLowEdges (const float fValue [32]) {
69  bool result = true;
70  for (int adc = 0; adc < 32; adc++) result = result && setLowEdge (fValue [adc], adc);
71  expand ();
72  return result;
73 }
int adc(sample_type sample)
get the ADC sample (12 bits)
int i
Definition: DBlmapReader.cc:9
bool setLowEdges(const float fValue[32])
unsigned range(unsigned fAdc) const
float highEdge(unsigned fAdc) const
tuple result
Definition: query.py:137
float mValues[129]
float center(unsigned fAdc) const
bool setLowEdge(float fValue, unsigned fAdc)
float lowEdge(unsigned fAdc) const