Specializations for fhicl::get_if_present seem to have stopped working
A long time ago Mu2e wrote template specializations for fhicl::get_if_present . Among other things they allowed us to do the following:
In the fhicl:
offset : [ 1., 2., 3. ]
and in the code:
CLHEP::Hep3Vector offset = pset.get<CLHEP::Hep3Vector>("offset");
where pset is a fhicl parameter set. This seems to have stopped working. The error is:
%MSG %MSG-s ArtException: HelloWorld:hello@Construction 24-Oct-2019 10:40:03 CDT ModuleConstruction cet::exception caught in art ---- Type mismatch BEGIN Unsuccessful attempt to convert FHiCL parameter 'v' to type 'CLHEP::Hep3Vector'. [Specific error:] bad any_cast ---- Type mismatch END %MSG Art has completed and will exit with status 65.
An example the reproduces the problem is on the Mu2e interactive machines in
/nashome/k/kutschke/Mu2e/Bugs/Custom_fhicl HelloWorld/src/HelloWorld_module.cc HelloWorld/fcl/hello.fcl
The source for the template specializations is found in mu2e Offline in:
We using art v3_03_01
#4 Updated by Rob Kutschke 3 months ago
FYI: At Chris' request, I ran my test against a handful of different version of Mu2e Offline going to back to Offline v6_3_2, which uses art v2_07_03. All failed with the same error message. All of our earlier builds on cvmfs require a SLF6 test machine which we no longer have. If someone can point me to an SLF6 machine that mounts the /cvmfs/mu2e.opensciencegrid.org/ I can go farther back.
#6 Updated by Christopher Green 3 months ago
- Status changed from Assigned to Feedback
- Tracker changed from Bug to Support
HelloWorld_module.cc to which you refer here does not include
GeneralUtilities/inc/ParameterSetHelpers.hh, and it is not pulled in indirectly. It is important that the compiler sees the template definition first, followed by the declaration of any specializations, before any code which would trigger the instantiation of the template for the specified type. Otherwise, the default template instantiation will be triggered, which in this case would give exactly the error you see.
Please try again with the appropriate include inserted, and let me know if the problem is resolved for you.