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