ROOT、インタープリテーションかコンパイレーションか

ROOTには、ClingというC++インタープリターが内蔵されています。Clingを用いた1つの例は:

root6

% root
root [0] TF1 f1("f1", "sin(x)/x", -10.0, 10.0)
root [1] f1.Draw()

各行の最後に終端の”;”が不要なことに注意して下さい。

もしくは、あなたはROOTのmacro、これは行の集合ですが、を書くことができます。

// file name = myprog1.C
void myprog1(){
   TCanvas *c1 = new TCanvas("c1" ,"Test" ,0 ,0 ,600 ,400) ;
   c1->SetGrid( ) ;
   TF1 *f1 = new TF1("f1", "sin(x)/x", -10.0, 10.0);
   f1->Draw();
   c1->Update();
}

あなたは、あなたのマクロを以下のいずれかの方法で実行することができます。

% root myprog1.C
// or
% root
root [0] .x myprog1.C

root7

あなたのマクロは、いくらかの”dressing code”を付加することにより、コンパイルすることもできます。

https://root.cern.ch/root/htmldoc/guides/primer/ROOTPrimer.html#interpretation-and-compilation

// file name = myprog2.C

//include some header files, not necessary for Cling.
#include "TApplication.h"
#include "TROOT.h"
#include "TCanvas.h"
#include "TF1.h"
using namespace std;

void myprog2() {
  TCanvas *c1 = new TCanvas("c1", "Test", 0, 0, 600, 400);
  c1->SetGrid();
  TF1 *f1 = new TF1("f1", "sin(x)/x", -10.0, 10.0);
  f1->Draw();
  c1->Update();
}

void StandaloneApplication(int argc, char** argv) {
  myprog2();
}

int main (int argc, char** argv) {
  TApplication app("ROOT Application", &argc, argv);
  StandaloneApplication(app.Argc(), app.Argv());
  app.Run();
  return 0;
}
% g++ -o myprog2 myprog2.C `root-config --cflags --libs`
./myprog2

最後に、あなたはバインディングの集合PyROOTを用いてPythonにインターフェースすることもできます。

# file name = myprog3.py
from ROOT import TCanvas, TF1
c1=TCanvas("c1" ,"Test" ,0 ,0 ,600 ,400) 
c1.SetGrid ()
f1=TF1("f1", "sin(x)/x", -10.0, 10.0)
f1.Draw()
c1.Update()
raw_input('Press <ret> to end -> ')
% python myprog3.py