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