Skip to content

Commit ee4fd48

Browse files
committed
Handle case for empty ROOT file
An empty ROOT files contains no ProcessHistory which causes problems when filling the ProductRegistry at construction time. Now skip empty files until we find a file with data.
1 parent 6cbbf95 commit ee4fd48

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

IOPool/Input/src/RootFile.cc

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -563,9 +563,13 @@ namespace edm {
563563
processingOrderMerge(*processHistoryRegistry_, processingOrder);
564564
newReg->setProcessOrder(processingOrder);
565565

566-
// freeze the product registry
567-
newReg->setFrozen(inputType != InputType::Primary);
568-
productRegistry_.reset(newReg.release());
566+
if (not processingOrder.empty()) {
567+
// freeze the product registry
568+
newReg->setFrozen(inputType != InputType::Primary);
569+
productRegistry_.reset(newReg.release());
570+
} else {
571+
productRegistry_ = std::make_shared<ProductRegistry>();
572+
}
569573
}
570574

571575
// Set up information from the product registry.
@@ -626,6 +630,7 @@ namespace edm {
626630

627631
RootFile::~RootFile() {}
628632

633+
bool RootFile::empty() const { return runTree_.entries() == 0; }
629634
void RootFile::readEntryDescriptionTree(EntryDescriptionMap& entryDescriptionMap, InputType inputType) {
630635
// Called only for old format files.
631636
// We use a smart pointer so the tree will be deleted after use, and not kept for the life of the file.

IOPool/Input/src/RootFile.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ namespace edm {
155155
std::array<bool, NumBranchTypes> const& hasNewlyDroppedBranch() const { return hasNewlyDroppedBranch_; }
156156
bool branchListIndexesUnchanged() const { return branchListIndexesUnchanged_; }
157157
bool modifiedIDs() const { return daqProvenanceHelper_.get() != nullptr; }
158+
//Are there no data stored in the file?
159+
bool empty() const;
158160
std::shared_ptr<FileBlock> createFileBlock();
159161
void updateFileBlock(FileBlock&);
160162

IOPool/Input/src/RootPrimaryFileSequence.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ namespace edm {
6666
// Open the first file.
6767
for (setAtFirstFile(); !noMoreFiles(); setAtNextFile()) {
6868
initFile(input_.skipBadFiles());
69-
if (rootFile())
69+
if (rootFile() and not rootFile()->empty())
7070
break;
7171
}
7272
if (rootFile()) {

0 commit comments

Comments
 (0)