LDMX Software
|
A map of bus passengers. More...
#include <Bus.h>
Classes | |
class | Passenger |
A bus passenger. More... | |
class | Seat |
The handle of a bus passenger. More... | |
Public Member Functions | |
template<typename BaggageType > | |
const BaggageType & | get (const std::string &name) |
Get the baggage carried by the passenger with the passed name. | |
template<typename BaggageType > | |
void | board (const std::string &name) |
Board a new passenger onto the bus. | |
template<typename BaggageType > | |
void | update (const std::string &name, const BaggageType &obj) |
Update the object a passenger is carrying. | |
TBranch * | attach (TTree *tree, const std::string &name, bool can_create) |
Attach the input tree to the object a passenger is carrying. | |
bool | isOnBoard (const std::string &name) |
Check if a passenger is on the bus. | |
void | clear () |
Reset the objects carried by the passengers. | |
void | everybodyOff () |
Kicks all of the passengers off the bus and therefore destroys any objects they are carrying. | |
void | stream (std::ostream &s) const |
Write the bus to the input ostream. | |
Private Member Functions | |
template<typename BaggageType > | |
Passenger< BaggageType > & | getRef (const std::string &name) |
Get a reference to a passenger on the bus. | |
Private Attributes | |
std::unordered_map< std::string, std::unique_ptr< Seat > > | passengers_ |
Map of passenger names to the seats filled by passengers. | |
Friends | |
std::ostream & | operator<< (std::ostream &s, const framework::Bus &b) |
Allow for the bus to be streamed to an ostream. | |
A map of bus passengers.
This is the actual bus that the passengers ride on during event processing. At its core, it is simply a specialization of a map between branch names and handles to the bus passengers (Seats) with some special accessors for connecting TTrees and updating contents.
|
inline |
Attach the input tree to the object a passenger is carrying.
[in] | tree | pointer to TTree to attach to |
[in] | name | name of passenger (and branch of tree) |
[in] | can_create | true if we are allowed to create new branches on the tree |
Definition at line 107 of file Bus.h.
References passengers_.
Referenced by framework::Event::add(), framework::NtupleManager::addVar(), and framework::Event::getObject().
|
inline |
Board a new passenger onto the bus.
Creates a new passenger that carries an object of type BaggageType and puts this passenger into the map of passengers.
in] BaggageType type of object new passenger is carrying
[in] | name | Name of new passenger (corresponds to branch name) |
Definition at line 65 of file Bus.h.
References passengers_.
Referenced by framework::Event::add(), framework::NtupleManager::addVar(), and framework::Event::getObject().
|
inline |
Reset the objects carried by the passengers.
Definition at line 126 of file Bus.h.
References passengers_.
Referenced by framework::Event::Clear(), and framework::NtupleManager::clear().
|
inline |
Kicks all of the passengers off the bus and therefore destroys any objects they are carrying.
Definition at line 140 of file Bus.h.
References passengers_.
Referenced by framework::Event::onEndOfFile(), framework::NtupleManager::reset(), and framework::Event::setInputTree().
|
inline |
Get the baggage carried by the passenger with the passed name.
std::bad_cast | if BaggageType does not match type of object passenger is carrying |
in] BaggageType type of object carried by passenger
[in] | name | Name of Passenger (corresponds to branch_name) |
Definition at line 43 of file Bus.h.
Referenced by framework::Event::getObject().
|
inlineprivate |
Get a reference to a passenger on the bus.
std::bad_cast | if BaggageType does not match actual type of object the passenger is carrying. |
in] BaggageType type of object passenger is carrying
[in] | name | Name of passenger |
Definition at line 810 of file Bus.h.
References passengers_.
|
inline |
Check if a passenger is on the bus.
[in] | name | name of passenger to check for |
Definition at line 117 of file Bus.h.
References passengers_.
Referenced by framework::Event::add(), framework::NtupleManager::addVar(), framework::Event::getObject(), and framework::NtupleManager::setVar().
|
inline |
Write the bus to the input ostream.
Includes new-line characters to separate out the different objects carried on the bus.
[in] | s | ostream to write to |
Definition at line 150 of file Bus.h.
References passengers_.
|
inline |
Update the object a passenger is carrying.
std::bad_cast | if BaggageType does not match type of object passenger is carrying |
in] BaggageType type of object carried by passenger
[in] | name | name of passenger (corresponds to branch name) |
[in] | obj | update object that should be carried by passenger |
Definition at line 83 of file Bus.h.
Referenced by framework::Event::add(), and framework::NtupleManager::setVar().
|
friend |
Allow for the bus to be streamed to an ostream.
[in] | s | ostream to write to |
[in] | b | Bus to write out |
|
private |
Map of passenger names to the seats filled by passengers.
The passenger names are assumed to correspond to any branch name that the passenger's baggage might be attached to.
Definition at line 821 of file Bus.h.
Referenced by attach(), board(), clear(), everybodyOff(), getRef(), isOnBoard(), and stream().