Belle II Software  release-08-01-10
DQMVXD_BelleII.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 import basf2 as b2
13 from simulation import add_simulation
14 from reconstruction import add_reconstruction
15 
16 import PXDROIUnpackerModule
17 
18 
19 import argparse
20 parser = argparse.ArgumentParser(
21  description="VXD DQM Belle II for Phase 2 (Exp=1), Phase 3 Early (Exp=2) and Phase 3 regular (Exp=3), show all possible histos")
22 parser.add_argument('--experiment-type', dest='ExperimentType', action='store',
23  default=2, type=int,
24  help='Set which experiment you want: 1 (Phase 2), 2 (Phase 3 Early) or 3 (Phase 3 regular), default = 2')
25 
26 args = parser.parse_args()
27 
28 print("Final setting of arguments: ")
29 print(" ExperimentType: ", args.ExperimentType)
30 
31 # background (collision) files
32 # bg = glob.glob('./BG/*.root')
33 bg = None
34 
35 # number of events to generate, can be overriden with -n
36 num_events = 100
37 # output filename, can be overriden with -o
38 output_filename = "RootOutput.root"
39 if (args.ExperimentType == 1):
40  output_filename = "RootOutput_Phase2.root"
41 if (args.ExperimentType == 2):
42  output_filename = "RootOutput_Phase3Early.root"
43 if (args.ExperimentType == 3):
44  output_filename = "RootOutput_Phase3.root"
45 
46 # create path
47 main = b2.create_path()
48 
49 if (args.ExperimentType == 1):
50  # the experiment number for phase2 MC has to be 1002, otherwise the wrong payloads (for VXDTF2 the SectorMap) are loaded
51  main.add_module("EventInfoSetter", expList=1002, runList=1, evtNumList=num_events)
52 if (args.ExperimentType == 2):
53  # the experiment number for early phase3 MC has to be 1003, otherwise the wrong payloads for this faze are loaded
54  main.add_module("EventInfoSetter", expList=1003, runList=1, evtNumList=num_events)
55 if (args.ExperimentType == 3):
56  # the experiment number for regular phase3 MC has no need to set, it is default
57  main.add_module("EventInfoSetter", evtNumList=num_events)
58 
59 # in case you need to fix seed of random numbers
60 # set_random_seed('d33fa68eab781f3dcb069fb23425885fcd92d3432e6433a14894e5d7bba34272')
61 
62 # generate BBbar events
63 main.add_module('EvtGenInput')
64 
65 # detector and L1 trigger simulation
66 add_simulation(main, bkgfiles=bg)
67 
68 
69 # PXD digitization module
70 # main.add_module('PXDDigitizer')
71 # Convert digits to raw pxd data
72 PXDPACKER = b2.register_module('PXDPacker')
73 # ============================================================================
74 # [[dhhc1, dhh1, dhh2, dhh3, dhh4, dhh5] [ ... ]]
75 # -1 is disable port
76 PXDPACKER.param('dhe_to_dhc', [
77  [0, 2, 4, 34, 36, 38],
78  [1, 6, 8, 40, 42, 44],
79  [2, 10, 12, 46, 48, 50],
80  [3, 14, 16, 52, 54, 56],
81  [4, 3, 5, 35, 37, 39],
82  [5, 7, 9, 41, 43, 45],
83  [6, 11, 13, 47, 49, 51],
84  [7, 15, 17, 53, 55, 57],
85 ])
86 main.add_module(PXDPACKER)
87 # Convert digits from raw pxd data
88 main.add_module('PXDUnpacker')
89 '''Unpack ROIs from ONSEN output'''
91 '''Unpack ROIs from HLT Payload (depends if there are in the sroot file)'''
92 # main.add_module(PXDROIUnpackerModule.PXDPayloadROIUnpackerModule())
93 
94 # reconstruction
95 add_reconstruction(main)
96 
97 # histomanager: use DqmHistoManager for in-line monitoring, or HistoManager for offline training
98 # main.add_module('DqmHistoManager', Port=7777)
99 Histos_filename = "Histos_DQMVXD.root"
100 if (args.ExperimentType == 1):
101  Histos_filename = "Histos_DQMVXD_Phase2.root"
102 if (args.ExperimentType == 2):
103  Histos_filename = "Histos_DQMVXD_Phase3Early.root"
104 if (args.ExperimentType == 3):
105  Histos_filename = "Histos_DQMVXD_Phase3.root"
106 main.add_module('HistoManager', histoFileName=Histos_filename)
107 
108 main.add_module('PXDDAQDQM', histogramDirectoryName='PXDDAQ')
109 main.add_module('PXDDQMClusters', histogramDirectoryName='PXDCls')
110 main.add_module('PXDDQMCorr', histogramDirectoryName='PXDCor')
111 main.add_module('PXDDQMEfficiency', histogramDirectoryName='PXDEff')
112 # main.add_module('PXDHardwareClusterDQM', histogramDirectoryName='PXDHCl')
113 main.add_module('PXDRawDQMChips', histogramDirectoryName='PXDRCh')
114 main.add_module('PXDRawDQMCorr', histogramDirectoryName='PXDRCo')
115 main.add_module('PXDRawDQM', histogramDirectoryName='PXDRaw')
116 main.add_module('PXDROIDQM', histogramDirectoryName='PXDROI')
117 
118 pxddqmExpReco = b2.register_module('PXDDQMExpressReco')
119 svddqmExpReco = b2.register_module('SVDDQMExpressReco')
120 vxddqmExpReco = b2.register_module('VXDDQMExpressReco')
121 
122 main.add_module(pxddqmExpReco)
123 main.add_module(svddqmExpReco)
124 main.add_module(vxddqmExpReco)
125 
126 # DQM of tracking
127 trackDQM = main.add_module('TrackDQM')
128 # In case to see more details:
129 # trackDQM = main.add_module('TrackDQM', debugLevel=250)
130 # trackDQM.logging.log_level = LogLevel.DEBUG
131 
132 # Finally add output, if you need
133 # main.add_module("RootOutput", outputFileName=output_filename)
134 
135 # process events and print call statistics
136 b2.process(main)
137 print(b2.statistics)