Skip to content

Fix DF examples to make them work as notebooks #10446

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 5 commits into from
Apr 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions documentation/doxygen/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

PYTHON_EXECUTABLE ?= /usr/bin/python3
export PYTHON_EXECUTABLE
export PYSPARK_PYTHON := $(PYTHON_EXECUTABLE)

DOXYGEN_OUTPUT_DIRECTORY ?= $(HOME)/rootdoc
export DOXYGEN_OUTPUT_DIRECTORY
Expand Down
14 changes: 9 additions & 5 deletions documentation/doxygen/filter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,11 @@ void FilterTutorial()
ReplaceAll(image_name, " ", "");
ReplaceAll(image_name, "///\\macro_image(", "");
ReplaceAll(image_name, ")\n", "");
ExecuteCommand(StringFormat("root -l -b -q %s", gFileName.c_str()));
if (gPython) {
ExecuteCommand(StringFormat("%s %s", gPythonExec.c_str(), gFileName.c_str()));
} else {
ExecuteCommand(StringFormat("root -l -b -q %s", gFileName.c_str()));
}
ExecuteCommand(StringFormat("mv %s %s/html", image_name.c_str(), gOutDir.c_str()));
ReplaceAll(gLineString, "macro_image (", "image html ");
ReplaceAll(gLineString, ")", "");
Expand All @@ -347,16 +351,16 @@ void FilterTutorial()
IN = gImageName;
int i = IN.find(".");
IN.erase(i,IN.length());
ExecuteCommand(StringFormat("root -l -b -q \"MakeTCanvasJS.C(\\\"%s\\\",\\\"%s\\\",\\\"%s\\\",false,false)\"",
gFileName.c_str(), IN.c_str(), gOutDir.c_str()));
ExecuteCommand(StringFormat("root -l -b -q \"MakeTCanvasJS.C(\\\"%s\\\",\\\"%s\\\",\\\"%s\\\",false,%d)\"",
gFileName.c_str(), IN.c_str(), gOutDir.c_str(), gPython));
ReplaceAll(gLineString, "macro_image", StringFormat("htmlinclude %s.html",IN.c_str()));
} else if (rcanvas_js) {
string IN;
IN = gImageName;
int i = IN.find(".");
IN.erase(i,IN.length());
ExecuteCommand(StringFormat("root -l -b -q --web=batch \"MakeRCanvasJS.C(\\\"%s\\\",\\\"%s\\\",\\\"%s\\\",false,false)\"",
gFileName.c_str(), IN.c_str(), gOutDir.c_str()));
ExecuteCommand(StringFormat("root -l -b -q --web=batch \"MakeRCanvasJS.C(\\\"%s\\\",\\\"%s\\\",\\\"%s\\\",false,%d)\"",
gFileName.c_str(), IN.c_str(), gOutDir.c_str(), gPython));
ReplaceAll(gLineString, "macro_image", StringFormat("htmlinclude %s.html",IN.c_str()));
} else {
if (gPython) {
Expand Down
2 changes: 1 addition & 1 deletion tutorials/dataframe/df105_WBosonAnalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
args = parser.parse_args()
else:
# Notebook
args =parser.parse_args(args=[])
args = parser.parse_args(args=[])

if args.b: ROOT.gROOT.SetBatch(True)
if args.t: ROOT.EnableImplicitMT()
Expand Down
3 changes: 2 additions & 1 deletion tutorials/dataframe/df106_HiggsToFourLeptons.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
# Create a ROOT dataframe for each dataset
# Note that we load the filenames from the external json file placed in the same folder than this script.
path = "root://eospublic.cern.ch//eos/opendata/atlas/OutreachDatasets/2020-01-22"
files = json.load(open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "df106_HiggsToFourLeptons.json")))
files = json.load(open(os.path.join(ROOT.gROOT.GetTutorialsDir(), "dataframe/df106_HiggsToFourLeptons.json")))

