Skip to content

Commit 05f188d

Browse files
wiechuladavidrohr
authored andcommitted
TPC: Restructure pad-wise calibration, implement missing workflows
* Generalize and rename pedestal workflow - to be able to process pulser and CE data - use digits as input * Inernally use unordered_map of CalPad in pedestal and pulser calib * Write Pedestal and Noise output to one ccdb entry * CalDetMergerPublisherSpec can take unordered_map of CalPads * MonitorWorkflowSpec can use digits as input
1 parent 41cf269 commit 05f188d

23 files changed

Lines changed: 417 additions & 209 deletions

Detectors/TPC/base/include/TPCBase/CDBInterface.h

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@
2626
#include "TPCBase/CalDet.h"
2727
#include "DataFormatsTPC/LtrCalibData.h"
2828

29-
namespace o2
30-
{
31-
namespace tpc
29+
namespace o2::tpc
3230
{
3331
// forward declarations
3432
class ParameterDetector;
@@ -40,6 +38,7 @@ class ParameterGEM;
4038
enum class CDBType {
4139
CalPedestal, ///< Pedestal calibration
4240
CalNoise, ///< Noise calibration
41+
CalPedestalNoise, ///< Pedestal and Noise calibration
4342
CalPulser, ///< Pulser calibration
4443
CalCE, ///< Laser CE calibration
4544
CalPadGainFull, ///< Full pad gain calibration
@@ -59,9 +58,10 @@ enum class CDBIntervention {
5958
};
6059

6160
/// Storage name in CCDB for each calibration and parameter type
62-
const std::unordered_map<CDBType, std::string> CDBTypeMap{
61+
const std::unordered_map<CDBType, const std::string> CDBTypeMap{
6362
{CDBType::CalPedestal, "TPC/Calib/Pedestal"},
6463
{CDBType::CalNoise, "TPC/Calib/Noise"},
64+
{CDBType::CalPedestalNoise, "TPC/Calib/PedestalNoise"},
6565
{CDBType::CalPulser, "TPC/Calib/Pulser"},
6666
{CDBType::CalCE, "TPC/Calib/CE"},
6767
{CDBType::CalPadGainFull, "TPC/Calib/PadGainFull"},
@@ -94,6 +94,8 @@ const std::unordered_map<CDBIntervention, std::string> CDBInterventionMap{
9494
class CDBInterface
9595
{
9696
public:
97+
using CalPadMapType = std::unordered_map<std::string, CalPad>;
98+
9799
CDBInterface(const CDBInterface&) = delete;
98100

99101
/// Create instance of singleton
@@ -243,6 +245,9 @@ inline T& CDBInterface::getObjectFromCDB(std::string_view path)
243245
{
244246
static auto& cdb = o2::ccdb::BasicCCDBManager::instance();
245247
auto* object = cdb.get<T>(path.data());
248+
if (!object) {
249+
LOGP(fatal, "Could not get {} from cdb", path);
250+
}
246251
return *object;
247252
}
248253

@@ -263,7 +268,7 @@ inline T& CDBInterface::getSpecificObjectFromCDB(std::string_view path, long tim
263268

264269
template CalPad& CDBInterface::getSpecificObjectFromCDB(const std::string_view path, long timestamp, const std::map<std::string, std::string>& metaData);
265270
template std::vector<CalPad>& CDBInterface::getSpecificObjectFromCDB(const std::string_view path, long timestamp, const std::map<std::string, std::string>& metaData);
266-
template std::unordered_map<std::string, o2::tpc::CalPad>& CDBInterface::getSpecificObjectFromCDB(const std::string_view path, long timestamp, const std::map<std::string, std::string>& metaData);
271+
template CDBInterface::CalPadMapType& CDBInterface::getSpecificObjectFromCDB(const std::string_view path, long timestamp, const std::map<std::string, std::string>& metaData);
267272
template LtrCalibData& CDBInterface::getSpecificObjectFromCDB(const std::string_view path, long timestamp, const std::map<std::string, std::string>& metaData);
268273

269274
/// \class CDBStorage
@@ -305,6 +310,11 @@ class CDBStorage
305310
mMetaData["Comment"] = comment;
306311
}
307312

313+
void setRunNumber(int run)
314+
{
315+
mMetaData["runNumber"] = std::to_string(run);
316+
}
317+
308318
template <typename T>
309319
void storeObject(T* obj, CDBType const type, MetaData_t const& metadata, long start, long end)
310320
{
@@ -322,9 +332,9 @@ class CDBStorage
322332
storeObject(obj, type, mMetaData, start, end);
323333
}
324334

325-
void uploadNoiseAndPedestal(std::string_view fileName, long first = -1, long last = -1);
326-
void uploadGainMap(std::string_view fileName, bool isFull = true, long first = -1, long last = -1);
327-
void uploadPulserOrCEData(CDBType type, std::string_view fileName, long first = -1, long last = -1);
335+
void uploadNoiseAndPedestal(std::string_view fileName, long first = -1, long last = 99999999999999);
336+
void uploadGainMap(std::string_view fileName, bool isFull = true, long first = -1, long last = 99999999999999);
337+
void uploadPulserOrCEData(CDBType type, std::string_view fileName, long first = -1, long last = 99999999999999);
328338

329339
private:
330340
bool checkMetaData(MetaData_t metaData) const;
@@ -335,7 +345,6 @@ class CDBStorage
335345
MetaData_t mMetaData;
336346
};
337347

338-
} // namespace tpc
339-
} // namespace o2
348+
} // namespace o2::tpc
340349

341350
#endif

Detectors/TPC/base/include/TPCBase/CalDet.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class CalDet
4141
using CalType = CalArray<T>;
4242

4343
public:
44-
CalDet() = default;
44+
CalDet() { initData(); }
4545
CalDet(CalDet const&) = default;
4646
CalDet& operator=(CalDet const&) = default;
4747
~CalDet() = default;
@@ -97,9 +97,9 @@ class CalDet
9797
friend CalDet<U> operator-(const CalDet<U>&, const CalDet<U>&);
9898

9999
private:
100-
std::string mName; ///< name of the object
101-
std::vector<CalType> mData; ///< internal CalArrays
102-
PadSubset mPadSubset; ///< Pad subset granularity
100+
std::string mName; ///< name of the object
101+
std::vector<CalType> mData; ///< internal CalArrays
102+
PadSubset mPadSubset = PadSubset::ROC; ///< Pad subset granularity
103103

104104
/// initialize the data array depending on what is set as PadSubset
105105
void initData();

Detectors/TPC/base/src/CDBInterface.cxx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const CalPad& CDBInterface::getPedestals()
5858
}
5959
} else {
6060
// return from CDB, assume that check for object existence are done there
61-
return getObjectFromCDB<CalPad>(CDBTypeMap.at(CDBType::CalPedestal));
61+
return getObjectFromCDB<CalPadMapType>(CDBTypeMap.at(CDBType::CalPedestalNoise)).at("Pedestals");
6262
}
6363

6464
if (!mPedestals) {
@@ -82,7 +82,7 @@ const CalPad& CDBInterface::getNoise()
8282
}
8383
} else {
8484
// return from CDB, assume that check for object existence are done there
85-
return getObjectFromCDB<CalPad>(CDBTypeMap.at(CDBType::CalNoise));
85+
return getObjectFromCDB<CalPadMapType>(CDBTypeMap.at(CDBType::CalPedestalNoise)).at("Noise");
8686
}
8787

