31 TCanvas *c1 =
new TCanvas(
"c1",
"Dynamic Filling Example",200,10,700,500);
35 TH1D* backgroundHist =
new TH1D(
"background",
"The expected background",30,-4,4);
36 TH1D* signalHist =
new TH1D(
"signal",
"the expected signal",30,-4,4);
37 TH1D* dataHist =
new TH1D(
"data",
"some fake data points",30,-4,4);
38 backgroundHist->SetFillColor(48);
39 signalHist->SetFillColor(41);
40 dataHist->SetMarkerStyle(21);
41 dataHist->SetMarkerColor(kBlue);
42 backgroundHist->Sumw2();
48 for (Int_t i = 0; i < 25000; i++) {
51 backgroundHist->Fill(bg,0.02);
52 signalHist->Fill(sig,0.001);
54 for (Int_t i = 0; i < 500; i++) {
58 THStack *hs =
new THStack(
"hs",
"Signal and background compared to data...");
59 hs->Add(backgroundHist);
62 dataHist->Draw(
"PE1,Same");
65 c1->GetFrame()->SetFillColor(21);
66 c1->GetFrame()->SetBorderSize(6);
67 c1->GetFrame()->SetBorderMode(-1);
70 gSystem->ProcessEvents();
73 cout <<
"Computing limits... " << endl;
74 TLimitDataSource* mydatasource =
new TLimitDataSource(signalHist,backgroundHist,dataHist);
75 TConfidenceLevel *myconfidence = TLimit::ComputeLimit(mydatasource,50000);
76 cout <<
"CLs : " << myconfidence->CLs() << endl;
77 cout <<
"CLsb : " << myconfidence->CLsb() << endl;
78 cout <<
"CLb : " << myconfidence->CLb() << endl;
79 cout <<
"< CLs > : " << myconfidence->GetExpectedCLs_b() << endl;
80 cout <<
"< CLsb > : " << myconfidence->GetExpectedCLsb_b() << endl;
81 cout <<
"< CLb > : " << myconfidence->GetExpectedCLb_b() << endl;
84 cout << endl <<
"Computing limits with stat systematics... " << endl;
85 TConfidenceLevel *mystatconfidence = TLimit::ComputeLimit(mydatasource,50000,
true);
86 cout <<
"CLs : " << mystatconfidence->CLs() << endl;
87 cout <<
"CLsb : " << mystatconfidence->CLsb() << endl;
88 cout <<
"CLb : " << mystatconfidence->CLb() << endl;
89 cout <<
"< CLs > : " << mystatconfidence->GetExpectedCLs_b() << endl;
90 cout <<
"< CLsb > : " << mystatconfidence->GetExpectedCLsb_b() << endl;
91 cout <<
"< CLb > : " << mystatconfidence->GetExpectedCLb_b() << endl;
94 cout << endl <<
"Computing limits with systematics... " << endl;
97 TObjArray* names =
new TObjArray();
98 TObjString name1(
"bg uncertainty");
99 TObjString name2(
"sig uncertainty");
100 names->AddLast(&name1);
101 names->AddLast(&name2);
106 TLimitDataSource* mynewdatasource =
new TLimitDataSource();
107 mynewdatasource->AddChannel(signalHist,backgroundHist,dataHist,&errors,&errorb,names);
108 TConfidenceLevel *mynewconfidence = TLimit::ComputeLimit(mynewdatasource,50000,
true);
109 cout <<
"CLs : " << mynewconfidence->CLs() << endl;
110 cout <<
"CLsb : " << mynewconfidence->CLsb() << endl;
111 cout <<
"CLb : " << mynewconfidence->CLb() << endl;
112 cout <<
"< CLs > : " << mynewconfidence->GetExpectedCLs_b() << endl;
113 cout <<
"< CLsb > : " << mynewconfidence->GetExpectedCLsb_b() << endl;
114 cout <<
"< CLb > : " << mynewconfidence->GetExpectedCLb_b() << endl;
119 TCanvas *c2 =
new TCanvas(
"c2");
120 myconfidence->Draw();
125 delete mystatconfidence;
126 delete mynewconfidence;
127 delete mynewdatasource;