Source + backround

In [1]:
%jsroot on
TCanvas *c1 = new TCanvas;
TH1F *hsb = new TH1F("hsb","source+background",100,0,100);//source + background
TH1F *hb1 = new TH1F("hb1","background1",100,0,100);//background1 with tb = ts
TH1F *hs1 = new TH1F("hs1","source",100,0,100);//source

TH1F *hb2a = new TH1F("hb2a","background/10",100,0,100);//background with tb = ts/10
TH1F *hs2 = new TH1F("hs2","source",100,0,100);
In [2]:
TRandom3 *gr = new TRandom3(0);//random
In [3]:
for(int i = 0; i < 20000; i++) {
    if(i % 4 == 0) hsb->Fill(gr->Gaus(50,10));
    hsb->Fill(gr->Uniform(100));
    hb1->Fill(gr->Uniform(100));
    if(i % 10 == 0) hb2a->Fill(gr->Uniform(100));
}
hs1->Add(hsb,hb1,1,-1);//subtract background1
TH1F *hb2 = (TH1F*)hb2a->Clone("hb2");
hb2->Scale(10.);////backgound2 = 10 * background with tb=ts/10
hs2->Add(hsb,hb2,1,-1);//subtract background2
In [4]:
hb1->SetLineColor(kRed);
hb2a->SetLineColor(kRed);
hb2->SetLineColor(kRed);
hs1->SetLineColor(kGreen);
hs2->SetLineColor(kGreen);

Time allocation: $t_b = t_s$

In [5]:
hsb->SetMinimum(0);
hsb->SetMaximum(500);
hs1->SetMinimum(-200);
hs1->SetMaximum(300);
hs2->SetMinimum(-200);
hs2->SetMaximum(300);
c1->Divide(2,1);
c1->cd(1);
hsb->Draw();
hb1->Draw("same");
c1->cd(2);
hs1->Draw("hist");
c1->Draw();

$N_b=200;\space \sigma_{N_b}=\sqrt{200}$

$\sigma_{N_0}=\sqrt{\sigma_{N_s}^2+\sigma_{N_b}^2}=\sqrt{N_s+200}$

Time allocation: $t_b = t_s/10$

In [23]:
TLatex latex;
latex.SetTextSize(0.15);
c1->Clear();
c1->Divide(2,1);
c1->cd(1);
hsb->Draw();
hb2a->Draw("same");
hb2->Draw("hist same");
latex.DrawLatex(20,100,"#color[4]{#uparrow}");
latex.SetTextSize(0.07);
latex.DrawLatex(30,100,"#color[4]{x 10}");
c1->cd(2);
hs2->Draw("hist");
c1->Draw();

$N_{ba}=20;\space \sigma_{N_{ba}}=\sqrt{20};$

$N_{b}'=10*N_{ba}=200;\space \sigma_{N_{b}}'=10*\sigma_{N_{ba}}=10*\sqrt{20};$

$\sigma_{N_0}'=\sqrt{\sigma_{N_s}^2+\sigma_{N_b}'^2}=\sqrt{N_s+2000}$

In [ ]: