Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building radiusOfInnermostHit from tracks #384

Closed
farakiko opened this issue Nov 26, 2024 · 1 comment
Closed

Building radiusOfInnermostHit from tracks #384

farakiko opened this issue Nov 26, 2024 · 1 comment

Comments

@farakiko
Copy link

farakiko commented Nov 26, 2024

  • EDM4hep version: unfortunately unsure because it was a nightly build from about 5 months ago
  • Reproduced by: running the piece of code below
  • Input: rootfile can be found here

Hi, I was looking into computing the radiusOfInnerMostHit because I need to use this variable for particle flow reconstruction. Since I have access to events generated with a previous software build that still has access to SiTracks_Refitted/SiTracks_Refitted.radiusOfInnermostHit, I was trying to confirm my piece of code below:

import math
import uproot

# load file
events = uproot.open("reco_p8_ee_tt_ecm365_100001.root")["events"]

# debug first event
iev = 0  
num_tracks = len(events["SiTracks_Refitted/SiTracks_Refitted.radiusOfInnermostHit"].array()[iev])

for itrack in range(num_tracks):
    
    val = events["SiTracks_Refitted/SiTracks_Refitted.radiusOfInnermostHit"].array()[iev][itrack]
    print(f"reading from branch; radiusOfInnermostHit of track {itrack} is: {val:.4f}")
    
    ############# now attempt to compute it using other branches
    # select the track states corresponding to itrack
    ibegin = events["SiTracks_Refitted/SiTracks_Refitted.trackStates_begin"].array()[iev][itrack]
    iend = events["SiTracks_Refitted/SiTracks_Refitted.trackStates_end"].array()[iev][itrack]

    num_track_states = iend - ibegin
    
    col = "_SiTracks_Refitted_trackStates"

    d0 = events[f"{col}/{col}.D0"].array()[iev][ibegin:iend]
    phi = events[f"{col}/{col}.phi"].array()[iev][ibegin:iend]
    refX = events[f"{col}/{col}.referencePoint.x"].array()[iev][ibegin:iend]
    refY = events[f"{col}/{col}.referencePoint.y"].array()[iev][ibegin:iend]    
    
    innermost_radius = float('inf')
    for ihit in range(num_track_states):
        x_closest = refX[ihit] + d0[ihit] * math.cos(phi[ihit])
        y_closest = refY[ihit] + d0[ihit] * math.sin(phi[ihit])
        
        radius = math.sqrt(x_closest**2 + y_closest**2)

        if radius < innermost_radius:
            innermost_radius = radius

    print(f"manually computed radiusOfInnermostHit of track {itrack} is: {innermost_radius:.4f}")
    break

which prints out:

reading from branch; radiusOfInnermostHit of track 0 is: 35.6223
manually computed radiusOfInnermostHit of track 0 is: 0.4091

Unfortunately, it seems that my piece of code is not correct because it does not match the value directly obtained from the branch SiTracks_Refitted/SiTracks_Refitted.radiusOfInnermostHit

Could you perhaps share how to build this variable from the other branches? Thanks!

@andresailer
Copy link
Collaborator

Thanks for providing the source code, but @tmadlener was faster in opening a separate issue, and started answering, so let's continue there: #383

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants