Skip to content

Commit eaa7fbb

Browse files
authored
TPC: Multiple fixes and extensions (AliceO2Group#13533)
* fix completion policy * Add possibility for a common file name extension saving canvases * Extend FW parameter file creation * Allow for different thresholds for each ROC Type in pedestal file creation * Add common mode k-values in float precision and inverse k-factors with truncated precision * Digit class extension for simple drawing * Extend TPC refitter * possibility to dump ITS-TPC * Tsallis downsampling * MB sampling * shared flag added to native clusters * Charge info now via native clusters * Write full native clusters * add occupancy info * add cosmics refitting with TOF cluster time * Extend time gain calibration * Undo previous timeGain corrections to allow for residual calibration * slot length in seconds * slot extension for CCDB (for residual calibration) * simple looper cut * settable debug output name * dumping of calibration histograms per slot * debug output on track level * average entries for calibration * Update event display - Pad vs time view for a single row * visualisation of hovered time bin in ADC vs. time - cluster overlay in pad vs. time view * selection of cluster flags - Pad vs. row view for a single time bin * visualisation of hovered time bin in ADC vs. time
1 parent 2f7add5 commit eaa7fbb

31 files changed

+1571
-313
lines changed

DataFormats/Detectors/TPC/include/DataFormatsTPC/CalibdEdxCorrection.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ class CalibdEdxCorrection
109109
/// Single fit parameters averaged over all sectors for a stack type
110110
float getMeanParam(const GEMstack stack, ChargeType charge, uint32_t param) const;
111111

112+
/// Single fit parameters averaged over all sectors for a stack type
113+
float getMeanEntries(ChargeType charge) const;
114+
115+
/// Single fit parameters averaged over all sectors for a stack type
116+
float getMeanEntries(const GEMstack stack, ChargeType charge) const;
117+
112118
#endif
113119

114120
private:

DataFormats/Detectors/TPC/include/DataFormatsTPC/TrackCuts.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,16 @@ class TrackCuts
4646
void setNClusMin(float NClusMin) { mNClusMin = NClusMin; }
4747
void setdEdxMin(float dEdxMin) { mdEdxMin = dEdxMin; }
4848
void setdEdxMax(float dEdxMax) { mdEdxMax = dEdxMax; }
49+
/// try to remove looper cutting on (abs(z_out) - abs(z_in)) < -10), not very precise
50+
void setCutLooper(bool cut) { mCutLooper = cut; }
4951

5052
private:
51-
float mPMin{0}; ///< min momentum allowed
52-
float mPMax{1e10}; ///< max momentum allowed
53-
float mNClusMin{0}; ///< min number of clusters in track allowed
54-
float mdEdxMin{0}; ///< min dEdx
55-
float mdEdxMax{1e10}; ///< max dEdx
53+
float mPMin{0}; ///< min momentum allowed
54+
float mPMax{1e10}; ///< max momentum allowed
55+
float mNClusMin{0}; ///< min number of clusters in track allowed
56+
float mdEdxMin{0}; ///< min dEdx
57+
float mdEdxMax{1e10}; ///< max dEdx
58+
bool mCutLooper{false}; ///< cut looper comparing zout-zin
5659

5760
ClassDefNV(TrackCuts, 1)
5861
};

DataFormats/Detectors/TPC/src/CalibdEdxCorrection.cxx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,23 @@ float CalibdEdxCorrection::getMeanParam(const GEMstack stack, ChargeType charge,
135135

136136
return mean / (SECTORSPERSIDE * SIDES);
137137
}
138+
139+
float CalibdEdxCorrection::getMeanEntries(ChargeType charge) const
140+
{
141+
float mean{};
142+
for (int index = 0; index < FitSize / 2; ++index) {
143+
mean += mEntries[index + charge * FitSize / 2];
144+
}
145+
146+
return mean / (0.5f * FitSize);
147+
}
148+
149+
float CalibdEdxCorrection::getMeanEntries(const GEMstack stack, ChargeType charge) const
150+
{
151+
float mean{};
152+
for (int index = 0; index < SECTORSPERSIDE * SIDES; ++index) {
153+
mean += getEntries(StackID{index, stack}, charge);
154+
}
155+
156+
return mean / (SECTORSPERSIDE * SIDES);
157+
}

