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