Can I use *.ASC files?

Hello All,
I have an asc file and want use this on root. Until now, I always used *.dat files to create a histogram. But now, I want to use my asc file. But I can not accomplish.
How can I achieve?
Is there anyone to give me some tips?
Best wishes to you all

Serkan

Hi,

How is your *.asc different from you *.dat file?
How does it fails to load?

Philippe

my asc file contain values such as
1
2
5
3
2
1
.
.
.
When I draw this, we see in the spectrum as
1 count in channel 1
two counts in channel 2
five counts in channel 3 etc.

but in dat files containing the values as above, I see,
two counts in channel 1 (due to there are two 1 )
two counts in channel 2 (due to there are two 2 )
one count in channel 3 (due to three is one 3)
one count in channel 5 etc.

with best wishes
serkan

Is there any program which converts asc files to dat files?
best regards

Something like this might help you:

#include <fstream>
#include <vector>
// #include <iostream>

#include "TH1.h"

void readasc()
{

  vector<Float_t> dat;
  ifstream in;
  in.open("foo.asc");

  //read file
  while( in.good() )
    {
      Double_t num;
      in >> num;
      // std::cout << "in.fail():" << in.fail() << "; num=" << num << std::endl;
      if( in.fail() )
        break;
      dat.push_back(num);
    }

  // fill histo
  Int_t numbins = dat.size();
  TH1F* h = new TH1F("h1","h1", numbins, 0, numbins );
  for ( Int_t i=0; i != numbins; ++i )
    {
      h->SetBinContent( i+1, dat.at(i) );
      h->SetEntries( h->GetEntries()+i );
    }

  //draw histo
  h->Draw();

}

foo.asc.txt (14 Bytes)
readasc.C (650 Bytes)

Thank you very much
The program that you send is OK for solving my problem.
Best Regards

Serkan