1f1bcfd0ce1df79c9e994cdaea2d768473e26de3
[u/mrichter/AliRoot.git] / ITS / ReadITSTracks.C
1 #include "iostream.h"
2
3
4   void ReadITSTracks(Int_t evNumber1=0,Int_t evNumber2=0) {
5
6   const char *filename="itstracks.root";
7   
8   ///////////////// Dynamically link some shared libs ////////////////////////////////
9   
10   if (gClassTable->GetID("AliRun") < 0) {
11     gROOT->LoadMacro("loadlibs.C");
12     loadlibs();
13   } else {
14     delete gAlice;
15     gAlice=0;
16   }
17
18 // Connect the Root Galice file containing Geometry, Kine and Hits
19    TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(filename);
20    if (!file) file = new TFile(filename);
21
22 //
23 //   Loop over events 
24 //
25
26    char tname[30];
27
28    for (int nev=0; nev<= evNumber2; nev++) {
29
30    sprintf(tname,"TreeT%d",nev);
31    TTree *tracktree=(TTree*)file->Get(tname);
32    TBranch *tbranch=tracktree->GetBranch("ITStracks");
33         //cout<<" open the file \n"; 
34         
35    Int_t nentr=tracktree->GetEntries();
36
37    TObjArray tarray(nentr);
38    AliITSiotrack *iotrack=0;
39    printf("nentr %d\n",nentr);
40         
41    for (Int_t i=0; i<nentr; i++) {
42       AliITSiotrack *iotrack=new AliITSiotrack;
43       // tarray.AddAt(new AliITSiotrack,i);
44       // iotrack=(AliITSiotrack*)tarray.UncheckedAt(i);
45        tbranch->SetAddress(&iotrack);
46        tracktree->GetEvent(i);
47                  tarray.AddLast(iotrack);
48    }
49         file->Close();           
50         
51           AliITSiotrack *iotrack;
52    for (Int_t i=0; i<nentr; i++) {      
53          iotrack=(AliITSiotrack*)tarray.UncheckedAt(i);
54          if(!iotrack) continue;
55      Int_t label=iotrack->GetLabel();
56           Double_t phistate=iotrack->GetStatePhi();
57           Double_t tgl=iotrack->GetStateTgl();  
58           Double_t Zstate=iotrack->GetStateZ();
59           Double_t Dr=iotrack->GetStateD();               
60           Double_t C=iotrack->GetStateC();
61           
62           Double_t C00,C10,C11,C20,C21,C22,C30,C31,C32,C33,C40,C41,C42,C43,C44;
63          
64           iotrack->GetCovMatrix(C00,C10,C11,C20,C21,C22,C30,C31,C32,C33,C40,C41,C42,C43,C44);
65           
66           
67           cout<<"\n"<<C00<<" "<<C10<<" "<<C11<<" "<<C20<<" "<<C21<<" "<<C22<<" "
68           <<C30<<" "<<C31<<" "<<C32<<" "<<C33<<" "<<C40<<" "<<C41<<" "<<C42<<" "
69           <<C43<<" "<<C44<<"\n\n\n";
70           
71       cout<<" label = "<<label<<"\n";
72       cout<< " phi z D tgl C = "<<phistate<<" "<<Zstate<<" "<<Dr<<" "<<tgl<<" "<<C<<"\n";  getchar();     
73           
74                                             
75             
76
77  /*
78        Int_t label=iotrack->GetLabel();
79        Float_t x=iotrack->GetX();
80        Float_t y=iotrack->GetY();
81        Float_t z=iotrack->GetZ();
82        printf(" i %d label x y z %d %f %f %f\n",i,label,x,y,z);
83        // delete iotrack;
84                  */
85                  
86    }  
87
88    }   // event loop    
89 }
90