ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/VHbbAnalysis/VHbbDataFormats/interface/CutsAndHistos.h
Revision: 1.2
Committed: Sun Jul 24 11:27:00 2011 UTC (13 years, 9 months ago) by arizzi
Content type: text/plain
Branch: MAIN
CVS Tags: HBB_EDMNtupleV1_ProcV2, Jul28th2011, Jul26th2011, Jul25th2011
Changes since 1.1: +56 -6 lines
Log Message:
implement control region in old DF

File Contents

# User Rev Content
1 tboccali 1.1 #ifndef CUTANDHISTOS_H
2     #define CUTANDHISTOS_H
3     #include "VHbbAnalysis/VHbbDataFormats/interface/VHbbEvent.h"
4     #include "VHbbAnalysis/VHbbDataFormats/interface/VHbbProxy.h"
5     #include <string>
6     #include <sstream>
7     #include <vector>
8     #include <TROOT.h>
9     #include <TFile.h>
10    
11     class VHbbEvent;
12    
13     class Histos {
14     public:
15     virtual void book(TFile &f, std::string suffix) = 0;
16     virtual void fill(VHbbProxy &, float w) = 0;
17     };
18    
19     class Cut {
20     public:
21     virtual bool pass(VHbbProxy &) = 0;
22     virtual std::string name() = 0;
23     virtual bool operator()(VHbbProxy &iProxy) {return pass(iProxy); }
24     };
25    
26 arizzi 1.2 /// One parameter cut class
27     class PCut : public Cut
28     {
29     public:
30     PCut(float cut) : m_cut(cut) {}
31     void setCut(float cut) {m_cut=cut;}
32    
33     std::string cutValueString()
34     {
35     std::stringstream s;
36     s << m_cut;
37     return s.str();
38     }
39    
40     private:
41     float m_cut;
42    
43     };
44    
45 tboccali 1.1 class CutSet : public Cut {
46     public:
47     void add(Cut *c) {cuts.push_back(c);}
48     bool pass(VHbbProxy &iProxy) {
49     bool result=true;
50     for(size_t i=0; i< cuts.size(); i++)
51     if( ! (cuts.at(i)->pass(iProxy)) )
52     result=false;
53     return result;
54     }
55     std::string name() {
56     std::stringstream s;
57     for(size_t i=0; i< cuts.size(); i++) {
58     s << "_" << cuts.at(i)->name();
59     }
60     return s.str();
61     }
62    
63     private:
64     std::vector<Cut *> cuts;
65    
66     };
67    
68 arizzi 1.2
69     ///CutSet of PCut, with scanning functions
70     class PCutSet : public Cut {
71     public:
72     void add(PCut *c) {cuts.push_back(c);}
73     bool pass(VHbbProxy &iProxy) {
74     bool result=true;
75     for(size_t i=0; i< cuts.size(); i++)
76     if( ! (cuts.at(i)->pass(iProxy)) )
77     result=false;
78     return result;
79     }
80     std::string name() {
81     std::stringstream s;
82     for(size_t i=0; i< cuts.size(); i++) {
83     s << "_" << cuts.at(i)->name();
84     }
85     return s.str();
86     }
87    
88     private:
89     std::vector<PCut *> cuts;
90    
91     };
92    
93    
94    
95 tboccali 1.1 class CutsAndHistos {
96     public:
97     CutsAndHistos() {}
98 arizzi 1.2 CutsAndHistos(Cut * c, std::vector<Histos *> & h):
99     cut(c),
100 tboccali 1.1 histos(h) {}
101 arizzi 1.2 CutsAndHistos(Cut * c, Histos * h):
102     cut(c) {
103     histos.push_back(h);
104     }
105     //TODO: implement destructor for all pointers received
106 tboccali 1.1
107     void book(TFile &f) {
108 arizzi 1.2 std::string suffix=cut->name();
109 tboccali 1.1 for(size_t i=0; i< histos.size(); i++)
110     histos.at(i)->book(f,suffix);
111     }
112    
113     void process(VHbbProxy & iProxy,float w)
114     {
115 arizzi 1.2 if(cut->pass(iProxy))
116 tboccali 1.1 for(size_t i=0; i< histos.size(); i++)
117     histos.at(i)->fill(iProxy,w);
118     }
119    
120    
121 arizzi 1.2 Cut * cut;
122 tboccali 1.1 std::vector<Histos *> histos;
123    
124     };
125    
126    
127    
128    
129     #endif