Missing branches in a TTree with pyROOT

Hi,

I have a small python code that essentially opens a file, take the TTree and write it into another file (flattening of a structure cluttered with directories). This part works perfectly, the second file contains a perfect copy of the first one.

But today I noticed that when I do:

tree = infile.Get(treepath)
tree.Print("toponly")

I only see a subset of the TTree branches. The above code returns:

******************************************************************************
*Tree    :oneelectron_mt40_tree: tree                                                   *
*Entries :      613 : Total =           39516 bytes  File  Size =      23403 *
*        :          : Tree compression factor =   1.48                       *
******************************************************************************
branch: nbj                        446
branch: nj                         364
branch: FS                         444
branch: met                       2291
branch: mct                       2331
branch: DRBB                      2314
branch: mt                        2310
branch: mbb                       2302
branch: j0pt                      2295
branch: j1pt                      2291
branch: lpt                       2306
branch: charge                     385
branch: weight                    2220

But the actual tree got a lot more branches (that I can see when opening input and output files with ROOT interpreter).

[code]******************************************************************************
*Tree :oneelectron_mt40_tree: tree *
*Entries : 613 : Total = 85341 bytes File Size = 57771 *

  •    :          : Tree compression factor =   1.28                       *
    

branch: nbj 446
branch: nj 364
branch: FS 444
branch: met 2290
branch: mct 2331
branch: DRBB 2314
branch: mt 2310
branch: mbb 2302
branch: j0pt 2295
branch: j1pt 2291
branch: lpt 2306
branch: charge 385
branch: weight 2220
branch: weightPileup 2273
branch: weightBUp 2231
branch: weightBDown 2242
branch: weightCUp 2222
branch: weightCDown 2224
branch: weightLUp 2228
branch: weightLDown 2226
branch: weightEeffUp 2228
branch: weightEeffDown 2234
branch: weightEtrigUp 2229
branch: weightEtrigDown 2234
branch: weightMeffUp 2226
branch: weightMeffDown 2228
branch: weightMtrigUp 2227
branch: weightMtrigDown 2229
[/code]

Is there anything I missed on TTree with PyROOT? I suspect that it may have something with memory management, but I’m not quite sure of what to do so I prefer to come here and ask for an expert look.

Thanks in advance, and if needed I’ll provide a minimal working code,

Michaël

Michaël,

yes, a working example would be needed. PyROOT simply forwards calls to the same underlying codes as does CINT. I can’t see how a call such as TTree::Print(), which goes to the libTree C++ library in both cases, could show any difference.

Best,
WIm

Hi Wim,

please find a minimal example there:
marwww.in2p3.fr/~ughetto/Working … hes.tar.gz

To see the weird behavor, run:

You can check by hand that an interactive ROOT sessions gives a different result:

root input/pMSSMHFTrees_v6.202383.TB10_050_200_300_1lhbb.susy1512.root 
root [0] nom->cd()
root [1] oneelectron_mt40_tree->Print("toponly")

Let me know if there anything else I can do.

And just for completeness, I have tested the py on:

  • SLC5, ROOT 5.34/09 on x86_64, with python 2.6.5 (also tested with 5.28/00 and 5.34/18 for ROOT)
  • Fedora 19, ROOT 5.34/17 on x86_64, with python 2.7.5

Best,

Michaël

Hi,

no, prints exactly the same result for me? You have a lot of trees in there, but only the ‘nom’ one (which you happen to select in the cint case) is larger. It appears somewhere above the middle in the large printout of the python script and is larger there, too. To cut down on the obfuscation, adjust this: if treesuffix != None and name != "nom": continueto this: if treesuffix != None: continue if name != "nom": continueso that only the ‘nom’ tree is printed in both cases.

And see that now both are the same …

Alternatively, print any of the other trees from the other directories (mmsup, mmsdown, egzeeup, egresup, midup, jesup, scalestdown, jesdown, egmatup, egzeedown, egpsdown, egmatdown, eglowdown, jer, egpsup, resost, jvfup, scalestup, jvfdown) that you do print in the python case, but not in the cint one, and see that they are all smaller.

Cheers,
Wim

Hi,

Wow, I’m really sorry, I didn’t thought of that… You’re absolutely right, I stupidly assumed that all trees would have the same content but it makes sens that it doesn’t…

Really sorry for the useless noise :confused:

At least, I created my RootTalk account and will lurk around now :wink:

Thanks and sorry again,

Michaël