8888
if (!mNoise) {
@@ -301,9 +301,9 @@ bool CDBStorage::checkMetaData(MetaData_t metaData) const
301301
"Optional"};
302302

303303
const std::array<std::vector<std::string_view>, 3> tests{{
304-
{"Responsible", "Reason", "Intervention"}, //errors
305-
{"JIRA"}, //warnings
306-
{"Comment"} //infos
304+
{"Responsible", "Reason", "Intervention"}, // errors
305+
{"JIRA"}, // warnings
306+
{"Comment"} // infos
307307
}};
308308

309309
std::array<int, 3> counts{};
@@ -346,8 +346,12 @@ void CDBStorage::uploadNoiseAndPedestal(std::string_view fileName, long first, l
346346
LOGP(fatal, "No valid noise object was loaded from file {}", fileName);
347347
}
348348

349-
storeObject(pedestals, CDBType::CalPedestal, first, last);
350-
storeObject(noise, CDBType::CalNoise, first, last);
349+
CDBInterface::CalPadMapType calib;
350+
351+
calib["Pedestals"] = *pedestals;
352+
calib["Noise"] = *noise;
353+
354+
storeObject(&calib, CDBType::CalPedestalNoise, first, last);
351355
}
352356

353357
//______________________________________________________________________________

Detectors/TPC/base/src/Painter.cxx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ TCanvas* painter::draw(const CalDet<T>& calDet, int nbins1D, float xMin1D, float
109109
TH1::SetDefaultBufferSize(Sector::MAXSECTOR * mapper.getPadsInSector());
110110

111111
auto hAside1D = new TH1F(fmt::format("h_Aside_1D_{}", name).data(), fmt::format("{} (A-Side)", title).data(),
112-
nbins1D, xMin1D, xMax1D); //TODO: modify ranges
112+
nbins1D, xMin1D, xMax1D); // TODO: modify ranges
113113

