ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/rootEWKanalyzer/include/baseClass.h
Revision: 1.3
Committed: Mon Sep 20 14:23:14 2010 UTC (14 years, 7 months ago) by jueugste
Content type: text/plain
Branch: MAIN
Changes since 1.2: +7 -1 lines
Log Message:
Update (plus EWK and HWW analysis added)

File Contents

# User Rev Content
1 jueugste 1.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 jueugste 1.2 #include <TF2.h>
18 jueugste 1.1 #include "TLorentzVector.h"
19 jueugste 1.2 #include <map>
20    
21 jueugste 1.1
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 jueugste 1.2 /* 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 jueugste 1.1
159    
160    
161 jueugste 1.2 };
162    
163 jueugste 1.1 class baseClass : public rootNtupleClass, public myEvent {
164     public :
165     map<string, bool> combCutName_passed_;
166    
167 jueugste 1.2 testEvent fillTestEvent();
168    
169 jueugste 1.3 enum NminusOneCutLabel {see, dphi, deta, hoe, combiso, conversion, all, oeop};
170 jueugste 1.2 int WPElectronID(int, NminusOneCutLabel, vector<double>);
171     int ElectronPreselection(int);
172 jueugste 1.3 int ETHElectronID(int, NminusOneCutLabel);
173    
174 jueugste 1.2
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 jueugste 1.1 // -------------------------------------
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 jueugste 1.3
210    
211     void scaleHisto(TH1D*, double);
212     string getFileName();
213 jueugste 1.1
214 jueugste 1.2 map<string, int> HLTmap;
215     void getHLTtable();
216     int getHLTtriggerBit(string);
217    
218     // -------------------------------------
219 jueugste 1.1 void resetCuts();
220     void fillVariableWithValue(const std::string&, const double&);
221     void evaluateCuts();
222     bool passedCut(const string& s);
223     bool passedAllPreviousCuts(const string& s);
224     bool passedAllOtherCuts(const string& s);
225     bool passedAllOtherSameAndLowerLevelCuts(const string& s);
226     bool variableIsFilled(const string& s);
227     double getVariableValue(const string& s);
228     double getPreCutValue1(const string& s);
229     double getPreCutValue2(const string& s);
230     double getPreCutValue3(const string& s);
231     double getPreCutValue4(const string& s);
232     double getCutMinValue1(const string& s);
233     double getCutMaxValue1(const string& s);
234     double getCutMinValue2(const string& s);
235     double getCutMaxValue2(const string& s);
236    
237     const TH1F& getHisto_noCuts_or_skim(const string& s);
238     const TH1F& getHisto_allPreviousCuts(const string& s);
239     const TH1F& getHisto_allOthrSmAndLwrLvlCuts(const string& s);
240     const TH1F& getHisto_allOtherCuts(const string& s);
241     const TH1F& getHisto_allCuts(const string& s);
242    
243     int getHistoNBins(const string& s);
244     double getHistoMin(const string& s);
245     double getHistoMax(const string& s);
246    
247    
248     baseClass(string * inputList, string * cutFile, string * treeName, string *outputFileName=0, string * cutEfficFile=0);
249     virtual ~baseClass();
250    
251     // Optimization stuff
252     void fillOptimizerWithValue(const string& s, const double& d);
253     void runOptimizer();
254    
255     private :
256     string * configFile_;
257     string * outputFileName_;
258     TFile * output_root_;
259     string * inputList_;
260     string * cutFile_;
261     string * treeName_; // Name of input tree objects in (.root) files
262     TTree * tree_; // main tree
263     TTree * tree2_; // tree for globalInfo
264     string * cutEfficFile_;
265     std::stringstream preCutInfo_;
266     map<string, preCut> preCutName_cut_;
267     map<string, cut> cutName_cut_;
268     vector<string> orderedCutNames_;
269     void init();
270     void readInputList();
271     void readCutFile();
272     bool fillCutHistos();
273     bool writeCutHistos();
274     bool updateCutEffic();
275     bool writeCutEfficFile();
276     bool sortCuts(const cut&, const cut&);
277     vector<string> split(const string& s);
278     double decodeCutValue(const string& s);
279     bool skimWasMade_;
280     int getGlobalInfoNstart( char* );
281     int NBeforeSkim_;
282    
283     // Optimization stuff
284     map<int, Optimize> optimizeName_cut_;
285     TH1F* eventcuts_; // number of events passing each cut
286     TH1F* h_optimizer_; // optimization histogram
287    
288     };
289    
290     #endif
291    
292     #ifdef baseClass_cxx
293    
294     #endif // #ifdef baseClass_cxx
295    
296