Skip to content

Conversation

@AdvaitDhingra
Copy link
Contributor

@AdvaitDhingra AdvaitDhingra commented Jul 19, 2021

This Pull request:

Changes or fixes:

Adds a tutorial demonstrating how a Histogram can be read from a ROOT File. I also added one that demos how a rootfile with a histogram can be made.

Checklist:

  • tested changes locally
  • updated the docs (if necessary)

As mentioned in this forum post.

@AdvaitDhingra AdvaitDhingra requested a review from couet as a code owner July 19, 2021 12:20
@phsft-bot
Copy link

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-ubuntu16/nortcxxmod, mac1014/python3, mac11.0/cxx17, windows10/cxx14
How to customize builds

@AdvaitDhingra AdvaitDhingra changed the title Added HIstogram ROOT File Tutorial Added Histogram ROOT File Tutorial Jul 19, 2021

void ReadROOTFile()
{
TFile *f = new TFile("demo.root");
Copy link
Member

Choose a reason for hiding this comment

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

"hsimple.root" should always exist

Copy link
Member

Choose a reason for hiding this comment

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

Please use a combination of gROOT->GetTutorialsDir() and hsimple.root - which does exist - instead of demo.root - which doesn't exist. You will have to use one of the histograms from hsimple.root then, of course.

Copy link
Member

Choose a reason for hiding this comment

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

The macro https://root.cern/doc/master/h1draw_8C.html does something similar to what you are doing. It creates the file hsimple.root if it does not exist, get the histograms in it and draw them.

@phsft-bot
Copy link

Build failed on ROOT-debian10-i386/cxx14.
Running on pcepsft11.dyndns.cern.ch:/home/sftnight/build/workspace/root-pullrequests-build
See console output.

Failing tests:

@phsft-bot
Copy link

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-ubuntu16/nortcxxmod, mac1014/python3, mac11.0/cxx17, windows10/cxx14
How to customize builds

1 similar comment
@phsft-bot
Copy link

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-ubuntu16/nortcxxmod, mac1014/python3, mac11.0/cxx17, windows10/cxx14
How to customize builds

@phsft-bot
Copy link

Build failed on ROOT-performance-centos8-multicore/default.
Running on olbdw-01.cern.ch:/data/sftnight/workspace/root-pullrequests-build
See console output.

Failing tests:

@phsft-bot
Copy link

Build failed on ROOT-debian10-i386/cxx14.
Running on pcepsft11.dyndns.cern.ch:/home/sftnight/build/workspace/root-pullrequests-build
See console output.

Failing tests:


void ReadROOTFile()
{
TFile *f = new TFile("demo.root");
Copy link
Member

Choose a reason for hiding this comment

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

Please use a combination of gROOT->GetTutorialsDir() and hsimple.root - which does exist - instead of demo.root - which doesn't exist. You will have to use one of the histograms from hsimple.root then, of course.

@@ -0,0 +1,31 @@
/// \file
Copy link
Member

Choose a reason for hiding this comment

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

As we discussed, please remove CreateROOTFile.C but instead rely on hsimple.root which gets created during build time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@phsft-bot
Copy link

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-ubuntu16/nortcxxmod, mac1014/python3, mac11.0/cxx17, windows10/cxx14
How to customize builds

@phsft-bot
Copy link

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-ubuntu16/nortcxxmod, mac1014/python3, mac11.0/cxx17, windows10/cxx14
How to customize builds

@ghost
Copy link

ghost commented Jul 20, 2021

Congratulations 🎉. DeepCode analyzed your code in 3.946 seconds and we found no issues. Enjoy a moment of no bugs ☀️.

👉 View analysis in DeepCode’s Dashboard | Configure the bot

👉 The DeepCode service and API will be deprecated in August, 2021. Here is the information how to migrate. Thank you for using DeepCode 🙏 ❤️ !

If you are using our plugins, you might be interested in their successors: Snyk's JetBrains plugin and Snyk's VS Code plugin.

@phsft-bot
Copy link

Build failed on ROOT-performance-centos8-multicore/default.
Running on olbdw-01.cern.ch:/data/sftnight/workspace/root-pullrequests-build
See console output.

Failing tests:

@phsft-bot
Copy link

Build failed on ROOT-debian10-i386/cxx14.
Running on pcepsft10.dyndns.cern.ch:/build/workspace/root-pullrequests-build
See console output.

Errors:

  • [2021-07-20T16:45:27.072Z] stderr: error: could not read '.git/rebase-apply/head-name': No such file or directory

Failing tests:

@AdvaitDhingra
Copy link
Contributor Author

AdvaitDhingra commented Jul 20, 2021

I think the problem is that hsimple.root doesnt exist without hsimple.C being run first.

I aborted the jenkins.

@Axel-Naumann
Copy link
Member

Axel-Naumann commented Jul 21, 2021

It gets created as part of the build: it does exist, in the tutorials/ subdir of the builddir. As I said, gROOT->GetTutoriaalDir() should help.

@AdvaitDhingra
Copy link
Contributor Author

It gets created as part of the build: it does exist, in the tutorials/ subdir of the builddir. As I said, gROOT->GetTutoriaalDir() should help.

Ahh, ok

@phsft-bot
Copy link

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-ubuntu16/nortcxxmod, mac1014/python3, mac11.0/cxx17, windows10/cxx14
How to customize builds

@phsft-bot
Copy link

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-ubuntu16/nortcxxmod, mac1014/python3, mac11.0/cxx17, windows10/cxx14
How to customize builds

@AdvaitDhingra
Copy link
Contributor Author

@Axel-Naumann, @couet pointed out that my read file was basically a simpler version of h1draw.C and that it would be better to just clarify some things in that file.

@phsft-bot
Copy link

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-ubuntu16/nortcxxmod, mac1014/python3, mac11.0/cxx17, windows10/cxx14
How to customize builds

@phsft-bot
Copy link

Build failed on ROOT-performance-centos8-multicore/default.
Running on olbdw-01.cern.ch:/data/sftnight/workspace/root-pullrequests-build
See console output.

Errors:

Failing tests:

@phsft-bot
Copy link

Build failed on ROOT-debian10-i386/cxx14.
Running on pcepsft10.dyndns.cern.ch:/build/workspace/root-pullrequests-build
See console output.

Errors:

  • [2021-07-21T20:37:37.519Z] stderr: error: could not read '.git/rebase-apply/head-name': No such file or directory

Failing tests:

@phsft-bot
Copy link

Build failed on mac11.0/cxx17.
Running on macphsft20.dyndns.cern.ch:/Users/sftnight/build/workspace/root-pullrequests-build
See console output.

Errors:

Failing tests:

@phsft-bot
Copy link

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-ubuntu16/nortcxxmod, mac1014/python3, mac11.0/cxx17, windows10/cxx14
How to customize builds

@AdvaitDhingra
Copy link
Contributor Author

That was a pretty funny mistake 😆

@phsft-bot
Copy link

Build failed on ROOT-debian10-i386/cxx14.
Running on pcepsft11.dyndns.cern.ch:/home/sftnight/build/workspace/root-pullrequests-build
See console output.

Failing tests:

@Axel-Naumann
Copy link
Member

The filename is referred to here:

tutorials/CMakeLists.txt:                       tutorial-hist-h1draw
tutorials/CMakeLists.txt:  set(pyroot-h1draw-depends tutorial-pyroot-hsimple-py)
tutorials/CMakeLists.txt:                                tutorial-pyroot-h1draw-py
tutorials/demos.C:   bar->AddButton("h1draw",     ".x hist/h1draw.C",        "Drawing Options for 1D Histograms");
tutorials/legacy/benchmarks.C:   summary->AddText("  hist/h1draw.C");
tutorials/legacy/benchmarks.C:   bexec(dir,"hist/h1draw.C");
tutorials/legacy/pyroot/benchmarks.py:   'fillrandom.py','fit1.py', 'h1draw.py', 'graph.py',
tutorials/pyroot/demo.py:bar.AddButton( 'h1draw',        r'TPython::Exec( "' + to_run.format('h1draw.py') + '" );',    'Drawing Options for 1D Histograms' )

@phsft-bot
Copy link

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-ubuntu16/nortcxxmod, mac1014/python3, mac11.0/cxx17, windows10/cxx14
How to customize builds

I clarified some things.

Modified tutorial

Removed my file and modified h1draw.C

Minor changes

Fixed mistake

Simplified
@phsft-bot
Copy link

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-ubuntu16/nortcxxmod, mac1014/python3, mac11.0/cxx17, windows10/cxx14
How to customize builds

@AdvaitDhingra AdvaitDhingra requested a review from bellenot as a code owner July 26, 2021 12:59
@phsft-bot
Copy link

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-ubuntu16/nortcxxmod, mac1014/python3, mac11.0/cxx17, windows10/cxx14
How to customize builds

@phsft-bot
Copy link

Build failed on ROOT-debian10-i386/cxx14.
Running on pcepsft10.dyndns.cern.ch:/build/workspace/root-pullrequests-build
See console output.

Errors:

  • [2021-07-26T14:14:31.127Z] stderr: error: could not read '.git/rebase-apply/head-name': No such file or directory

Failing tests:

@AdvaitDhingra
Copy link
Contributor Author

@Axel-Naumann is everything okay?

@phsft-bot
Copy link

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-ubuntu16/nortcxxmod, mac1014/python3, mac11.0/cxx17, windows10/cxx14
How to customize builds

@phsft-bot
Copy link

Build failed on ROOT-debian10-i386/cxx14.
Running on pcepsft11.dyndns.cern.ch:/home/sftnight/build/workspace/root-pullrequests-build
See console output.

Failing tests:

@AdvaitDhingra
Copy link
Contributor Author

Should be fine now

@AdvaitDhingra
Copy link
Contributor Author

@Axel-Naumann @couet everything ok with this?


void ReadROOTFile()
{
TFile *f = new TFile("demo.root");
Copy link
Member

Choose a reason for hiding this comment

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

The macro https://root.cern/doc/master/h1draw_8C.html does something similar to what you are doing. It creates the file hsimple.root if it does not exist, get the histograms in it and draw them.

#include "TInterpreter.h"

void h1draw()
void h1ReadAndDraw()
Copy link
Member

Choose a reason for hiding this comment

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

Be careful changing the macro name. It is used in several places:

% git grep h1draw
documentation/doxygen/parallelNotebooks.py:    dependenciesgraph.add("pyroot/h1draw.py",["pyroot/hsimple.py"])
documentation/users-guide/Graphics.md:root[] .x tutorials/hist/h1draw.C
graf2d/gpad/src/TControlBar.cxx:   bar.AddButton("h1draw",           ".x h1draw.C",
hist/histpainter/doc/index.md:  - h1draw.C: Drawing Options for 1D Histograms.
test/stressGUI.cxx:   bar->AddButton("h1draw",    ".x hist/h1draw.C",      "Drawing Options for 1D Histograms");
tutorials/CMakeLists.txt:                       tutorial-hist-h1draw
tutorials/CMakeLists.txt:  set(pyroot-h1draw-depends tutorial-pyroot-hsimple-py)
tutorials/CMakeLists.txt:                                tutorial-pyroot-h1draw-py
tutorials/demos.C:   bar->AddButton("h1draw",     ".x hist/h1draw.C",        "Drawing Options for 1D Histograms");
tutorials/hist/h1draw.C:void h1draw()
tutorials/legacy/benchmarks.C:   summary->AddText("  hist/h1draw.C");
tutorials/legacy/benchmarks.C:   bexec(dir,"hist/h1draw.C");
tutorials/legacy/pyroot/benchmarks.py:   'fillrandom.py','fit1.py', 'h1draw.py', 'graph.py',
tutorials/pyroot/demo.py:bar.AddButton( 'h1draw',        r'TPython::Exec( "' + to_run.format('h1draw.py') + '" );',    'Drawing Options for 1D Histograms' )

macros = [
'framework.py', 'hsimple.py', 'hsum.py', 'formula1.py',
'fillrandom.py','fit1.py', 'h1draw.py', 'graph.py',
'fillrandom.py','fit1.py', 'h1ReadAndDraw.py', 'graph.py',
Copy link
Member

Choose a reason for hiding this comment

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

have you renamed ./tutorials/pyroot/h1draw.py ? it do not see this file renaming in that PR (I may have missed it)

if (gBenchmark->GetBench("hsimple") < 0) gInterpreter->LoadMacro(dir.Data());
TFile *example = (TFile*)gROOT->ProcessLineFast("hsimple(1)");
if (!example) return;
// Generate the ROOT File
Copy link
Member

Choose a reason for hiding this comment

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

Now the comment should not be "generate the ROOT file" as you assume the file already exists. It is not generated.

Copy link
Member

Choose a reason for hiding this comment

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

@AdvaitDhingra can you change the comment ?

@phsft-bot
Copy link

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-ubuntu16/nortcxxmod, mac1014/python3, mac11.0/cxx17, windows10/cxx14
How to customize builds

@couet couet merged commit 4f5928c into root-project:master Aug 25, 2021
@AdvaitDhingra AdvaitDhingra deleted the file branch August 25, 2021 16:32
@phsft-bot
Copy link

Build failed on ROOT-debian10-i386/cxx14.
Running on pcepsft10.dyndns.cern.ch:/build/workspace/root-pullrequests-build
See console output.

Errors:

  • [2021-08-25T16:46:23.582Z] CMake Error at /home/sftnight/build/workspace/root-pullrequests-build/rootspi/jenkins/root-build.cmake:1045 (message):

pzhristov pushed a commit to alisw/root that referenced this pull request Aug 27, 2021
* Modified h1draw.C tutorial

I clarified some things.

Modified tutorial

Removed my file and modified h1draw.C

Minor changes

Fixed mistake

Simplified

* Changed name

* Renamed pyroot file

* Update h1ReadAndDraw.C
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants