Removing compilation warnings and failures
[u/mrichter/AliRoot.git] / TPC / macros / AliEveTree.C
1 /*
2
3   .L $ALICE_ROOT/TPC/macros/AliEveTree.C+
4   MakeEveTree();
5   
6   TFile fesd("AliESDs.root");
7   TTree * treeESD = (TTree*)fesd.Get("esdTree");
8
9
10
11   TFile ftpc("TPCdebug.root");
12   TFile fits("ITSdebug.root");
13   TTree * treeTPC = (TTree*)ftpc.Get("Transform");
14   TTree * treeITS = (TTree*)fits.Get("Clusters");
15     
16   treeTPC->Draw("gx2/sqrt(gx0^2+gx1^2):sqrt(gx0^2+gx1^2)>>his(100,0,200,100,-1,1)","event==4","")
17   treeITS->Draw("gz/sqrt(gx^2+gy^2):sqrt(gx^2+gy^2)>>his(100,0,200,100,-1,1)","event==4","same")
18   
19   treeTPC->Draw("atan2(gx1,gx0):sqrt(gx0^2+gx1^2)>>his(100,0,200,100,-1,1)","event==4","*")
20   treeITS->Draw("atan2(gy,gx):sqrt(gx^2+gy^2)>>his(100,0,200,100,-1,1)","event==4","same*");
21
22 */
23 #include "TFile.h"
24 #include "TTree.h"
25 #include "TTreeStream.h"
26 #include "TPolyMarker3D.h"
27 #include "TVectorD.h"
28
29 #include "AliESDEvent.h"
30 #include "AliESDtrack.h"
31 #include "AliESDfriendTrack.h"
32 #include "AliTrackPointArray.h"
33
34
35 AliTrackPointArray* MakeArray(TPolyMarker3D *pol);
36 void MakeESDTree(AliESDEvent*esd, TTreeSRedirector &cstream);
37
38 void MakeEveTree(){
39   TFile fesd("AliESDs.root");
40   TTree * esdTree = (TTree*)fesd.Get("esdTree");
41   AliESDEvent cesd; 
42   esdTree->SetBranchStatus("*",kTRUE);
43   cesd.ReadFromTree(esdTree);
44   TTreeSRedirector cstream("eveTree.root");
45   for (Int_t ievent=0; ievent<esdTree->GetEntries();ievent++) {
46     //cout<<endl<<endl<<"********* Processing event number: "<<event<<"*******\n";
47     esdTree->GetEvent(ievent);
48     AliESDfriend *fESDfriend =  (AliESDfriend*)cesd.FindListObject("AliESDfriend");
49     cesd.SetESDfriend(fESDfriend);
50     MakeESDTree(&cesd,cstream);
51   }
52 }
53
54
55 void MakeESDTree(AliESDEvent*esd, TTreeSRedirector &cstream){
56   //
57   //
58   //
59   Float_t bz = esd->GetMagneticField();
60   //AliTPCseed dummyTPC;
61   //AliTPCseed dummyTRD;
62   for (Int_t i=0;i<esd->GetNumberOfTracks(); i++){
63     AliESDtrack * track = esd->GetTrack(i);
64     if (!track) continue;
65     TPolyMarker3D polA;
66     TPolyMarker3D polV;
67     TPolyMarker3D polI;
68     TPolyMarker3D polO;
69     //
70     AliTrackPointArray * arrayA=0;
71     AliTrackPointArray * arrayV=0;
72     AliTrackPointArray * arrayI=0;
73     AliTrackPointArray * arrayO=0;
74     //
75     if (track->GetInnerParam()) {
76       ((AliExternalTrackParam*)track->GetInnerParam())->FillPolymarker(&polA,bz,0,350,1);}
77     else{
78       track->FillPolymarker(&polA,bz,0,300,5);
79     }
80     arrayA=MakeArray(&polA);
81     track->FillPolymarker(&polV,bz,0,60,1);
82     arrayV=MakeArray(&polV);
83     if (track->GetInnerParam()) {
84       ((AliExternalTrackParam*)track->GetInnerParam())->FillPolymarker(&polI,bz,60,170,1);
85       arrayI = MakeArray(&polI);
86     }
87     if (track->GetOuterParam()) {
88       ((AliExternalTrackParam*)track->GetOuterParam())->FillPolymarker(&polO,bz,170,350,1);    
89       arrayO=MakeArray(&polO);
90     }
91     static  AliTrackPointArray cldummy(5);
92     AliTrackPointArray *clarray= &cldummy;
93     const AliESDfriendTrack *ftrack = track->GetFriendTrack();
94     if (ftrack && ftrack->GetTrackPointArray()) {
95       clarray=(AliTrackPointArray *)ftrack->GetTrackPointArray();
96     }
97     Int_t event = esd->GetEventNumberInFile();
98     Int_t id = track->GetID();
99     cstream<<"Tracks"<<
100       "eventNr="<<event<<
101       "trackNr="<<id<<
102       "Tr.="<<track<<
103       "Cl.="<<clarray<<
104       //
105       "pA.="<<&polA<<
106       "pV.="<<&polV<<
107       "pI.="<<&polI<<
108       "pO.="<<&polO<<
109       //
110       "aA.="<<arrayA<<
111       "aV.="<<arrayV<<
112       "aI.="<<arrayI<<
113       "aO.="<<arrayO<<
114       "\n";
115   }
116 }
117
118
119
120 AliTrackPointArray *MakeArray(TPolyMarker3D *pol){
121   //
122   // Make a aray of  points with errors
123   //
124   Int_t entries = pol->GetN();
125   AliTrackPointArray * array = new AliTrackPointArray(entries);
126   for (Int_t i=0;i<entries;i++){
127     Double_t xyz[3]={0,0,0};
128     pol->GetPoint(i,xyz[0],xyz[1],xyz[2]);
129     ((Float_t*)array->GetX())[i]=xyz[0];
130     ((Float_t*)array->GetY())[i]=xyz[1];
131     ((Float_t*)array->GetZ())[i]=xyz[2];
132   }
133   return array;
134 }
135