Re: [ROOT] Fill vector to histogram

From: Rene Brun (Rene.Brun@cern.ch)
Date: Tue Oct 03 2000 - 19:15:30 MEST


Hi Hucheng,
Here a small example. You can find more in the tutorials


{
//   example of macro to read data from an ascii file and
//   create an histogram

   ifstream in;
   in.open("basic.dat", ios::in);

   Float_t x;
   TH1F *h1 = new TH1F("h1","x distribution",100,-4,4);

   while (1) {
      in >> x;
      if (!in.good()) break;
      h1->Fill(x);
   }
   h1->Draw();
}


Rene Brun

Hucheng CHEN wrote:
> 
> Hi, Rooters:
> 
> I am a new rooter, I have one simple questions. For example, I have a simple
> data file, which includes one column of data. In PAW, I can read this data
> file to one vector, then fill this vector to one hisgram by command hfill.
> 
> vec/read a a.dat
> hfill a 1
> h/pl 1
> 
> Now in ROOT, how can I implement this simple task. Thank you very much.
> 
> Regards,
> 
> Hucheng
> -----------------------------------------------------------------
>  ------------------------------   Hucheng CHEN
>      _/_/_/_/   _/    _/   _/     Omega Group
>     _/    _/   _/_/  _/   _/      Physics Department
>    _/_/_/     _/ _/ _/   _/       Building 510
>   _/    _/   _/  _/_/   _/        P. O. Box 5000
>  _/_/_/_/   _/    _/   _/_/_/_/   Brookhaven National Laboratory
>  Brookhaven National Laboratory   Upton, NY 11973-5000
>  ------------------------------   USA
> --------------------------------  Tel: 631-344-3468
>  Home Phone: 631-344-1210         Fax: 631-344-5568
>  URL: http://www.bnl.gov          E-Mail: chc@bnl.gov
> -----------------------------------------------------------------



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:34 MET