# How I can convert dat file to root file

**URL:** <https://root-forum.cern.ch/t/how-i-can-convert-dat-file-to-root-file/37793>\
**Category:** ROOT\
**Created:** [January 30, 2020, 8:45pm UTC](https://root-forum.cern.ch/t/how-i-can-convert-dat-file-to-root-file/37793 "2020-01-30T20:45:36Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [January 30, 2020, 9:02pm UTC](https://root-forum.cern.ch/t/how-i-can-convert-dat-file-to-root-file/37793/2 "2020-01-30T21:02:06Z")

</div>

```cpp
{
  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);
}

```

---

_[View the full topic](https://root-forum.cern.ch/t/how-i-can-convert-dat-file-to-root-file/37793)._
