jet.Constituents.GetEntriesFast returns a different length of jet constituents

Hi all,

I find a wired thing:

for jet in event.Jet: print " the jet.Constituents.GetEntriesFast is : " , jet.Constituents.GetEntriesFast() print " the len(jet.Constituents) is: ", len(jet.Constituents) for i in xrange(0,len(jet.Constituents)): print jet.Constituents[i]

Sometimes the jet.Constituents.GetEntriesFast return a different number compare to len(jet.Constituents), for example , part of the output is:

the jet.Constituents.GetEntriesFast is : 3 the len(jet.Constituents) is: 10 <ROOT.Tower object ("Tower") at 0x7ff576fe2a00> <ROOT.Tower object ("Tower") at 0x7ff576fe2610> <ROOT.Tower object ("Tower") at 0x7ff576fe2970> <ROOT.Tower object ("Tower") at 0x7ff576fe2a00> <ROOT.Tower object ("Tower") at 0x7ff576fe2730> <ROOT.Tower object ("Tower") at 0x7ff576fe2970> <ROOT.Tower object ("Tower") at 0x7ff576fe28e0> <ROOT.Tower object ("Tower") at 0x7ff576fe2850> <ROOT.Tower object ("Tower") at 0x7ff576fe2a90> <ROOT.Tower object ("Tower") at 0x7ff576fe2b20>

So what’s the constituent number of the jet? Which one is right, GetEntriesFast or the len(…) ?

But question: what is type ‘Constituents’? If type is fixed-size buffer, is happens sometimes not use all slots, so len() give real buffer size (meaning: all slots), GetEntriesFast() give used slots in current jet (meaning: data read). Is “for c in jet.Constituents” loop work?

-Dom

[quote=“Dominique”]But question: what is type ‘Constituents’? If type is fixed-size buffer, is happens sometimes not use all slots, so len() give real buffer size (meaning: all slots), GetEntriesFast() give used slots in current jet (meaning: data read). Is “for c in jet.Constituents” loop work?

-Dom[/quote]

Hi Dom,
Thanks for your idea, I think it’s reasonable. So I write a code for compare:

the code is:

for jet in event.Jet: print " the jet.Constituents.GetEntriesFast is : " , jet.Constituents.GetEntriesFast() print " the len(jet.Constituents) is: ", len(jet.Constituents) print "way one" for i in xrange(0,len(jet.Constituents)): print jet.Constituents[i] print "way two" for i in xrange(0,jet.Constituents.GetEntriesFast()): print jet.Constituents.At(i)

part of the result is:

the jet.Constituents.GetEntriesFast is : 5 the len(jet.Constituents) is: 17 way one <ROOT.Tower object ("Tower") at 0x7fd5ae055dc0> <ROOT.Tower object ("Tower") at 0x7fd5ae055ee0> <ROOT.Tower object ("Tower") at 0x7fd5ae055ca0> <ROOT.Tower object ("Tower") at 0x7fd5ae055d30> <ROOT.Tower object ("Tower") at 0x7fd5ae055e50> <ROOT.Tower object ("Tower") at 0x7fd5ae055f70> <ROOT.Tower object ("Tower") at 0x7fd5ae0550a0> <ROOT.Tower object ("Tower") at 0x7fd5ae056000> <ROOT.Tower object ("Tower") at 0x7fd5ae054dd0> <ROOT.Tower object ("Tower") at 0x7fd5ae054cb0> <ROOT.Tower object ("Tower") at 0x7fd5ae054d40> <ROOT.Tower object ("Tower") at 0x7fd5ae054e60> <ROOT.Tower object ("Tower") at 0x7fd5ae075c50> <ROOT.Tower object ("Tower") at 0x7fd5ae075bc0> <ROOT.Tower object ("Tower") at 0x7fd5ae076800> <ROOT.Tower object ("Tower") at 0x7fd5ae0565a0> <ROOT.Tower object ("Tower") at 0x7fd5ae0753e0> way two <ROOT.Tower object ("Tower") at 0x7fd5ae055dc0> <ROOT.Tower object ("Tower") at 0x7fd5ae055ee0> <ROOT.Tower object ("Tower") at 0x7fd5ae055ca0> <ROOT.Tower object ("Tower") at 0x7fd5ae055d30> <ROOT.Tower object ("Tower") at 0x7fd5ae055e50>

It seems that the 'Constituent" is ranged and first few are labeled “current jet constituents” and last few are not.

“for c in jet.Constituents” loop works, and it will loop in the whole array.

Best,
Li