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

Made many methods const, GetTrack, GetHits methods now return a constant reference #41

Merged
merged 6 commits into from
Apr 5, 2022

Conversation

lobis
Copy link
Member

@lobis lobis commented Apr 1, 2022

Large lobis 492

Currently very few methods in the framework are marked as const. I have tried in the past to make the methods related to the event / track / hits const but its impossible unless you basically make all of them const, since they call each other multiple times, especially methods such as GetTrack etc. This is also why this PR is very large.

This PR makes the necessary changes in Geant4Lib so that the getters on TRestGeant4Event, TRestGeant4Track and TRestGeant4Hits are marked as const.

In order to do this I had to also modify:

I only had to introduce a significant change to the framework: methods such as TRestGeant4Event::GetTrack or TRestGeant4Track::GetHits now return a constant reference. Previously they returned a pointer, but this is incompatible with having all getters marked as const and it makes little sense in my opinion.

This means that before you wrote:

TRestGeant4Track* event.GetTrack();

and now you write:

TRestGeant4Track event.GetTrack();

in 99% of usage its not necessary to modify this returned track, as you generally use it for analysis. I only found one instance where its necessary to modify it, on the restG4 package. I created the method TRestGeant4Event::GetTrackPointer which works as the previous GetTrack to solve this issue.

@lobis lobis requested review from Vindaar, jgalan and juanangp April 1, 2022 13:41
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

Successfully merging this pull request may close these issues.

2 participants