ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
tvdemo.C
Go to the documentation of this file.
1 void tvdemo() {
2  printf("This demo show how to handle TTreeViewer sessions\n");
3  printf("Compile class Event from test directory before running this\n");
4  printf("- use arrow buttons from bottom to cycle records ...\n");
5  printf("- make new expressions and drag them to X, Y, Z or Cut items ...\n");
6  printf("- use the Draw button to check your current selection ...\n");
7  printf("- click the record button once you are happy with this ...\n");
8  printf("- open the TV context menu (right-click on the right panel)...\n");
9  printf(" Use : RemoveLastRecord() - to remove last record :-)\n");
10  printf(" SetRecordName() - to name current record\n");
11  printf(" UpdateRecord() - if you want to change a record from the list\n");
12  printf(" with your new X, Y, Z, Cut configuration.\n");
13  printf(" Best luck !\n");
14 
15  open_session();
16 }
17 
18 open_session(void *p = 0) {
19 //=========Macro generated by ROOT version3.00/00
20 //=========for tree "T" (Wed Feb 21 14:16:23 2001)
21 //===This macro can be opened from a TreeViewer session after loading
22 //===the corresponding tree
23  gSystem->Load("libTreeViewer");
24  TTreeViewer *treeview = (TTreeViewer *) p;
25  if (!treeview) treeview = new TTreeViewer();
26  TTree *tv_tree = (TTree*)gROOT->FindObject("T");
27  TFile *tv_file = (TFile*)gROOT->GetListOfFiles()->FindObject("Event.root");
28  if (!tv_tree) {
29  if (!tv_file) tv_file = new TFile("$ROOTSYS/test/Event.root");
30  if (tv_file) tv_tree = (TTree*)tv_file->Get("T");
31  if(!tv_tree) {
32  printf("Tree %s not found", fTree->GetName());
33  return;
34  }
35  }
36 
37  treeview->SetTreeName("T");
38  treeview->SetNexpressions(10);
39 // Set expressions on axis and cut
40  TTVLVEntry *item;
41 // X expression
42  item = treeview->ExpressionItem(0);
43  item->SetExpression("fTemperature", "fTemperature");
44 // Y expression
45  item = treeview->ExpressionItem(1);
46  item->SetExpression("", "-empty-");
47 // Z expression
48  item = treeview->ExpressionItem(2);
49  item->SetExpression("", "-empty-");
50 // Cut expression
51  item = treeview->ExpressionItem(3);
52  item->SetExpression("", "-empty-");
53 // Scan list
54  item = treeview->ExpressionItem(4);
55  item->SetExpression("", "Scan box");
56 // User defined expressions
57  item = treeview->ExpressionItem(5);
58  item->SetExpression("sqrt(fTracks.fPx*fTracks.fPx+fTracks.fPy*fTracks.fPy)", "~Pt", kFALSE);
59  item = treeview->ExpressionItem(6);
60  item->SetExpression("fTracks.fPx>0", "~Cut1", kTRUE);
61  item = treeview->ExpressionItem(7);
62  item->SetExpression("", "-empty-", kFALSE);
63  item = treeview->ExpressionItem(8);
64  item->SetExpression("", "-empty-", kFALSE);
65  item = treeview->ExpressionItem(9);
66  item->SetExpression("", "-empty-", kFALSE);
67  item = treeview->ExpressionItem(10);
68  item->SetExpression("", "-empty-", kFALSE);
69  item = treeview->ExpressionItem(11);
70  item->SetExpression("", "-empty-", kFALSE);
71  item = treeview->ExpressionItem(12);
72  item->SetExpression("", "-empty-", kFALSE);
73  item = treeview->ExpressionItem(13);
74  item->SetExpression("", "-empty-", kFALSE);
75  item = treeview->ExpressionItem(14);
76  item->SetExpression("", "-empty-", kFALSE);
77 //--- session object
78  tv_session = new TTVSession(treeview);
79  treeview->SetSession(tv_session);
80 //--- tree viewer record
81  tv_record = tv_session->AddRecord(kTRUE);
82  tv_session->SetRecordName("Temperature");
83  tv_record->fX = "fTemperature";
84  tv_record->fY = "";
85  tv_record->fZ = "";
86  tv_record->fCut = "";
87  tv_record->fXAlias = "fTemperature";
88  tv_record->fYAlias = "-empty-";
89  tv_record->fZAlias = "-empty-";
90  tv_record->fCutAlias = "-empty-";
91  tv_record->fOption = "lego1";
92  tv_record->fScanRedirected = kFALSE;
93  tv_record->fCutEnabled = kTRUE;
94 //--- tree viewer record
95  tv_record = tv_session->AddRecord(kTRUE);
96  tv_session->SetRecordName("Py versus Px");
97  tv_record->fX = "fTracks.fPx";
98  tv_record->fY = "fTracks.fPy";
99  tv_record->fZ = "";
100  tv_record->fCut = "";
101  tv_record->fXAlias = "fTracks.fPx";
102  tv_record->fYAlias = "fTracks.fPy";
103  tv_record->fZAlias = "-empty-";
104  tv_record->fCutAlias = "-empty-";
105  tv_record->fOption = "lego";
106  tv_record->fScanRedirected = kFALSE;
107  tv_record->fCutEnabled = kTRUE;
108 //--- tree viewer record
109  tv_record = tv_session->AddRecord(kTRUE);
110  tv_session->SetRecordName("Transverse momentum");
111  tv_record->fX = "sqrt(fTracks.fPx*fTracks.fPx+fTracks.fPy*fTracks.fPy)";
112  tv_record->fY = "";
113  tv_record->fZ = "";
114  tv_record->fCut = "fTracks.fPx>0";
115  tv_record->fXAlias = "~Pt";
116  tv_record->fYAlias = "-empty-";
117  tv_record->fZAlias = "-empty-";
118  tv_record->fCutAlias = "~Cut1";
119  tv_record->fOption = "";
120  tv_record->fScanRedirected = kFALSE;
121  tv_record->fCutEnabled = kTRUE;
122 //--- tree viewer record
123  tv_record = tv_session->AddRecord(kTRUE);
124  tv_session->SetRecordName("Surface plot of Py vs. Px");
125  tv_record->fX = "fTracks.fPx";
126  tv_record->fY = "fTracks.fPy";
127  tv_record->fZ = "";
128  tv_record->fCut = "";
129  tv_record->fXAlias = "fTracks.fPx";
130  tv_record->fYAlias = "fTracks.fPy";
131  tv_record->fZAlias = "-empty-";
132  tv_record->fCutAlias = "-empty-";
133  tv_record->fOption = "SURF";
134  tv_record->fScanRedirected = kFALSE;
135  tv_record->fCutEnabled = kTRUE;
136 //--- Show first record
137  tv_session->Show(tv_session->First());
138 }
open_session(void *p=0)
Definition: tvdemo.C:18
void SetNexpressions(Int_t expr)
Change the number of expression widgets.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:45
virtual TObject * Get(const char *namecycle)
Return pointer to object identified by namecycle.
#define gROOT
Definition: TROOT.h:344
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Definition: TSystem.cxx:1766
void SetTreeName(const char *treeName)
Allow geting the tree from the context menu.
const Bool_t kFALSE
Definition: Rtypes.h:92
A graphic user interface designed to handle ROOT trees and to take advantage of TTree class features...
Definition: TTreeViewer.h:60
void SetExpression(const char *name, const char *alias, Bool_t cutType=kFALSE)
Set the true name, alias and type of the expression, then refresh it.
R__EXTERN TSystem * gSystem
Definition: TSystem.h:545
TTVLVEntry * ExpressionItem(Int_t index)
Get the item from a specific position.
This class represent entries that goes into the TreeViewer listview container.
void SetSession(TTVSession *session)
Set current session.
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
I/O classes for TreeViewer session handling.
Definition: TTVSession.h:71
void tvdemo()
Definition: tvdemo.C:1
A TTree object has a header with a name and a title.
Definition: TTree.h:98
const Bool_t kTRUE
Definition: Rtypes.h:91