Belle II Software development
ValidationMetadataSetter Class Reference
Inheritance diagram for ValidationMetadataSetter:

Public Member Functions

 __init__ (self, List[Tuple[str]] variables, Union[str, pathlib.PurePath] rootfile, description="")
 
 initialize (self)
 
 terminate (self)
 

Protected Attributes

 _variables = variables
 Remember the metadata.
 
str _rootfile = rootfile
 And the name of the root file.
 
 _description = description
 Common description/information of/about all plots in this ROOT file (will be displayed above the plots)
 
ROOT.TFile _tfile = None
 Shared pointer to the root file that will be closed when the last user disconnects.
 

Detailed Description

Simple module to set the valdiation metadata for a given list of objects
automatically at the end of event processing

Just add this module **before** any
VariablesToNtuple/VariablesToHistogram modules and it will set the
correct validation metadata at the end of processing

Warning:
    The module needs to be before the modules creating the objects
    as terminate() functions are executed in reverse order from last to
    first module.  If this module is after the creation modules the metadata
    might not be set correctly

Definition at line 188 of file metadata.py.

Constructor & Destructor Documentation

◆ __init__()

__init__ ( self,
List[Tuple[str]] variables,
Union[str, pathlib.PurePath] rootfile,
description = "" )
Initialize ValidationMetadataSetter

Arguments:
    variables (list(tuple(str))): List of objects to set the metadata
        for. Each entry should be the name of an object followed by the
        metadata values which will be forwarded to
        `validation_metadata_set`:
        ``(name, title, contact, description, check, xlabel, ylabel,
        metaoptions)``
        where ``xlabel``, ``ylabel`` and ``metaoptions`` are optional
    rootfile (str or pathlib.PurePath): The name of the ROOT file where
        the objects can be found
    description (str): Common description/information of/about all plots
        in this ROOT file (will be displayed above the plots)

Definition at line 204 of file metadata.py.

209 ):
210 """
211 Initialize ValidationMetadataSetter
212
213 Arguments:
214 variables (list(tuple(str))): List of objects to set the metadata
215 for. Each entry should be the name of an object followed by the
216 metadata values which will be forwarded to
217 `validation_metadata_set`:
218 ``(name, title, contact, description, check, xlabel, ylabel,
219 metaoptions)``
220 where ``xlabel``, ``ylabel`` and ``metaoptions`` are optional
221 rootfile (str or pathlib.PurePath): The name of the ROOT file where
222 the objects can be found
223 description (str): Common description/information of/about all plots
224 in this ROOT file (will be displayed above the plots)
225 """
226 super().__init__()
227
228 self._variables = variables
229 if isinstance(rootfile, pathlib.PurePath):
230 rootfile = str(rootfile)
231
232 self._rootfile: str = rootfile
233
235 self._description = description
236
238 self._tfile: ROOT.TFile = None
239

Member Function Documentation

◆ initialize()

initialize ( self)
Make sure we keep the file open

Definition at line 240 of file metadata.py.

240 def initialize(self):
241 """Make sure we keep the file open"""
242 self._tfile = Belle2.RootFileCreationManager.getInstance().getFile(
243 self._rootfile
244 )
245
static RootFileCreationManager & getInstance()
Interface for the FileManager.

◆ terminate()

terminate ( self)
And update the metadata at the end

Definition at line 246 of file metadata.py.

246 def terminate(self):
247 """And update the metadata at the end"""
248 for name, *metadata in self._variables:
250 validation_metadata_update(self._tfile, name, *metadata)
251 if self._description:
252 file_description_set(self._tfile, self._description)
253 self._tfile.Close()
254
255
static std::string makeROOTCompatible(std::string str)
Remove special characters that ROOT dislikes in branch names, e.g.

Member Data Documentation

◆ _description

_description = description
protected

Common description/information of/about all plots in this ROOT file (will be displayed above the plots)

Definition at line 235 of file metadata.py.

◆ _rootfile

str _rootfile = rootfile
protected

And the name of the root file.

Definition at line 232 of file metadata.py.

◆ _tfile

_tfile = None
protected

Shared pointer to the root file that will be closed when the last user disconnects.

Definition at line 238 of file metadata.py.

◆ _variables

_variables = variables
protected

Remember the metadata.

Definition at line 228 of file metadata.py.


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