RootController Class Reference

#include <RootController.h>

Inheritance diagram for RootController:

Inheritance graph
Observer
[legend]
Collaboration diagram for RootController:

Collaboration graph
Observer
[legend]
List of all members.

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_Kunz@slac.stanford.edu>

Definition at line 42 of file RootController.h.

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 &filename, const std::string &treename)
 Creates a RootNTuple from the file filename and TTree named treename.
DataSourcecreateNTuple (const std::string &name)
void fillDimSize (std::vector< int > &dims, const DataSource *source, const std::string &column)
 Fills the vector dims.
TTreegetTree (const std::string &file, const std::string &tree)
 Returns the named tree from file in the ROOT file.
DataSourceinitNTuple (DataSource *source, const std::string &filename, const std::string &treename)
 Initialized and registers new DataSource.
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.


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 &  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().

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

Definition at line 188 of file RootController.cxx.

References RootController::getNTupleNames().

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 &   ) 

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.

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 DataSourceController::instance(), and RootController::m_tuple_map.

Referenced by RootController::createNTuple().

RootController * instance (  )  [static]

Returns the singleton instance of the RootController.

Definition at line 42 of file RootController.cxx.

References RootController::s_instance.

Referenced by Inspector::addDataRepButton_clicked(), Inspector::getArrayTupleLabel(), HiNTupleXML::getObject(), CanvasView::helpAbout(), QtRootController::instance(), Inspector::newPlotButton_clicked(), and QtFileDialog::openRootTuple().

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.

Implements Observer.

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.

Reimplemented from Observer.

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 [mutable, private]

The version of ROOT being used.

Definition at line 63 of file RootController.h.

Referenced by RootController::version().

RootController * s_instance = 0 [static, private]

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