processes = files.keys()
df = {}
xsecs = {}
Expand Down
10 changes: 8 additions & 2 deletions tutorials/dataframe/df107_SingleTopAnalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
## \author Stefan Wunsch (KIT, CERN)

import ROOT
import sys
import json
import argparse
import os
Expand All @@ -32,7 +33,12 @@
help="Use the full dataset (use --lumi-scale to run only on a fraction of it)")
parser.add_argument("-b", action="store_true", default=False, help="Use ROOT batch mode")
parser.add_argument("-t", action="store_true", default=False, help="Use implicit multi threading (for the full dataset only possible with --lumi-scale 1.0)")
args = parser.parse_args()
if 'df107_SingleTopAnalysis.py' in sys.argv[0]:
# Script
args = parser.parse_args()
else:
# Notebook
args = parser.parse_args(args=[])

if args.b: ROOT.gROOT.SetBatch(True)
if args.t: ROOT.EnableImplicitMT()
Expand All @@ -47,7 +53,7 @@

# Create a ROOT dataframe for each dataset
# Note that we load the filenames from the external json file placed in the same folder than this script.
files = json.load(open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "df107_SingleTopAnalysis.json")))
files = json.load(open(os.path.join(ROOT.gROOT.GetTutorialsDir(), "dataframe/df107_SingleTopAnalysis.json")))
processes = files.keys()
df = {}
xsecs = {}
Expand Down
2 changes: 1 addition & 1 deletion tutorials/r/SimpleFitting.C
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// \file
/// \ingroup tutorial_r
/// \notebook
///
/// Create an exponential fitting
/// The idea is to create a set of numbers x,y with the function x^3 and some noise from ROOT,
/// fit the function to get the exponent (which must be near 3) and plot the points with noise,
Expand Down
2 changes: 1 addition & 1 deletion tutorials/rcanvas/df104.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
## This macro is replica of tutorials/dataframe/df104_HiggsToTwoPhotons.py, but with usage of ROOT7 graphics
## Run macro with python3 -i df104.py command to get interactive canvas
##
## \macro_image (rcanvas_js)
## \macro_image (df104.png)
## \macro_code
##
## \date 2021-06-15
Expand Down
2 changes: 1 addition & 1 deletion tutorials/rcanvas/df105.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

# Create a ROOT dataframe for each dataset
# Note that we load the filenames from the external json file placed in the same folder than this script.
files = json.load(open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "df105.json")))
files = json.load(open(os.path.join(ROOT.gROOT.GetTutorialsDir(), "rcanvas/df105.json")))
processes = files.keys()
df = {}
xsecs = {}
Expand Down
3 changes: 1 addition & 2 deletions tutorials/roofit/rf207_comptools.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
## \macro_code
##
## \date February 2018
## \author Clemens Lange
## \author Wouter Verkerke (C version)
## \authors Clemens Lange, Wouter Verkerke (C version)

import ROOT

Expand Down
2 changes: 1 addition & 1 deletion tutorials/sql/sqlselect.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## \file
## \ingroup tutorial_sql
## \notebook -nodraw
##
## Query example to MySQL test database.
## Example of query by using the test database made in MySQL, you need the
## database test installed in localhost, with user nobody without password.
Expand Down
2 changes: 1 addition & 1 deletion tutorials/xml/xmlmodifyfile.C
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// \file
/// \ingroup tutorial_xml
/// \notebook -nodraw
///
/// Example to read, modify and store xml file, using TXMLEngine class
/// The input file, produced by xmlnewfile.C macro is used
/// If you need full xml syntax support, use TXMLParser instead
Expand Down
2 changes: 1 addition & 1 deletion tutorials/xml/xmlreadfile.C
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// \file
/// \ingroup tutorial_xml
/// \notebook -nodraw
///
/// Example to read and parse any xml file, supported by TXMLEngine class
/// The input file, produced by xmlnewfile.C macro is used
/// If you need full xml syntax support, use TXMLParser instead
Expand Down