]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/src/AliHLTDisplay.cxx
L3 becomes HLT
[u/mrichter/AliRoot.git] / HLT / src / AliHLTDisplay.cxx
CommitLineData
3e87ef69 1// @(#) $Id$
a3039c91 2
4aa41877 3/** \class AliHLTDisplay
c3d96f5a 4<pre>
5//_____________________________________________________________
4aa41877 6// AliHLTDisplay
c3d96f5a 7//
8// Simple display class for the HLT tracks.
9</pre>
10*/
b661165c 11// Author: Anders Vestbo <mailto:vestbo@fi.uib.no>
3e87ef69 12//*-- Copyright &copy ALICE HLT Group
108615fc 13
4aa41877 14#include "AliHLTStandardIncludes.h"
108615fc 15#include <TCanvas.h>
16#include <TView.h>
17#include <TPolyMarker3D.h>
18#include <TPolyLine3D.h>
19#include <TH2.h>
20#include <TTree.h>
7d3726a4 21#include <TNode.h>
22#include <TGeometry.h>
23#include <TShape.h>
4e03c52a 24#include <TParticle.h>
95a00d93 25#include <TFile.h>
5e0f9911 26#ifdef use_aliroot
27#include <TClonesArray.h>
28#include <AliRun.h>
29#include <AliSimDigits.h>
30#include <AliTPCParam.h>
31#endif
108615fc 32
4aa41877 33#include "AliHLTLogging.h"
34#include "AliHLTDisplay.h"
35#include "AliHLTTransform.h"
36#include "AliHLTTrack.h"
37#include "AliHLTTrackArray.h"
38#include "AliHLTSpacePointData.h"
39#include "AliHLTMemHandler.h"
95a00d93 40
5929c18d 41#if __GNUC__ >= 3
118c26c3 42using namespace std;
43#endif
108615fc 44
108615fc 45
4aa41877 46ClassImp(AliHLTDisplay)
108615fc 47
4aa41877 48AliHLTDisplay::AliHLTDisplay()
108615fc 49{
b1ed0288 50 //constructor
108615fc 51 fGeom = NULL;
52 fTracks = NULL;
53}
54
4aa41877 55AliHLTDisplay::AliHLTDisplay(Int_t *slice,Char_t *gfile)
108615fc 56{
c3d96f5a 57 //ctor. Specify which slices you want to look at.
0a86fbb7 58 TFile *file = TFile::Open(gfile);
59 if(!file)
60 {
4aa41877 61 LOG(AliHLTLog::kError,"AliHLTDisplay::AliHLTDisplay","File Open")
0a86fbb7 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
4aa41877 74AliHLTDisplay::~AliHLTDisplay()
108615fc 75{
b1ed0288 76 //destructor
108615fc 77 if(fTracks)
78 delete fTracks;
108615fc 79}
80
4aa41877 81void AliHLTDisplay::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];
4aa41877 86 AliHLTMemHandler *clusterfile[36][6];
87 memset(fClusters,0,36*6*sizeof(AliHLTSpacePointData*));
108615fc 88 for(Int_t s=fMinSlice; s<=fMaxSlice; s++)
89 {
4aa41877 90 for(Int_t p=0; p<AliHLTTransform::GetNPatches(); p++)
108615fc 91 {
3e87ef69 92 Int_t patch;
93 if(sp==kTRUE)
94 patch=-1;
95 else
96 patch=p;
4aa41877 97 clusterfile[s][p] = new AliHLTMemHandler();
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 {
4aa41877 104 LOG(AliHLTLog::kError,"AliHLTEvaluation::Setup","File Open")
108615fc 105 <<"Inputfile "<<fname<<" does not exist"<<ENDLOG;
7d3726a4 106 delete clusterfile[s][p];
107 clusterfile[s][p] = 0;
108 continue;
108615fc 109 }
4aa41877 110 fClusters[s][p] = (AliHLTSpacePointData*)clusterfile[s][p]->Allocate();
108615fc 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;
4aa41877 119 AliHLTMemHandler *tfile = new AliHLTMemHandler();
108615fc 120 if(!tfile->SetBinaryInput(trackfile))
121 {
4aa41877 122 LOG(AliHLTLog::kError,"AliHLTEvaluation::Setup","File Open")
108615fc 123 <<"Inputfile "<<trackfile<<" does not exist"<<ENDLOG;
124 return;
125 }
4aa41877 126 fTracks = new AliHLTTrackArray();
108615fc 127 tfile->Binary2TrackArray(fTracks);
128 tfile->CloseBinaryInput();
129 delete tfile;
130
131}
132
4aa41877 133void AliHLTDisplay::DisplayTracks(Int_t minhits,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 {
4aa41877 155 AliHLTTrack *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();
c3d96f5a 160 if(nHits < minhits) continue;
108615fc 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;
4aa41877 171 AliHLTSpacePointData *points = fClusters[slice][patch];
4e03c52a 172 if(slice < fMinSlice || slice > fMaxSlice)
173 continue;
174
108615fc 175 if(!points) {
4aa41877 176 LOG(AliHLTLog::kError,"AliHLTDisplay::DisplayTracks","Clusterarray")
108615fc 177 <<"No points at slice "<<slice<<" patch "<<patch<<" pos "<<pos<<ENDLOG;
178 continue;
179 }
02f030e3 180 if(pos>=fNcl[slice][patch]){
4aa41877 181 LOG(AliHLTLog::kError,"AliHLTDisplay::DisplayTracks","Clusterarray")
02f030e3 182 <<"Pos is too large: pos "<<pos <<" ncl "<<fNcl[slice][patch]<<ENDLOG;
183 continue;
184 }
185
c3d96f5a 186 Float_t xyztmp[3];
187 xyztmp[0] = points[pos].fX;
188 xyztmp[1] = points[pos].fY;
189 xyztmp[2] = points[pos].fZ;
4e03c52a 190
c3d96f5a 191 xcl[h] = xyztmp[0];
192 ycl[h] = xyztmp[1];
193 zcl[h] = xyztmp[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();
c3d96f5a 201 TPolyLine3D *currentline = &(line[j]);
202 currentline = new TPolyLine3D(nHits,xcl,ycl,zcl,"");
108615fc 203
c3d96f5a 204 currentline->SetLineColor(4);
205 currentline->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
4aa41877 235void AliHLTDisplay::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 {
4aa41877 253 AliHLTSpacePointData *points = fClusters[s][p];
108615fc 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;
4aa41877 264 //AliHLTTransform::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
4aa41877 277void AliHLTDisplay::DisplayAll(Int_t minhits,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 {
4aa41877 294 AliHLTSpacePointData *points = fClusters[s][p];
108615fc 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 {
4aa41877 321 AliHLTTrack *gtrack = fTracks->GetCheckedTrack(j);
108615fc 322 if(!gtrack) continue;
323 Int_t nHits = gtrack->GetNHits();
324 UInt_t *hitnum = gtrack->GetHitNumbers();
c3d96f5a 325 if(nHits < minhits) continue;
108615fc 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
4aa41877 337 AliHLTSpacePointData *points = fClusters[slice][patch];
108615fc 338 if(!points) {
4aa41877 339 LOG(AliHLTLog::kError,"AliHLTDisplay::DisplayAll","Clusterarray")
108615fc 340 <<"No points at slice "<<slice<<" patch "<<patch<<" pos "<<pos<<ENDLOG;
341 continue;
342 }
02f030e3 343 if(pos>=fNcl[slice][patch]) {
4aa41877 344 LOG(AliHLTLog::kError,"AliHLTDisplay::DisplayAll","Clusterarray")
02f030e3 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();
c3d96f5a 357 TPolyLine3D *currentline = &(line[j]);
358 currentline = new TPolyLine3D(nHits,xcl,ycl,zcl,"");
359 currentline->SetLineColor(4);
360 currentline->SetLineWidth(2);
361 currentline->Draw("same");
108615fc 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
4aa41877 388void AliHLTDisplay::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);
4aa41877 394 AliTPCParam *param = (AliTPCParam*)file->Get(AliHLTTransform::GetParamName());
5e0f9911 395
396 Char_t dname[100];
4aa41877 397 sprintf(dname,"TreeD_%s_0",AliHLTTransform::GetParamName());
c3d96f5a 398 TTree *td=(TTree*)file->Get(dname);
108615fc 399 AliSimDigits da, *digits=&da;
c3d96f5a 400 td->GetBranch("Segment")->SetAddress(&digits); //Return pointer to branch segment.
108615fc 401
402 Int_t sector,row;
4aa41877 403 AliHLTTransform::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
c3d96f5a 411 Int_t sectorsbyrows=(Int_t)td->GetEntries();
108615fc 412 Int_t i;
c3d96f5a 413 for (i=0; i<sectorsbyrows; i++) {
414 if (!td->GetEvent(i)) continue;
108615fc 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);
4aa41877 442 AliHLTEvaluate *eval = new AliHLTEvaluate();
c3d96f5a 443 Float_t xyzcross[3];
4e03c52a 444 */
cf63f233 445
8f924a46 446 for(Int_t p=0;p<6;p++)
108615fc 447 {
4aa41877 448 AliHLTSpacePointData *points = fClusters[slice][p];
108615fc 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;
4aa41877 459 AliHLTTransform::Global2Raw(xyz,sector,row);
460 //AliHLTTransform::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}