]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/src/AliL3Display.cxx
Updates to aliroot V3.06
[u/mrichter/AliRoot.git] / HLT / src / AliL3Display.cxx
1 //Author:        Anders Strand Vestbo
2 //Last Modified: 12.01.2001
3
4 #include <TCanvas.h>
5 #include <TView.h>
6 #include <TPolyMarker3D.h>
7 #include <TPolyLine3D.h>
8 #include <TH2.h>
9 #include <TTree.h>
10 #include <TNode.h>
11 #include <TGeometry.h>
12 #include <TShape.h>
13 #include <TParticle.h>
14
15 #include "AliL3Evaluate.h"
16 #include "AliRun.h"
17 #include "AliSimDigits.h"
18 #include "AliTPCParam.h"
19 #include "AliL3Transform.h"
20 #include "AliL3Track.h"
21 #include "AliL3TrackArray.h"
22 #include "AliL3SpacePointData.h"
23 #include "AliL3FileHandler.h"
24 #include "AliL3Logging.h"
25 #include "AliL3Display.h"
26
27 // AliL3Display
28 // Simple display class for the Level3 tracker.
29
30 ClassImp(AliL3Display)
31
32 AliL3Display::AliL3Display()
33 {
34   fGeom = NULL;
35   fTracks = NULL;
36 }
37
38 AliL3Display::AliL3Display(Int_t *slice)
39 {
40   //Ctor. Specify which slices you want to look at.
41
42   TFile *file = new TFile("/prog/alice/data/GEO/alice.geom");
43   if(!file) printf("NO FILE\n");
44   if(!file->IsOpen())
45     LOG(AliL3Log::kError,"AliL3Display::AliL3Display","File Open")
46       <<"Geometry file alice.geom does not exist"<<ENDLOG;
47   
48   fGeom = (TGeometry*)file->Get("AliceGeom");
49   fMinSlice = slice[0];
50   fMaxSlice = slice[1];
51
52   fTransform = new AliL3Transform();
53   file->Close();
54   delete file;
55 }
56
57 AliL3Display::~AliL3Display()
58 {
59
60   if(fTracks)
61     delete fTracks;
62   if(fTransform)
63     delete fTransform;
64 }
65
66 void AliL3Display::Setup(Char_t *trackfile,Char_t *path)
67 {
68   //Read in the hit and track information from produced files.
69   
70   Char_t fname[256];
71   AliL3FileHandler *clusterfile[36][6];
72   for(Int_t s=fMinSlice; s<=fMaxSlice; s++)
73     {
74       for(Int_t p=0; p<6; p++)
75         {
76           clusterfile[s][p] = new AliL3FileHandler();
77           sprintf(fname,"%spoints_%d_%d.raw",path,s,p);
78           if(!clusterfile[s][p]->SetBinaryInput(fname))
79             {
80               LOG(AliL3Log::kError,"AliL3Evaluation::Setup","File Open")
81                 <<"Inputfile "<<fname<<" does not exist"<<ENDLOG; 
82               delete clusterfile[s][p];
83               clusterfile[s][p] = 0; 
84               continue;
85             }
86           fClusters[s][p] = (AliL3SpacePointData*)clusterfile[s][p]->Allocate();
87           clusterfile[s][p]->Binary2Memory(fNcl[s][p],fClusters[s][p]);
88           clusterfile[s][p]->CloseBinaryInput();
89         }
90     }
91   
92   
93   AliL3FileHandler *tfile = new AliL3FileHandler();
94   if(!tfile->SetBinaryInput(trackfile))
95     {
96       LOG(AliL3Log::kError,"AliL3Evaluation::Setup","File Open")
97         <<"Inputfile "<<trackfile<<" does not exist"<<ENDLOG; 
98       return;
99     }
100   fTracks = new AliL3TrackArray();
101   tfile->Binary2TrackArray(fTracks);
102   tfile->CloseBinaryInput();
103   delete tfile;
104
105 }
106
107 void AliL3Display::DisplayTracks(Int_t min_hits)
108 {
109   //Display the found tracks.
110
111   TCanvas *c1 = new TCanvas("c1","",700,700);
112   c1->cd();
113   
114   TView *v = new TView(1);
115   v->SetRange(-430,-560,-430,430,560,1710);
116   
117   c1->Clear();
118   c1->SetFillColor(1);
119   c1->SetTheta(90.);
120   c1->SetPhi(0.);
121     
122   Int_t ntracks = fTracks->GetNTracks();
123   TPolyLine3D *line = new TPolyLine3D[ntracks];
124   Float_t xcl[176];
125   Float_t ycl[176];
126   Float_t zcl[176];
127   
128   for(Int_t j=0; j<ntracks; j++)
129     {
130       AliL3Track *gtrack = fTracks->GetCheckedTrack(j); 
131       if(!gtrack) continue;        
132       Int_t nHits = gtrack->GetNHits();
133       UInt_t *hitnum = gtrack->GetHitNumbers();
134       if(nHits < min_hits) continue;
135       TPolyMarker3D *pm = new TPolyMarker3D(nHits);
136       
137       for(Int_t h=0; h<nHits; h++)
138         {
139           UInt_t id=hitnum[h];
140           Int_t slice = (id>>25) & 0x7f;
141           Int_t patch = (id>>22) & 0x7;
142           UInt_t pos = id&0x3fffff;           
143           AliL3SpacePointData *points = fClusters[slice][patch];
144           if(slice < fMinSlice || slice > fMaxSlice)
145             continue;
146
147           if(!points) {
148             LOG(AliL3Log::kError,"AliL3Display::DisplayTracks","Clusterarray")
149               <<"No points at slice "<<slice<<" patch "<<patch<<" pos "<<pos<<ENDLOG;
150             continue;
151           }
152           if(pos>=fNcl[slice][patch]) {printf("Error \n"); continue;}
153           Float_t xyz_tmp[3];
154           xyz_tmp[0] = points[pos].fX;
155           xyz_tmp[1] = points[pos].fY;
156           xyz_tmp[2] = points[pos].fZ;
157                   
158           xcl[h] = xyz_tmp[0];
159           ycl[h] = xyz_tmp[1];
160           zcl[h] = xyz_tmp[2];
161           
162           pm->SetPoint(h,xcl[h],ycl[h],zcl[h]);
163         }
164       pm->SetMarkerColor(2);
165       pm->Draw();
166       TPolyLine3D *current_line = &(line[j]);
167       current_line = new TPolyLine3D(nHits,xcl,ycl,zcl,"");
168       
169       current_line->SetLineColor(1);
170       current_line->Draw("same");
171             
172     }
173   
174   /*Take this if you want black&white display for printing.
175     Char_t fname[256];
176     Int_t i;
177     Int_t color = 1;
178     for(i=0; i<10; i++)
179     {
180     sprintf(fname,"LS0%d",i);
181     geom->GetNode(fname)->SetLineColor(color);
182     sprintf(fname,"US0%d",i);
183     geom->GetNode(fname)->SetLineColor(color);
184     }
185     for(i=10; i<18; i++)
186     {
187     sprintf(fname,"LS%d",i);
188     geom->GetNode(fname)->SetLineColor(color);
189     sprintf(fname,"US%d",i);
190     geom->GetNode(fname)->SetLineColor(color);
191     }
192   */
193   fGeom->Draw("same");
194   
195   c1->x3d();
196   
197 }
198
199 void AliL3Display::DisplayClusters()
200 {
201   //Display all clusters.
202   
203   TCanvas *c1 = new TCanvas("c1","",700,700);
204   c1->cd();
205   TView *v = new TView(1);
206   v->SetRange(-430,-560,-430,430,560,1710);
207   c1->Clear();
208   c1->SetFillColor(1);
209   c1->SetTheta(90.);
210   c1->SetPhi(0.);
211   
212   for(Int_t s=fMinSlice; s<=fMaxSlice; s++)
213     {
214       for(Int_t p=0;p<6;p++)
215         {
216           AliL3SpacePointData *points = fClusters[s][p];
217           if(!points) continue;
218           Int_t npoints = fNcl[s][p];
219           TPolyMarker3D *pm = new TPolyMarker3D(npoints);
220           
221           Float_t xyz[3];
222           for(Int_t i=0; i<npoints; i++)
223             {
224               
225               xyz[0] = points[i].fX;
226               xyz[1] = points[i].fY;
227               xyz[2] = points[i].fZ;
228               
229               pm->SetPoint(i,xyz[0],xyz[1],xyz[2]); 
230               
231             }
232           pm->SetMarkerColor(2);
233           pm->Draw("");
234         }
235     }
236   fGeom->Draw("same");
237   
238   c1->x3d(); 
239 }
240
241
242 void AliL3Display::DisplayAll(Int_t min_hits)
243 {
244   //Display tracks & all hits.
245
246   
247   TCanvas *c1 = new TCanvas("c1","",700,700);
248   c1->cd();
249   TView *v = new TView(1);
250   v->SetRange(-430,-560,-430,430,560,1710);
251   c1->Clear();
252   c1->SetFillColor(1);
253   c1->SetTheta(90.);
254   c1->SetPhi(0.);
255   
256   for(Int_t s=fMinSlice; s<=fMaxSlice; s++)
257     {
258       for(Int_t p=0;p<1;p++)
259         {
260           AliL3SpacePointData *points = fClusters[s][p];
261           if(!points) continue;
262           Int_t npoints = fNcl[s][p];
263           TPolyMarker3D *pm = new TPolyMarker3D(npoints);
264           
265           Float_t xyz[3];
266           for(Int_t i=0; i<npoints; i++){
267             xyz[0] = points[i].fX;
268             xyz[1] = points[i].fY;
269             xyz[2] = points[i].fZ;
270             
271             pm->SetPoint(i,xyz[0],xyz[1],xyz[2]); 
272             
273           }
274           pm->SetMarkerColor(2);
275           pm->Draw("");
276         }
277     }
278   
279   Int_t ntracks = fTracks->GetNTracks();
280   TPolyLine3D *line = new TPolyLine3D[ntracks];
281   Float_t xcl[176];
282   Float_t ycl[176];
283   Float_t zcl[176];
284   
285   
286   for(Int_t j=0; j<ntracks; j++)
287     {
288       AliL3Track *gtrack = fTracks->GetCheckedTrack(j); 
289       if(!gtrack) continue;        
290       Int_t nHits = gtrack->GetNHits();
291       UInt_t *hitnum = gtrack->GetHitNumbers();
292       if(nHits < min_hits) continue;
293       TPolyMarker3D *pm = new TPolyMarker3D(nHits);
294       for(Int_t h=0; h<nHits; h++)
295         {
296           UInt_t id=hitnum[h];
297           Int_t slice = (id>>25) & 0x7f;
298           Int_t patch = (id>>22) & 0x7;
299           UInt_t pos = id&0x3fffff;           
300           
301           AliL3SpacePointData *points = fClusters[slice][patch];
302
303           if(!points) {
304             LOG(AliL3Log::kError,"AliL3Display::DisplayTracks","Clusterarray")
305               <<"No points at slice "<<slice<<" patch "<<patch<<" pos "<<pos<<ENDLOG;
306             continue;
307           }
308           if(pos>=fNcl[slice][patch]) {printf("Error \n"); continue;}
309           xcl[h] = points[pos].fX;
310           ycl[h] = points[pos].fY;
311           zcl[h] = points[pos].fZ;
312           pm->SetPoint(h,xcl[h],ycl[h],zcl[h]);
313         }
314       pm->SetMarkerColor(3);
315       pm->Draw();
316       TPolyLine3D *current_line = &(line[j]);
317       current_line = new TPolyLine3D(nHits,xcl,ycl,zcl,"");
318       
319       current_line->SetLineColor(4);
320       current_line->Draw("same");
321     }
322
323   fGeom->Draw("same");
324   
325   c1->x3d();
326   
327 }
328
329 void AliL3Display::DisplayClusterRow(Int_t slice,Int_t padrow,Char_t *digitsFile,Char_t *type)
330 {
331   //Display the found clusters on this row together with the raw data.
332   
333   
334   TFile *file = new TFile(digitsFile);
335   AliTPCParam *param = (AliTPCParam*)file->Get("75x40_100x60");
336   TTree *TD=(TTree*)file->Get("TreeD_75x40_100x60_0");
337   AliSimDigits da, *digits=&da;
338   TD->GetBranch("Segment")->SetAddress(&digits); //Return pointer to branch segment.
339   AliL3Transform *transform = new AliL3Transform();
340   
341   Int_t sector,row;
342   transform->Slice2Sector(slice,padrow,sector,row);
343   Int_t npads = param->GetNPads(sector,row);
344   Int_t ntimes = param->GetMaxTBin();
345   TH2F *histdig = new TH2F("histdig","",npads,0,npads-1,ntimes,0,ntimes-1);
346   TH2F *histfast = new TH2F("histfast","",npads,0,npads-1,ntimes,0,ntimes-1);
347   TH2F *histpart = new TH2F("histpart","",npads,0,npads-1,ntimes,0,ntimes-1);
348
349   
350   Int_t sectors_by_rows=(Int_t)TD->GetEntries();
351   Int_t i;
352   for (i=0; i<sectors_by_rows; i++) {
353     if (!TD->GetEvent(i)) continue;
354     Int_t sec,ro;
355     param->AdjustSectorRow(digits->GetID(),sec,ro);
356     
357     if(sec != sector) continue;
358     if(ro < row) continue;
359     if(ro != row) break;
360     printf("sector %d row %d\n",sec,ro);
361     digits->First();
362     while (digits->Next()) {
363       Int_t it=digits->CurrentRow(), ip=digits->CurrentColumn();
364       Short_t dig = digits->GetDigit(it,ip);
365       if(dig<=param->GetZeroSup()) continue;
366       /*
367       if(it < param->GetMaxTBin()-1 && it > 0)
368         if(digits->GetDigit(it+1,ip) <= param->GetZeroSup()
369            && digits->GetDigit(it-1,ip) <= param->GetZeroSup())
370           continue;
371       */
372       histdig->Fill(ip,it,dig);
373     }
374   }
375   
376   /*file->cd();
377   AliRun *gAlice = (AliRun*)file->Get("gAlice");
378   gAlice->GetEvent(0);
379   TClonesArray *fParticles=gAlice->Particles(); 
380   TParticle *part = (TParticle*)fParticles->UncheckedAt(0);
381   AliL3Evaluate *eval = new AliL3Evaluate();
382   Float_t xyz_cross[3];
383   */
384   
385   for(Int_t p=0;p<6;p++)
386     {
387       AliL3SpacePointData *points = fClusters[slice][p];
388       if(!points) continue;
389       
390       Int_t npoints = fNcl[slice][p];     
391       Float_t xyz[3];
392       for(Int_t i=0; i<npoints; i++)
393         {
394           if(points[i].fPadRow != padrow) continue;
395           xyz[0] = points[i].fX;
396           xyz[1] = points[i].fY;
397           xyz[2] = points[i].fZ;
398           transform->Global2Raw(xyz,sector,row);
399           histfast->Fill(xyz[1],xyz[2],1);
400           
401           
402         }
403       
404     }
405   
406   TCanvas *c1 = new TCanvas("c1","",900,900);
407   c1->cd();
408   histdig->Draw();
409   histfast->SetMarkerColor(2);
410   histfast->SetMarkerStyle(4);
411   histpart->SetMarkerColor(2);
412   histpart->SetMarkerStyle(3);
413
414   histdig->GetXaxis()->SetTitle("Pad #");
415   histdig->GetYaxis()->SetTitle("Timebin #");
416   histdig->Draw(type);
417   histfast->Draw("psame");
418   //histpart->Draw("psame");
419 }