Belle II Software development
DQMTracking_BelleII.py
1#!/usr/bin/env python3
2
3
10
11
15
16import basf2 as b2
17from simulation import add_simulation
18from reconstruction import add_reconstruction
19
20import argparse
21parser = argparse.ArgumentParser(
22 description="Tracking DQM Belle II for early phase 3 (Exp=1) and nominal phase 3 (Exp=2)")
23parser.add_argument('--experiment-type', dest='ExperimentType', action='store',
24 default=2, type=int,
25 help='Set which experiment you want: 1 (early phase 3) or 2 (nominal phase 3), default = 2')
26
27args = parser.parse_args()
28
29if args.ExperimentType not in [1, 2]:
30 import sys
31 print("Parameter experiment-type must be either 1 (early phase 3) "
32 f"or 2 (nominal phase 3, default), but you set {args.ExperimentType}. Exiting.")
33 sys.exit(1)
34
35# number of events to generate, can be overridden with -n
36num_events = 100
37
38# create path
39main = b2.create_path()
40
41if (args.ExperimentType == 1):
42 # the experiment number for early phase3 MC has to be 1003, otherwise the wrong payloads for this faze are loaded
43 main.add_module("EventInfoSetter", expList=1003, runList=1, evtNumList=num_events)
44elif (args.ExperimentType == 2):
45 # the experiment number for nominal phase3 MC has no need to set, it is default
46 main.add_module("EventInfoSetter", evtNumList=num_events)
47
48# Set a random seed to ensure reproducibility
49b2.set_random_seed('some_seed')
50
51# generate BBbar events
52main.add_module('EvtGenInput')
53
54# detector and L1 trigger simulation
55add_simulation(main, bkgfiles=None)
56
57# reconstruction
58add_reconstruction(main)
59
60# histomanager: use DqmHistoManager for in-line monitoring, or HistoManager for offline training
61# main.add_module('DqmHistoManager', Port=7777)
62Histos_filename = ""
63if (args.ExperimentType == 1):
64 Histos_filename = "Histos_DQMTracks_Phase3Early.root"
65elif (args.ExperimentType == 2):
66 Histos_filename = "Histos_DQMTracks_Phase3.root"
67main.add_module('HistoManager', histoFileName=Histos_filename)
68
69# DQM of tracking
70trackDQM = main.add_module('TrackDQM', debugLevel=250)
71# In case to see more details:
72# trackDQM.logging.log_level = LogLevel.DEBUG
73
74# output filename, can be overridden with -o
75output_filename = ""
76if (args.ExperimentType == 1):
77 output_filename = "RootOutput_Phase3Early.root"
78elif (args.ExperimentType == 2):
79 output_filename = "RootOutput_Phase3.root"
80main.add_module("RootOutput", outputFileName=output_filename)
81
82main.add_module('Progress')
83
84# process events and print call statistics
85b2.process(main)
86print(b2.statistics)