Belle II Software development
DecayHashMap Class Reference

Public Member Functions

def __init__ (self, rootfile, removeRadiativeGammaFlag=False)
 
def get_string (self, decayHash, decayHashExtended)
 
def get_original_decay (self, decayHash, decayHashExtended)
 
def get_reconstructed_decay (self, decayHash, decayHashExtended)
 
def print_hash (self, decayHash, decayHashExtended)
 

Protected Attributes

 _string
 Dict Int -> DecayStrings.
 
 _forest
 Dict Int -> Reconstructed DecayTree.
 

Detailed Description

DecayHashMap using the C++ implementation of DecayTree and DecayNode

Definition at line 49 of file decayHash.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  rootfile,
  removeRadiativeGammaFlag = False 
)
Constructor

Definition at line 54 of file decayHash.py.

54 def __init__(self, rootfile, removeRadiativeGammaFlag=False):
55 """Constructor"""
56 # Always avoid the top-level 'import ROOT'.
57 import ROOT # noqa
58 with uproot.open(rootfile) as rf:
59 trees = rf.keys()
60 assert len(trees) == 1
61 ntuple = rf[trees[0]].arrays(library='np')
62 # self._removeGammaFlag = removeRadiativeGammaFlag
63
64 self._string = {}
65
66 self._forest = {}
67 for decayHash, decayHashExtended, decayString in zip(
68 ntuple['decayHash'], ntuple['decayHashExtended'], ntuple['decayString']):
69 decayInt = ROOT.Belle2.DecayForest.decayHashFloatToInt(decayHash, decayHashExtended)
70 if decayInt in self._string:
71 continue
72 self._string[decayInt] = decayString
73 self._forest[decayInt] = ROOT.Belle2.DecayForest(decayString, True, removeRadiativeGammaFlag)
74

Member Function Documentation

◆ get_original_decay()

def get_original_decay (   self,
  decayHash,
  decayHashExtended 
)
Return original (MC) DecayTree given the decayHash and decayHashExtended
@param decayHash output of extraInfo(decayHash)
@param decayHashExtended output of extraInfo(decayHashExtended)

Definition at line 85 of file decayHash.py.

85 def get_original_decay(self, decayHash, decayHashExtended):
86 """
87 Return original (MC) DecayTree given the decayHash and decayHashExtended
88 @param decayHash output of extraInfo(decayHash)
89 @param decayHashExtended output of extraInfo(decayHashExtended)
90 """
91 # Always avoid the top-level 'import ROOT'.
92 import ROOT # noqa
93 return self._forest[ROOT.Belle2.DecayForest.decayHashFloatToInt(decayHash, decayHashExtended)].getOriginalTree()
94

◆ get_reconstructed_decay()

def get_reconstructed_decay (   self,
  decayHash,
  decayHashExtended 
)
Return reconstructed DecayTree given the decayHash and decayHashExtended
@param decayHash output of extraInfo(decayHash)
@param decayHashExtended output of extraInfo(decayHashExtended)

Definition at line 95 of file decayHash.py.

95 def get_reconstructed_decay(self, decayHash, decayHashExtended):
96 """
97 Return reconstructed DecayTree given the decayHash and decayHashExtended
98 @param decayHash output of extraInfo(decayHash)
99 @param decayHashExtended output of extraInfo(decayHashExtended)
100 """
101 # Always avoid the top-level 'import ROOT'.
102 import ROOT # noqa
103 return self._forest[ROOT.Belle2.DecayForest.decayHashFloatToInt(decayHash, decayHashExtended)].getReconstructedTree()
104

◆ get_string()

def get_string (   self,
  decayHash,
  decayHashExtended 
)
Return DecayString given the decayHash and decayHashExtended
@param decayHash output of extraInfo(decayHash)
@param decayHashExtended output of extraInfo(decayHashExtended)

Definition at line 75 of file decayHash.py.

75 def get_string(self, decayHash, decayHashExtended):
76 """
77 Return DecayString given the decayHash and decayHashExtended
78 @param decayHash output of extraInfo(decayHash)
79 @param decayHashExtended output of extraInfo(decayHashExtended)
80 """
81 # Always avoid the top-level 'import ROOT'.
82 import ROOT # noqa
83 return self._string[ROOT.Belle2.DecayForest.decayHashFloatToInt(decayHash, decayHashExtended)]
84

◆ print_hash()

def print_hash (   self,
  decayHash,
  decayHashExtended 
)
Print the DecayString in a fancy way given the decayHash and decayHashExtended
@param decayHash output of extraInfo(decayHash)
@param decayHashExtended output of extraInfo(decayHashExtended)

Definition at line 105 of file decayHash.py.

105 def print_hash(self, decayHash, decayHashExtended):
106 """
107 Print the DecayString in a fancy way given the decayHash and decayHashExtended
108 @param decayHash output of extraInfo(decayHash)
109 @param decayHashExtended output of extraInfo(decayHashExtended)
110 """
111 entry = self.get_string(decayHash, decayHashExtended)
112 entries = entry.split('|')
113 all_particles = re.findall(r"(-?[0-9]+)", entries[0])
114
115 if len(all_particles) != len(entries) - 1:
116 print(entry)
117 raise RuntimeError("Bad format of decay string: " +
118 str(len(all_particles)) + " " + str(len(entries)) + " " + str(entries))
119
120 table = []
121 table.append(["Decay ", prettify_pdg_codes(entries[0])])
122 for particle, mc_decay_string in zip(all_particles, entries[1:]):
123 table.append([prettify_pdg_codes(particle), prettify_pdg_codes(mc_decay_string)])
124
125 basf2.pretty_print_table(table, column_widths=[6, '*'])
126
127

Member Data Documentation

◆ _forest

_forest
protected

Dict Int -> Reconstructed DecayTree.

Definition at line 66 of file decayHash.py.

◆ _string

_string
protected

Dict Int -> DecayStrings.

Definition at line 64 of file decayHash.py.


The documentation for this class was generated from the following file: