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

Remove unnecessary usage of TClass from RNTupleReader #548

Merged
merged 1 commit into from
Jan 30, 2024
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
15 changes: 5 additions & 10 deletions src/RNTupleReader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include "podio/GenericParameters.h"
#include "rootUtils.h"

#include "TClass.h"
#include <ROOT/RError.hxx>

#include <memory>

namespace podio {
Expand Down Expand Up @@ -141,15 +141,10 @@ std::unique_ptr<ROOTFrameData> RNTupleReader::readEntry(const std::string& categ
auto dentry = m_readers[category][0]->GetModel()->GetDefaultEntry();

for (size_t i = 0; i < m_collectionInfo[category].id.size(); ++i) {
const auto collectionClass = TClass::GetClass(m_collectionInfo[category].type[i].c_str());

auto collection =
std::unique_ptr<podio::CollectionBase>(static_cast<podio::CollectionBase*>(collectionClass->New()));
Copy link
Member

Choose a reason for hiding this comment

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

Was this line problematic?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, not really per se. It has just become unnecessary with the introduction of our own buffer factory. Now it was only used to get the type name basically, which we already have available otherwise.


const auto& collType = m_collectionInfo[category].type[i];
const auto& bufferFactory = podio::CollectionBufferFactory::instance();
auto maybeBuffers =
bufferFactory.createBuffers(m_collectionInfo[category].type[i], m_collectionInfo[category].schemaVersion[i],
m_collectionInfo[category].isSubsetCollection[i]);
auto maybeBuffers = bufferFactory.createBuffers(collType, m_collectionInfo[category].schemaVersion[i],
m_collectionInfo[category].isSubsetCollection[i]);
auto collBuffers = maybeBuffers.value_or(podio::CollectionReadBuffers{});

if (!maybeBuffers) {
Expand All @@ -167,7 +162,7 @@ std::unique_ptr<ROOTFrameData> RNTupleReader::readEntry(const std::string& categ
} else {
dentry->CaptureValueUnsafe(m_collectionInfo[category].name[i], collBuffers.data);

const auto relVecNames = podio::DatamodelRegistry::instance().getRelationNames(collection->getTypeName());
const auto relVecNames = podio::DatamodelRegistry::instance().getRelationNames(collType);
for (size_t j = 0; j < relVecNames.relations.size(); ++j) {
const auto relName = relVecNames.relations[j];
auto vec = new std::vector<podio::ObjectID>;
Expand Down
Loading