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 |
class CutSet : public Cut {
|
27 |
public:
|
28 |
void add(Cut *c) {cuts.push_back(c);}
|
29 |
bool pass(VHbbProxy &iProxy) {
|
30 |
bool result=true;
|
31 |
for(size_t i=0; i< cuts.size(); i++)
|
32 |
if( ! (cuts.at(i)->pass(iProxy)) )
|
33 |
result=false;
|
34 |
return result;
|
35 |
}
|
36 |
std::string name() {
|
37 |
std::stringstream s;
|
38 |
for(size_t i=0; i< cuts.size(); i++) {
|
39 |
s << "_" << cuts.at(i)->name();
|
40 |
}
|
41 |
return s.str();
|
42 |
}
|
43 |
|
44 |
private:
|
45 |
std::vector<Cut *> cuts;
|
46 |
|
47 |
};
|
48 |
|
49 |
class CutsAndHistos {
|
50 |
public:
|
51 |
CutsAndHistos() {}
|
52 |
CutsAndHistos(CutSet & c, std::vector<Histos *> & h):
|
53 |
cutset(c),
|
54 |
histos(h) {}
|
55 |
|
56 |
void book(TFile &f) {
|
57 |
std::string suffix=cutset.name();
|
58 |
for(size_t i=0; i< histos.size(); i++)
|
59 |
histos.at(i)->book(f,suffix);
|
60 |
}
|
61 |
|
62 |
void process(VHbbProxy & iProxy,float w)
|
63 |
{
|
64 |
if(cutset.pass(iProxy))
|
65 |
for(size_t i=0; i< histos.size(); i++)
|
66 |
histos.at(i)->fill(iProxy,w);
|
67 |
}
|
68 |
|
69 |
|
70 |
CutSet cutset;
|
71 |
std::vector<Histos *> histos;
|
72 |
|
73 |
};
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 |
#endif
|