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 191 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 207 of file metadata.py.

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

Member Function Documentation

◆ initialize()

initialize ( self)
Make sure we keep the file open

Definition at line 243 of file metadata.py.

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

◆ terminate()

terminate ( self)
And update the metadata at the end

Definition at line 249 of file metadata.py.

249 def terminate(self):
250 """And update the metadata at the end"""
251 for name, *metadata in self._variables:
253 validation_metadata_update(self._tfile, name, *metadata)
254 if self._description:
255 file_description_set(self._tfile, self._description)
256 del self._tfile
257
258
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 238 of file metadata.py.

◆ _rootfile

str _rootfile = rootfile
protected

And the name of the root file.

Definition at line 235 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 241 of file metadata.py.

◆ _variables

_variables = variables
protected

Remember the metadata.

Definition at line 231 of file metadata.py.


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