Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add calculation of mean values over all sectors
  • Loading branch information
wiechula committed Apr 25, 2024
commit 6e59d8c63870005850b9cb59c1759fe8ae2ae1c5
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#ifndef GPUCA_GPUCODE_DEVICE
#include <string_view>
#include <algorithm>
#include <array>
#endif

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

/// Parameters averaged over all stacks
const std::array<float, ParamSize> getMeanParams(ChargeType charge) const;

/// Parameters averaged over all sectors for a stack type
const std::array<float, ParamSize> getMeanParams(const GEMstack stack, ChargeType charge) const;

/// Single fit parameters averaged over all sectors for a stack type
float getMeanParam(ChargeType charge, uint32_t param) const;

/// Single fit parameters averaged over all sectors for a stack type
float getMeanParam(const GEMstack stack, ChargeType charge, uint32_t param) const;

#endif

private:
Expand Down
49 changes: 49 additions & 0 deletions DataFormats/Detectors/TPC/src/CalibdEdxCorrection.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "DataFormatsTPC/CalibdEdxCorrection.h"

#include <algorithm>
#include <string_view>

// o2 includes
Expand Down Expand Up @@ -86,3 +87,51 @@ void CalibdEdxCorrection::dumpToTree(const char* outFileName) const
}
}
}

const std::array<float, CalibdEdxCorrection::ParamSize> CalibdEdxCorrection::getMeanParams(ChargeType charge) const
{
std::array<float, ParamSize> params{};

for (int index = 0; index < FitSize / 2; ++index) {
std::transform(params.begin(), params.end(), mParams[index + charge * FitSize / 2], params.begin(), std::plus<>());
}
std::for_each(params.begin(), params.end(), [](auto& val) { val /= (0.5f * FitSize); });
return params;
}

const std::array<float, CalibdEdxCorrection::ParamSize> CalibdEdxCorrection::getMeanParams(const GEMstack stack, ChargeType charge) const
{
std::array<float, ParamSize> params{};

for (int index = 0; index < SECTORSPERSIDE * SIDES; ++index) {
std::transform(params.begin(), params.end(), getParams(StackID{index, stack}, charge), params.begin(), std::plus<>());
}
std::for_each(params.begin(), params.end(), [](auto& val) { val /= (SECTORSPERSIDE * SIDES); });
return params;
}

float CalibdEdxCorrection::getMeanParam(ChargeType charge, uint32_t param) const
{
if (param >= ParamSize) {
return 0.f;
}
float mean{};
for (int index = 0; index < FitSize / 2; ++index) {
mean += mParams[index + charge * FitSize / 2][param];
}

return mean / (0.5f * FitSize);
}

float CalibdEdxCorrection::getMeanParam(const GEMstack stack, ChargeType charge, uint32_t param) const
{
if (param >= ParamSize) {
return 0.f;
}
float mean{};
for (int index = 0; index < SECTORSPERSIDE * SIDES; ++index) {
mean += getParams(StackID{index, stack}, charge)[param];
}

return mean / (SECTORSPERSIDE * SIDES);
}