Parameter set helper methods
Andrei has created a specialization for the fhicl::ParameterSet::get_if_present templated method that allows us to write code like:
CLHEP::Hep3Vector pos = pset.get<CLHEP::Hep3Vector>("position");
to read FHiCL written as:
position : [ -3904., 0., 10200. ]
The header and implementation are in the Mu2e GeneralUtilities library
We think that this code might be of use outside of Mu2e and propose it for inclusion into one of the libraries supported by the art team, cetlib? art?
Some other classes that could benefit from this include G4ThreeVector, CLHEP::HepLorentzVector, art::InputTag and perhaps some of the HepRotation/G4Rotation classes. I am sure there are many more that are of general use and that each experiment will find the basic technology useful for their own classes.
It's great that this sort of thing was designed into FHICLCPP.
What do the other experiments and the art team think of this proposal? We can talk about it at one of the stakeholders' meetings in early 2013.
#1 Updated by Christopher Green over 6 years ago
- Due date set to 09/30/2013
- Category set to Infrastructure
- Target version set to 1.09.00
- Estimated time set to 16.00 h
- Scope set to Internal
- Experiment - added
- SSI Package - added
We are a little leery of implementing this exactly as specified, because we are unsure of whether it is possible to break the One Definition Rule this way. We would prefer to provide the ability for a user to add to the overload set for a free function, and then implement the facility for this CLHEP object in art to avoid adding a CLHEP dependency to fhicl-cpp. That said, we believe this solution has a simple implementation.
#8 Updated by Kyle Knoepfel almost 5 years ago
- Status changed from Accepted to Resolved
- % Done changed from 0 to 100
The following statements are now supported:
// C++ code // Assumed convention (as specified in FHiCL file) //=========================================================================================== pset.get< CLHEP::Hep2Vector >(...); // vector : [ x, y ] pset.get< CLHEP::Hep3Vector >(...); // vector : [ x, y, z ] pset.get< CLHEP::HepLorentzVector >(...); // vector : [ x, y, z, t ]
as well as their corresponding
pset.get_if_present functions. To use them, the following must be present in the user's code:
Support has not been included for any of the
CLHEP::Rotation* matrix classes as the matrix classes are constructed with arguments that need to be more carefully specified and understood. Providing a simple
pset.get interface does not seem appropriate in this case.
Implemented with art:9052b3891782ad211618e2f51fc14fcb71f8384b.