Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
RootController Class Reference

A Controller class for ROOT files. More...

#include <RootController.h>

Inheritance diagram for RootController:
Inheritance graph
[legend]
Collaboration diagram for RootController:
Collaboration graph
[legend]

Public Member Functions

const std::vector< std::string > & getNTupleNames (const std::string &)
 Returns the names of the DataSource objects contained in the file name.
const std::string & version () const
 Returns the version of ROOT being used.
virtual ~RootController ()
 The destructor.
can be of the

Creates a RootNTuple object named name.

form "filename.root: tree", in which case the part left of `:' is taken as the filename and the part right of the `:' is taken as the tree name. If a `:' does not exist in name, then the first tree is used.

DataSourcecreateNTuple (const std::string &name)
DataSourcecreateNTuple (const std::string &filename, const std::string &treename)
 Creates a RootNTuple from the file filename and TTree named treename.
DataSourceinitNTuple (DataSource *source, const std::string &filename, const std::string &treename)
 Initialized and registers new DataSource.
TTreegetTree (const std::string &file, const std::string &tree)
 Returns the named tree from file in the ROOT file.
void fillDimSize (std::vector< int > &dims, const DataSource *source, const std::string &column)
 Fills the vector dims.
bool smartExpandRootNTuple (DataSource *source, std::string &column)
 Expands the array column.
virtual void update (const Observable *)
 Does nothing, but satisfies the pure virtual function in base.
virtual void willDelete (const Observable *obs)
 Closes the file that was used to create the observed RootNTuple.

Static Public Member Functions

static RootControllerinstance ()
 Returns the singleton instance of the RootController.

Private Types

typedef std::map< const
DataSource *, std::string > 
TupleToFileMap_t

Private Member Functions

void closeFile (const std::string &name)
 Closed the named file, if found in list of opened files.
TFile * openFile (const std::string &name)
 Attempts to open the file name.

Private Attributes

std::map< std::string, TFile * > m_file_map
 The list of opened ROOT files.
std::vector< std::string > m_ntuple_names
 Temporary list of DataSource names in the file.
TupleToFileMap_t m_tuple_map
 A map to find which ROOT file was used to create RootNTuple.
std::string m_version
 The version of ROOT being used.

Static Private Attributes

static RootControllers_instance = 0
 The singleton instance of the RootController.

Detailed Description

A Controller class for ROOT files.

Bug:
@@@ testsuite/towercut.py needs fixing.
Requests:
@@ Be able to chain ROOT files.
Requests:
Read TH1 and TH2 histograms in ROOT file and convert to corresponding static histograms.
Author
Paul F. Kunz Paul_.nosp@m.Kunz.nosp@m.@slac.nosp@m..sta.nosp@m.nford.nosp@m..edu

Definition at line 42 of file RootController.h.

Member Typedef Documentation

typedef std::map< const DataSource *, std::string > TupleToFileMap_t
private

Definition at line 52 of file RootController.h.

Constructor & Destructor Documentation

~RootController ( )
virtual

The destructor.

Definition at line 57 of file RootController.cxx.

Member Function Documentation

void closeFile ( const std::string &  name)
private

Closed the named file, if found in list of opened files.

Definition at line 97 of file RootController.cxx.

References RootController::m_file_map.

Referenced by RootController::getNTupleNames(), and RootController::willDelete().

DataSource * createNTuple ( const std::string &  name)

Definition at line 188 of file RootController.cxx.

References RootController::getNTupleNames().

DataSource * createNTuple ( const std::string &  filename,
const std::string &  treename 
)

Creates a RootNTuple from the file filename and TTree named treename.

Definition at line 155 of file RootController.cxx.

References RootController::getTree(), and RootController::initNTuple().

void fillDimSize ( std::vector< int > &  dims,
const DataSource source,
const std::string &  column 
)

Fills the vector dims.

If the DataSource is a RootNTuple, fills the vector dim with the dimension of he column labeled column, otherwise does nothing.

Definition at line 210 of file RootController.cxx.

References num_util::shape().

const vector< string > & getNTupleNames ( const std::string &  file_name)

Returns the names of the DataSource objects contained in the file name.

For ROOT files, this is the names of the TTree.

Bug:
Returns all top level names instead of only the ones that could be a DataSource.
Bug:
@@@ If can not open file, should thrown an exception. When fixing this bug, check also the FitsController for same bug.

Definition at line 112 of file RootController.cxx.

References RootController::closeFile(), RootController::m_ntuple_names, RootController::openFile(), and num_util::size().

Referenced by RootController::createNTuple().

TTree * getTree ( const std::string &  file,
const std::string &  tree 
)

Returns the named tree from file in the ROOT file.

Definition at line 141 of file RootController.cxx.

References RootController::openFile().

Referenced by RootController::createNTuple().

DataSource * initNTuple ( DataSource source,
const std::string &  filename,
const std::string &  treename 
)

Initialized and registers new DataSource.

Definition at line 167 of file RootController.cxx.

References RootController::instance(), and RootController::m_tuple_map.

Referenced by RootController::createNTuple().

RootController * instance ( )
static
TFile * openFile ( const std::string &  name)
private

Attempts to open the file name.

Throws a std::runtime_error exception if file not found.

Definition at line 71 of file RootController.cxx.

References RootController::m_file_map.

Referenced by RootController::getNTupleNames(), and RootController::getTree().

bool smartExpandRootNTuple ( DataSource source,
std::string &  column 
)

Expands the array column.

If the DataSource is a RootNTuple, expands the column with array TLeaf and returns true, otherwise returns false.

Definition at line 229 of file RootController.cxx.

void update ( const Observable )
virtual

Does nothing, but satisfies the pure virtual function in base.

Definition at line 243 of file RootController.cxx.

const std::string & version ( ) const

Returns the version of ROOT being used.

Definition at line 63 of file RootController.cxx.

References RootController::m_version.

void willDelete ( const Observable obs)
virtual

Closes the file that was used to create the observed RootNTuple.

Closes the file that was used to create the observed RootNTuple if it was the only RootNTuple created from that file.

Todo:
This method does get called with obs != RootNTuple, find out why.

Definition at line 253 of file RootController.cxx.

References RootController::closeFile(), and RootController::m_tuple_map.

Member Data Documentation

std::map< std::string, TFile * > m_file_map
private

The list of opened ROOT files.

Definition at line 48 of file RootController.h.

Referenced by RootController::closeFile(), and RootController::openFile().

std::vector< std::string > m_ntuple_names
private

Temporary list of DataSource names in the file.

Definition at line 60 of file RootController.h.

Referenced by RootController::getNTupleNames().

TupleToFileMap_t m_tuple_map
private

A map to find which ROOT file was used to create RootNTuple.

Definition at line 56 of file RootController.h.

Referenced by RootController::initNTuple(), and RootController::willDelete().

std::string m_version
mutableprivate

The version of ROOT being used.

Definition at line 63 of file RootController.h.

Referenced by RootController::version().

RootController * s_instance = 0
staticprivate

The singleton instance of the RootController.

Definition at line 67 of file RootController.h.

Referenced by RootController::instance().


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

Generated for HippoDraw Class Library by doxygen