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