I have compiled a macro with ACLiC without problems. However one of the variables (integer one) become 0 when I make
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.
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.:
Xprim = 0.397437
Yprim = -0.931583
Zprim = -68.5966
Nout = 2
But, if I compile with ACLiC, althoug everything seems correct, Nout becomes 0.
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]
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:
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,
/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:
(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.)
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).