void CDF_77_33() { TCanvas *c1 = new TCanvas(); ifstream file ("Mean v 77.3395.dat", ios::in); int loop=0; string x, y; double xx[22], yy[22], yy2[22], yy3[22] = {0.}; while(!file.eof()) { file >> x >> y; cout<0) { xx[loop-1]=std::stod(x); yy[loop-1]=std::stod(y); } loop++; } double sum=0; for(int m=0;mSetTitle(";Neutron Velocity (m/s);Cumulative Distributions"); grCDF->GetYaxis()->SetRangeUser(0.,1.1); grCDF->GetXaxis()->CenterTitle(true); grCDF->GetYaxis()->CenterTitle(true); grCDF->Draw("*AP"); // create a histograms with input data from dat file TH1F *h = new TH1F("",";Neutron Velocity (m/s);Entries",22,64,91); for (int i=0;i<22;i++) { h->SetBinContent(h->FindBin(xx[i]), yy[i]); } //h->SetBinContent(h->FindBin(xx[i]), yy[i]); // Now, try to fill a new histograms with random velocity: TH1F *h_new = new TH1F("",";Neutron Velocity (m/s);Entries",500,64,91); for (int i=0;i<100000;i++) { float randomVelocity = h->GetRandom(); for (int bin=1;bin<=h_new->GetNbinsX();bin++) { if (randomVelocity<=h_new->GetXaxis()->GetBinCenter(bin)-h_new->GetXaxis()->GetBinWidth(bin)) { h_new->AddBinContent(bin); } } } h_new->Scale(1/100000.); h_new->SetFillColor(kOrange-4); h_new->Draw("same"); }