Global, local variable and ACLiC

file macro.C:[code]
{
gROOT->Reset();
TFile *file = new TFile(“file.root”,“READ”);
TTree tree = (TTree)file->Get(“tree”);
TEvent *event = new TEvent;
tree->SetBranchAddress(“TEvent”,&event);

gROOT->LoadMacro(“functions.C+”);
}[/code]
file functions.C:[code]
#include “TEvent.h”

#include “TFile.h”
#include “TTree.h”

// ??? TTree *tree =
// ??? TEvent *event =

void foo1()
{

for (Int_t i = 0; i < tree->GetEntries(); i++) {
tree->GetEntry(i);
bla = event->GetBla();
}

}

void foo2()
{

for (Int_t i = 0; i < tree->GetEntries(); i++) {
tree->GetEntry(i);
bla2 = event->GetBla2();
}

}

void foo3()
{
// using global variables from file macro.C
}
[/code]

How define global variables from macro.C (with their values !) in functions foo ? or another way ?

Thanks, Jan

The best is not to use any global but to pass the value by parameter:

void foo1(TTree *tree, Event *&event) {...} If you absolutely need a globals then the easiest is to use

[code]#include “TEvent.h”

#include “TFile.h”
#include “TTree.h”

TTree *tree = 0;
TEvent *event = 0;

void foo1()
{
…[/code]and[code]{
gROOT->Reset();
gROOT->LoadMacro(“functions.C+”);
TFile file = new TFile(“file.root”,“READ”);
tree = (TTree
)file->Get(“tree”);
event = new TEvent;
tree->SetBranchAddress(“TEvent”,&event);

}
[/code]or one of a few other ways.

Cheers,
Philippe.