Belle II Software  release-08-01-10
independent_merge_path_real.py
1 #!/usr/bin/env python3
2 
3 
10 
11 # @cond
12 
13 import basf2
14 
15 main = basf2.Path()
16 indep = basf2.Path()
17 
18 # input (if you're doing signal embedding, this should be the ROE from data)
19 input1 = basf2.register_module('RootInput')
20 input1.param('inputFileName', basf2.find_file('embedding_jpsi_exp12_skim.root', 'examples'))
21 main.add_module(input1).set_name("--input_main--")
22 
23 # and the other input (if you're doing signal embedding, this should be the signal from MC)
24 input2 = basf2.register_module('RootInput')
25 input2.param('inputFileName', basf2.find_file('embedding_kplusnunu_mcsig_skim.root', 'examples'))
26 input2.param('isSecondaryInput', True) # <- set flag for secondary input module
27 indep.add_module(input2).set_name("input_indep")
28 
29 # merge it!
30 # Use merge_back_event=['ALL'] to merge everything
31 # or specify explicitly merge_back_event=['EventMetaData', 'ECLClusters', 'Tracks', 'TracksToECLClusters']
32 # NOTE: StoreArrays have to be merged before their Relations (and 'EventMetaData' is strictly required!)
33 # NOTE: Also merge 'EventExtraInfo' if you want to do a consistency_check
34 main.add_independent_merge_path(
35  indep,
36  # <- skip event if charge of ROE/sig (or ROE/ROE) does not match [None or "" if you don't want to do this]
37  consistency_check="charge",
38  merge_back_event=['ALL'], # <- list of content to be merged
39  event_mixing=False, # <- signal embedding or event mixing
40  merge_same_file=False # <- for event mixing, you can mix a file with itself
41 )
42 
43 main.add_module('FixMergedObjects')
44 
45 # output
46 output = basf2.register_module('RootOutput')
47 output.param('outputFileName', 'merged_10evts.root')
48 main.add_module(output)
49 
50 # progress
51 main.add_module('Progress')
52 
53 basf2.print_path(main)
54 basf2.process(main)
55 
56 print(basf2.statistics)
57 
58 # @endcond