Change AliTRDdataArrayI to AliTRDdataArray in MakeBranch()
[u/mrichter/AliRoot.git] / TRD / TrackDisplay.C
CommitLineData
46d29e70 1void TrackDisplay(Int_t track) {
2
3 c1 = new TCanvas( "RecPoints", "RecPoints Display", 10, 10, 710, 740);
4 c1->SetFillColor(1);
5 TView *v=new TView(1);
6
7 v->SetRange(-350.,-350.,-400.,350.,350.,400.); // full
8 // v->SetRange(0.,0.,0.,350.,350.,400.); // top right
9 // v->SetRange(-350.,0.,0.,0.,350.,400.); // top left
10 // v->SetRange(0.,-350.,0.,350.,0.,400.); // bottom right
11 // v->SetRange(-350.,-350.,0.,0.,0.,400.); // bottom left
12 // v->Side();
13 v->Top();
14 cerr<<"psi = "<<v->GetPsi()<<endl;
15
16 // Dynamically link some shared libs
17 if (gClassTable->GetID("AliRun") < 0) {
18 gROOT->LoadMacro("loadlibs.C");
19 loadlibs();
20 cout << "Loaded shared libraries" << endl;
21 }
22
23
24// Load tracks
25
26 TFile *tf=TFile::Open("AliTRDtracks.root");
27 if (!tf->IsOpen()) {cerr<<"Can't open AliTRDtracks.root !\n"; return 3;}
28 TObjArray tarray(2000);
29 TTree *tracktree=(TTree*)tf->Get("TreeT");
30 TBranch *tbranch=tracktree->GetBranch("tracks");
31 Int_t nentr=tracktree->GetEntries();
32 cerr<<"Found "<<nentr<<" entries in the track tree"<<endl;
33 for (Int_t i=0; i<nentr; i++) {
34 AliTRDtrack *iotrack=new AliTRDtrack;
35 tbranch->SetAddress(&iotrack);
36 tracktree->GetEvent(i);
37 tarray.AddLast(iotrack);
38 cerr<<"got track "<<i<<": index ="<<iotrack->GetLabel()<<endl;
39 }
40 tf->Close();
41
42
43 // Load clusters
44 Char_t *alifile = "AliTRDclusters.root";
45 Int_t nEvent = 0;
46 TObjArray rparray(2000);
47 TObjArray *RecPointsArray = &rparray;
48 AliTRDtracker *Tracker = new AliTRDtracker("dummy","dummy");
49 Tracker->ReadClusters(RecPointsArray,alifile,nEvent,-1);
50 Int_t nRecPoints = RecPointsArray->GetEntriesFast();
51 cerr<<"Found "<<nRecPoints<<" rec. points"<<endl;
52
53
54 // Connect the AliRoot file containing Geometry, Kine, Hits, and Digits
55 TFile *gafl = (TFile*) gROOT->GetListOfFiles()->FindObject(alifile);
56 if (!gafl) {
57 cout << "Open the ALIROOT-file " << alifile << endl;
58 gafl = new TFile(alifile);
59 }
60 else {
61 cout << alifile << " is already open" << endl;
62 }
63
64 // Get AliRun object from file or create it if not on file
65 gAlice = (AliRun*) gafl->Get("gAlice");
66 if (gAlice)
67 cout << "AliRun object found on file" << endl;
68 else
69 gAlice = new AliRun("gAlice","Alice test program");
70
71
72 AliTRDv1 *TRD = (AliTRDv1*) gAlice->GetDetector("TRD");
73 AliTRDgeometry *fGeom = TRD->GetGeometry();
74
75 Int_t i,j,index,det,sector, ti[3];
76 Double_t x,y,z, cs,sn,tmp;
77 Float_t global[3], local[3];
78
79 // Display all TRD RecPoints
80 TPolyMarker3D *pm = new TPolyMarker3D(nRecPoints);
81
82 for (Int_t i = 0; i < nRecPoints; i++) {
83 printf("\r point %d out of %d",i,nRecPoints);
84 AliTRDrecPoint *rp = (AliTRDrecPoint *) RecPointsArray->UncheckedAt(i);
85
86 local[0]=rp->GetLocalRow();
87 local[1]=rp->GetLocalCol();
88 local[2]=rp->GetLocalTime();
89 det=rp->GetDetector();
90
91 for (j = 0; j < 3; j++) { ti[j] = rp->GetTrackIndex(j); }
92
93 if((track < 0) ||
94 ((ti[0]==track)||(ti[1]==track)||(ti[2]==track))) {
95
96 if(fGeom->Local2Global(det,local,global)) {
97 x=global[0]; y=global[1]; z=global[2];
98 pm->SetPoint(i,x,y,z);
99 }
100 }
101 }
102
103 pm->SetMarkerSize(1); pm->SetMarkerColor(10); pm->SetMarkerStyle(1);
104 pm->Draw();
105
106
107 Int_t ntracks = tarray.GetEntriesFast();
108
109 for (i = 0; i < ntracks; i++) {
110 AliTRDtrack *pt = (AliTRDtrack *) tarray.UncheckedAt(i), &t=*pt;
111 Int_t nclusters = t.GetNclusters();
112 cerr<<"in track "<<i<<" found "<<nclusters<<" clusters"<<endl;
113
114 TPolyMarker3D *pm = new TPolyMarker3D(nclusters);
115 for(j = 0; j < nclusters; j++) {
116 index = t.GetClusterIndex(j);
117 AliTRDrecPoint *rp = (AliTRDrecPoint *) RecPointsArray->UncheckedAt(index);
118 local[0]=rp->GetLocalRow();
119 local[1]=rp->GetLocalCol();
120 local[2]=rp->GetLocalTime();
121 det=rp->GetDetector();
122
123 if(fGeom->Local2Global(det,local,global)) {
124 x=global[0]; y=global[1]; z=global[2];
125 pm->SetPoint(j,x,y,z);
126 }
127 }
128 pm->SetMarkerSize(1); pm->SetMarkerColor(i%6+3); pm->SetMarkerStyle(1);
129 pm->Draw();
130 }
131
132 TGeometry *geom=(TGeometry*)gafl->Get("AliceGeom");
133 geom->Draw("same");
134
135 c1->Modified();
136
137 c1->Update();
138
139 gafl->Close();
140
141}