用Xshell画图时写一个程序将一个.root文件中的参数读取出来画出相应的直方图
#include<iostream>
#include<fstream>
#include<string>
#include<sstream>
#include<vector>
#include <TGraph.h>
using namespace std;
void hist()
{
ifstream in_hist;
in_hist.open("沉积能量.txt");
Float_t ene;
TH1F *h1 = new TH1F("ene","ene_num",100,0,1);
while(1)
{
in_hist >> ene;
if(!in_hist.good())break;
h1->Fill(ene);
}
in_hist.close();
TCanvas *c1 = new TCanvas();
//gstyle->SetOptStat(kFALSE);
//gstyle->SetPalette(kRainBow);
//c1->Divide(1,1);
//c1->cd(1);
h1->Draw();
}