ATLAS Offline Software
Loading...
Searching...
No Matches
CutFlow Class Reference

#include <CutFlow.h>

Collaboration diagram for CutFlow:

Public Types

enum  CutMode { ALL , UNTIL_FAIL }
enum  EReservedCuts { kAll , kIsValidParticle , kNReserved }

Public Member Functions

 CutFlow ()
 CutFlow (unsigned int n_cuts, CutMode cut_mode=UNTIL_FAIL)
std::vector< unsigned int > & counter ()
const std::vector< unsigned int > & counter () const
void update (unsigned int missing_cuts)
void merge (CutFlow &&a_cutflow)
void clear ()
std::string report (const std::vector< std::string > &names)
 Produce a formatted string report of the results.

Private Member Functions

void update (bool)

Private Attributes

std::vector< unsigned int > m_counter
bool m_integrated = false
bool m_accumulateIntegrated = false

Detailed Description

Definition at line 165 of file CutFlow.h.

Member Enumeration Documentation

◆ CutMode

Enumerator
ALL 
UNTIL_FAIL 

Definition at line 169 of file CutFlow.h.

169 {
171 };
@ UNTIL_FAIL
Definition CutFlow.h:170

◆ EReservedCuts

Enumerator
kAll 
kIsValidParticle 
kNReserved 

Definition at line 173 of file CutFlow.h.

173 {
174 kAll,
177 };
@ kIsValidParticle
Definition CutFlow.h:175
@ kNReserved
Definition CutFlow.h:176

Constructor & Destructor Documentation

◆ CutFlow() [1/2]

CutFlow::CutFlow ( )
inline

Definition at line 179 of file CutFlow.h.

179{}

◆ CutFlow() [2/2]

CutFlow::CutFlow ( unsigned int n_cuts,
CutMode cut_mode = UNTIL_FAIL )
inline

Definition at line 181 of file CutFlow.h.

182 : m_counter(n_cuts+kNReserved,0) ,
183 m_integrated( cut_mode == ALL ),
184 m_accumulateIntegrated( cut_mode == ALL )
185 {}
bool m_integrated
Definition CutFlow.h:252
std::vector< unsigned int > m_counter
Definition CutFlow.h:251
bool m_accumulateIntegrated
Definition CutFlow.h:253

Member Function Documentation

◆ clear()

void CutFlow::clear ( )
inline

Definition at line 219 of file CutFlow.h.

219 {
220 for(unsigned int &count : m_counter) {count=0; }
221 }
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:146

◆ counter() [1/2]

std::vector< unsigned int > & CutFlow::counter ( )
inline

Definition at line 187 of file CutFlow.h.

187{return m_counter; }

◆ counter() [2/2]

const std::vector< unsigned int > & CutFlow::counter ( ) const
inline

Definition at line 188 of file CutFlow.h.

188{return m_counter; }

◆ merge()

void CutFlow::merge ( CutFlow && a_cutflow)
inline

Definition at line 202 of file CutFlow.h.

202 {
203 if (m_counter.empty()) {
204 m_counter = std::move(a_cutflow.m_counter);
205 m_integrated = a_cutflow.m_integrated;
207 }
208 else {
209 if (m_counter.size() != a_cutflow.m_counter.size() || m_integrated != a_cutflow.m_integrated) {
210 throw std::logic_error("Tried to merge non matching cut_flows.");
211 }
212 std::vector<unsigned int>::iterator iter=m_counter.begin();
213 for(unsigned int count : a_cutflow.m_counter) {
214 *(iter++) += count;
215 }
216 }
217 }

◆ report()

std::string CutFlow::report ( const std::vector< std::string > & names)
inline

Produce a formatted string report of the results.

Definition at line 225 of file CutFlow.h.

225 {
226 if (not m_integrated) {
227 unsigned int sum=0;
228 for(std::vector<unsigned int>::reverse_iterator iter = m_counter.rbegin();
229 iter != m_counter.rend();
230 ++iter) {
231 *iter += sum;
232 sum = *iter;
233 };
234 m_integrated=true;
235 }
236
237 std::string op = "\nCutList Report; Total processed: " + std::to_string(m_counter[kIsValidParticle]);
238 op += "\nTotal passed: " + std::to_string(m_counter[m_counter.size()-1]);
239 std::string modeString = (m_accumulateIntegrated) ? "\nAll cuts were applied\n" : "\nCuts were applied until one fails\n";
240 op += modeString;
241 for (unsigned int idx=0; idx<names.size(); ++idx) {
242 op += names[idx] + ": " + std::to_string( idx+kNReserved<m_counter.size() ? m_counter[idx+kNReserved] : -1) + " passed\n";
243 }
244 if (names.size()+kNReserved != m_counter.size()) {
245 throw std::logic_error(std::string( "Number of cuts and counters do not match. Resulting report:\n") + op );
246 }
247 return op;
248 }

◆ update() [1/2]

void CutFlow::update ( bool )
inlineprivate

Definition at line 192 of file CutFlow.h.

192 {
193 }

◆ update() [2/2]

void CutFlow::update ( unsigned int missing_cuts)
inline

Definition at line 197 of file CutFlow.h.

197 {
198 assert( m_integrated == false);
199 ++(m_counter.at(m_counter.size()-missing_cuts-1) );
200 }

Member Data Documentation

◆ m_accumulateIntegrated

bool CutFlow::m_accumulateIntegrated = false
private

Definition at line 253 of file CutFlow.h.

◆ m_counter

std::vector<unsigned int> CutFlow::m_counter
private

Definition at line 251 of file CutFlow.h.

◆ m_integrated

bool CutFlow::m_integrated = false
private

Definition at line 252 of file CutFlow.h.


The documentation for this class was generated from the following file: