High Energy Physics (HEP) folks on Julia?

Sorry for the spam, I just wanted to update you and share my first tiny milestone: I managed to parse all the streamers in basic ROOT files and also a sample file from our detector.

Now I can start to work on parsing the data in the TTrees. The code structure is super ugly and I need to consolidate a lot of stuff, but for now I just want to get it work.

Here it is in action (still very basic, but it does something):

julia> using ROOTIO

julia> f = ROOTFile("test/samples/km3net_online.root")
ROOTFile("test/samples/km3net_online.root") with 10 entries and 56 streamers.

julia> keys(f)
10-element Array{String,1}:
 "JTRIGGER::JTriggerParameters"
 "META"                        
 "E"                           
 "KM3NET_TIMESLICE"            
 "KM3NET_TIMESLICE_L0"         
 "KM3NET_TIMESLICE_L1"         
 "KM3NET_TIMESLICE_L2"         
 "KM3NET_TIMESLICE_SN"         
 "KM3NET_EVENT"                
 "KM3NET_SUMMARYSLICE"         

julia> f.streamers.streamers.objects[1:4]
4-element Array{Any,1}:
 ROOTIO.TStreamerInfo("TNamed", "", 0xdfb74a3c, 1, ROOTIO.TObjArray("", 0, Any[ROOTIO.TStreamerBase(0x0004, 0, "TObject", "Basic ROOT object", 66, 0, 0, 0, Int32[0, -1877229523, 0, 0, 0], "BASE", 0.0, 0.0, 0.0, 1), ROOTIO.TStreamerString(ROOTIO.TStreamerElement(0x0004, 0, "fName", "object identifier", 65, 24, 0, 0, Int32[0, 0, 0, 0, 0], "TString", 0.0, 0.0, 0.0)), ROOTIO.TStreamerString(ROOTIO.TStreamerElement(0x0004, 0, "fTitle", "object title", 65, 24, 0, 0, Int32[0, 0, 0, 0, 0], "TString", 0.0, 0.0, 0.0))]))
 ROOTIO.TStreamerInfo("TObject", "", 0x901bc02d, 1, ROOTIO.TObjArray("", 0, ROOTIO.TStreamerBasicType[ROOTIO.TStreamerBasicType(ROOTIO.TStreamerElement(0x0004, 0, "fUniqueID", "object unique identifier", 13, 4, 0, 0, Int32[0, 0, 0, 0, 0], "unsigned int", 0.0, 0.0, 0.0)), ROOTIO.TStreamerBasicType(ROOTIO.TStreamerElement(0x0004, 0, "fBits", "bit field status word", 15, 4, 0, 0, Int32[0, 0, 0, 0, 0], "unsigned int", 0.0, 0.0, 0.0))]))                                                                                
 ROOTIO.TStreamerInfo("TList", "", 0x69c5c3bb, 5, ROOTIO.TObjArray("", 0, ROOTIO.TStreamerBase[ROOTIO.TStreamerBase(0x0004, 0, "TSeqCollection", "Sequenceable collection ABC", 0, 0, 0, 0, Int32[0, -60015674, 0, 0, 0], "BASE", 0.0, 0.0, 0.0, 0)]))                                                                                                                                                                                                                                                                              
 ROOTIO.TStreamerInfo("TSeqCollection", "", 0xfc6c3bc6, 0, ROOTIO.TObjArray("", 0, ROOTIO.TStreamerBase[ROOTIO.TStreamerBase(0x0004, 0, "TCollection", "Collection abstract base class", 0, 0, 0, 0, Int32[0, 1474546588, 0, 0, 0], "BASE", 0.0, 0.0, 0.0, 3)]))   
9 Likes

Another tiny milestone, first readout of flat Int32 arrays (support for multiple baskets):

julia> using ROOTIO

julia> f = ROOTFile("test/samples/tree_with_histos.root")
ROOTFile("test/samples/tree_with_histos.root") with 1 entry and 4 streamers.

julia> array(f, "t1/mynum")
25-element Array{Int32,1}:
  0
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 10
 10
 10
 10
 10
 10
 10
 10
 10
 10
 10
 10
 10
 10
9 Likes

HEP person from a loooong time ago (LEP era)
I awlays thought Julia is a natural for HEP work - you could define quark or hadron data types for instance.
If I wanted to play about with this, are there some small sample data files you would recommend?

1 Like

Oh, that’s difficult. You mean particle interactions? You can browse through the open data of CERN http://opendata.cern.ch for example… In our experiment (https://www.km3net.org) we are currently in the phase of open data format definitions and specifications, so we don’t have data available yet.

A neutrino telescope in the Mediterranean?
Other physicists get to freeze their asses off at the South Pole while you top up your tans… :stuck_out_tongue_winking_eye:

:laughing: indeed… but we are at 3.5km depth and our detector is changing its geometry all the time, so we have to fight other difficulties :wink: (including bioluminescence)

4 Likes

Another tiny milestone :smiley:

So now the API is starting to take shape (very preliminary though), but I am already able to read hit-level data from our detector, which is basically what I need to make progress with my own work.

