Skip to content

Commit b24478c

Browse files
committed
Keep thte ROOTReader functional for older versions
1 parent 59bbb45 commit b24478c

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

src/ROOTReader.cc

+24-11
Original file line numberDiff line numberDiff line change
@@ -170,19 +170,32 @@ void ROOTReader::initCategory(CategoryInfo& catInfo, const std::string& category
170170
auto* collInfoBranch = root_utils::getBranch(m_metaChain.get(), root_utils::collInfoName(category));
171171

172172
auto collInfo = new std::vector<root_utils::CollectionWriteInfo>();
173-
if (m_fileVersion < podio::version::Version{0, 16, 4}) {
174-
auto oldCollInfo = new std::vector<root_utils::CollectionInfoWithoutSchemaT>();
175-
collInfoBranch->SetAddress(&oldCollInfo);
176-
collInfoBranch->GetEntry(0);
177-
collInfo->reserve(oldCollInfo->size());
178-
for (auto&& [collID, collType, isSubsetColl] : *oldCollInfo) {
179-
// Manually set the schema version to 1
180-
collInfo->emplace_back(collID, std::move(collType), isSubsetColl, 1u);
181-
}
182-
delete oldCollInfo;
183-
} else {
173+
174+
if (m_fileVersion >= podio::version::Version{1, 1, 0}) {
184175
collInfoBranch->SetAddress(&collInfo);
185176
collInfoBranch->GetEntry(0);
177+
} else {
178+
auto collInfoOld = new std::vector<root_utils::CollectionWriteInfoT>();
179+
if (m_fileVersion < podio::version::Version{0, 16, 4}) {
180+
auto collInfoReallyOld = new std::vector<root_utils::CollectionInfoWithoutSchemaT>();
181+
collInfoBranch->SetAddress(&collInfoReallyOld);
182+
collInfoBranch->GetEntry(0);
183+
collInfoOld->reserve(collInfoReallyOld->size());
184+
for (auto& [collID, collType, isSubsetColl] : *collInfoReallyOld) {
185+
// Manually set the schema version to 1
186+
collInfo->emplace_back(collID, std::move(collType), isSubsetColl, 1u);
187+
}
188+
delete collInfoReallyOld;
189+
} else {
190+
collInfoBranch->SetAddress(&collInfoOld);
191+
collInfoBranch->GetEntry(0);
192+
}
193+
// "Convert" to new style
194+
collInfo->reserve(collInfoOld->size());
195+
for (auto& [id, typeName, isSubsetColl, schemaVersion] : *collInfoOld) {
196+
collInfo->emplace_back(id, std::move(typeName), isSubsetColl, schemaVersion);
197+
}
198+
delete collInfoOld;
186199
}
187200

188201
// For backwards compatibility make it possible to read the index based files

0 commit comments

Comments
 (0)