|
11 | 11 |
|
12 | 12 | #include "DataFormatsTPC/CalibdEdxCorrection.h" |
13 | 13 |
|
| 14 | +#include <algorithm> |
14 | 15 | #include <string_view> |
15 | 16 |
|
16 | 17 | // o2 includes |
@@ -86,3 +87,51 @@ void CalibdEdxCorrection::dumpToTree(const char* outFileName) const |
86 | 87 | } |
87 | 88 | } |
88 | 89 | } |
| 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