21 """Create and write an TNtuple of the validation figures of merit"""
34 self.
namename = root_save_name(name)
48 """Informal string output listing the assigned figures of merit."""
51 return '\n'.join(
'%s : %s' % (key, figures_by_name[key])
53 figures_by_name.keys())
55 def write(self, tdirectory=None):
56 """Writes the figures of merit as a TNtuple.
60 tdirectory : ROOT.TDirectory, optional
61 The directory to which the TNtuple shall be written.
62 Defaults to the current directory.
67 get_logger().warning(
'Do not create Ntuple for empty ValidationFiguresOfMerit %s' % name)
70 title = self.
titletitle
or name
74 check = self.
checkcheck
76 figure_names = [root_save_name(key)
for key
in list(self.
figures_by_namefigures_by_name.keys())]
79 with root_cd(tdirectory)
as tdirectory:
81 tntuple = tdirectory.Get(name)
83 former_description = tntuple.GetAlias(
'Description')
84 former_check = tntuple.GetAlias(
'Check')
85 former_figure_names = []
88 for tleaf
in tntuple.GetListOfLeaves():
89 former_figure_names.append(tleaf.GetName())
90 former_values.append(tleaf.GetValue())
93 description = former_description +
' <br/>\n' + description
94 check = former_check +
' <br/>\n' + check
96 figure_names = former_figure_names + figure_names
97 values = former_values + values
100 tdirectory.Delete(name)
101 write_option = ROOT.TObject.kOverwrite
106 leaf_specification =
':'.join(figure_names)
107 tntuple = ROOT.TNtuple(name, title, leaf_specification)
109 array_of_values = array.array(
'f', values)
110 tntuple.Fill(array_of_values)
112 tntuple.SetAlias(
'Description', description)
113 tntuple.SetAlias(
'Check', check)
114 tntuple.SetAlias(
'Contact', contact)
117 tntuple.Write(
"", write_option)
120 """Braketed item assignement for figures of merit"""
125 """Braketed item lookup for figures of merit"""
130 """Braketed item deletion for figures of merit"""
135 """Implements the iter() hook as if it was a dictionary."""
140 """Returns the number of figures of merit assigned. Implements the len() hook."""
146 """Create and write an TNtuple with several validation figures of merit"""
149 """Describe myself"""
150 return 'Not supported.'
153 """Writes the figures of merit as a TNtuple.
157 tdirectory : ROOT.TDirectory, optional
158 The directory to which the TNtuple shall be written.
159 Defaults to the current directory.
162 figure_names = [root_save_name(key)
for key
in list(self.
figures_by_namefigures_by_name.keys())]
165 leaf_specification =
':'.join(figure_names)
166 title = self.
titletitle
or ""
167 ntuple = ROOT.TNtuple(name, title, leaf_specification)
169 for value
in zip(*values):
172 ntuple.SetAlias(
'Description', self.
descriptiondescription)
173 ntuple.SetAlias(
'Check', self.
checkcheck)
174 ntuple.SetAlias(
'Contact', self.
contactcontact)
176 with root_cd(tdirectory):