Skip to content

Allow default construction and delayed initialisation of HistogramWrapper instances

Built on top of !1646 (merged) and !1641 (merged) so they should be merged first.

A fairly commonly used pattern in the LHCb stack is to wrap histogram instances inside an std::option<T> in order to allow for delayed initialisation of the histogram, for instance during the algorithm initialize() method when more information about the algorithm runtime configuration is known.

However, the HistogramWrapper class already uses an std::optional internally around the actual hsitogram instance, so has most of what is needed to handle delayed initialisation itself, without the need for an additional std::optional layer on top. This MR just does a minor refactoring of the code to allow users to do this.

  1. A default constructor is allowed.
  2. Initialisation is moved to new public initialize() methods, which share the same API as the constructors (which now just call these internally)

with this, I was able to simplify things on the LHCb(RICH) side removing the additional optional layer.

FYI @sponce

Could this please, if you agree be added to the lhcb-gaudi-head slot and also if agreed its OK could it be included in the up coming Gaudi v39r1 ? I would very much like to take advantage of this on the LHCb side if I can.

Edited by Christopher Rob Jones

Merge request reports

Loading