Belle II Software development
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
21import basf2 as b2
22
23# Create path
24main = b2.create_path()
25
26# Root input
27roinput = b2.register_module('SeqRootInput')
28# roinput = register_module('RootInput')
29main.add_module(roinput)
30
31# Output only events that pass
32output_calib_path = b2.create_path()
33output = b2.register_module('RootOutput')
34output.param('outputFileName', "calib_mumu.root")
35output_calib_path.add_module(output)
36
37cut_decision = b2.register_module("TriggerSkim")
38cut_decision.param('triggerLines', ['software_trigger_cut&hlt&accept_2_tracks',
39 'software_trigger_cut&hlt&accept_mu_mu'])
40cut_decision.param('expectedResult', 1)
41# cut_decision.param('logicMode', 'and') # Default == 'or'
42cut_decision.if_value("==1", output_calib_path, b2.AfterConditionPath.CONTINUE)
43main.add_module(cut_decision)
44
45# Output all events but in ROOT (not SeqROOT) format
46output_path = b2.create_path()
47output = b2.register_module('RootOutput')
48output.param('outputFileName', "raw.root")
49main.add_module(output)
50
51# Process events
52b2.process(main)
53print(b2.statistics)