Skip to content

Commit 2effd72

Browse files
authored
QC-1105 Avoid "Unable to find object" at 2nd STOP in (Slice)TrendingTask (#2157)
Done so by proper cleanup before initializing objects in initialize(). Also, we reset the trend, so the 2nd run will start from an empty trend, just as the 1st would and should. Picking up an existing trend still is still a possibility of course.
1 parent 9e4e30a commit 2effd72

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

Framework/src/SliceTrendingTask.cxx

+11-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ void SliceTrendingTask::configure(const boost::property_tree::ptree& config)
4747

4848
void SliceTrendingTask::initialize(Trigger, framework::ServiceRegistryRef services)
4949
{
50+
// removing leftovers from any previous runs
51+
mTrend.reset();
52+
for (auto [name, object] : mPlots) {
53+
getObjectsManager()->stopPublishing(object);
54+
delete object;
55+
}
56+
mPlots.clear();
57+
mReductors.clear();
58+
mSources.clear();
59+
5060
// Prepare the data structure of the trending TTree.
5161
if (mConfig.resumeTrend) {
5262
ILOG(Info, Support) << "Trying to retrieve an existing TTree for this task to continue the trend." << ENDM;
@@ -169,7 +179,7 @@ void SliceTrendingTask::generatePlots()
169179
for (const auto& plot : mConfig.plots) {
170180
// Delete the existing plots before regenerating them.
171181
if (mPlots.count(plot.name)) {
172-
getObjectsManager()->stopPublishing(plot.name);
182+
getObjectsManager()->stopPublishing(mPlots[plot.name]);
173183
delete mPlots[plot.name];
174184
}
175185

Framework/src/TrendingTask.cxx

+10-1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@ bool TrendingTask::canContinueTrend(TTree* tree)
8080

8181
void TrendingTask::initialize(Trigger, framework::ServiceRegistryRef services)
8282
{
83+
// removing leftovers from any previous runs
84+
mTrend.reset();
85+
for (auto [name, object] : mPlots) {
86+
getObjectsManager()->stopPublishing(object);
87+
delete object;
88+
}
89+
mPlots.clear();
90+
mReductors.clear();
91+
8392
// Preparing data structure of TTree
8493
if (mConfig.resumeTrend) {
8594
ILOG(Info, Support) << "Trying to retrieve an existing TTree for this task to continue the trend." << ENDM;
@@ -208,7 +217,7 @@ void TrendingTask::generatePlots()
208217
// Before we generate any new plots, we have to delete existing under the same names.
209218
// It seems that ROOT cannot handle an existence of two canvases with a common name in the same process.
210219
if (mPlots.count(plot.name)) {
211-
getObjectsManager()->stopPublishing(plot.name);
220+
getObjectsManager()->stopPublishing(mPlots[plot.name]);
212221
delete mPlots[plot.name];
213222
}
214223

0 commit comments

Comments
 (0)