L3 becomes HLT
[u/mrichter/AliRoot.git] / HLT / TPCLib / OnlineDisplay / AliHLTTPCDisplay.cxx
CommitLineData
9e0f7672 1// @(#) $Id$
4aa41877 2// Original: AliHLTDisplay.cxx,v 1.26 2005/06/14 10:55:21 cvetan
9e0f7672 3
4/** \class AliHLTTPCDisplay
5<pre>
6//_____________________________________________________________
7// AliHLTTPCDisplay
8//
9// Display class for the HLT TPC events.
10</pre>
11*/
12// Author: Jochen Thaeder <mailto:thaeder@kip.uni-heidelberg.de>
13// Anders Vestbo <mailto:vestbo@fi.uib.no>
14//*-- Copyright &copy ALICE HLT Group
15
16#define TRACKHELIX 0
17#define TRACKPOLYMARKER 0
18#define BACKWARD 0
19#define FIRSTLASTPOINT 0
20
21#define TRACKCOLOR
22#define USEDCLUSTERCOLOR
23#define UNUSEDCLUSTERCOLOR
24
25#include "AliHLTStdIncludes.h"
26#include <TView.h>
27#include <TPolyMarker3D.h>
28#include <TPolyLine3D.h>
29#include <TH2.h>
30#include <TTree.h>
31#include <TNode.h>
32#include <TGeometry.h>
33#include <TShape.h>
34#include <TParticle.h>
35#include <TFile.h>
36#include <THelix.h>
37#include <TStyle.h>
38#include <TGraph.h>
39#include <TMultiGraph.h>
40#include <TAttText.h>
41#include <TAxis.h>
42
43#if TRACKHELIX
44#include <THelix.h>
45#endif
46
47#ifdef use_aliroot
48#include <TClonesArray.h>
49#include <AliRun.h>
50#include <AliSimDigits.h>
51#include <AliTPCParam.h>
52#endif
53
54#include "AliHLTTPCLogging.h"
55#include "AliHLTTPCDisplay.h"
56#include "AliHLTTPCTransform.h"
57#include "AliHLTTPCTrack.h"
58#include "AliHLTTPCTrackArray.h"
59#include "AliHLTTPCSpacePointData.h"
60#include "AliHLTTPCMemHandler.h"
61#include "AliHLTTPCDigitReaderPacked.h"
62
63#if __GNUC__ == 3
64using namespace std;
65#endif
66
67ClassImp(AliHLTTPCDisplay)
68
69// #############################################################################
70void AliHLTTPCDisplay::InitDisplay(Char_t *gfile) {
71 //constructor
72 memset(fClusters,0,36*6*sizeof(AliHLTTPCSpacePointData*));
73 memset(fNcl, 0, 36*6*sizeof(UInt_t));
74
75 fTracks = NULL;
76 fHistrawcl = NULL;
77 fHistraw = NULL;
78 fHistpad1 = NULL;
79 fHistpad2 = NULL;
80 fHistpad3 = NULL;
81 fHistallresidualsY = NULL;
82 fHistallresidualsZ = NULL;
83 fHistcharge = NULL;
84 fGraphresidualsY = NULL;
85 fGraphresidualsZ = NULL;
86 fGraphresidualsYLength = NULL;
87 fGraphresidualsZLength = NULL;
88
89
90 fGeom = NULL;
91// ---------------------------------------------------
92// In order to be backward compatible
93// ---------------------------------------------------
94#if BACKWARD
95 //fc1 = NULL;
96#endif
97// ---------------------------------------------------
98 fNPads = 0;
99 fNTimes = 0;
100 fMinHits = 0;
101 fPtThreshold = 0.;
102 fPad = -1;
103 fPadRow = 0;
104 fSlicePadRow = 0;
105 fSelectTrack = -1;
106 fSelectTrackSlice = 0;
107 fSelectTrackSwitch = kFALSE;
108 fSelectCluster = 0;
109
110 fMinSlice = 0;
111 fMaxSlice = 35;
112 fSlicePair = kFALSE;
113
114 SetSliceArray();
115
116 fBackColor = 1;
117 fLineColor = 0;
118 fKeepView = kFALSE;
119
120 fSwitch3DCluster = kFALSE;
121 fSwitch3DTracks = kFALSE;
122 fSwitch3DPadRow = kFALSE;
123 fSwitch3DGeometry = kFALSE;
124
125 AliHLTTPCTransform::SetBField(0.4);
126 LoadGeometrie(gfile);
127}
128
129
130// #############################################################################
131AliHLTTPCDisplay::~AliHLTTPCDisplay() {
132 //destructor
133 if(fTracks) delete fTracks;
134 fTracks = NULL;
135}
136
137// #############################################################################
138Bool_t AliHLTTPCDisplay::LoadGeometrie(Char_t *gfile) {
139 if (gfile) {
140 TFile *file = TFile::Open(gfile);
141 if(!file) {
142 LOG(AliHLTTPCLog::kError,"AliHLTTPCDisplay::AliHLTTPCDisplay","File Open") <<"Geometry file " << gfile << " does not exist!"<<ENDLOG;
143 return kFALSE;
144 }
145
146 fGeom = (TGeometry*)file->Get("AliceGeom");
147
148 file->Close();
149 delete file;
150 }
151 return kTRUE;
152}
153
154// #############################################################################
155// EXECUTER
156// #############################################################################
157void AliHLTTPCDisplay::ExecPadRow(){
158 int event = gPad->GetEvent();
159 if (event != 11) return;
160
161 printf("TEST !!!!!!!!!!!!!!!");
162/* int px = gPad->GetEventX();
163 TObject *select = gPad->GetSelected();
164 if (!select) return;
165 if (select->InheritsFrom("TH1")) {
166 TH1 *h = (TH1*)select;
167 Float_t xx = gPad->AbsPixeltoX(px);
168 Float_t x = gPad->PadtoX(xx);
169 Int_t binx = h->GetXaxis()->FindBin(x);
170 printf("event=%d, hist:%s, bin=%d, content=%f\n",event,h->GetName(),binx,h->GetBinContent(binx));
171 }
172
173*/
174
175}
176
177// #############################################################################
178// SETTER
179// #############################################################################
180void AliHLTTPCDisplay::SetHistPadRowAxis() {
181 // Set Axis range of Histogramm, due to variable NPads per padrow
182
183 fNPads = AliHLTTPCTransform::GetNPads(fPadRow);
184 fHistrawcl->SetAxisRange(0,fNPads);
185 fHistraw->SetAxisRange(0,fNPads);
186 fHistrawcl->SetAxisRange(0,fNTimes,"Y");
187 fHistraw->SetAxisRange(0,fNTimes,"Y");
188}
189
190void AliHLTTPCDisplay::SetSliceArray() {
191 Int_t slice=0;
192 Int_t minSlice = fMinSlice;
193 Int_t maxSlice = fMaxSlice;
194 Int_t realslice = 0;
195
196 for (slice=0;slice<=35;slice++){
197 fSliceArray[slice] = kFALSE;
198 }
199
200 // Single Slice, or Range
201 if (minSlice > maxSlice) maxSlice += 17;
202
203 for (slice=minSlice;slice<=maxSlice;slice++){
204 realslice = slice % 18;
205 fSliceArray[realslice] = kTRUE;
206 fSliceArray[realslice+18] = kTRUE;
207 }
208
209 // Pair of Slices
210 if (fSlicePair) {
211 minSlice = fMinSlice + 9;
212 maxSlice = fMaxSlice + 9;
213
214 if (minSlice > maxSlice) maxSlice += 17;
215
216 for (slice=minSlice;slice<=maxSlice;slice++){
217 realslice = slice % 18;
218 fSliceArray[realslice] = kTRUE;
219 fSliceArray[realslice+18] = kTRUE;
220 }
221 }
222}
223
224// #############################################################################
225// SETUP
226// #############################################################################
227void AliHLTTPCDisplay::SetupCluster(Int_t slice, Int_t patch, UInt_t nofClusters, AliHLTTPCSpacePointData* data) {
228
229 if (data && slice>=0 && slice<36 && patch>=0 && patch<AliHLTTPCTransform::GetNPatches()) {
230 if (fClusters[slice][patch]!=NULL) {
231 delete(fClusters[slice][patch]);
232 fClusters[slice][patch]=NULL;
233 }
234 Int_t arraysize=nofClusters*sizeof(AliHLTTPCSpacePointData);
235 fClusters[slice][patch] = (AliHLTTPCSpacePointData*)new Byte_t[arraysize];
236 if (fClusters[slice][patch]) {
237 memcpy(fClusters[slice][patch], data, arraysize);
238 fNcl[slice][patch]=nofClusters;
239 } else {
240 fNcl[slice][patch]=nofClusters;
241 LOG(AliHLTTPCLog::kError,"AliHLTTPCDisplay::SetupCluster","memory allocation") << "memory allocation failed "<<ENDLOG;
242 }
243 } else LOG(AliHLTTPCLog::kError,"AliHLTTPCDisplay::SetupCluster","argument check") << "invalid argument "<<ENDLOG;
244}
245
246// #############################################################################
247void AliHLTTPCDisplay::SetupTracks(AliHLTTPCTrackArray *tracks) {
248 fTracks=tracks;
249
250 // Set USED cluster
251 Int_t ntracks = fTracks->GetNTracks();
252
253 for(Int_t j=0; j<ntracks; j++) {
254 AliHLTTPCTrack *gtrack = fTracks->GetCheckedTrack(j);
255 if(!gtrack) continue;
256
257 Int_t nHits = gtrack->GetNHits();
258 UInt_t *hitnum = gtrack->GetHitNumbers();
259
260 for(Int_t h=0; h<nHits; h++){
261
262 UInt_t id=hitnum[h];
263 Int_t slice = (id>>25) & 0x7f;
264 Int_t patch = (id>>22) & 0x7;
265 UInt_t pos = id&0x3fffff;
266
267 AliHLTTPCSpacePointData *points = fClusters[slice][patch];
268
269 if(!points) {
270 LOG(AliHLTTPCLog::kError,"AliHLTTPCDisplay::Draw3D","Clusterarray") <<"No points at slice "<<slice<<" patch "<<patch<<" pos "<<pos<<ENDLOG;
271 continue;
272 }
273
274 if(pos>=fNcl[slice][patch]) {
275 LOG(AliHLTTPCLog::kError,"AliHLTTPCDisplay::Draw3D","Clusterarray") <<"Pos is too large: pos "<<pos <<" ncl "<<fNcl[slice][patch]<<ENDLOG;
276 continue;
277 }
278 points[pos].fUsed = kTRUE;
279 points[pos].fTrackN = j;
280 }
281 }
282}
283
284// #############################################################################
285void AliHLTTPCDisplay::SetupHist(){
286
287 Int_t maxpads = 150;
288 fNTimes = AliHLTTPCTransform::GetNTimeBins();
289
290 if ( fHistraw ){
291 delete fHistraw;
292 fHistraw = NULL;
293 }
294 if ( fHistrawcl ){
295 delete fHistrawcl;
296 fHistrawcl = NULL;
297 }
298
299 if ( fHistpad1 ){
300 delete fHistpad1;
301 fHistpad1 = NULL;
302 }
303
304 if ( fHistpad2 ){
305 delete fHistpad2;
306 fHistpad2 = NULL;
307 }
308
309 if ( fHistpad3 ){
310 delete fHistpad3;
311 fHistpad3 = NULL;
312 }
313
314 if ( fHistallresidualsY){
315 delete fHistallresidualsY;
316 fHistallresidualsY = NULL;
317 }
318
319 if ( fHistallresidualsZ){
320 delete fHistallresidualsZ;
321 fHistallresidualsZ = NULL;
322 }
323 if ( fHistcharge){
324 delete fHistcharge;
325 fHistcharge = NULL;
326 }
327
328 // Setup the histograms
329 Int_t padbinning = maxpads*10;
330 fHistraw = new TH2F("fHistraw","Selected PadRow with found Clusters;Pad #;Timebin #",maxpads,0,maxpads-1,fNTimes,0,fNTimes-1);
331 fHistrawcl = new TH1F("fHistrawcl","",padbinning,0,maxpads-1);
332 fHistpad1 = new TH1F ("fHistpad1","Selected Pad -1;Timebin #",fNTimes,0,fNTimes-1);
333 fHistpad2 = new TH1F ("fHistpad2","Selected Pad;Timebin #",fNTimes,0,fNTimes-1);
334 fHistpad3 = new TH1F ("fHistpad3","Selected Pad +1;Timebin #",fNTimes,0,fNTimes-1);
335 fHistallresidualsY = new TH1F ("fHistallresiduals","Y Residuals of all Tracks in selected slices;residuals",5000,-100,100);
336 fHistallresidualsZ = new TH1F ("fHistallresiduals","Z Residuals of all Tracks in selected slices;residuals",5000,-100,100);
337 fHistcharge = new TH1F ("fHistcharge","Cluster distribution per charge;charge;#cluster",5000,0,30000);
338
339 fHistraw->SetOption("COLZ");
340
341 fHistallresidualsY->SetTitleSize(0.03);
342 fHistallresidualsY->GetXaxis()->SetLabelSize(0.03);
343 fHistallresidualsY->GetXaxis()->SetTitleSize(0.03);
344 fHistallresidualsY->GetYaxis()->SetLabelSize(0.03);
345 fHistallresidualsY->GetYaxis()->SetTitleSize(0.03);
346
347 fHistallresidualsZ->SetTitleSize(0.03);
348 fHistallresidualsZ->GetXaxis()->SetLabelSize(0.03);
349 fHistallresidualsZ->GetXaxis()->SetTitleSize(0.03);
350 fHistallresidualsZ->GetYaxis()->SetLabelSize(0.03);
351 fHistallresidualsZ->GetYaxis()->SetTitleSize(0.03);
352
353 fHistcharge->SetTitleSize(0.03);
354 fHistcharge->GetXaxis()->SetLabelSize(0.03);
355 fHistcharge->GetXaxis()->SetTitleSize(0.03);
356 fHistcharge->GetYaxis()->SetLabelSize(0.03);
357 fHistcharge->GetYaxis()->SetTitleSize(0.03);
358
359 fHistraw->SetTitleSize(0.03);
360 fHistraw->GetXaxis()->SetLabelSize(0.03);
361 fHistraw->GetXaxis()->SetTitleSize(0.03);
362 fHistraw->GetYaxis()->SetLabelSize(0.03);
363 fHistraw->GetYaxis()->SetTitleSize(0.03);
364
365 fHistpad1->SetTitleSize(0.03);
366 fHistpad1->GetXaxis()->SetLabelSize(0.03);
367 fHistpad1->GetXaxis()->SetTitleSize(0.03);
368 fHistpad1->GetYaxis()->SetLabelSize(0.03);
369 fHistpad1->GetYaxis()->SetTitleSize(0.03);
370
371 fHistpad2->SetTitleSize(0.03);
372 fHistpad2->GetXaxis()->SetLabelSize(0.03);
373 fHistpad2->GetXaxis()->SetTitleSize(0.03);
374 fHistpad2->GetYaxis()->SetLabelSize(0.03);
375 fHistpad2->GetYaxis()->SetTitleSize(0.03);
376
377 fHistpad3->SetTitleSize(0.03);
378 fHistpad3->GetXaxis()->SetLabelSize(0.03);
379 fHistpad3->GetXaxis()->SetTitleSize(0.03);
380 fHistpad3->GetYaxis()->SetLabelSize(0.03);
381 fHistpad3->GetYaxis()->SetTitleSize(0.03);
382
383 gStyle->SetPalette(1);
384
385 SetHistPadRowAxis();
386}
387
388// ####################################################################################################
389void AliHLTTPCDisplay::FillPadRow(Int_t patch, ULong_t dataBlock, ULong_t dataLen){
390#if defined(HAVE_ALIRAWDATA) && defined(HAVE_ALITPCRAWSTREAM_H)
391 AliHLTTPCDigitReader* digitReader = new AliHLTTPCDigitReaderPacked();
392 bool readValue = true;
393 Int_t rowOffset = 0;
394
395 // Initialize RAW DATA
396 Int_t firstRow = AliHLTTPCTransform::GetFirstRow(patch);
397 Int_t lastRow = AliHLTTPCTransform::GetLastRow(patch);
398
399 // Outer sector, patches 2, 3, 4, 5 - start counting in patch 2 with row 0
400 if ( patch >= 2 ) rowOffset = AliHLTTPCTransform::GetFirstRow( 2 );
401
402 // Initialize block for reading packed data
403 void* tmpdataBlock = (void*) dataBlock;
404 digitReader->InitBlock(tmpdataBlock,dataLen,firstRow,lastRow,patch,0);
405
406 readValue = digitReader->Next();
407
408 if (!readValue){
409 LOG(AliHLTTPCLog::kError,"AliHLTTPCDisplay::FillPadRow","Read first value") << "No value in data block" << ENDLOG;
410 return;
411 }
412
413 // FILL PADROW 3D --- Initialize the colorbins
414 if (fSwitch3DPadRow){
415 for (UInt_t ii=0;ii < 20;ii++){
416 fbinct[ii] = 0;
417 fcolorbin[ii] = 0;
418 }
419
420 // read number of entries in colorbin
421 while ( readValue ){
422
423 Int_t row = digitReader->GetRow() + rowOffset;
424
425 if (row == fPadRow){
426 UInt_t charge = digitReader->GetSignal();
427
428 for (UInt_t ii=0;ii < 19;ii++){
429 if ( charge > (ii*15) && charge <= ((ii*15) + 15) ) fcolorbin[ii]++;
430 }
431 // larger than 19 * 15
432 if (charge > 285 ) fcolorbin[19]++;
433 }
434
435 // read next value
436 readValue = digitReader->Next();
437
438 if(!readValue) break; //No more value
439 }
440 //Initialize fpmarr[color][3*colorbin[ii]]
441 fpmarr[0] = new Float_t[fcolorbin[0]*3];
442 fpmarr[1] = new Float_t[fcolorbin[1]*3];
443 fpmarr[2] = new Float_t[fcolorbin[2]*3];
444 fpmarr[3] = new Float_t[fcolorbin[3]*3];
445 fpmarr[4] = new Float_t[fcolorbin[4]*3];
446 fpmarr[5] = new Float_t[fcolorbin[5]*3];
447 fpmarr[6] = new Float_t[fcolorbin[6]*3];
448 fpmarr[7] = new Float_t[fcolorbin[7]*3];
449 fpmarr[8] = new Float_t[fcolorbin[8]*3];
450 fpmarr[9] = new Float_t[fcolorbin[9]*3];
451 fpmarr[10] = new Float_t[fcolorbin[10]*3];
452 fpmarr[11] = new Float_t[fcolorbin[11]*3];
453 fpmarr[12] = new Float_t[fcolorbin[12]*3];
454 fpmarr[13] = new Float_t[fcolorbin[13]*3];
455 fpmarr[14] = new Float_t[fcolorbin[14]*3];
456 fpmarr[15] = new Float_t[fcolorbin[15]*3];
457 fpmarr[16] = new Float_t[fcolorbin[16]*3];
458 fpmarr[17] = new Float_t[fcolorbin[17]*3];
459 fpmarr[18] = new Float_t[fcolorbin[18]*3];
460 fpmarr[19] = new Float_t[fcolorbin[19]*3];
461
462 // Rewind the raw reader and fill the polymarker3D
463 digitReader->InitBlock(tmpdataBlock,dataLen,firstRow,lastRow,patch,0);
464
465 readValue = digitReader->Next();
466 } // END if (fSwitch3DPadRow)
467
468 // -- Fill Raw Data
469 while ( readValue ){
470
471 Int_t row = digitReader->GetRow() + rowOffset;
472
473 // select padrow to fill in histogramm
474 if (row == fPadRow){
475 UChar_t pad = digitReader->GetPad();
476 UShort_t time = digitReader->GetTime();
477 UInt_t charge = digitReader->GetSignal();
478 Float_t xyz[3];
479 fHistraw->Fill(pad,time,charge);
480
481 if (pad == (fPad-1) ) fHistpad1->Fill(time,charge);
482 if (pad == fPad) fHistpad2->Fill(time,charge);
483 if (pad == (fPad+1) ) fHistpad3->Fill(time,charge);
484
485 if (fSwitch3DPadRow) {
486 // Transform raw coordinates to local coordinates
487 AliHLTTPCTransform::RawHLT2Global(xyz, fSlicePadRow, fPadRow, pad, time);
488
489 for (UInt_t ii=0;ii < 19;ii++){
490 if ( charge > (ii*15) && charge <= ((ii*15) + 15) ){
491 fpmarr[ii][fbinct[ii]] = xyz[0];
492 fpmarr[ii][fbinct[ii]+1] = xyz[1];
493 fpmarr[ii][fbinct[ii]+2] = xyz[2];
494 fbinct[ii] += 3;
495 }
496 }
497 // larger than 19 * 15
498 if (charge > 285 ) {
499 fpmarr[19][fbinct[19]] = xyz[0];
500 fpmarr[19][fbinct[19]+1] = xyz[1];
501 fpmarr[19][fbinct[19]+2] = xyz[2];
502 fbinct[19] += 3;
503 }
504 } // END if (fSwitch3DPadRow)
505
506 }
507
508 // read next value
509 readValue = digitReader->Next();
510
511 //Check where to stop:
512 if(!readValue) break; //No more value
513 }
514
515 if ( digitReader )
516 delete digitReader;
517 digitReader = NULL;
518
519 AliHLTTPCSpacePointData *points = fClusters[fSlicePadRow][patch];
520 if(!points) return;
521 Int_t npoints = fNcl[fSlicePadRow][patch];
522
523 Float_t xyz[3];
524 for(Int_t i=0; i<npoints; i++){
525 xyz[0] = points[i].fX;
526 xyz[1] = points[i].fY;
527 xyz[2] = points[i].fZ;
528
529 Int_t clrow = AliHLTTPCTransform::GetPadRow(xyz[0]);
530 // select padrow to fill in histogramm
531 if (clrow == fPadRow){
532 AliHLTTPCTransform::LocHLT2Raw(xyz, fSlicePadRow, fPadRow);
533 fHistrawcl->Fill(xyz[1],xyz[2]);
534 }
535 }
536#else //! if defined(HAVE_ALIRAWDATA) && defined(HAVE_ALITPCRAWSTREAM_H)
537 HLTFatal("DigitReaderPacked not available - check your build");
538#endif //defined(HAVE_ALIRAWDATA) && defined(HAVE_ALITPCRAWSTREAM_H)
539}
540
541// #############################################################################
542void AliHLTTPCDisplay::ResetHistPadRow(){
543 fHistraw->Reset();
544 fHistrawcl->Reset();
545 fHistpad1->Reset();
546 fHistpad2->Reset();
547 fHistpad3->Reset();
548}
549
550// #############################################################################
551void AliHLTTPCDisplay::ResetHistResiduals(){
552 fHistallresidualsY->Reset();
553 fHistallresidualsZ->Reset();
554}
555
556// #############################################################################
557void AliHLTTPCDisplay::ResetHistCharge(){
558 fHistcharge->Reset();
559}
560
561
562// #############################################################################
563// DRAWER
564// #############################################################################
565void AliHLTTPCDisplay::DrawGeomSector(Int_t sector) {
566 Char_t fname[256];
567 Int_t realsector = sector;// % 18;
568
569 if (realsector < 10){
570 sprintf(fname,"LS0%d",realsector);
571 fGeom->GetNode(fname)->SetLineColor(fLineColor);
572 fGeom->GetNode(fname)->Draw("same");
573 sprintf(fname,"US0%d",realsector);
574 fGeom->GetNode(fname)->SetLineColor(fLineColor);
575 fGeom->GetNode(fname)->Draw("same");
576 }
577 else {
578 sprintf(fname,"LS%d",realsector);
579 fGeom->GetNode(fname)->SetLineColor(fLineColor);
580 fGeom->GetNode(fname)->Draw("same");
581 sprintf(fname,"US%d",realsector);
582 fGeom->GetNode(fname)->SetLineColor(fLineColor);
583 fGeom->GetNode(fname)->Draw("same");
584 }
585}
586// #############################################################################
587void AliHLTTPCDisplay::DrawHistPadRow(){
588 Char_t title[256];
589 sprintf(title,"Selected PadRow %d with found Clusters",fPadRow);
590
591 fHistraw->SetTitle(title);
592 fHistraw->SetStats(kFALSE);
593 fHistraw->Draw("COLZ");
594
595 fHistrawcl->SetStats(kFALSE);
596 fHistrawcl->SetMarkerStyle(28);
597 fHistrawcl->SetMarkerSize(2);
598 fHistrawcl->SetMarkerColor(1);
599 fHistrawcl->Draw("psame");
600}
601
602// #############################################################################
603void AliHLTTPCDisplay::DrawHistPad1(){
604 Char_t title[256];
605 sprintf(title,"Selected Pad %d",fPad -1);
606 fHistpad1->SetStats(kFALSE);
607 fHistpad1->SetTitle(title);
608 fHistpad1->Draw();
609}
610
611// #############################################################################
612void AliHLTTPCDisplay::DrawHistPad2(){
613 Char_t title[256];
614 sprintf(title,"Selected Pad %d",fPad);
615
616 fHistpad2->SetStats(kFALSE);
617 fHistpad2->SetTitle(title);
618 fHistpad2->Draw();
619}
620
621// #############################################################################
622void AliHLTTPCDisplay::DrawHistPad3(){
623 Char_t title[256];
624 sprintf(title,"Selected Pad %d",fPad +1);
625
626 fHistpad3->SetStats(kFALSE);
627 fHistpad3->SetTitle(title);
628 fHistpad3->Draw();
629}
630
631// #############################################################################
632void AliHLTTPCDisplay::DrawHistResiduals(Bool_t ySwitch){
633 if (fSwitch3DTracks){
634 if (ySwitch){
635 // Y Residual histogram for 1 track
636
637 if (fSelectTrackSwitch){
638 Char_t title[256];
639 sprintf(title,"Y Residuals of Track %d in Slice %d",fSelectTrack, fSelectTrackSlice );
640
641 TMultiGraph *mgY = new TMultiGraph();
642
643
644// fGraphresidualsY->SetTitle(title);
645 fGraphresidualsY->GetXaxis()->SetTitle("padrow");
646 fGraphresidualsY->GetYaxis()->SetTitle("residuals");
647// fGraphresidualsY->Draw("A*");
648 fGraphresidualsY->GetXaxis()->SetLabelSize(0.02);
649 fGraphresidualsY->GetXaxis()->SetTitleSize(0.02);
650 fGraphresidualsY->GetYaxis()->SetLabelSize(0.02);
651 fGraphresidualsY->GetYaxis()->SetTitleSize(0.02);
652 fGraphresidualsYLength->SetMarkerColor(2);
653 fGraphresidualsYLength->SetMarkerStyle(5);
654 fGraphresidualsY->SetMarkerColor(1);
655 fGraphresidualsY->SetMarkerStyle(3);
656
657// fGraphresidualsY->Draw("A*");
658// fGraphresidualsYLength->Draw("*");
659
660 mgY->Add(fGraphresidualsY);
661 mgY->Add(fGraphresidualsYLength);
662 mgY->SetTitle(title);
663// mgY->GetXaxis()->SetTitle("padrow");
664// mgY->GetYaxis()->SetTitle("residuals");
665 mgY->Draw("AP");
666 }
667 // Global residuals histogram
668 else{
669 fHistallresidualsY->SetStats(kFALSE);
670 fHistallresidualsY->Draw();
671 }
672 }
673 else {
674 // Z Residual histogram for 1 track
675 if (fSelectTrackSwitch){
676 Char_t title[256];
677 sprintf(title,"Z Residuals of Track %d in Slice %d",fSelectTrack, fSelectTrackSlice );
678
679 TMultiGraph *mgZ = new TMultiGraph();
680
681 fGraphresidualsZ->SetTitle(title);
682 fGraphresidualsZ->GetXaxis()->SetTitle("padrow");
683 fGraphresidualsZ->GetYaxis()->SetTitle("residuals");
684 fGraphresidualsZ->GetXaxis()->SetLabelSize(0.02);
685 fGraphresidualsZ->GetXaxis()->SetTitleSize(0.02);
686 fGraphresidualsZ->GetYaxis()->SetLabelSize(0.02);
687 fGraphresidualsZ->GetYaxis()->SetTitleSize(0.02);
688// fGraphresidualsZLength->Draw("F*");
689// fGraphresidualsZ->Draw("A*");
690
691 mgZ->Add(fGraphresidualsZ);
692// mgZ->Add(fGraphresidualsZLength);
693 mgZ->SetTitle(title);
694 mgZ->Draw("A*");
695 }
696 // Global residuals histogram
697 else{
698 fHistallresidualsZ->SetStats(kFALSE);
699 fHistallresidualsZ->Draw();
700 }
701 }
702 }
703}
704
705// #############################################################################
706void AliHLTTPCDisplay::DrawHistCharge(){
707 if (fSwitch3DCluster){
708// fHistcharge->SetStats(kFALSE);
709 fHistcharge->Draw();
710 }
711}
712
713// #############################################################################
714void AliHLTTPCDisplay::Draw3D(){
715
716 TView *v = new TView(1);
717 v->SetRange(-800,-800,-800,800,800,800);
718
719 Float_t* etaRange = NULL; // ------ STILL TO FIX
720
721
722 //--------------------------------------------------------------------------------------------
723 // DRAW 3D CLUSTER
724 //--------------------------------------------------------------------------------------------
725 if (fSwitch3DCluster){
726 Int_t maxCharge = 0;
727
728 for (Int_t slice=0; slice <= 35; slice++){
729
730 Int_t currenttrack = -1;
731
732 if (fSelectCluster == 1 && fSelectTrackSwitch && slice == fSelectTrackSlice ){
733
734 Int_t trackcounter = 0;
735 Int_t ntracks = fTracks->GetNTracks();
736
737 for(Int_t j=0; j<ntracks; j++) {
738
739 AliHLTTPCTrack *gtrack = fTracks->GetCheckedTrack(j);
740 if(!gtrack) continue;
741
742 Int_t nHits = gtrack->GetNHits(); // Number of associated hits to track
743 Int_t tmpslice = gtrack->GetSector();
744
745 // --- CHECK if track is should be drawn
746 // select Single Track
747 if(tmpslice != fSelectTrackSlice) continue;
748
749 if (trackcounter != fSelectTrack){
750 trackcounter++;
751 continue;
752 }
753 trackcounter++;
754
755 if((fPtThreshold > 0) && (gtrack->GetPt()< fPtThreshold)) continue;
756 if(nHits < fMinHits) continue;
757
758 currenttrack = j;
759 break;
760 }
761 }
762
763 if (!fSliceArray[slice]) continue;
764
765 for(Int_t p=0;p<6;p++){
766
767 AliHLTTPCSpacePointData *points = fClusters[slice][p];
768 if(!points) continue;
769 Int_t npoints = fNcl[slice][p];
770 TPolyMarker3D *pmUsed = new TPolyMarker3D(1,6);
771 TPolyMarker3D *pmUnused = new TPolyMarker3D(1,6);
772 Int_t nUsedCluster = 0;
773 Int_t nUnusedCluster = 0;
774
775 Float_t xyz[3];
776 for(Int_t i=0; i<npoints; i++){
777 // Used cluster only
778 if (fSelectCluster == 1 && points[i].fUsed == kFALSE) continue;
779 // Unused cluster only
780 if (fSelectCluster == 2 && points[i].fUsed == kTRUE) continue;
781
782 // if single track is selcted draw only cluster for this track
783 if (fSelectCluster == 1 && fSelectTrackSwitch && points[i].fTrackN != currenttrack) continue;
784
785 xyz[0] = points[i].fX;
786 xyz[1] = points[i].fY;
787 xyz[2] = points[i].fZ;
788
789 if ( etaRange ){
790 // Do this before the transform, because the tracker also uses
791 // local coordinates when using this limit to determine
792 // which clusters to use for tracking
793 Double_t pointEta = AliHLTTPCTransform::GetEta( xyz );
794 if ( pointEta<etaRange[0] || pointEta>etaRange[1] )
795 continue;
796 }
797
798 AliHLTTPCTransform::Local2Global(xyz,slice);
799
800 if (points[i].fUsed == kTRUE){
801 pmUsed->SetPoint(nUsedCluster,xyz[0],xyz[1],xyz[2]);
802 nUsedCluster++;
803 }
804 else {
805 pmUnused->SetPoint(nUnusedCluster,xyz[0],xyz[1],xyz[2]);
806 nUnusedCluster++;
807 }
808
809 // Fill Charge Histogram
810 fHistcharge->Fill(points[i].fCharge);
811 if ((Int_t)points[i].fCharge > maxCharge ) maxCharge = (Int_t) points[i].fCharge;
812 }
813 pmUsed->SetMarkerSize(1);
814 pmUsed->SetMarkerColor(3);
815 pmUsed->Draw("");
816
817 pmUnused->SetMarkerSize(1);
818 pmUnused->SetMarkerColor(2);
819 pmUnused->Draw("");
820 } // END - PATCH LOOP
821 } // END - SLICE LOOP
822 fHistcharge->SetAxisRange(0,maxCharge);
823 } // END - DRAW 3D CLUSTER
824
825 //--------------------------------------------------------------------------------------------
826 // DRAW 3D TRACKS
827 //--------------------------------------------------------------------------------------------
828 if (fSwitch3DTracks){
829
830 Int_t trackcounter = 0;
831 Int_t ntracks = fTracks->GetNTracks();
832 Double_t drawStep = 0.2;
833
834 Double_t maxResidualY = 0.;
835 Double_t maxResidualZ = 0.;
836
837 TPolyLine3D *line = new TPolyLine3D[ntracks];
838#if TRACKHELIX
839 THelix *helix = new THelix[ntracks];
840#endif
841 for(Int_t j=0; j<ntracks; j++) {
842
843 AliHLTTPCTrack *gtrack = fTracks->GetCheckedTrack(j);
844 if(!gtrack) continue;
845
846 Int_t nHits = gtrack->GetNHits(); // Number of associated hits to track
847 Int_t slice = gtrack->GetSector();
848
849 // --- CHECK if track is should be drawn
850 // select if slice should be displayed or not
851 if (!fSliceArray[slice]) continue;
852
853 // select Single Track
854 if (fSelectTrackSwitch){
855 if(slice != fSelectTrackSlice) continue;
856
857 if (trackcounter != fSelectTrack){
858 trackcounter++;
859 continue;
860 }
861 trackcounter++;
862 }
863
864 if((fPtThreshold > 0) && (gtrack->GetPt()< fPtThreshold)) continue;
865 if(nHits < fMinHits) continue;
866
867 TPolyMarker3D *pmL = new TPolyMarker3D(1,2);
868 TPolyMarker3D *pmF = new TPolyMarker3D(1,2);
869
870 Double_t radius = gtrack->GetRadius(); // radius
871 Double_t kappa = gtrack->GetKappa(); // curvature = 1/R , signed
872 Double_t lambda = atan( gtrack->GetTgl() ); // dipAngle lambda
873 Double_t phi0 = gtrack->GetPsi() + (gtrack->GetCharge() * AliHLTTPCTransform::PiHalf() ); // azimuthal angle of startingpoint, with respect to helix axis
874
875 Double_t xyzL[3]; // lastpoint of track
876 Double_t xyzF[3]; // firstpoint of track
877
878 xyzF[0] = gtrack->GetFirstPointX();
879 xyzF[1] = gtrack->GetFirstPointY();
880 xyzF[2] = gtrack->GetFirstPointZ();
881 pmF->SetPoint(0,xyzF[0],xyzF[1],xyzF[2]);
882
883 xyzL[0] = gtrack->GetLastPointX();
884 xyzL[1] = gtrack->GetLastPointY();
885 xyzL[2] = gtrack->GetLastPointZ();
886 pmL->SetPoint(0,xyzL[0],xyzL[1],xyzL[2]);
887
888 Double_t s = 0.; // length of the track
889
890 // Calculate the length of the track. If it is to flat in in s,z plane use sxy, otherwise use sz
891 if (fabs(lambda) > 0.05){
892 // length of track calculated out of z
893 s = fabs( (xyzL[2] - xyzF[2]) / sin(lambda) ); // length of track calculated out of z
894 }
895 else {
896 Double_t d = (xyzL[0] - xyzF[0])*(xyzL[0] - xyzF[0]) + (xyzL[1] - xyzF[1])*(xyzL[1] - xyzF[1]);
897 // length of track calculated out of xy
898 s = fabs ( acos( 0.5 * (2 - (d / (radius*radius)))) / ( kappa * cos(lambda) ) );
899 }
900
901 Int_t nTrackPoints = 2 + (Int_t) floor(s / drawStep);
902
903#if TRACKPOLYMARKER
904 TPolyMarker3D *pmT = new TPolyMarker3D(nTrackPoints,6);
905#endif
906
907 Double_t *xT = new Double_t[nTrackPoints];
908 Double_t *yT = new Double_t[nTrackPoints];
909 Double_t *zT = new Double_t[nTrackPoints];
910
911 //Write Track Parameters for single track
912 if (fSelectTrackSwitch){
913 fTrackParam.id = trackcounter - 1;
914 fTrackParam.nHits = nHits;
915 fTrackParam.charge = gtrack->GetCharge();
916 fTrackParam.lambda = lambda;
917 fTrackParam.kappa = kappa;
918 fTrackParam.radius = radius;
919 fTrackParam.slice = slice;
920 fTrackParam.phi0 = phi0;
921 fTrackParam.pt = gtrack->GetPt();
922 fTrackParam.bfield = AliHLTTPCTransform::GetBFieldValue();
923 fTrackParam.xyzF[0] = gtrack->GetFirstPointX();
924 fTrackParam.xyzF[1] = gtrack->GetFirstPointY();
925 fTrackParam.xyzF[2] = gtrack->GetFirstPointZ();
926 fTrackParam.xyzL[0] = gtrack->GetLastPointX();
927 fTrackParam.xyzL[1] = gtrack->GetLastPointY();
928 fTrackParam.xyzL[2] = gtrack->GetLastPointZ();
929 fTrackParam.psi = gtrack->GetPsi();
930 fTrackParam.s = s;
931 }
932
933 Int_t trackPointCounter = 0;
934
935 for (Double_t ds = 0.; ds < s; ds = ds + drawStep){
936 // FILL ARRAYS IN ORDER TO DRAW THE TRACKPOINTS, OUT OF THE PARAMETER
937 xT[trackPointCounter] = xyzF[0] + radius * ( cos( phi0 + (ds*kappa*cos(lambda)) ) - cos(phi0) );
938 yT[trackPointCounter] = xyzF[1] + radius * ( sin( phi0 + (ds*kappa*cos(lambda)) ) - sin(phi0) );
939 zT[trackPointCounter] = xyzF[2] + ds * sin(lambda);
940#if TRACKPOLYMARKER
941 pmT->SetPoint(trackPointCounter,xT[trackPointCounter],yT[trackPointCounter],zT[trackPointCounter]);
942#endif
943 trackPointCounter++;
944 }
945
946 xT[trackPointCounter] = xyzF[0] + radius * ( cos( phi0 + (s*kappa*cos(lambda)) ) - cos(phi0) );
947 yT[trackPointCounter] = xyzF[1] + radius * ( sin( phi0 + (s*kappa*cos(lambda)) ) - sin(phi0) );
948 zT[trackPointCounter] = xyzF[2] + s * sin(lambda);
949#if TRACKPOLYMARKER
950 pmT->SetPoint(trackPointCounter,xT[trackPointCounter],yT[trackPointCounter],zT[trackPointCounter]);
951#endif
952 // --- RESIDUALS ---
953 gtrack->Rotate(slice,kTRUE);
954 Int_t nRes = 0; // number of resiudals
955
956 UInt_t *hitnum = gtrack->GetHitNumbers();
957
958 Double_t *resY= new Double_t[nHits];
959 Double_t *resZ= new Double_t[nHits];
960
961 Double_t *resYLength= new Double_t[2*nHits];
962 Double_t *resZLength= new Double_t[2*nHits];
963
964 Double_t *padrows = new Double_t[nHits];
965 Double_t *padrowsLength = new Double_t[2*nHits];
966
967 for(Int_t h=0; h<nHits; h++){
968 UInt_t id=hitnum[h];
969 Int_t patch = (id>>22) & 0x7;
970 UInt_t pos = id&0x3fffff;
971
972 AliHLTTPCSpacePointData *points = fClusters[slice][patch];
973
974 Float_t xyzCtmp[3]; // cluster tmp
975 Float_t xyzTtmp[3]; // track tmp
976
977 xyzCtmp[0] = points[pos].fX;
978 xyzCtmp[1] = points[pos].fY;
979 xyzCtmp[2] = points[pos].fZ;
980
981 Int_t padrow = AliHLTTPCTransform::GetPadRow(points[pos].fX);
982 xyzTtmp[0] = gtrack->GetFirstPointX();
983 if(gtrack->GetCrossingPoint(padrow,xyzTtmp)) {
984
985 Float_t deltaY = ( xyzCtmp[1] - xyzTtmp[1] );
986 Float_t deltaZ = ( xyzCtmp[2] - xyzTtmp[2] );
987// Float_t residual = sqrt( deltaY*deltaY + deltaZ*deltaZ );
988
989 padrows[nRes] = (Double_t) padrow;
990 resY[nRes] = (Double_t) deltaY;
991 resZ[nRes] = (Double_t) deltaZ;
992
993 resYLength[(2*nRes)] = 0.5 * AliHLTTPCTransform::GetPadLength(padrow);
994 resYLength[(2*nRes)+1] = -0.5 * AliHLTTPCTransform::GetPadLength(padrow);
995 resZLength[nRes] = AliHLTTPCTransform::GetZLength();
996 padrowsLength[(2*nRes)] = (Double_t) padrow;
997 padrowsLength[(2*nRes)+1] = (Double_t) padrow;
998
999 // FILL RESIDUALS HISTOGRAM
1000 fHistallresidualsY->Fill(resY[nRes]);
1001 fHistallresidualsZ->Fill(resZ[nRes]);
1002 if (resY[nRes] > maxResidualY ) maxResidualY = resY[nRes];
1003 if (resZ[nRes] > maxResidualZ ) maxResidualZ = resZ[nRes];
1004 nRes++;
1005 }
1006 }
1007
1008 gtrack->Rotate(slice,kFALSE);
1009 // --- RESIDUALS ---
1010
1011 // Draw last point of Track
1012 pmL->SetMarkerSize(3);
1013 pmL->SetMarkerColor(4);
1014// pmL->Draw();
1015
1016 // Draw first point of Track
1017 pmF->SetMarkerSize(3);
1018 pmF->SetMarkerColor(5);
1019// pmF->Draw();
1020
1021#if TRACKPOLYMARKER
1022 // Draw Track -- as polymarker
1023 pmT->SetMarkerSize(3);
1024 pmT->SetMarkerColor(3);
1025 pmT->Draw();
1026#endif
1027 // Draw Track -- as line
1028 TPolyLine3D *currentline = &(line[j]);
1029 currentline = new TPolyLine3D(nTrackPoints,xT,yT,zT,"");
1030 currentline->SetLineColor(4);
1031 currentline->SetLineWidth(2);
1032 currentline->Draw("same");
1033
1034#if TRACKHELIX
1035 // Draw Track -- as helix
1036 // works ok, execpt for very small dipangles -> track almost horizontal
1037 Double_t hrange[2];
1038 Double_t v0[3];
1039 Double_t omega;
1040 hrange[0] = xyzF[2];
1041 hrange[1] = xyzL[2];
1042 v0[0] = gtrack->GetPx();
1043 v0[1] = gtrack->GetPy();
1044 v0[2] = gtrack->GetPz();
1045 omega = AliHLTTPCTransform::GetBFieldValue() * gtrack->GetCharge();
1046
1047 THelix *currenthelix = &(helix[j]);
1048 currenthelix = new THelix(xyzF,v0,omega,hrange,kHelixZ,0);
1049 currenthelix->SetLineColor(6);
1050 currenthelix->SetLineWidth(1);
1051 currenthelix->Draw("same");
1052#endif
1053
1054 //Residuals
1055 if ( fGraphresidualsY){
1056 delete fGraphresidualsY;
1057 fGraphresidualsY = NULL;
1058 }
1059
1060 if ( fGraphresidualsZ){
1061 delete fGraphresidualsZ;
1062 fGraphresidualsZ = NULL;
1063 }
1064 //Residuals
1065 if ( fGraphresidualsYLength){
1066 delete fGraphresidualsYLength;
1067 fGraphresidualsYLength = NULL;
1068 }
1069
1070 if ( fGraphresidualsZLength){
1071 delete fGraphresidualsZLength;
1072 fGraphresidualsZLength = NULL;
1073 }
1074
1075
1076
1077 // FILL Y RESIDUALS GRAPH
1078 fGraphresidualsY = new TGraph(nRes-1,padrows,resY);
1079 fGraphresidualsYLength = new TGraph((2*nRes)-2,padrowsLength,resYLength);
1080 // FILL Z RESIDUALS GRAPH
1081 fGraphresidualsZ = new TGraph(nRes-1,padrows,resZ);
1082 fGraphresidualsZLength = new TGraph(nRes-1,padrows,resZLength);
1083
1084 if (xT) delete xT;
1085 if (yT) delete yT;
1086 if (zT) delete zT;
1087
1088 } // END for tracks
1089
1090 fHistallresidualsY->SetAxisRange(-maxResidualY,maxResidualY);
1091 fHistallresidualsZ->SetAxisRange(-maxResidualZ,maxResidualZ);
1092
1093 } // END - DRAW 3D Tracks
1094
1095 //--------------------------------------------------------------------------------------------
1096 // DRAW 3D GEOMETRY
1097 //--------------------------------------------------------------------------------------------
1098 if (fSwitch3DGeometry){
1099
1100 for (Int_t slice=0; slice <= 17; slice++){
1101 if (!fSliceArray[slice]) continue;
1102 DrawGeomSector(slice);
1103 }
1104 } // END - DRAW 3D GEOMETRY
1105
1106 //--------------------------------------------------------------------------------------------
1107 // DRAW 3D PadRow
1108 //--------------------------------------------------------------------------------------------
1109 if (fSwitch3DPadRow && fSliceArray[fSlicePadRow]){
1110 Int_t markercolor = 51;
1111
1112 for (UInt_t ii=0;ii < 20;ii++){
1113 if (fcolorbin[ii]> 0){
1114
1115 TPolyMarker3D *pm = new TPolyMarker3D(fcolorbin[ii], fpmarr[ii], 7 );
1116
1117 pm->SetMarkerColor(markercolor);
1118 pm->Draw("");
1119 }
1120
1121 // in order to have the SetPalette(1), so called "pretty"
1122 if (ii % 2 == 0 ) markercolor += 2;
1123 else markercolor += 3;
1124 }
1125 }
1126
1127 //--------------------------------------------------------------------------------------------
1128 // DRAW 3D
1129 //--------------------------------------------------------------------------------------------
1130 v->ZoomView(0,4);
1131 v->Draw();
1132}
1133
1134// ---------------------------------------------------
1135// In order to be backward compatible
1136// ---------------------------------------------------
1137#if BACKWARD
1138void AliHLTTPCDisplay::DisplayClusters(Bool_t x3don,Float_t* etaRange) {
1139 if (!fc1){
1140 fc1 = new TCanvas("c1","",900,900);
1141 fc1->cd();
1142 }
1143
1144 fSwitch3DTracks = kFALSE;
1145 fSwitch3DCluster = kTRUE;
1146 fSwitch3DPadRow = kFALSE;
1147 fSwitch3DGeometry = kFALSE;
1148
1149 Draw3D();
1150}
1151// ---------------------------------------------------
1152void AliHLTTPCDisplay::DisplayTracks(Int_t minhits,Bool_t x3don,Float_t thr) {
1153 if (!fc1){
1154 fc1 = new TCanvas("c1","",900,900);
1155 fc1->cd();
1156 }
1157
1158 fMinHits = minhits;
1159 fPtThreshold = thr;
1160 fSwitch3DTracks = kTRUE;
1161 fSwitch3DCluster = kFALSE;
1162 fSwitch3DPadRow = kFALSE;
1163 fSwitch3DGeometry = kFALSE;
1164
1165 Draw3D();
1166}
1167// ---------------------------------------------------
1168void AliHLTTPCDisplay::DisplayAll(Int_t minhits,Bool_t clusterswitch,Bool_t trackswitch,Bool_t x3don, Float_t thr, Float_t* etaRange){
1169 if (!fc1){
1170 fc1 = new TCanvas("c1","",900,900);
1171 fc1->cd();
1172 }
1173
1174 fMinHits = minhits;
1175 fPtThreshold = thr;
1176 fSwitch3DTracks = trackswitch;
1177 fSwitch3DCluster = clusterswitch;
1178 fSwitch3DPadRow = kFALSE;
1179 fSwitch3DGeometry = kFALSE;
1180
1181 Draw3D();
1182}
1183#endif
1184// ---------------------------------------------------