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