Skip to content

Commit 717ce11

Browse files
committed
Add calculation of mean values over all sectors
1 parent 724584a commit 717ce11

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#ifndef GPUCA_GPUCODE_DEVICE
2323
#include <string_view>
2424
#include <algorithm>
25+
#include <array>
2526
#endif
2627

2728
// o2 includes
@@ -96,6 +97,18 @@ class CalibdEdxCorrection
9697
/// \param outFileName name of the output file
9798
void dumpToTree(const char* outFileName = "calib_dedx.root") const;
9899

100+
/// Parameters averaged over all stacks
101+
const std::array<float, ParamSize> getMeanParams(ChargeType charge) const;
102+
103+
/// Parameters averaged over all sectors for a stack type
104+
const std::array<float, ParamSize> getMeanParams(const GEMstack stack, ChargeType charge) const;
105+
106+
/// Single fit parameters averaged over all sectors for a stack type
107+
float getMeanParam(ChargeType charge, uint32_t param) const;
108+
109+
/// Single fit parameters averaged over all sectors for a stack type
110+
float getMeanParam(const GEMstack stack, ChargeType charge, uint32_t param) const;
111+
99112
#endif
100113

101114
private:

DataFormats/Detectors/TPC/src/CalibdEdxCorrection.cxx

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include "DataFormatsTPC/CalibdEdxCorrection.h"
1313

14+
#include <algorithm>
1415
#include <string_view>
1516

1617
// o2 includes
@@ -86,3 +87,51 @@ void CalibdEdxCorrection::dumpToTree(const char* outFileName) const
8687
}
8788
}
8889
}
90+
91+
const std::array<float, CalibdEdxCorrection::ParamSize> CalibdEdxCorrection::getMeanParams(ChargeType charge) const
92+
{
93+
std::array<float, ParamSize> params{};
94+
95+
for (int index = 0; index < FitSize / 2; ++index) {
96+
std::transform(params.begin(), params.end(), mParams[index + charge * FitSize / 2], params.begin(), std::plus<>());
97+
}
98+
std::for_each(params.begin(), params.end(), [](auto& val) { val /= (0.5f * FitSize); });
99+
return params;
100+
}
101+
102+
const std::array<float, CalibdEdxCorrection::ParamSize> CalibdEdxCorrection::getMeanParams(const GEMstack stack, ChargeType charge) const
103+
{
104+
std::array<float, ParamSize> params{};
105+
106+
for (int index = 0; index < SECTORSPERSIDE * SIDES; ++index) {
107+
std::transform(params.begin(), params.end(), getParams(StackID{index, stack}, charge), params.begin(), std::plus<>());
108+
}
109+
std::for_each(params.begin(), params.end(), [](auto& val) { val /= (SECTORSPERSIDE * SIDES); });
110+
return params;
111+
}
112+
113+
float CalibdEdxCorrection::getMeanParam(ChargeType charge, uint32_t param) const
114+
{
115+
if (param >= ParamSize) {
116+
return 0.f;
117+
}
118+
float mean{};
119+
for (int index = 0; index < FitSize / 2; ++index) {
120+
mean += mParams[index + charge * FitSize / 2][param];
121+
}
122+
123+
return mean / (0.5f * FitSize);
124+
}
125+
126+
float CalibdEdxCorrection::getMeanParam(const GEMstack stack, ChargeType charge, uint32_t param) const
127+
{
128+
if (param >= ParamSize) {
129+
return 0.f;
130+
}
131+
float mean{};
132+
for (int index = 0; index < SECTORSPERSIDE * SIDES; ++index) {
133+
mean += getParams(StackID{index, stack}, charge)[param];
134+
}
135+
136+
return mean / (SECTORSPERSIDE * SIDES);
137+
}

0 commit comments

Comments
 (0)