Belle II Software development
displaytriggered.py
1#!/usr/bin/env python3
2
3
10
11#
12# Opens a .root/.sroot file and shows MCParticles,
13# SimHits and Tracks using the Display module. Only
14# events which were triggered by the HLT are displayed.
15# Usage:
16# basf2 display/example/displaytrigger.py -i MyInputFile.root
17
18import basf2 as b2
19import ROOT
20from ROOT import Belle2
21
22
23class DisplayHLTTags(b2.Module):
24 """Test DisplayData"""
25
26 def initialize(self):
27 """reimplementation of Module::initialize()."""
28
29 Belle2.PyStoreObj("DisplayData").registerInDataStore()
30
31 def event(self):
32 """reimplementation of Module::event()."""
33
34 displayData = Belle2.PyStoreObj("DisplayData")
35 displayData.create()
36
37 print("HLT Tags:")
38 displayData.obj().addLabel('HLT Tags:', ROOT.Math.XYZVector(200, 220, -300))
39 trigger_result = Belle2.PyStoreObj('SoftwareTriggerResult')
40 dz_pos = 0
41 for name, result in trigger_result.getResults():
42 prefix = 'software_trigger_cut&hlt&accept_'
43 if result == 1 and name.startswith(prefix):
44 name = name[len(prefix):]
45 displayData.obj().addLabel(name, ROOT.Math.XYVector(200, 200 - dz_pos, -300))
46 dz_pos += 15
47 print(name)
48
49
50# create paths
51main = b2.create_path()
52
53# Get type of input file to decide, which input module we want to use
54input_files = Belle2.Environment.Instance().getInputFilesOverride()
55if not input_files.empty() and input_files.front().endswith(".sroot"):
56 rootinput = b2.register_module('SeqRootInput')
57else:
58 rootinput = b2.register_module('RootInput')
59
60# create geometry
61gearbox = b2.register_module('Gearbox')
62geometry = b2.register_module('Geometry')
63
64main.add_module(rootinput)
65main.add_module(gearbox)
66main.add_module(geometry)
67
68main.add_module(DisplayHLTTags())
69
70display = b2.register_module('Display')
71# --- MC options ---
72# Should Monte Carlo info be shown? (MCParticles, SimHits)
73display.param('showMCInfo', True)
74
75# should hits always be assigned to a particle with c_PrimaryParticle flag?
76display.param('assignHitsToPrimaries', False)
77
78# show all primary MCParticles?
79display.param('showAllPrimaries', True)
80
81# show all charged MCParticles?
82display.param('showCharged', True)
83
84# show all neutral MCParticles?
85display.param('showNeutrals', True)
86
87
88# --- Intermediate options ---
89# show track candidates?
90# You most likely don't want this unless you are a tracking developer
91display.param('showRecoTracks', False)
92
93# directly show CDCHits as drift cylinders (shortened, z position = 0)
94display.param('showCDCHits', False)
95
96# show trigger objects?
97display.param('showTriggerObjects', False)
98
99
100# --- Track options ---
101# show tracks, vertices, eclgammas?
102display.param('showTrackLevelObjects', True)
103
104# The options parameter is a combination of:
105# D draw detectors - draw simple detector representation (with different size)
106# for each hit
107# H draw track hits
108# M draw track markers - intersections of track with detector planes
109# P draw detector planes
110#
111# Note that you can always turn off an individual detector component or track
112# interactively by removing its checkmark in the 'Eve' tab.
113#
114# only makes sense when showTrackLevelObjects/showTrackCandidates is used
115display.param('options', 'MH') # default
116
117# --- Other options ---
118
119# save events non-interactively (without showing window)?
120display.param('automatic', False)
121
122# change to True to show the full TGeo geometry instead of simplified extract
123display.param('fullGeometry', False)
124
125# Objects which are to be hidden (can be manually re-enabled in tree view).
126# Names correspond to the object names in the 'Event'. (Note that this won't
127# work for objects somewhere deep in the tree, only for those immediately
128# below 'Event'.
129display.param('hideObjects', [])
130
131# this path will only be executed for events which satfisy the trigger skim
132triggered_event_path = b2.Path()
133triggered_event_path.add_module(display)
134
135trigger_skim_module = b2.register_module("TriggerSkim")
136# add whatever HLT/Calib trigger lines you would like to select here
137trigger_skim_module.param('triggerLines', ['software_trigger_cut&hlt&accept_mumu_2trk',
138 'software_trigger_cut&hlt&accept_bhabha',
139 'software_trigger_cut&hlt&accept_hadron'])
140# if any of the trigger lines are true, run the display path
141trigger_skim_module.if_value("==1", triggered_event_path, b2.AfterConditionPath.CONTINUE)
142
143main.add_module(trigger_skim_module)
144
145b2.process(main)
static Environment & Instance()
Static method to get a reference to the Environment instance.
Definition: Environment.cc:28
a (simplified) python wrapper for StoreObjPtr.
Definition: PyStoreObj.h:67