cafe::EventBase Class Reference
[CAF Environment (Cafe)]

#include <EventBase.hpp>

Inheritance diagram for cafe::EventBase:

cafe::Event List of all members.

Detailed Description

CAF tree independent part of Event.

This class provides three generic services:

  1. Access to an arbitrary branch in the associated TTree
  2. Access to an intermediate store for arbitrary values
  3. Tagging of events.

Definition at line 33 of file EventBase.hpp.

Public Member Functions

 EventBase ()
virtual ~EventBase ()
TTree * getTree () const
 Get current TTree.

int getCookie () const
 Get current cookie (== tree number).

 ClassDef (EventBase, 0)
Access to branches in the tree.
template<typename T> const T * get (const std::string &branchName, const Variables &vars=cafe::detail::empty) const
 Return a pointer to the object corresponding to branch 'branchName'.

template<typename T> Collection< T > getCollection (const std::string &branchName, const Variables &vars=cafe::detail::empty) const
 Return a Collection<T> corresponding to the TClonesArray in 'branchName'.

const TClonesArray * getClonesArray (const std::string &branchName, const Variables &vars=cafe::detail::empty) const
 Return the TClonesArray for the given branch.

bool readBranch (const std::string &branchName)
 Read this branch if not already in memory.

void setBranchAddresses (TTree *tree)
 Called when the tree changes.

bool setPartialRead (bool allow)
 Allow/Disallow partial reading of objects.

bool getPartialRead () const
 Get partial read flag.

Access to intermediate values stored in Event.
template<typename T> void put (const std::string &key, const T &value)
 Store arbitrary value with key.

void clear (const std::string &key)
template<typename T> bool get (const std::string &key, T &value) const
 Retrieve arbitrary value with key.

void clear ()
 Clear any values kept in the event store.

std::vector< std::string > * varnames ()
std::vector< std::string > * vartypes ()
Tagging
void tag (const std::string &name)
 Tag the event with 'name'.

template<typename ITER> void tag (ITER from, ITER to)
 Tag the events with all tags in the list 'C' can be any STL container.

bool hasTag (const std::string &name) const
 Check if event is tagged with 'name'.

bool hasTag (const char *name) const
 Check if event is tagged with 'name'.

template<typename C> bool hasTag (const C &c) const
 Check if event has any of the tags in the list 'C' can be any STL container.

void untag (const std::string &name)
 Remove tag with 'name'.

template<typename ITER> void untag (ITER from, ITER to)
 Remove all of the tags in the list 'C' can be any STL container.

ostream & printTags (ostream &os) const
 Print all tags in the event.


Private Types

typedef std::map< std::string,
BaseHolder * > 
Map
typedef std::map< std::string,
BranchHolderBase * > 
BranchMap

Private Attributes

Map _map
TTree * _tree
BranchMap _branches
std::set< std::string > _tags
int _cookie
bool _partial_read
UInt_t _objectCount


Member Typedef Documentation

typedef std::map<std::string,BranchHolderBase*> cafe::EventBase::BranchMap [private]
 

Definition at line 203 of file EventBase.hpp.

typedef std::map<std::string, BaseHolder*> cafe::EventBase::Map [private]
 

Definition at line 187 of file EventBase.hpp.


Constructor & Destructor Documentation

cafe::EventBase::EventBase  ) 
 

Definition at line 19 of file EventBase.cpp.

cafe::EventBase::~EventBase  )  [virtual]
 

Definition at line 27 of file EventBase.cpp.


Member Function Documentation

cafe::EventBase::ClassDef EventBase  ,
 

Reimplemented in cafe::Event.

void cafe::EventBase::clear  ) 
 

Clear any values kept in the event store.

Definition at line 69 of file EventBase.cpp.

References _map, _objectCount, _tags, cafe::Stat::eventEnd(), and STAT.

void cafe::EventBase::clear const std::string &  key  ) 
 

Definition at line 94 of file EventBase.cpp.

References _map.

Referenced by cafe::EventMultiSplitter::processPermutation(), and cafe::RunController::processTree().

template<typename T>
bool cafe::EventBase::get const std::string &  key,
T &  value
const
 