DataFormats/Detectors/TPC/src/TrackCuts.cxx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,8 @@ bool TrackCuts::goodTrack(o2::tpc::TrackTPC const& track)
4949
if (dEdx < mdEdxMin) {
5050
return false;
5151
}
52+
if ((std::abs(track.getOuterParam().getZ()) - std::abs(track.getZ())) < -10) {
53+
return false;
54+
}
5255
return true;
5356
}

Detectors/Base/include/DetectorsBase/DPLWorkflowUtils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "Framework/CompletionPolicy.h"
2626
#include "Framework/CompletionPolicyHelpers.h"
2727
#include "Framework/DeviceSpec.h"
28+
#include "Framework/Task.h"
2829
#include "Framework/DataSpecUtils.h"
2930
#include <vector>
3031
#include <unordered_map>

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <gsl/span>
2121
#include <filesystem>
2222
#include <type_traits>
23+
#include <vector>
2324
namespace fs = std::filesystem;
2425

2526
#include "Rtypes.h"
@@ -246,7 +247,9 @@ o2::tpc::CalDet<float> getCalPad(const std::string_view fileName, const std::str
246247
return calPad;
247248
}
248249

249-
std::unordered_map<std::string, CalPad> preparePedestalFiles(const CalPad& pedestals, const CalPad& noise, float sigmaNoise = 3, float minADC = 2, float pedestalOffset = 0, bool onlyFilled = false, bool maskBad = true, float noisyChannelThreshold = 1.5, float sigmaNoiseNoisyChannels = 4, float badChannelThreshold = 6, bool fixedSize = false);
250+
/// \param sigmaNoiseROCType can be either one value for all ROC types, or {IROC, OROC}, or {IROC, OROC1, OROC2, OROC3}
251+
/// \param minADCROCType can be either one value for all ROC types, or {IROC, OROC}, or {IROC, OROC1, OROC2, OROC3}
252+
std::unordered_map<std::string, CalPad> preparePedestalFiles(const CalPad& pedestals, const CalPad& noise, std::vector<float> sigmaNoiseROCType = {3, 3, 3, 3}, std::vector<float> minADCROCType = {2, 2, 2, 2}, float pedestalOffset = 0, bool onlyFilled = false, bool maskBad = true, float noisyChannelThreshold = 1.5, float sigmaNoiseNoisyChannels = 4, float badChannelThreshold = 6, bool fixedSize = false);
250253

251254
} // namespace o2::tpc::cru_calib_helpers
252255

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
/// \author Jens Wiechula, [email protected]
1818
///
1919

20+
#include <string>
2021
#include <vector>
2122
#include <string_view>
2223

@@ -44,9 +45,9 @@ namespace utils
4445
const std::vector<std::string> tokenize(const std::string_view input, const std::string_view pattern);
4546
TH1* getBinInfoXY(int& binx, int& biny, float& bincx, float& bincy);
4647
void addFECInfo();
47-
void saveCanvases(TObjArray& arr, std::string_view outDir, std::string_view types = "png,pdf", std::string_view rootFileName = "");
48-
void saveCanvases(std::vector<TCanvas*>& canvases, std::string_view outDir, std::string_view types = "png,pdf", std::string_view rootFileName = "");
49-
void saveCanvas(TCanvas& c, std::string_view outDir, std::string_view types);
48+
void saveCanvases(TObjArray& arr, std::string_view outDir, std::string_view types = "png,pdf", std::string_view rootFileName = "", std::string nameAdd = "");
49+
void saveCanvases(std::vector<TCanvas*>& canvases, std::string_view outDir, std::string_view types = "png,pdf", std::string_view rootFileName = "", std::string nameAdd = "");
50+
void saveCanvas(TCanvas& c, std::string_view outDir, std::string_view types, std::string nameAdd = "");
5051
std::vector<CalPad*> readCalPads(const std::string_view fileName, const std::vector<std::string>& calPadNames);
5152
std::vector<CalPad*> readCalPads(const std::string_view fileName, const std::string_view calPadNames);
5253

