ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/VHbbAnalysis/VHbbDataFormats/interface/CutsAndHistos.h
Revision: 1.4
Committed: Tue Aug 9 09:35:47 2011 UTC (13 years, 8 months ago) by arizzi
Content type: text/plain
Branch: MAIN
CVS Tags: AndreaAug10th
Changes since 1.3: +7 -0 lines
Log Message:
add methods for transverse mass computation

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.3 class NoCut : public Cut {
27     public:
28     virtual bool pass(VHbbProxy &) { return true;}
29     virtual std::string name() {return "NoCut"; }
30     };
31    
32 arizzi 1.2 /// One parameter cut class
33     class PCut : public Cut
34     {
35     public:
36     PCut(float cut) : m_cut(cut) {}
37     void setCut(float cut) {m_cut=cut;}
38    
39     std::string cutValueString()
40     {
41     std::stringstream s;
42     s << m_cut;
43     return s.str();
44     }
45    
46     private:
47     float m_cut;
48    
49     };
50    
51 arizzi 1.4 /*class HPtCut : public PCut
52     {
53     public:
54     bool pass(VHbbProxy &p) {return 0; } //p.C.H.Pt() > m_cut;}
55     virtual std::string name() {return "HPt_Gt_"+cutValueString(); }
56     };*/
57    
58 tboccali 1.1 class CutSet : public Cut {
59     public:
60     void add(Cut *c) {cuts.push_back(c);}
61     bool pass(VHbbProxy &iProxy) {
62     bool result=true;
63     for(size_t i=0; i< cuts.size(); i++)
64     if( ! (cuts.at(i)->pass(iProxy)) )
65     result=false;
66     return result;
67     }
68     std::string name() {
69     std::stringstream s;
70     for(size_t i=0; i< cuts.size(); i++) {
71     s << "_" << cuts.at(i)->name();
72     }
73     return s.str();
74     }
75    
76     private:
77     std::vector<Cut *> cuts;
78    
79     };
80    
81 arizzi 1.2
82     ///CutSet of PCut, with scanning functions
83     class PCutSet : public Cut {
84     public:
85     void add(PCut *c) {cuts.push_back(c);}
86     bool pass(VHbbProxy &iProxy) {
87     bool result=true;
88     for(size_t i=0; i< cuts.size(); i++)
89     if( ! (cuts.at(i)->pass(iProxy)) )
90     result=false;
91     return result;
92     }
93     std::string name() {
94     std::stringstream s;
95     for(size_t i=0; i< cuts.size(); i++) {
96     s << "_" << cuts.at(i)->name();
97     }
98     return s.str();
99     }
100    
101     private:
102     std::vector<PCut *> cuts;
103    
104     };
105    
106    
107    
108 tboccali 1.1 class CutsAndHistos {
109     public:
110     CutsAndHistos() {}
111 arizzi 1.2 CutsAndHistos(Cut * c, std::vector<Histos *> & h):
112     cut(c),
113 tboccali 1.1 histos(h) {}
114 arizzi 1.2 CutsAndHistos(Cut * c, Histos * h):
115     cut(c) {
116     histos.push_back(h);
117     }
118     //TODO: implement destructor for all pointers received
119 tboccali 1.1
120     void book(TFile &f) {
121 arizzi 1.2 std::string suffix=cut->name();
122 tboccali 1.1 for(size_t i=0; i< histos.size(); i++)
123     histos.at(i)->book(f,suffix);
124     }
125    
126     void process(VHbbProxy & iProxy,float w)
127     {
128 arizzi 1.2 if(cut->pass(iProxy))
129 tboccali 1.1 for(size_t i=0; i< histos.size(); i++)
130     histos.at(i)->fill(iProxy,w);
131     }
132    
133    
134 arizzi 1.2 Cut * cut;
135 tboccali 1.1 std::vector<Histos *> histos;
136    
137     };
138    
139    
140    
141    
142     #endif