IJS F9F9

Inspecting ROOT NTuple

(Most information adopted from EventView wiki).

Basic TTree use

Get the pointer to the ntuplefile.root and see what trees it contains:
>file1=new TFile("ntuplefile.root","update")
>file1->ls()
  TFile**      ntuplefile.root   
  TFile*      ntuplefile.root   
    KEY: AttributeListLayout   Schema;1   
    KEY: TTree   CollectionTree;1   CollectionTree
Inspect the Tree:
>Tree1=file1.Get("CollectionTree")
>Tree1.Print()
******************************************************************************
*Tree    :CollectionTree: CollectionTree                                         *
*Entries :     5985 : Total =        85528919 bytes  File  Size =   19709075 *
*        :          : Tree compression factor =   4.36                       *
******************************************************************************
*Br    0 :RunNumber : RunNumber/I                                            *
*Entries :     5985 : Total  Size=      24610 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    1 :EventNumber : EventNumber/I                                        *
*Entries :     5985 : Total  Size=      24622 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    2 :Token     : Token/C                                                *
*Entries :     5985 : Total  Size=     583067 bytes  File Size  =      23130 *
*Baskets :       18 : Basket Size=      32000 bytes  Compression=  23.92     *
*............................................................................*
*Br    3 :Run       : Run/I                                                  *
*Entries :     5985 : Total  Size=      24574 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    4 :Event     : Event/I                                                *
*Entries :     5985 : Total  Size=      24586 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br   46 :jetNumCone4TruthJets : Cone4TruthJetsjetNum/i                      *
*Entries :     5985 : Total  Size=      24676 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br   47 :jetEtaCone4TruthJets :                                             *
*Entries :     5985 : Total  Size=     448040 bytes  File Size  =     372571 *
*Baskets :       14 : Basket Size=      32000 bytes  Compression=   1.14     *
*............................................................................*
*Br   48 :jetPhiCone4TruthJets :                                             *
*Entries :     5985 : Total  Size=     448040 bytes  File Size  =     372492 *
*Baskets :       14 : Basket Size=      32000 bytes  Compression=   1.14     *
*............................................................................*
*Br   49 :jetECone4TruthJets :                                               *
*Entries :     5985 : Total  Size=     448000 bytes  File Size  =     368223 *
*Baskets :       14 : Basket Size=      32000 bytes  Compression=   1.15     *
*............................................................................*
*Br   50 :jetEtCone4TruthJets :                                              *
*Entries :     5985 : Total  Size=     448020 bytes  File Size  =     366062 *
*Baskets :       14 : Basket Size=      32000 bytes  Compression=   1.16     *
*............................................................................*
...
*............................................................................*
Draw a histogram:
> Tree2->Draw("jetNumCone4TruthJets")
or
> Tree2->Draw("jetNumCone4TruthJets>>h1(20,0,20)")
Comapre a histograms in 3 files (with different generator parameters settings for example):
>f2=new TFile("ntuplefile2.root","update")
>f3=new TFile("ntuplefile3.root","update") 
>Tree2=f2.Get("CollectionTree")
>Tree3=f3.Get("CollectionTree") 
>h1=TH1F("h1", "h1", 20, 0, 20);
>h2=TH1F("h2", "h2", 20, 0, 20);
>h3=TH1F("h3", "h3", 20, 0, 20);
>Tree1->Draw("jetNumCone4TruthJets>>h1") 
>Tree2->Draw("jetNumCone4TruthJets>>h2")
>Tree3->Draw("jetNumCone4TruthJets>>h3") 
>h1->SetLineColor(kBlue) 
>h3->SetLineColor(kRed) 
>h2->Draw();
>h2->Draw("same"); 
>h3->Draw("same"); 

Chaining files and drawing plots using conditions

>c1=TChain("CollectionTree") 
>c2=TChain("CollectionTree") 
>c3=TChain("CollectionTree") 
>c1.Add("ntupfile1.root")
>c2.Add("ntupfile2.root")
>c3.Add("ntupfile3.root") 
Chain Draw is somewhat more flexible than TTree Draw (why?): getting plots:
>c1.Draw("jetEtCone4TruthJets>>p1(100,0,100000.)");
>c2.Draw("jetEtCone4TruthJets>>p2(100,0,100000.)"); 
>c3.Draw("jetEtCone4TruthJets>>p3(100,0,100000.)"); 
>p1->SetLineColor(kBlue)
>p3->SetLineColor(kRed) 
>p1->Draw()
>p2->Draw("same")
>p3->Draw("same")
using options:
>c1.Draw("jetEtCone4TruthJets","","jetEtCone4TruthJets>20000.");
>c1.Draw("jetEtCone4TruthJets","","same");
for vectors components can be drawn
>c2.Draw("jetEtCone4TruthJets[0]"); 
for complex analysis MakeClass methods should be used.

-- LizaMijovic - 28 Oct 2008
Topic revision: r1 - 28 Oct 2008, LizaMijovic
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback