Links to Root Resources



  • Online Documents

  • Some root basics

    • ? - help
    • .q, .qqq - to exit
    • .! - shell commands
    • h2root - converts from hst4 to root format
    • .rootrc - order of evaluation
      $ROOTSYS/.rootrc, then $HOME/.rootrc, then ./.rootrc

  • Files ant their ntuples and histograms
    • Open a file:
      TFile* f = new TFile("http://...file.root");
    • Access to a histogram or an ntuple under a subdirectory in file f:
      TTree* t = f.Get("/TOPPLOT/h21");
    • Draw an ntuple variable
      t->Draw("Met");
    • Use of cuts
      t->Draw("Met","(Met<50)&&(abs(Pz)<40)");
    • Scatter plots
      t->Draw("tcpu:nhit","nhit<2000.","BOX");

  • Macros
    • PAW's uwfunc counterpart in root
      t->Makecode("uw1.C");
    • To execute a macro
      .x uw1.C
    • To book a histogram from a macro
      TH1F* h_met = new TH1F("met","missing Et",...);
    • To set histogram attributes
      h_met->SetFillColor(color);
      h_met->SetFillStyle(style); (style = 3000..3025)
    • To fill histogram from a macro
      h_met->Fill(Met);
    • To define a class based on an ntuple
      t->MakeClass("Name");
    • To load it and use it
      .L Name.C
      Name x;
      x.Loop();

  • Functions
    • User defined function:
      TFormula* form = new TFormula("form","[0]*sin([1]*x)*exp(-[2]*x)");
    • To plot a function:
      TF1* fun = new TF1("fun","form",0,25);

  • PAW translations
    • get/content 10 x
             Float_t* arr = h1->GetArray();
             
    • sigma xx=vecsum(x); v/pri xx
             h1->GetSum();
             
    • h/fit 10 g
             h1->Fit("gaus");
             
    • opt fit
             gStyle->SetOptFit();
             
    • opt grid
             c1->SetGrid();
             c1->SetGridx(); c1->SetGridy();
             
    • To get a pointer to a histogram in memory
             TH1F *h1 = (TH1F*)gROOT->Get("hname");
             
    • To fit over a subrange
             TF1 *g1 = new TF1("g1","gaus",-1,1);
             h1->Fit("g1","R");
             


Last update: 08 / Mar / 2000
E-mail: lima@fnal.gov