larutil::LArUtilBase Class Reference

Base class for utility classes. More...

#include <LArUtilBase.hh>

Inheritance diagram for larutil::LArUtilBase:
larlight::larlight_base larutil::DetectorProperties larutil::Geometry larutil::LArProperties

List of all members.

Public Member Functions

 LArUtilBase ()
 Default constructor.
virtual ~LArUtilBase ()
 Default destructor.
void SetFileName (const std::string filename)
 Method to set data file name.
void SetTreeName (const std::string treename)
 Method to set data TTree name.
virtual bool LoadData (bool force_reload=false)
 Method to load data TTree.
virtual void set_verbosity (MSG::Level level)
 Setter for the verbosity level.
MSG::Level get_verbosity () const
 Getter for the verbosity level.
const std::string class_name () const
 Getter for the class name.
void print (MSG::Level level, std::string where, std::string msg) const
 message print out method
void print (MSG::Level level, std::string msg) const
 message print out method

Protected Member Functions

virtual bool ReadTree ()=0
virtual void ClearData ()=0

Protected Attributes

std::string _file_name
std::string _tree_name
bool _loaded
char _buf [200]
 char buffer for message manipulation
std::vector< bool > _verbosity
 holder for enabled message levels
MSG::Level _verbosity_level
 holder for specified verbosity level
std::string _name
 class name holder

Detailed Description

Base class for utility classes.

Currently we take a simple approach of reading-in parameter values from TTree. This base class implements a way to read TTree and also store output TTree. DB access may be implemented here in future.

Definition at line 33 of file LArUtilBase.hh.


Constructor & Destructor Documentation

larutil::LArUtilBase::LArUtilBase (  ) 

Default constructor.

Definition at line 9 of file LArUtilBase.cc.

References _loaded, and larlight::larlight_base::_name.

00010     : larlight::larlight_base(),
00011       _file_name(""),
00012       _tree_name("")
00013   //-----------------------------------------------------
00014   { 
00015     _name   = "LArUtilBase";
00016     _loaded = false;
00017   }

virtual larutil::LArUtilBase::~LArUtilBase (  )  [inline, virtual]

Default destructor.

Definition at line 41 of file LArUtilBase.hh.

00041 {};


Member Function Documentation

const std::string larlight::larlight_base::class_name (  )  const [inline, inherited]

Getter for the class name.

Definition at line 49 of file larlight_base.hh.

References larlight::larlight_base::_name.

00049 {return _name;};

virtual void larutil::LArUtilBase::ClearData (  )  [protected, pure virtual]
MSG::Level larlight::larlight_base::get_verbosity (  )  const [inline, inherited]

Getter for the verbosity level.

Definition at line 46 of file larlight_base.hh.

References larlight::larlight_base::_verbosity_level.

00046 {return _verbosity_level;};

bool larutil::LArUtilBase::LoadData ( bool  force_reload = false  )  [virtual]

Method to load data TTree.

Reimplemented in larutil::Geometry.

Definition at line 20 of file LArUtilBase.cc.

References _file_name, _loaded, larlight::larlight_base::_name, _tree_name, ClearData(), larlight::MSG::ERROR, larlight::MSG::INFO, larlight::MSG::NORMAL, larlight::larlight_base::print(), ReadTree(), and larutil::LArUtilException::what().

Referenced by larutil::DetectorProperties::DetectorProperties(), larutil::LArProperties::LArProperties(), and larutil::LArUtilManager::ReconfigureUtilities().

00022   {
00023     if(!force_reload && _loaded) return true;
00024 
00025     print(larlight::MSG::INFO,__FUNCTION__,
00026       Form("Reading-in data for %s",_name.c_str()));
00027 
00028     if(_file_name.empty() || _tree_name.empty()) {
00029 
00030       throw LArUtilException(Form("Either file or tree name not specified to load data for %s",_name.c_str()));
00031       
00032       return false;
00033     }
00034 
00035     bool status=false;
00036     try {
00037 
00038       print(larlight::MSG::NORMAL, __FUNCTION__,
00039         Form("Loading data for %s...\n     file=%s ", _name.c_str(), _file_name.c_str()));
00040       ClearData();
00041       status = ReadTree();
00042       if(!status)
00043     throw LArUtilException("Failed to load !");
00044     }
00045     catch (LArUtilException &e) {
00046 
00047       print(larlight::MSG::ERROR, __FUNCTION__,
00048         Form("Failed loading data for %s...",_name.c_str()));
00049 
00050       print(larlight::MSG::ERROR, __FUNCTION__,
00051         e.what());
00052       
00053       throw e;
00054       status = false;
00055     }
00056 
00057     return status;
00058   }

