Belle II Software  release-08-01-10
CalibObjManager Class Reference

Manager class for collector registered data. Handles much of the TDirectory/TObject manipulation. More...

#include <CalibObjManager.h>

Collaboration diagram for CalibObjManager:

Public Member Functions

 CalibObjManager (TDirectory *dir=nullptr)
 Constructor.
 
virtual ~CalibObjManager ()
 Destructor: Every object we are managing is ultimately either saved into a file to write out, or was read in from an open file, or was created via merging objects together and passed out. More...
 
void setDirectory (TDirectory *dir)
 Change the directory that we will be using to find/store all our objects, we don't own it.
 
void addObject (const std::string &name, std::shared_ptr< TNamed > object)
 Add a new object to manage, this is used as a template for creating future/missing objects. More...
 
void writeCurrentObjects (const Calibration::ExpRun &expRun)
 For each templated object we know about, we find an in memory object for this exprun and write to the TDirectory.
 
void clearCurrentObjects (const Calibration::ExpRun &expRun)
 Deletes all in-memory objects in the exprun directories for all the collector objects we know about.
 
void createDirectories ()
 Each object gets its own TDirectory under the main manager directory to store its objects. More...
 
void createExpRunDirectories (Calibration::ExpRun &expRun) const
 For each templated object, we create a new TDirectory for this exprun.
 
unsigned int getHighestIndexObject (const std::string &name, const TDirectory *dir) const
 Scans the directory to get the highest "_i" index of an object with this name.
 
void deleteHeldObjects ()
 Clears the map of templated objects -> causing their destruction.
 
bool isRegistered (const std::string &name) const
 Checks for the existence of a name in the templated object map to see if we registered the object.
 
template<class T >
T * getObject (const std::string &name, const Belle2::Calibration::ExpRun expRun)
 Gets the collector object of this name for the given exprun. More...
 
template<>
TTree * cloneObj (TTree *source, const std::string &newName) const
 Template specialization for TTree needs to be defined here to prevent automatic specialization being created.
 

Private Member Functions

template<class T >
T * cloneObj (T *source, const std::string &newName) const
 Clone object.
 
std::string getSuffix (const Calibration::ExpRun &key) const
 We rename objects based on the Exp,Run that they contain so we need to generate a nice naming convention.
 
std::string getSuffix (const EventMetaData &emd) const
 Sometimes it's nice to just pass in the EventMetaData instead of converting manually.
 
std::string getObjectExpRunName (const std::string &name, const Calibration::ExpRun &expRun) const
 Get object experiment and run name.
 
unsigned int extractKeyIndex (const std::string &keyName) const
 Extract key index.
 

Private Attributes

TDirectory * m_dir
 The TDirectory where all of our managed objects should be found, and where we should create new ones.
 
std::map< std::string, std::shared_ptr< TNamed > > m_templateObjects
 The objects that we are managing, these are template objects for all future objects for each (Exp,Run). More...
 

Detailed Description

Manager class for collector registered data. Handles much of the TDirectory/TObject manipulation.

Definition at line 29 of file CalibObjManager.h.

Constructor & Destructor Documentation

◆ ~CalibObjManager()

virtual ~CalibObjManager ( )
inlinevirtual

Destructor: Every object we are managing is ultimately either saved into a file to write out, or was read in from an open file, or was created via merging objects together and passed out.

Ultimately the objects that are saved or read from a file are memory managed by a TFile/TDirectory. The created/merged objects are returned and are the responsibility of the user to clean up once finished with them. So we are only really responsible for cleaning up the template object which belongs to no directory and is never used directly by an outside user except when creating object that is passed in for the template.

Definition at line 42 of file CalibObjManager.h.

42 {m_templateObjects.clear();}
std::map< std::string, std::shared_ptr< TNamed > > m_templateObjects
The objects that we are managing, these are template objects for all future objects for each (Exp,...

Member Function Documentation

◆ getObject()

T* getObject ( const std::string &  name,
const Belle2::Calibration::ExpRun  expRun 
)
inline

Gets the collector object of this name for the given exprun.

If there already exists some objects it gets the highest index one if it is in-memory. If the highest index object is file resident it creates a new in memory object with a higher index.

Definition at line 80 of file CalibObjManager.h.

Member Data Documentation

◆ m_templateObjects

std::map<std::string, std::shared_ptr<TNamed> > m_templateObjects
private

The objects that we are managing, these are template objects for all future objects for each (Exp,Run).

They should not contain data themselves.

Definition at line 132 of file CalibObjManager.h.


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