Skip to content

Commit 006907c

Browse files
committed
Protect CTF reader against empty trees
1 parent e44b773 commit 006907c

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

Detectors/CTF/workflow/src/CTFReaderSpec.cxx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,14 @@ void CTFReaderSpec::openCTFFile(const std::string& flname)
167167
mFilesRead++;
168168
mCTFFile.reset(TFile::Open(flname.c_str()));
169169
if (!mCTFFile || !mCTFFile->IsOpen() || mCTFFile->IsZombie()) {
170-
throw std::runtime_error("failed to open CTF file");
170+
throw std::runtime_error(fmt::format("failed to open CTF file {}, skipping", flname));
171171
}
172172
mCTFTree.reset((TTree*)mCTFFile->Get(std::string(o2::base::NameConf::CTFTREENAME).c_str()));
173173
if (!mCTFTree) {
174-
throw std::runtime_error("failed to load CTF tree from");
174+
throw std::runtime_error(fmt::format("failed to load CTF tree from {}, skipping", flname));
175+
}
176+
if (mCTFTree->GetEntries() < 1) {
177+
throw std::runtime_error(fmt::format("CTF tree in {} has 0 entries, skipping", flname));
175178
}
176179
} catch (const std::exception& e) {
177180
LOG(error) << "Cannot process " << flname << ", reason: " << e.what();

0 commit comments

Comments
 (0)