Skip to content

Commit

Permalink
Check presence of hit files before adding to TChain
Browse files Browse the repository at this point in the history
This reduces bogus error messages about missing hit files
(in particular for ZDC) and improves the handling of
setting up the hits for digitization.
  • Loading branch information
sawenzel committed Jan 9, 2025
1 parent e550484 commit 43223a4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ inline void DigitizationContext::retrieveHits(std::vector<TChain*> const& chains
int entryID,
std::vector<T>* hits) const
{
if (chains.size() <= sourceID) {
return;
}
auto br = chains[sourceID]->GetBranch(brname);
if (!br) {
LOG(error) << "No branch found with name " << brname;
Expand Down
8 changes: 8 additions & 0 deletions DataFormats/simulation/src/DigitizationContext.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ bool DigitizationContext::initSimChains(o2::detectors::DetID detid, std::vector<
return false;
}

// check that all files are present, otherwise quit
for (int source = 0; source < mSimPrefixes.size(); ++source) {
if (!std::filesystem::exists(o2::base::DetectorNameConf::getHitsFileName(detid, mSimPrefixes[source].data()))) {
LOG(info) << "Not hit file present for " << detid.getName() << " (exiting SimChain setup)";
return false;
}
}

simchains.emplace_back(new TChain("o2sim"));
// add the main (background) file
simchains.back()->AddFile(o2::base::DetectorNameConf::getHitsFileName(detid, mSimPrefixes[0].data()).c_str());
Expand Down

0 comments on commit 43223a4

Please sign in to comment.