void StatNewEPScatteringSample01() { static Int_t nof = 500; // number of functions to be generated auto can = new TCanvas("c1", "c1", 800,800); // setting the canvas //gStyle->SetOptStat("nerf"); //gStyle->SetOptStat(); gStyle->SetOptStat(0); can->Draw(); auto avf = new TH1F("avf", "Average of Functions", 100, 0.0025, 1.0); avf->Draw(); //=== generating the functions ===// TF1 *fpf[nof], *ppf[nof]; TString fna; for (Int_t i=0; iSetParameter(0,1.0); fpf[i]->SetParameter(1,1.0); fpf[i]->SetParameter(2,1.0/137.0); fpf[i]->SetParameter(3,gRandom->Gaus(0.938272081,0.000000023)); fpf[i]->SetParameter(4,10.0); fpf[i]->SetParameter(5,TMath::Pi()); fpf[i]->SetParameter(6,2.793); } for (Int_t i=0; iSetParameter(0,1.0); ppf[i]->SetParameter(1,1.0); ppf[i]->SetParameter(2,1.0/137.0); ppf[i]->SetParameter(3,gRandom->Gaus(0.938272081,0.000000023)); ppf[i]->SetParameter(4,10.0); ppf[i]->SetParameter(5,TMath::Pi()); ppf[i]->SetParameter(6,2.793); } //=== getting the average ===// Int_t nop=100; Double_t xpt, ypt, del = 0.9975/nop; TGraph *av1 = new TGraph(); for (Int_t j=0; j < nop; j++) { xpt = del*j + 0.0025*del; av1->SetPoint(j, xpt, 0.0); } for (Int_t i=0; iGetPoint(j, xpt, ypt); av1->SetPoint(j, xpt, ypt + fpf[i]->Eval(xpt)/(Double_t)nof); } } TGraph *av2 = new TGraph(); for (Int_t j=0; j < nop; j++) { xpt = del*j + 0.0025*del; av2->SetPoint(j, xpt, 0.0); } for (Int_t i=0; iGetPoint(j, xpt, ypt); av2->SetPoint(j, xpt, ypt + ppf[i]->Eval(xpt)/(Double_t)nof); } } TGraph *av4 = new TGraph(); int j = 0; double eps = 0.0001; for (Int_t i=0; iGetPoint(i, xpt, ypt); if (abs(xpt - 0.409) < eps || abs(xpt - 0.6085) < eps || abs(xpt - 0.808) < eps || abs(xpt - 0.9676) < eps ) { av4->GetPoint(i, xpt, ypt); av4->SetPoint(j, xpt, ypt + ppf[i]->Eval(xpt)/(Double_t)nof); j++; } } //=== pLotting the average on canvas ===// gPad->SetLogy(1); av1->SetMarkerStyle(7); av1->SetMarkerColor(kBlue); av1->SetMarkerSize(1); av2->SetMarkerStyle(6); av2->SetMarkerColor(kRed); av2->SetMarkerSize(1); av4->SetMarkerStyle(3); av4->SetMarkerColor(kMagenta); av4->SetMarkerSize(1); TMultiGraph *mgp = new TMultiGraph(); mgp->SetMinimum(1.e-4); mgp->SetMaximum(1.e0); mgp->Add(av1,"PL"); mgp->Add(av2,"PL"); mgp->Add(av4,"PL"); mgp->Draw("a"); avf->SetMaximum(1.e0); can->Modified(); can->Update(); }