ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/UHHAnalysis/SFrameTools/src/Selection.cxx
Revision: 1.3
Committed: Wed Jun 6 15:29:09 2012 UTC (12 years, 11 months ago) by peiffer
Content type: text/plain
Branch: MAIN
Changes since 1.2: +12 -0 lines
Log Message:
Selection without BaseCycleContainer as argument

File Contents

# Content
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 }
12
13 void Selection::addSelectionModule(SelectionModule* sel){
14 m_cuts.push_back(sel);
15 m_cutflow.push_back(0);
16 }
17
18 void Selection::clearSelectionModulesList(){
19 m_cuts.clear();
20 m_cutflow.clear();
21 Ntotal=0;
22 }
23
24 bool Selection::passSelection(BaseCycleContainer *bcc){
25 Ntotal++;
26 if(m_cuts.size()!=m_cutflow.size()){
27 m_logger << WARNING << "size of cut list != number of entries in cut flow table "<< SLogger::endmsg;
28 }
29 for(unsigned int i=0; i<m_cuts.size(); ++i){
30 if(!m_cuts[i]->pass(bcc)) return false;
31 m_cutflow[i]++;
32 }
33 return true;
34 }
35
36 bool Selection::passInvertedSelection(BaseCycleContainer *bcc){
37
38 for(unsigned int i=0; i<m_cuts.size(); ++i){
39 if(!m_cuts[i]->pass(bcc)) return true;
40 }
41 return false;
42 }
43
44 bool Selection::passSelection(){
45 ObjectHandler* objs = ObjectHandler::Instance();
46 BaseCycleContainer* bcc = objs->GetBaseCycleContainer();
47 return passSelection(bcc);
48 }
49
50 bool Selection::passInvertedSelection(){
51 ObjectHandler* objs = ObjectHandler::Instance();
52 BaseCycleContainer* bcc = objs->GetBaseCycleContainer();
53 return passInvertedSelection(bcc);
54 }
55
56 void Selection::printCutFlow(){
57
58 using namespace std;
59
60 m_logger << INFO << "-------------------------- Cut Flow Table -------------------------"<< SLogger::endmsg;
61 if(m_cuts.size()!=m_cutflow.size()){
62 m_logger << WARNING << "size of cut list != number of entries in cut flow table "<< SLogger::endmsg;
63 }
64 else{
65 m_logger << INFO << setw(12) << "Events" << " | Description" << SLogger::endmsg;
66 m_logger << INFO << "-------------+-----------------------------------------------------"<< SLogger::endmsg;
67 m_logger << INFO << setw(12) << Ntotal << " | Events entered the selection. " << SLogger::endmsg;
68 for(unsigned int i=0; i<m_cuts.size(); ++i){
69 m_logger << INFO << setw(12) << m_cutflow[i] << " | left after: " << m_cuts[i]->description() << SLogger::endmsg;
70 }
71 }
72 m_logger << INFO << "-------------+-----------------------------------------------------"<< SLogger::endmsg;
73
74 }