Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

An example of how to access the event, track, and hit level information, as well as how to decode the processID to obtain the processID and sourceFlag. Use the example root file (RUS.root) to run the below python script. 


Code Block
languagepy
import ROOT

def decode_source_flag(encoded):
    return (encoded >> 5) & 0x3  # Extract bits 5-6

def decode_process_id(encoded):
    return encoded & 0x1F  # Extract lower 5 bits

file = ROOT.TFile("RUS.root") 
tree = file.Get("tree")

for event in tree:

    print("EventID:", event.eventID)

    for i in range(len(event.gpz)):

        #print track level information
        print("true pz of the track: ", event.gpz[i] )
        print("charge of the track: ", event.gCharge[i] )

        for j in range(len(event.hit_trackID)):

            #check for the track id. When the track id matches with the track id at the hit level, we access the hit information.
            if event.hit_trackID[j] != trackID:
                continue
            hit_id = event.hitID[j]
            hit_trackid = event.hit_trackID[j]
            encoded_value = event.processID[j] 
            process_id = decode_process_id(encoded_value) #decoding the process_id
            source_flag = decode_source_flag(encoded_value) #decoding the source_flag
            print("hitID:", hit_id)
            print("hit_trackID:", hit_trackid)
            print("Encoded value:", encoded_value)
            print("Decoded Process ID:", process_id)
            print("Decoded Source Flag:", source_flag)

...