Skip to content
Merged
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
13 changes: 10 additions & 3 deletions tree/ntuple/src/RNTupleMetrics.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include <ROOT/RNTupleMetrics.hxx>

#include <ROOT/RError.hxx>
#include <ROOT/RField.hxx>
#include <ROOT/RLogger.hxx>
#include <ROOT/RNTupleModel.hxx>
Expand Down Expand Up @@ -138,7 +139,11 @@ ROOT::Experimental::Detail::RNTupleMetrics::~RNTupleMetrics()
if (!fIsEnabled || fExportPath.empty())
return;

ExportToRootFile();
try {
ExportToRootFile();
} catch (const RException &e) {
R__LOG_ERROR(ROOT::Internal::NTupleLog()) << "cannot export metrics: " << e.what();
}
}

void ROOT::Experimental::Detail::RNTupleMetrics::CollectCounters(
Expand Down Expand Up @@ -174,10 +179,12 @@ void ROOT::Experimental::Detail::RNTupleMetrics::ExportToRootFile()

auto model = ROOT::RNTupleModel::Create();
for (const auto &[fullyQualifiedName, counter] : counters) {
if (const auto *calc = dynamic_cast<const RNTupleCalcPerf *>(counter))
R__ASSERT(counter);
if (const auto *calc = dynamic_cast<const RNTupleCalcPerf *>(counter)) {
*model->MakeField<double>(fullyQualifiedName) = calc->GetValue();
else
} else {
*model->MakeField<std::int64_t>(fullyQualifiedName) = counter->GetValueAsInt();
}
}

TMemFile memoryFile(fNTupleName.c_str(), "RECREATE");
Expand Down
Loading