Project

General

Profile

Support #23483

Problem with Source module

Added by Stefano Soleti about 1 month ago. Updated about 1 month ago.

Status:
Resolved
Priority:
Normal
Target version:
-
Start date:
10/28/2019
Due date:
% Done:

100%

Estimated time:
Scope:
Internal
Experiment:
Mu2e
SSI Package:
Co-Assignees:
Duration:

Description

Dear Art users,

I am a member of the Mu2e collaboration and I have a problem with a Source module. Basically, I have this code which decides when to move to the next file (inspired by https://github.com/Mu2e/Offline/blob/0f7502f4abb436ae4ae860033cfa42117065e4eb/Sandbox/src/Source00_source.cc)

bool CorsikaBinaryDetail::readNext(art::RunPrincipal* const& inR,
art::SubRunPrincipal /./ .* const& inSR,
art::R.unPrincipal*& outR,
art::SubRunPrincipal*& outSR,
art::EventPrincipal*& outE) {
std::unique_ptr<GenParticleCollection> particles(new GenParticleCollection());
bool still_data = (_corsikaGen.generate(*particles));
std::cout << "Still data? " << still_data << std::endl;
if (!still_data) {
return false;
}
managePrincipals(runNumber_, currentSubRunNumber_, ++currentEventNumber_, outR, outSR, outE);
art::put_product_in_principal(std::move(particles), *outE, myModuleLabel_);
return true;
}

Which should go to the next input file once it finishes to read the first one. However, when I try to run I obtain:

Still data? 1
Still data? 1
Still data? 1
END OF FILE
Still data? 0
Still data? 1

cet::exception caught in art
---- OtherArt BEGIN
---- LogicError BEGIN
readNext returned true but no RunPrincipal has been set, and no cached RunPrincipal exists.
This can happen if a new input file has been opened and the RunPrincipal has not been appropriately assigned.
---- LogicError END
---- OtherArt END
%MSG
Art has completed and will exit with status 1.

Which I don't understand because I correctly returned false when the first file ended. Could you please hlep me understand what's going on? If you are interested, the complete file is in /mu2e/app/users/srsoleti/Offline/Sources/src/FromCorsikaBinary_source.cc

The same error happens with another Source module that used to work a while ago (https://github.com/Mu2e/Offline/blob/master/Sources/src/FromExtMonFNALMARSFile_source.cc), so I assume something changed in art.

Thank you very much,
Roberto

History

#1 Updated by Stefano Soleti about 1 month ago

Error was caused by breaking change in art 2.0.6:

Change in art::Source template readNext pre-conditions

Whenever an input file is closed, the inR and inSR pointers to readNext 
are now set to null, requiring users to set outR and outSR at the first 
call to readNext after the next input file is opened.

Assigning a new outR pointer when the new file is opened solves the issue.

#2 Updated by Christopher Green about 1 month ago

  • % Done changed from 0 to 100
  • Assignee set to Christopher Green
  • Status changed from New to Resolved
  • Tracker changed from Bug to Support

We're glad you were able to resolve this problem quickly.



Also available in: Atom PDF