Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
36 changes: 24 additions & 12 deletions PWGCF/FemtoUniverse/Core/FemtoUniverseEfficiencyCorrection.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ class EfficiencyCorrection
LOGF(fatal, notify("Unknown configuration for efficiency variables"));
break;
}
} else {
hLoaded[idx] = nullptr;
}
}
}
Expand Down Expand Up @@ -201,17 +199,18 @@ class EfficiencyCorrection

auto bin = -1;
if (config->confEffCorVariables.value == "pt") {
bin = hLoaded[partNo - 1]->FindBin(particle.pt());
bin = hWeights->FindBin(particle.pt());
} else if (config->confEffCorVariables.value == "pt,eta") {
bin = hLoaded[partNo - 1]->FindBin(particle.pt(), particle.eta());
bin = hWeights->FindBin(particle.pt(), particle.eta());
} else if (config->confEffCorVariables.value == "pt,mult") {
bin = hLoaded[partNo - 1]->FindBin(particle.pt(), particle.fdCollision().multV0M());
bin = hWeights->FindBin(particle.pt(), particle.fdCollision().multV0M());
} else if (config->confEffCorVariables.value == "pt,eta,mult") {
bin = hLoaded[partNo - 1]->FindBin(particle.pt(), particle.eta(), particle.fdCollision().multV0M());
bin = hWeights->FindBin(particle.pt(), particle.eta(), particle.fdCollision().multV0M());
} else {
LOGF(fatal, notify("Unknown configuration for efficiency variables"));
return weight;
}

weight = hWeights->GetBinContent(bin);
}

Expand All @@ -229,11 +228,21 @@ class EfficiencyCorrection
if (!hist) {
return true;
}
for (auto idx = 0; idx <= hist->GetNbinsX() + 1; idx++) {
if (hist->GetBinContent(idx) > 0) {
return false;

const int nBinsX = hist->GetNbinsX() + 2;
const int nBinsY = hist->GetNbinsY() + 2;
const int nBinsZ = hist->GetNbinsZ() + 2;

for (int x = 0; x < nBinsX; ++x) {
for (int y = 0; y < nBinsY; ++y) {
for (int z = 0; z < nBinsZ; ++z) {
if (hist->GetBinContent(x, y, z) != 0) {
return false;
}
}
}
}

return true;
}

Expand All @@ -247,11 +256,14 @@ class EfficiencyCorrection
}

if (isHistEmpty(hWeights)) {
LOGF(warn, notify("Histogram \"%s/%ld\" has been loaded, but it is empty"), config->confEffCorCCDBUrl.value, timestamp);
LOGF(warn, notify("Histogram \"%s/%ld\" has been loaded, but it is empty"), config->confEffCorCCDBPath.value, timestamp);
}

auto clonedHist = static_cast<H*>(hWeights->Clone());
clonedHist->SetDirectory(nullptr);

LOGF(info, notify("Successfully loaded %ld"), timestamp);
return hWeights;
return clonedHist;
}

auto getDimensionFromVariables() -> size_t
Expand All @@ -266,7 +278,7 @@ class EfficiencyCorrection
bool shouldFillHistograms{false};

o2::ccdb::BasicCCDBManager& ccdb{o2::ccdb::BasicCCDBManager::instance()};
std::array<TH1*, 2> hLoaded{};
std::array<TH1*, 2> hLoaded{nullptr, nullptr};

framework::HistogramRegistry* histRegistry{};
static constexpr std::string_view histDirectory{"EfficiencyCorrection"};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.

Check failure on line 1 in PWGCF/FemtoUniverse/Macros/calculateEfficiencyCorrection.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[name/workflow-file]

Name of a workflow file must match the name of the main struct in it (without the PWG prefix). (Class implementation files should be in "Core" directories.)
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
Expand Down Expand Up @@ -26,7 +26,7 @@
#include <cassert>
#include <cmath>
#include <filesystem> // NOLINT
#include <iostream>

Check failure on line 29 in PWGCF/FemtoUniverse/Macros/calculateEfficiencyCorrection.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[include-iostream]

Do not include iostream. Use O2 logging instead.
#include <format>
#include <string>

Expand Down Expand Up @@ -54,13 +54,13 @@
for (auto x{1}; x <= hist->GetNbinsX(); ++x) {
func(x, 0, 0);
}
} else if (hist->GetDimension() == 2) {

Check failure on line 57 in PWGCF/FemtoUniverse/Macros/calculateEfficiencyCorrection.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
for (auto x{1}; x <= hist->GetNbinsX(); ++x) {
for (auto y{1}; y <= hist->GetNbinsY(); ++y) {
func(x, y, 0);
}
}
} else if (hist->GetDimension() == 3) {

Check failure on line 63 in PWGCF/FemtoUniverse/Macros/calculateEfficiencyCorrection.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
for (auto x{1}; x <= hist->GetNbinsX(); ++x) {
for (auto y{1}; y <= hist->GetNbinsY(); ++y) {
for (auto z{1}; z <= hist->GetNbinsZ(); ++z) {
Expand All @@ -81,13 +81,13 @@

xAxis->SetTitle("#it{p}_{T} (GeV/#it{c})");

if (hist->GetDimension() == 2) {

Check failure on line 84 in PWGCF/FemtoUniverse/Macros/calculateEfficiencyCorrection.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
if (projection == "yx") {
yAxis->SetTitle("#it{#eta}");
} else if (projection == "zx") {
yAxis->SetTitle("mult");
}
} else if (hist->GetDimension() == 3) {

Check failure on line 90 in PWGCF/FemtoUniverse/Macros/calculateEfficiencyCorrection.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
yAxis->SetTitle("#it{#eta}");
zAxis->SetTitle("mult");
}
Expand Down Expand Up @@ -148,6 +148,10 @@
histWeights->Reset();
setAxisTitles(histWeights, projection);

auto* histCont{cloneHistogram(histPrimary, "hCont")};
histCont->Reset();
setAxisTitles(histCont, projection);

forEachBin(histPrimary, [&](int x, int y, int z) {
auto primVal{histPrimary->GetBinContent(x, y, z)};
auto primErr{histPrimary->GetBinError(x, y, z)};
Expand Down Expand Up @@ -178,6 +182,9 @@
contErr = std::sqrt(std::pow(secErr / totalVal, 2) + std::pow((secVal * totalErr / std::pow(totalVal, 2)), 2));
}

histCont->SetBinContent(x, y, z, contVal);
histCont->SetBinError(x, y, z, contErr);

auto weightVal{0.};
auto weightErr{0.};
if (effVal > 0) {
Expand All @@ -190,6 +197,7 @@
});

outputFile->WriteTObject(histEfficiency);
outputFile->WriteTObject(histCont);
outputFile->WriteTObject(histWeights);

outputFile->Close();
Expand Down
Loading