Belle II Software  release-08-01-10
DQMTracking_BelleII.py
1 #!/usr/bin/env python3
2 
3 
10 
11 
15 
16 import basf2 as b2
17 from simulation import add_simulation
18 from reconstruction import add_reconstruction
19 
20 import argparse
21 parser = argparse.ArgumentParser(
22  description="Tracking DQM Belle II for Phase 2 (Exp=1), Phase 3 Early (Exp=2) and Phase 3 regular (Exp=3)")
23 parser.add_argument('--experiment-type', dest='ExperimentType', action='store',
24  default=2, type=int,
25  help='Set which experiment you want: 1 (Phase 2), 2 (Phase 3 Early) or 3 (Phase 3 regular), default = 2')
26 
27 args = parser.parse_args()
28 
29 print("Final setting of arguments: ")
30 print(" ExperimentType: ", args.ExperimentType)
31 
32 # background (collision) files
33 # bg = glob.glob('./BG/*.root')
34 bg = None
35 
36 # number of events to generate, can be overriden with -n
37 num_events = 100
38 # output filename, can be overriden with -o
39 output_filename = "RootOutput.root"
40 if (args.ExperimentType == 1):
41  output_filename = "RootOutput_Phase2.root"
42 if (args.ExperimentType == 2):
43  output_filename = "RootOutput_Phase3Early.root"
44 if (args.ExperimentType == 3):
45  output_filename = "RootOutput_Phase3.root"
46 
47 # create path
48 main = b2.create_path()
49 
50 if (args.ExperimentType == 1):
51  # the experiment number for phase2 MC has to be 1002, otherwise the wrong payloads (for VXDTF2 the SectorMap) are loaded
52  main.add_module("EventInfoSetter", expList=1002, runList=1, evtNumList=num_events)
53 if (args.ExperimentType == 2):
54  # the experiment number for early phase3 MC has to be 1003, otherwise the wrong payloads for this faze are loaded
55  main.add_module("EventInfoSetter", expList=1003, runList=1, evtNumList=num_events)
56 if (args.ExperimentType == 3):
57  # the experiment number for regular phase3 MC has no need to set, it is default
58  main.add_module("EventInfoSetter", evtNumList=num_events)
59 
60 # in case you need to fix seed of random numbers
61 # set_random_seed('d33fa68eab781f3dcb069fb23425885fcd92d3432e6433a14894e5d7bba34272')
62 
63 # generate BBbar events
64 main.add_module('EvtGenInput')
65 
66 # detector and L1 trigger simulation
67 add_simulation(main, bkgfiles=bg)
68 
69 # reconstruction
70 add_reconstruction(main)
71 
72 # histomanager: use DqmHistoManager for in-line monitoring, or HistoManager for offline training
73 # main.add_module('DqmHistoManager', Port=7777)
74 Histos_filename = "Histos_DQMTracks.root"
75 if (args.ExperimentType == 1):
76  Histos_filename = "Histos_DQMTracks_Phase2.root"
77 if (args.ExperimentType == 2):
78  Histos_filename = "Histos_DQMTracks_Phase3Early.root"
79 if (args.ExperimentType == 3):
80  Histos_filename = "Histos_DQMTracks_Phase3.root"
81 main.add_module('HistoManager', histoFileName=Histos_filename)
82 
83 # DQM of tracking
84 trackDQM = main.add_module('TrackDQM', debugLevel=250)
85 # In case to see more details:
86 # trackDQM.logging.log_level = LogLevel.DEBUG
87 
88 # Finally add output, if you need
89 # main.add_module("RootOutput", outputFileName=output_filename)
90 
91 # process events and print call statistics
92 b2.process(main)
93 print(b2.statistics)