hsf-training / hsf-training-scikit-hep-webpage

https://hsf-training.github.io/hsf-training-scikit-hep-webpage/
Other
9 stars 19 forks source link

Unclear solution/statement of exercise #27

Closed klieret closed 9 months ago

klieret commented 1 year ago

@amangoel185 @ekauffma Can you fill in the details here/take this issue?

jpivarski commented 1 year ago

Do you mean this one?

Quick quiz: apply both cuts; that is, select muons with over 20 GeV from events that have them.

klieret commented 1 year ago

Copying from @GuillermoFidalgo

event_cut = ak.any(muon_pt>20,axis=1) # getting events that have muons with pt>20
clean_events = muon_pt[event_cut]

particle_cut= clean_events> 20 # getting the muons with pt>20
clean_events[particle_cut].tolist()
jpivarski commented 1 year ago

That's a solution if you can redefine (or later define) particle_cut, after clean_events has already been defined. If particle_cut and event_cut are both based on the original muon_pt, then you'd have to do this:

cleaned = muon_pt[particle_cut]
final_result = cleaned[event_cut]

or

final_result = muon_pt[particle_cut]

Maybe to indicate that this is the form that we want the output to take, we can add

Hint: the final result should be a jagged array, just like muon_pt, but with fewer lists and fewer items in those lists.

stale[bot] commented 1 year ago

This issue or pull request has been automatically marked as stale because it has not had recent activity. Please manually close it, if it is no longer relevant, or ask for help or support to help getting it unstuck. Let me bring this to the attention of @klieret @wdconinc @michmx for now.

GuillermoFidalgo commented 9 months ago

Just wanted to confirm that what correctly answers this exercise is the following as I'll be adding the hint mentioned above to the tutorial

cleaned = muon_pt[particle_cut]
final_result = cleaned[event_cut]
final_result.tolist()

[[32.911224365234375, 23.72175407409668],
 [57.6067008972168, 53.04507827758789],
 [23.906352996826172]]

having particle_cut and event_cut defined as

particle_cut = muon_pt  >20
event_cut = ak.max(muon_pt,axis=1)  >20

... Actually this doesn't really follow the condition that says

You can't use event_cut as is

because it is the solution to the previous question

Quick quiz: construct exactly the same event_cut using ak.max.

Unless what we mean is that it simply can't be defined as originally given using ak.any, in which case all is fine.