Belle II Software  release-05-01-25
B2A503-ReadDecayHash.py
1 #!/usr/bin/env python3
2 
3 
28 
29 import root_pandas
30 import decayHash
31 import basf2 as b2
32 from decayHash import DecayHashMap
33 import sys
34 
35 # read in root-file as a pandas dataframe
36 data = root_pandas.read_root(b2.find_file('Jpsi_from_B2A502.root', 'examples', False))
37 hashmap = DecayHashMap(b2.find_file('hashmap_Jpsi_from_B2A502.root', 'examples', False), removeRadiativeGammaFlag=False)
38 hashmap2 = DecayHashMap(b2.find_file('hashmap_Jpsi_from_B2A502.root', 'examples', False), removeRadiativeGammaFlag=True)
39 
40 # get one reconstructed J/psi
41 candidate42 = data.iloc[42][["extraInfo__boDecayHash__bc", "extraInfo__boDecayHashExtended__bc"]].values
42 
43 # print the reconstruced decay
44 print("Reconstructed Decay: ")
45 rec = hashmap.get_reconstructed_decay(*candidate42)
46 print(rec.to_string())
47 
48 # print the original decay as simulated in MC
49 print("Monte Carlo Decay: ")
50 org = hashmap.get_original_decay(*candidate42)
51 print(org.to_string())
52 
53 # print the original decay as simulated in MC with removed Bremstrahlung gammas
54 print("Monte Carlo Decay with removed Bremsstrahlung gammas: ")
55 org2 = hashmap2.get_original_decay(*candidate42)
56 print(org2.to_string())
57 
58 # search for a specific decay (sub-decay)
59 print("Search for decay:")
60 search_decay = decayHash.Belle2.DecayTree('511 (-> 130 (-> -11 11 22) 443)')
61 print(search_decay.to_string())
62 found = hashmap.get_original_decay(data.iloc[42]["extraInfo__boDecayHash__bc"],
63  data.iloc[42]["extraInfo__boDecayHashExtended__bc"]).find_decay(search_decay)
64 print("Found: ", found)
65 sys.exit(0)