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