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 |
tboccali |
1.1 |
class CutSet : public Cut {
|
52 |
|
|
public:
|
53 |
|
|
void add(Cut *c) {cuts.push_back(c);}
|
54 |
|
|
bool pass(VHbbProxy &iProxy) {
|
55 |
|
|
bool result=true;
|
56 |
|
|
for(size_t i=0; i< cuts.size(); i++)
|
57 |
|
|
if( ! (cuts.at(i)->pass(iProxy)) )
|
58 |
|
|
result=false;
|
59 |
|
|
return result;
|
60 |
|
|
}
|
61 |
|
|
std::string name() {
|
62 |
|
|
std::stringstream s;
|
63 |
|
|
for(size_t i=0; i< cuts.size(); i++) {
|
64 |
|
|
s << "_" << cuts.at(i)->name();
|
65 |
|
|
}
|
66 |
|
|
return s.str();
|
67 |
|
|
}
|
68 |
|
|
|
69 |
|
|
private:
|
70 |
|
|
std::vector<Cut *> cuts;
|
71 |
|
|
|
72 |
|
|
};
|
73 |
|
|
|
74 |
arizzi |
1.2 |
|
75 |
|
|
///CutSet of PCut, with scanning functions
|
76 |
|
|
class PCutSet : public Cut {
|
77 |
|
|
public:
|
78 |
|
|
void add(PCut *c) {cuts.push_back(c);}
|
79 |
|
|
bool pass(VHbbProxy &iProxy) {
|
80 |
|
|
bool result=true;
|
81 |
|
|
for(size_t i=0; i< cuts.size(); i++)
|
82 |
|
|
if( ! (cuts.at(i)->pass(iProxy)) )
|
83 |
|
|
result=false;
|
84 |
|
|
return result;
|
85 |
|
|
}
|
86 |
|
|
std::string name() {
|
87 |
|
|
std::stringstream s;
|
88 |
|
|
for(size_t i=0; i< cuts.size(); i++) {
|
89 |
|
|
s << "_" << cuts.at(i)->name();
|
90 |
|
|
}
|
91 |
|
|
return s.str();
|
92 |
|
|
}
|
93 |
|
|
|
94 |
|
|
private:
|
95 |
|
|
std::vector<PCut *> cuts;
|
96 |
|
|
|
97 |
|
|
};
|
98 |
|
|
|
99 |
|
|
|
100 |
|
|
|
101 |
tboccali |
1.1 |
class CutsAndHistos {
|
102 |
|
|
public:
|
103 |
|
|
CutsAndHistos() {}
|
104 |
arizzi |
1.2 |
CutsAndHistos(Cut * c, std::vector<Histos *> & h):
|
105 |
|
|
cut(c),
|
106 |
tboccali |
1.1 |
histos(h) {}
|
107 |
arizzi |
1.2 |
CutsAndHistos(Cut * c, Histos * h):
|
108 |
|
|
cut(c) {
|
109 |
|
|
histos.push_back(h);
|
110 |
|
|
}
|
111 |
|
|
//TODO: implement destructor for all pointers received
|
112 |
tboccali |
1.1 |
|
113 |
|
|
void book(TFile &f) {
|
114 |
arizzi |
1.2 |
std::string suffix=cut->name();
|
115 |
tboccali |
1.1 |
for(size_t i=0; i< histos.size(); i++)
|
116 |
|
|
histos.at(i)->book(f,suffix);
|
117 |
|
|
}
|
118 |
|
|
|
119 |
|
|
void process(VHbbProxy & iProxy,float w)
|
120 |
|
|
{
|
121 |
arizzi |
1.2 |
if(cut->pass(iProxy))
|
122 |
tboccali |
1.1 |
for(size_t i=0; i< histos.size(); i++)
|
123 |
|
|
histos.at(i)->fill(iProxy,w);
|
124 |
|
|
}
|
125 |
|
|
|
126 |
|
|
|
127 |
arizzi |
1.2 |
Cut * cut;
|
128 |
tboccali |
1.1 |
std::vector<Histos *> histos;
|
129 |
|
|
|
130 |
|
|
};
|
131 |
|
|
|
132 |
|
|
|
133 |
|
|
|
134 |
|
|
|
135 |
|
|
#endif
|