Revision: | 1.8 |
Committed: | Tue Aug 23 10:54:50 2011 UTC (13 years, 8 months ago) by arizzi |
Content type: | text/plain |
Branch: | MAIN |
CVS Tags: | EDMV42_Step2_V8, EDMV42_Step2_V7, EDMV42_Step2_V6, EDMV42_Step2_V5a, EDMV42_Step2_V5, tauCandV42, hbbsubstructDev_11, hbbsubstructDev_10, hbbsubstructDev_9, hbbsubstructDev_8, hbbsubstructDev_7, hbbsubstructDev_6, hbbsubstructDev_5, hbbsubstructDev_4, hbbsubstructDev_3, hbbsubstructDev_2, hbbsubstructDev_1, hbbsubstructDev, V21TauCand_0, EDMV42_Step2_V4a, EDMV42_Step2_V4, EDMV42_Step2_V3, EDMV42_Step2_V2, EDMV42_Step2_V1, EdmV42, EdmV41alpha1, EdmV40alpha1, EdmV40alpha, V21emuCand, EdmV33Jun12v2_consistent, Step2ForV33_v2, Step2ForV33_v1, EdmV33Jun12v2, EdmV33Jun12v1, EdmV33Jun12v0, Step2ForV32_v2, Step2ForV32_v1, Step2ForV32_v0, Step2ForV31_v0, EdmV32May24v0, EdmV31May21v1, EdmV31May17v0, May14thStep2, EdmV30Apr10, EdmV21Apr10v2, EdmV22May9, EdmV21Apr06, EdmV21Apr10, EdmV21Apr04, EdmV21Apr03, EdmV21Apr2, EdmV21Mar30, EdmV20Mar12, AR_Nov10Ntuple, AR_step2_Oct25, AR_step2_oct19, EdmV11Oct2011, AR_Step2_Oct13, AR_Oct9Ntuple, AR_Oct7_step2ntuple, AR_Oct5Ntuple, EdmV10Oct2011, EdmV9Sept2011, Sept19th2011_2, Sept19th2011, Sept19th, VHNtupleV9_AR1, VHSept15_AR1, Sept14th2011_2, Sept14th2011_AR1, Sept14th2011, Sept13th2011, AR_Sep8_LightNtuple, VHBB_EDMNtupleV3, HEAD |
Branch point for: | V42TauCandidate, hbbsubstructDevPostHCP, V21TauCand, V21emuCandidate |
Changes since 1.7: | +1 -0 lines |
Log Message: | cleanup histo maker and make functions for booking |
# | 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 | arizzi | 1.8 | // virtual Histos * clone() =0; |
18 | tboccali | 1.1 | }; |
19 | |||
20 | class Cut { | ||
21 | public: | ||
22 | virtual bool pass(VHbbProxy &) = 0; | ||
23 | virtual std::string name() = 0; | ||
24 | virtual bool operator()(VHbbProxy &iProxy) {return pass(iProxy); } | ||
25 | }; | ||
26 | |||
27 | arizzi | 1.3 | class NoCut : public Cut { |
28 | public: | ||
29 | virtual bool pass(VHbbProxy &) { return true;} | ||
30 | virtual std::string name() {return "NoCut"; } | ||
31 | }; | ||
32 | |||
33 | arizzi | 1.2 | /// One parameter cut class |
34 | class PCut : public Cut | ||
35 | { | ||
36 | public: | ||
37 | PCut(float cut) : m_cut(cut) {} | ||
38 | void setCut(float cut) {m_cut=cut;} | ||
39 | |||
40 | std::string cutValueString() | ||
41 | { | ||
42 | std::stringstream s; | ||
43 | s << m_cut; | ||
44 | return s.str(); | ||
45 | } | ||
46 | |||
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 | arizzi | 1.7 | bool pass(VHbbProxy &iProxy) { |
55 | tboccali | 1.1 | bool result=true; |
56 | arizzi | 1.7 | for(size_t i=0; i< cuts.size() ; i++) |
57 | tboccali | 1.1 | if( ! (cuts.at(i)->pass(iProxy)) ) |
58 | result=false; | ||
59 | return result; | ||
60 | } | ||
61 | arizzi | 1.7 | std::string name() { |
62 | tboccali | 1.1 | std::stringstream s; |
63 | arizzi | 1.7 | for(size_t i=0; i< cuts.size() ; i++) { |
64 | tboccali | 1.1 | 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 | arizzi | 1.5 | // to be implemented still |
77 | arizzi | 1.2 | class PCutSet : public Cut { |
78 | public: | ||
79 | void add(PCut *c) {cuts.push_back(c);} | ||
80 | bool pass(VHbbProxy &iProxy) { | ||
81 | bool result=true; | ||
82 | for(size_t i=0; i< cuts.size(); i++) | ||
83 | if( ! (cuts.at(i)->pass(iProxy)) ) | ||
84 | result=false; | ||
85 | return result; | ||
86 | } | ||
87 | std::string name() { | ||
88 | std::stringstream s; | ||
89 | for(size_t i=0; i< cuts.size(); i++) { | ||
90 | s << "_" << cuts.at(i)->name(); | ||
91 | } | ||
92 | return s.str(); | ||
93 | } | ||
94 | |||
95 | private: | ||
96 | std::vector<PCut *> cuts; | ||
97 | |||
98 | }; | ||
99 | |||
100 | |||
101 | |||
102 | tboccali | 1.1 | class CutsAndHistos { |
103 | public: | ||
104 | CutsAndHistos() {} | ||
105 | arizzi | 1.2 | CutsAndHistos(Cut * c, std::vector<Histos *> & h): |
106 | cut(c), | ||
107 | tboccali | 1.1 | histos(h) {} |
108 | arizzi | 1.2 | CutsAndHistos(Cut * c, Histos * h): |
109 | cut(c) { | ||
110 | histos.push_back(h); | ||
111 | } | ||
112 | //TODO: implement destructor for all pointers received | ||
113 | tboccali | 1.1 | |
114 | void book(TFile &f) { | ||
115 | arizzi | 1.2 | std::string suffix=cut->name(); |
116 | tboccali | 1.1 | for(size_t i=0; i< histos.size(); i++) |
117 | histos.at(i)->book(f,suffix); | ||
118 | } | ||
119 | |||
120 | void process(VHbbProxy & iProxy,float w) | ||
121 | { | ||
122 | arizzi | 1.2 | if(cut->pass(iProxy)) |
123 | tboccali | 1.1 | for(size_t i=0; i< histos.size(); i++) |
124 | histos.at(i)->fill(iProxy,w); | ||
125 | } | ||
126 | |||
127 | |||
128 | arizzi | 1.2 | Cut * cut; |
129 | tboccali | 1.1 | std::vector<Histos *> histos; |
130 | |||
131 | }; | ||
132 | |||
133 | |||
134 | |||
135 | |||
136 | #endif |