3 |
|
#include <TFile.h> |
4 |
|
#include <TH1.h> |
5 |
|
#include <TH2.h> |
6 |
+ |
#include <THStack.h> |
7 |
|
#include <TLatex.h> |
8 |
|
#include <TCanvas.h> |
9 |
|
#include <TMath.h> |
31 |
|
}; |
32 |
|
|
33 |
|
//function for doing KS test |
34 |
< |
vector<testMC> doKStest(Double_t NsS, Double_t Ns1, Double_t Ns2, TH1F* mixS, TH1F* s1, TH1F* s2) { |
34 |
> |
vector<testMC> doKStest(const vector<Double_t>& vnevt, map<string,TH1F*>& mhisto) { |
35 |
|
vector<testMC> output; |
36 |
|
//define the scale factors |
37 |
|
Double_t sf1 = 0.0; // QCD |
38 |
|
Double_t sf2 = 0.0; // Wjets |
39 |
+ |
Double_t Ns = 0.0; // non-Wjets (ttbar,Zjets,single top...) |
40 |
+ |
for (UInt_t i = 3; i < vnevt.size(); ++i) |
41 |
+ |
Ns += vnevt[i]; |
42 |
+ |
//cout << "Total number of Non Wjets events = " << Ns << endl; |
43 |
|
//KS test |
44 |
|
do { |
45 |
< |
sf1 = (NsS - Ns2*sf2)/Ns1; |
45 |
> |
sf1 = (vnevt.at(0) - Ns - vnevt.at(2)*sf2)/vnevt.at(1); |
46 |
|
if (sf1 < 0) break; |
47 |
|
//cout << "..........sf1 = " << sf1 << endl; |
48 |
< |
int nbins = mixS->GetNbinsX(); |
49 |
< |
double xmin = mixS->GetXaxis()->GetBinLowEdge(1); |
50 |
< |
double xmax = mixS->GetXaxis()->GetBinUpEdge(nbins); |
48 |
> |
int nbins = mhisto["Data"]->GetNbinsX(); |
49 |
> |
double xmin = mhisto["Data"]->GetXaxis()->GetBinLowEdge(1); |
50 |
> |
double xmax = mhisto["Data"]->GetXaxis()->GetBinUpEdge(nbins); |
51 |
|
TH1F *test = new TH1F("test", "", nbins, xmin, xmax); |
52 |
< |
test -> Sumw2(); |
53 |
< |
test -> Add(s1,s2,sf1,sf2); |
52 |
> |
test->Sumw2(); |
53 |
> |
test->Add(mhisto["QCD"],mhisto["WJets"],sf1,sf2); |
54 |
> |
for (map<string,TH1F*>::iterator ihisto = mhisto.begin(); |
55 |
> |
ihisto != mhisto.end(); ++ihisto) { |
56 |
> |
if (ihisto->first != "QCD" |
57 |
> |
&& ihisto->first != "Data" |
58 |
> |
&& ihisto->first != "WJets" |
59 |
> |
) { |
60 |
> |
test->Add(ihisto->second,1.); |
61 |
> |
} |
62 |
> |
} |
63 |
> |
|
64 |
|
//test->Scale(1./(1.*test->Integral())); |
65 |
< |
Double_t probability = mixS -> KolmogorovTest(test,""); |
65 |
> |
Double_t probability = mhisto["Data"]->KolmogorovTest(test,""); |
66 |
|
testMC temp = testMC(probability,sf1,sf2); |
67 |
|
output.push_back(temp); |
68 |
< |
// cout << "probability = " << setw(15) << temp.prob |
69 |
< |
// << "; sfQCD = " << setw(10) << temp.scaleF_backg |
70 |
< |
// << "; sfWjets = " << setw(6) << temp.scaleF_sample << endl; |
68 |
> |
/* cout << "probability = " << setw(15) << temp.prob */ |
69 |
> |
/* << "; sfQCD = " << setw(10) << temp.scaleF_backg */ |
70 |
> |
/* << "; sfWjets = " << setw(6) << temp.scaleF_sample << endl; */ |
71 |
|
delete test; |
72 |
|
sf2 = sf2 + stepsize; |
73 |
|
} while(sf1 > 0 && sf2 <= 2.0); |