Belle II Software  release-08-01-10
runOverlay.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 
22 
23 import sys
24 import basf2 as b2
25 import svd.overlay_utils as svdou
26 import simulation as simu
27 import glob
28 
29 tag = "unused"
30 if len(sys.argv) == 2:
31  tag = sys.argv[1]
32 
33 '''
34 # PREPARE YOUR INPUT FILES - ERROR printed at the end does not
35 # affect output files
36 # function provides output rootfile with SVDShaperDigits only
37 
38 # random TRG
39 # 1. link the input raw data in /gpfs/fs02/belle2/group/detector/SVD/overlayFiles/randomTRG/
40 # and select:
41 # location="/gpfs/fs02/belle2/group/detector/SVD/overlayFiles/randomTRG/*.root"
42 # and outputFileTag = ZS3
43 # 2. then select:
44 # location="/gpfs/fs02/belle2/group/detector/SVD/overlayFiles/randomTRG/*_ZS3.root"
45 # and outputFileTag = overlay
46 # and outputFileTag = overlayZS with same location
47 
48 filelist=glob.glob(location)
49 # print(filelist)
50 for inputfile in filelist:
51  main = b2.create_path()
52 # svdou.prepare_svd_overlay(main, [inputfile],"ZS3")
53  svdou.prepare_svd_overlay(main, [inputfile],"overlay")
54 # svdou.prepare_svd_overlay(main, [inputfile],"overlayZS5")
55 '''
56 
57 # EXAMPLE OF OVERLAY
58 main = b2.create_path()
59 
60 b2.set_random_seed(1)
61 
62 # set the exp/run event informations
63 eventinfosetter = b2.register_module('EventInfoSetter')
64 eventinfosetter.param('expList', [0])
65 eventinfosetter.param('runList', [1])
66 eventinfosetter.param('evtNumList', [10])
67 main.add_module(eventinfosetter)
68 
69 # register HistoModules for DQM plots
70 main.add_module("HistoManager", histoFileName="SVDDQMOutput_"+str(tag)+".root")
71 
72 # generate signal
73 main.add_module('EvtGenInput')
74 
75 # add default simulation
76 bkgDir = '/group/belle2/BGFile/OfficialBKG/early_phase3/prerelease-04-00-00a/overlay/phase31/BGx1/set0/*.root'
77 bg = glob.glob(bkgDir)
78 if len(bg) == 0:
79  b2.B2ERROR('No files found in ', bkgDir)
80  sys.exit()
81 simu.add_simulation(main, bkgfiles=bg, usePXDDataReduction=False, forceSetPXDDataReduction=True)
82 
83 if str(tag) == "xTalk" or str(tag) == "cosmics" or str(tag) == "randomTrigger" or str(tag) == "randomTriggerZS5":
84  svdou.overlay_svd_data(main, str(tag))
85 
86 
87 # add offline ZS for DQM
88 main.add_module(
89  'SVDZeroSuppressionEmulator',
90  SNthreshold=5,
91  ShaperDigits='SVDShaperDigits',
92  ShaperDigitsIN='SVDShaperDigitsZS5',
93  FADCmode=True)
94 main.add_module('SVDDQMExpressReco', offlineZSShaperDigits='SVDShaperDigitsZS5')
95 
96 main.add_module('Progress')
97 
98 b2.print_path(main)
99 
100 b2.process(main)
101 
102 print(b2.statistics)