Default c++ Notebooks with Root¶
The following page describes how to setup root with jupyter notebooks such that the default type of a cell is c++. This is what we did above. But you loose the flexibility of mixing python and c++. The description is a bit outdated and repeats what we habe descripted in P1.0 but it referes to another setup with jupterlab-desktop which is no longer maintained.
In [1]:
cout <<"Hello Bo";
Hello Bo
In [2]:
%jsroot on
In [3]:
%%python
import ROOT
In [4]:
%%python
h = ROOT.TH1F("gauss","Example histogram",100,-4,4)
h.FillRandom("gaus")
In [5]:
%%python
c = ROOT.TCanvas("myCanvasName","The Canvas Title",800,600)
h.Draw()
In [6]:
%%python
c.Draw()
In [7]:
cout <<"Somehow you need to call C++ to get the graph";
Somehow you need to call C++ to get the graph
In [9]:
gauss->Fit("gaus", "S");
myCanvasName->Draw();
**************************************** Minimizer is Minuit2 / Migrad Chi2 = 65.0502 NDf = 82 Edm = 4.61536e-07 NCalls = 53 Constant = 157.425 +/- 2.76819 Mean = 0.0138321 +/- 0.0143799 Sigma = 1.00178 +/- 0.0104857 (limited)
In [ ]: