hello All,
I have a tree that I am attempting to process with PyROOT and there are a couple issues that I have been unable to work around.
The root file has a tree called ‘scalerTree’ with a single branch called ‘scalers’ and a number of leafs associated with it. Here is the structure:
>>> tree.Print()
******************************************************************************
*Tree :scalerTree: Scalers *
*Entries : 898 : Total = 141451 bytes File Size = 37294 *
* : : Tree compression factor = 3.79 *
******************************************************************************
*Branch :scaler *
*Entries : 898 : BranchElement (see below) *
*............................................................................*
*Br 0 :fUniqueID : UInt_t *
*Entries : 898 : Total Size= 4183 bytes File Size = 129 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 28.48 *
*............................................................................*
*Br 1 :fBits : UInt_t *
*Entries : 898 : Total Size= 7763 bytes File Size = 1269 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 5.73 *
*............................................................................*
*Br 2 :scalerStartTime : UInt_t *
*Entries : 898 : Total Size= 4213 bytes File Size = 1807 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 2.04 *
*............................................................................*
*Br 3 :scalerEndTime : UInt_t *
*Entries : 898 : Total Size= 4203 bytes File Size = 1805 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 2.04 *
*............................................................................*
*Br 4 :scalers[32] : UInt_t *
*Entries : 898 : Total Size= 119417 bytes File Size = 31159 *
*Baskets : 4 : Basket Size= 32000 bytes Compression= 3.82 *
*............................................................................*
With reading a branch with no leafs and a non-array value, I have been able to do that using, (for example)
tree.GetEntry(0)
print tree.Branch
However, attempting to get to out the leaf values from the scalers branch above is proving, at least to me, not straightforward. I have attempted an old solution I found, works but inelegantly,
tree.GetEntry(0)
Y = tree.GetLeaf("scalerEndTime").GetValue()
This method I can get the two leafs (scalerEndTime and scalerStartTime) for each event, but I am uncertain how I can read our the scalers[32] array.
If I simply do the following:
tree.GetEntry(0)
Y = tree.scalers
for x in Y:
print x
Y is a pointer to all the data and I can access it by looking at elements of Y, i.e. Y[0], Y[1], etc. However, iterating through it, it does NOT contain all of the data as its length is only 32 while just the scalers[32] array is that length alone.
My question is how can I efficiently get the data from this branch? It would be nice to read out the scalers[32] leaf into an array rather than have to look over all 32 entries of that leaf to read out the values.
Thank you for any help,
ROOT Version: 6.14.06
Platform: OSX 10.14 Mojave
Compiler: Not Provided