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
3 changes: 3 additions & 0 deletions Framework/include/QualityControl/MonitorObjectCollection.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ class MonitorObjectCollection : public TObjArray, public mergers::MergeInterface
~MonitorObjectCollection() = default;

void merge(mergers::MergeInterface* const other) override;

void postDeserialization() override;

ClassDefOverride(MonitorObjectCollection, 0);
};

Expand Down
7 changes: 4 additions & 3 deletions Framework/src/CheckRunner.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,12 @@ void CheckRunner::prepareCacheData(framework::InputRecord& inputRecord)

// We don't know what we receive, so we test for an array and then try a tobject.
// If we received a tobject, it gets encapsulated in the tobjarray.
shared_ptr<const TObjArray> array = nullptr;
shared_ptr<const TObject> tobj = inputRecord.get<TObject*>(input.binding.c_str());
shared_ptr<TObjArray> array = nullptr;
auto tobj = DataRefUtils::as<TObject>(dataRef);
// if the object has not been found, it will raise an exception that we just let go.
if (tobj->InheritsFrom("TObjArray")) {
array = dynamic_pointer_cast<const TObjArray>(tobj);
array.reset(dynamic_cast<TObjArray*>(tobj.release()));
array->SetOwner(false);
mLogger << AliceO2::InfoLogger::InfoLogger::Info << "CheckRunner " << mDeviceName
<< " received an array with " << array->GetEntries()
<< " entries from " << input.binding << ENDM;
Expand Down
21 changes: 20 additions & 1 deletion Framework/src/MonitorObjectCollection.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
///

#include "QualityControl/MonitorObjectCollection.h"

#include "QualityControl/MonitorObject.h"
#include "QualityControl/QcInfoLogger.h"

#include <Mergers/MergerAlgorithm.h>

Expand Down Expand Up @@ -51,4 +51,23 @@ void MonitorObjectCollection::merge(mergers::MergeInterface* const other)
delete otherIterator;
}

void MonitorObjectCollection::postDeserialization()
{
auto it = this->MakeIterator();
while (auto obj = it->Next()) {
auto mo = dynamic_cast<MonitorObject*>(obj);
if (mo == nullptr) {
ILOG(Warning) << "Could not cast an object of type '" << obj->ClassName() << "' in MonitorObjectCollection to MonitorObject, skipping." << ENDM;
continue;
}
mo->setIsOwner(true);
if (mo->getObject() != nullptr && mo->getObject()->InheritsFrom(TCollection::Class())) {
auto collection = dynamic_cast<TCollection*>(mo->getObject());
collection->SetOwner(true);
}
}
this->SetOwner(true);
delete it;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ROOT objects ownership at its best.


} // namespace o2::quality_control::core
2 changes: 1 addition & 1 deletion Framework/src/ObjectsManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ ObjectsManager::~ObjectsManager() = default;

void ObjectsManager::startPublishing(TObject* object)
{
if (mMonitorObjects->FindObject(object->GetName()) != 0) {
if (mMonitorObjects->FindObject(object->GetName()) != nullptr) {
ILOG(Warning, Support) << "Object is already being published (" << object->GetName() << ")" << ENDM;
BOOST_THROW_EXCEPTION(DuplicateObjectError() << errinfo_object_name(object->GetName()));
}
Expand Down