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