Belle II Software  release-08-01-10
dqmNeuro_SW.py
1 
8 
9 import basf2
10 import neurotrigger
11 import sys
12 import os
13 
14 
16 
17 # basf2.conditions.override_globaltags()
18 # basf2.conditions.append_globaltag('klm_alignment_testing')
19 # basf2.conditions.append_globaltag('neurotrigger') # should not be needed
20 # basf2.conditions.append_globaltag('online')
21 
22 
24 basf2.set_log_level(basf2.LogLevel.DEBUG)
25 basf2.set_debug_level(20)
26 
27 
28 
31 main = basf2.create_path()
32 
33 # Loading filelist and checking for ending: ###
34 dstfiles = [sys.argv[1]]
35 
36 ending = ".root"
37 
38 print('Files to be processed:')
39 for x in dstfiles:
40  print(x)
41 
42 # Creating output directories with the script's name: ###
43 os.makedirs(sys.argv[0].split('.py')[0] + '/data', exist_ok=True)
44 os.makedirs(sys.argv[0].split('.py')[0] + '/hist', exist_ok=True)
45 
46 # Creating filenames for dqm histogram output and root dst output: ###
47 outputfile = sys.argv[0].split('.py')[0] + '/hist/histo.' + sys.argv[1].split('/')[-1].split(ending)[0] + '.root'
48 dstputfile = sys.argv[0].split('.py')[0] + '/data/dst.' + sys.argv[1].split('/')[-1].split(ending)[0] + '.root'
49 
50 # adding root input module depending on the input file: ###
51 main.add_module("RootInput", inputFileNames=dstfiles)
52 
53 # loading gearbox and geometry, which is needed for simulation: ###
54 main.add_module('Gearbox')
55 main.add_module('Geometry')
56 
57 # show progress at least every 10^maxN events: ###
58 main.add_module('Progress', maxN=3)
59 
60 # add filter to just use events with trg information present: ###
61 main.add_module(neurotrigger.filterTRG()) # branchname="CDCTriggerNNInput2DFinderTracks"))
62 
63 # adding neurotrigger simulations for one hwsim and one swsim case: ###
64 # neurotrigger.add_neurotrigger_sim(main)
66 
67 # adding software neurotrigger simulation from CDCHits on:
68 # neurotrigger.add_neuro_simulation(main)
69 
70 # add reconstruction in case .sroot files were used: ###
71 # main.add_module('CDCUnpacker')
72 # add matcher modules to match trigger tracks to reco tracks: ###
73 
74 main.add_module('CDCTriggerRecoMatcher', TrgTrackCollectionName=neurotrigger.hwneurotracks,
75  hitCollectionName=neurotrigger.hwneuroinputsegmenthits, axialOnly=True)
76 main.add_module('CDCTriggerRecoMatcher', TrgTrackCollectionName=neurotrigger.hwsimneurotracks,
77  hitCollectionName=neurotrigger.hwneuroinputsegmenthits, axialOnly=True)
78 main.add_module('CDCTriggerRecoMatcher', TrgTrackCollectionName=neurotrigger.hwneuroinput2dfindertracks,
79  hitCollectionName=neurotrigger.hwneuroinputsegmenthits, axialOnly=True)
80 # main.add_module('CDCTriggerRecoHitMatcher', hitCollectionName=neurotrigger.simsegmenthits)
81 # main.add_module('CDCTriggerRecoMatcher', TrgTrackCollectionName=neurotrigger.simneurotracks_swtssw2d,
82 # hitCollectionName=neurotrigger.simsegmenthits, axialOnly=True)
83 main.add_module('SetupGenfitExtrapolation')
84 
85 # adding histomanager and the dqm module: ###
86 main.add_module('HistoManager',
87  histoFileName=outputfile)
88 main.add_module('CDCTriggerNeuroDQM',
89  simNeuroTracksName=neurotrigger.hwsimneurotracks,
90  unpackedNeuroInput2dTracksName=neurotrigger.hwneuroinput2dfindertracks,
91  # simNeuroTracksSWTSSW2DName=neurotrigger.simneurotracks_swtssw2d,
92  # sim2DTracksSWTSName=neurotrigger.sim2dtracks_swts,
93  # simSegmentHitsName=neurotrigger.simsegmenthits,
94  showRecoTracks=True,
95  skipWithoutHWTS=True,
96  maxRecoZDist=-1,
97  maxRecoD0Dist=-1,
98  limitedoutput=False,
99  )
100 
101 # add root output: ###
102 main.add_module('RootOutput', outputFileName=dstputfile)
103 
104 # run basf2: ###
105 basf2.process(main)
106 print(basf2.statistics)
def filterTRG(path)
Definition: neurotrigger.py:41
def add_neurotrigger_hw(path, nntweightfile=None, debug_level=4, debugout=False, **kwargs)