114114
auto hCside1D = new TH1F(fmt::format("h_Cside_1D_{}", name).data(), fmt::format("{} (C-Side)", title).data(),
115-
nbins1D, xMin1D, xMax1D); //TODO: modify ranges
115+
nbins1D, xMin1D, xMax1D); // TODO: modify ranges
116116

117117
auto hAside2D = new TH2F(fmt::format("h_Aside_2D_{}", name).data(), fmt::format("{} (A-Side);#it{{x}} (cm);#it{{y}} (cm)", title).data(),
118118
330, -270, 270, 330, -270, 270);
@@ -387,7 +387,7 @@ std::vector<TCanvas*> painter::makeSummaryCanvases(const CalDet<T>& calDet, int
387387
}
388388

389389
// ===| 1D histogram |===
390-
auto h1D = new TH1F(fmt::format("h_{}_{:02d}", calName, iroc).data(), fmt::format("{} distribution ROC {:02d} ({});ADC value", calName, iroc, getROCTitle(iroc)).data(), nbins1D, xMin1D, xMax1D);
390+
auto h1D = new TH1F(fmt::format("h1_{}_{:02d}", calName, iroc).data(), fmt::format("{} distribution ROC {:02d} ({});ADC value", calName, iroc, getROCTitle(iroc)).data(), nbins1D, xMin1D, xMax1D);
391391
for (const auto& val : roc.getData()) {
392392
h1D->Fill(val);
393393
}
@@ -806,7 +806,7 @@ std::vector<TCanvas*> painter::makeSummaryCanvases(const LtrCalibData& ltr, std:
806806
cLtrCoverage = new TCanvas("cLtrCoverage", "laser track coverage", size, 2. * size * 7 / 24 * 1.1);
807807
cCalibValues = new TCanvas("cCalibValues", "calibration values", size, 2. * size * 7 / 24 * 1.1);
808808

809-
//TODO: add cCalibValues
809+
// TODO: add cCalibValues
810810
}
811811

