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