/// \file /// \ingroup tutorial_hist /// \notebook -js /// Illustrate use of the TH1::GetCumulative method. /// /// \macro_image /// \macro_code /// /// \author M. Schiller #include #include #include "TH1.h" #include "TH1D.h" #include "TCanvas.h" #include "TRandom.h" #include #include #include #include #include #include #include void original() { TCanvas* c = new TCanvas(); Float_t Min[5]; Float_t Mean[5] = {0.0,0.0,0.0,0.0, 0.0}; Float_t X[5] = {100,1000,2000,4000,8000}; Float_t y; Int_t t =0; //Read File 100_stats ifstream inp; inp.open("100_stats.txt"); TNtuple *stats100 = new TNtuple("stats100","data from ascii file","x:y"); while (1) { inp >> y; if (!inp.good()) break; stats100->Fill(100,y); } inp.close(); //Read File 1000_stats inp.open("1000_stats.txt"); TNtuple *stats1000 = new TNtuple("stats1000","data from ascii file","x:y"); while (1) { inp >> y; if (!inp.good()) break; stats1000->Fill(1000,y); } inp.close(); //Read File 2000_stats inp.open("2000_stats.txt"); TNtuple *stats2000 = new TNtuple("stats2000","data from ascii file","x:y"); while (1) { inp >> y; if (!inp.good()) break; stats2000->Fill(2000,y); } inp.close(); //Read File 4000_stats inp.open("4000_stats.txt"); TNtuple *stats4000 = new TNtuple("stats4000","data from ascii file","x:y"); while (1) { inp >> y; if (!inp.good()) break; stats4000->Fill(4000,y); } inp.close(); //Read File 8000_stats inp.open("8000_stats.txt"); TNtuple *stats8000 = new TNtuple("stats8000","data from ascii file","x:y"); while (1) { inp >> y; if (!inp.good()) break; stats8000->Fill(8000,y); } inp.close(); stats100->SetBranchAddress("y",&y); stats1000->SetBranchAddress("y",&y); stats2000->SetBranchAddress("y",&y); stats4000->SetBranchAddress("y",&y); stats8000->SetBranchAddress("y",&y); t = stats100->GetEntries(); for (Int_t i=0; iGetEntry(i); if (i == 0) Min[0] = y; else if (Min[0] > y) Min[0] = y; Mean[0] += y; //Stats_1000 stats1000->GetEntry(i); if (i == 0) Min[1] = y; else if (Min[1] > y) Min[1] = y; Mean[1] += y; //Stats_2000 stats2000->GetEntry(i); if (i == 0) Min[2] = y; else if (Min[2] > y) Min[2] = y; Mean[2] += y; //Stats_4000 stats4000->GetEntry(i); if (i == 0) Min[3] = y; else if (Min[3] > y) Min[3] = y; Mean[3] += y; //Stats_8000 stats8000->GetEntry(i); if (i == 0) Min[4] = y; else if (Min[4] > y) Min[4] = y; Mean[4] += y; } Mean[0] /= t; Mean[1] /= t; Mean[2] /= t; Mean[3] /= t; Mean[4] /= t; TGraph *G1 = new TGraph(5,X,Mean); G1->SetTitle(""); G1->GetXaxis()->SetRangeUser(0,8100); G1->GetXaxis()->SetTitle("Amount of samples"); G1->GetXaxis()->SetTitleSize(0.025); G1->GetXaxis()->SetTickLength(-0.02); G1->GetXaxis()->SetLabelSize(0.02); G1->GetXaxis()->SetLabelOffset(0.04); G1->GetXaxis()->CenterTitle(); G1->GetXaxis()->SetTitleOffset(3); TAxis* a = G1->GetXaxis(); a->SetNdivisions(510, kTRUE); a->ChangeLabel(1,-1,-1,-1,-1,-1,"100"); a->ChangeLabel(4,-1,0.); a->ChangeLabel(6,-1,0.); a->ChangeLabel(8,-1,0.); G1->GetYaxis()->SetRangeUser(5,27); G1->GetYaxis()->SetTitle("Penalty Value"); G1->GetYaxis()->SetTitleSize(0.025); G1->GetYaxis()->SetTickLength(-0.013); G1->GetYaxis()->SetLabelSize(0.02); G1->GetYaxis()->SetLabelOffset(0.008); G1->GetYaxis()->CenterTitle(); G1->GetYaxis()->SetTitleOffset(1.9); G1->SetLineWidth(3); G1->SetLineColor(38); G1->Draw("APL"); gPad->SetGrid(1,1); TLine *l = new TLine(0,9.278828,8100,9.278828); l->SetLineColor(14); l->SetLineWidth(2); l->SetLineStyle(7); l->Draw(); TMarker *m; for (Int_t i=0; iGetEntry(i); m = new TMarker(100,y, 7); m->SetMarkerStyle(8); m->SetMarkerSize(2.0); m->SetMarkerColor(30); if (y == Min[0]) m->SetMarkerColor(46); m->Draw("same"); stats1000->GetEntry(i); m = new TMarker(1000,y, 7); m->SetMarkerStyle(8); m->SetMarkerSize(2.0); m->SetMarkerColor(30); if (y == Min[1]) m->SetMarkerColor(46); m->Draw("same"); stats2000->GetEntry(i); m = new TMarker(2000,y, 7); m->SetMarkerStyle(8); m->SetMarkerSize(2.0); m->SetMarkerColor(30); if (y == Min[2]) m->SetMarkerColor(46); m->Draw("same"); stats4000->GetEntry(i); m = new TMarker(4000,y, 7); m->SetMarkerStyle(8); m->SetMarkerSize(2.0); m->SetMarkerColor(30); if (y == Min[3]) m->SetMarkerColor(46); m->Draw("same"); stats8000->GetEntry(i); m = new TMarker(8000,y, 7); m->SetMarkerStyle(8); m->SetMarkerSize(2.0); m->SetMarkerColor(30); if (y == Min[4]) m->SetMarkerColor(46); m->Draw("same"); } c->Update(); gPad->Print("Stats.tex"); gPad->Print("Stats.pdf"); }