@@ -69,6 +70,19 @@ void mergeCalPads(std::string_view outputFileName, std::string_view inputFileNam
6970
/// \param treeTitle title of the tree
7071
TChain* buildChain(std::string_view command, std::string_view treeName, std::string_view treeTitle = "", bool checkSubDir = false);
7172

73+
template <typename Iterator>
74+
std::string elementsToString(Iterator begin, Iterator end, const std::string separator = ", ")
75+
{
76+
return std::accumulate(std::next(begin), end, std::to_string(*begin),
77+
[&separator](auto s, auto f) { return std::move(s) + separator + std::to_string(f); });
78+
}
79+
80+
template <typename T>
81+
std::string elementsToString(const T& val, const std::string separator = ", ")
82+
{
83+
return elementsToString(val.begin(), val.end(), separator);
84+
}
85+
7286
} // namespace utils
7387
} // namespace o2::tpc
7488

Detectors/TPC/base/src/CRUCalibHelpers.cxx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
#include <fstream>
1313
#include <iostream>
1414
#include <numeric>
15+
#include <vector>
1516

17+
#include "TPCBase/Utils.h"
1618
#include "TROOT.h"
1719

1820
#include "Framework/Logger.h"
@@ -102,10 +104,26 @@ void cru_calib_helpers::debugDiff(std::string_view file1, std::string_view file2
102104
}
103105
}
104106

