PAW to CINT/ROOT

---  
PRELIMINARY COMMENTS:
  • This page gives the "translation" of some commonly used PAW commands into ROOT's interactive interpreter CINT. Its purpose is to show the (former) PAW user the basic syntax of CINT. You must take into account, however, that the performances of ROOT are best seen by using it as a OO framework linked with your own C++ applications.
  • Note that CINT allows for some shortcuts which are not valid in macros or compiled programmes: Object.Function is equivalent to Object->Function; TClass *obj = new TClass(...) can be abbreviated to obj = new TClass(...); and semicolons at the end of a command may be omitted.
  • Note also that some of the actions can be more easily performed by using the left button on the canvas or/and by using the Browser.
  • (This page is originally an idea of "The Primer ROOT Page").




  • PAW

    CINT/ROOT



    Functions:
    Functions:
    fun/plot sin(x) 100 0. 3.14

    histo/plot 12345
    TF1 *f1 = new TF1("f1","sin(x)",0,10);
    f1->Draw();
    (f1->GetHistogram())->Draw();
    fun2 10 sin(x)*sin(y) 100 0. 3.14 100 0. 3.14
    histo/plot 10 surf4
    TF2 *fun2 = new TF2("fun2","sin(x)*sin(y)",0.,3.14,0.,3.14);
    fun2->Draw("surf4");


    Files:
    Files:
    histo/file 10 histos.hbook
    histo/file 10 histos.hbook ! N
    histo/file 10 histos.hbook ! U
    TFile *hfile = new TFile("histos.root");
    TFile *hfile = new TFile("histos.root","new");
    TFile *hfile = new TFile("histos.root","update");
    histo/list 10 hfile.ls(); (or just .ls)
    cd //lun10 hfile.cd();
    hrout 10 hfile->Write();
    close 10 hfile->Close();


    Histos:
    Histos:
    1-dim: 1-dim:
    1d/crea 10 'title' nbins xlow xup TH1F *h10 = new TH1F("h10","title",nbins,xlow,xup);
    histo/plot 10
    histo/plot 10(20.:50.)
    h10->Draw();
    h10->GetXaxis()->SetRange(20,50) ; h10->Draw();
    set hcol 5
    histo/plot 10 e1,s
    h10.SetLineColor(5)
    h10->Draw("e1same");
    null xmin xmax ymin ymax
    histo/plot 10 s
    TH2F frame = new TH2F("frame","",ncx,xmin,xmax,ncy,ymin,ymax);
    frame->Draw();
    h10->Draw("same")
    histo/op/add 10 11 12 a b E TH1F *h12 = new TH1F(*h10);
    h12->Sumw2();
    h12->Add(h10,h11,a,b);
    histo/op/div 10 11 12 TH1F *h12 = new TH1F(*h10);
    h12->Divide(h10,h11,1,1);
    histo/fit 10 chopt (chopt=G/pN/func/myfit.for/...) h10->Fit("opt"); (opt=gaus/pN/myfunc/myfit.C/...)
    histo/fit 10(15.:25.) chopt (chopt=G/pN/func/myfit.for/...) h10->Fit("opt","R","",15,25); (opt=gaus/pN/myfunc/myfit.C/...)
    loca -i h10->Integral(bin1,bin2);
    histo/del 10 h10->Delete();
    2-dim: 2-dim:
    2d/crea 20 'title' ncx xmin xmax ncy ymin ymax TH2F *h20 = new TH2F("h20","title",ncx,xmin,xmax,ncy,ymin,ymax);
    set hcol 5
    histo/plot 20 chopt (chopt=box/col/cont/...)
    h20.SetMarkerColor(5)
    h20->Draw("opt"); (opt = box/col/cont/...)
    min 20 5
    max 20 10
    h20->SetMinimum(5);
    h20->SetMaximum(10);
    histo/proj 20
    histo/plot 20.prox
    h20->ProjectionX("Xproj",);


    Ntuples:
    Trees:
    ntuple/create 100 ' ' 3 ' ' 1024 x y z TTree *t100 = new TTree("t100","Tree 100","z:y:x");
    ntuple/print 100 t100->Print();
    ntuple/scan 100 t100->Scan();
    ntuple/plot 100.x t100->Draw("x");
    ntuple/plot 100.x x>0 t100->Draw("x","x>0");
    ntuple/plot 100.x ! ! ! ! s t100->Draw("x","","same");
    ntuple/plot 100.y%x t100->Draw("y:x");
    ntuple/plot 100.z%y%x t100->Draw("z:y:x");
    ntuple/plot 100.x*x+y*y t100->Draw("x*x+y*y");
    ntuple/proj 10 100.x t100->Draw("x>>h10");
    ntuple/uwfnc 100 file.for t100->MakeCode("file.root");


    Windows:
    Canvas:
    (Open HIGZ window) TCanvas *c1 = new TCanvas("c1","title",sizex,sizey);
    next c1->Clear();
    (Refresh changes in window) c1->Update();
    zone 1 2
    histo/plot 1
    histo/plot 2
    c1->Divide(1,2);
    c1_1->cd();
    h1->Draw();
    c1_2->Draw();
    c1_2->cd();
    h2->Draw();
    opt logy
    opt liny
    c1->SetLogy();
    c1->SetLogy(0);
    fortran/file 66 graph.ps (or: graph.eps)
    meta -66 -111 (or: -113)
    picture/plot
    fortran/close 66
    c1->Draw();
    c1->Print("graph.ps");
    or: c1->Print("graph.eps");

    c1->Print("graph.C");
    c1->Print("graph.root");


    Primitives:
    Primitives:
    text 0.5 0.5 "TEXT" 0.35 45 TText *t1 = new TText(0.5,0.5,"TEXT");
    t1->SetTextSize(0.35);
    t1->SetTextAngle(45);
    t1->Draw();
    line 0.05 0.05 0.95 0.95 TLine *line1 = new TLine(0.05,0.05,0.95,0.95);
    line1->Draw();
    arrow 5. 5. 10. 10. 0.3 TArrow *arrow1 = new TArrow(5.,5.,10.,10.,0.03,">");
    arrow1->Draw();


    Other useful commands:
    Other useful commands:
    exec macro.kumac .x macro.C
    shell (command) .! (command)
    exit .q
    ldir .ls
    cd .pwd()
    mdir subdir dir.mkdir("subdir") (dir=gROOT,hfile, ...)
    cd dir dir.cd() or .cd("hfile.root");
    cd //PAWC gROOT.cd()
    lcdir .which
    mess "Welcome" printf("Welcome\n");
    (Load a file) .L myfit.C
    trace on .s
    wait getchar();
    (PAW++ mode) TBrowser *b = new TBrowser
    last.kumac .root_hist
    pawlogon.kumac rootlogon.C
      ---
     Copyright  1998-2000 Groupe PHOTONS at SUBATECH
    This document was created on 10-May-1998 by David d'Enterria (last modified on 20-May-2000)