- Welding section on absorber side (LHCVC2C_001)
[u/mrichter/AliRoot.git] / MUON / ReadTree.C
CommitLineData
c7ba256d 1#include <iostream.h>
2
3
4//***************************************************************************
5
6void ReadTree()
7{
8// This is a basic example on how the tree of reconstructed events
9// should be accessed
10//Dynamically link some shared libs
11 if (gClassTable->GetID("AliRun") < 0) {
12 gROOT->LoadMacro("loadlibs.C");
13 loadlibs();
14 }
15
16
17// Connect the Root Galice file containing ...
18 TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject("tree_reco.root");
19 if (!file) file = new TFile("tree_reco.root");
20 if (!file) {
21 cout << "File tree_reco.root not found\n";
22 return;
23 }
24
25 TFile *galice_file = (TFile*)gROOT->GetListOfFiles()->FindObject("galice.root");
26 if (!galice_file) galice_file = new TFile("galice.root");
27 if (!galice_file) {
28 cout << "File galice.root not found\n";
29 return;
30 }
31
32// Get AliRun object from file or create it if not on file
33 if (!gAlice) {
34 gAlice = (AliRun*)galice_file->Get("gAlice");
35 if (gAlice) {
36 cout << "AliRun object found on file\n";
37 } else {
38 cout << "AliRun object not found on file !!!\n";
39 return;
40 }
41 }
42
43 TTree *tree = (TTree*)file->Get("TreeRecoEvent");
44 TBranch *branch = tree->GetBranch("Event");
45 AliMUONRecoEvent *event = 0;
46 branch->SetAddress(&event);
47 Int_t nentries = (Int_t)tree->GetEntries(); // no. of reco events on file
48
49 for (Int_t evNumber=0; evNumber<nentries; evNumber++) {
50 tree->GetEntry(evNumber);
51 cout << "Event : " << event->GetNoEvent() << " with" << event->GetNoTracks() << " tracks\n";
52// print reconstr. event information
53// event->EventInfo();
54 }
55}