// this is the main program, no need to do anything here int main(int argc, char* argv[]) { // sum of squares error info for histograms TH1D::SetDefaultSumw2(); // create analysis // NoiseSystematics analyser(argc, argv); // analyser.run(); TFile* ofile = new TFile("NoiseSystematics.root", "RECREATE"); std::cout << "Output file : " << ofile->GetName() << std::endl; if (ofile->IsZombie()) { std::exit(2); } TH1F hcosmic("hcosmic","",10,0,10); TH1F hobs("hobs",";# expected events;",10,0,10); TH1F hnoise("hnoise","",10,0,10); TRandom2 rndm; for (int i = 0; i < 10000; i++) { // DT by RPC background: 0.96061 +/- 0.559146 double ncos = rndm.Poisson(rndm.Gaus (0.96, 0.56)); double nobs = rndm.PoissonD(2.); hcosmic.Fill(ncos); hobs.Fill(nobs); hnoise.Fill(nobs-ncos); //std::cout << ncos << "\t" << nobs << "\t" << nobs-ncos << std::endl; } double nq = 1; Double_t xq[1] = {0.68}; // position where to compute the quantiles in [0,1] Double_t yq[1] = {0.}; // array to contain the quantiles hnoise.GetQuantiles(nq,yq,xq); std::cout << xq[0] << "\t" << yq[0] << std::endl; ofile->cd(); ofile->Write("",TObject::kOverwrite); TCanvas c("c"); hnoise.SetStats(0); hobs.SetStats(0); hcosmic.SetStats(0); hcosmic.SetLineColor(kRed); //hcosmic.Scale(1.4); hobs.SetLineColor(kBlue); hnoise.SetLineColor(kBlack); hcosmic.SetMaximum(hcosmic.GetMaximum()*1.1); hcosmic.Draw("hist"); hobs.Draw("hist same"); hnoise.Draw("hist same"); c.Update(); TLine line(yq[0],0,yq[0],hcosmic.GetMaximum()); line.SetLineColor(kBlack); line.SetLineStyle(5); line.SetLineWidth(2); line.Draw(); TLegend leg(0.6, 0.70, 0.88, 0.85); leg.SetFillColor(kWhite); leg.AddEntry("hcosmic", "N_{cosmic}", "l"); leg.AddEntry("hobs", "N_{obs} [#lambda = 2]","l"); leg.AddEntry("hnoise", "n_{noise} = N_{obs} - N_{cosmic}","l"); leg.SetBorderSize(0); leg.Draw(); c.SaveAs("NoiseSystematics.pdf"); return 0; }