Retrieve arbitrary value with key.

Definition at line 362 of file EventBase.hpp.

References _map, and cafe::EventBase::Holder< T >::value().

template<typename T>
const T * cafe::EventBase::get const std::string &  branchName,
const Variables vars = cafe::detail::empty
const
 

Return a pointer to the object corresponding to branch 'branchName'.

If the branch does not exist, return 0.

Definition at line 263 of file EventBase.hpp.

References _branches, _cookie, _partial_read, _tree, cafe::EventBase::BranchHolder< T >::getObject(), and cafe::EventBase::BranchHolder< T >::setBranchAddress().

Referenced by cafe::Trigger::processEvent(), cafe::Stat::processEvent(), cafe::SelectObjects::processEvent(), cafe::RemoveObjects::processEvent(), cafe::Hist3D::processEvent(), cafe::Hist2D::processEvent(), and cafe::Hist1D::processEvent().

const TClonesArray * cafe::EventBase::getClonesArray const std::string &  branchName,
const Variables vars = cafe::detail::empty
const
 

Return the TClonesArray for the given branch.

Definition at line 158 of file EventBase.cpp.

References _branches, _cookie, _partial_read, _tree, cafe::EventBase::BranchHolder< T >::getObject(), and cafe::EventBase::BranchHolder< T >::setBranchAddress().

Referenced by cafe::RemoveObjects::processEvent(), cafe::Hist1D::processEvent(), and cafe::AssociatedTracks::processEvent().

template<typename T>
Collection< T > cafe::EventBase::getCollection const std::string &  branchName,
const Variables vars = cafe::detail::empty
const
 

Return a Collection<T> corresponding to the TClonesArray in 'branchName'.

If the branch does not exist, return an empty Collection<T>.

Definition at line 275 of file EventBase.hpp.

References _branches, _cookie, _partial_read, _tree, cafe::EventBase::BranchHolder< T >::getObject(), and cafe::EventBase::BranchHolder< T >::setBranchAddress().

Referenced by cafe::RandomSelectUserObjects< T >::processEvent(), and cafe::AssociatedTracks::processEvent().

int cafe::EventBase::getCookie  )  const
 

Get current cookie (== tree number).

Definition at line 153 of file EventBase.cpp.

References _cookie.

Referenced by cafe::SelectBranches::SelectBranches().

bool cafe::EventBase::getPartialRead  )  const
 

Get partial read flag.

Definition at line 64 of file EventBase.cpp.

References _partial_read.

TTree * cafe::EventBase::getTree  )  const
 

Get current TTree.

Definition at line 148 of file EventBase.cpp.

References _tree.

Referenced by cafe::SelectObjects::processEvent(), cafe::RandomProcessor::processEvent(), cafe::EventList::processEvent(), and cafe::SelectBranches::SelectBranches().

template<typename C>
bool cafe::EventBase::hasTag const C &  c  )  const
 

Check if event has any of the tags in the list 'C' can be any STL container.

Definition at line 380 of file EventBase.hpp.

References _tags.

bool cafe::EventBase::hasTag const char *  name  )  const
 

Check if event is tagged with 'name'.

Definition at line 130 of file EventBase.cpp.

References _tags.

bool cafe::EventBase::hasTag const std::string &  name  )  const
 

Check if event is tagged with 'name'.

Definition at line 125 of file EventBase.cpp.

References _tags.

Referenced by cafe::EventList::processEvent(), and cafe::StatSample::tagged().

ostream & cafe::EventBase::printTags ostream &  os  )  const
 

Print all tags in the event.

Definition at line 140 of file EventBase.cpp.

References _tags.

template<typename T>
void cafe::EventBase::put const std::string &  key,
const T &  value
 

Store arbitrary value with key.

The value must be copy constructible and assignable. If you store primitive types, make sure to tell it exactly which type you mean, e.g.:

event.put("MyValue", (int )5); int x; event.get("MyValue", x);

If you store a pointer, the pointer will be deleted at the end of the current event processing.

If you want the pointer to be preserved, call the method like this:

SomePointer *ptr = ...; event.put("MyName", keep(ptr));

where 'keep' is defined in the 'cafe' namespace.

