-
Notifications
You must be signed in to change notification settings - Fork 37
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
Reverse the direction of the ParticleID relation(s) #268
Conversation
b4b3eb9
to
cb81768
Compare
cb81768
to
8ee4384
Compare
8ee4384
to
7e0679b
Compare
7e0679b
to
2c17d83
Compare
I have added a first version of a Since |
6e5c4b9
to
96a8567
Compare
d7d93c6
to
432629e
Compare
949fa99
to
ddb4d7f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the documentation! It only allows me to offer a minor nitpick.
6b1e4e7
to
61bcbb8
Compare
utils/src/ParticleIDUtils.cc
Outdated
for (const auto& pid : getPIDs(reco)) { | ||
if (pid.getAlgorithmType() == algoType) { | ||
return pid; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (const auto& pid : getPIDs(reco)) { | |
if (pid.getAlgorithmType() == algoType) { | |
return pid; | |
const auto& [begin, end] = m_recoPidMap.equal_range(reco); | |
for (auto it = begin; it != end; ++it) { | |
if (it->getAlgorithmType() == algoType) { | |
return *it; |
The vector of PIDs doesn't need to be created
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going for some code reuse, but good point. Changed.
**Finally most of the examples assume that the desired values were found and | ||
simply get the `value` from the returned `std::optional` directly.** This means | ||
that most of the times you will see lines like this | ||
|
||
```cpp | ||
const auto value = pidHandler.getAlgoType("someAlgo").value(); | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem here is that the exception messages are very cryptic:
terminate called after throwing an instance of 'std::bad_optional_access'
what(): bad optional access
zsh: IOT instruction (core dumped) ./a.out
so encouraging not checking is not great. At the same time I think this part is too verbose, we don't need to teach std::optional
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I have to reword this a bit. The section here introduces the assumptions we make in the examples below. This should not be read as encouraging using value
directly. If we do the proper checks, the examples get rather long.
@@ -0,0 +1,229 @@ | |||
# PIDHandler introduction and usage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe somewhere it should say that it's not mandatory to use the PIDHandler and one can iterate manually? For example if each reco particle needs to be accessed once for a given PID algorithm, then it's not necessary to build a map.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Done.
Co-authored-by: Juan Miguel Carceller <[email protected]>
Co-authored-by: Andre Sailer <[email protected]>
Co-authored-by: Mateusz Jakub Fila <[email protected]>
31588c4
to
2d36f27
Compare
BEGINRELEASENOTES
Cluster
toParticleID
ReconstructedParticle
toParticleID
OneToOneRelation
fromParticleID
to aReconstructedParticle
edm4hep::utils::PIDHandler
and some related utility functionality to help with handling the necessary meta data.ENDRELEASENOTES
Fixes #251, Fixes #217
Associated PRs (need to be merged at the same time to not break the nightlies completely)
Open questions (so far):
ParticleID
still need thetype
andalgorithmType
members. In principle at least the latter now can be entirely encoded in the ParticleID collection, since in principle each algorithm can (should?) produce its own collection?