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