Skip to content

Add a new test producing histograms and improve comments in tests #208

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

Merged
merged 12 commits into from
Jul 15, 2024

Conversation

jmcarcell
Copy link
Member

BEGINRELEASENOTES

  • Add a new test producing histograms, making use of the corresponding service in Gaudi
  • Improve comments and descriptions in tests

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. I have a few minor questions inline. I think it would be nice to also have some documentation explaining the main building blocks so that it's a bit more obvious which pieces are related to histograms on the c++ and the python side.

f = ROOT.TFile.Open("functional_producer_hist.root")
for i in range(2):
if (
str(f.GetListOfKeys()[i])
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this guaranteed to be always ordered?

Copy link
Member Author

Choose a reason for hiding this comment

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

In the current test I left multithreading disabled not to have too many multithreaded jobs running at same time since ctest doesn't know about this but after running it several times I never got the other ordering. I think the histograms may be registered when the class is created and in that case it would always be ordered but I'm not sure.

Copy link
Contributor

Choose a reason for hiding this comment

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

The alternative would be to simply make a set of the names in the files and the expected ones and do a set comparison to make sure everything is there to avoid any ordering issues.

Comment on lines 37 to 39
// Not thread-safe!
Rndm::Numbers rndu(randSvc(), Rndm::Flat(0, 1));
++m_histograms[rndu()];
Copy link
Contributor

Choose a reason for hiding this comment

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

Which part here is not thread safe? I suppose it's randSvc? Is that only used for seeding here? Can we make this into a thread safe example without too much work?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the engine comes from randSvc and since you can do randSvc()->engine()->setSeeds({1, 2}); any time then I assume it's not going to work. There is something for multithreading here: https://gitlab.cern.ch/gaudi/Gaudi/-/blob/master/GaudiHive/src/HiveNumbers.h#L29 but this is not even being installed and it's only being used in one test in Gaudi.


#include <string>

struct ExampleFunctionalProducerHist final : k4FWCore::Producer<edm4hep::MCParticleCollection()> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we only produce an empty collection here, could we not make this a Consumer (or something else that doesn't have an output)?

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought it's more common to have a producer or transformer producing something and then making some histograms so as a example, and possible starting point, I think it's closer to what most people will want (?) But indeed the output is not doing anything. Or it could be a slightly more complicated algorithm that reads some input and histograms that.

Copy link
Contributor

Choose a reason for hiding this comment

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

It could take the MCParticles as inputs and then histogram their energy. Or a different datatype for which we already have a functional producer. That would also remove the threadsafety issue with the random numbers(?)

@jmcarcell jmcarcell merged commit ad01f7c into main Jul 15, 2024
4 of 9 checks passed
@jmcarcell jmcarcell deleted the tests branch July 15, 2024 06:12
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