Skip to content

Commit 43223a4

Browse files
committed
Check presence of hit files before adding to TChain
This reduces bogus error messages about missing hit files (in particular for ZDC) and improves the handling of setting up the hits for digitization.
1 parent e550484 commit 43223a4

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

DataFormats/simulation/include/SimulationDataFormat/DigitizationContext.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@ inline void DigitizationContext::retrieveHits(std::vector<TChain*> const& chains
209209
int entryID,
210210
std::vector<T>* hits) const
211211
{
212+
if (chains.size() <= sourceID) {
213+
return;
214+
}
212215
auto br = chains[sourceID]->GetBranch(brname);
213216
if (!br) {
214217
LOG(error) << "No branch found with name " << brname;

DataFormats/simulation/src/DigitizationContext.cxx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ bool DigitizationContext::initSimChains(o2::detectors::DetID detid, std::vector<
9999
return false;
100100
}
101101

102+
// check that all files are present, otherwise quit
103+
for (int source = 0; source < mSimPrefixes.size(); ++source) {
104+
if (!std::filesystem::exists(o2::base::DetectorNameConf::getHitsFileName(detid, mSimPrefixes[source].data()))) {
105+
LOG(info) << "Not hit file present for " << detid.getName() << " (exiting SimChain setup)";
106+
return false;
107+
}
108+
}
109+
102110
simchains.emplace_back(new TChain("o2sim"));
103111
// add the main (background) file
104112
simchains.back()->AddFile(o2::base::DetectorNameConf::getHitsFileName(detid, mSimPrefixes[0].data()).c_str());

0 commit comments

Comments
 (0)