void treeviewer() {
//=========Macro generated by ROOT version5.32/00
//=========for tree "t1" (Sat May  5 17:31:13 2012)
//===This macro can be opened from a TreeViewer session after loading
//===the corresponding tree, or by running root with the macro name argument

   open_session();
}

open_session(void *p = 0) {
   gSystem->Load("libTreeViewer");
   TTreeViewer *treeview = (TTreeViewer *) p;
   if (!treeview) treeview = new TTreeViewer();
   TTree *tv_tree = (TTree*)gROOT->FindObject("t1");
   TFile *tv_file = (TFile*)gROOT->GetListOfFiles()->FindObject("data/musr_50703.root");
   if (!tv_tree) {
      if (!tv_file) tv_file = new TFile("data/musr_50703.root");
      if (tv_file)  tv_tree = (TTree*)tv_file->Get("t1");
      if(!tv_tree) {
         printf("Tree %s not found", fTree->GetName());
         return;
      }
   }

   treeview->SetTreeName("t1");
   treeview->SetNexpressions(10);
//         Set expressions on axis and cut
   TTVLVEntry *item;
//   X expression
   item = treeview->ExpressionItem(0);
   item->SetExpression("save_z", "~save_z");
//   Y expression
   item = treeview->ExpressionItem(1);
   item->SetExpression("save_ke", "~save_ke");
//   Z expression
   item = treeview->ExpressionItem(2);
   item->SetExpression("", "-empty-");
//   Cut expression
   item = treeview->ExpressionItem(3);
   item->SetExpression("save_detID>870&&save_particleID==-13", "~ScanAlongZ");
//         Scan list
   item = treeview->ExpressionItem(4);
   item->SetExpression("", "Scan box");
//         User defined expressions
   item = treeview->ExpressionItem(5);
   item->SetExpression("save_detID==902&&save_particleID==-13", "~SamplePosition", kTRUE);
   item = treeview->ExpressionItem(6);
   item->SetExpression("save_detID>870&&save_particleID==-13", "~ScanAlongZ", kTRUE);
   item = treeview->ExpressionItem(7);
   item->SetExpression("save_detID==890&&save_particleID==-13", "~TDAfterFoil", kTRUE);
   item = treeview->ExpressionItem(8);
   item->SetExpression("acos(save_pz/sqrt(save_px^2+save_py^2+save_pz^2))*180/3.14", "~AcosTheta", kFALSE);
   item = treeview->ExpressionItem(9);
   item->SetExpression("save_time-0.3152", "~TOFTDSample", kFALSE);
   item = treeview->ExpressionItem(10);
   item->SetExpression("", "-empty-", kFALSE);
   item = treeview->ExpressionItem(11);
   item->SetExpression("", "-empty-", kFALSE);
   item = treeview->ExpressionItem(12);
   item->SetExpression("", "-empty-", kFALSE);
   item = treeview->ExpressionItem(13);
   item->SetExpression("", "-empty-", kFALSE);
   item = treeview->ExpressionItem(14);
   item->SetExpression("", "-empty-", kFALSE);
//--- session object
   tv_session = new TTVSession(treeview);
   treeview->SetSession(tv_session);
//--- Connect first record
   tv_session->First();
}
