Skip to content

Commit

Permalink
Update changes after the changes in the collectionID and string_view
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcarcell committed Jun 27, 2023
1 parent f34ebc7 commit 659e051
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion include/podio/ROOTNTupleReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class ROOTNTupleReader {
std::unordered_map<std::string, unsigned> m_totalEntries{};

struct CollectionInfo {
std::vector<int> id{};
std::vector<unsigned int> id{};
std::vector<std::string> name{};
std::vector<std::string> type{};
std::vector<short> isSubsetCollection{};
Expand Down
2 changes: 1 addition & 1 deletion include/podio/ROOTNTupleWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ROOTNTupleWriter {
DatamodelDefinitionCollector m_datamodelCollector{};

struct CollectionInfo {
std::vector<int> id{};
std::vector<unsigned int> id{};
std::vector<std::string> name{};
std::vector<std::string> type{};
std::vector<short> isSubsetCollection{};
Expand Down
7 changes: 4 additions & 3 deletions src/ROOTNTupleReader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ bool ROOTNTupleReader::initCategory(const std::string& category) {
// Assume that the metadata is the same in all files
auto filename = m_filenames[0];

auto id = m_metadata_readers[filename]->GetView<std::vector<int>>(root_utils::idTableName(category));
auto id = m_metadata_readers[filename]->GetView<std::vector<unsigned int>>(root_utils::idTableName(category));
m_collectionInfo[category].id = id(0);

auto collectionName =
Expand Down Expand Up @@ -136,9 +136,10 @@ std::unique_ptr<ROOTFrameData> ROOTNTupleReader::readEntry(const std::string& ca
auto collection =
std::unique_ptr<podio::CollectionBase>(static_cast<podio::CollectionBase*>(collectionClass->New()));

const std::string bufferClassName = "std::vector<" + collection->getDataTypeName() + ">";
// const std::string bufferClassName = "std::vector<" + collection->getDataTypeName() + ">";
const auto bufferClassName = collection->getTypeName();
const auto bufferClass =
m_collectionInfo[category].isSubsetCollection[i] ? nullptr : TClass::GetClass(bufferClassName.c_str());
m_collectionInfo[category].isSubsetCollection[i] ? nullptr : TClass::GetClass(std::string(bufferClassName).c_str());

const bool isSubsetColl = bufferClass == nullptr;

Expand Down
4 changes: 2 additions & 2 deletions src/ROOTNTupleWriter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ ROOTNTupleWriter::createModels(const std::vector<StoreCollection>& collections)
const auto collBuffers = coll->getBuffers();

if (collBuffers.vecPtr) {
auto collClassName = "std::vector<" + coll->getDataTypeName() + ">";
auto collClassName = "std::vector<" + std::string(coll->getDataTypeName()) + ">";
auto field = ROOT::Experimental::Detail::RFieldBase::Create(name, collClassName).Unwrap();
model->AddField(std::move(field));
}
Expand Down Expand Up @@ -202,7 +202,7 @@ void ROOTNTupleWriter::finish() {
}

for (auto& category : m_categories) {
auto idField = m_metadata->MakeField<std::vector<int>>({root_utils::idTableName(category)});
auto idField = m_metadata->MakeField<std::vector<unsigned int>>({root_utils::idTableName(category)});
*idField = m_collectionInfo[category].id;
auto collectionNameField = m_metadata->MakeField<std::vector<std::string>>({root_utils::collectionName(category)});
*collectionNameField = m_collectionInfo[category].name;
Expand Down

0 comments on commit 659e051

Please sign in to comment.