Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GLO: fix memory leak #2337

Merged
merged 2 commits into from
Jun 14, 2024
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
10 changes: 8 additions & 2 deletions Modules/GLO/include/GLO/ITSTPCMatchingTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
#include "QualityControl/TaskInterface.h"
#include "GlobalTracking/MatchITSTPCQC.h"

class TH1F;
#include "TH1.h"

#include <memory>

using namespace o2::quality_control::core;

Expand All @@ -35,7 +37,7 @@ class ITSTPCMatchingTask final : public TaskInterface
/// \brief Constructor
ITSTPCMatchingTask() = default;
/// Destructor
~ITSTPCMatchingTask() override;
~ITSTPCMatchingTask() override = default;

// Definition of the methods for the template method pattern
void initialize(o2::framework::InitContext& ctx) override;
Expand All @@ -48,6 +50,10 @@ class ITSTPCMatchingTask final : public TaskInterface

private:
o2::globaltracking::MatchITSTPCQC mMatchITSTPCQC;

std::unique_ptr<TH1> mHEffPt;
std::unique_ptr<TH1> mHEffEta;
std::unique_ptr<TH1> mHEffPhi;
};

} // namespace o2::quality_control_modules::glo
Expand Down
36 changes: 19 additions & 17 deletions Modules/GLO/src/ITSTPCMatchingTask.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ using matchType = o2::globaltracking::MatchITSTPCQC::matchType;
namespace o2::quality_control_modules::glo
{

ITSTPCMatchingTask::~ITSTPCMatchingTask()
{
// mMatchITSTPCQC.deleteHistograms();
}
void ITSTPCMatchingTask::initialize(o2::framework::InitContext& /*ctx*/)
{
ILOG(Debug, Devel) << "initialize ITSTPCMatchingTask" << ENDM; // QcInfoLogger is used. FairMQ logs will go to there as well.
Expand Down Expand Up @@ -132,33 +128,39 @@ void ITSTPCMatchingTask::endOfCycle()
if (common::getFromConfig(mCustomParameters, "isSync", false)) {
{ // Pt
auto hEffPt = mMatchITSTPCQC.getFractionITSTPCmatch(globaltracking::MatchITSTPCQC::ITS);
if (auto hEffPtHist = dynamic_cast<TH1*>(hEffPt->GetPassedHistogram()->Clone("mFractionITSTPCmatch_ITS_Hist")); hEffPtHist != nullptr) {
hEffPtHist->Divide(hEffPt->GetPassedHistogram(), hEffPt->GetTotalHistogram(), 1.0, 1.0, "B");
hEffPtHist->SetBit(TH1::EStatusBits::kNoStats);
getObjectsManager()->startPublishing(hEffPtHist);
getObjectsManager()->setDefaultDrawOptions(hEffPtHist->GetName(), "logx");
mHEffPt.reset();
mHEffPt.reset(dynamic_cast<TH1*>(hEffPt->GetPassedHistogram()->Clone("mFractionITSTPCmatch_ITS_Hist")));
f3sch marked this conversation as resolved.
Show resolved Hide resolved
if (mHEffPt) {
mHEffPt->Divide(hEffPt->GetPassedHistogram(), hEffPt->GetTotalHistogram(), 1.0, 1.0, "B");
mHEffPt->SetBit(TH1::EStatusBits::kNoStats);
getObjectsManager()->startPublishing(mHEffPt.get(), PublicationPolicy::Once);
getObjectsManager()->setDefaultDrawOptions(mHEffPt->GetName(), "logx");
} else {
ILOG(Error) << "Failed cast for hEffPtHist, will not publish!" << ENDM;
}
}

{ // Eta
auto hEffEta = mMatchITSTPCQC.getFractionITSTPCmatchEta(globaltracking::MatchITSTPCQC::ITS);
if (auto hEffEtaHist = dynamic_cast<TH1*>(hEffEta->GetPassedHistogram()->Clone("mFractionITSTPCmatchEta_ITS_Hist")); hEffEtaHist != nullptr) {
hEffEtaHist->Divide(hEffEta->GetPassedHistogram(), hEffEta->GetTotalHistogram(), 1.0, 1.0, "B");
hEffEtaHist->SetBit(TH1::EStatusBits::kNoStats);
getObjectsManager()->startPublishing(hEffEtaHist);
mHEffEta.reset();
mHEffEta.reset(dynamic_cast<TH1*>(hEffEta->GetPassedHistogram()->Clone("mFractionITSTPCmatchEta_ITS_Hist")));
if (mHEffEta) {
mHEffEta->Divide(hEffEta->GetPassedHistogram(), hEffEta->GetTotalHistogram(), 1.0, 1.0, "B");
mHEffEta->SetBit(TH1::EStatusBits::kNoStats);
getObjectsManager()->startPublishing(mHEffEta.get(), PublicationPolicy::Once);
} else {
ILOG(Error) << "Failed cast for hEffEtaHist, will not publish!" << ENDM;
}
}

{ // Phi
auto hEffPhi = mMatchITSTPCQC.getFractionITSTPCmatchPhi(globaltracking::MatchITSTPCQC::ITS);
if (auto hEffPhiHist = dynamic_cast<TH1*>(hEffPhi->GetPassedHistogram()->Clone("mFractionITSTPCmatchPhi_ITS_Hist")); hEffPhiHist != nullptr) {
hEffPhiHist->Divide(hEffPhi->GetPassedHistogram(), hEffPhi->GetTotalHistogram(), 1.0, 1.0, "B");
hEffPhiHist->SetBit(TH1::EStatusBits::kNoStats);
getObjectsManager()->startPublishing(hEffPhiHist);
mHEffPhi.reset();
mHEffPhi.reset(dynamic_cast<TH1*>(hEffPhi->GetPassedHistogram()->Clone("mFractionITSTPCmatchPhi_ITS_Hist")));
if (mHEffPhi) {
mHEffPhi->Divide(hEffPhi->GetPassedHistogram(), hEffPhi->GetTotalHistogram(), 1.0, 1.0, "B");
mHEffPhi->SetBit(TH1::EStatusBits::kNoStats);
getObjectsManager()->startPublishing(mHEffPhi.get(), PublicationPolicy::Once);
} else {
ILOG(Error) << "Failed cast for hEffPhiHist, will not publish!" << ENDM;
}
Expand Down
Loading