MakeClass-made-classes won't compile

Dear RooTers,

This is probably a rookie’s stupid question, so sorry in advance.

I am using TTree::MakeClass to generate a .C and .h
file from a given tree (called “Data”). This tree contains
TH1 and TH2 histograms.

Here are the beginnigs of the files:

Data.h:

[code]//////////////////////////////////////////////////////////
// This class has been automatically generated
// (Fri Feb 13 17:21:13 2004 by ROOT version3.10/02)
// from TTree Data/Data
// found on file: /data/usr/lumi/data/Root/040201/21h.root
//////////////////////////////////////////////////////////

#ifndef Data_h
#define Data_h

#include <TROOT.h>
#include <TChain.h>
#include <TFile.h>

class Data {
public :
TTree *fChain; //!pointer to the analyzed TTree or TChain
Int_t fCurrent; //!current Tree number in a TChain
//Declaration of leaves types
UInt_t TimeStamp_date;
[…]
TH2F *LED_ET1;
TH1F *TrainEtotY_Ped;
[…][/code]

Data.C:

[code]#define Data_cxx
#include “Data.h”
#include “TH2.h”
#include “TStyle.h”
#include “TCanvas.h”

void Data::Loop()
{
[…]
[/code]

Compilation with ACLiC fails:

[color=blue][size=75]Error: Symbol TH2F is not defined in current scope FILE:/afs/desy.de/user/s/specka/lumi/LOnlChx/LOnlClasses/Data.h LINE:99
Error: Symbol LED_ET1 is not defined in current scope FILE:/afs/desy.de/user/s/specka/lumi/LOnlChx/LOnlClasses/Data.h LINE:99
Error: Symbol TH1F is not defined in current scope FILE:/afs/desy.de/user/s/specka/lumi/LOnlChx/LOnlClasses/Data.h LINE:100
Error: Symbol TrainEtotY_Ped is not defined in current scope FILE:/afs/desy.de/user/s/specka/lumi/LOnlChx/LOnlClasses/Data.h LINE:100[/size][/color]

This comes as no surprise because the C precompiler pragma #include "TH2.h"
comes after #include “Data.h” in Data.C, and Data.h contains
no pragma #include “TH2.h” at all.

Changing the order of the pragmas by hand helps, of course.

Maybe there’s something wrong with my setup (include path etc.),
so that ACLiC does not know about TH2 (and TH1, and other RooT classes).

Thanks

Arnd

Hi,

You need to put line like

#include "TH1.h" #include "TH2.h"
in you Data.h just after the

Cheers,
Philippe

Dear Philippe,
Yes, I know that. In fact it is sufficient to invert the order of
#include <Data.h>
#include <TH2.h>
in the Data.C

My question related was rather why MakeClass does not put the required #include pragmas
in the currect order all by itself.

Cheers

Arnd

Hi Arnd,

The include lines that listed in the .C files are intented to allow using histogram and canvas to display the content of the data.

The include line in the .h files are intented to declared the object type
that are in your tree. Currently this has to be done by hand. (i.e. ROOT
never put them their for you).

It just so happen that you data are histograms, so it appears that
ROOT tried to include the correct include files for you … but it did not :slight_smile:

We hope to improve on this in a later release.

Cheers,
Philippe.