Problem with ACLiC

Hello,

I have compiled a macro with ACLiC without problems. However one of the variables (integer one) become 0 when I make
t_p->SetBranchAddress(“Nout”,&Nout);
and, then, I try to use it (e.g., just printing it out).
However, if I run the macro iteratively it returns the true value.

Do you have an idea of what is going on?

Many thanks in advance.
Helena

Hi,

What is the type of the branch Nout (TTree::Print will remind you) and what is the type of the variable Nout?

Philippe

It is:
*Br 22 :Nout : Nout/I *
*Entries : 29499 : Total Size= 118846 bytes File Size = 12565 *
*Baskets : 3 : Basket Size= 32000 bytes Compression= 7.64 *

what is the type of the variable Nout?

Philippe

Sorry. It is an integer.

I create this variable and its branch with a simple code:
static int Nout; // Number of tracks in primary vertex
sitree->Branch(“Nout”, &Nout, “Nout/I”);
Nout = vP.NOutParticles();
Then, I run a macro which reads the Tree.
If I open the ntuple and print the event’s variables, e.g.:
USRSI->Show(10)
Xprim = 0.397437
Yprim = -0.931583
Zprim = -68.5966
Nout = 2

But, if I compile with ACLiC, althoug everything seems correct, Nout becomes 0.
(e.g. cout<<Nout<<endl;)

Hi,

This is odd. I would need a complete running example to understand this issue better.

Thanks,
Philippe.

Thank you so much.

I attach 2 macros. you need also two ntuples, but as they are too big I will try to attach them separately.

Please, try:
root [0] .L corr_.C
root [1] corr_()

and
root [0] .L corr_.C+
root [1] corr_()

see the difference in:
cout<<z<<" "<<Nout<<endl; corrhm.C, line 27

Helena
corr_.C (12.4 KB)
corrhm.C (40.3 KB)

Attach hist.root and hist1.root

Please, replace the lines:
t_p->Add(“his_35259-2-7.root.03”);
and
t_n->Add(“his_35259-2-7.root.02”);
by
t_p->Add(“hist.root”);
t_n->Add(“hist1.root”);

Helena
hist1.root (1.07 MB)
hist.root (1.15 MB)

Hi Helena,

With the source and the root files I download and call corr_() I never see the line cout<<z<<" "<<Nout<<endl; corrhm.C, line 27 being executed …

Note that you should never use the line: gROOT->Reset(); inside a function.

You have long long EvN; but the branch is defined as an int (hence the value EvN is a random value in your code!)

I also needed to change the line: fprintf (hadout, "HADP[%i] = %i \t HADN[%i] = %i \t\t year = %i \t period = %s \t config = %i \n", i,HADP[i],i, HADN[i], year, week[iweek].c_str(), iconfig );(I replace %f by the required %i)

After that valgrind was still reporting a problem with line 273: if (A1avper[i][j][k] ==0 || err_A1avper[i][j][k] ==0) continue;:==7866== Conditional jump or move depends on uninitialised value(s) ==7866== at 0x965D518: corr_() (corr_.C:273)

Once I made those changes I could see the Nout value start to appear and I got the same value in both interpreted and compiled code.
[Note that I ran on a 64bit unix machine]

Cheers,
Philippe

Hello Phillippe,

Thank you very much for your help. Let me just to clarify some issues.

“cout<<z<<” “<<Nout<<endl; corrhm.C, line 27”. I wanted to mean line 147. Mea culpa…

EvN has been declared as:
static long long EvN;
And stored as:
sitree->Branch(“EvN”, &EvN, “EvN/I”);
It should be “EvN/i”, instead?

Unfortunately, even with your corrections, I still have the problem, so I wonder if it is due to run in a 32 bits machine.
I tried to run at CERN but it does not accept the compiled mode:
.L corr_.C+
Info in TUnixSystem::ACLiC: creating shared library /afs/cern.ch/user/h/helena s/./corr__C.so
In file included from /afs/cern.ch/user/h/helenas/./corr_.C:24,
from /afs/cern.ch/user/h/helenas/./fileO9Ma8R.h:32,
from /afs/cern.ch/user/h/helenas/./fileO9Ma8R.cxx:16:
/afs/cern.ch/user/h/helenas/./corrhm.C:1: warning: unused parameter ‘pRun’
/afs/cern.ch/user/h/helenas/./corrhm.C:1: warning: unused parameter ‘nRun’
/afs/cern.ch/sw/lcg/external/root/5.14.00b/slc4_ia32_gcc34/root/lib/libvectorDic t.so: could not read symbols: File in wrong format
collect2: ld returned 1 exit status
Error in : Compilation failed!

Do you know how to overcome this? Maybe it is a topic for AFS support.
Besides I wanted to try:
slc4_amd64_gcc34

(Please, note that the aim of running with the compiled mode is the speed. It is important as I need to use this macro to treat millions events. Otherwise, I would use in the interpreted mode, withou problems.)

Helena

[quote]EvN has been declared as: …[/quote]You must use eitherstatic long long EvN; .... sitree->Branch("EvN", &EvN, "EvN/L");

OR

Int_t EvN; ... sitree->Branch("EvN", &EvN, "EvN/I");

Note that this can be automatically taken care of, if instead of using the leaflist method of branch creation, you switch to use the object method of branch creation (i.e. you would need to define a class to hold all your variable).

[quote]Do you know how to overcome this? Maybe it is a topic for AFS support. [/quote]Well it is a setup problem, the build you are using is incompatible with you platform (os or architecture or compiler).

Cheers,
Philippe

Hello Philippe,

The key was:

static long long EvN;

sitree->Branch(“EvN”, &EvN, “EvN/L”);

It is solved :slight_smile:)

Thank you so much!
Helena