Home | News | Documentation | Download

Contour Plot with bin error

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();
}
  1. this is not a COL plot but it is a BOX plot
  2. the number of bins (270) for your histogram is much larger than the number of bin of this plot. Also the binning of the plot seems to be not regular. So a regular binning as you do is not right very likely.

May be you should try ask for the orignal macro which produces this plot.

Okay. Thanks a lot for the reply.