2 #include "TopQuarkAnalysis/TopTools/test/tdrstyle.C"
8 gStyle->SetCanvasDefW(900);
13 const std::vector<double>& obsMin,
14 const std::vector<double>& obsMax,
15 const std::vector<const char*>&
functions) {
19 gStyle->SetCanvasDefW(900);
20 for (
size_t o = 0;
o < obsNr.size();
o++) {
30 htSB +=
"_SoverSplusB";
31 hObsS.push_back(
new TH1F(htS, htS, nrBins, obsMin[
o], obsMax[
o]));
32 hObsB.push_back(
new TH1F(htB, htB, nrBins, obsMin[
o], obsMax[
o]));
36 for (
size_t o2 =
o + 1; o2 < obsNr.size(); o2++) {
37 TString hcorr =
"Corr_Obs";
41 hObsCorr.push_back(
new TH2F(hcorr, hcorr, nrBins, obsMin[
o], obsMax[
o], nrBins, obsMin[o2], obsMax[o2]));
45 TString ftSB =
"F_Obs";
47 ftSB +=
"_SoverSplusB";
56 for (
size_t o = 0;
o < obsNr.size();
o++) {
58 TString ftSB =
"F_Obs";
60 ftSB +=
"_SoverSplusB";
69 gStyle->SetCanvasDefW(900);
72 hLRtotS =
new TH1F(
"hLRtotS",
"hLRtotS", nrLRbins, LRmin, LRmax);
73 hLRtotS->GetXaxis()->SetTitle(
"Combined LR");
74 hLRtotB =
new TH1F(
"hLRtotB",
"hLRtotB", nrLRbins, LRmin, LRmax);
75 hLRtotB->GetXaxis()->SetTitle(
"Combined LR");
76 hLRtotSoverSplusB =
new TH1F(
"hLRtotSoverSplusB",
"hLRtotSoverSplusB", nrLRbins, LRmin, LRmax);
89 hLRtotS =
new TH1F(
"hLRtotS",
"hLRtotS", nrLRbins, LRmin, LRmax);
90 hLRtotB =
new TH1F(
"hLRtotB",
"hLRtotB", nrLRbins, LRmin, LRmax);
91 hLRtotSoverSplusB =
new TH1F(
"hLRtotSoverSplusB",
"hLRtotSoverSplusB", nrLRbins, LRmin, LRmax);
102 for (
size_t p = 0;
p < fitPars.size();
p++) {
112 for (
size_t o = 0;
o < obsVals.size();
o++) {
114 for (
size_t o2 =
o + 1; o2 < obsVals.size(); o2++) {
126 for (
size_t f = 0;
f <
hObsS.size();
f++) {
127 if (((TString)(
hObsS[
f]->GetName())).Contains(obs)) {
136 TString hcorr =
"Corr_Obs";
137 hcorr +=
std::min(obsNbr1, obsNbr2);
139 hcorr +=
std::max(obsNbr1, obsNbr2);
141 if (((TString)(
hObsCorr[
i]->GetName())) == hcorr) {
142 if (obsNbr1 < obsNbr2) {
154 for (
size_t o = 0;
o < obsVals.size();
o++)
163 for (
size_t f = 0;
f <
hObsB.size();
f++) {
164 if (((TString)(
hObsB[
f]->GetName())).Contains(obs)) {
173 for (
size_t o = 0;
o <
hObsS.size();
o++) {
176 double nrSignEntries = 0, nrBackEntries = 0;
177 for (
int i = 0;
i <=
hObsS[
o]->GetNbinsX() + 1;
i++) {
178 nrSignEntries +=
hObsS[
o]->GetBinContent(
i);
179 nrBackEntries +=
hObsB[
o]->GetBinContent(
i);
181 for (
int b = 0;
b <=
hObsS[
o]->GetNbinsX() + 1;
b++) {
182 hObsS[
o]->SetBinContent(
b,
hObsS[
o]->GetBinContent(
b) / (nrSignEntries));
183 hObsB[
o]->SetBinContent(
b,
hObsB[
o]->GetBinContent(
b) / (nrBackEntries));
184 hObsS[
o]->SetBinError(
b,
hObsS[
o]->GetBinError(
b) / (nrSignEntries));
185 hObsB[
o]->SetBinError(
b,
hObsB[
o]->GetBinError(
b) / (nrBackEntries));
193 for (
size_t o = 0;
o <
hObsS.size();
o++) {
194 for (
int b = 0;
b <=
hObsS[
o]->GetNbinsX() + 1;
b++) {
195 if ((
hObsS[
o]->GetBinContent(
b) +
hObsB[
o]->GetBinContent(
b)) > 0) {
213 const std::vector<int>& observables,
219 TFile* fitFile =
new TFile(
fileName,
"READ");
220 if (observables[0] == -1) {
221 std::cout <<
" ... will read hists and fit for all available observables in file " <<
fileName << std::endl;
222 TList* list = fitFile->GetListOfKeys();
225 while ((el = (TKey*)
next())) {
226 TString keyName = el->GetName();
227 if (keyName.Contains(
"F_") && keyName.Contains(
"_SoverSplusB")) {
229 }
else if (keyName.Contains(
"_SoverSplusB")) {
231 }
else if (keyName.Contains(
"_S")) {
232 hObsS.push_back(
new TH1F(*((TH1F*)el->ReadObj())));
233 }
else if (keyName.Contains(
"_B")) {
234 hObsB.push_back(
new TH1F(*((TH1F*)el->ReadObj())));
235 }
else if (keyName.Contains(
"Corr")) {
236 hObsCorr.push_back(
new TH2F(*((TH2F*)el->ReadObj())));
241 for (
unsigned int obs = 0; obs < observables.size(); obs++) {
242 std::cout <<
" ... will read hists and fit for obs " << observables[obs] <<
" from file " <<
fileName
244 TString hStitle =
"Obs";
245 hStitle += observables[obs];
247 hObsS.push_back(
new TH1F(*((TH1F*)fitFile->GetKey(hStitle)->ReadObj())));
248 TString hBtitle =
"Obs";
249 hBtitle += observables[obs];
251 hObsB.push_back(
new TH1F(*((TH1F*)fitFile->GetKey(hBtitle)->ReadObj())));
252 TString hSBtitle =
"Obs";
253 hSBtitle += observables[obs];
254 hSBtitle +=
"_SoverSplusB";
255 TString fSBtitle =
"F_";
256 fSBtitle += hSBtitle;
257 hObsSoverSplusB.push_back(
new TH1F(*((TH1F*)fitFile->GetKey(hSBtitle)->ReadObj())));
258 fObsSoverSplusB.push_back(
new TF1(*((TF1*)fitFile->GetKey(fSBtitle)->ReadObj())));
259 for (
unsigned int obs2 = obs + 1; obs2 < observables.size(); obs2++) {
260 TString hCorrtitle =
"Corr_Obs";
261 hCorrtitle += observables[obs];
262 hCorrtitle +=
"_Obs";
263 hCorrtitle += observables[obs2];
264 hObsCorr.push_back(
new TH2F(*((TH2F*)fitFile->GetKey(hCorrtitle)->ReadObj())));
272 hLRtotS =
new TH1F(*((TH1F*)fitFile->GetKey(
"hLRtotS")->ReadObj()));
273 hLRtotB =
new TH1F(*((TH1F*)fitFile->GetKey(
"hLRtotB")->ReadObj()));
274 hLRtotSoverSplusB =
new TH1F(*((TH1F*)fitFile->GetKey(
"hLRtotSoverSplusB")->ReadObj()));
275 fLRtotSoverSplusB =
new TF1(*((TF1*)fitFile->GetKey(
"fLRtotSoverSplusB")->ReadObj()));
281 TFile fOut(
fname,
"RECREATE");
283 for (
size_t o = 0;
o <
hObsS.size();
o++) {
290 for (
size_t o = 0;
o <
hObsS.size();
o++) {
291 for (
size_t o2 =
o + 1; o2 <
hObsS.size(); o2++) {
312 TCanvas
c(
"dummy",
"", 1);
313 c.Print(
fname +
"[",
"landscape");
314 for (
size_t o = 0;
o <
hObsS.size();
o++) {
315 TCanvas c2(
"c2",
"", 1);
318 hObsS[
o]->SetLineColor(2);
321 hObsS[
o]->Draw(
"histsame");
324 hObsB[
o]->Draw(
"histsame");
329 c2.Print(
fname,
"Landscape");
333 for (
size_t o = 0;
o <
hObsS.size();
o++) {
334 for (
size_t o2 =
o + 1; o2 <
hObsS.size(); o2++) {
335 TCanvas
cc(
"cc",
"", 1);
337 TPaveText
pt(0.5, 0.87, 0.98, 0.93,
"blNDC");
341 TString tcorr =
"Corr. of ";
342 tcorr += (
int)(100. *
hObsCorr[hIndex]->GetCorrelationFactor());
352 TCanvas c3(
"c3",
"", 1);
360 c3.Print(
fname,
"Landscape");
362 TCanvas c4(
"c4",
"", 1);
364 c4.Print(
fname,
"Landscape");
366 TCanvas c5(
"c5",
"", 1);
368 c5.Print(
fname,
"Landscape");
370 TCanvas c6(
"c6",
"", 1);
372 c6.Print(
fname,
"Landscape");
374 c.Print(
fname +
"]",
"landscape");
382 double SoverN = 1. / ((1. / SoverSplusN) - 1.);
383 logLR +=
log(SoverN);
395 if (SoverSplusN < 0.0001)
396 SoverSplusN = 0.0001;
403 TString hcorr =
"Corr_Obs";
408 if (((TString)(
hObsCorr[
i]->GetName())) == hcorr)
435 for (
int b = 0;
b <=
hLRtotS->GetNbinsX();
b++) {
438 if (Sint + Bint > 0) {
445 hLRtotS->GetXaxis()->SetTitle(
"Combined LR ratio");
446 hLRtotB->GetXaxis()->SetTitle(
"Combined LR ratio");
451 double totSignal =
hLRtotS->Integral(0,
hLRtotS->GetNbinsX() + 1);
452 double Eff[200], Pur[200], LRVal[200];
453 if (
hLRtotS->GetNbinsX() > 200) {
454 std::cout <<
"Number of bins of LR histograms can not execeed 200!" << std::endl;
458 double LRcutVal =
hLRtotS->GetBinLowEdge(
cut);
461 LRVal[
cut] = LRcutVal;
466 hEffvsPur->GetXaxis()->SetTitle((TString)(
"Efficiency of cut on log combined LR"));
467 hEffvsPur->GetYaxis()->SetTitle((TString)(
"Purity"));
468 hEffvsPur->GetYaxis()->SetRangeUser(0, 1.1);
473 hLRValvsPur->GetXaxis()->SetTitle((TString)(
"Cut on the log combined LR value"));
474 hLRValvsPur->GetYaxis()->SetTitle((TString)(
"Purity"));
480 hLRValvsEff->GetXaxis()->SetTitle((TString)(
"Cut on the log combined LR value"));
481 hLRValvsEff->GetYaxis()->SetTitle((TString)(
"Efficiency of cut on log combined LR"));
490 bool included =
false;
491 TString obs =
"_Obs";
502 if (
hObsS.size() != xLabels.size()) {
503 std::cout <<
"LRHelpFunctions::setXlabels: Number of labels (" << xLabels.size()
504 <<
") does not match number of obervables(" <<
hObsS.size() <<
").\n";
507 for (
size_t i = 0;
i <
hObsS.size(); ++
i) {
508 hObsS[
i]->GetXaxis()->SetTitle(TString(xLabels[
i]));
509 hObsB[
i]->GetXaxis()->SetTitle(TString(xLabels[
i]));
516 if (
hObsS.size() != yLabels.size()) {
517 std::cout <<
"LRHelpFunctions::setYlabels: Number of labels (" << yLabels.size()
518 <<
") does not match number of obervables(" <<
hObsS.size() <<
").\n";
521 for (
size_t i = 0;
i <
hObsS.size(); ++
i) {
522 hObsS[
i]->GetYaxis()->SetTitle(TString(yLabels[
i]));
523 hObsB[
i]->GetYaxis()->SetTitle(TString(yLabels[
i]));
531 TStyle*
tdrStyle = gROOT->GetStyle(
"tdrStyle");
540 TCanvas c2(
"c2",
"", 600, 300);
541 c2.SetTopMargin(0.01);
542 c2.SetBottomMargin(0.01);
543 c2.SetLeftMargin(0.01);
544 c2.SetRightMargin(0.01);
551 for (
size_t o = 0;
o <
hObsB.size(); ++
o) {
552 if (((TString)(
hObsB[
o]->GetName())).Contains(obs)) {
554 hObsS[
o]->SetLineColor(2);
557 hObsS[
o]->Draw(
"histsame");
560 hObsB[
o]->Draw(
"histsame");
573 TStyle*
tdrStyle = gROOT->GetStyle(
"tdrStyle");
582 TCanvas c2(
"c2",
"", 600, 300);
583 c2.SetTopMargin(0.01);
584 c2.SetBottomMargin(0.01);
585 c2.SetLeftMargin(0.01);
586 c2.SetRightMargin(0.01);
596 hLRtotS->GetXaxis()->SetNdivisions(505);
597 hLRtotB->GetXaxis()->SetNdivisions(505);
598 TCanvas c3(
"c2",
"", 300, 300);
603 hLRtotS->GetXaxis()->SetTitle(
"Combined LR");
604 hLRtotB->GetXaxis()->SetTitle(
"Combined LR");
611 TCanvas c5(
"c3",
"", 900, 600);