Belle II Software  release-08-01-10
skim_calibration.py
1 #!/usr/bin/env python3
2 
3 
10 
11 # An example of how to skim off events that pass a set of trigger lines (using a custom module for now)
12 # and how to also convert SROOT->ROOT at the same time. This is roughly the planned data flow after the DAQ
13 # finishes with the data and outputs SROOT files. We want to copy/skim off calibration events (muon trigger here
14 # is the stand-in since the calib triggers aren't ready) into their own ROOT files while allowing ALL events
15 # to be output to RAW ROOT files.
16 
17 # The TriggerSkim module allows us to query SoftwareTriggerResult objects in the RAW output without having to
18 # re-do the reconstruction/calculation again i.e. using the Trigger decisions already done by the HLT.
19 # Notice that we NEVER UNPACK the RAW data during this step, making this very fast.
20 
21 import basf2 as b2
22 
23 # Create path
24 main = b2.create_path()
25 
26 # Root input
27 roinput = b2.register_module('SeqRootInput')
28 # roinput = register_module('RootInput')
29 main.add_module(roinput)
30 
31 # Output only events that pass
32 output_calib_path = b2.create_path()
33 output = b2.register_module('RootOutput')
34 output.param('outputFileName', "calib_mumu.root")
35 output_calib_path.add_module(output)
36 
37 cut_decision = b2.register_module("TriggerSkim")
38 cut_decision.param('triggerLines', ['software_trigger_cut&hlt&accept_2_tracks',
39  'software_trigger_cut&hlt&accept_mu_mu'])
40 cut_decision.param('expectedResult', 1)
41 # cut_decision.param('logicMode', 'and') # Default == 'or'
42 cut_decision.if_value("==1", output_calib_path, b2.AfterConditionPath.CONTINUE)
43 main.add_module(cut_decision)
44 
45 # Output all events but in ROOT (not SeqROOT) format
46 output_path = b2.create_path()
47 output = b2.register_module('RootOutput')
48 output.param('outputFileName', "raw.root")
49 main.add_module(output)
50 
51 # Process events
52 b2.process(main)
53 print(b2.statistics)