clearer
 

#include <TSystem.h>
#include <TProfile.h>
#include <TBrowser.h>
#include <TROOT.h>
#include <TGraph.h>
#include <TNtuple.h>
#include <TString.h>
#include <TH1D.h>
#include <TFile.h>
#include <TH1D.h>
#include <TF1.h>
#include <TMath.h>
#include <TH2D.h>
#include <TCanvas.h>
#include <TLegend.h>
#include <TStyle.h>
#include <TLatex.h>
#include <TInterpreter.h>
#include <TGraphAsymmErrors.h>
#include <TGraphErrors.h>

void readTxT() {

TFile *pfOutput;
ifstream in; 
in.open("example.txt");
pfOutput = new TFile("out.root","RECREATE");
cout<<"!!!!!!!!!!!Got the input files!!!!"<<endl;
double x[18];
double aaa[300], bbb[300], ccc[300], ddd[300];
int nline = 0;
TH1F *hTest = new TH1F("hTest",";Temp;A.U",1000, 0, 10000);
string tmpstring;
getline(in,tmpstring);
getline(in,tmpstring);
if( !in.good() ) cout<< "!!!!! You have a problem, the input file is not good" <<endl;
while (in.good()) {
  in >> x[0] >> x[1] >> x[2] >> x[3] >> x[4] >> x[5] >> x[6] >> x[7] >> x[8] ;
  aaa[nline] = x[0]; bbb[nline] = x[1]; ccc[nline] = x[2]; ddd[nline] = x[3]; 
  cout<<"nline= "<<nline<<" y= " <<x[0] <<"-"<< x[1] << "\t pt= "<<x[2] <<"-"<<x[3] <<endl;
  hTest->Fill(x[0]);
  nline++;
}// while
printf(" found %d points\n",nline);
cout<<"#######  Done reading the input dat file!"<<endl;
pfOutput->cd();

TH1::SetDefaultSumw2();

hTest->Write();
in.close();
pfOutput->Write();
cout<<"####### Wrote hists to file, and closed file! Good luck!"<<endl;

}

dhmoon/readingfilemacro.txt · 마지막 수정: 2019/12/07 12:36 작성자 dhmoon
 
광주광역시 북구 용봉동 전남대학교 자연대 4호관 물리학과 319호 | Tel. +82-62-530-3484
Bld.4-319 Department of Physics, Chonnam National University, 77 Yongbong-ro, Buk-gu, Gwangju 500-757, KOREA
별도로 라이선스를 알리지 않을 경우, 이 위키의 내용은 다음의 라이선스에 따릅니다: CC Attribution-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki