This TableTest class is a simple example of how to use a TGTable with a TTreeTableInterface.
TableTest inherits from TGMainFrame to create a top level frame to embed the TGTable in. First, the hsimple.root file is opened to obtain an ntuple. Then a TTreeTableInterface is created using this ntuple. A table is then created using the interface. In the end, the table is added to the TGMainFrame that is the TableTest and the necessary calls to correctly draw the window are made. For more information about the use of TTreeTableInterface and TGTable, see their documentation.
#include <iostream>
class IDList {
private:
public:
IDList() : nID(0) {}
~IDList() {}
Int_t GetUnID(
void) {
return ++nID ; }
} ;
private:
IDList fIDs ;
public:
virtual ~TableTest() ;
void DoExit() ;
TGTable *GetTable() {
return fTable; }
};
:
TGMainFrame(p, w,
h), fNTableRows(ntrows), fNTableColumns(ntcols),
fTable(0)
{
Connect("CloseWindow()", "TableTest", this, "DoExit()") ;
DontCallClose() ;
fFile =
new TFile(
"$ROOTSYS/tutorials/hsimple.root");
if (!fFile || fFile->IsZombie()) {
printf("Please run <ROOT location>/tutorials/hsimple.C first.");
return;
}
TString varexp =
"px:py:pz:random:sin(px):log(px/py):log(pz)";
fTable =
new TGTable(
this, fIDs.GetUnID(), fInterface, fNTableRows,
fNTableColumns);
SetWindowName("Tree Table Test") ;
MapSubwindows() ;
Resize(GetDefaultWidth()+20, 600) ;
MapWindow() ;
} ;
TableTest::~TableTest()
{
delete fInterface;
fFile->Close();
Cleanup() ;
}
void TableTest::DoExit()
{
DeleteWindow();
}
TableTest *
test =
new TableTest(0, ntrows, ntcols, 500, 200);
}
#define ClassDef(name, id)
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
A simple TTree restricted to a list of float variables only.
const char * Data() const
TTreeTableInterface is used to interface to data that is stored in a TTree.
RooCmdArg Layout(Double_t xmin, Double_t xmax=0.99, Double_t ymin=0.95)
- Author
- Roel Aaij 13/07/2007
Definition in file ntupleTableTest.C.