Default values of modules are not always converted properly by Units::convert()
I observed that when I didn't specify the parameter spatial_cut
for [TrackingSpatial]
, I would get another result compared to setting it to the same value as in the constructor (200um in this case).
For [Tracking4D]
it was set correctly to 200um.
Comparing to [Tracking4D]
I saw that in the former case the default value is set using
spatialCut = m_config.get<double>("spatial_cut", static_cast<double>(Units::convert(0.2, "mm")));
and by
spatialCut = m_config.get<double>("spatial_cut", static_cast<double>(Units::convert(200, "um")));
in the other which shouldn't make a difference of course.
On the other hand, when specifying the parameter in the config file, it is read correctly in both cases.
To demonstrate this strange behaviour, I created the branch fix_unit_conversion_of_module_default_values where the value spatialCut_nm
, spatialCut_um
and spatialCut_mm
are using the corresponding unit int Units::convert().
To run a simple example, I used:
[Corryvreckan]
log_level = "WARNING"
log_format = "DEFAULT"
output_directory = "/home/jens/software/testbeam-analysis/macros/2019-02-28/output"
detectors_file = "/home/jens/software/testbeam-analysis/macros/2019-02-28/telescope_cp2.conf"
#[Tracking4D]
[TrackingSpatial]
#spatial_cut_nm = 100um
#spatial_cut_um = 100um
#spatial_cut_mm = 100um
spatial_cut_nm = 0.1mm
spatial_cut_um = 0.1mm
spatial_cut_mm = 0.1mm
A dirty workaround would of course be to change the line in [TrackingSpatial]
to what's used in [Tracking4D]
but this might go wrong again when someone's implementing the next module.
I'll also check if the same problem happens for time (ns, us, um).