Skip to content

Commit

Permalink
GLO: fix memory leak (#2337)
Browse files Browse the repository at this point in the history
* GLO: fix memory leak

Signed-off-by: Felix Schlepper <felix.schlepper@cern.ch>

* GLO:  avoid having two histos same time

Signed-off-by: Felix Schlepper <felix.schlepper@cern.ch>

---------

Signed-off-by: Felix Schlepper <felix.schlepper@cern.ch>
  • Loading branch information
f3sch committed Jun 14, 2024
1 parent dbcc1ca commit a03bfa5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 19 deletions.
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")));
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

0 comments on commit a03bfa5

Please sign in to comment.