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