12 """Create and write an TNtuple of the validation figures of merit"""
25 self.
name = root_save_name(name)
39 """Informal string output listing the assigned figures of merit."""
42 return '\n'.join(
'%s : %s' % (key, figures_by_name[key])
44 figures_by_name.keys())
46 def write(self, tdirectory=None):
47 """Writes the figures of merit as a TNtuple.
51 tdirectory : ROOT.TDirectory, optional
52 The directory to which the TNtuple shall be written.
53 Defaults to the current directory.
58 get_logger().warning(
'Do not create Ntuple for empty ValidationFiguresOfMerit %s' % name)
61 title = self.
title or name
67 figure_names = [root_save_name(key)
for key
in list(self.
figures_by_name.keys())]
70 with root_cd(tdirectory)
as tdirectory:
72 tntuple = tdirectory.Get(name)
74 former_description = tntuple.GetAlias(
'Description')
75 former_check = tntuple.GetAlias(
'Check')
76 former_figure_names = []
79 for tleaf
in tntuple.GetListOfLeaves():
80 former_figure_names.append(tleaf.GetName())
81 former_values.append(tleaf.GetValue())
84 description = former_description +
' <br/>\n' + description
85 check = former_check +
' <br/>\n' + check
87 figure_names = former_figure_names + figure_names
88 values = former_values + values
91 tdirectory.Delete(name)
92 write_option = ROOT.TObject.kOverwrite
97 leaf_specification =
':'.join(figure_names)
98 tntuple = ROOT.TNtuple(name, title, leaf_specification)
100 array_of_values = array.array(
'f', values)
101 tntuple.Fill(array_of_values)
103 tntuple.SetAlias(
'Description', description)
104 tntuple.SetAlias(
'Check', check)
105 tntuple.SetAlias(
'Contact', contact)
108 tntuple.Write(
"", write_option)
111 """Braketed item assignement for figures of merit"""
116 """Braketed item lookup for figures of merit"""
121 """Braketed item deletion for figures of merit"""
126 """Implements the iter() hook as if it was a dictionary."""
131 """Returns the number of figures of merit assigned. Implements the len() hook."""
137 """Create and write an TNtuple with several validation figures of merit"""
140 """Describe myself"""
141 return 'Not supported.'
144 """Writes the figures of merit as a TNtuple.
148 tdirectory : ROOT.TDirectory, optional
149 The directory to which the TNtuple shall be written.
150 Defaults to the current directory.
153 figure_names = [root_save_name(key)
for key
in list(self.
figures_by_name.keys())]
156 leaf_specification =
':'.join(figure_names)
157 title = self.
title or ""
158 ntuple = ROOT.TNtuple(name, title, leaf_specification)
160 for value
in zip(*values):
164 ntuple.SetAlias(
'Check', self.
check)
165 ntuple.SetAlias(
'Contact', self.
contact)
167 with root_cd(tdirectory):