Skip to content
Snippets Groups Projects
Commit bfcd018f authored by Dominik Smith's avatar Dominik Smith Committed by Florian Uhlig
Browse files

Added protection against out-of-sequence timeslice reading to...

Added protection against out-of-sequence timeslice reading to CbmSourceTs::ReadEvent(). This is not supported but could previously be requested by the user, leading to unexpected behavior.
parent 689e844e
No related branches found
No related tags found
1 merge request!931Bugfix: Protection against out-of-sequence timeslice reading in CbmSourceTs.
Pipeline #19154 passed
...@@ -50,24 +50,40 @@ Bool_t CbmSourceTs::Init() ...@@ -50,24 +50,40 @@ Bool_t CbmSourceTs::Init()
// ----- Read one time slice from archive --------------------------------- // ----- Read one time slice from archive ---------------------------------
Int_t CbmSourceTs::ReadEvent(UInt_t) Int_t CbmSourceTs::ReadEvent(UInt_t tsIndex)
{ {
// Timeslices can only be read sequentially, so the argument is ignored. // Timeslices can only be read sequentially.
// It appears that the first call to this method from FairRunOnline is in the // It appears that the first call to this method from FairRunOnline is in the
// init stage. In order not to always lose the first timeslice, a call to // init stage. In order not to always lose the first timeslice, a call to
// TimesliceSource::get is avoided in the first call. // TimesliceSource::get is avoided in the first call.
if (fNumCalls == 0) LOG(info) << "SourceTs: Init call to ReadEvent"; if (fNumCalls == 0) {
LOG(info) << "SourceTs: Init call to ReadEvent";
fNumCalls++;
}
else if (tsIndex > 0 && tsIndex < fNumCalls - 1) {
LOG(error) << "SourceTs: Out-of-sequence reading of timeslices not supported.";
return 1;
}
else { else {
fFlesTs = nullptr; do {
fFlesTs = fFlesSource->get(); fFlesTs = nullptr;
if (!fFlesTs) { fFlesTs = fFlesSource->get();
LOG(info) << "SourceTs: End of archive reached; stopping run."; if (!fFlesTs) {
return 1; LOG(info) << "SourceTs: End of archive reached; stopping run.";
} return 1;
LOG(info) << "SourceTs: Reading time slice " << GetNumTs() << " (index " << fFlesTs->index() }
<< ") at t = " << fFlesTs->start_time() << " ns"; if (tsIndex == fNumCalls - 1) {
LOG(info) << "SourceTs: Reading time slice " << GetNumTs() << " (index " << fFlesTs->index()
<< ") at t = " << fFlesTs->start_time() << " ns";
}
else {
LOG(info) << "SourceTs: Skipping time slice " << GetNumTs() << " (index " << fFlesTs->index()
<< ") at t = " << fFlesTs->start_time() << " ns";
LOG(info) << "(TS is still fetched from disk, this may take some time)";
}
fNumCalls++;
} while (tsIndex >= fNumCalls - 1);
} }
fNumCalls++;
return 0; return 0;
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment