20 """Create and write an TNtuple of the validation figures of merit"""
33 self.name = root_save_name(name)
47 """Informal string output listing the assigned figures of merit."""
50 return '\n'.join(f
'{key} : {figures_by_name[key]}'
52 figures_by_name.keys())
54 def write(self, tdirectory=None):
55 """Writes the figures of merit as a TNtuple.
59 tdirectory : ROOT.TDirectory, optional
60 The directory to which the TNtuple shall be written.
61 Defaults to the current directory.
66 get_logger().warning(f
'Do not create Ntuple for empty ValidationFiguresOfMerit {name}')
69 title = self.
title or name
75 figure_names = [root_save_name(key)
for key
in list(self.
figures_by_name.keys())]
78 with root_cd(tdirectory)
as tdirectory:
80 tntuple = tdirectory.Get(name)
82 former_description = tntuple.GetAlias(
'Description')
83 former_check = tntuple.GetAlias(
'Check')
84 former_figure_names = []
87 for tleaf
in tntuple.GetListOfLeaves():
88 former_figure_names.append(tleaf.GetName())
89 former_values.append(tleaf.GetValue())
92 description = former_description +
' <br/>\n' + description
93 check = former_check +
' <br/>\n' + check
95 figure_names = former_figure_names + figure_names
96 values = former_values + values
99 tdirectory.Delete(name)
100 write_option = ROOT.TObject.kOverwrite
105 leaf_specification =
':'.join(figure_names)
106 tntuple = ROOT.TNtuple(name, title, leaf_specification)
108 array_of_values = array.array(
'f', values)
109 tntuple.Fill(array_of_values)
111 tntuple.SetAlias(
'Description', description)
112 tntuple.SetAlias(
'Check', check)
113 tntuple.SetAlias(
'Contact', contact)
116 tntuple.Write(
"", write_option)
119 """Braketed item assignment for figures of merit"""
124 """Braketed item lookup for figures of merit"""
129 """Braketed item deletion for figures of merit"""
134 """Implements the iter() hook as if it was a dictionary."""
139 """Returns the number of figures of merit assigned. Implements the len() hook."""
145 """Create and write an TNtuple with several validation figures of merit"""
148 """Describe myself"""
149 return 'Not supported.'
152 """Writes the figures of merit as a TNtuple.
156 tdirectory : ROOT.TDirectory, optional
157 The directory to which the TNtuple shall be written.
158 Defaults to the current directory.
161 figure_names = [root_save_name(key) for key
in list(self.
figures_by_name.keys())]
164 leaf_specification =
':'.join(figure_names)
165 title = self.
title or ""
166 ntuple = ROOT.TNtuple(name, title, leaf_specification)
168 for value
in zip(*values):
172 ntuple.SetAlias(
'Check', self.
check)
173 ntuple.SetAlias(
'Contact', self.
contact)
175 with root_cd(tdirectory):