ATLAS Offline Software
Loading...
Searching...
No Matches
TileLaserDefaultCalibTool.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef TILECALIBALG_TILELASERDEFAULTCALIBTOOL_H
6#define TILECALIBALG_TILELASERDEFAULTCALIBTOOL_H
7
8// Tile includes
18
19
20// Athena includes
23
24#include <string>
25#include <map>
26#include <cmath>
27
28
29#define NDIODES 10
30#define NDIODES_LASER1 4
31#define NMONITORS 4
32#define NPMTS 2
33
34#define NGAINS 2
35#define NPARTITIONS 4
36#define NDRAWERS 64
37#define NCOUPLES 22
38#define NCHANNELS 48
39#define NSLICES 100
40#define NFIBERS 2
41
42
44class TileLaserObject;
45class TileHWID;
46class TFile;
47class RunningStat;
48
50{
51
52 public:
53 TileLaserDefaultCalibTool(const std::string& type, const std::string& name,const IInterface* pParent);
55
56 virtual StatusCode initialize() override;
57 virtual StatusCode initNtuple(int runNumber, int runType, TFile * rootfile) override;
58 virtual StatusCode execute() override;
59 virtual StatusCode finalizeCalculations() override;
60 virtual StatusCode writeNtuple(int runNumber, int runType, TFile * rootfile) override;
61 virtual StatusCode finalize() override;
62
63 private:
64
65 // Name of ntuple of the Tool
66 std::string m_toolNtuple;
67
70
73
76 ToolHandle<TileCondToolEmscale> m_tileToolEmscale{this,
77 "TileCondToolEmscale", "TileCondToolEmscale", "Tile em scale tool"};
78 ToolHandle<ITileBadChanTool> m_tileBadChanTool{this,
79 "TileBadChanTool", "TileBadChanTool", "Tile bad channel tool"};
80 ToolHandle<ITileStuckBitsProbsTool> m_stuckBitsProbs{this,
81 "StuckBitsProbsTool", "", "Tile stuck bits probabilities tool"};
82
85 "TileRawChannelContainer", "TileRawChannelOpt2", "Tile raw channel container"};
87 "TileLaserObject", "TileLaserObj", "Tile laser object"};
88
89 ToolHandle<ITileDCSTool> m_tileDCS{this, "TileDCSTool", "TileDCSTool", "Tile DCS tool"};
90
91 // Parameter which will end up in the ROOTuple
92 //
93 // Details concerning this parameters could be found on the LASER webpage :
94 //
95 // http://atlas-tile-laser.web.cern.ch/
96 //
97
98 int m_toolRunNo; // The run number
99 int m_ADC_problem; // Expert tag for LastROD problem noticfication
100 int m_las_filter; // Filter wheel position
101 float m_las_requ_amp; // Requested amplitude
102 float m_hrate; // Humidity rate (in %)
103 float m_flow; // Gas flow in diodes box (in L/h)
104 float m_head_temp; // Temperature of the LASER head
105 float m_las_time; // Event time
106
107 // LASERII
108 float (*m_ratio_LASERII)[NGAINS][NPARTITIONS][NDRAWERS][NCHANNELS][NGAINS]; // Calib coefficients computed for this run (for all diodes, PMTs, phocal, CIS)
109 float (*m_ratio_S_LASERII)[NGAINS][NPARTITIONS][NDRAWERS][NCHANNELS][NGAINS]; // Corresponding RMS
110 float (*m_ratio_LASERII_good)[NGAINS][NPARTITIONS][NDRAWERS][NCHANNELS][NGAINS]; // Calib coefficients computed for this run (for all diodes, PMTs, phocal, CIS)
112
114 RunningStat* (*m_rs_ratio_LASERII_good)[NGAINS][NPARTITIONS][NDRAWERS][NCHANNELS][NGAINS];
115
116 // FIRST PART OF DATA FRAGMENT
117 /* float m_chan_LAS[32]; // Mean value for monitoring diodes, PMTs, phocal, CIS in Laser runs
118 float m_chan_PED[32]; // Mean value for monitoring diodes, PMTs, phocal, CIS in Pedestal runs
119 float m_chan_LED[32]; // Mean value for monitoring diodes, PMTs, phocal, CIS in LED runs
120 float m_chan_APH[32]; // Mean value for monitoring diodes, PMTs, phocal, CIS in Alpha runs
121 float m_chan_LIN[32]; // Mean value for monitoring diodes, PMTs, phocal, CIS un Linearity runs
122 float m_chan_S_LAS[32]; // Corresponding RMS in Laser runs
123 float m_chan_S_PED[32]; // Corresponding RMS in Pedestal runs
124 float m_chan_S_LED[32]; // Corresponding RMS in LED runs
125 float m_chan_S_APH[32]; // Corresponding RMS in Alpha runs
126 float m_chan_S_LIN[32]; // Corresponding RMS in Linearity runs
127 */
128
129 // SECOND PART OF DATA FRAGMENT
130 float (*m_PMT_LASERII)[NGAINS]; // Mean value for box PMTs
131 float (*m_PMT_S_LASERII)[NGAINS]; // Corresponding RMS
132 RunningStat* (*m_rs_PMT_signal_LASERII)[NGAINS];
133
134 float (*m_diode_LASERII)[NGAINS]; // Mean value for box Photodiodes
135 float (*m_diode_S_LASERII)[NGAINS]; // Corresponding RMS
136 int (*m_entries_diode_LASERII)[NGAINS]; //Number of DIODE events collected for one diode (and a particular gain)
137
138 RunningStat* (*m_rs_diode_signal_LASERII)[NGAINS];
139
140
141 float (*m_diode_Ped_LASERII)[NGAINS]; // Corresponding pedestal values
142 float (*m_diode_Ped_S_LASERII)[NGAINS]; // Sigma of pedestal values
143 float (*m_diode_Alpha_LASERII)[NGAINS]; // Corresponding pedestal values
144 float (*m_diode_Alpha_S_LASERII)[NGAINS]; // Sigma of pedestal values
145 float (*m_diode_Led_LASERII)[NGAINS]; // Corresponding pedestal values
146 float (*m_diode_Led_S_LASERII)[NGAINS]; // Sigma of pedestal values
147 // float m_diode_Lin_LASERII[NDIODES][NGAINS]; // Corresponding pedestal values
148 // float m_diode_Lin_S_LASERII[NDIODES][NGAINS]; // Sigma of pedestal values
149 // float m_diode_Las_LASERII[NDIODES][NGAINS]; // Corresponding pedestal values
150 // float m_diode_Las_S_LASERII[NDIODES][NGAINS]; // Sigma of pedestal values
151 float (*m_PMT_Ped_LASERII)[NGAINS]; // Corresponding pedestal values
152 float (*m_PMT_Ped_S_LASERII)[NGAINS]; // Sigma of pedestal values
153
154
155 // LASERI
156 float m_PMT[NPMTS]; // Mean value for box PMTs
157 float m_PMT_S[NPMTS]; // Corresponding RMS
158 float m_diode[NDIODES_LASER1]; // Mean value for box Photodiodes
159 float m_diode_S[NDIODES_LASER1]; // Corresponding RMS
160 float m_diode_Ped[NDIODES_LASER1]; // Corresponding pedestal values
161 float m_diode_Alpha[NDIODES_LASER1]; // Corresponding alpha peaks
162 float m_diode_SPed[NDIODES_LASER1]; // Sigma of pedestals
163 float m_diode_SAlpha[NDIODES_LASER1]; // RMS of alpha spectra
164 float (*m_ratio)[NPARTITIONS][NDRAWERS][NCHANNELS][NGAINS]; // Calib coefficients computed for this run (for all diodes)
165 float (*m_ratio_S)[NPARTITIONS][NDRAWERS][NCHANNELS][NGAINS]; // Corresponding RMS
166 float (*m_ratio_good)[NPARTITIONS][NDRAWERS][NCHANNELS][NGAINS]; // Calib coefficients computed for this run (for all diodes)
167 float (*m_ratio_good_S)[NPARTITIONS][NDRAWERS][NCHANNELS][NGAINS]; // Corresponding RMS
168 float (*m_pmt_ratios)[NDRAWERS][NCHANNELS][NGAINS]; // Calib coefficients computed for this run (for all diodes)
169 float (*m_pmt_S_ratios)[NDRAWERS][NCHANNELS][NGAINS]; // Corresponding RMS
170
175
176
181 RunningStat* (*m_rs_pmt_ratios)[NDRAWERS][NCHANNELS][NGAINS];
182
183 RunningStat* (*m_rs_diode_ratio_low)[NDIODES];
184 RunningStat* (*m_rs_diode_ratio_high)[NDIODES];
185
186 float (*m_meantime)[NGAINS]; // Mean time computed for this run per partition (to remove 25ns jitter)
187 float (*m_time)[NDRAWERS][NCHANNELS][NGAINS]; // Mean time computed for this run
188 float (*m_time_S)[NDRAWERS][NCHANNELS][NGAINS]; // Corresponding RMS
189
190 float (*m_mean)[NDRAWERS][NCHANNELS][NGAINS]; // Mean signal computed for this run
191 float (*m_mean_S)[NDRAWERS][NCHANNELS][NGAINS]; // Corresponding RMS
192 float (*m_raw_mean)[NDRAWERS][NCHANNELS][NGAINS]; // Mean signal computed for this run
193 float (*m_raw_mean_S)[NDRAWERS][NCHANNELS][NGAINS]; // Corresponding RMS
194 int (*m_entries)[NDRAWERS][NCHANNELS][NGAINS]; // Number of LASER events collected for one channel (and a particular gain)
195 float (*m_kappa)[NDRAWERS][NFIBERS][NGAINS]; // Kappa correction term
198 short (*m_status)[NDRAWERS][NCHANNELS][NGAINS]; // Status of the channel in the DB
201
202 // Local results - not sent to ROOTuple
205
207 long long m_evtNr;
213
214 RunningStat* (*m_rs_meantime)[NGAINS];
217 RunningStat* (*m_rs_raw_signal)[NDRAWERS][NCHANNELS][NGAINS];
218 RunningStat* (*m_rs_reducedKappa)[NDRAWERS][NCOUPLES-1][NCOUPLES][NGAINS][NFIBERS];
219
220 // Functions
221 static std::pair<unsigned int, unsigned int> getCoupleOfPMT(int ros, int couple);
222 short isCellBad(int ros, int drawer, int channel, int gain);
223
224 inline int chanIsConnected(int ros, int chan) {
225 if(m_cabling->channel2hole(ros,chan)<0) return 0; //negative means not connected
226 return 1;
227 }
228};
229
230
231// Small class to compute mean & variance in a efficient way
233
234public:
235 // Default constructor
238
239 void Clear() {
240 m_n = 0;
241 }
242
243 // See Knuth TAOCP vol 2, 3rd edition, page 232
244 void Push(double x) {
245 m_n++;
246 m_n_slice++;
248
249 if (m_n == 1) {
250 m_oldM = m_newM = x;
251 m_oldS = 0.0;
252 } else {
253 m_newM = m_oldM + (x - m_oldM)/m_n;
254 m_newS = m_oldS + (x - m_oldM)*(x - m_newM);
255
256 // set up for next iteration
257 m_oldM = m_newM;
258 m_oldS = m_newS;
259 }
260
261 //--- for slicing
262 if (m_n_slice == 1) {
264 m_oldS_slice = 0.0;
265 } else {
270 }
271
273 m_vectMean.push_back( (m_n_slice > 0) ? m_newM_slice : 0.0 );
274 m_vectVar.push_back( (m_n_slice > 1) ? m_newS_slice/(m_n_slice - 1) : 0.0 );
275 m_n_slice=0;
276 }
277 }
278
279 inline int NumDataValues() const { return m_nTotEntries;}
280 inline double Mean() const { return (m_n > 0) ? m_newM : 0.0; }
281 inline double Variance() const { return ( (m_n > 1) ? m_newS/(m_n - 1) : 0.0 ); }
282 inline double StandardDeviation() const { return sqrt( Variance() ); }
283 inline int EventsPerSlice() { return m_eventsPerSlice;}
284
285 inline double Mean(unsigned int iSlice){
286 if ( iSlice<m_vectMean.size() ) return m_vectMean[iSlice];
287 return 0;
288 }
289
290 inline double Variance(unsigned int iSlice){
291 if (iSlice<m_vectVar.size()) return m_vectVar[iSlice];
292 return 0;
293 }
294
295 inline int GetNSlices(){
296 return m_vectVar.size();
297 }
298
299
300private:
301 int m_n;
307 std::vector<double> m_vectMean, m_vectVar;
308
309};
310
311
312
313#endif // #ifndef TILECALIBALG_TILELASERDEFAULTCALIBTOOL_H
Property holding a SG store/key/clid from which a ReadHandle is made.
Information produced by TileDQstatusAlg (used to be done by TileBeamInfoProvider).
#define NDIODES
#define NCOUPLES
#define NGAINS
#define NFIBERS
#define NCHANNELS
#define NSLICES
#define NPARTITIONS
#define NDRAWERS
#define NPMTS
#define NDIODES_LASER1
#define x
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
double StandardDeviation() const
std::vector< double > m_vectMean
std::vector< double > m_vectVar
double Mean(unsigned int iSlice)
double Variance(unsigned int iSlice)
Property holding a SG store/key/clid from which a ReadHandle is made.
Helper class for TileCal online (hardware) identifiers.
Definition TileHWID.h:49
short isCellBad(int ros, int drawer, int channel, int gain)
virtual StatusCode initNtuple(int runNumber, int runType, TFile *rootfile) override
ToolHandle< ITileStuckBitsProbsTool > m_stuckBitsProbs
float(* m_ratio_LASERII_good)[NGAINS][NPARTITIONS][NDRAWERS][NCHANNELS][NGAINS]
ToolHandle< ITileDCSTool > m_tileDCS
float(* m_ratio)[NPARTITIONS][NDRAWERS][NCHANNELS][NGAINS]
int(* m_entries)[NDRAWERS][NCHANNELS][NGAINS]
float(* m_mean_slice)[NDRAWERS][NCHANNELS][NSLICES][NGAINS]
float(* m_ratio_S_LASERII_good)[NGAINS][NPARTITIONS][NDRAWERS][NCHANNELS][NGAINS]
SG::ReadHandleKey< TileDQstatus > m_dqStatusKey
float(* m_ratio_good_S)[NPARTITIONS][NDRAWERS][NCHANNELS][NGAINS]
virtual StatusCode initialize() override
float(* m_raw_mean)[NDRAWERS][NCHANNELS][NGAINS]
float(* m_time_S)[NDRAWERS][NCHANNELS][NGAINS]
const TileCablingService * m_cabling
ToolHandle< ITileBadChanTool > m_tileBadChanTool
RunningStat * m_rs_diode_signal[NDIODES_LASER1]
float(* m_ratio_LASERII)[NGAINS][NPARTITIONS][NDRAWERS][NCHANNELS][NGAINS]
float(* m_mean)[NDRAWERS][NCHANNELS][NGAINS]
ToolHandle< TileCondToolEmscale > m_tileToolEmscale
float(* m_HV)[NDRAWERS][NCHANNELS]
int chanIsConnected(int ros, int chan)
static std::pair< unsigned int, unsigned int > getCoupleOfPMT(int ros, int couple)
float(* m_pmt_S_ratios)[NDRAWERS][NCHANNELS][NGAINS]
float(* m_variance_slice)[NDRAWERS][NCHANNELS][NSLICES][NGAINS]
float(* m_raw_mean_S)[NDRAWERS][NCHANNELS][NGAINS]
virtual StatusCode finalize() override
virtual StatusCode writeNtuple(int runNumber, int runType, TFile *rootfile) override
float(* m_kappa)[NDRAWERS][NFIBERS][NGAINS]
float(* m_pmt_ratios)[NDRAWERS][NCHANNELS][NGAINS]
virtual StatusCode execute() override
short(* m_status)[NDRAWERS][NCHANNELS][NGAINS]
TileLaserDefaultCalibTool(const std::string &type, const std::string &name, const IInterface *pParent)
float(* m_ratio_S_LASERII)[NGAINS][NPARTITIONS][NDRAWERS][NCHANNELS][NGAINS]
float(* m_mean_S)[NDRAWERS][NCHANNELS][NGAINS]
float(* m_ratio_S)[NPARTITIONS][NDRAWERS][NCHANNELS][NGAINS]
float(* m_HVSet)[NDRAWERS][NCHANNELS]
SG::ReadHandleKey< TileLaserObject > m_laserContainerKey
virtual StatusCode finalizeCalculations() override
SG::ReadHandleKey< TileRawChannelContainer > m_rawChannelContainerKey
float(* m_ratio_good)[NPARTITIONS][NDRAWERS][NCHANNELS][NGAINS]
float(* m_time)[NDRAWERS][NCHANNELS][NGAINS]
static std::vector< std::string > rootfile
Definition iLumiCalc.h:30