Initializing the histogram parameters (/analysis/h1/set vs. analysisManager->CreateH1)

In the radioactivedecay example, there are two ways provided to initialize the histogram parameters (e.g., nbin, vmin, vmax). One is to use analysisManager->CreateH1, and the other is to use /analysis/h1/set command. I thought they are equivalent, but they seem to be executed along different routes. Here is the observation.

  1. When I initialize the histogram using the following command and execute ‘/run/beamOn’, the vmax of the histogram are set at 1.5e6.
    analysisManager->CreateH1(1, “energy spectrum (%): e+ e-”, 100, 0, 1500, “keV”);

In this case, vmax seems to be initialized using the unit provided (keV), which makes sense.

  1. When I run the following command, the vmax is set at 1.5e3.
    /analysis/h1/set 1 150 0. 1500 keV

This probably sets the vmax using the default unit (eV). Not sure why.

Hello,

When using analysisManager->CreateH1(), the min/max values must be provide with a unit:

analysisManager->CreateH1(1, “energy spectrum (%): e+ e-”, 100, 0, 1500*keV, “keV”);

While when using UI commands, the unit is also applied to the min/max values.

This difference is intentional to be consistent with usual applying units in the Geant4 code (where units are required for all physical quantities) and commands (where a unit, if provided applies to more values when appropriate).

Best regards,

1 Like