Project
Loading...
Searching...
No Matches
CalibPulser.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#ifndef ALICEO2_TPC_CALIBPULSER_H_
13#define ALICEO2_TPC_CALIBPULSER_H_
14
17
18#include <vector>
19#include <memory>
20#include <unordered_map>
21
22#include "TH2S.h"
23
24#include "DataFormatsTPC/Defs.h"
25#include "TPCBase/CalDet.h"
26#include "TPCBase/CRU.h"
27#include "TPCBase/PadROCPos.h"
29
30namespace o2
31{
32namespace tpc
33{
34
41
43{
44 public:
45 using VectorType = std::vector<float>;
46 using PtrVectorType = std::vector<std::unique_ptr<TH2S>>;
47
50
52 ~CalibPulser() override = default;
53
55 void init();
56
64 Int_t updateROC(const Int_t roc, const Int_t row, const Int_t pad,
65 const Int_t timeBin, const Float_t signal) final;
66
68 Int_t updateCRU(const CRU& cru, const Int_t row, const Int_t pad,
69 const Int_t timeBin, const Float_t signal) final { return 0; }
70
72 void resetData();
73
75 void setADCRange(int minADC, int maxADC)
76 {
77 mADCMin = minADC;
78 mADCMax = maxADC;
79 mNumberOfADCs = mADCMax - mADCMin + 1;
80 }
81
83 void setTimeBinRange(int first, int last)
84 {
85 mFirstTimeBin = first;
86 mLastTimeBin = last;
87 // TODO: until automatic T0 calibration is done we use the same time range
88 // as for the time bin selection
89 mXminT0 = mFirstTimeBin;
90 mXmaxT0 = mLastTimeBin;
91 }
92
94 void setPedestalAndNoise(const CalPad* pedestal, const CalPad* noise)
95 {
96 mPedestal = pedestal;
97 mNoise = noise;
98 }
99
101 void setT0Binning(int nbins, float min, float max)
102 {
103 mNbinsT0 = nbins;
104 mXminT0 = min;
105 mXmaxT0 = max;
106 }
107
109 void setWidthBinning(int nbins, float min, float max)
110 {
111 mNbinsWidth = nbins;
112 mXminWidth = min;
113 mXmaxWidth = max;
114 }
115
117 void setQtotBinning(int nbins, float min, float max)
118 {
119 mNbinsQtot = nbins;
120 mXminQtot = min;
121 mXmaxQtot = max;
122 }
123
125 void setMinQtot(float minQtot) { mMinimumQtot = minQtot; }
126
128 void setMinQmax(float minQmax) { mMinimumQmax = minQmax; }
129
131 void setMaxTimeBinRange(int max) { mMaxTimeBinRange = max; }
132
134 void analyse();
135
138 const CalPad& getT0() const { return mCalDets.at("T0"); }
139
142 const CalPad& getWidth() const { return mCalDets.at("Width"); }
143
146 const CalPad& getQtot() const { return mCalDets.at("Qtot"); }
147
148 const auto& getCalDets() const { return mCalDets; }
149
151 void dumpToFile(const std::string filename, uint32_t type = 0) final;
152
154 void endReader() final;
155
157 void endEvent() final{};
158
159 private:
160 // reference histogram ranges
161 int mNbinsT0;
162 float mXminT0;
163 float mXmaxT0;
164 int mNbinsQtot;
165 float mXminQtot;
166 float mXmaxQtot;
167 int mNbinsWidth;
168 float mXminWidth;
169 float mXmaxWidth;
170
171 int mFirstTimeBin;
172 int mLastTimeBin;
173 int mADCMin;
174 int mADCMax;
175 int mNumberOfADCs;
176 int mPeakIntMinus;
177 int mPeakIntPlus;
178 float mMinimumQtot;
179 float mMinimumQmax;
180 int mMaxTimeBinRange;
181 std::unordered_map<std::string, CalPad> mCalDets;
182
183 const CalPad* mPedestal;
184 const CalPad* mNoise;
185
186 std::map<PadROCPos, VectorType> mPulserData;
187
188 std::array<std::vector<size_t>, ROC::MaxROC> mTimeBinEntries{};
189
190 PtrVectorType mT0Histograms;
191 PtrVectorType mWidthHistograms;
192 PtrVectorType mQtotHistograms;
193
195 struct PulserData {
196 float mT0{0.f};
197 float mWidth{0.f};
198 float mQtot{0.f};
199
200 bool isValid() const { return (mT0 > 0.f) || (mWidth > 0.f) || (mQtot > 0.f); }
201 };
202
204 struct ElemPair {
205 size_t first{0};
206 size_t last{0};
207 };
208
215 TH2S* getHistogram(ROC roc, CalibPulser::PtrVectorType& rocVector,
216 int nbins, float min, float max,
217 std::string_view type, bool create /*=kFALSE*/);
218
220 TH2S* getHistoT0(ROC roc, Bool_t force)
221 {
222 return getHistogram(roc, mT0Histograms, mNbinsT0, mXminT0, mXmaxT0, "T0", force);
223 }
224
226 TH2S* getHistoQtot(ROC roc, Bool_t force)
227 {
228 return getHistogram(roc, mQtotHistograms, mNbinsQtot, mXminQtot, mXmaxQtot, "Qtot", force);
229 }
230
232 TH2S* getHistoSigma(ROC roc, Bool_t force)
233 {
234 return getHistogram(roc, mWidthHistograms, mNbinsWidth, mXminWidth, mXmaxWidth, "Width", force);
235 }
236
240 PulserData processPadData(const PadROCPos& padROCPos, const VectorType& adcData, const ElemPair& range);
241
243 std::array<ElemPair, ROC::MaxROC> getTimeRangeROCs();
244
246 void resetEvent() final {}
247};
248
249} // namespace tpc
250
251} // namespace o2
252#endif
uint32_t roc
Definition RawData.h:3
Pulser calibration class.
Definition CalibPulser.h:43
Int_t updateCRU(const CRU &cru, const Int_t row, const Int_t pad, const Int_t timeBin, const Float_t signal) final
not used
Definition CalibPulser.h:68
void setMinQmax(float minQmax)
set minimum Qmax for the signal
void setWidthBinning(int nbins, float min, float max)
set Width Binning
void setPedestalAndNoise(const CalPad *pedestal, const CalPad *noise)
set noise and pedestal calibration objects
Definition CalibPulser.h:94
std::vector< float > VectorType
Definition CalibPulser.h:45
void init()
initialize the clusterer from CalibPedestalParam
void endReader() final
Process the end of one raw reader.
void setTimeBinRange(int first, int last)
set the timeBin range
Definition CalibPulser.h:83
void setQtotBinning(int nbins, float min, float max)
set Qtot Binning
void setMinQtot(float minQtot)
set minimum Qtot for the signal
void analyse()
Analyse the buffered pulser information.
Int_t updateROC(const Int_t roc, const Int_t row, const Int_t pad, const Int_t timeBin, const Float_t signal) final
const CalPad & getWidth() const
void resetData()
Reset temporary data and histogrms.
~CalibPulser() override=default
default destructor
void setMaxTimeBinRange(int max)
set time bin range around the one with the maximum number of entries
const CalPad & getT0() const
const CalPad & getQtot() const
std::vector< std::unique_ptr< TH2S > > PtrVectorType
Definition CalibPulser.h:46
void dumpToFile(const std::string filename, uint32_t type=0) final
Dump the relevant data to file.
void endEvent() final
Dummy end event.
const auto & getCalDets() const
void setADCRange(int minADC, int maxADC)
set the adc range
Definition CalibPulser.h:75
void setT0Binning(int nbins, float min, float max)
set T0 Binning
Base class for raw data calibrations.
@ MaxROC
Definition ROC.h:47
GLint first
Definition glcorearb.h:399
GLenum GLint * range
Definition glcorearb.h:1899
GLint GLint GLsizei GLint GLenum GLenum type
Definition glcorearb.h:275
bool isValid(std::string_view dcsAlias)
PadSubset
Definition of the different pad subsets.
Definition Defs.h:63
@ ROC
ROCs (up to 72)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::string filename()
constexpr size_t min
constexpr size_t max
std::vector< int > row