3 // Author: Anders Vestbo <mailto:vestbo@fi.uib.no>
4 //*-- Copyright © ASV
8 #include <TPolyMarker3D.h>
9 #include <TPolyLine3D.h>
13 #include <TGeometry.h>
15 #include <TParticle.h>
18 #include "AliL3Display.h"
21 #include "AliSimDigits.h"
22 #include "AliTPCParam.h"
24 #include "AliL3Transform.h"
25 #include "AliL3Track.h"
26 #include "AliL3TrackArray.h"
27 #include "AliL3SpacePointData.h"
28 #include "AliL3MemHandler.h"
29 #include "AliL3Logging.h"
32 //_____________________________________________________________
35 // Simple display class for the Level3 tracker.
37 ClassImp(AliL3Display)
39 AliL3Display::AliL3Display()
45 AliL3Display::AliL3Display(Int_t *slice)
47 //Ctor. Specify which slices you want to look at.
49 TFile *file = new TFile("/prog/alice/data/GEO/alice.geom");
50 if(!file) printf("NO FILE\n");
52 LOG(AliL3Log::kError,"AliL3Display::AliL3Display","File Open")
53 <<"Geometry file alice.geom does not exist"<<ENDLOG;
55 fGeom = (TGeometry*)file->Get("AliceGeom");
59 fTransform = new AliL3Transform();
64 AliL3Display::~AliL3Display()
73 void AliL3Display::Setup(Char_t *trackfile,Char_t *path)
75 //Read in the hit and track information from produced files.
78 AliL3MemHandler *clusterfile[36][6];
79 for(Int_t s=fMinSlice; s<=fMaxSlice; s++)
81 for(Int_t p=0; p<6; p++)
83 clusterfile[s][p] = new AliL3MemHandler();
84 sprintf(fname,"%spoints_%d_%d.raw",path,s,p);
85 if(!clusterfile[s][p]->SetBinaryInput(fname))
87 LOG(AliL3Log::kError,"AliL3Evaluation::Setup","File Open")
88 <<"Inputfile "<<fname<<" does not exist"<<ENDLOG;
89 delete clusterfile[s][p];
90 clusterfile[s][p] = 0;
93 fClusters[s][p] = (AliL3SpacePointData*)clusterfile[s][p]->Allocate();
94 clusterfile[s][p]->Binary2Memory(fNcl[s][p],fClusters[s][p]);
95 clusterfile[s][p]->CloseBinaryInput();
100 AliL3MemHandler *tfile = new AliL3MemHandler();
101 if(!tfile->SetBinaryInput(trackfile))
103 LOG(AliL3Log::kError,"AliL3Evaluation::Setup","File Open")
104 <<"Inputfile "<<trackfile<<" does not exist"<<ENDLOG;
107 fTracks = new AliL3TrackArray();
108 tfile->Binary2TrackArray(fTracks);
109 tfile->CloseBinaryInput();
114 void AliL3Display::DisplayTracks(Int_t min_hits)
116 //Display the found tracks.
118 TCanvas *c1 = new TCanvas("c1","",700,700);
121 TView *v = new TView(1);
122 v->SetRange(-430,-560,-430,430,560,1710);
129 Int_t ntracks = fTracks->GetNTracks();
130 TPolyLine3D *line = new TPolyLine3D[ntracks];
135 for(Int_t j=0; j<ntracks; j++)
137 AliL3Track *gtrack = fTracks->GetCheckedTrack(j);
138 if(!gtrack) continue;
139 Int_t nHits = gtrack->GetNHits();
140 UInt_t *hitnum = gtrack->GetHitNumbers();
141 if(nHits < min_hits) continue;
142 TPolyMarker3D *pm = new TPolyMarker3D(nHits);
144 for(Int_t h=0; h<nHits; h++)
147 Int_t slice = (id>>25) & 0x7f;
148 Int_t patch = (id>>22) & 0x7;
149 UInt_t pos = id&0x3fffff;
150 AliL3SpacePointData *points = fClusters[slice][patch];
151 if(slice < fMinSlice || slice > fMaxSlice)
155 LOG(AliL3Log::kError,"AliL3Display::DisplayTracks","Clusterarray")
156 <<"No points at slice "<<slice<<" patch "<<patch<<" pos "<<pos<<ENDLOG;
159 if(pos>=fNcl[slice][patch]) {printf("Error \n"); continue;}
161 xyz_tmp[0] = points[pos].fX;
162 xyz_tmp[1] = points[pos].fY;
163 xyz_tmp[2] = points[pos].fZ;
169 pm->SetPoint(h,xcl[h],ycl[h],zcl[h]);
172 if(hitcount==0) continue;
173 pm->SetMarkerColor(2);
175 TPolyLine3D *current_line = &(line[j]);
176 current_line = new TPolyLine3D(nHits,xcl,ycl,zcl,"");
178 current_line->SetLineColor(4);
179 current_line->Draw("same");
183 //Take this if you want black&white display for printing.
187 c1->SetFillColor(10);
190 sprintf(fname,"LS0%d",i);
191 fGeom->GetNode(fname)->SetLineColor(color);
192 sprintf(fname,"US0%d",i);
193 fGeom->GetNode(fname)->SetLineColor(color);
197 sprintf(fname,"LS%d",i);
198 fGeom->GetNode(fname)->SetLineColor(color);
199 sprintf(fname,"US%d",i);
200 fGeom->GetNode(fname)->SetLineColor(color);
209 void AliL3Display::DisplayClusters()
211 //Display all clusters.
213 TCanvas *c1 = new TCanvas("c1","",700,700);
215 TView *v = new TView(1);
216 v->SetRange(-430,-560,-430,430,560,1710);
222 for(Int_t s=fMinSlice; s<=fMaxSlice; s++)
224 for(Int_t p=0;p<6;p++)
226 AliL3SpacePointData *points = fClusters[s][p];
227 if(!points) continue;
228 Int_t npoints = fNcl[s][p];
229 TPolyMarker3D *pm = new TPolyMarker3D(npoints);
232 for(Int_t i=0; i<npoints; i++)
235 xyz[0] = points[i].fX;
236 xyz[1] = points[i].fY;
237 xyz[2] = points[i].fZ;
239 pm->SetPoint(i,xyz[0],xyz[1],xyz[2]);
242 pm->SetMarkerColor(2);
252 void AliL3Display::DisplayAll(Int_t min_hits)
254 //Display tracks & all hits.
257 TCanvas *c1 = new TCanvas("c1","",700,700);
259 TView *v = new TView(1);
260 v->SetRange(-430,-560,-430,430,560,1710);
266 for(Int_t s=fMinSlice; s<=fMaxSlice; s++)
268 for(Int_t p=0;p<6;p++)
270 AliL3SpacePointData *points = fClusters[s][p];
271 if(!points) continue;
272 Int_t npoints = fNcl[s][p];
273 TPolyMarker3D *pm = new TPolyMarker3D(npoints);
276 for(Int_t i=0; i<npoints; i++){
277 xyz[0] = points[i].fX;
278 xyz[1] = points[i].fY;
279 xyz[2] = points[i].fZ;
281 pm->SetPoint(i,xyz[0],xyz[1],xyz[2]);
284 pm->SetMarkerColor(2);
289 Int_t ntracks = fTracks->GetNTracks();
290 TPolyLine3D *line = new TPolyLine3D[ntracks];
296 for(Int_t j=0; j<ntracks; j++)
298 AliL3Track *gtrack = fTracks->GetCheckedTrack(j);
299 if(!gtrack) continue;
300 Int_t nHits = gtrack->GetNHits();
301 UInt_t *hitnum = gtrack->GetHitNumbers();
302 if(nHits < min_hits) continue;
303 TPolyMarker3D *pm = new TPolyMarker3D(nHits);
305 for(Int_t h=0; h<nHits; h++)
308 Int_t slice = (id>>25) & 0x7f;
309 Int_t patch = (id>>22) & 0x7;
310 UInt_t pos = id&0x3fffff;
311 if(slice < fMinSlice || slice > fMaxSlice)
314 AliL3SpacePointData *points = fClusters[slice][patch];
316 LOG(AliL3Log::kError,"AliL3Display::DisplayTracks","Clusterarray")
317 <<"No points at slice "<<slice<<" patch "<<patch<<" pos "<<pos<<ENDLOG;
320 if(pos>=fNcl[slice][patch]) {printf("Error \n"); continue;}
321 xcl[h] = points[pos].fX;
322 ycl[h] = points[pos].fY;
323 zcl[h] = points[pos].fZ;
324 pm->SetPoint(h,xcl[h],ycl[h],zcl[h]);
327 if(hitcount==0) continue;
328 pm->SetMarkerColor(3);
330 TPolyLine3D *current_line = &(line[j]);
331 current_line = new TPolyLine3D(nHits,xcl,ycl,zcl,"");
332 current_line->SetLineColor(4);
333 current_line->SetLineWidth(2);
334 current_line->Draw("same");
341 c1->SetFillColor(10);
344 sprintf(fname,"LS0%d",i);
345 fGeom->GetNode(fname)->SetLineColor(color);
346 sprintf(fname,"US0%d",i);
347 fGeom->GetNode(fname)->SetLineColor(color);
351 sprintf(fname,"LS%d",i);
352 fGeom->GetNode(fname)->SetLineColor(color);
353 sprintf(fname,"US%d",i);
354 fGeom->GetNode(fname)->SetLineColor(color);
364 void AliL3Display::DisplayClusterRow(Int_t slice,Int_t padrow,Char_t *digitsFile,Char_t *type)
366 //Display the found clusters on this row together with the raw data.
369 TFile *file = new TFile(digitsFile);
370 AliTPCParam *param = (AliTPCParam*)file->Get("75x40_100x60");
371 TTree *TD=(TTree*)file->Get("TreeD_75x40_100x60_0");
372 AliSimDigits da, *digits=&da;
373 TD->GetBranch("Segment")->SetAddress(&digits); //Return pointer to branch segment.
374 AliL3Transform *transform = new AliL3Transform();
377 transform->Slice2Sector(slice,padrow,sector,row);
378 Int_t npads = param->GetNPads(sector,row);
379 Int_t ntimes = param->GetMaxTBin();
380 TH2F *histdig = new TH2F("histdig","",npads,0,npads-1,ntimes,0,ntimes-1);
381 TH2F *histfast = new TH2F("histfast","",npads,0,npads-1,ntimes,0,ntimes-1);
382 TH2F *histpart = new TH2F("histpart","",npads,0,npads-1,ntimes,0,ntimes-1);
385 Int_t sectors_by_rows=(Int_t)TD->GetEntries();
387 for (i=0; i<sectors_by_rows; i++) {
388 if (!TD->GetEvent(i)) continue;
390 param->AdjustSectorRow(digits->GetID(),sec,ro);
392 if(sec != sector) continue;
393 if(ro < row) continue;
395 printf("sector %d row %d\n",sec,ro);
397 while (digits->Next()) {
398 Int_t it=digits->CurrentRow(), ip=digits->CurrentColumn();
399 Short_t dig = digits->GetDigit(it,ip);
400 if(dig<=param->GetZeroSup()) continue;
402 if(it < param->GetMaxTBin()-1 && it > 0)
403 if(digits->GetDigit(it+1,ip) <= param->GetZeroSup()
404 && digits->GetDigit(it-1,ip) <= param->GetZeroSup())
407 histdig->Fill(ip,it,dig);
412 AliRun *gAlice = (AliRun*)file->Get("gAlice");
414 TClonesArray *fParticles=gAlice->Particles();
415 TParticle *part = (TParticle*)fParticles->UncheckedAt(0);
416 AliL3Evaluate *eval = new AliL3Evaluate();
417 Float_t xyz_cross[3];
420 for(Int_t p=0;p<6;p++)
422 AliL3SpacePointData *points = fClusters[slice][p];
423 if(!points) continue;
425 Int_t npoints = fNcl[slice][p];
427 for(Int_t i=0; i<npoints; i++)
429 if(points[i].fPadRow != padrow) continue;
430 xyz[0] = points[i].fX;
431 xyz[1] = points[i].fY;
432 xyz[2] = points[i].fZ;
433 transform->Global2Raw(xyz,sector,row);
434 histfast->Fill(xyz[1],xyz[2],1);
441 TCanvas *c1 = new TCanvas("c1","",900,900);
444 histfast->SetMarkerColor(2);
445 histfast->SetMarkerStyle(4);
446 histpart->SetMarkerColor(2);
447 histpart->SetMarkerStyle(3);
449 histdig->GetXaxis()->SetTitle("Pad #");
450 histdig->GetYaxis()->SetTitle("Timebin #");
452 histfast->Draw("psame");
453 //histpart->Draw("psame");