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