105-
std::unordered_map<std::string, CalPad> cru_calib_helpers::preparePedestalFiles(const CalPad& pedestals, const CalPad& noise, float sigmaNoise, float minADC, float pedestalOffset, bool onlyFilled, bool maskBad, float noisyChannelThreshold, float sigmaNoiseNoisyChannels, float badChannelThreshold, bool fixedSize)
107+
std::unordered_map<std::string, CalPad> cru_calib_helpers::preparePedestalFiles(const CalPad& pedestals, const CalPad& noise, std::vector<float> sigmaNoiseROCType, std::vector<float> minADCROCType, float pedestalOffset, bool onlyFilled, bool maskBad, float noisyChannelThreshold, float sigmaNoiseNoisyChannels, float badChannelThreshold, bool fixedSize)
106108
{
107109
const auto& mapper = Mapper::instance();
108110

111+
auto expandVector = [](std::vector<float>& vec, const std::string name) {
112+
if (vec.size() == 1) {
113+
vec.resize(4);
114+
std::fill_n(&vec[1], 3, vec[0]);
115+
} else if (vec.size() == 2) {
116+
vec.resize(4);
117+
std::fill_n(&vec[2], 2, vec[1]);
118+
} else if (vec.size() != 4) {
119+
LOGP(fatal, "{} definition must be either one value for all ROC types, or {{IROC, OROC}}, or {{IROC, OROC1, OROC2, OROC3}}", name);
120+
}
121+
LOGP(info, "Using {} = {{{}}}", name, utils::elementsToString(vec));
122+
};
123+
124+
expandVector(sigmaNoiseROCType, "sigmaNoiseROCType");
125+
expandVector(minADCROCType, "minADCROCType");
126+
109127
std::unordered_map<std::string, CalPad> pedestalsThreshold;
110128
pedestalsThreshold["Pedestals"] = CalPad("Pedestals");
111129
pedestalsThreshold["ThresholdMap"] = CalPad("ThresholdMap");
@@ -147,6 +165,9 @@ std::unordered_map<std::string, CalPad> cru_calib_helpers::preparePedestalFiles(
147165
const int fecInPartition = fecInfo.getIndex() - partInfo.getSectorFECOffset();
148166
// const int dataWrapperID = fecInPartition >= fecOffset;
149167
// const int globalLinkID = (fecInPartition % fecOffset) + dataWrapperID * 12;
168+
const int rocType = roc.isIROC() ? 0 : cru.partition() - 1;
169+
const float sigmaNoise = sigmaNoiseROCType[rocType];
170+
const float minADC = minADCROCType[rocType];
150171

151172
const auto traceLength = traceLengths[ipad];
152173

@@ -174,6 +195,7 @@ std::unordered_map<std::string, CalPad> cru_calib_helpers::preparePedestalFiles(
174195
float threshold = (noise > 0) ? std::max(sigmaNoise * noise, minADC) : 0;
175196
threshold = std::min(threshold, 1023.f);
176197
float thresholdHighNoise = (noiseCorr > noisyChannelThreshold) ? std::max(sigmaNoiseNoisyChannels * noise, minADC) : threshold;
198+
thresholdHighNoise = std::min(thresholdHighNoise, 1023.f);
177199

178200
float pedestalHighNoise = pedestal;
179201
if (noiseCorr > badChannelThreshold) {

Detectors/TPC/base/src/Utils.cxx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,11 @@ void utils::addFECInfo()
133133
h->SetTitle(title.data());
134134
}
135135

136-
void utils::saveCanvases(TObjArray& arr, std::string_view outDir, std::string_view types, std::string_view rootFileName)
136+
void utils::saveCanvases(TObjArray& arr, std::string_view outDir, std::string_view types, std::string_view rootFileName, std::string nameAdd)
137137
{
138138
if (types.size()) {
139139
for (auto c : arr) {
140-
utils::saveCanvas(*static_cast<TCanvas*>(c), outDir, types);
140+
utils::saveCanvas(*static_cast<TCanvas*>(c), outDir, types, nameAdd);
141141
}
142142
}
143143

@@ -148,24 +148,24 @@ void utils::saveCanvases(TObjArray& arr, std::string_view outDir, std::string_vi
148148
}
149149
}
150150

151-
void utils::saveCanvases(std::vector<TCanvas*>& canvases, std::string_view outDir, std::string_view types, std::string_view rootFileName)
151+
void utils::saveCanvases(std::vector<TCanvas*>& canvases, std::string_view outDir, std::string_view types, std::string_view rootFileName, std::string nameAdd)
152152
{
153153
TObjArray arr;
154154
for (auto c : canvases) {
155155
arr.Add(c);
156156
}
157157

158-
saveCanvases(arr, outDir, types, rootFileName);
158+
saveCanvases(arr, outDir, types, rootFileName, nameAdd);
159159
}
160160

161-
void utils::saveCanvas(TCanvas& c, std::string_view outDir, std::string_view types)
161+
void utils::saveCanvas(TCanvas& c, std::string_view outDir, std::string_view types, std::string nameAdd)
162162
{
163163
if (!types.size()) {
164164
return;
165165
}
166166
const auto typesVec = tokenize(types, ",");
167167
for (const auto& type : typesVec) {
168-
c.SaveAs(fmt::format("{}/{}.{}", outDir, c.GetName(), type).data());
168+
c.SaveAs(fmt::format("{}/{}{}.{}", outDir, c.GetName(), nameAdd, type).data());
169169
}
170170
}
171171

Detectors/TPC/calibration/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ o2_add_library(TPCCalibration
5555
src/TPCScaler.cxx
5656
src/CorrMapParam.cxx
5757
src/TPCMShapeCorrection.cxx
58+
src/DigitAdd.cxx
5859
PUBLIC_LINK_LIBRARIES O2::DataFormatsTPC O2::TPCBase
5960
O2::TPCReconstruction ROOT::Minuit
6061
Microsoft.GSL::GSL
@@ -109,7 +110,8 @@ o2_target_root_dictionary(TPCCalibration
109110
include/TPCCalibration/CalculatedEdx.h
110111
include/TPCCalibration/TPCScaler.h
111112
include/TPCCalibration/CorrMapParam.h
112-
include/TPCCalibration/TPCMShapeCorrection.h)
113+
include/TPCCalibration/TPCMShapeCorrection.h
114+
include/TPCCalibration/DigitAdd.h)
113115

114116
o2_add_test_root_macro(macro/comparePedestalsAndNoise.C
115117
PUBLIC_LINK_LIBRARIES O2::TPCBase

0 commit comments

Comments
 (0)