12This script determines the time spent in each part of the simulation. It does
13that by assigning regions to the geometry created by each creator and then
14measuring the time spent in these regions using the G4VSteppingVerbose
15facilities provided by Geant4. These get compiled out in the opt version of the
16externals so this only works with the debug externals. It was intended as a
17validation script but due to this problem it was moved to examples
19Generate detailed timing information of the simulation when simulating
21WARNING: Does not work in parallel processing mode
28if os.environ.get(
"BELLE2_EXTERNALS_OPTION",
"opt") !=
"debug":
29 b2.B2FATAL(
"This script needs to be run with debug externals, otherwise it "
30 "cannot determine the time spent in each volume.")
33b2.logging.log_level = b2.LogLevel.WARNING
37main = b2.create_path()
39main.add_module(
"EventInfoSetter", evtNumList=[100])
41main.add_module(
"EvtGenInput")
43main.add_module(
"Gearbox")
45main.add_module(
"Geometry", assignRegions=
True)
47main.add_module(
"FullSim")
49main.add_module(
"FullSimTiming", rootFile=
"EvtGenTiming.root", logLevel=b2.LogLevel.INFO)
55def add_info(obj, title, text):
56 """Add a description item to a TH object"""
57 obj.GetListOfFunctions().Add(ROOT.TNamed(title, text))
61root_file = ROOT.TFile(
"EvtGenTiming.root",
"UPDATE")
62timing = root_file.Get(
"SimulationTiming")
66for i
in range(timing.GetNbinsX()):
67 if timing.GetXaxis().GetBinLabel(i + 1) ==
"DefaultRegionForTheWorld":
68 timing.GetXaxis().SetBinLabel(i + 1,
"Top Volume")
71add_info(timing,
"Description",
72 "Time spent in each sub detector when simulating EvtGen events "
73 "(default settings). This includes tracking through the volume, "
74 "calculating of all physics processes and calling the sensitive "
75 "detector implementations (if any). It does not include the "
76 "overall Geant4/framework overhead (event action, generation, "
77 "stacking action, tracking action, stepping action and so forth) "
78 "<br>The errors are standard deviations of the stepping time per "
80add_info(timing,
"Check",
"Dunno, mostly for informational purpose but "
81 "large deviations might point to problematic geometry/sensitive "
83add_info(timing,
"Contact",
"ritter")