812812
auto getLtrStatHist = [](Side side) -> TH2F* {
@@ -849,7 +849,7 @@ std::vector<TCanvas*> painter::makeSummaryCanvases(const LtrCalibData& ltr, std:
849849

850850
hltrCoverage->Fill(bundleID, trackID);
851851
}
852-
//hltrCoverage->Scale(1.f/float(ltr->processedTFs));
852+
// hltrCoverage->Scale(1.f/float(ltr->processedTFs));
853853

854854
cLtrCoverage->Divide(1, 2);
855855

Detectors/TPC/calibration/include/TPCCalibration/CalibPedestal.h

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
/// \file CalibPedestal.h
1616
/// \author Jens Wiechula, Jens.Wiechula@ikf.uni-frankfurt.de
1717

18+
#include <string>
1819
#include <vector>
1920
#include <memory>
21+
#include <unordered_map>
2022

2123
#include "Rtypes.h"
2224

@@ -45,10 +47,10 @@ class CalibPedestal : public CalibRawBase
4547
public:
4648
using vectorType = std::vector<float>;
4749

48-
//enum class StatisticsType {
49-
//GausFit, ///< Use Gaus fit for pedestal and noise
50-
//MeanStdDev ///< Use mean and standard deviation
51-
//};
50+
// enum class StatisticsType {
51+
// GausFit, ///< Use Gaus fit for pedestal and noise
52+
// MeanStdDev ///< Use mean and standard deviation
53+
// };
5254

5355
/// default constructor
5456
CalibPedestal(PadSubset padSubset = PadSubset::ROC);
@@ -99,15 +101,17 @@ class CalibPedestal : public CalibRawBase
99101
/// Get the pedestal calibration object
100102
///
101103
/// \return pedestal calibration object
102-
const CalPad& getPedestal() const { return mPedestal; }
104+
const CalPad& getPedestal() const { return mCalDets.at("Pedestals"); }
103105

104106
/// Get the noise calibration object
105107
///
106108
/// \return noise calibration object
107-
const CalPad& getNoise() const { return mNoise; }
109+
const CalPad& getNoise() const { return mCalDets.at("Noise"); }
110+
111+
const auto& getCalDets() const { return mCalDets; }
108112

109113
/// return all pad clibrations as vector
110-
const std::vector<const o2::tpc::CalDet<float>*> getCalDets() const { return std::vector<const o2::tpc::CalDet<float>*>{&mPedestal, &mNoise}; }
114+
// const std::vector<const o2::tpc::CalDet<float>*> getCalDets() const { return std::vector<const o2::tpc::CalDet<float>*>{&mCalDets.at("Pedestals"), &mCalDets.at("Noise")}; }
111115

112116
/// Get the statistics type
113117
StatisticsType getStatisticsType() const { return mStatisticsType; }
@@ -122,14 +126,13 @@ class CalibPedestal : public CalibRawBase
122126
TH2* createControlHistogram(ROC roc);
123127

124128
private:
125-
int mFirstTimeBin; ///< first time bin used in analysis
126-
int mLastTimeBin; ///< first time bin used in analysis
127-
int mADCMin; ///< minimum adc value
128-
int mADCMax; ///< maximum adc value
129-
int mNumberOfADCs; ///< number of adc values (mADCMax-mADCMin+1)
130-
StatisticsType mStatisticsType; ///< statistics type to be used for pedestal and noise evaluation
131-
CalPad mPedestal; ///< CalDet object with pedestal information
132-
CalPad mNoise; ///< CalDet object with noise
129+
int mFirstTimeBin; ///< first time bin used in analysis
130+
int mLastTimeBin; ///< first time bin used in analysis
131+
int mADCMin; ///< minimum adc value
132+
int mADCMax; ///< maximum adc value
133+
int mNumberOfADCs; ///< number of adc values (mADCMax-mADCMin+1)
134+
StatisticsType mStatisticsType; ///< statistics type to be used for pedestal and noise evaluation
135+
std::unordered_map<std::string, CalPad> mCalDets; ///< CalDet objects for pedestal and noise
133136

134137
std::vector<std::unique_ptr<vectorType>> mADCdata; //!< ADC data to calculate noise and pedestal
135138

Detectors/TPC/calibration/include/TPCCalibration/CalibPulser.h

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include <vector>
1919
#include <memory>
20+
#include <unordered_map>
2021

2122
#include "TH2S.h"
2223

@@ -83,8 +84,8 @@ class CalibPulser : public CalibRawBase
8384
{
8485
mFirstTimeBin = first;
8586
mLastTimeBin = last;
86-
//TODO: until automatic T0 calibration is done we use the same time range
87-
// as for the time bin selection
87+
// TODO: until automatic T0 calibration is done we use the same time range
88+
// as for the time bin selection
8889
mXminT0 = mFirstTimeBin;
8990
mXmaxT0 = mLastTimeBin;
9091
}
@@ -134,15 +135,17 @@ class CalibPulser : public CalibRawBase
134135

135136
/// Get the pulser mean time calibration object
136137
/// \return pedestal calibration object
137-
const CalPad& getT0() const { return mT0; }
138+
const CalPad& getT0() const { return mCalDets.at("T0"); }
138139

139140
/// Get the pulser pulse with calibration object
140141
/// \return pulse width calibration object
141-
const CalPad& getWidth() const { return mWidth; }
142+
const CalPad& getWidth() const { return mCalDets.at("Width"); }
142143

143144
/// Get the pulser total charge calibration object
144145
/// \return pulser total charge calibration object
145-
const CalPad& getQtot() const { return mQtot; }
146+
const CalPad& getQtot() const { return mCalDets.at("Qtot"); }
147+
148+
const auto& getCalDets() const { return mCalDets; }
146149

147150
/// Dump the relevant data to file
148151
void dumpToFile(const std::string filename, uint32_t type = 0) final;
@@ -165,19 +168,17 @@ class CalibPulser : public CalibRawBase
165168
float mXminWidth; ///< xmin of width reference histogram
166169
float mXmaxWidth; ///< xmax of width reference histogram
167170

168-
int mFirstTimeBin; ///< first time bin used in analysis
169-
int mLastTimeBin; ///< first time bin used in analysis
170-
int mADCMin; ///< minimum adc value
171-
int mADCMax; ///< maximum adc value
172-
int mNumberOfADCs; ///< number of adc values (mADCMax-mADCMin+1)
173-
int mPeakIntMinus; ///< lower bound from maximum for the peak integration, mean and std dev. calc
174-
int mPeakIntPlus; ///< upper bound from maximum for the peak integration, mean and std dev. calc
175-
float mMinimumQtot; ///< minimal Qtot accepted as pulser signal
176-
float mMinimumQmax; ///< minimal Qtot accepted as pulser signal
177-
int mMaxTimeBinRange; ///< number of time bins around the one with the maximum number of entries arouch which to analyse
178-
CalPad mT0; ///< CalDet object with pulser time information
179-
CalPad mWidth; ///< CalDet object with pulser pulse width information
180-
CalPad mQtot; ///< CalDet object with pulser Qtot information
171+
int mFirstTimeBin; ///< first time bin used in analysis
172+
int mLastTimeBin; ///< first time bin used in analysis
173+
int mADCMin; ///< minimum adc value
174+
int mADCMax; ///< maximum adc value
175+
int mNumberOfADCs; ///< number of adc values (mADCMax-mADCMin+1)
176+
int mPeakIntMinus; ///< lower bound from maximum for the peak integration, mean and std dev. calc
177+
int mPeakIntPlus; ///< upper bound from maximum for the peak integration, mean and std dev. calc
178+
float mMinimumQtot; ///< minimal Qtot accepted as pulser signal
179+
float mMinimumQmax; ///< minimal Qtot accepted as pulser signal
180+
int mMaxTimeBinRange; ///< number of time bins around the one with the maximum number of entries arouch which to analyse
181+
std::unordered_map<std::string, CalPad> mCalDets; ///< CalDet objects for pedestal and noise
181182

182183
const CalPad* mPedestal; //!< Pedestal calibration object
183184
const CalPad* mNoise; //!< Noise calibration object

Detectors/TPC/calibration/include/TPCCalibration/CalibPulserParam.h

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,24 @@ namespace tpc
2525
{
2626

2727
struct CalibPulserParam : public o2::conf::ConfigurableParamHelper<CalibPulserParam> {
28-
int NbinsT0{200}; ///< Number of bins for T0 reference histogram
29-
float XminT0{-2}; ///< xmin of T0 reference histogram
30-
float XmaxT0{2}; ///< xmax of T0 reference histogram
31-
int NbinsQtot{200}; ///< Number of bins for Qtot reference histogram
32-
float XminQtot{50}; ///< xmin of Qtot reference histogram
33-
float XmaxQtot{700}; ///< xmax of Qtot reference histogram
34-
int NbinsWidth{100}; ///< Number of bins for width reference histogram
35-
float XminWidth{0.1}; ///< xmin of width reference histogram
36-
float XmaxWidth{5.1}; ///< xmax of width reference histogram
37-
int FirstTimeBin{10}; ///< first time bin used in analysis
38-
int LastTimeBin{490}; ///< first time bin used in analysis
39-
int ADCMin{5}; ///< minimum adc value
40-
int ADCMax{1023}; ///< maximum adc value
41-
int PeakIntMinus{2}; ///< lower bound from maximum for the peak integration, mean and std dev. calc
42-
int PeakIntPlus{2}; ///< upper bound from maximum for the peak integration, mean and std dev. calc
43-
float MinimumQtot{20}; ///< minimal Qtot accepted as pulser signal
44-
float MinimumQmax{10}; ///< minimal Qmax accepted as pulser signal
28+
int NbinsT0{200}; ///< Number of bins for T0 reference histogram
29+
float XminT0{-2}; ///< xmin of T0 reference histogram
30+
float XmaxT0{2}; ///< xmax of T0 reference histogram
31+
int NbinsQtot{200}; ///< Number of bins for Qtot reference histogram
32+
float XminQtot{50}; ///< xmin of Qtot reference histogram
33+
float XmaxQtot{700}; ///< xmax of Qtot reference histogram
34+
int NbinsWidth{100}; ///< Number of bins for width reference histogram
35+
float XminWidth{0.1}; ///< xmin of width reference histogram
36+
float XmaxWidth{5.1}; ///< xmax of width reference histogram
37+
int FirstTimeBin{10}; ///< first time bin used in analysis
38+
int LastTimeBin{490}; ///< first time bin used in analysis
39+
int ADCMin{5}; ///< minimum adc value
40+
int ADCMax{1023}; ///< maximum adc value
41+
int PeakIntMinus{2}; ///< lower bound from maximum for the peak integration, mean and std dev. calc
42+
int PeakIntPlus{2}; ///< upper bound from maximum for the peak integration, mean and std dev. calc
43+
float MinimumQtot{20}; ///< minimal Qtot accepted as pulser signal
44+
float MinimumQmax{10}; ///< minimal Qmax accepted as pulser signal
45+
int MaxTimeBinRange{5}; ///< number of time bins around the one with the maximum number of entries arouch which to analyse
4546

4647
O2ParamDef(CalibPulserParam, "TPCCalibPulser");
4748
};

0 commit comments

Comments
 (0)