Note that the entry "MyName" in the Event is still cleared at the end of the current event processing.

Definition at line 351 of file EventBase.hpp.

References _map.

Referenced by cafe::Stat::processEvent(), and cafe::AssociatedTracks::processEvent().

bool cafe::EventBase::readBranch const std::string &  branchName  ) 
 

Read this branch if not already in memory.

Definition at line 44 of file EventBase.cpp.

References _branches, _tree, and cafe::EventBase::BranchHolderBase::readBranch().

Referenced by cafe::Write::processEvent(), and cafe::RandomSelectUserObjects< T >::processEvent().

void cafe::EventBase::setBranchAddresses TTree *  tree  ) 
 

Called when the tree changes.

Set addresses for reading Branches.

Definition at line 33 of file EventBase.cpp.

References _branches, _cookie, and _tree.

Referenced by cafe::Selector::Init(), and cafe::RunController::processTree().

bool cafe::EventBase::setPartialRead bool  allow  ) 
 

Allow/Disallow partial reading of objects.

Returns old value. Default is true.

Definition at line 57 of file EventBase.cpp.

References _partial_read.

Referenced by cafe::RunController::Run().

template<typename ITER>
void cafe::EventBase::tag ITER  from,
ITER  to
 

Tag the events with all tags in the list 'C' can be any STL container.

Definition at line 393 of file EventBase.hpp.

References tag().

void cafe::EventBase::tag const std::string &  name  ) 
 

Tag the event with 'name'.

Definition at line 120 of file EventBase.cpp.

References _tags.

Referenced by cafe::Stat::processEvent(), cafe::Select::processEvent(), cafe::OR::processEvent(), cafe::IfPr::processEvent(), cafe::If::processEvent(), cafe::Fork::processEvent(), cafe::Controller::processEvent(), and tag().

template<typename ITER>
void cafe::EventBase::untag ITER  from,
ITER  to
 

Remove all of the tags in the list 'C' can be any STL container.

Definition at line 403 of file EventBase.hpp.

References untag().

void cafe::EventBase::untag const std::string &  name  ) 
 

Remove tag with 'name'.

Definition at line 135 of file EventBase.cpp.

References _tags.

Referenced by cafe::OR::processEvent(), cafe::IfPr::processEvent(), cafe::If::processEvent(), cafe::Fork::processEvent(), cafe::Controller::processEvent(), and untag().

std::vector< std::string > * cafe::EventBase::varnames  ) 
 

Definition at line 104 of file EventBase.cpp.

References _map.

std::vector< std::string > * cafe::EventBase::vartypes  ) 
 

Definition at line 112 of file EventBase.cpp.

References _map.


Member Data Documentation

BranchMap cafe::EventBase::_branches [mutable, private]
 

Definition at line 222 of file EventBase.hpp.

Referenced by get(), getClonesArray(), getCollection(), readBranch(), and setBranchAddresses().

int cafe::EventBase::_cookie [private]
 

Definition at line 224 of file EventBase.hpp.

Referenced by get(), getClonesArray(), getCollection(), getCookie(), and setBranchAddresses().

Map cafe::EventBase::_map [private]
 

Definition at line 188 of file EventBase.hpp.

Referenced by clear(), get(), put(), varnames(), and vartypes().

UInt_t cafe::EventBase::_objectCount [private]
 

Definition at line 226 of file EventBase.hpp.

Referenced by clear().

bool cafe::EventBase::_partial_read [private]
 

Definition at line 225 of file EventBase.hpp.

Referenced by get(), getClonesArray(), getCollection(), getPartialRead(), and setPartialRead().

std::set<std::string> cafe::EventBase::_tags [private]
 

Definition at line 223 of file EventBase.hpp.

Referenced by clear(), hasTag(), printTags(), tag(), and untag().

TTree* cafe::EventBase::_tree [private]
 

Definition at line 221 of file EventBase.hpp.

Referenced by get(), getClonesArray(), getCollection(), getTree(), readBranch(), and setBranchAddresses().


The documentation for this class was generated from the following files:
Generated on Thu Apr 3 04:14:27 2008 for CAF by doxygen 1.3.4