1 |
#include <iomanip>
|
2 |
|
3 |
#include "../include/Selection.h"
|
4 |
|
5 |
Selection::Selection(std::string name):
|
6 |
m_logger ( name.c_str() ){
|
7 |
|
8 |
m_name = name.c_str();
|
9 |
clearSelectionModulesList();
|
10 |
Ntotal=0;
|
11 |
m_isactive = true;
|
12 |
}
|
13 |
|
14 |
void Selection::resetCutFlow(){
|
15 |
Ntotal=0;
|
16 |
for(unsigned int i=0; i<m_cuts.size(); ++i){
|
17 |
m_cutflow[i]=0;
|
18 |
}
|
19 |
}
|
20 |
|
21 |
void Selection::addSelectionModule(SelectionModule* sel){
|
22 |
m_logger << DEBUG << "Adding selection module: " << sel->description() << SLogger::endmsg;
|
23 |
m_cuts.push_back(sel);
|
24 |
m_cutflow.push_back(0);
|
25 |
}
|
26 |
|
27 |
void Selection::clearSelectionModulesList(){
|
28 |
m_cuts.clear();
|
29 |
m_cutflow.clear();
|
30 |
Ntotal=0;
|
31 |
}
|
32 |
|
33 |
bool Selection::passSelection(BaseCycleContainer *bcc){
|
34 |
|
35 |
if (!m_isactive) return true; // always true if the selection is not active
|
36 |
|
37 |
Ntotal++;
|
38 |
if(m_cuts.size()!=m_cutflow.size()){
|
39 |
m_logger << WARNING << "size of cut list != number of entries in cut flow table "<< SLogger::endmsg;
|
40 |
}
|
41 |
for(unsigned int i=0; i<m_cuts.size(); ++i){
|
42 |
if(!m_cuts[i]->pass(bcc)) return false;
|
43 |
m_cutflow[i]++;
|
44 |
}
|
45 |
return true;
|
46 |
}
|
47 |
|
48 |
bool Selection::passInvertedSelection(BaseCycleContainer *bcc){
|
49 |
|
50 |
if (!m_isactive) return true; // always true if the selection is not active
|
51 |
|
52 |
for(unsigned int i=0; i<m_cuts.size(); ++i){
|
53 |
if(!m_cuts[i]->pass(bcc)) return true;
|
54 |
}
|
55 |
return false;
|
56 |
}
|
57 |
|
58 |
bool Selection::passSelection(){
|
59 |
EventCalc* calc = EventCalc::Instance();
|
60 |
BaseCycleContainer* bcc = calc->GetBaseCycleContainer();
|
61 |
return passSelection(bcc);
|
62 |
}
|
63 |
|
64 |
bool Selection::passInvertedSelection(){
|
65 |
EventCalc* calc = EventCalc::Instance();
|
66 |
BaseCycleContainer* bcc = calc->GetBaseCycleContainer();
|
67 |
return passInvertedSelection(bcc);
|
68 |
}
|
69 |
|
70 |
void Selection::printCutFlow(){
|
71 |
|
72 |
using namespace std;
|
73 |
|
74 |
m_logger << INFO << "--------------- Cut Flow Table of Selection " << m_name << " ---------------"<< SLogger::endmsg;
|
75 |
if (!m_isactive){
|
76 |
m_logger << INFO << "Selection was not active." << SLogger::endmsg;
|
77 |
m_logger << INFO << "-----------------------------------------------------------------------------"<< SLogger::endmsg;
|
78 |
return;
|
79 |
}
|
80 |
|
81 |
if(m_cuts.size()!=m_cutflow.size()){
|
82 |
m_logger << WARNING << "size of cut list != number of entries in cut flow table "<< SLogger::endmsg;
|
83 |
}
|
84 |
else{
|
85 |
m_logger << INFO << setw(12) << "Events" << " | Description" << SLogger::endmsg;
|
86 |
m_logger << INFO << "-------------+-----------------------------------------------------"<< SLogger::endmsg;
|
87 |
m_logger << INFO << setw(12) << Ntotal << " | Events entered the selection. " << SLogger::endmsg;
|
88 |
for(unsigned int i=0; i<m_cuts.size(); ++i){
|
89 |
m_logger << INFO << setw(12) << m_cutflow[i] << " | left after: " << m_cuts[i]->description() << SLogger::endmsg;
|
90 |
}
|
91 |
}
|
92 |
m_logger << INFO << "-------------+---------------------------------------------------------------"<< SLogger::endmsg;
|
93 |
|
94 |
}
|