Macro working under XP but not under linux

I have a MakeClass macro that I built under Root 5.15 on Windows XP with a certain chain of nutples. I have ported it onto a linux machine (lxplus at CERN) where I use Root 5.14. The ntuples themselves were made on the linux side. I use the exact same code and ntuples in both places and it works on XP and runs, but does not work, under linux.

The problem occurs because I check the size of a vector array at the start of the code. On the linux side

Array->size()

always returns zero, whereas on the XP size it returns a value >0.

Help??
Thanks, Tony Liss

Hi,

Unless you removed the fChain->SetMakeClass(1), the array->Size() is only working by chance.

Cheers,
Philippe.

Thanks. I have done this but array->size() still returns zero always.

Hi,

Humm … Can you provide a complete running example, so I can investigate it further (i.e I don’t what your file look like, I don’t know what modification you made to the MakeClass skeleton, etc. :slight_smile: ).

Cheers,
Philippe.

Thanks very much for being willing to look. I’ve attached the .C and .h files that I use . They are a bit lengthy, so if you want me to provide something else instead, please ask.

Thanks again,
Tony
Align_3.h (13.6 KB)
Align_3.C (27.6 KB)

Hi,

I will also need the ROOT file :slight_smile:

Philippe

OK, sorry. The two files cited are attached.
MuonAnal_Sec9pos_muminusNEW_00004.aan.root (364 KB)
MuonAnal_Sec9pos_muminusNEW_00003.aan.root (369 KB)

Hi,

Can you simplify the example to show me what is not working (i.e. from your code I am sure what you are expecting from what you are getting)? A simple change in your code: ILoop=0; cout << MSTrk_z0->size() << endl; continue; if(MSTrk_z0->size()>0 && IDTrk_z0->size()>0) { shows me zeros and ones on linux …

Philippe

For these two ntuple files both should be 1 for each event. That’s what I see under XP, but under linux I see only zeros for both. I will try to reproduce it with a stripped down macro.

Thanks!

OK, Attached is a very stripped down version which reproduces the problem. It uses the same two root files. It prints out the size of two vectors. They are always 1 when I run on XP and always 0 when I run on Linux.

Thanks again!

-Tony
TestLinux.h (11.5 KB)
TestLinux.C (1.55 KB)

Hi,

I get the same result on Linux and Windows (albeit I am using 5.20).
More over, the result I am seeing with your MakeClass is actually consistent with the result of TTree::Scan/TTree::Draw). For example The event #75 of your first file seems to have indeed 0 element in the MSTrk_z0 vector.
So I am guessing Linux (in your case) is actually correct.

The first thing to try is to compile your code. To do so you will to slightly update your header file:

[code]diff TestLinux.h*
14,15c14
< #include
< #include “Riostream.h”

#include <vector.h>
315c314
< Int_t TestLinux::Cut(Long64_t /* entry */)


Int_t TestLinux::Cut(Long64_t entry)
[/code]
and use itroot.exe -b -l root [0] .L TestLinux.C+ root [1] TestLinux x root [2] x.Loop(); >res03

Cheers,
Philippe.

Here’s what happened:

[Wed 9 : liss at lxplus206 :]root.exe -b -l
root [0] .L TestLinux.C+
Info in TUnixSystem::ACLiC: creating shared library /afs/cern.ch/user/l/liss/root/./TestLinux_C.so
root [1] TestLinux x
zsh: 28690 segmentation fault root.exe -b -l

Hi,

Humm … this is very odd :slight_smile:. I assume that you might have a configuration problem (i.e. header and library and executable and compiler are not ‘compatible’). Check you PATH, LD_LIBRARY_PATH, ROOTSYS and check which compiler version is on your path.

If all those works, then you ought to run your example using valgrind to get more information.

Cheers,
Philippe.

PS. Also my observation (your data file contains 0 and 1 size) and your statement (all event have vector of size) are in conflict. Did you understand why?

Hi again,

I’m not sure what i’m looking for in the path. How do I tell what compiler is in my path?

Regarding the vector size, this is from a simulation sample with a single track per event, so the vector size of each of the vectors cited really should be 1 for every event. I can imagine that there might be an occasional zero, but not many. So I think what I’m seeing on XP is correct.

Thanks for your continued help! I really appreciate it!

-Tony

It does indeed seem to be a setup issue - I tried it on a different linux machine (not CERN) where I just did a simple root setup rather than the whole ATLAS offline thing, and it works - even without compiling the code - so it must be something in my ATLAS setup that is scrambling things (but this is also happening to someone else who was trying to run my code, so it’s not just me!).

Thank you for your help!

Tony