void larlight::larlight_base::print ( MSG::Level  level,
std::string  msg 
) const [inline, inherited]

message print out method

Definition at line 56 of file larlight_base.hh.

00057     {if(_verbosity.at(level)) Message::send(level,msg);};

void larlight::larlight_base::print ( MSG::Level  level,
std::string  where,
std::string  msg 
) const [inline, inherited]
virtual bool larutil::LArUtilBase::ReadTree (  )  [protected, pure virtual]
void larlight::larlight_base::set_verbosity ( MSG::Level  level  )  [virtual, inherited]

Setter for the verbosity level.

Reimplemented in larlight::ana_processor.

Definition at line 8 of file larlight_base.cc.

References larlight::larlight_base::_verbosity, larlight::larlight_base::_verbosity_level, larlight::MSG::DEBUG, larlight::MSG::ERROR, larlight::MSG::INFO, larlight::MSG::MSG_TYPE_MAX, larlight::MSG::NORMAL, and larlight::MSG::WARNING.

Referenced by larlight::larlight_base::larlight_base(), main(), and larlight::ana_processor::set_verbosity().

00010   {
00011     
00012     _verbosity_level=level;
00013     
00014     for(size_t i=(size_t)(MSG::DEBUG); i<(size_t)(MSG::MSG_TYPE_MAX); ++i)
00015       _verbosity[i]=false;
00016     
00017     switch(level){
00018     case MSG::DEBUG:
00019       _verbosity[MSG::DEBUG]=true;
00020     case MSG::INFO:
00021       _verbosity[MSG::INFO]=true;
00022     case MSG::NORMAL:
00023       _verbosity[MSG::NORMAL]=true;
00024     case MSG::WARNING:
00025       _verbosity[MSG::WARNING]=true;
00026     case MSG::ERROR:
00027       _verbosity[MSG::ERROR]=true;
00028     case MSG::MSG_TYPE_MAX:
00029       break;
00030     }
00031     
00032   }

void larutil::LArUtilBase::SetFileName ( const std::string  filename  )  [inline]

Method to set data file name.

Definition at line 44 of file LArUtilBase.hh.

References _file_name.

Referenced by larutil::LArUtilManager::ReconfigureUtilities().

00045     { _file_name = filename; }

void larutil::LArUtilBase::SetTreeName ( const std::string  treename  )  [inline]

Method to set data TTree name.

Definition at line 48 of file LArUtilBase.hh.

References _tree_name.

Referenced by larutil::LArUtilManager::ReconfigureUtilities().

00049     { _tree_name = treename; }


Member Data Documentation

char larlight::larlight_base::_buf[200] [protected, inherited]

char buffer for message manipulation

Definition at line 57 of file larlight_base.hh.

Referenced by larlight::storage_manager::open(), larlight::storage_manager::prepare_tree(), and larlight::ana_processor::run().

std::string larutil::LArUtilBase::_file_name [protected]

Definition at line 62 of file LArUtilBase.hh.

Referenced by LArUtilBase(), and LoadData().

std::string larlight::larlight_base::_name [protected, inherited]
std::string larutil::LArUtilBase::_tree_name [protected]
std::vector<bool> larlight::larlight_base::_verbosity [protected, inherited]
MSG::Level larlight::larlight_base::_verbosity_level [protected, inherited]

holder for specified verbosity level

Definition at line 63 of file larlight_base.hh.

Referenced by larlight::larlight_base::get_verbosity(), larlight::ana_processor::initialize(), and larlight::larlight_base::set_verbosity().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Enumerations Enumerator

Generated on 3 Jun 2014 for MyProject by  doxygen 1.6.1