ATLAS Offline Software
TileLasCalib.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /*author Marius Cornelis van Woerden*/
6 /*date Nov/2014*/
7 /*mvanwoer@cern.ch*/
8 
9 #ifndef TILELASCALIB_H
10 #define TILELASCALIB_H
11 
12 
13 #include <string>
14 #include <math.h>
15 
16 
17 
18 class TileLasCalib {
19 
20  public:
21 
23  : m_mean_LG(-99.)
24  , m_sigma_LG(-99.)
25  , m_mean_HG(-99.)
26  , m_sigma_HG(-99.)
27  , m_type(-1)
28  , m_nevts(0)
29  , m_isSet_LG(false)
30  , m_isSet_HG(false) { }
31 
32 
33  void setCalib(int type, double sumXinQDC, double sumX2inQDC, int nevts, int gain){
34  if(nevts > 0 && !isSet(gain) && (gain == LG || gain == HG) ){
35  double tmp_mean = sumXinQDC / double(nevts);
36  double tmp_sigma = sqrt(sumX2inQDC / nevts - tmp_mean * tmp_mean);
37  tmp_mean = 8500. - tmp_mean; // CONVERT QDC TO ADC COUNTS
38  if(tmp_mean > 0){
39  if(gain == LG){
40  m_mean_LG = tmp_mean;
41  m_sigma_LG = tmp_sigma;
42  m_isSet_LG = true;
43  } else { // IF
44  m_mean_HG = tmp_mean;
45  m_sigma_HG = tmp_sigma;
46  m_isSet_HG = true;
47  } // ELSE
48  m_type = type;
49  m_nevts = nevts;
50  } // IF
51  } // IF
52  } // setPed
53 
54  // MEAN IS CALCULATED FROM SUMX AND N EVENTS
55  // <X> = SUMX / N
56  // CONVERTED FROM QDC TO ADC BY
57  // <X>' = 8500-<X>
58 
59  double getMean(int gain) const {
60  if(gain == LG) return m_mean_LG;
61  return m_mean_HG;
62  } // getMean
63 
64  // SIGMA IS CALCULATED USING MEAN <X> AND SUMX^2
65  // SIGMA = SQRT(SUMX^2/N - <X>^2)
66 
67  double getSigma(int gain) const{
68  if(gain == LG) return m_sigma_LG;
69  return m_sigma_HG;
70  } // getSigma
71 
72  // DATA ACQUISITION TYPE VALUES
73  // TYPE HEX DEC
74  // Pedestal 0x10 16
75  // Alpha 0x11 17
76  // Led 0x12 18
77  // Linearity 0x13 19
78  // Laser 0x14 20
79 
80  // CALIBRATION TYPE VALUES
81  // TYPE HEX DEC
82  // Pedestal 0x00 0
83  // Pedestal 0x01 1
84  // Led 0x02 2
85  // Alpha 0x03 3
86 
87  int getType() const{
88  return m_type;
89  } // getType
90 
91  // NUMBER OF EVENTS USED IN PEDESTAL RUN
92 
93  int getN() const{
94  return m_nevts;
95  } // getN
96 
97  bool isSet(int gain) const{
98  if(gain == LG) return m_isSet_LG;
99  if(gain == HG) return m_isSet_HG;
100  //if(gain != LG && gain != HG) return false;
101  return false;
102  } // isSet
103 
104 
107  operator std::string() const;
108 
109 
110 private:
111 
112  static const int HG = 1;
113  static const int LG = 0;
114  double m_mean_LG;
115  double m_sigma_LG;
116  double m_mean_HG;
117  double m_sigma_HG;
118  int m_type;
119  int m_nevts;
122 
123  };
124 
125 
126 #endif
TileLasCalib::getN
int getN() const
Definition: TileLasCalib.h:93
TileLasCalib::m_nevts
int m_nevts
Definition: TileLasCalib.h:119
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
TileLasCalib::HG
static const int HG
Definition: TileLasCalib.h:112
TileLasCalib::getType
int getType() const
Definition: TileLasCalib.h:87
TileLasCalib::m_isSet_LG
bool m_isSet_LG
Definition: TileLasCalib.h:120
TileLasCalib::isSet
bool isSet(int gain) const
Definition: TileLasCalib.h:97
TileLasCalib::m_isSet_HG
bool m_isSet_HG
Definition: TileLasCalib.h:121
TileLasCalib::m_type
int m_type
Definition: TileLasCalib.h:118
TileLasCalib::LG
static const int LG
Definition: TileLasCalib.h:113
TileLasCalib::m_mean_LG
double m_mean_LG
Definition: TileLasCalib.h:114
TileLasCalib::m_mean_HG
double m_mean_HG
Definition: TileLasCalib.h:116
TileLasCalib::getSigma
double getSigma(int gain) const
Definition: TileLasCalib.h:67
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
sg-dump.nevts
nevts
Definition: sg-dump.py:146
TileLasCalib::m_sigma_HG
double m_sigma_HG
Definition: TileLasCalib.h:117
TileLasCalib::TileLasCalib
TileLasCalib()
Definition: TileLasCalib.h:22
TileLasCalib::getMean
double getMean(int gain) const
Definition: TileLasCalib.h:59
TileLasCalib::m_sigma_LG
double m_sigma_LG
Definition: TileLasCalib.h:115
TileLasCalib
Definition: TileLasCalib.h:18
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TileLasCalib::setCalib
void setCalib(int type, double sumXinQDC, double sumX2inQDC, int nevts, int gain)
Definition: TileLasCalib.h:33