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

Use ndf instead of probability for vertexes in EDM4hep #71

Merged
merged 7 commits into from
Jun 28, 2024

Conversation

jmcarcell
Copy link
Member

@jmcarcell jmcarcell commented Jun 20, 2024

Changes after key4hep/EDM4hep#324. I'm finding ndf by a binary search in the LCIO to EDM4hep direction and seems to work fine. Maybe the upper value can be tuned with typical values to reduce a few steps in the search.

BEGINRELEASENOTES

  • Use ndf instead of probability for vertexes in EDM4hep
  • Add a utility function to find ndf from chi^2 and the probability to go from LCIO to EDM4hep
  • Add a utility macro to compare float values

ENDRELEASENOTES

Copy link
Contributor

@tmadlener tmadlener left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice, thanks. One question and one suggestion below.

@@ -174,6 +176,29 @@ std::vector<CollNamePair> convertReconstructedParticles(const std::string& name,
return results;
}

// Go from chi^2 and probability (1 - CDF(chi^2, ndf))
// to ndf by a binary search
int find_ndf(double chi2, double prob) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is not a template, we could put this into the header (and potentially into a nested namespace) and move the implementation to the cc file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, I think a namespace for a single small function is a bit overkill, no?

// Initial guess for the upper bound. If it's not enough, it will be increased
int upper = 100;
while (TMath::Prob(chi2, upper) < prob) {
lower = upper;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice :)

@jmcarcell
Copy link
Member Author

Another consideration is that if the probability is > 1 or chi^2 < 0 then it will be an infinite loop. I don't know if those cases have ever happened, but if they do then someone will have to debug why it's not doing anything...

@tmadlener
Copy link
Contributor

Maybe we can add an assert on that? That would at least make it show up in a debug build immediately. Or throw an invalid_argument, because at that point there is really not that much that we can do.

@jmcarcell
Copy link
Member Author

I added a throw since it's going to be very annoying to run some chain of algorithms that never ends and having to figure out why that is happening, better throw before.

Copy link
Contributor

@tmadlener tmadlener left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI is failing because key4hep/EDM4hep#324 is not yet merged, but that cannot be merged without breaking the nightlies, without this. I assume that you have tested this locally, so I think this can go in, together with the EDM4hep PR.

@tmadlener tmadlener merged commit 74efd62 into main Jun 28, 2024
2 of 7 checks passed
@tmadlener tmadlener deleted the probability-ndf branch June 28, 2024 11:43
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