Re: [ROOT] TH1I

From: Edward Moyse (edward.moyse@cern.ch)
Date: Mon Sep 08 2003 - 14:43:47 MEST


I'm sorry Rene,  but I don't see how that can be it ... I'm using 2.96 which 
is less fussy about namespace, so I don't need to do those changes, but in 
any case.

#include <TROOT.h>
#include <TH1.h>
#include <vector>

class Analysis {
private:
std::vector<TH1S*>* m_particleLevelsHist;
};


compiles but :

#include <TROOT.h>
#include <TH1.h>
#include <vector>

class Analysis {
private:
std::vector<TH1I*>* m_particleLevelsHist;
//            ^^^^^^^

};

doesn't.

However I have tracked down the source of my problem and confusion: the 
machine I was using to compile has 
ROOTSYS= /afs/cern.ch/sw/root/v3.05.05/rh73_gcc296/root
whilst the machine I was browsing code on has:
ROOTSYS=/afs/cern.ch/sw/root/v3.05.07/rh73_gcc296/root
and I gather TH1I si a recent addition?

I have no idea how this is possible, since both *should* be using the same 
.zshrc but I will investigate. Sorry about that though - I should have 
checked this first.

Nevertheless, even in the latest version of ROOT(3.05/07) it appears that 
there's no TH1I.h file, like TH1S.h, TH1F.h etc. I know they don't do 
anything other than include TH1.h but it seems a bit inconsistent not to have 
a TH1I.h version too.

Cheers,

Ed

On Monday 08 September 2003 2:26 pm, Rene Brun wrote:
> Ed,
>
> The problem has nothing to do with TH1I, but with an incomplete declaration
> of vector. Choose one of the two solutions:
>
> //solution1
> ===========
> #include <TROOT.h>
> #include <TH1.h>
> #include <vector>
> using namespace std;
>
> class Analysis {
> private:
> vector<TH1S*>* m_particleLevelsHist;
> };
>
> solution2
> =========
> #include <TROOT.h>
> #include <TH1.h>
> #include <vector>
>
> class Analysis {
> private:
> std::vector<TH1S*>* m_particleLevelsHist;
> };
>
> Rene Brun
>
> Edward Moyse wrote:
> > Okay. If you compile the following very, very simple example with :
> > g++ -c -fPIC `root-config --cflags` test.cxx
> > then it works.
> >
> > Change:
> > vector<TH1S*>* m_particleLevelsHist;
> > to:
> > vector<TH1I*>* m_particleLevelsHist;
> >
> > then it doesn't and I get:
> > test.cxx:8: `TH1I' was not declared in this scope
> > test.cxx:8: parse error before `>'
> >
> > ---------------------------------------- test.cxx
> > #include <TROOT.h>
> > #include <TH1.h>
> > #include <vector>
> >
> > class Analysis {
> > private:
> > vector<TH1S*>* m_particleLevelsHist;
> > };
> >
> > On Monday 08 September 2003 1:38 pm, Rene Brun wrote:
> > > Ed,
> > >
> > > TH1I is defined in TH1.h. I do not see any problems with your example.
> > >
> > > Send a short script reproducing the problem.
> > >
> > > Rene Brun
> > >
> > > Edward Moyse wrote:
> > > > Hi,
> > > >
> > > > Can anyone explain why:
> > > >
> > > > #include <TH1.h>
> > > > vector<TH1S*>* m_particleLevelsHist;
> > > >
> > > > works, but
> > > > #include <TH1.h>
> > > > vector<TH1I*>* m_particleLevelsHist;
> > > > gives:
> > > >
> > > > In file included from Analysis.C:1:
> > > > Analysis.h:70: `TH1I' was not declared in this scope
> > > >
> > > > I'd guess that TH1Is aren't supported somehow., especially since
> > > > there's a TH1F header which just points to TH1.h, but there's no
> > > > TH1I.h header doing the same thing.
> > > >
> > > > % ls $ROOTSYS/include/TH1*
> > > > /afs/cern.ch/sw/root/v3.05.07/rh73_gcc296/root/include/TH1.h
> > > > /afs/cern.ch/sw/root/v3.05.07/rh73_gcc296/root/include/TH1C.h
> > > > /afs/cern.ch/sw/root/v3.05.07/rh73_gcc296/root/include/TH1D.h
> > > > /afs/cern.ch/sw/root/v3.05.07/rh73_gcc296/root/include/TH1F.h
> > > > /afs/cern.ch/sw/root/v3.05.07/rh73_gcc296/root/include/TH1K.h
> > > > /afs/cern.ch/sw/root/v3.05.07/rh73_gcc296/root/include/TH1S.h
> > > >
> > > > But this page:
> > > > http://root.cern.ch/root/html/TH1I.html
> > > > definitely lists TH1Is as an available type of histogram.
> > > >
> > > > Cheers,
> > > >
> > > > Ed



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:15 MET