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