2 // Original: AliHLTDisplay.cxx,v 1.26 2005/06/14 10:55:21 cvetan
6 //_____________________________________________________________
9 // Display class for the HLT TPC events.
12 // Author: Jochen Thaeder <mailto:thaeder@kip.uni-heidelberg.de>
13 // Anders Vestbo <mailto:vestbo@fi.uib.no>
14 //*-- Copyright © ALICE HLT Group
17 #define TRACKPOLYMARKER 0
19 #define FIRSTLASTPOINT 0
22 #define USEDCLUSTERCOLOR
23 #define UNUSEDCLUSTERCOLOR
25 #include "AliHLTStdIncludes.h"
26 #if defined(HAVE_TVIEW3D_H)
31 #include <TPolyMarker3D.h>
32 #include <TPolyLine3D.h>
36 #include <TGeometry.h>
38 #include <TParticle.h>
43 #include <TMultiGraph.h>
52 #include <TClonesArray.h>
54 #include <AliSimDigits.h>
55 #include <AliTPCParam.h>
58 #include "AliHLTTPCLogging.h"
59 #include "AliHLTTPCDisplay.h"
60 #include "AliHLTTPCTransform.h"
61 #include "AliHLTTPCTrack.h"
62 #include "AliHLTTPCTrackArray.h"
63 #include "AliHLTTPCSpacePointData.h"
64 #include "AliHLTTPCMemHandler.h"
65 #include "AliHLTTPCDigitReaderPacked.h"
71 ClassImp(AliHLTTPCDisplay)
73 // #############################################################################
74 void AliHLTTPCDisplay::InitDisplay(Char_t *gfile) {
76 memset(fClusters,0,36*6*sizeof(AliHLTTPCSpacePointData*));
77 memset(fNcl, 0, 36*6*sizeof(UInt_t));
85 fHistallresidualsY = NULL;
86 fHistallresidualsZ = NULL;
88 fGraphresidualsY = NULL;
89 fGraphresidualsZ = NULL;
90 fGraphresidualsYLength = NULL;
91 fGraphresidualsZLength = NULL;
95 // ---------------------------------------------------
96 // In order to be backward compatible
97 // ---------------------------------------------------
101 // ---------------------------------------------------
110 fSelectTrackSlice = 0;
111 fSelectTrackSwitch = kFALSE;
124 fSwitch3DCluster = kFALSE;
125 fSwitch3DTracks = kFALSE;
126 fSwitch3DPadRow = kFALSE;
127 fSwitch3DGeometry = kFALSE;
129 AliHLTTPCTransform::SetBField(0.4);
130 LoadGeometrie(gfile);
134 // #############################################################################
135 AliHLTTPCDisplay::~AliHLTTPCDisplay() {
137 if(fTracks) delete fTracks;
141 // #############################################################################
142 Bool_t AliHLTTPCDisplay::LoadGeometrie(Char_t *gfile) {
144 TFile *file = TFile::Open(gfile);
146 LOG(AliHLTTPCLog::kError,"AliHLTTPCDisplay::AliHLTTPCDisplay","File Open") <<"Geometry file " << gfile << " does not exist!"<<ENDLOG;
150 fGeom = (TGeometry*)file->Get("AliceGeom");
158 // #############################################################################
160 // #############################################################################
161 void AliHLTTPCDisplay::ExecPadRow(){
162 int event = gPad->GetEvent();
163 if (event != 11) return;
165 printf("TEST !!!!!!!!!!!!!!!");
166 /* int px = gPad->GetEventX();
167 TObject *select = gPad->GetSelected();
169 if (select->InheritsFrom("TH1")) {
170 TH1 *h = (TH1*)select;
171 Float_t xx = gPad->AbsPixeltoX(px);
172 Float_t x = gPad->PadtoX(xx);
173 Int_t binx = h->GetXaxis()->FindBin(x);
174 printf("event=%d, hist:%s, bin=%d, content=%f\n",event,h->GetName(),binx,h->GetBinContent(binx));
181 // #############################################################################
183 // #############################################################################
184 void AliHLTTPCDisplay::SetHistPadRowAxis() {
185 // Set Axis range of Histogramm, due to variable NPads per padrow
187 fNPads = AliHLTTPCTransform::GetNPads(fPadRow);
188 fHistrawcl->SetAxisRange(0,fNPads);
189 fHistraw->SetAxisRange(0,fNPads);
190 fHistrawcl->SetAxisRange(0,fNTimes,"Y");
191 fHistraw->SetAxisRange(0,fNTimes,"Y");
194 void AliHLTTPCDisplay::SetSliceArray() {
196 Int_t minSlice = fMinSlice;
197 Int_t maxSlice = fMaxSlice;
200 for (slice=0;slice<=35;slice++){
201 fSliceArray[slice] = kFALSE;
204 // Single Slice, or Range
205 if (minSlice > maxSlice) maxSlice += 17;
207 for (slice=minSlice;slice<=maxSlice;slice++){
208 realslice = slice % 18;
209 fSliceArray[realslice] = kTRUE;
210 fSliceArray[realslice+18] = kTRUE;
215 minSlice = fMinSlice + 9;
216 maxSlice = fMaxSlice + 9;
218 if (minSlice > maxSlice) maxSlice += 17;
220 for (slice=minSlice;slice<=maxSlice;slice++){
221 realslice = slice % 18;
222 fSliceArray[realslice] = kTRUE;
223 fSliceArray[realslice+18] = kTRUE;
228 // #############################################################################
230 // #############################################################################
231 void AliHLTTPCDisplay::SetupCluster(Int_t slice, Int_t patch, UInt_t nofClusters, AliHLTTPCSpacePointData* data) {
233 if (data && slice>=0 && slice<36 && patch>=0 && patch<AliHLTTPCTransform::GetNPatches()) {
234 if (fClusters[slice][patch]!=NULL) {
235 delete(fClusters[slice][patch]);
236 fClusters[slice][patch]=NULL;
238 Int_t arraysize=nofClusters*sizeof(AliHLTTPCSpacePointData);
239 fClusters[slice][patch] = (AliHLTTPCSpacePointData*)new Byte_t[arraysize];
240 if (fClusters[slice][patch]) {
241 memcpy(fClusters[slice][patch], data, arraysize);
242 fNcl[slice][patch]=nofClusters;
244 fNcl[slice][patch]=nofClusters;
245 LOG(AliHLTTPCLog::kError,"AliHLTTPCDisplay::SetupCluster","memory allocation") << "memory allocation failed "<<ENDLOG;
247 } else LOG(AliHLTTPCLog::kError,"AliHLTTPCDisplay::SetupCluster","argument check") << "invalid argument "<<ENDLOG;
250 // #############################################################################
251 void AliHLTTPCDisplay::SetupTracks(AliHLTTPCTrackArray *tracks) {
255 Int_t ntracks = fTracks->GetNTracks();
257 for(Int_t j=0; j<ntracks; j++) {
258 AliHLTTPCTrack *gtrack = fTracks->GetCheckedTrack(j);
259 if(!gtrack) continue;
261 Int_t nHits = gtrack->GetNHits();
262 UInt_t *hitnum = gtrack->GetHitNumbers();
264 for(Int_t h=0; h<nHits; h++){
267 Int_t slice = (id>>25) & 0x7f;
268 Int_t patch = (id>>22) & 0x7;
269 UInt_t pos = id&0x3fffff;
271 AliHLTTPCSpacePointData *points = fClusters[slice][patch];
274 LOG(AliHLTTPCLog::kError,"AliHLTTPCDisplay::Draw3D","Clusterarray") <<"No points at slice "<<slice<<" patch "<<patch<<" pos "<<pos<<ENDLOG;
278 if(pos>=fNcl[slice][patch]) {
279 LOG(AliHLTTPCLog::kError,"AliHLTTPCDisplay::Draw3D","Clusterarray") <<"Pos is too large: pos "<<pos <<" ncl "<<fNcl[slice][patch]<<ENDLOG;
282 points[pos].fUsed = kTRUE;
283 points[pos].fTrackN = j;
288 // #############################################################################
289 void AliHLTTPCDisplay::SetupHist(){
292 fNTimes = AliHLTTPCTransform::GetNTimeBins();
318 if ( fHistallresidualsY){
319 delete fHistallresidualsY;
320 fHistallresidualsY = NULL;
323 if ( fHistallresidualsZ){
324 delete fHistallresidualsZ;
325 fHistallresidualsZ = NULL;
332 // Setup the histograms
333 Int_t padbinning = maxpads*10;
334 fHistraw = new TH2F("fHistraw","Selected PadRow with found Clusters;Pad #;Timebin #",maxpads,0,maxpads-1,fNTimes,0,fNTimes-1);
335 fHistrawcl = new TH1F("fHistrawcl","",padbinning,0,maxpads-1);
336 fHistpad1 = new TH1F ("fHistpad1","Selected Pad -1;Timebin #",fNTimes,0,fNTimes-1);
337 fHistpad2 = new TH1F ("fHistpad2","Selected Pad;Timebin #",fNTimes,0,fNTimes-1);
338 fHistpad3 = new TH1F ("fHistpad3","Selected Pad +1;Timebin #",fNTimes,0,fNTimes-1);
339 fHistallresidualsY = new TH1F ("fHistallresiduals","Y Residuals of all Tracks in selected slices;residuals",5000,-100,100);
340 fHistallresidualsZ = new TH1F ("fHistallresiduals","Z Residuals of all Tracks in selected slices;residuals",5000,-100,100);
341 fHistcharge = new TH1F ("fHistcharge","Cluster distribution per charge;charge;#cluster",5000,0,30000);
343 fHistraw->SetOption("COLZ");
345 fHistallresidualsY->SetTitleSize(0.03);
346 fHistallresidualsY->GetXaxis()->SetLabelSize(0.03);
347 fHistallresidualsY->GetXaxis()->SetTitleSize(0.03);
348 fHistallresidualsY->GetYaxis()->SetLabelSize(0.03);
349 fHistallresidualsY->GetYaxis()->SetTitleSize(0.03);
351 fHistallresidualsZ->SetTitleSize(0.03);
352 fHistallresidualsZ->GetXaxis()->SetLabelSize(0.03);
353 fHistallresidualsZ->GetXaxis()->SetTitleSize(0.03);
354 fHistallresidualsZ->GetYaxis()->SetLabelSize(0.03);
355 fHistallresidualsZ->GetYaxis()->SetTitleSize(0.03);
357 fHistcharge->SetTitleSize(0.03);
358 fHistcharge->GetXaxis()->SetLabelSize(0.03);
359 fHistcharge->GetXaxis()->SetTitleSize(0.03);
360 fHistcharge->GetYaxis()->SetLabelSize(0.03);
361 fHistcharge->GetYaxis()->SetTitleSize(0.03);
363 fHistraw->SetTitleSize(0.03);
364 fHistraw->GetXaxis()->SetLabelSize(0.03);
365 fHistraw->GetXaxis()->SetTitleSize(0.03);
366 fHistraw->GetYaxis()->SetLabelSize(0.03);
367 fHistraw->GetYaxis()->SetTitleSize(0.03);
369 fHistpad1->SetTitleSize(0.03);
370 fHistpad1->GetXaxis()->SetLabelSize(0.03);
371 fHistpad1->GetXaxis()->SetTitleSize(0.03);
372 fHistpad1->GetYaxis()->SetLabelSize(0.03);
373 fHistpad1->GetYaxis()->SetTitleSize(0.03);
375 fHistpad2->SetTitleSize(0.03);
376 fHistpad2->GetXaxis()->SetLabelSize(0.03);
377 fHistpad2->GetXaxis()->SetTitleSize(0.03);
378 fHistpad2->GetYaxis()->SetLabelSize(0.03);
379 fHistpad2->GetYaxis()->SetTitleSize(0.03);
381 fHistpad3->SetTitleSize(0.03);
382 fHistpad3->GetXaxis()->SetLabelSize(0.03);
383 fHistpad3->GetXaxis()->SetTitleSize(0.03);
384 fHistpad3->GetYaxis()->SetLabelSize(0.03);
385 fHistpad3->GetYaxis()->SetTitleSize(0.03);
387 gStyle->SetPalette(1);
392 // ####################################################################################################
393 void AliHLTTPCDisplay::FillPadRow(Int_t patch, ULong_t dataBlock, ULong_t dataLen){
394 #if defined(HAVE_ALIRAWDATA) && defined(HAVE_ALITPCRAWSTREAM_H)
395 AliHLTTPCDigitReader* digitReader = new AliHLTTPCDigitReaderPacked();
396 bool readValue = true;
399 // Initialize RAW DATA
400 Int_t firstRow = AliHLTTPCTransform::GetFirstRow(patch);
401 Int_t lastRow = AliHLTTPCTransform::GetLastRow(patch);
403 // Outer sector, patches 2, 3, 4, 5 - start counting in patch 2 with row 0
404 if ( patch >= 2 ) rowOffset = AliHLTTPCTransform::GetFirstRow( 2 );
406 // Initialize block for reading packed data
407 void* tmpdataBlock = (void*) dataBlock;
408 digitReader->InitBlock(tmpdataBlock,dataLen,firstRow,lastRow,patch,0);
410 readValue = digitReader->Next();
413 LOG(AliHLTTPCLog::kError,"AliHLTTPCDisplay::FillPadRow","Read first value") << "No value in data block" << ENDLOG;
417 // FILL PADROW 3D --- Initialize the colorbins
418 if (fSwitch3DPadRow){
419 for (UInt_t ii=0;ii < 20;ii++){
424 // read number of entries in colorbin
427 Int_t row = digitReader->GetRow() + rowOffset;
430 UInt_t charge = digitReader->GetSignal();
432 for (UInt_t ii=0;ii < 19;ii++){
433 if ( charge > (ii*15) && charge <= ((ii*15) + 15) ) fcolorbin[ii]++;
435 // larger than 19 * 15
436 if (charge > 285 ) fcolorbin[19]++;
440 readValue = digitReader->Next();
442 if(!readValue) break; //No more value
444 //Initialize fpmarr[color][3*colorbin[ii]]
445 fpmarr[0] = new Float_t[fcolorbin[0]*3];
446 fpmarr[1] = new Float_t[fcolorbin[1]*3];
447 fpmarr[2] = new Float_t[fcolorbin[2]*3];
448 fpmarr[3] = new Float_t[fcolorbin[3]*3];
449 fpmarr[4] = new Float_t[fcolorbin[4]*3];
450 fpmarr[5] = new Float_t[fcolorbin[5]*3];
451 fpmarr[6] = new Float_t[fcolorbin[6]*3];
452 fpmarr[7] = new Float_t[fcolorbin[7]*3];
453 fpmarr[8] = new Float_t[fcolorbin[8]*3];
454 fpmarr[9] = new Float_t[fcolorbin[9]*3];
455 fpmarr[10] = new Float_t[fcolorbin[10]*3];
456 fpmarr[11] = new Float_t[fcolorbin[11]*3];
457 fpmarr[12] = new Float_t[fcolorbin[12]*3];
458 fpmarr[13] = new Float_t[fcolorbin[13]*3];
459 fpmarr[14] = new Float_t[fcolorbin[14]*3];
460 fpmarr[15] = new Float_t[fcolorbin[15]*3];
461 fpmarr[16] = new Float_t[fcolorbin[16]*3];
462 fpmarr[17] = new Float_t[fcolorbin[17]*3];
463 fpmarr[18] = new Float_t[fcolorbin[18]*3];
464 fpmarr[19] = new Float_t[fcolorbin[19]*3];
466 // Rewind the raw reader and fill the polymarker3D
467 digitReader->InitBlock(tmpdataBlock,dataLen,firstRow,lastRow,patch,0);
469 readValue = digitReader->Next();
470 } // END if (fSwitch3DPadRow)
475 Int_t row = digitReader->GetRow() + rowOffset;
477 // select padrow to fill in histogramm
479 UChar_t pad = digitReader->GetPad();
480 UShort_t time = digitReader->GetTime();
481 UInt_t charge = digitReader->GetSignal();
483 fHistraw->Fill(pad,time,charge);
485 if (pad == (fPad-1) ) fHistpad1->Fill(time,charge);
486 if (pad == fPad) fHistpad2->Fill(time,charge);
487 if (pad == (fPad+1) ) fHistpad3->Fill(time,charge);
489 if (fSwitch3DPadRow) {
490 // Transform raw coordinates to local coordinates
491 AliHLTTPCTransform::RawHLT2Global(xyz, fSlicePadRow, fPadRow, pad, time);
493 for (UInt_t ii=0;ii < 19;ii++){
494 if ( charge > (ii*15) && charge <= ((ii*15) + 15) ){
495 fpmarr[ii][fbinct[ii]] = xyz[0];
496 fpmarr[ii][fbinct[ii]+1] = xyz[1];
497 fpmarr[ii][fbinct[ii]+2] = xyz[2];
501 // larger than 19 * 15
503 fpmarr[19][fbinct[19]] = xyz[0];
504 fpmarr[19][fbinct[19]+1] = xyz[1];
505 fpmarr[19][fbinct[19]+2] = xyz[2];
508 } // END if (fSwitch3DPadRow)
513 readValue = digitReader->Next();
515 //Check where to stop:
516 if(!readValue) break; //No more value
523 AliHLTTPCSpacePointData *points = fClusters[fSlicePadRow][patch];
525 Int_t npoints = fNcl[fSlicePadRow][patch];
528 for(Int_t i=0; i<npoints; i++){
529 xyz[0] = points[i].fX;
530 xyz[1] = points[i].fY;
531 xyz[2] = points[i].fZ;
533 Int_t clrow = AliHLTTPCTransform::GetPadRow(xyz[0]);
534 // select padrow to fill in histogramm
535 if (clrow == fPadRow){
536 AliHLTTPCTransform::LocHLT2Raw(xyz, fSlicePadRow, fPadRow);
537 fHistrawcl->Fill(xyz[1],xyz[2]);
540 #else //! if defined(HAVE_ALIRAWDATA) && defined(HAVE_ALITPCRAWSTREAM_H)
541 HLTFatal("DigitReaderPacked not available - check your build");
542 #endif //defined(HAVE_ALIRAWDATA) && defined(HAVE_ALITPCRAWSTREAM_H)
545 // #############################################################################
546 void AliHLTTPCDisplay::ResetHistPadRow(){
554 // #############################################################################
555 void AliHLTTPCDisplay::ResetHistResiduals(){
556 fHistallresidualsY->Reset();
557 fHistallresidualsZ->Reset();
560 // #############################################################################
561 void AliHLTTPCDisplay::ResetHistCharge(){
562 fHistcharge->Reset();
566 // #############################################################################
568 // #############################################################################
569 void AliHLTTPCDisplay::DrawGeomSector(Int_t sector) {
571 Int_t realsector = sector;// % 18;
573 if (realsector < 10){
574 sprintf(fname,"LS0%d",realsector);
575 fGeom->GetNode(fname)->SetLineColor(fLineColor);
576 fGeom->GetNode(fname)->Draw("same");
577 sprintf(fname,"US0%d",realsector);
578 fGeom->GetNode(fname)->SetLineColor(fLineColor);
579 fGeom->GetNode(fname)->Draw("same");
582 sprintf(fname,"LS%d",realsector);
583 fGeom->GetNode(fname)->SetLineColor(fLineColor);
584 fGeom->GetNode(fname)->Draw("same");
585 sprintf(fname,"US%d",realsector);
586 fGeom->GetNode(fname)->SetLineColor(fLineColor);
587 fGeom->GetNode(fname)->Draw("same");
590 // #############################################################################
591 void AliHLTTPCDisplay::DrawHistPadRow(){
593 sprintf(title,"Selected PadRow %d with found Clusters",fPadRow);
595 fHistraw->SetTitle(title);
596 fHistraw->SetStats(kFALSE);
597 fHistraw->Draw("COLZ");
599 fHistrawcl->SetStats(kFALSE);
600 fHistrawcl->SetMarkerStyle(28);
601 fHistrawcl->SetMarkerSize(2);
602 fHistrawcl->SetMarkerColor(1);
603 fHistrawcl->Draw("psame");
606 // #############################################################################
607 void AliHLTTPCDisplay::DrawHistPad1(){
609 sprintf(title,"Selected Pad %d",fPad -1);
610 fHistpad1->SetStats(kFALSE);
611 fHistpad1->SetTitle(title);
615 // #############################################################################
616 void AliHLTTPCDisplay::DrawHistPad2(){
618 sprintf(title,"Selected Pad %d",fPad);
620 fHistpad2->SetStats(kFALSE);
621 fHistpad2->SetTitle(title);
625 // #############################################################################
626 void AliHLTTPCDisplay::DrawHistPad3(){
628 sprintf(title,"Selected Pad %d",fPad +1);
630 fHistpad3->SetStats(kFALSE);
631 fHistpad3->SetTitle(title);
635 // #############################################################################
636 void AliHLTTPCDisplay::DrawHistResiduals(Bool_t ySwitch){
637 if (fSwitch3DTracks){
639 // Y Residual histogram for 1 track
641 if (fSelectTrackSwitch){
643 sprintf(title,"Y Residuals of Track %d in Slice %d",fSelectTrack, fSelectTrackSlice );
645 TMultiGraph *mgY = new TMultiGraph();
648 // fGraphresidualsY->SetTitle(title);
649 fGraphresidualsY->GetXaxis()->SetTitle("padrow");
650 fGraphresidualsY->GetYaxis()->SetTitle("residuals");
651 // fGraphresidualsY->Draw("A*");
652 fGraphresidualsY->GetXaxis()->SetLabelSize(0.02);
653 fGraphresidualsY->GetXaxis()->SetTitleSize(0.02);
654 fGraphresidualsY->GetYaxis()->SetLabelSize(0.02);
655 fGraphresidualsY->GetYaxis()->SetTitleSize(0.02);
656 fGraphresidualsYLength->SetMarkerColor(2);
657 fGraphresidualsYLength->SetMarkerStyle(5);
658 fGraphresidualsY->SetMarkerColor(1);
659 fGraphresidualsY->SetMarkerStyle(3);
661 // fGraphresidualsY->Draw("A*");
662 // fGraphresidualsYLength->Draw("*");
664 mgY->Add(fGraphresidualsY);
665 mgY->Add(fGraphresidualsYLength);
666 mgY->SetTitle(title);
667 // mgY->GetXaxis()->SetTitle("padrow");
668 // mgY->GetYaxis()->SetTitle("residuals");
671 // Global residuals histogram
673 fHistallresidualsY->SetStats(kFALSE);
674 fHistallresidualsY->Draw();
678 // Z Residual histogram for 1 track
679 if (fSelectTrackSwitch){
681 sprintf(title,"Z Residuals of Track %d in Slice %d",fSelectTrack, fSelectTrackSlice );
683 TMultiGraph *mgZ = new TMultiGraph();
685 fGraphresidualsZ->SetTitle(title);
686 fGraphresidualsZ->GetXaxis()->SetTitle("padrow");
687 fGraphresidualsZ->GetYaxis()->SetTitle("residuals");
688 fGraphresidualsZ->GetXaxis()->SetLabelSize(0.02);
689 fGraphresidualsZ->GetXaxis()->SetTitleSize(0.02);
690 fGraphresidualsZ->GetYaxis()->SetLabelSize(0.02);
691 fGraphresidualsZ->GetYaxis()->SetTitleSize(0.02);
692 // fGraphresidualsZLength->Draw("F*");
693 // fGraphresidualsZ->Draw("A*");
695 mgZ->Add(fGraphresidualsZ);
696 // mgZ->Add(fGraphresidualsZLength);
697 mgZ->SetTitle(title);
700 // Global residuals histogram
702 fHistallresidualsZ->SetStats(kFALSE);
703 fHistallresidualsZ->Draw();
709 // #############################################################################
710 void AliHLTTPCDisplay::DrawHistCharge(){
711 if (fSwitch3DCluster){
712 // fHistcharge->SetStats(kFALSE);
717 // #############################################################################
718 void AliHLTTPCDisplay::Draw3D(){
720 #if defined(HAVE_TVIEW3D_H)
721 TView3D *v = new TView3D();
722 if (v) v->SetSystem(1);
724 TView *v = new TView(1);
727 HLTFatal("can not create viewer");
730 v->SetRange(-800,-800,-800,800,800,800);
732 Float_t* etaRange = NULL; // ------ STILL TO FIX
735 //--------------------------------------------------------------------------------------------
737 //--------------------------------------------------------------------------------------------
738 if (fSwitch3DCluster){
741 for (Int_t slice=0; slice <= 35; slice++){
743 Int_t currenttrack = -1;
745 if (fSelectCluster == 1 && fSelectTrackSwitch && slice == fSelectTrackSlice ){
747 Int_t trackcounter = 0;
748 Int_t ntracks = fTracks->GetNTracks();
750 for(Int_t j=0; j<ntracks; j++) {
752 AliHLTTPCTrack *gtrack = fTracks->GetCheckedTrack(j);
753 if(!gtrack) continue;
755 Int_t nHits = gtrack->GetNHits(); // Number of associated hits to track
756 Int_t tmpslice = gtrack->GetSector();
758 // --- CHECK if track is should be drawn
759 // select Single Track
760 if(tmpslice != fSelectTrackSlice) continue;
762 if (trackcounter != fSelectTrack){
768 if((fPtThreshold > 0) && (gtrack->GetPt()< fPtThreshold)) continue;
769 if(nHits < fMinHits) continue;
776 if (!fSliceArray[slice]) continue;
778 for(Int_t p=0;p<6;p++){
780 AliHLTTPCSpacePointData *points = fClusters[slice][p];
781 if(!points) continue;
782 Int_t npoints = fNcl[slice][p];
783 TPolyMarker3D *pmUsed = new TPolyMarker3D(1,6);
784 TPolyMarker3D *pmUnused = new TPolyMarker3D(1,6);
785 Int_t nUsedCluster = 0;
786 Int_t nUnusedCluster = 0;
789 for(Int_t i=0; i<npoints; i++){
791 if (fSelectCluster == 1 && points[i].fUsed == kFALSE) continue;
792 // Unused cluster only
793 if (fSelectCluster == 2 && points[i].fUsed == kTRUE) continue;
795 // if single track is selcted draw only cluster for this track
796 if (fSelectCluster == 1 && fSelectTrackSwitch && points[i].fTrackN != currenttrack) continue;
798 xyz[0] = points[i].fX;
799 xyz[1] = points[i].fY;
800 xyz[2] = points[i].fZ;
803 // Do this before the transform, because the tracker also uses
804 // local coordinates when using this limit to determine
805 // which clusters to use for tracking
806 Double_t pointEta = AliHLTTPCTransform::GetEta( xyz );
807 if ( pointEta<etaRange[0] || pointEta>etaRange[1] )
811 AliHLTTPCTransform::Local2Global(xyz,slice);
813 if (points[i].fUsed == kTRUE){
814 pmUsed->SetPoint(nUsedCluster,xyz[0],xyz[1],xyz[2]);
818 pmUnused->SetPoint(nUnusedCluster,xyz[0],xyz[1],xyz[2]);
822 // Fill Charge Histogram
823 fHistcharge->Fill(points[i].fCharge);
824 if ((Int_t)points[i].fCharge > maxCharge ) maxCharge = (Int_t) points[i].fCharge;
826 pmUsed->SetMarkerSize(1);
827 pmUsed->SetMarkerColor(3);
830 pmUnused->SetMarkerSize(1);
831 pmUnused->SetMarkerColor(2);
833 } // END - PATCH LOOP
834 } // END - SLICE LOOP
835 fHistcharge->SetAxisRange(0,maxCharge);
836 } // END - DRAW 3D CLUSTER
838 //--------------------------------------------------------------------------------------------
840 //--------------------------------------------------------------------------------------------
841 if (fSwitch3DTracks){
843 Int_t trackcounter = 0;
844 Int_t ntracks = fTracks->GetNTracks();
845 Double_t drawStep = 0.2;
847 Double_t maxResidualY = 0.;
848 Double_t maxResidualZ = 0.;
850 TPolyLine3D *line = new TPolyLine3D[ntracks];
852 THelix *helix = new THelix[ntracks];
854 for(Int_t j=0; j<ntracks; j++) {
856 AliHLTTPCTrack *gtrack = fTracks->GetCheckedTrack(j);
857 if(!gtrack) continue;
859 Int_t nHits = gtrack->GetNHits(); // Number of associated hits to track
860 Int_t slice = gtrack->GetSector();
862 // --- CHECK if track is should be drawn
863 // select if slice should be displayed or not
864 if (!fSliceArray[slice]) continue;
866 // select Single Track
867 if (fSelectTrackSwitch){
868 if(slice != fSelectTrackSlice) continue;
870 if (trackcounter != fSelectTrack){
877 if((fPtThreshold > 0) && (gtrack->GetPt()< fPtThreshold)) continue;
878 if(nHits < fMinHits) continue;
880 TPolyMarker3D *pmL = new TPolyMarker3D(1,2);
881 TPolyMarker3D *pmF = new TPolyMarker3D(1,2);
883 Double_t radius = gtrack->GetRadius(); // radius
884 Double_t kappa = gtrack->GetKappa(); // curvature = 1/R , signed
885 Double_t lambda = atan( gtrack->GetTgl() ); // dipAngle lambda
886 Double_t phi0 = gtrack->GetPsi() + (gtrack->GetCharge() * AliHLTTPCTransform::PiHalf() ); // azimuthal angle of startingpoint, with respect to helix axis
888 Double_t xyzL[3]; // lastpoint of track
889 Double_t xyzF[3]; // firstpoint of track
891 xyzF[0] = gtrack->GetFirstPointX();
892 xyzF[1] = gtrack->GetFirstPointY();
893 xyzF[2] = gtrack->GetFirstPointZ();
894 pmF->SetPoint(0,xyzF[0],xyzF[1],xyzF[2]);
896 xyzL[0] = gtrack->GetLastPointX();
897 xyzL[1] = gtrack->GetLastPointY();
898 xyzL[2] = gtrack->GetLastPointZ();
899 pmL->SetPoint(0,xyzL[0],xyzL[1],xyzL[2]);
901 Double_t s = 0.; // length of the track
903 // Calculate the length of the track. If it is to flat in in s,z plane use sxy, otherwise use sz
904 if (fabs(lambda) > 0.05){
905 // length of track calculated out of z
906 s = fabs( (xyzL[2] - xyzF[2]) / sin(lambda) ); // length of track calculated out of z
909 Double_t d = (xyzL[0] - xyzF[0])*(xyzL[0] - xyzF[0]) + (xyzL[1] - xyzF[1])*(xyzL[1] - xyzF[1]);
910 // length of track calculated out of xy
911 s = fabs ( acos( 0.5 * (2 - (d / (radius*radius)))) / ( kappa * cos(lambda) ) );
914 Int_t nTrackPoints = 2 + (Int_t) floor(s / drawStep);
917 TPolyMarker3D *pmT = new TPolyMarker3D(nTrackPoints,6);
920 Double_t *xT = new Double_t[nTrackPoints];
921 Double_t *yT = new Double_t[nTrackPoints];
922 Double_t *zT = new Double_t[nTrackPoints];
924 //Write Track Parameters for single track
925 if (fSelectTrackSwitch){
926 fTrackParam.id = trackcounter - 1;
927 fTrackParam.nHits = nHits;
928 fTrackParam.charge = gtrack->GetCharge();
929 fTrackParam.lambda = lambda;
930 fTrackParam.kappa = kappa;
931 fTrackParam.radius = radius;
932 fTrackParam.slice = slice;
933 fTrackParam.phi0 = phi0;
934 fTrackParam.pt = gtrack->GetPt();
935 fTrackParam.bfield = AliHLTTPCTransform::GetBFieldValue();
936 fTrackParam.xyzF[0] = gtrack->GetFirstPointX();
937 fTrackParam.xyzF[1] = gtrack->GetFirstPointY();
938 fTrackParam.xyzF[2] = gtrack->GetFirstPointZ();
939 fTrackParam.xyzL[0] = gtrack->GetLastPointX();
940 fTrackParam.xyzL[1] = gtrack->GetLastPointY();
941 fTrackParam.xyzL[2] = gtrack->GetLastPointZ();
942 fTrackParam.psi = gtrack->GetPsi();
946 Int_t trackPointCounter = 0;
948 for (Double_t ds = 0.; ds < s; ds = ds + drawStep){
949 // FILL ARRAYS IN ORDER TO DRAW THE TRACKPOINTS, OUT OF THE PARAMETER
950 xT[trackPointCounter] = xyzF[0] + radius * ( cos( phi0 + (ds*kappa*cos(lambda)) ) - cos(phi0) );
951 yT[trackPointCounter] = xyzF[1] + radius * ( sin( phi0 + (ds*kappa*cos(lambda)) ) - sin(phi0) );
952 zT[trackPointCounter] = xyzF[2] + ds * sin(lambda);
954 pmT->SetPoint(trackPointCounter,xT[trackPointCounter],yT[trackPointCounter],zT[trackPointCounter]);
959 xT[trackPointCounter] = xyzF[0] + radius * ( cos( phi0 + (s*kappa*cos(lambda)) ) - cos(phi0) );
960 yT[trackPointCounter] = xyzF[1] + radius * ( sin( phi0 + (s*kappa*cos(lambda)) ) - sin(phi0) );
961 zT[trackPointCounter] = xyzF[2] + s * sin(lambda);
963 pmT->SetPoint(trackPointCounter,xT[trackPointCounter],yT[trackPointCounter],zT[trackPointCounter]);
966 gtrack->Rotate(slice,kTRUE);
967 Int_t nRes = 0; // number of resiudals
969 UInt_t *hitnum = gtrack->GetHitNumbers();
971 Double_t *resY= new Double_t[nHits];
972 Double_t *resZ= new Double_t[nHits];
974 Double_t *resYLength= new Double_t[2*nHits];
975 Double_t *resZLength= new Double_t[2*nHits];
977 Double_t *padrows = new Double_t[nHits];
978 Double_t *padrowsLength = new Double_t[2*nHits];
980 for(Int_t h=0; h<nHits; h++){
982 Int_t patch = (id>>22) & 0x7;
983 UInt_t pos = id&0x3fffff;
985 AliHLTTPCSpacePointData *points = fClusters[slice][patch];
987 Float_t xyzCtmp[3]; // cluster tmp
988 Float_t xyzTtmp[3]; // track tmp
990 xyzCtmp[0] = points[pos].fX;
991 xyzCtmp[1] = points[pos].fY;
992 xyzCtmp[2] = points[pos].fZ;
994 Int_t padrow = AliHLTTPCTransform::GetPadRow(points[pos].fX);
995 xyzTtmp[0] = gtrack->GetFirstPointX();
996 if(gtrack->GetCrossingPoint(padrow,xyzTtmp)) {
998 Float_t deltaY = ( xyzCtmp[1] - xyzTtmp[1] );
999 Float_t deltaZ = ( xyzCtmp[2] - xyzTtmp[2] );
1000 // Float_t residual = sqrt( deltaY*deltaY + deltaZ*deltaZ );
1002 padrows[nRes] = (Double_t) padrow;
1003 resY[nRes] = (Double_t) deltaY;
1004 resZ[nRes] = (Double_t) deltaZ;
1006 resYLength[(2*nRes)] = 0.5 * AliHLTTPCTransform::GetPadLength(padrow);
1007 resYLength[(2*nRes)+1] = -0.5 * AliHLTTPCTransform::GetPadLength(padrow);
1008 resZLength[nRes] = AliHLTTPCTransform::GetZLength();
1009 padrowsLength[(2*nRes)] = (Double_t) padrow;
1010 padrowsLength[(2*nRes)+1] = (Double_t) padrow;
1012 // FILL RESIDUALS HISTOGRAM
1013 fHistallresidualsY->Fill(resY[nRes]);
1014 fHistallresidualsZ->Fill(resZ[nRes]);
1015 if (resY[nRes] > maxResidualY ) maxResidualY = resY[nRes];
1016 if (resZ[nRes] > maxResidualZ ) maxResidualZ = resZ[nRes];
1021 gtrack->Rotate(slice,kFALSE);
1022 // --- RESIDUALS ---
1024 // Draw last point of Track
1025 pmL->SetMarkerSize(3);
1026 pmL->SetMarkerColor(4);
1029 // Draw first point of Track
1030 pmF->SetMarkerSize(3);
1031 pmF->SetMarkerColor(5);
1035 // Draw Track -- as polymarker
1036 pmT->SetMarkerSize(3);
1037 pmT->SetMarkerColor(3);
1040 // Draw Track -- as line
1041 TPolyLine3D *currentline = &(line[j]);
1042 currentline = new TPolyLine3D(nTrackPoints,xT,yT,zT,"");
1043 currentline->SetLineColor(4);
1044 currentline->SetLineWidth(2);
1045 currentline->Draw("same");
1048 // Draw Track -- as helix
1049 // works ok, execpt for very small dipangles -> track almost horizontal
1053 hrange[0] = xyzF[2];
1054 hrange[1] = xyzL[2];
1055 v0[0] = gtrack->GetPx();
1056 v0[1] = gtrack->GetPy();
1057 v0[2] = gtrack->GetPz();
1058 omega = AliHLTTPCTransform::GetBFieldValue() * gtrack->GetCharge();
1060 THelix *currenthelix = &(helix[j]);
1061 currenthelix = new THelix(xyzF,v0,omega,hrange,kHelixZ,0);
1062 currenthelix->SetLineColor(6);
1063 currenthelix->SetLineWidth(1);
1064 currenthelix->Draw("same");
1068 if ( fGraphresidualsY){
1069 delete fGraphresidualsY;
1070 fGraphresidualsY = NULL;
1073 if ( fGraphresidualsZ){
1074 delete fGraphresidualsZ;
1075 fGraphresidualsZ = NULL;
1078 if ( fGraphresidualsYLength){
1079 delete fGraphresidualsYLength;
1080 fGraphresidualsYLength = NULL;
1083 if ( fGraphresidualsZLength){
1084 delete fGraphresidualsZLength;
1085 fGraphresidualsZLength = NULL;
1090 // FILL Y RESIDUALS GRAPH
1091 fGraphresidualsY = new TGraph(nRes-1,padrows,resY);
1092 fGraphresidualsYLength = new TGraph((2*nRes)-2,padrowsLength,resYLength);
1093 // FILL Z RESIDUALS GRAPH
1094 fGraphresidualsZ = new TGraph(nRes-1,padrows,resZ);
1095 fGraphresidualsZLength = new TGraph(nRes-1,padrows,resZLength);
1103 fHistallresidualsY->SetAxisRange(-maxResidualY,maxResidualY);
1104 fHistallresidualsZ->SetAxisRange(-maxResidualZ,maxResidualZ);
1106 } // END - DRAW 3D Tracks
1108 //--------------------------------------------------------------------------------------------
1110 //--------------------------------------------------------------------------------------------
1111 if (fSwitch3DGeometry){
1113 for (Int_t slice=0; slice <= 17; slice++){
1114 if (!fSliceArray[slice]) continue;
1115 DrawGeomSector(slice);
1117 } // END - DRAW 3D GEOMETRY
1119 //--------------------------------------------------------------------------------------------
1121 //--------------------------------------------------------------------------------------------
1122 if (fSwitch3DPadRow && fSliceArray[fSlicePadRow]){
1123 Int_t markercolor = 51;
1125 for (UInt_t ii=0;ii < 20;ii++){
1126 if (fcolorbin[ii]> 0){
1128 TPolyMarker3D *pm = new TPolyMarker3D(fcolorbin[ii], fpmarr[ii], 7 );
1130 pm->SetMarkerColor(markercolor);
1134 // in order to have the SetPalette(1), so called "pretty"
1135 if (ii % 2 == 0 ) markercolor += 2;
1136 else markercolor += 3;
1140 //--------------------------------------------------------------------------------------------
1142 //--------------------------------------------------------------------------------------------
1147 // ---------------------------------------------------
1148 // In order to be backward compatible
1149 // ---------------------------------------------------
1151 void AliHLTTPCDisplay::DisplayClusters(Bool_t x3don,Float_t* etaRange) {
1153 fc1 = new TCanvas("c1","",900,900);
1157 fSwitch3DTracks = kFALSE;
1158 fSwitch3DCluster = kTRUE;
1159 fSwitch3DPadRow = kFALSE;
1160 fSwitch3DGeometry = kFALSE;
1164 // ---------------------------------------------------
1165 void AliHLTTPCDisplay::DisplayTracks(Int_t minhits,Bool_t x3don,Float_t thr) {
1167 fc1 = new TCanvas("c1","",900,900);
1173 fSwitch3DTracks = kTRUE;
1174 fSwitch3DCluster = kFALSE;
1175 fSwitch3DPadRow = kFALSE;
1176 fSwitch3DGeometry = kFALSE;
1180 // ---------------------------------------------------
1181 void AliHLTTPCDisplay::DisplayAll(Int_t minhits,Bool_t clusterswitch,Bool_t trackswitch,Bool_t x3don, Float_t thr, Float_t* etaRange){
1183 fc1 = new TCanvas("c1","",900,900);
1189 fSwitch3DTracks = trackswitch;
1190 fSwitch3DCluster = clusterswitch;
1191 fSwitch3DPadRow = kFALSE;
1192 fSwitch3DGeometry = kFALSE;
1197 // ---------------------------------------------------