This means, for now I will focus a bit on the “raw data readout” which is a functionality that allows you to get simply the bytes and offsets of a branch. ROOTIO can then provide all the streamer information but is currently not able to create a parser and the appropriate struct for it. This can now be done by the user (by hand).

Here is a rough example how I manually read out 2e7 hits from a ROOT file, coming directly from our neutrino detector, using the array(f::ROOTFile, path; raw=true) method:

julia> using ROOTIO

julia> f = ROOTFile("/Users/tamasgal/data/KM3NeT/sea/KM3NeT_00000049_00007917.root")
ROOTFile("/Users/tamasgal/data/KM3NeT/sea/KM3NeT_00000049_00007917.root") with 13 entries and 59 streamers.

julia> data, offsets = array(f, "KM3NET_EVENT/KM3NET_EVENT/snapshotHits"; raw=true);

julia> io = IOBuffer(data); skip(io, 10);

julia> events = diff(offsets);

julia> hits = [ROOTIO.readtype(io, ROOTIO.KM3NETDAQHit) for _ in 1:events[1]];

julia> hits[1:5]
5-element Array{ROOTIO.KM3NETDAQHit,1}:
 ROOTIO.KM3NETDAQHit(806455814, 0x09, 9968119, 0x15)
 ROOTIO.KM3NETDAQHit(806455814, 0x07, 9968666, 0x1e)
 ROOTIO.KM3NETDAQHit(806465101, 0x0f, 9968278, 0x18)
 ROOTIO.KM3NETDAQHit(806469630, 0x05, 9968091, 0x1b)
 ROOTIO.KM3NETDAQHit(806469630, 0x07, 9968091, 0x29)

julia> length(data) / sizeof(ROOTIO.KM3NETDAQHit)
2.0831771e7
9 Likes

Where I can find most reacent information about Julia and High Energy Physics? Checking every GitHub/GitLab project repository is suboptimal solution.

Are you looking for a specific functionality, or just an overview, or use case examples?

First, overview, second use case examples.

I was working on theoretical side of HEP and field theory, but I’m increasingly more involved in numerical work. Now, I just want to have overview of Julia HEP ecosystem, to know if it is good time to try to join in or should I stay with my current work and tools for it. Which are less than perfect, but do the work that I need.

1 Like

I don’t have anything for theory, I’m afraid, other than fastjet.
https://github.com/jstrube/FastJet.jl
Works fine in the baseline. I have used some plugins, but it probably needs more testing.
The only minor annoyance is that the garbage collector kills the jet too early, so if you loop over the constituents, make sure you have a call to the jet after the loop over the constituents is done.

Other than that, I only have a few loose examples, probably not useful for theorists, but please feel free to take a look: https://github.com/jstrube/LC_with_Julia_examples

1 Like

And there’s a super-old example from Keno on using Pythia with Cxx, but I’d be pretty surprised if that still worked…
https://github.com/Keno/Pythia.jl

1 Like

Hi - I’m a Fermilab scientist in our Scientific Computing division working on the Muon g-2 experiment. Is there any interest in having a Zoom meeting for those of us trying to use Julia in High Energy Physics? The HPC Julia folks have a monthly meeting and a running Google Doc of issues and notes – it’s a nice idea, though unfortunately I always have a work meeting when they have theirs so I can never go :frowning: For us in HEP, I have a feeling that we are a small group so may be nice to get together and talk about what we’re doing. Perhaps there are opportunities to collaborate. I’m happy to host and organize the Zoom meeting. Let me know and I’ll set up a Doodle poll to find the day/time. Thanks! – Adam

6 Likes

I support!
Dropping a message on slack might be a good idea.

1 Like

Hi Adam! I think that’s a good idea. I do neutrino physics with KM3NeT and I am using Julia for the detector monitoring system and real-time event reconstruction. The only byproducts so far which may be usueful for other HEP people are UnROOT.jl (alpha) and Corpuscles.jl.
I would really like to hear what others are doing with Julia in HEP.
Maybe we try to find a new monthly date so that more people can join? A doodle is a good start anyways :wink:

2 Likes

I also think it might be a good idea to have regular meetings.
I am a phenomenologist working with SHiP and ATLAS, and I have used Julia extensively to implement toy Monte-Carlos, either to cross-validate other generators or when existing generators were not enough. Hopefully I should be able to release part of this code at some point, but it would need a major cleanup first.
I also use Julia when processing datasets which are too large for Numpy + Pandas, but otherwise I still default to a Python workflow because this is what my colleagues know.

3 Likes

Great! Thanks @misha_mikhasenko, @tamasgal and @JLT. I’ll set up a Doodle Poll later today. There’s also the #physics channel on the Julia Slack. I’ll announce there as well. How about we try for a meeting the week of 12/14?

Pinging @oschulz @jling @jstrube

1 Like

I’d definitely be in!

Thanks everyone! I’ve made a Doodle Poll at https://doodle.com/poll/7ts583ff3k7v5hn3 . Please fill in when you are available (and please pay attention to the time zone - I’m not sure if it will adjust to your TZ - I’m in US Central Time). I’ll also announce this on the Julia Slack #physics channel. Looking forward to chatting with you all. – Adam

5 Likes