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