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