ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/rootEWKanalyzer/include/baseClass.h
Revision: 1.4
Committed: Mon Nov 15 09:51:24 2010 UTC (14 years, 5 months ago) by jueugste
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +1 -0 lines
Error occurred while calculating annotation data.
Log Message:
*** empty log message ***

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 <TF2.h>
18 #include "TLorentzVector.h"
19 #include <map>
20
21
22 #define STDOUT(STRING) { \
23 std::cout << __FILE__ <<" - Line "<<__LINE__<<" - "<<__FUNCTION__<<": "<< STRING <<std::endl; \
24 }
25
26 using namespace std;
27
28 struct cut {
29 string variableName;
30 double minValue1;
31 double maxValue1;
32 double minValue2;
33 double maxValue2;
34 int level_int;
35 string level_str;
36 int histoNBins;
37 double histoMin;
38 double histoMax;
39 // Not filled from file
40 int id;
41 TH1F histo1;
42 TH1F histo2;
43 TH1F histo3;
44 TH1F histo4;
45 TH1F histo5;
46 // Filled event by event
47 bool filled;
48 double value;
49 bool passed;
50 int nEvtInput;
51 int nEvtPassed;
52 };
53
54 struct preCut {
55 string variableName;
56 double value1;
57 double value2;
58 double value3;
59 double value4;
60 int level_int;
61 string level_str;
62 };
63
64 // Create structure to hold
65 class Optimize {
66 public:
67 Optimize(){count=0; variableName=""; minvalue=0; maxvalue=0; testgreater=false; level_int=-10;};
68 Optimize(int x0, string x1, double x2, double x3, bool x4, int x5)
69 {
70 count=x0;
71 variableName=x1;
72 minvalue=x2;
73 maxvalue=x3;
74 if (minvalue>maxvalue)
75 {
76 maxvalue=x2;
77 minvalue=x3;
78 }
79 increment=(maxvalue-minvalue)/9.;
80 if (increment<=0)
81 increment=1;
82 testgreater=x4;
83 level_int=x5;
84 value=-999999; // dummy start value
85 };
86 ~Optimize(){};
87 int count; // store number for ordering of optimization cuts
88 string variableName; // store name of variable
89 double minvalue; // minimum threshold value to test
90 double maxvalue; // maximum threshold to test
91 double increment; // max-min, divided into 10 parts
92 bool testgreater; // tests whether value should be greater or less than threshold
93 int level_int; // cut level -- not used?
94 double value; // value to check against threshold
95
96 bool Compare(int counter)
97 {
98 // compare value to threshold # <counter>
99
100 // if testing that value is greater than some threshold, start with lowest threshold first
101 bool passed=false;
102 if (testgreater)
103 {
104 double thresh=minvalue+increment*counter; // convert counter # to physical threshold
105 value > thresh ? passed=true: passed=false;
106 }
107 // 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.
108 else
109 {
110 double thresh=maxvalue-increment*counter;
111 value < thresh ? passed=true : passed = false;
112 }
113 return passed;
114 }; // comparison function
115 }; // class Optimize
116
117
118 class myEvent {
119 public :
120 vector<TLorentzVector> fourvector;
121 vector<double> momentum;
122 vector<bool> isolation;
123 vector<int> charge;
124 vector<double> deltaPhi;
125 vector<double> deltaEta;
126 vector<double> oneOverEminusOverP;
127 vector<double> transverseMass;
128 vector<double> ethIso;
129 vector<double> trkIso;
130 vector<double> ecalIso;
131 vector<double> hcalIso;
132 vector<double> HoverE;
133 vector<double> sigmaIetaIeta;
134 vector<double> numberOfMissingInnerHits;
135 vector<double> deltaPhiMet;
136 double missinget;
137 bool WorkingPointID(myEvent, vector<double>);
138 bool WorkingPointNminus1(myEvent, vector<double>, char *);
139 /* bool ETHminus1better(myEvent, vector<double>, char *); */
140 }; // class myEvent
141
142
143 struct testEvent {
144 vector<TLorentzVector> fourMomentum;
145
146 double etaMax_B;
147 double etaMax_E;
148 double SeeMax_B;
149 double dEtaMax_B;
150 double dPhiMax_B;
151 double HoEMax_B;
152 double combIsoMax_B;
153 double SeeMax_E;
154 double dEtaMax_E;
155 double dPhiMax_E;
156 double HoEMax_E;
157 double combIsoMax_E;
158
159
160
161 };
162
163 class baseClass : public rootNtupleClass, public myEvent {
164 public :
165 map<string, bool> combCutName_passed_;
166
167 testEvent fillTestEvent();
168
169 enum NminusOneCutLabel {see, dphi, deta, hoe, combiso, conversion, all, oeop};
170 int WPElectronID(int, NminusOneCutLabel, vector<double>);
171 int ElectronPreselection(int);
172 int ETHElectronID(int, NminusOneCutLabel);
173
174
175 enum WNminusOneCutLabel {pre, misset, pt, mt, full};
176 int WSelection(int, WNminusOneCutLabel);
177
178 double detaCorrections(double, double);
179 double dphiCorrections(double, double);
180
181
182 /* double etaMax_B; */
183 /* double etaMax_E; */
184 /* double SeeMax_B; */
185 /* double dEtaMax_B; */
186 /* double dPhiMax_B; */
187 /* double HoEMax_B; */
188 /* double combIsoMax_B; */
189 /* double SeeMax_E; */
190 /* double dEtaMax_E; */
191 /* double dPhiMax_E; */
192 /* double HoEMax_E; */
193 /* double combIsoMax_E; */
194
195 /* void initializeWP(vector<double>); */
196
197 // -------------------------------------
198 double multiply(double, double);
199 bool triggerBitSelection(int*, int*, int*);
200 bool goodPrimaryVertexSelection(int, double);
201 /* bool noBeamScrapingSelection(int*, int*); */
202 bool ethID(int, double, double, double, double, double);
203 /* bool WorkingPointNminus1(myevent, vector<double>, char *); */
204 bool ethNminus1(int, double, double, double, double, double, char *, bool);
205 bool isolation(double, double);
206 double deltaPhi(double, double);
207 double transverseMass(double, double, double);
208 // -------------------------------------
209
210
211 void scaleHisto(TH1D*, double);
212 string getFileName();
213
214 map<string, int> HLTmap;
215 void getHLTtable();
216 void GetHLTNames(Int_t& run);
217 int getHLTtriggerBit(string);
218
219 // -------------------------------------
220 void resetCuts();
221 void fillVariableWithValue(const std::string&, const double&);
222 void evaluateCuts();
223 bool passedCut(const string& s);
224 bool passedAllPreviousCuts(const string& s);
225 bool passedAllOtherCuts(const string& s);
226 bool passedAllOtherSameAndLowerLevelCuts(const string& s);
227 bool variableIsFilled(const string& s);
228 double getVariableValue(const string& s);
229 double getPreCutValue1(const string& s);
230 double getPreCutValue2(const string& s);
231 double getPreCutValue3(const string& s);
232 double getPreCutValue4(const string& s);
233 double getCutMinValue1(const string& s);
234 double getCutMaxValue1(const string& s);
235 double getCutMinValue2(const string& s);
236 double getCutMaxValue2(const string& s);
237
238 const TH1F& getHisto_noCuts_or_skim(const string& s);
239 const TH1F& getHisto_allPreviousCuts(const string& s);
240 const TH1F& getHisto_allOthrSmAndLwrLvlCuts(const string& s);
241 const TH1F& getHisto_allOtherCuts(const string& s);
242 const TH1F& getHisto_allCuts(const string& s);
243
244 int getHistoNBins(const string& s);
245 double getHistoMin(const string& s);
246 double getHistoMax(const string& s);
247
248
249 baseClass(string * inputList, string * cutFile, string * treeName, string *outputFileName=0, string * cutEfficFile=0);
250 virtual ~baseClass();
251
252 // Optimization stuff
253 void fillOptimizerWithValue(const string& s, const double& d);
254 void runOptimizer();
255
256 private :
257 string * configFile_;
258 string * outputFileName_;
259 TFile * output_root_;
260 string * inputList_;
261 string * cutFile_;
262 string * treeName_; // Name of input tree objects in (.root) files
263 TTree * tree_; // main tree
264 TTree * tree2_; // tree for globalInfo
265 string * cutEfficFile_;
266 std::stringstream preCutInfo_;
267 map<string, preCut> preCutName_cut_;
268 map<string, cut> cutName_cut_;
269 vector<string> orderedCutNames_;
270 void init();
271 void readInputList();
272 void readCutFile();
273 bool fillCutHistos();
274 bool writeCutHistos();
275 bool updateCutEffic();
276 bool writeCutEfficFile();
277 bool sortCuts(const cut&, const cut&);
278 vector<string> split(const string& s);
279 double decodeCutValue(const string& s);
280 bool skimWasMade_;
281 int getGlobalInfoNstart( char* );
282 int NBeforeSkim_;
283
284 // Optimization stuff
285 map<int, Optimize> optimizeName_cut_;
286 TH1F* eventcuts_; // number of events passing each cut
287 TH1F* h_optimizer_; // optimization histogram
288
289 };
290
291 #endif
292
293 #ifdef baseClass_cxx
294
295 #endif // #ifdef baseClass_cxx
296
297