TH1F *DrawFrame(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax, const char *title) { // Draw a pad frame // This function is a copy of TPad::DrawFrame in CVS head // // Compute real pad range taking into account all margins // Use services of TH1F class TH1F *hframe = (TH1F*)gPad->FindObject("hframe"); if (hframe) delete hframe; Int_t nbins = 1000; //if log scale in X, use variable bin size linear with log(x) //this gives a better precision when zooming on the axis if (gPad->GetLogx() && xmin > 0 && xmax > xmin) { Double_t xminl = TMath::Log(xmin); Double_t xmaxl = TMath::Log(xmax); Double_t dx = (xmaxl-xminl)/nbins; Double_t *xbins = new Double_t[nbins+1]; xbins[0] = xmin; for (Int_t i=1;i<=nbins;i++) { xbins[i] = TMath::Exp(xminl+i*dx); } hframe = new TH1F("hframe",title,nbins,xbins); delete [] xbins; } else { hframe = new TH1F("hframe",title,nbins,xmin,xmax); } hframe->SetBit(TH1::kNoStats); hframe->SetBit(kCanDelete); hframe->SetMinimum(ymin); hframe->SetMaximum(ymax); hframe->GetYaxis()->SetLimits(ymin,ymax); hframe->SetDirectory(0); hframe->Draw(" "); gPad->Update(); return hframe; } void leggi() { TCanvas *c1= new TCanvas("c1","c1",200,10,700,500); c1->SetLogy(kTRUE); c1->SetLogx(kTRUE); c1->SetGrid(kTRUE); int nlines=0,n=0; FILE *file; file=fopen("xs.dat","r"); if(file==NULL) { cout << "Errore apertura file!" << endl; } char riga[10000]; float energy_,xs_,xserr_; float energy[10000],xs[10000],xserr[10000]; while(fscanf(file,"\n%[^\n]",riga)>EOF) { sscanf(riga, "%f %f %f", &energy_,&xs_,&xserr_); energy[n]=energy_; xs[n]=xs_; xserr[n]=xserr_; nlines++; n++; } fclose(file); cout << nlines << endl; TGraphErrors *gr = new TGraphErrors(nlines,energy,xs,0,xserr); gr->SetMarkerStyle(21); gr->SetMarkerSize(0.5); gr->SetMarkerColor(4); TH1F *hpx = DrawFrame(1e-2,1e-2,5e6,5e6,"Sezione d'urto^{245}Cm"); hpx->GetXaxis()->CenterTitle(); hpx->GetXaxis()->SetTitle("E_{n} (eV)"); hpx->GetYaxis()->CenterTitle(); hpx->GetYaxis()->SetTitle("#sigma (barn)"); hpx->GetYaxis()->SetLimits(1e-2,5e6); gr->Draw("lp"); }