ATLAS Offline Software
Loading...
Searching...
No Matches
TileLaserTimingTool.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_TILELASERTIMINGTOOL_H
6#define TILECALIBALG_TILELASERTIMINGTOOL_H
7
32
33// Gaudi includes
34#include "GaudiKernel/ToolHandle.h"
35
36// Athena includes
41
42// Tile includes
44#include "TileSimpleStat.h"
49
50#include "TH1F.h"
51#include "TH2F.h"
52#include "TProfile.h"
53
54#include <string>
55#include <map>
56#include <sstream>
57
58#define NDIODES 10
59#define NDIODES_LASER1 4
60#define NMONITORS 4
61#define NPMTS 2
62
63#define NGAINS 2
64#define NPARTITIONS 4
65#define NDRAWERS 64
66#define NCHANNELS 48
67#define NDIGI 8
68
69class TileHWID;
71
72class TFile;
73class TF1;
74
75#define TileLaserTimingMon
76// #define TileLaserTimingMonPulse
77// #defibe TileLaserTimingPMT0Mon
78
79class TileLaserTimingTool: public AthAlgTool, virtual public ITileCalibTool {
80
81 public:
82 TileLaserTimingTool(const std::string& type, const std::string& name, const IInterface* pParent);
83 virtual ~TileLaserTimingTool();
84
85 // implementation of ITileCalibTool
86 virtual StatusCode initialize() override;
87 virtual StatusCode initNtuple(int runNumber, int runType, TFile * rootfile) override;
88 virtual StatusCode execute() override;
89 virtual StatusCode finalizeCalculations() override;
90 virtual StatusCode writeNtuple(int runNumber, int runType, TFile * rootfile) override;
91 virtual StatusCode finalize() override;
92
93 private:
99 struct PMTData {
100 PMTData(const std::string &id);
101
102 // time diff wrt pmt 0
105
106#ifdef TileLaserTimingMon
110#endif
111
112#ifdef TileLaserTimingPMT0Mon
113 // High gain data, diff wrt pmt 0
114 TH1F TimeDiffHistoHigh;
115 // Low gain data, diff wrt pmt 0
116 TH1F TimeDiffHistoLow;
117#endif
118
119#ifdef TileLaserTimingMonPulse
120 TProfile pulseShapeHigh;
121 TProfile pulseShapeLow;
122#endif
123
124 // histogram for time residuals in inter module calib.
125 // this is TFit corrected for fiber length and the mean time of digitizer 0
127
128 // tmp variables
129 double time; // abs time
130#ifdef TileLaserTimingPMT0
131 double dtime; // time diff
132 double dtimeNoCFCorr;// time diff w.o. fiber correction
133#endif
134 double energy; // ev. energy
135
136 // Pedestal mean and sigma, accumulated
138 };
139
142 void Add(float time);
143 int GetTotActive() const { return m_N_active; }
144 float GetDigiTime() const { return m_mean_time; }
145 float GetDigiTimeRMS() const { return m_mean_rms; }
146 void Freeze();
147
148 private:
149 float m_ch_time[6];
153 };
154
155 struct DrawerData {
156 DrawerData(const std::string &id);
159
160 // Time difference for Inter module timing
161 // The difference between time in digitizer 0 in this
162 // drawer and in the ref. drawer
164
165#ifdef TileLaserTimingMon
166 // Histo of mean time for digitizer 0
168#endif
169
170 // digitizer 0 mean time (temporary variable)
172 };
173
174 DrawerData* (*m_drawerData)[NDRAWERS];
175
176 static const int NROS = 5;
177
178 // ---- Ntuple data ----
179
180 // mean of Gaussian fit to DrawerData.Digi0TimeDiffHisto
183
184 // time diff wrt Digi0
187 // Maximum ADC amplitude
189
192
193 // time diff wrt PMT0
197
198 // mon-->
204 // <-- mon
205
206#ifdef TileLaserTimingPMT0Mon
207 float (*m_TimeDiffHighMean)[NDRAWERS][NCHANNELS];
208 float (*m_TimeDiffHighMeanError)[NDRAWERS][NCHANNELS];
209 float (*m_TimeDiffHighSigma)[NDRAWERS][NCHANNELS];
210
211 float (*m_TimeDiffLowMean)[NDRAWERS][NCHANNELS];
212 float (*m_TimeDiffLowMeanError)[NDRAWERS][NCHANNELS];
213 float (*m_TimeDiffLowSigma)[NDRAWERS][NCHANNELS];
214
215 float (*m_TimeDiffNoCFCorrMean)[NDRAWERS][NCHANNELS];
216 float (*m_TimeDiffNoCFCorrMeanError)[NDRAWERS][NCHANNELS];
217 float (*m_TimeDiffNoCFCorrSigma)[NDRAWERS][NCHANNELS];
218#endif
219
220 float (*m_FiberLength)[NDRAWERS][NCHANNELS]; // Not needed
221
222#ifdef TileLaserTimingMon
223 float (*m_TimeDiffPMTDigi0)[NDRAWERS][NCHANNELS]; // Not needed
224 float (*m_FiberCorrection)[NDRAWERS][NCHANNELS]; // Not needed
225 int (*m_IsConnected)[NDRAWERS][NCHANNELS]; // Not needed
226
231
233#endif
234
237
239 inline DrawerData* drawerData(int ros, int drawer) {
240 if (!m_drawerData[ros - 1][drawer]) {
241 std::ostringstream sout;
242 sout << ros << '_' << drawer;
243 m_drawerData[ros - 1][drawer] = new DrawerData(sout.str());
244 }
245 return m_drawerData[ros - 1][drawer];
246 }
247
248 //StoreGate
250 "EventInfo", "EventInfo", "EventInfo key"};
252 "TileRawChannelContainer", "TileRawChannelFit", "Tile raw channel container"};
254 "TileDigitsContainer", "TileDigitsCnt", "Tile digits container"};
255
256 // Tools info
259 ToolHandle<TileCondToolTiming> m_tileToolTiming{this,
260 "TileCondToolTiming", "TileCondToolTiming", "Tile timing tool"};
261
262 // jobOptions
265 std::string m_ntupleID;
266 double m_fiberLightSpeed = 0.0;
267 unsigned m_nSamples;
268 // low limit for energy when adding samples to pulse shape
270 // the reference drawer nr
271 unsigned int m_refDrawer;
273 // max allowed abs value for time diff
275 // if PMT0 or digi0 should be used as reference to dskew settings
277
278 // the tag for the registered cond objects, default ""
279 std::string m_IOVTag;
280
281 // help vars
282
285
287
288#ifdef TileLaserTimingMonPulse
289 // Mon data
290 TH1F* m_h1_time_check;
291 TH2F* m_h2_time_check;
292
293 TProfile* m_PulseShapeHigh;
294 TProfile* m_PulseShapeLow;
295#endif
296
297 // fiber lengths
298 // first index is barrel(0) and extended barrel(1)
299 // second index is PMT-1
300 static const float s_fiberLength[2][48];
301
303 inline bool isConnectedChan(int ros, int chan) {
304 if (m_cabling->channel2hole(ros, chan) < 0) return false;
305 return true;
306 }
307
308 static bool isConnectedPMT(int ros, int chan);
309
311 inline int channel2PMT(int ros, int chan) {
312 return (abs(m_cabling->channel2hole(ros, chan)) - 1);
313 }
314
315 static inline bool isBarrel(int ros) {
316 return ros == 1 || ros == 2;
317 }
318
319 static inline bool isExtBarrel(int ros) {
320 return ros == 3 || ros == 4;
321 }
322
323 inline double fiberCorrection(int ros, int pmt) {
324 return (s_fiberLength[isExtBarrel(ros)][pmt] - s_fiberLength[isExtBarrel(ros)][0])
326 }
327 static inline float fiberLength(int ros, int pmt) {
328 return s_fiberLength[isExtBarrel(ros)][pmt];
329 }
330
331 inline HWIdentifier drawerId(int frag) {
332 return m_tileHWID->drawer_id(frag);
333 }
334
335 inline std::string drawerIdStr(int frag) {
336 return m_tileHWID->to_string(drawerId(frag));
337 }
338
339 inline HWIdentifier drawerId(int ros, int drawer) {
340 return m_tileHWID->drawer_id(ros, drawer);
341 }
342
346 void fitGauss(TH1F &hi, float &p1, float &p2, float &p1_err);
347
352 void fitGauss2(TH1F &hi, float &p1, float &p2, float &chi2, float &p1_err, float w1, float w2);
353
354 typedef float (*TPMTArray)[NDRAWERS][NCHANNELS];
355 typedef float (*TDrawerArrayF)[NDRAWERS];
356 typedef int (*TDrawerArrayI)[NDRAWERS];
357
361 void correctEvenOddPMT(int ros, int drawer, TPMTArray& ChannelOffset,
362 TDrawerArrayF& MeanOddPmtTdiff, TDrawerArrayI& OddPmtCounter,
363 TDrawerArrayF& MeanEvenPmtTdiff, TDrawerArrayI& EvenPmtCounter,
364 TDrawerArrayF& EvenOddTimeDiff);
365};
366
367#endif // TILECALIBALG_TILELASERTIMINGTOOL_H
Property holding a SG store/key/clid from which a ReadHandle is made.
#define NDIGI
#define NCHANNELS
#define NDRAWERS
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Property holding a SG store/key/clid from which a ReadHandle is made.
Helper class for TileCal online (hardware) identifiers.
Definition TileHWID.h:49
float(* m_FiberCorrection)[NDRAWERS][NCHANNELS]
float(* m_ChannelOffset)[NDRAWERS][NCHANNELS]
float(* m_TimeDiffMean)[NDRAWERS][NCHANNELS]
ToolHandle< TileCondToolTiming > m_tileToolTiming
float(* m_EvenOddTimeDiff)[NDRAWERS]
HWIdentifier drawerId(int frag)
float(* TDrawerArrayF)[NDRAWERS]
int(* m_IsConnected)[NDRAWERS][NCHANNELS]
void fitGauss(TH1F &hi, float &p1, float &p2, float &p1_err)
Fit a Gaussian function (m_gaussf) to the given histogram, store mean, rms and mean error.
int(* m_OddPmtCounterPMT0)[NDRAWERS]
std::string m_rawChannelContainerName
virtual StatusCode execute() override
TODO: determine event type, select laser?
const TileHWID * m_tileHWID
static bool isConnectedPMT(int ros, int chan)
virtual StatusCode finalize() override
float(* m_TimeDiffPMTDigi0)[NDRAWERS][NCHANNELS]
int(* m_EvenPmtCounterPMT0)[NDRAWERS]
int(* m_OddPmtCounter)[NDRAWERS]
float(* m_ADCAmplitude)[NDRAWERS][NCHANNELS]
virtual StatusCode initNtuple(int runNumber, int runType, TFile *rootfile) override
static bool isExtBarrel(int ros)
float(* m_DrawerOffset)[NDRAWERS]
float(* m_TimeDiffMeanError)[NDRAWERS][NCHANNELS]
virtual StatusCode finalizeCalculations() override
DrawerData *(* m_drawerData)[NDRAWERS]
HWIdentifier drawerId(int ros, int drawer)
int(* m_EvenPmtCounter)[NDRAWERS]
static bool isBarrel(int ros)
float(* m_MeanOddPmtTdiffPMT0)[NDRAWERS]
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
SG::ReadHandleKey< TileDigitsContainer > m_digitsContainerKey
const TileCablingService * m_cabling
float(* m_PedestalMean)[NDRAWERS][NCHANNELS]
bool isConnectedChan(int ros, int chan)
int m_nevts
number of laser events
std::string drawerIdStr(int frag)
float(* m_MeanOddPmtTdiff)[NDRAWERS]
DrawerData * drawerData(int ros, int drawer)
static float fiberLength(int ros, int pmt)
void correctEvenOddPMT(int ros, int drawer, TPMTArray &ChannelOffset, TDrawerArrayF &MeanOddPmtTdiff, TDrawerArrayI &OddPmtCounter, TDrawerArrayF &MeanEvenPmtTdiff, TDrawerArrayI &EvenPmtCounter, TDrawerArrayF &EvenOddTimeDiff)
Correct for differences between even and odd PMTs.
float(* m_TimeDiffSigma)[NDRAWERS][NCHANNELS]
float(* m_MeanEvenPmtTdiff)[NDRAWERS]
float(* TPMTArray)[NDRAWERS][NCHANNELS]
int channel2PMT(int ros, int chan)
SG::ReadHandleKey< TileRawChannelContainer > m_rawChannelContainerKey
float(* m_ChannelOffsetError)[NDRAWERS][NCHANNELS]
float(* m_FiberLength)[NDRAWERS][NCHANNELS]
virtual StatusCode initialize() override
float(* m_DigiMean)[NDRAWERS][NDIGI]
float(* m_PedestalSigma)[NDRAWERS][NCHANNELS]
double fiberCorrection(int ros, int pmt)
static const float s_fiberLength[2][48]
virtual StatusCode writeNtuple(int runNumber, int runType, TFile *rootfile) override
float(* m_DrawerOffsetError)[NDRAWERS]
float(* m_DSkewSet)[NDRAWERS][NDIGI]
float(* m_MeanEvenPmtTdiffPMT0)[NDRAWERS]
int(* TDrawerArrayI)[NDRAWERS]
void fitGauss2(TH1F &hi, float &p1, float &p2, float &chi2, float &p1_err, float w1, float w2)
Fit a Gaussian function with two iterations mean range = hi.mean +- w1|w2 * hi.rms.
TileLaserTimingTool(const std::string &type, const std::string &name, const IInterface *pParent)
float(* m_EvenOddTimeDiffPMT0)[NDRAWERS]
double chi2(TH1 *h0, TH1 *h1)
static std::vector< std::string > rootfile
Definition iLumiCalc.h:30