How I can convert dat file to root file

Dear Sir,

I am new to root and willing to learn it at my highest. I recently performed an experiment and the collection of data was in the form of .dat format. I am interested to turn it to .root file, where X axis are channels and Y axis - counts. The file is attched herewith.
I have gone through the Generate root file from a data file, but unable to convert.

Eagerly waiting to receive suggestions.

Much Respect
VJ
10B27Al-120MeV-Ge-8.dat.tar.gz (29.2 KB)

{
  TGraph *g = new TGraph("10B27Al-120MeV-Ge-8.dat");
  g->SetTitle("Sample title;channel number;#counts");
  Int_t T_real = g->GetY()[0]; g->GetY()[0] = 0;
  Int_t T_vivo = g->GetY()[1]; g->GetY()[1] = 0;
  std::cout << "Espectro en: " << g->GetN() << " canales" << std::endl;
  std::cout << "T real: " << T_real << " s" << std::endl;
  std::cout << "T vivo: " << T_vivo << " s" << std::endl;
  g->Draw("ALP");
  // g->SetMinimum(1); gPad->SetLogy(1);
}
1 Like

Dear Sir, million thanks for helping me.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.