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