RE: a question of <fstream> used in makeselector analyse file

From: Philippe Canal <pcanal_at_fnal.gov>
Date: Thu, 12 Oct 2006 12:56:54 -0500


> it does not work ,how can I do ?

How does it not work?

> I do not quite understand how to include C++ version of the fstream
header.

Simply replace

#include <fstream.h>      //the line I added in ana.C
#include <iostream.h>     //the line I added in ana.C
by
#include <fstream>      //the line I added in ana.C
#include <iostream>     //the line I added in ana.C

Cheers,
Philippe

-----Original Message-----
From: owner-roottalk_at_pcroot.cern.ch [mailto:owner-roottalk_at_pcroot.cern.ch] On Behalf Of Zhijun Liang
Sent: Thursday, October 12, 2006 10:20 AM To: Axel Naumann
Cc: roottalk_at_pcroot.cern.ch
Subject: re: [ROOT] a question of <fstream> used in makeselector analyse file

dear Axel:
it does not work ,how can I do ?
I do not quite understand how to include C++ version of the fstream header. my system is fedora linux ,root version is 5.12, gcc version is 4.1.0
thank you very much
best regards
Liang
-----Original Message-----
From: Axel Naumann
Sent: 2006-10-12 ($B_at_14|;M(B) 15:56
To: Zhijun Liang
Cc: roottalk_at_pcroot.cern.ch
Subject: Re: [ROOT] a question of <fstream> used in makeselector analyse file  

Hi,

you should #include the C++ version of the fstream header:

#include "ana.h"
#include <TH2.h>
#include <TStyle.h>
#include <fstream>      //the line I added in ana.C

using namespace std;
ofstream output("out.txt"); //the line I added in ana.C output<<"the output text"; //the line I added in ana.C

Does that help?

Cheers, Axel.

Zhijun Liang wrote:
> dear all:
> I meet some problem in using fstream object in files generated by
makeselector or makeclass .
> could you help me?
> for example :in tutorial directory
> ""
> TFile f("tree1.root");
> t1->MakeSelector("ana");
> ""
> and then I add 4 lines in ana.C to do file output .
>
> """
> #include "ana.h"
> #include <TH2.h>
> #include <TStyle.h>
> #include <fstream.h> //the line I added in ana.C
> #include <iostream.h> //the line I added in ana.C
> ofstream output("out.txt",ios::out); //the line I added in ana.C
> output<<"the output text"; //the line I added in ana.C
> """
> and then I use
> "'
> TFile f("tree1.root");
> t1->process("ana.C+");
> ""
> error message is :
> Error: Symbol output is not defined in current scope ana.C:32:
> Error: << Illegal operator for pointer 3 ana.C:32:
>
> it seems the fstream can not be used in makeselector files ,could you help
me?
> thank you
>
> best regards
> Liang
>
Received on Thu Oct 12 2006 - 19:57:24 MEST

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:32:01 MET