Belle II Software development
B2A704-EventShape.py
1#!/usr/bin/env python3
2
3
10
11
19
20
21import basf2 as b2
22import modularAnalysis as ma
23import variables.collections as vc
24
25# create path
26my_path = b2.create_path()
27
28# load input ROOT file
29ma.inputMdst(filename=b2.find_file('B02D0pi0_D02pi0pi0.root', 'examples', False),
30 path=my_path)
31
32
33# Creates a list of good tracks (using the pion mass hypothesis)
34# and good gammas with very minimal cuts
35ma.fillParticleList(decayString='pi+:goodtracks',
36 cut='pt> 0.1',
37 path=my_path)
38ma.fillParticleList(decayString='gamma:minimal',
39 cut='E > 0.1',
40 path=my_path)
41
42# Builds the event shape enabling explicitly ALL the variables.
43# Most of them are actually enabled by default, but here we prefer
44# to list explicitly all the flags
45ma.buildEventShape(inputListNames=['pi+:goodtracks', 'gamma:minimal'],
46 allMoments=True,
47 foxWolfram=True,
48 harmonicMoments=True,
49 cleoCones=True,
50 thrust=True,
51 collisionAxis=True,
52 jets=True,
53 sphericity=True,
54 checkForDuplicates=False,
55 path=my_path)
56
57# Here we use the predefined collection 'event_shape', that contains thrust,
58# sphericity, aplanarity, FW ratios up to 4, harmonic moments w/respect to
59# the thrust axis up to 4 and all the cleo cones w/respect to the thrust
60# axis. In addition, we will save also the forward and backward hemisphere (
61# or "jet") energies, and the 2nd order harmonic moment calculated with
62# respect to the collision axis (i.e. the z axis)
63ma.variablesToNtuple(
64 '',
65 variables=[
66 *vc.event_shape, # [1] see below
67 'backwardHemisphereEnergy',
68 'forwardHemisphereEnergy',
69 'harmonicMoment(2, collision)'
70 ],
71 filename='B2A704-EventShape.root',
72 path=my_path
73)
74
75# [1] Note: The * operator "unpacks" the list of variables provided by the
76# variable collection (because we don't want to get a list in a list, but just
77# add the elements): ```[*[1, 2, 3], 4] == [1, 2, 3, 4])```
78
79# Process the events
80b2.process(my_path)
81# print out the summary
82print(b2.statistics)