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

QC-1105 Avoid "Unable to find object" at 2nd STOP in (Slice)TrendingTask #2157

Merged
merged 1 commit into from
Feb 28, 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
12 changes: 11 additions & 1 deletion Framework/src/SliceTrendingTask.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ void SliceTrendingTask::configure(const boost::property_tree::ptree& config)

void SliceTrendingTask::initialize(Trigger, framework::ServiceRegistryRef services)
{
// removing leftovers from any previous runs
mTrend.reset();
for (auto [name, object] : mPlots) {
getObjectsManager()->stopPublishing(object);
delete object;
}
mPlots.clear();
mReductors.clear();
mSources.clear();

// Prepare the data structure of the trending TTree.
if (mConfig.resumeTrend) {
ILOG(Info, Support) << "Trying to retrieve an existing TTree for this task to continue the trend." << ENDM;
Expand Down Expand Up @@ -169,7 +179,7 @@ void SliceTrendingTask::generatePlots()
for (const auto& plot : mConfig.plots) {
// Delete the existing plots before regenerating them.
if (mPlots.count(plot.name)) {
getObjectsManager()->stopPublishing(plot.name);
getObjectsManager()->stopPublishing(mPlots[plot.name]);
delete mPlots[plot.name];
}

Expand Down
11 changes: 10 additions & 1 deletion Framework/src/TrendingTask.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ bool TrendingTask::canContinueTrend(TTree* tree)

void TrendingTask::initialize(Trigger, framework::ServiceRegistryRef services)
{
// removing leftovers from any previous runs
mTrend.reset();
for (auto [name, object] : mPlots) {
getObjectsManager()->stopPublishing(object);
delete object;
}
mPlots.clear();
mReductors.clear();

// Preparing data structure of TTree
if (mConfig.resumeTrend) {
ILOG(Info, Support) << "Trying to retrieve an existing TTree for this task to continue the trend." << ENDM;
Expand Down Expand Up @@ -208,7 +217,7 @@ void TrendingTask::generatePlots()
// Before we generate any new plots, we have to delete existing under the same names.
// It seems that ROOT cannot handle an existence of two canvases with a common name in the same process.
if (mPlots.count(plot.name)) {
getObjectsManager()->stopPublishing(plot.name);
getObjectsManager()->stopPublishing(mPlots[plot.name]);
delete mPlots[plot.name];
}

Expand Down
Loading