]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/exa/Display.C
Moved this functionaly to a functio in AliL3Transform::MakeInitFile.
[u/mrichter/AliRoot.git] / HLT / exa / Display.C
1 // $Id$
2
3 /**
4    Displays tracks and clusters read from a file. 
5    Functionality is now in AliL3Display. See also the
6 */
7
8 void Display(char *trackfile=0,Bool_t rpoints = kFALSE,Bool_t tpoints = kTRUE,Char_t *gfile="/prog/alice/data/GEO/alice.geom")
9 {
10 //  gROOT->Reset();
11   Int_t minslice=0;
12   Int_t maxslice=35;
13   /*
14     Display tracks and clusters already written to file.
15   */
16   char fname[256];
17   UInt_t npp[36][6];
18   AliL3SpacePointData *ppp[36][6];
19   AliL3FileHandler *fff[36][6];
20   for(int s=minslice;s<=maxslice;s++){
21     for(int p=0;p<6;p++){
22       ppp[s][p]=0;
23       fff[s][p] = new AliL3FileHandler();
24       sprintf(fname,"points_%d_%d.raw",s,p);
25       if(!fff[s][p]->SetBinaryInput(fname)){
26         delete fff[s][p];
27         continue;
28       }
29       ppp[s][p] = (AliL3SpacePointData *)fff[s][p]->Allocate();
30       fff[s][p]->Binary2Memory(npp[s][p],ppp[s][p]);
31       fff[s][p]->CloseBinaryInput();
32       printf("%s: %d points\n",fname,npp[s][p]);
33     }
34   }
35   if(trackfile){
36     AliL3FileHandler *trackf  = new AliL3FileHandler();
37     if(!trackf->SetBinaryInput(trackfile)) return;
38     AliL3TrackArray *tracks= new AliL3TrackArray();
39     trackf->Binary2TrackArray(tracks);
40     trackf->CloseBinaryInput();
41     delete trackf;
42     printf("%s: %d tracks\n",trackfile,tracks->GetNPresent());
43   }
44
45   //display the event in 3D
46   TCanvas *c1 = new TCanvas("v1","",700,700);
47   TView *v = new TView(1);
48   v->SetRange(-430,-560,-430,430,560,1710);
49   //v->SetRange(0,0,-430,430,560,1710);
50   c1->Clear();
51   c1->SetFillColor(1);
52   c1->SetTheta(90.);
53   c1->SetPhi(0.);
54
55   if(rpoints){
56     for(Int_t s=0;s<36;s++){
57       for(int p=0;p<6;p++){
58         AliL3SpacePointData *points = ppp[s][p];
59         if(!points) continue;
60         int npoints = npp[s][p];
61         TPolyMarker3D *pm = new TPolyMarker3D(npoints);
62   
63         float xyz[3];
64         for(int i=0; i<npoints; i++){
65           xyz[0] = points[i].fX;
66           xyz[1] = points[i].fY;
67           xyz[2] = points[i].fZ;
68            
69           pm->SetPoint(i,xyz[0],xyz[1],xyz[2]); 
70           if(xyz[0]==0){
71             printf("%d %d %d %d\n",npoints,s,p,i);
72           }
73         }
74         pm->SetMarkerColor(2);
75         pm->Draw("");
76       }
77     }
78   }
79
80   if(trackfile)
81     {
82       int ntracks = tracks->GetNTracks();
83       TPolyLine3D *line = new TPolyLine3D[ntracks];
84       Float_t xcl[176];
85       Float_t ycl[176];
86       Float_t zcl[176];
87       
88       printf("ntracks %d\n",ntracks);
89       
90       for(int j=0; j<ntracks; j++)
91         {
92           AliL3Track *gtrack = tracks->GetCheckedTrack(j); 
93           if(!gtrack) continue;        
94           Int_t nHits = gtrack->GetNHits();
95           UInt_t *hitnum=gtrack->GetHitNumbers();
96           //printf("nhits %d\n",nHits);
97           if(nHits < 10) continue;
98           TPolyMarker3D *pm = new TPolyMarker3D(nHits);
99           for(int h=0; h<nHits; h++)
100             {
101               UInt_t id=hitnum[h];
102               Int_t slice = (id>>25) & 0x7f;
103               Int_t patch = (id>>22) & 0x7;
104               UInt_t pos = id&0x3fffff;       
105 //              printf("slice: %d patch: %d #%d \n",slice,patch,pos);
106
107               AliL3SpacePointData *points = ppp[slice][patch];
108
109               if(!points) {
110                 printf("*** No Points at slice: %d patch: %d #%d \n",
111                       slice,patch,pos);
112                 continue;
113               }
114               if(pos>=npp[slice][patch]) {printf("Error \n"); continue;}
115               //printf("hit %d %d\n",curclust->GetHitNumber(),id);
116               xcl[h] = points[pos].fX;
117               ycl[h] = points[pos].fY;
118               zcl[h] = points[pos].fZ;
119               pm->SetPoint(h,xcl[h],ycl[h],zcl[h]);
120             }
121           pm->SetMarkerColor(4);
122           if(tpoints) pm->Draw();
123           TPolyLine3D *current_line = &(line[j]);
124           current_line = new TPolyLine3D(nHits,xcl,ycl,zcl,"");
125           
126           current_line->SetLineColor(4);
127           current_line->Draw("same");
128         }
129     }
130
131   TFile *geofile = new TFile(gfile,"READ");  
132   TGeometry *geom=(TGeometry*)geofile->Get("AliceGeom");
133   geom->Draw("same");
134   
135   c1->cd();
136   
137     c1->x3d();
138   // c1->Modified();
139   //c1->Update();
140   
141   return;
142 }