Looping over events in TTree suddenly slows

Dear all,

I have a (specific) problem and a question (I use ROOT v. 4.04/02):

I use TTrees in ROOT and after creating script to loop over events in tree (MakeClass()) I create my private code in tree::Loop() method in xxx.C file.

In xxx.C file I create lots of TH1F* variables, fill them, etc… . Everything works fine and looping over events is fast (key point).

As my analysis evolves I add more and more simple variables (int, float, etc) or histograms and still the ROOT seem to loop over events equally as fast as at the beginnig. Perfect.

BUT at some point, when I add only 1 more plot which I then fill, the looping over events is suddenly very_slow. Even if I fill the histogram under a condition which is actually anyway ignored for some events (if (…) histo->Fill), looping is always slow.

When I then comment another line (another histo), the looping eventually starts to be as fast as at the beginning…

I am sorry I can not explain this particular problem more precisely, because I really don’t know what’s happening. Is it some internal memory that is filled up, or something? I heard other people complaining about the same problem. The only solution known to me is to reduce the number of histograms, but I guess there is some smarter way how to avoid such a decrease in speed?

Have anyone of you experienced the same problem? Thank you very much for any information.

Best regards,

this might happen dif you dont have enough memory and PC start to SWAP a lot.

You may notice this by monitoring swap file size, or just hearing hard drive click and moan and groan when you add one more histo.


If you are not compiling your macro, then what you are hitting is a limitation of the CINT bytecode compiler which stops working when the function grows to large.

To solve the problem simply load your macro via ACLiC to compile (aka add a trailing +: .L myClass.C+


Thank you for your replies! I run uncompiled macro and exactly as you said Philippe, when I use ACLiC it loops fast again. Thank you for your help,

Have a nice weekend,

Best regards,