ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/rootEWKanalyzer/include/baseClass.h
Revision: 1.1
Committed: Mon Jun 7 14:57:39 2010 UTC (14 years, 10 months ago) by jueugste
Content type: text/plain
Branch: MAIN
Log Message:
first commit

File Contents

# Content
1 #ifndef baseClass_h
2 #define baseClass_h
3
4 #include "rootNtupleClass.h"
5 #include <iostream>
6 #include <sstream>
7 #include <string>
8 #include <vector>
9 #include <map>
10 #include <fstream>
11 #include <stdio.h>
12 #include <iomanip>
13 #include <TH1F.h>
14 #include <math.h>
15 #include <stdlib.h>
16
17 #include "TLorentzVector.h"
18
19 #define STDOUT(STRING) { \
20 std::cout << __FILE__ <<" - Line "<<__LINE__<<" - "<<__FUNCTION__<<": "<< STRING <<std::endl; \
21 }
22
23 using namespace std;
24
25 struct cut {
26 string variableName;
27 double minValue1;
28 double maxValue1;
29 double minValue2;
30 double maxValue2;
31 int level_int;
32 string level_str;
33 int histoNBins;
34 double histoMin;
35 double histoMax;
36 // Not filled from file
37 int id;
38 TH1F histo1;
39 TH1F histo2;
40 TH1F histo3;
41 TH1F histo4;
42 TH1F histo5;
43 // Filled event by event
44 bool filled;
45 double value;
46 bool passed;
47 int nEvtInput;
48 int nEvtPassed;
49 };
50
51 struct preCut {
52 string variableName;
53 double value1;
54 double value2;
55 double value3;
56 double value4;
57 int level_int;
58 string level_str;
59 };
60
61 // Create structure to hold
62 class Optimize {
63 public:
64 Optimize(){count=0; variableName=""; minvalue=0; maxvalue=0; testgreater=false; level_int=-10;};
65 Optimize(int x0, string x1, double x2, double x3, bool x4, int x5)
66 {
67 count=x0;
68 variableName=x1;
69 minvalue=x2;
70 maxvalue=x3;
71 if (minvalue>maxvalue)
72 {
73 maxvalue=x2;
74 minvalue=x3;
75 }
76 increment=(maxvalue-minvalue)/9.;
77 if (increment<=0)
78 increment=1;
79 testgreater=x4;
80 level_int=x5;
81 value=-999999; // dummy start value
82 };
83 ~Optimize(){};
84 int count; // store number for ordering of optimization cuts
85 string variableName; // store name of variable
86 double minvalue; // minimum threshold value to test
87 double maxvalue; // maximum threshold to test
88 double increment; // max-min, divided into 10 parts
89 bool testgreater; // tests whether value should be greater or less than threshold
90 int level_int; // cut level -- not used?
91 double value; // value to check against threshold
92
93 bool Compare(int counter)
94 {
95 // compare value to threshold # <counter>
96
97 // if testing that value is greater than some threshold, start with lowest threshold first
98 bool passed=false;
99 if (testgreater)
100 {
101 double thresh=minvalue+increment*counter; // convert counter # to physical threshold
102 value > thresh ? passed=true: passed=false;
103 }
104 // if testing that value is less than threshold, start with largest threshold first. This keep the number of \events "monotonically decreasing" over a series of 10 cuts.
105 else
106 {
107 double thresh=maxvalue-increment*counter;
108 value < thresh ? passed=true : passed = false;
109 }
110 return passed;
111 }; // comparison function
112 }; // class Optimize
113
114
115 class myEvent {
116 public :
117 vector<TLorentzVector> fourvector;
118 vector<double> momentum;
119 vector<bool> isolation;
120 vector<int> charge;
121 vector<double> deltaPhi;
122 vector<double> deltaEta;
123 vector<double> oneOverEminusOverP;
124 vector<double> transverseMass;
125 vector<double> ethIso;
126 vector<double> trkIso;
127 vector<double> ecalIso;
128 vector<double> hcalIso;
129 vector<double> HoverE;
130 vector<double> sigmaIetaIeta;
131 vector<double> numberOfMissingInnerHits;
132 vector<double> deltaPhiMet;
133 double missinget;
134 bool WorkingPointID(myEvent, vector<double>);
135 bool WorkingPointNminus1(myEvent, vector<double>, char *);
136
137 }; // class myEvent
138
139
140 class baseClass : public rootNtupleClass, public myEvent {
141 public :
142 map<string, bool> combCutName_passed_;
143
144 // -------------------------------------
145 double multiply(double, double);
146 bool triggerBitSelection(int*, int*, int*);
147 bool goodPrimaryVertexSelection(int, double);
148 /* bool noBeamScrapingSelection(int*, int*); */
149 bool ethID(int, double, double, double, double, double);
150 /* bool WorkingPointNminus1(myevent, vector<double>, char *); */
151 bool ethNminus1(int, double, double, double, double, double, char *, bool);
152 bool isolation(double, double);
153 double deltaPhi(double, double);
154 double transverseMass(double, double, double);
155 // -------------------------------------
156
157 void resetCuts();
158 void fillVariableWithValue(const std::string&, const double&);
159 void evaluateCuts();
160 bool passedCut(const string& s);
161 bool passedAllPreviousCuts(const string& s);
162 bool passedAllOtherCuts(const string& s);
163 bool passedAllOtherSameAndLowerLevelCuts(const string& s);
164 bool variableIsFilled(const string& s);
165 double getVariableValue(const string& s);
166 double getPreCutValue1(const string& s);
167 double getPreCutValue2(const string& s);
168 double getPreCutValue3(const string& s);
169 double getPreCutValue4(const string& s);
170 double getCutMinValue1(const string& s);
171 double getCutMaxValue1(const string& s);
172 double getCutMinValue2(const string& s);
173 double getCutMaxValue2(const string& s);
174
175 const TH1F& getHisto_noCuts_or_skim(const string& s);
176 const TH1F& getHisto_allPreviousCuts(const string& s);
177 const TH1F& getHisto_allOthrSmAndLwrLvlCuts(const string& s);
178 const TH1F& getHisto_allOtherCuts(const string& s);
179 const TH1F& getHisto_allCuts(const string& s);
180
181 int getHistoNBins(const string& s);
182 double getHistoMin(const string& s);
183 double getHistoMax(const string& s);
184
185
186 baseClass(string * inputList, string * cutFile, string * treeName, string *outputFileName=0, string * cutEfficFile=0);
187 virtual ~baseClass();
188
189 // Optimization stuff
190 void fillOptimizerWithValue(const string& s, const double& d);
191 void runOptimizer();
192
193 private :
194 string * configFile_;
195 string * outputFileName_;
196 TFile * output_root_;
197 string * inputList_;
198 string * cutFile_;
199 string * treeName_; // Name of input tree objects in (.root) files
200 TTree * tree_; // main tree
201 TTree * tree2_; // tree for globalInfo
202 string * cutEfficFile_;
203 std::stringstream preCutInfo_;
204 map<string, preCut> preCutName_cut_;
205 map<string, cut> cutName_cut_;
206 vector<string> orderedCutNames_;
207 void init();
208 void readInputList();
209 void readCutFile();
210 bool fillCutHistos();
211 bool writeCutHistos();
212 bool updateCutEffic();
213 bool writeCutEfficFile();
214 bool sortCuts(const cut&, const cut&);
215 vector<string> split(const string& s);
216 double decodeCutValue(const string& s);
217 bool skimWasMade_;
218 int getGlobalInfoNstart( char* );
219 int NBeforeSkim_;
220
221 // Optimization stuff
222 map<int, Optimize> optimizeName_cut_;
223 TH1F* eventcuts_; // number of events passing each cut
224 TH1F* h_optimizer_; // optimization histogram
225
226 };
227
228 #endif
229
230 #ifdef baseClass_cxx
231
232 #endif // #ifdef baseClass_cxx
233
234