get_reco_fit() is great, however it is somewhat incomplete without some way to also extract mc_tracks, events, hits for corresponding fully-reconstructed events (otherwise arrays won't match in lenght).
Designs
Child items
...
Show closed items
Linked items
0
Link issues together to show that they're related.
Learn more.
New methods were implemented in km3io (currently in the branch add-reco-hits-events), but will soon be merged to the master branch.
The new methods are:
get_reco_hits, get_reco_tracks and get_reco_events. These three methods can be used in the exact same way, therefore I will only present one here:
this will actually look for the reconstruction stages in the mc tracks tree and extract the pox_x and pos_y from the mc tracks tree as well.
Please let me know if this corresponds to what you requested (I tested all the mc data with a file full of zeros, so I am curious to hear back from you). Please also share with me a tiny file with some data (non zero data in mc trees) so that I can make further tests if needed.
If I understand correctly, you just want the index mask if the events of the best reconstructed tracks.
With that mask you can select hits, events or whatever, matching the best tracks.
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/pbs/home/k/kakiczi/.pyenv/versions/3.8.0/lib/python3.8/site-packages/km3io/offline.py", line 739, in get_reco_tracks raise ValueError(ValueError: The stages [1, 2, 3, 4, 5] are not found in your file.
It works with mc=False, but not with mc=True. I guess it tries to find the reco stages inside the mc_tracks, where they are obviously not to be found. I think the only solution is the index matching between mc_tracks and reco_tracks (though I may be wrong).
Yep, I want pretty much exactly what you wrote @tgal.
@zaly I guess an example will be most useful here. In my script I wanna do this:
VARS[0].extend(mc_tracks['type']) # primaryVARS[1].extend(sum(reco_hits['tot']))VARS[2].extend(sum(reco_hits['trig']))VARS[3].extend(len(reco_hits['trig']))VARS[4].extend(reco_events['overlays'])VARS[5].extend(reco_events['w'][:,2]) # (hopefully) w3 weightsVARS[6].extend(len(mc_tracks['type'])-1) # multiplicity (-1 because of the primary)VARS[7].extend(reco_tracks['pos_x'][:,0])VARS[8].extend(reco_tracks['pos_y'][:,0])VARS[9].extend(reco_tracks['pos_z'][:,0])VARS[10].extend(reco_tracks['dir_x'][:,0])VARS[11].extend(reco_tracks['dir_y'][:,0])VARS[12].extend(reco_tracks['dir_z'][:,0])VARS[13].extend(reco_tracks['E'][:,0]) # energyVARS[14].extend(mc_tracks['E'][:,0]) # primary energyVARS[15].extend(np.ones(len(reco_tracks['pos_x']))*((int)(r.header['norma'].split()[1]))*len(FNAMES))
So as you can see I need the corresponding info from mc_tracks, reco_tracks and reco_events
In this particular case I want to get the multiplicity, primary type and primary energy from the true mc info and I want it ONLY for the reconstructed events.
So ok now I understand what you want. In fact, what's implemented now treats mc_tracks class and tracks class as two completely separate words! So when you use mc=True it really just looks for mc_tracks data and ignores the other tracks class! So since there are no rec_stages in the mc_track, the error is raised!
anyway, I will provide this in a different branch for you. I will keep the master branch as it is for the moment because @tgal and I believe that this needs more thinking (the current implementation is a temporary/transitory solution).
We always face the same issue with this aanet stuff. One class for everything... mc_tracks should not have rec_stages, but since in aanet it's the same class, you cannot do much about it. However, we can hack it...
What you asked for is now in the branch called piotr-selection.
So now the reconstruction stages are ONLY looked for in the tracks tree (not mc_tracks anymore). And when you type mc=True in any get_reco_XX method, it should look in the same index of events as those found with the rec_stages=[1, 2, 3, 4, 5] in the tracks tree!
Btw. a future notice, I think we can provide the same naming convention is used in many other low level libraries: bestreco(tracks) and argbestreco(tracks). The first gives the data, the second only the mask etc.
Sure! I suggest we discuss these details in a phone call after your code review, or on the issue #31 (closed) . I am happy to add any naming conventions you think is necessary ;)
Thanks @zaly , it works. However, it still does not provide all the functionality I need. Since I have an ungly (but working) alternative, I would say it does not make sense for you to try to just write another bunch of functions just for me. You better focus on the general solution.
As @tgal said, a mask that would only show entries corresponding to the fully-recoed ones would be best. Right now I cannot e.g. extract multiplicities from r.get_reco_tracks(stages=[1, 2, 3, 4, 5], keys=["type", "E"], mc=True), since I get 1 entry per event (and multiplicity is not a standard key in offline files).
@tgal and I are aware of this, I only wanted to help you make progress on your work...
km3io is still under development so this is absolutely not the final version, but a temporary solution to help people make progress in their work. The idea behind the get_reco_XX methods is to select the tracks with a specific reco stages and the highest likelihood. In fact, if you need multiplicity then get_reco_XX are not suited for that!
I am on holidays for a week so I can not promise to provide anything now. But we (with @tgal ) will combine efforts to have a more robust solution for this.
Thanks again for your contribution!
Sorry but I really did my best to try to help you before going on holidays.
This issue will stay open until a better solution is available.
I appreciate that, but I see it's jsut getting too complicated this way.
Yep, they are not. Don't feel too bad, this stuff is just messy and annoying and I'm quite fine with what I have now. I can generate hdf5's with the variables I need, this would only be a performance (and script attractiveness let's say ;) ) boost for me.
I really appreciate what you guys do with km3io, it has already made my life a lot easier!
This issue is directly related to the tracks slicing issue #15 (closed) as well. @pkalaczynski issue initiated the work on a new API design for offline module. Since there is no further work that will be done with the current offline design to address Piotr's issue about tracks slicing, I suggest we close it and keep issue #15 (closed) open to focus on the new API design of offline module.
I do not think that a quick fix can be provided with the current offline design anyway! Meanwhile, users can use the available methods to by-pass the issues of slicing while waiting for the official release of the new design.