-
Hello pylhe experts, I was wondering if the pylhe package is able to take a .lhe file and transform the event data into a .root file? It seems like many MC generators output a .lhe file and I didn’t know if there was a tool to take the .lhe event data and analyze it in ROOT all within python. Within my group, analysis code is often developed in pyROOT, and so it would be nice to only make slight modifications to the analysis code when switching between the different output file types of MC generators. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hi there. I'm very low on time right now but let me cc @jpivarski already now. You could for example get your data into an awkward array, see https://github.com/scikit-hep/pylhe/blob/main/examples/awkward_example.ipynb, and then convert to an RDataFrame, see https://awkward-array.org/doc/main/user-guide/how-to-convert-rdataframe.html, at which point you're in the ROOT world? I may be missing something but this is certainly viable. Dunno if others have better ideas. |
Beta Was this translation helpful? Give feedback.
If you go this route (LHE → Awkward Array → RDataFrame → ROOT file), then you'll need to convert the Awkward C++ iterators into generic C++ types, since Awkward C++ iterators ("ArrayView") can't be serialized into an on-disk file with
RDataFrame::Snapshot
. (The issue here is that iterators over an Awkward Array in RDataFrame don't "own" their data; they are pointers to a data structure in Python, and when ROOT tries to serialize that, it doesn't know that it's only saved a symlink...)Perhaps I'm being overcautious, since your data types might be simple: if the columns in the RDataFrame are numeric types or jagged arrays of numbers (which can come from an Awkward Array), those types are a…