10#ifndef _IDPVM_CutFlow_h_
11#define _IDPVM_CutFlow_h_
41 Accept(
const std::function<
bool(
const A&)>& predicate,
const std::string&
name =
"",
116 unsigned int missing_cuts =
m_cuts.size();
118 for (
auto& thisCut:
m_cuts) {
119 if (not thisCut.pass(value)) {
128 testAllCuts(
const A& value, std::vector<unsigned int> &counter)
const {
129 unsigned int idx = 0;
131 if (counter.size() !=
m_cuts.size()+2 ) {
132 throw std::logic_error(
"Number of cuts and counters do not match." );
134 unsigned int missing_cuts = 0;
136 for (
auto& thisCut:
m_cuts) {
137 if (!thisCut.pass(value)) { ++missing_cuts; }
138 else { ++(counter[idx]); }
151 std::vector<std::string>
155 for (
const auto& i:
m_cuts) {
204 m_counter = std::move(a_cutflow.m_counter);
210 throw std::logic_error(
"Tried to merge non matching cut_flows.");
212 std::vector<unsigned int>::iterator iter=
m_counter.begin();
213 for(
unsigned int count : a_cutflow.m_counter) {
225 report(
const std::vector<std::string> &names) {
228 for(std::vector<unsigned int>::reverse_iterator iter =
m_counter.rbegin();
239 std::string modeString = (
m_accumulateIntegrated) ?
"\nAll cuts were applied\n" :
"\nCuts were applied until one fails\n";
241 for (
unsigned int idx=0; idx<names.size(); ++idx) {
245 throw std::logic_error(std::string(
"Number of cuts and counters do not match. Resulting report:\n") + op );
Templated class containing a cut, name of cut and description of cut(optional) Typically,...
Accept()
Default constructor with a simple predicate returning false.
Accept(const std::function< bool(const A &)> &predicate, const std::string &name="", const std::string &description="")
Normal constructor.
const std::string & name() const
Return cut name.
A value_type
Utility typedefs to help callers: the value type.
bool operator()(const A &i) const
Overloading the () operator allows the class to be used as a functional.
const std::string & description() const
Return cut description.
const std::function< bool(const A &)> func_type
Utility typedefs to help callers: the function type.
bool pass(const A &i) const
Apply the predicate function and return the value, also updating an internal counter.
const std::vector< unsigned int > & counter() const
std::vector< unsigned int > & counter()
std::vector< unsigned int > m_counter
CutFlow(unsigned int n_cuts, CutMode cut_mode=UNTIL_FAIL)
void merge(CutFlow &&a_cutflow)
void update(unsigned int missing_cuts)
bool m_accumulateIntegrated
std::string report(const std::vector< std::string > &names)
Produce a formatted string report of the results.
CutList()
Default constructor with no cuts implemented.
unsigned int size() const
Return the number of cuts.
unsigned int accept(const A &value) const
Apply cuts and return the boolean result; keep count of number of calls and passes.
std::vector< std::string > names() const
Return a vector of the cut names.
void add(const Accept< A > &newCut)
Add one cut.
std::vector< Accept< A > > m_cuts
CutList(const std::vector< Accept< A > > &cuts)
Normal constructor takes a vector<Accept>. Note default mode is 'ALL'.
unsigned int testAllCuts(const A &value, std::vector< unsigned int > &counter) const
int count(std::string s, const std::string ®x)
count how many occurances of a regx are in a string
hold the test vectors and ease the comparison