#include #include #include #include #include #include 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<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; iGetEntry(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(); }