Belle II Software  release-08-01-10
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(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
35 ma.fillParticleList(decayString='pi+:goodtracks',
36  cut='pt> 0.1',
37  path=my_path)
38 ma.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
45 ma.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)
63 ma.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
80 b2.process(my_path)
81 # print out the summary
82 print(b2.statistics)