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