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

From: Zhijun Liang <Zhijun.Liang_at_cern.ch>
Date: Fri, 13 Oct 2006 08:45:08 +0200


hi Philippe and Axel:
I konw where I made the mistake now .
I put the line """output<<"the output text"; """ outside the ana::begin(), it is a mistake. when I place this line inside ,everything is fine, thank you very much for your help.

best regards
Liang

-----Original Message-----
From: Philippe Canal [mailto:pcanal_at_fnal.gov] Sent: 2006-10-12 () 19:56
To: Zhijun Liang; Axel Naumann
Cc: roottalk_at_pcroot.cern.ch
Subject: RE: [ROOT] a question of <fstream> used in makeselector analyse file  

> 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 () 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 Fri Oct 13 2006 - 08:48:09 MEST

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