3#include "TBranchElement.h"
7Event::Event(
const std::string& thePassName) : pass_name_(thePassName) {}
17 std::cout << tag << std::endl;
23 if (!regcomp(®, exp.c_str(), REG_EXTENDED | REG_ICASE | REG_NOSUB)) {
26 EXCEPTION_RAISE(
"InvalidRegex",
"The passed drop rule regex '" + exp +
27 "' is not a valid regex.");
48 bool full_string_match) {
49 std::string pattern_regex{pattern};
50 if (pattern_regex.empty())
52 else if (full_string_match)
53 pattern_regex =
"^" + pattern_regex +
"$";
56 if (regcomp(®, pattern_regex.c_str(),
57 REG_EXTENDED | REG_ICASE | REG_NOSUB)) {
60 EXCEPTION_RAISE(
"InvalidRegex",
"The passed regex '" + pattern +
61 "' is not a valid regular expression.");
67 const std::string& passmatch,
68 const std::string& typematch,
69 bool full_string_match)
const {
70 std::vector<ProductTag> retval;
76 const std::vector<ProductTag>& products =
getProducts();
77 for (std::vector<ProductTag>::const_iterator i = products.begin();
78 i != products.end(); i++) {
79 if (!regexec(®_name, i->name().c_str(), 0, 0, 0) &&
80 !regexec(®_pass, i->passname().c_str(), 0, 0, 0) &&
81 !regexec(®_type, i->type().c_str(), 0, 0, 0))
94 static const bool require_full_string_match =
true;
95 auto matches =
searchProducts(name, passName,
"", require_full_string_match);
97 return (matches.size() == 1);
99 return (matches.size() > 0);
123 TObjArray* branches =
input_tree_->GetListOfBranches();
127 "Input tree doesn't have a list of branches but still made it to this "
128 "point. This is bad and has never been seen before!");
131 for (
int i = 0; i < branches->GetEntriesFast(); i++) {
133 if (branches->At(i)) {
134 brname = branches->At(i)->GetName();
137 size_t j = brname.find(
"_");
138 auto br =
dynamic_cast<TBranchElement*
>(branches->At(i));
145 brname.substr(j + 1),
146 br ? br->GetClassName() :
"BSILFD");
183 if (!regexec(&exp, branch_name.c_str(), 0, 0, 0))
return true;
Class implementing an event buffer system for storing event data.
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.
bool exists(const std::string &name, const std::string &passName, bool unique=true) const
Check for the existence of an object or collection with the given name and pass name in the event.
TTree * input_tree_
The input tree for reading existing data.
std::vector< ProductTag > products_
List of all the event products.
std::vector< ProductTag > searchProducts(const std::string &namematch, const std::string &passmatch, const std::string &typematch, bool full_string_match=false) const
Get a list of products which match the given POSIX-Extended, case-insenstive regular-expressions.
void clear()
Clear this object's data (including passengers).
~Event()
Class destructor.
void onEndOfFile()
Perform end of file action.
TTree * createTree()
Create the output data tree.
ldmx::EventHeader event_header_
The event header object.
void setOutputTree(TTree *tree)
Set the output data tree.
void beforeFill()
Action to be executed before the tree is filled.
void onEndOfEvent()
Perform end of event action (doesn't do anything right now).
const std::vector< ProductTag > & getProducts() const
Get a list of the data products in the event.
framework::Bus bus_
The Bus.
Event(const std::string &passName)
Class constructor.
const T & getObject(const std::string &collectionName, const std::string &passName) const
Get an general object from the event bus.
std::set< std::string > branches_filled_
Names of branches filled during this event.
bool nextEvent()
Go to the next event by retrieving the event header.
std::vector< regex_t > regex_drop_collections_
Regex of collection names to not store in event.
void setInputTree(TTree *tree)
Set the input data tree.
void print() const
Print event bus.
void add(const std::string &collectionName, T &obj)
Adds an object to the event bus.
bool shouldDrop(const std::string &collName) const
Check if collection should be dropped.
TTree * output_tree_
The output tree for writing a new file.
std::map< std::string, std::string > known_lookups_
Efficiency cache for empty pass name lookups.
void addDrop(const std::string &exp)
Add a drop rule to the list of regex expressions to drop.
Defines the identity of a product and can be used for searches.
All classes in the ldmx-sw project use this namespace.
static regex_t constructRegex(const std::string &pattern, bool full_string_match)
Construct an actual regex from the pass pattern (and full-string flag)