ROOT Version:_ 6.18/00
Platform:_ Ubuntu 20.04
I wanted to plot this figure
. Which is from this paper https://arxiv.org/pdf/hep-ex/0606028.pdf. Here is the root file.data.root (8.1 KB) .Here is my code. dat_root.C (1.7 KB) and the text file data.txt (7.7 KB) . Can anyone please help me? I wanted to add the error (I hope the data is sufficient to for the error ).
#include<iostream>
#include<fstream>
#include<TFile.h>
#include<TNtuple.h>
#include<TCanvas.h>
#include<TH2F.h>
void dat_root()
{
ifstream data;
Float_t xF, pT, xsect, error;
data.open("data.txt");
TFile* file = new TFile("data.root","RECREATE");
// TTree* tree = 0;
TNtuple* ntup = new TNtuple("ntup","import data file","xF:pT:xsect:error");
while(1){
data>>xF>>pT>>xsect>>error;
if(!data.good()) break;
ntup->Fill(xF,pT,xsect,error);
// cout<<xF<<pT<<xsect<<error<<endl;
}
data.close();
file->Write();
file->Get("ntup");
//access branch
ntup->SetBranchAddress("xF",&xF);
ntup->SetBranchAddress("pT",&pT);
ntup->SetBranchAddress("xsect",&xsect);
ntup->SetBranchAddress("error",&error);
Int_t nEntries = 271;
Int_t nbins = 270;
TH2F* hist = new TH2F(""," ",nbins,0,0.5,nbins,0,1);
TH1F* hist_c = new TH1F(""," ",nbins,0,700);//,nbins,0,1);
TCanvas* c = new TCanvas("c","",800,600);
for (Int_t i = 0; i<nEntries; i++)
{
ntup->GetEntry(i);
hist->Fill(xF,pT);
// hist_c->Fill(xsect,error);
//hist_c->Fill(xsect,error);
}
hist->SetMarkerStyle(kFullDotMedium);
hist->SetMarkerColor(1);
hist->GetXaxis()->SetRangeUser(0,0.5);
hist->GetYaxis()->SetRangeUser(0,1);
//ntup->Draw("xF:pT","xsect","COLZ");
// hist->SetCellError(xF,pT,error);
hist->Draw("COLZ");
hist->SetLineColor(kBlack);
//ntup->Draw("pT:xF","error","colz"); // for weighting with error
// hist_c->Draw("COLZ SAME");
hist->GetXaxis()->SetTitle("Feynman Variable xF");
hist->GetYaxis()->SetTitle("Momentum Transverse pT");
c->Update();
}