Mu2e / TrkAna

Track-based analysis TTree maker working in the art framework
Apache License 2.0
1 stars 19 forks source link

Weird behavior of vector<vector<array>> leaves in TTree::Draw #168

Open bonventre opened 4 weeks ago

bonventre commented 4 weeks ago

The demtsh.etime leaf is a std::array of two doubles. When using TTree::Draw both etime[1] and etime[0] are identical (etime[1]-etime[0] is always 0). Tried

trkana->Draw("demtsh.etime[][][1]-demtsh.etime[][][0]") trkana->Draw("demtsh.etime[0][][1]-demtsh.etime[0][][0]") trkana->Draw("demtsh.etime[0][0][1]-demtsh.etime[0][0][0]")

and all are zero. In uproot t["demtsh"]["etime"] has the correct shape and the two values are different for each entry

sam-grant commented 1 week ago

@bonventre could you point me to the file you were running on so I can look at this?

sam-grant commented 1 week ago

I can confirm that I see the same thing.

Screenshot 2024-07-10 at 13 57 57

When I scan the tree using the ROOT interface, I see that the two sets of values are identical.

root [1] trkana->Scan("kltsh.etime[][][1]")
***********************************
*    Row   * Instance * kltsh.eti *
***********************************
*        0 *        0 * 91257.687 *
*        0 *        1 * 91244.164 *
*        0 *        2 * 91259.531 *

root [2] trkana->Scan("kltsh.etime[][][0]")
***********************************
*    Row   * Instance * kltsh.eti *
***********************************
*        0 *        0 * 91257.687 *
*        0 *        1 * 91244.164 *
*        0 *        2 * 91259.531 *

When I print them out using uproot they are different, and data_["kltsh"]["etime"][[:,:,:,0] is identical to both 0 and 1 from trkana->Scan().

data_["kltsh"]["etime"][[:,:,:,1]:

91257.2265625
91243.8593750
91255.2890625
...

data_["kltsh"]["etime"][[:,:,:,0]:
91257.6875000
91244.1640625
91259.5312500
...

I have no idea why this happens! It's very strange. It seems like it might be ROOT issue/limitation?

AndrewEdmonds11 commented 12 hours ago

I've posted a question about this on the ROOT forum here: https://root-forum.cern.ch/t/problems-with-std-vector-std-array-branches/60239