Belle II Software development
independent_merge_path_real.py
1#!/usr/bin/env python3
2
3
10
11# @cond
12
13import basf2
14
15main = basf2.Path()
16indep = basf2.Path()
17
18# input (if you're doing signal embedding, this should be the ROE from data)
19input1 = basf2.register_module('RootInput')
20input1.param('inputFileName', basf2.find_file('embedding_jpsi_exp12_skim.root', 'examples'))
21main.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)
24input2 = basf2.register_module('RootInput')
25input2.param('inputFileName', basf2.find_file('embedding_kplusnunu_mcsig_skim.root', 'examples'))
26input2.param('isSecondaryInput', True) # <- set flag for secondary input module
27indep.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
34main.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
43main.add_module('FixMergedObjects')
44
45# output
46output = basf2.register_module('RootOutput')
47output.param('outputFileName', 'merged_10evts.root')
48main.add_module(output)
49
50# progress
51main.add_module('Progress')
52
53basf2.print_path(main)
54basf2.process(main)
55
56print(basf2.statistics)
57
58# @endcond