ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/rootEWKanalyzer/include/baseClass.h
Revision: 1.2
Committed: Tue Jul 20 15:32:44 2010 UTC (14 years, 9 months ago) by jueugste
Content type: text/plain
Branch: MAIN
Changes since 1.1: +57 -1 lines
Log Message:
many changes...

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     enum NminusOneCutLabel {see, dphi, deta, hoe, combiso, conversion, all};
170     int WPElectronID(int, NminusOneCutLabel, vector<double>);
171     int ElectronPreselection(int);
172    
173     enum WNminusOneCutLabel {pre, misset, pt, mt, full};
174     int WSelection(int, WNminusOneCutLabel);
175    
176     double detaCorrections(double, double);
177     double dphiCorrections(double, double);
178    
179    
180     /* double etaMax_B; */
181     /* double etaMax_E; */
182     /* double SeeMax_B; */
183     /* double dEtaMax_B; */
184     /* double dPhiMax_B; */
185     /* double HoEMax_B; */
186     /* double combIsoMax_B; */
187     /* double SeeMax_E; */
188     /* double dEtaMax_E; */
189     /* double dPhiMax_E; */
190     /* double HoEMax_E; */
191     /* double combIsoMax_E; */
192    
193     /* void initializeWP(vector<double>); */
194    
195 jueugste 1.1 // -------------------------------------
196     double multiply(double, double);
197     bool triggerBitSelection(int*, int*, int*);
198     bool goodPrimaryVertexSelection(int, double);
199     /* bool noBeamScrapingSelection(int*, int*); */
200     bool ethID(int, double, double, double, double, double);
201     /* bool WorkingPointNminus1(myevent, vector<double>, char *); */
202     bool ethNminus1(int, double, double, double, double, double, char *, bool);
203     bool isolation(double, double);
204     double deltaPhi(double, double);
205     double transverseMass(double, double, double);
206     // -------------------------------------
207    
208 jueugste 1.2 map<string, int> HLTmap;
209     void getHLTtable();
210     int getHLTtriggerBit(string);
211    
212     // -------------------------------------
213 jueugste 1.1 void resetCuts();
214     void fillVariableWithValue(const std::string&, const double&);
215     void evaluateCuts();
216     bool passedCut(const string& s);
217     bool passedAllPreviousCuts(const string& s);
218     bool passedAllOtherCuts(const string& s);
219     bool passedAllOtherSameAndLowerLevelCuts(const string& s);
220     bool variableIsFilled(const string& s);
221     double getVariableValue(const string& s);
222     double getPreCutValue1(const string& s);
223     double getPreCutValue2(const string& s);
224     double getPreCutValue3(const string& s);
225     double getPreCutValue4(const string& s);
226     double getCutMinValue1(const string& s);
227     double getCutMaxValue1(const string& s);
228     double getCutMinValue2(const string& s);
229     double getCutMaxValue2(const string& s);
230    
231     const TH1F& getHisto_noCuts_or_skim(const string& s);
232     const TH1F& getHisto_allPreviousCuts(const string& s);
233     const TH1F& getHisto_allOthrSmAndLwrLvlCuts(const string& s);
234     const TH1F& getHisto_allOtherCuts(const string& s);
235     const TH1F& getHisto_allCuts(const string& s);
236    
237     int getHistoNBins(const string& s);
238     double getHistoMin(const string& s);
239     double getHistoMax(const string& s);
240    
241    
242     baseClass(string * inputList, string * cutFile, string * treeName, string *outputFileName=0, string * cutEfficFile=0);
243     virtual ~baseClass();
244    
245     // Optimization stuff
246     void fillOptimizerWithValue(const string& s, const double& d);
247     void runOptimizer();
248    
249     private :
250     string * configFile_;
251     string * outputFileName_;
252     TFile * output_root_;
253     string * inputList_;
254     string * cutFile_;
255     string * treeName_; // Name of input tree objects in (.root) files
256     TTree * tree_; // main tree
257     TTree * tree2_; // tree for globalInfo
258     string * cutEfficFile_;
259     std::stringstream preCutInfo_;
260     map<string, preCut> preCutName_cut_;
261     map<string, cut> cutName_cut_;
262     vector<string> orderedCutNames_;
263     void init();
264     void readInputList();
265     void readCutFile();
266     bool fillCutHistos();
267     bool writeCutHistos();
268     bool updateCutEffic();
269     bool writeCutEfficFile();
270     bool sortCuts(const cut&, const cut&);
271     vector<string> split(const string& s);
272     double decodeCutValue(const string& s);
273     bool skimWasMade_;
274     int getGlobalInfoNstart( char* );
275     int NBeforeSkim_;
276    
277     // Optimization stuff
278     map<int, Optimize> optimizeName_cut_;
279     TH1F* eventcuts_; // number of events passing each cut
280     TH1F* h_optimizer_; // optimization histogram
281    
282     };
283    
284     #endif
285    
286     #ifdef baseClass_cxx
287    
288     #endif // #ifdef baseClass_cxx
289    
290