root icon indicating copy to clipboard operation
root copied to clipboard

[RF] Translate RooStats tutorials to Python

Open guitargeek opened this issue 3 years ago • 7 comments

After the translations of the RooFit tutorials to pyROOT were completed (see https://github.com/root-project/root/issues/8523), a next step is to translate also the RooStats tutorials to pyROOT.

The RooStats tutorials can be found in the tutorials/roostats directory. Right now, none of the tutorials are translated to Python yet. For a start, one could start with the translation of the very popular StandardHypoTestInvDemo tutorial, which explains the widely used AsymptoticCalculator and HypoTestInverter classes.

Any new Python tutorials should be formatted with black:

black --line-length=120 <tutorial file>.py

Here is the list of all the RooStats tutorials and whether they have already been translated:

  • [ ] CreateExampleFile.C
  • [x] FourBinInstructional.C
  • [ ] HybridInstructional.C
  • [ ] HybridStandardForm.C
  • [x] IntervalExamples.C
  • [ ] ModelInspector.C
  • [x] MultivariateGaussianTest.C
  • [ ] OneSidedFrequentistUpperLimitWithBands.C
  • [x] rs101_limitexample.C
  • [ ] rs102_hypotestwithshapes.C
  • [ ] rs301_splot.C
  • [ ] rs302_JeffreysPriorDemo.C
  • [x] rs401c_FeldmanCousins.C
  • [ ] rs401d_FeldmanCousins.C
  • [x] rs601_HLFactoryexample.C
  • [ ] rs602_HLFactoryCombinationexample.C
  • [ ] rs603_HLFactoryElaborateExample.C
  • [x] rs701_BayesianCalculator.C
  • [x] rs_bernsteinCorrection.C
  • [ ] rs_numberCountingCombination.C
  • [x] rs_numbercountingutils.C
  • [ ] StandardBayesianMCMCDemo.C
  • [ ] StandardBayesianNumericalDemo.C
  • [ ] StandardFeldmanCousinsDemo.C
  • [ ] StandardFrequentistDiscovery.C
  • [ ] StandardHistFactoryPlotsWithCategories.C
  • [ ] StandardHypoTestDemo.C
  • [ ] StandardHypoTestInvDemo.C
  • [x] StandardProfileInspectorDemo.C
  • [x] StandardProfileLikelihoodDemo.C
  • [ ] StandardTestStatDistributionDemo.C
  • [ ] TestNonCentral.C
  • [ ] TwoSidedFrequentistUpperLimitWithBands.C
  • [x] Zbi_Zgamma.C

guitargeek avatar Jul 27 '21 23:07 guitargeek

Hello @guitargeek @couet , I'd like to contribute to this repository. Can you guide me in going about this issue?

virenvarma007 avatar Nov 18 '21 16:11 virenvarma007

Sir I'm having a little issue with setting up the code can you help out? @guitargeek @couet

virenvarma007 avatar Nov 20 '21 09:11 virenvarma007

Hi @virenvarma007, thanks for reaching out to us about this issue!

Fortunately, you don't necessarily have to compile and set up ROOT yourself to work on this issue :) All you need it a working ROOT installation on your system. Which Linux distribution are you using? Most likely root is available as a package for your distribution, for example on Ubuntu you can just do sudo apt install root to install it. For more information on how to install ROOT also on different platforms, please take a look also at https://root.cern/install/.

Once you have ROOT installed, you can download one of the roostats tutorials that you want to translate (maybe pick a shorter one in the beginning, like rs101_limitexample. Remember you just need the tutorial file, not the whole ROOT repository.

To try out the tutorial, you can run it with the root interpreter by typing root rs101_limitexample.C in the command line. You will get a graph as a result. To translate the tutorial, you need to create a rs101_limitexample.py file where you exactly recreate the tutorial in pyROOT, such that one can run it with python rs101_limitexample.py and get the same graph than with the C++ version.

When you have translated your first tutorial, you can make a pull request here with the new python file in the same directory as the C++ tutorials.

You can find more information of ROOT and especially pyROOT for your usecase in the ROOT users manual: https://root.cern/manual/. If you have any questions that are not answered in this manual, please feel free to ask!

Good luck and thanks for your effort already! Jonas

guitargeek avatar Nov 21 '21 09:11 guitargeek

Thanks you so much for the details Sir, I'm using Ubuntu 18.04 and I already have root installed in pc. I'll start with the tutorial and work on the Issue right away.

virenvarma007 avatar Nov 21 '21 15:11 virenvarma007

Hello @guitargeek Sir, while Installing Root to my Ubuntu VM 18.04, during the building of the file "cmake --build . -- -j3" the build stops and shows this error every time at the 49% of the build. I have tried to start the process multiple times and even increase space in my Oracle VM but nothing seemed to work.

CMake Error at /home/viren/Root CERN/root/AFTERIMAGE-prefix/src/AFTERIMAGE-stamp/AFTERIMAGE-install-RelWithDebInfo.cmake:16 (message): Command failed: 2

'/usr/bin/make' 'install'

See also

/home/viren/Root CERN/root/AFTERIMAGE-prefix/src/AFTERIMAGE-stamp/AFTERIMAGE-install-*.log

CMakeFiles/AFTERIMAGE.dir/build.make:73: recipe for target 'AFTERIMAGE-prefix/src/AFTERIMAGE-stamp/AFTERIMAGE-install' failed make[2]: *** [AFTERIMAGE-prefix/src/AFTERIMAGE-stamp/AFTERIMAGE-install] Error 1 CMakeFiles/Makefile2:280: recipe for target 'CMakeFiles/AFTERIMAGE.dir/all' failed make[1]: *** [CMakeFiles/AFTERIMAGE.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs.... [ 49%] Built target move_artifacts [ 49%] Built target clang-tblgen Makefile:151: recipe for target 'all' failed make: *** [all] Error 2

virenvarma007 avatar Nov 21 '21 21:11 virenvarma007

Hi @guitargeek @couet I am interested in contributing to this repository. Can you inform me about the process? Thank you.

SunSummoner avatar Apr 17 '23 18:04 SunSummoner

Hi @guitargeek, while working on this issue, I tried to create a script that could somewhat automate this process. Manual changes are still required, but hopefully using this could speed up the process a bit for the remaining tutorials.

CppToPyConverter.zip

jolly-chen avatar Feb 15 '24 15:02 jolly-chen