2 // Original: AliHLTDisplay.cxx,v 1.26 2005/06/14 10:55:21 cvetan
4 //*************************************************************************
5 // This file is property of and copyright by the ALICE HLT Project *
6 // ALICE Experiment at CERN, All rights reserved. *
8 // Primary Authors: Jochen Thaeder <mailto:thaeder@kip.uni-heidelberg.de> *
10 // for The ALICE HLT Project. *
12 // Permission to use, copy, modify and distribute this software and its *
13 // documentation strictly for non-commercial purposes is hereby granted *
14 // without fee, provided that the above copyright notice appears in all *
15 // copies and that both the copyright notice and this permission notice *
16 // appear in the supporting documentation. The authors make no claims *
17 // about the suitability of this software for any purpose. It is *
18 // provided "as is" without express or implied warranty. *
19 //*************************************************************************/
21 /** @file AliHLTTPCDisplay.cxx
22 @author Jochen Thaeder, Anders Vestbo
24 @brief Display class for the HLT TPC events.
28 #define TRACKPOLYMARKER 0
30 #define FIRSTLASTPOINT 0
33 #define USEDCLUSTERCOLOR
34 #define UNUSEDCLUSTERCOLOR
36 #include "AliHLTStdIncludes.h"
37 #if defined(HAVE_TVIEW3D_H)
42 #include <TPolyMarker3D.h>
43 #include <TPolyLine3D.h>
47 #include <TGeometry.h>
49 #include <TParticle.h>
54 #include <TMultiGraph.h>
63 #include <TClonesArray.h>
65 #include <AliSimDigits.h>
66 #include <AliTPCParam.h>
69 #include "AliHLTTPCLogging.h"
70 #include "AliHLTTPCDisplay.h"
71 #include "AliHLTTPCTransform.h"
72 #include "AliHLTTPCTrack.h"
73 #include "AliHLTTPCTrackArray.h"
74 #include "AliHLTTPCSpacePointData.h"
75 #include "AliHLTTPCMemHandler.h"
76 #include "AliHLTTPCDigitReaderPacked.h"
82 ClassImp(AliHLTTPCDisplay);
84 AliHLTTPCDisplay::AliHLTTPCDisplay( Char_t * gfile ) :
94 fHistallresidualsY(NULL),
95 fHistallresidualsZ(NULL),
97 fGraphresidualsY(NULL),
98 fGraphresidualsZ(NULL),
99 fGraphresidualsYLength(NULL),
100 fGraphresidualsZLength(NULL),
112 fSelectTrackSwitch(kFALSE),
114 fSelectTrackSlice(0),
124 fSwitch3DCluster(kFALSE),
125 fSwitch3DTracks(kFALSE),
126 fSwitch3DPadRow(kFALSE),
127 fSwitch3DGeometry(kFALSE)
133 // #############################################################################
134 void AliHLTTPCDisplay::InitDisplay(Char_t *gfile) {
136 memset(fClusters,0,36*6*sizeof(AliHLTTPCSpacePointData*));
137 memset(fNcl, 0, 36*6*sizeof(UInt_t));
139 // ---------------------------------------------------
140 // In order to be backward compatible
141 // ---------------------------------------------------
145 // ---------------------------------------------------
149 AliHLTTPCTransform::SetBField(0.4);
151 LoadGeometrie(gfile);
155 // #############################################################################
156 AliHLTTPCDisplay::~AliHLTTPCDisplay() {
158 if(fTracks) delete fTracks;
162 // #############################################################################
163 Bool_t AliHLTTPCDisplay::LoadGeometrie(Char_t *gfile) {
165 TFile *file = TFile::Open(gfile);
167 LOG(AliHLTTPCLog::kError,"AliHLTTPCDisplay::AliHLTTPCDisplay","File Open") <<"Geometry file " << gfile << " does not exist!"<<ENDLOG;
171 fGeom = (TGeometry*)file->Get("AliceGeom");
179 // #############################################################################
181 // #############################################################################
182 void AliHLTTPCDisplay::ExecPadRow(){
183 int event = gPad->GetEvent();
184 if (event != 11) return;
186 printf("TEST !!!!!!!!!!!!!!!");
187 /* int px = gPad->GetEventX();
188 TObject *select = gPad->GetSelected();
190 if (select->InheritsFrom("TH1")) {
191 TH1 *h = (TH1*)select;
192 Float_t xx = gPad->AbsPixeltoX(px);
193 Float_t x = gPad->PadtoX(xx);
194 Int_t binx = h->GetXaxis()->FindBin(x);
195 printf("event=%d, hist:%s, bin=%d, content=%f\n",event,h->GetName(),binx,h->GetBinContent(binx));
202 // #############################################################################
204 // #############################################################################
205 void AliHLTTPCDisplay::SetHistPadRowAxis() {
206 // Set Axis range of Histogramm, due to variable NPads per padrow
208 fNPads = AliHLTTPCTransform::GetNPads(fPadRow);
209 fHistrawcl->SetAxisRange(0,fNPads);
210 fHistraw->SetAxisRange(0,fNPads);
211 fHistrawcl->SetAxisRange(0,fNTimes,"Y");
212 fHistraw->SetAxisRange(0,fNTimes,"Y");
215 void AliHLTTPCDisplay::SetSliceArray() {
217 Int_t minSlice = fMinSlice;
218 Int_t maxSlice = fMaxSlice;
221 for (slice=0;slice<=35;slice++){
222 fSliceArray[slice] = kFALSE;
225 // Single Slice, or Range
226 if (minSlice > maxSlice) maxSlice += 17;
228 for (slice=minSlice;slice<=maxSlice;slice++){
229 realslice = slice % 18;
230 fSliceArray[realslice] = kTRUE;
231 fSliceArray[realslice+18] = kTRUE;
236 minSlice = fMinSlice + 9;
237 maxSlice = fMaxSlice + 9;
239 if (minSlice > maxSlice) maxSlice += 17;
241 for (slice=minSlice;slice<=maxSlice;slice++){
242 realslice = slice % 18;
243 fSliceArray[realslice] = kTRUE;
244 fSliceArray[realslice+18] = kTRUE;
249 // #############################################################################
251 // #############################################################################
252 void AliHLTTPCDisplay::SetupCluster(Int_t slice, Int_t patch, UInt_t nofClusters, AliHLTTPCSpacePointData* data) {
254 if (data && slice>=0 && slice<36 && patch>=0 && patch<AliHLTTPCTransform::GetNPatches()) {
255 if (fClusters[slice][patch]!=NULL) {
256 delete(fClusters[slice][patch]);
257 fClusters[slice][patch]=NULL;
259 Int_t arraysize=nofClusters*sizeof(AliHLTTPCSpacePointData);
260 fClusters[slice][patch] = (AliHLTTPCSpacePointData*)new Byte_t[arraysize];
261 if (fClusters[slice][patch]) {
262 memcpy(fClusters[slice][patch], data, arraysize);
263 fNcl[slice][patch]=nofClusters;
265 fNcl[slice][patch]=nofClusters;
266 LOG(AliHLTTPCLog::kError,"AliHLTTPCDisplay::SetupCluster","memory allocation") << "memory allocation failed "<<ENDLOG;
268 } else LOG(AliHLTTPCLog::kError,"AliHLTTPCDisplay::SetupCluster","argument check") << "invalid argument "<<ENDLOG;
271 // #############################################################################
272 void AliHLTTPCDisplay::SetupTracks(AliHLTTPCTrackArray *tracks) {
276 Int_t ntracks = fTracks->GetNTracks();
278 for(Int_t j=0; j<ntracks; j++) {
279 AliHLTTPCTrack *gtrack = fTracks->GetCheckedTrack(j);
280 if(!gtrack) continue;
282 Int_t nHits = gtrack->GetNHits();
283 UInt_t *hitnum = gtrack->GetHitNumbers();
285 for(Int_t h=0; h<nHits; h++){
288 Int_t slice = (id>>25) & 0x7f;
289 Int_t patch = (id>>22) & 0x7;
290 UInt_t pos = id&0x3fffff;
292 AliHLTTPCSpacePointData *points = fClusters[slice][patch];
295 LOG(AliHLTTPCLog::kError,"AliHLTTPCDisplay::Draw3D","Clusterarray") <<"No points at slice "<<slice<<" patch "<<patch<<" pos "<<pos<<ENDLOG;
299 if(pos>=fNcl[slice][patch]) {
300 LOG(AliHLTTPCLog::kError,"AliHLTTPCDisplay::Draw3D","Clusterarray") <<"Pos is too large: pos "<<pos <<" ncl "<<fNcl[slice][patch]<<ENDLOG;
303 points[pos].fUsed = kTRUE;
304 points[pos].fTrackN = j;
309 // #############################################################################
310 void AliHLTTPCDisplay::SetupHist(){
313 fNTimes = AliHLTTPCTransform::GetNTimeBins();
339 if ( fHistallresidualsY){
340 delete fHistallresidualsY;
341 fHistallresidualsY = NULL;
344 if ( fHistallresidualsZ){
345 delete fHistallresidualsZ;
346 fHistallresidualsZ = NULL;
353 // Setup the histograms
354 Int_t padbinning = maxpads*10;
355 fHistraw = new TH2F("fHistraw","Selected PadRow with found Clusters;Pad #;Timebin #",maxpads,0,maxpads-1,fNTimes,0,fNTimes-1);
356 fHistrawcl = new TH1F("fHistrawcl","",padbinning,0,maxpads-1);
357 fHistpad1 = new TH1F ("fHistpad1","Selected Pad -1;Timebin #",fNTimes,0,fNTimes-1);
358 fHistpad2 = new TH1F ("fHistpad2","Selected Pad;Timebin #",fNTimes,0,fNTimes-1);
359 fHistpad3 = new TH1F ("fHistpad3","Selected Pad +1;Timebin #",fNTimes,0,fNTimes-1);
360 fHistallresidualsY = new TH1F ("fHistallresiduals","Y Residuals of all Tracks in selected slices;residuals",5000,-100,100);
361 fHistallresidualsZ = new TH1F ("fHistallresiduals","Z Residuals of all Tracks in selected slices;residuals",5000,-100,100);
362 fHistcharge = new TH1F ("fHistcharge","Cluster distribution per charge;charge;#cluster",5000,0,30000);
364 fHistraw->SetOption("COLZ");
366 fHistallresidualsY->SetTitleSize(0.03);
367 fHistallresidualsY->GetXaxis()->SetLabelSize(0.03);
368 fHistallresidualsY->GetXaxis()->SetTitleSize(0.03);
369 fHistallresidualsY->GetYaxis()->SetLabelSize(0.03);
370 fHistallresidualsY->GetYaxis()->SetTitleSize(0.03);
372 fHistallresidualsZ->SetTitleSize(0.03);
373 fHistallresidualsZ->GetXaxis()->SetLabelSize(0.03);
374 fHistallresidualsZ->GetXaxis()->SetTitleSize(0.03);
375 fHistallresidualsZ->GetYaxis()->SetLabelSize(0.03);
376 fHistallresidualsZ->GetYaxis()->SetTitleSize(0.03);
378 fHistcharge->SetTitleSize(0.03);
379 fHistcharge->GetXaxis()->SetLabelSize(0.03);
380 fHistcharge->GetXaxis()->SetTitleSize(0.03);
381 fHistcharge->GetYaxis()->SetLabelSize(0.03);
382 fHistcharge->GetYaxis()->SetTitleSize(0.03);
384 fHistraw->SetTitleSize(0.03);
385 fHistraw->GetXaxis()->SetLabelSize(0.03);
386 fHistraw->GetXaxis()->SetTitleSize(0.03);
387 fHistraw->GetYaxis()->SetLabelSize(0.03);
388 fHistraw->GetYaxis()->SetTitleSize(0.03);
390 fHistpad1->SetTitleSize(0.03);
391 fHistpad1->GetXaxis()->SetLabelSize(0.03);
392 fHistpad1->GetXaxis()->SetTitleSize(0.03);
393 fHistpad1->GetYaxis()->SetLabelSize(0.03);
394 fHistpad1->GetYaxis()->SetTitleSize(0.03);
396 fHistpad2->SetTitleSize(0.03);
397 fHistpad2->GetXaxis()->SetLabelSize(0.03);
398 fHistpad2->GetXaxis()->SetTitleSize(0.03);
399 fHistpad2->GetYaxis()->SetLabelSize(0.03);
400 fHistpad2->GetYaxis()->SetTitleSize(0.03);
402 fHistpad3->SetTitleSize(0.03);
403 fHistpad3->GetXaxis()->SetLabelSize(0.03);
404 fHistpad3->GetXaxis()->SetTitleSize(0.03);
405 fHistpad3->GetYaxis()->SetLabelSize(0.03);
406 fHistpad3->GetYaxis()->SetTitleSize(0.03);
408 gStyle->SetPalette(1);
413 // ####################################################################################################
414 void AliHLTTPCDisplay::FillPadRow(Int_t patch, ULong_t dataBlock, ULong_t dataLen){
415 AliHLTTPCDigitReader* digitReader = new AliHLTTPCDigitReaderPacked();
416 bool readValue = true;
419 // Initialize RAW DATA
420 Int_t firstRow = AliHLTTPCTransform::GetFirstRow(patch);
421 Int_t lastRow = AliHLTTPCTransform::GetLastRow(patch);
423 // Outer sector, patches 2, 3, 4, 5 - start counting in patch 2 with row 0
424 if ( patch >= 2 ) rowOffset = AliHLTTPCTransform::GetFirstRow( 2 );
426 // Initialize block for reading packed data
427 void* tmpdataBlock = (void*) dataBlock;
428 digitReader->InitBlock(tmpdataBlock,dataLen,firstRow,lastRow,patch,0);
430 readValue = digitReader->Next();
433 LOG(AliHLTTPCLog::kError,"AliHLTTPCDisplay::FillPadRow","Read first value") << "No value in data block" << ENDLOG;
437 // FILL PADROW 3D --- Initialize the colorbins
438 if (fSwitch3DPadRow){
439 for (UInt_t ii=0;ii < 20;ii++){
444 // read number of entries in colorbin
447 Int_t row = digitReader->GetRow() + rowOffset;
450 UInt_t charge = digitReader->GetSignal();
452 for (UInt_t ii=0;ii < 19;ii++){
453 if ( charge > (ii*15) && charge <= ((ii*15) + 15) ) fcolorbin[ii]++;
455 // larger than 19 * 15
456 if (charge > 285 ) fcolorbin[19]++;
460 readValue = digitReader->Next();
462 if(!readValue) break; //No more value
464 //Initialize fpmarr[color][3*colorbin[ii]]
465 fpmarr[0] = new Float_t[fcolorbin[0]*3];
466 fpmarr[1] = new Float_t[fcolorbin[1]*3];
467 fpmarr[2] = new Float_t[fcolorbin[2]*3];
468 fpmarr[3] = new Float_t[fcolorbin[3]*3];
469 fpmarr[4] = new Float_t[fcolorbin[4]*3];
470 fpmarr[5] = new Float_t[fcolorbin[5]*3];
471 fpmarr[6] = new Float_t[fcolorbin[6]*3];
472 fpmarr[7] = new Float_t[fcolorbin[7]*3];
473 fpmarr[8] = new Float_t[fcolorbin[8]*3];
474 fpmarr[9] = new Float_t[fcolorbin[9]*3];
475 fpmarr[10] = new Float_t[fcolorbin[10]*3];
476 fpmarr[11] = new Float_t[fcolorbin[11]*3];
477 fpmarr[12] = new Float_t[fcolorbin[12]*3];
478 fpmarr[13] = new Float_t[fcolorbin[13]*3];
479 fpmarr[14] = new Float_t[fcolorbin[14]*3];
480 fpmarr[15] = new Float_t[fcolorbin[15]*3];
481 fpmarr[16] = new Float_t[fcolorbin[16]*3];
482 fpmarr[17] = new Float_t[fcolorbin[17]*3];
483 fpmarr[18] = new Float_t[fcolorbin[18]*3];
484 fpmarr[19] = new Float_t[fcolorbin[19]*3];
486 // Rewind the raw reader and fill the polymarker3D
487 digitReader->InitBlock(tmpdataBlock,dataLen,firstRow,lastRow,patch,0);
489 readValue = digitReader->Next();
490 } // END if (fSwitch3DPadRow)
495 Int_t row = digitReader->GetRow() + rowOffset;
497 // select padrow to fill in histogramm
499 UChar_t pad = digitReader->GetPad();
500 UShort_t time = digitReader->GetTime();
501 UInt_t charge = digitReader->GetSignal();
503 fHistraw->Fill(pad,time,charge);
505 if (pad == (fPad-1) ) fHistpad1->Fill(time,charge);
506 if (pad == fPad) fHistpad2->Fill(time,charge);
507 if (pad == (fPad+1) ) fHistpad3->Fill(time,charge);
509 if (fSwitch3DPadRow) {
510 // Transform raw coordinates to local coordinates
511 AliHLTTPCTransform::RawHLT2Global(xyz, fSlicePadRow, fPadRow, pad, time);
513 for (UInt_t ii=0;ii < 19;ii++){
514 if ( charge > (ii*15) && charge <= ((ii*15) + 15) ){
515 fpmarr[ii][fbinct[ii]] = xyz[0];
516 fpmarr[ii][fbinct[ii]+1] = xyz[1];
517 fpmarr[ii][fbinct[ii]+2] = xyz[2];
521 // larger than 19 * 15
523 fpmarr[19][fbinct[19]] = xyz[0];
524 fpmarr[19][fbinct[19]+1] = xyz[1];
525 fpmarr[19][fbinct[19]+2] = xyz[2];
528 } // END if (fSwitch3DPadRow)
533 readValue = digitReader->Next();
535 //Check where to stop:
536 if(!readValue) break; //No more value
543 AliHLTTPCSpacePointData *points = fClusters[fSlicePadRow][patch];
545 Int_t npoints = fNcl[fSlicePadRow][patch];
548 for(Int_t i=0; i<npoints; i++){
549 xyz[0] = points[i].fX;
550 xyz[1] = points[i].fY;
551 xyz[2] = points[i].fZ;
553 Int_t clrow = AliHLTTPCTransform::GetPadRow(xyz[0]);
554 // select padrow to fill in histogramm
555 if (clrow == fPadRow){
556 AliHLTTPCTransform::LocHLT2Raw(xyz, fSlicePadRow, fPadRow);
557 fHistrawcl->Fill(xyz[1],xyz[2]);
562 // #############################################################################
563 void AliHLTTPCDisplay::ResetHistPadRow(){
571 // #############################################################################
572 void AliHLTTPCDisplay::ResetHistResiduals(){
573 fHistallresidualsY->Reset();
574 fHistallresidualsZ->Reset();
577 // #############################################################################
578 void AliHLTTPCDisplay::ResetHistCharge(){
579 fHistcharge->Reset();
583 // #############################################################################
585 // #############################################################################
586 void AliHLTTPCDisplay::DrawGeomSector(Int_t sector) {
588 Int_t realsector = sector;// % 18;
590 if (realsector < 10){
591 sprintf(fname,"LS0%d",realsector);
592 fGeom->GetNode(fname)->SetLineColor(fLineColor);
593 fGeom->GetNode(fname)->Draw("same");
594 sprintf(fname,"US0%d",realsector);
595 fGeom->GetNode(fname)->SetLineColor(fLineColor);
596 fGeom->GetNode(fname)->Draw("same");
599 sprintf(fname,"LS%d",realsector);
600 fGeom->GetNode(fname)->SetLineColor(fLineColor);
601 fGeom->GetNode(fname)->Draw("same");
602 sprintf(fname,"US%d",realsector);
603 fGeom->GetNode(fname)->SetLineColor(fLineColor);
604 fGeom->GetNode(fname)->Draw("same");
607 // #############################################################################
608 void AliHLTTPCDisplay::DrawHistPadRow(){
610 sprintf(title,"Selected PadRow %d with found Clusters",fPadRow);
612 fHistraw->SetTitle(title);
613 fHistraw->SetStats(kFALSE);
614 fHistraw->Draw("COLZ");
616 fHistrawcl->SetStats(kFALSE);
617 fHistrawcl->SetMarkerStyle(28);
618 fHistrawcl->SetMarkerSize(2);
619 fHistrawcl->SetMarkerColor(1);
620 fHistrawcl->Draw("psame");
623 // #############################################################################
624 void AliHLTTPCDisplay::DrawHistPad1(){
626 sprintf(title,"Selected Pad %d",fPad -1);
627 fHistpad1->SetStats(kFALSE);
628 fHistpad1->SetTitle(title);
632 // #############################################################################
633 void AliHLTTPCDisplay::DrawHistPad2(){
635 sprintf(title,"Selected Pad %d",fPad);
637 fHistpad2->SetStats(kFALSE);
638 fHistpad2->SetTitle(title);
642 // #############################################################################
643 void AliHLTTPCDisplay::DrawHistPad3(){
645 sprintf(title,"Selected Pad %d",fPad +1);
647 fHistpad3->SetStats(kFALSE);
648 fHistpad3->SetTitle(title);
652 // #############################################################################
653 void AliHLTTPCDisplay::DrawHistResiduals(Bool_t ySwitch){
654 if (fSwitch3DTracks){
656 // Y Residual histogram for 1 track
658 if (fSelectTrackSwitch){
660 sprintf(title,"Y Residuals of Track %d in Slice %d",fSelectTrack, fSelectTrackSlice );
662 TMultiGraph *mgY = new TMultiGraph();
665 // fGraphresidualsY->SetTitle(title);
666 fGraphresidualsY->GetXaxis()->SetTitle("padrow");
667 fGraphresidualsY->GetYaxis()->SetTitle("residuals");
668 // fGraphresidualsY->Draw("A*");
669 fGraphresidualsY->GetXaxis()->SetLabelSize(0.02);
670 fGraphresidualsY->GetXaxis()->SetTitleSize(0.02);
671 fGraphresidualsY->GetYaxis()->SetLabelSize(0.02);
672 fGraphresidualsY->GetYaxis()->SetTitleSize(0.02);
673 fGraphresidualsYLength->SetMarkerColor(2);
674 fGraphresidualsYLength->SetMarkerStyle(5);
675 fGraphresidualsY->SetMarkerColor(1);
676 fGraphresidualsY->SetMarkerStyle(3);
678 // fGraphresidualsY->Draw("A*");
679 // fGraphresidualsYLength->Draw("*");
681 mgY->Add(fGraphresidualsY);
682 mgY->Add(fGraphresidualsYLength);
683 mgY->SetTitle(title);
684 // mgY->GetXaxis()->SetTitle("padrow");
685 // mgY->GetYaxis()->SetTitle("residuals");
688 // Global residuals histogram
690 fHistallresidualsY->SetStats(kFALSE);
691 fHistallresidualsY->Draw();
695 // Z Residual histogram for 1 track
696 if (fSelectTrackSwitch){
698 sprintf(title,"Z Residuals of Track %d in Slice %d",fSelectTrack, fSelectTrackSlice );
700 TMultiGraph *mgZ = new TMultiGraph();
702 fGraphresidualsZ->SetTitle(title);
703 fGraphresidualsZ->GetXaxis()->SetTitle("padrow");
704 fGraphresidualsZ->GetYaxis()->SetTitle("residuals");
705 fGraphresidualsZ->GetXaxis()->SetLabelSize(0.02);
706 fGraphresidualsZ->GetXaxis()->SetTitleSize(0.02);
707 fGraphresidualsZ->GetYaxis()->SetLabelSize(0.02);
708 fGraphresidualsZ->GetYaxis()->SetTitleSize(0.02);
709 // fGraphresidualsZLength->Draw("F*");
710 // fGraphresidualsZ->Draw("A*");
712 mgZ->Add(fGraphresidualsZ);
713 // mgZ->Add(fGraphresidualsZLength);
714 mgZ->SetTitle(title);
717 // Global residuals histogram
719 fHistallresidualsZ->SetStats(kFALSE);
720 fHistallresidualsZ->Draw();
726 // #############################################################################
727 void AliHLTTPCDisplay::DrawHistCharge(){
728 if (fSwitch3DCluster){
729 // fHistcharge->SetStats(kFALSE);
734 // #############################################################################
735 void AliHLTTPCDisplay::Draw3D(){
737 #if defined(HAVE_TVIEW3D_H)
738 TView3D *v = new TView3D();
739 if (v) v->SetSystem(1);
741 TView *v = new TView(1);
744 HLTFatal("can not create viewer");
747 v->SetRange(-800,-800,-800,800,800,800);
749 Float_t* etaRange = NULL; // ------ STILL TO FIX
752 //--------------------------------------------------------------------------------------------
754 //--------------------------------------------------------------------------------------------
755 if (fSwitch3DCluster){
758 for (Int_t slice=0; slice <= 35; slice++){
760 Int_t currenttrack = -1;
762 if (fSelectCluster == 1 && fSelectTrackSwitch && slice == fSelectTrackSlice ){
764 Int_t trackcounter = 0;
765 Int_t ntracks = fTracks->GetNTracks();
767 for(Int_t j=0; j<ntracks; j++) {
769 AliHLTTPCTrack *gtrack = fTracks->GetCheckedTrack(j);
770 if(!gtrack) continue;
772 Int_t nHits = gtrack->GetNHits(); // Number of associated hits to track
773 Int_t tmpslice = gtrack->GetSector();
775 // --- CHECK if track is should be drawn
776 // select Single Track
777 if(tmpslice != fSelectTrackSlice) continue;
779 if (trackcounter != fSelectTrack){
785 if((fPtThreshold > 0) && (gtrack->GetPt()< fPtThreshold)) continue;
786 if(nHits < fMinHits) continue;
793 if (!fSliceArray[slice]) continue;
795 for(Int_t p=0;p<6;p++){
797 AliHLTTPCSpacePointData *points = fClusters[slice][p];
798 if(!points) continue;
799 Int_t npoints = fNcl[slice][p];
800 TPolyMarker3D *pmUsed = new TPolyMarker3D(1,6);
801 TPolyMarker3D *pmUnused = new TPolyMarker3D(1,6);
802 Int_t nUsedCluster = 0;
803 Int_t nUnusedCluster = 0;
806 for(Int_t i=0; i<npoints; i++){
808 if (fSelectCluster == 1 && points[i].fUsed == kFALSE) continue;
809 // Unused cluster only
810 if (fSelectCluster == 2 && points[i].fUsed == kTRUE) continue;
812 // if single track is selcted draw only cluster for this track
813 if (fSelectCluster == 1 && fSelectTrackSwitch && points[i].fTrackN != currenttrack) continue;
815 xyz[0] = points[i].fX;
816 xyz[1] = points[i].fY;
817 xyz[2] = points[i].fZ;
820 // Do this before the transform, because the tracker also uses
821 // local coordinates when using this limit to determine
822 // which clusters to use for tracking
823 Double_t pointEta = AliHLTTPCTransform::GetEta( xyz );
824 if ( pointEta<etaRange[0] || pointEta>etaRange[1] )
828 AliHLTTPCTransform::Local2Global(xyz,slice);
830 if (points[i].fUsed == kTRUE){
831 pmUsed->SetPoint(nUsedCluster,xyz[0],xyz[1],xyz[2]);
835 pmUnused->SetPoint(nUnusedCluster,xyz[0],xyz[1],xyz[2]);
839 // Fill Charge Histogram
840 fHistcharge->Fill(points[i].fCharge);
841 if ((Int_t)points[i].fCharge > maxCharge ) maxCharge = (Int_t) points[i].fCharge;
843 pmUsed->SetMarkerSize(1);
844 pmUsed->SetMarkerColor(3);
847 pmUnused->SetMarkerSize(1);
848 pmUnused->SetMarkerColor(2);
850 } // END - PATCH LOOP
851 } // END - SLICE LOOP
852 fHistcharge->SetAxisRange(0,maxCharge);
853 } // END - DRAW 3D CLUSTER
855 //--------------------------------------------------------------------------------------------
857 //--------------------------------------------------------------------------------------------
858 if (fSwitch3DTracks){
860 Int_t trackcounter = 0;
861 Int_t ntracks = fTracks->GetNTracks();
862 Double_t drawStep = 0.2;
864 Double_t maxResidualY = 0.;
865 Double_t maxResidualZ = 0.;
867 TPolyLine3D *line = new TPolyLine3D[ntracks];
869 THelix *helix = new THelix[ntracks];
871 for(Int_t j=0; j<ntracks; j++) {
873 AliHLTTPCTrack *gtrack = fTracks->GetCheckedTrack(j);
874 if(!gtrack) continue;
876 Int_t nHits = gtrack->GetNHits(); // Number of associated hits to track
877 Int_t slice = gtrack->GetSector();
879 // --- CHECK if track is should be drawn
880 // select if slice should be displayed or not
881 if (!fSliceArray[slice]) continue;
883 // select Single Track
884 if (fSelectTrackSwitch){
885 if(slice != fSelectTrackSlice) continue;
887 if (trackcounter != fSelectTrack){
894 if((fPtThreshold > 0) && (gtrack->GetPt()< fPtThreshold)) continue;
895 if(nHits < fMinHits) continue;
897 TPolyMarker3D *pmL = new TPolyMarker3D(1,2);
898 TPolyMarker3D *pmF = new TPolyMarker3D(1,2);
900 Double_t radius = gtrack->GetRadius(); // radius
901 Double_t kappa = gtrack->GetKappa(); // curvature = 1/R , signed
902 Double_t lambda = atan( gtrack->GetTgl() ); // dipAngle lambda
903 Double_t phi0 = gtrack->GetPsi() + (gtrack->GetCharge() * AliHLTTPCTransform::PiHalf() ); // azimuthal angle of startingpoint, with respect to helix axis
905 Double_t xyzL[3]; // lastpoint of track
906 Double_t xyzF[3]; // firstpoint of track
908 xyzF[0] = gtrack->GetFirstPointX();
909 xyzF[1] = gtrack->GetFirstPointY();
910 xyzF[2] = gtrack->GetFirstPointZ();
911 pmF->SetPoint(0,xyzF[0],xyzF[1],xyzF[2]);
913 xyzL[0] = gtrack->GetLastPointX();
914 xyzL[1] = gtrack->GetLastPointY();
915 xyzL[2] = gtrack->GetLastPointZ();
916 pmL->SetPoint(0,xyzL[0],xyzL[1],xyzL[2]);
918 Double_t s = 0.; // length of the track
920 // Calculate the length of the track. If it is to flat in in s,z plane use sxy, otherwise use sz
921 if (fabs(lambda) > 0.05){
922 // length of track calculated out of z
923 s = fabs( (xyzL[2] - xyzF[2]) / sin(lambda) ); // length of track calculated out of z
926 Double_t d = (xyzL[0] - xyzF[0])*(xyzL[0] - xyzF[0]) + (xyzL[1] - xyzF[1])*(xyzL[1] - xyzF[1]);
927 // length of track calculated out of xy
928 s = fabs ( acos( 0.5 * (2 - (d / (radius*radius)))) / ( kappa * cos(lambda) ) );
931 Int_t nTrackPoints = 2 + (Int_t) floor(s / drawStep);
934 TPolyMarker3D *pmT = new TPolyMarker3D(nTrackPoints,6);
937 Double_t *xT = new Double_t[nTrackPoints];
938 Double_t *yT = new Double_t[nTrackPoints];
939 Double_t *zT = new Double_t[nTrackPoints];
941 //Write Track Parameters for single track
942 if (fSelectTrackSwitch){
943 fTrackParam.id = trackcounter - 1;
944 fTrackParam.nHits = nHits;
945 fTrackParam.charge = gtrack->GetCharge();
946 fTrackParam.lambda = lambda;
947 fTrackParam.kappa = kappa;
948 fTrackParam.radius = radius;
949 fTrackParam.slice = slice;
950 fTrackParam.phi0 = phi0;
951 fTrackParam.pt = gtrack->GetPt();
952 fTrackParam.bfield = AliHLTTPCTransform::GetBFieldValue();
953 fTrackParam.xyzF[0] = gtrack->GetFirstPointX();
954 fTrackParam.xyzF[1] = gtrack->GetFirstPointY();
955 fTrackParam.xyzF[2] = gtrack->GetFirstPointZ();
956 fTrackParam.xyzL[0] = gtrack->GetLastPointX();
957 fTrackParam.xyzL[1] = gtrack->GetLastPointY();
958 fTrackParam.xyzL[2] = gtrack->GetLastPointZ();
959 fTrackParam.psi = gtrack->GetPsi();
963 Int_t trackPointCounter = 0;
965 for (Double_t ds = 0.; ds < s; ds = ds + drawStep){
966 // FILL ARRAYS IN ORDER TO DRAW THE TRACKPOINTS, OUT OF THE PARAMETER
967 xT[trackPointCounter] = xyzF[0] + radius * ( cos( phi0 + (ds*kappa*cos(lambda)) ) - cos(phi0) );
968 yT[trackPointCounter] = xyzF[1] + radius * ( sin( phi0 + (ds*kappa*cos(lambda)) ) - sin(phi0) );
969 zT[trackPointCounter] = xyzF[2] + ds * sin(lambda);
971 pmT->SetPoint(trackPointCounter,xT[trackPointCounter],yT[trackPointCounter],zT[trackPointCounter]);
976 xT[trackPointCounter] = xyzF[0] + radius * ( cos( phi0 + (s*kappa*cos(lambda)) ) - cos(phi0) );
977 yT[trackPointCounter] = xyzF[1] + radius * ( sin( phi0 + (s*kappa*cos(lambda)) ) - sin(phi0) );
978 zT[trackPointCounter] = xyzF[2] + s * sin(lambda);
980 pmT->SetPoint(trackPointCounter,xT[trackPointCounter],yT[trackPointCounter],zT[trackPointCounter]);
983 gtrack->Rotate(slice,kTRUE);
984 Int_t nRes = 0; // number of resiudals
986 UInt_t *hitnum = gtrack->GetHitNumbers();
988 Double_t *resY= new Double_t[nHits];
989 Double_t *resZ= new Double_t[nHits];
991 Double_t *resYLength= new Double_t[2*nHits];
992 Double_t *resZLength= new Double_t[2*nHits];
994 Double_t *padrows = new Double_t[nHits];
995 Double_t *padrowsLength = new Double_t[2*nHits];
997 for(Int_t h=0; h<nHits; h++){
999 Int_t patch = (id>>22) & 0x7;
1000 UInt_t pos = id&0x3fffff;
1002 AliHLTTPCSpacePointData *points = fClusters[slice][patch];
1004 Float_t xyzCtmp[3]; // cluster tmp
1005 Float_t xyzTtmp[3]; // track tmp
1007 xyzCtmp[0] = points[pos].fX;
1008 xyzCtmp[1] = points[pos].fY;
1009 xyzCtmp[2] = points[pos].fZ;
1011 Int_t padrow = AliHLTTPCTransform::GetPadRow(points[pos].fX);
1012 xyzTtmp[0] = gtrack->GetFirstPointX();
1013 if(gtrack->GetCrossingPoint(padrow,xyzTtmp)) {
1015 Float_t deltaY = ( xyzCtmp[1] - xyzTtmp[1] );
1016 Float_t deltaZ = ( xyzCtmp[2] - xyzTtmp[2] );
1017 // Float_t residual = sqrt( deltaY*deltaY + deltaZ*deltaZ );
1019 padrows[nRes] = (Double_t) padrow;
1020 resY[nRes] = (Double_t) deltaY;
1021 resZ[nRes] = (Double_t) deltaZ;
1023 resYLength[(2*nRes)] = 0.5 * AliHLTTPCTransform::GetPadLength(padrow);
1024 resYLength[(2*nRes)+1] = -0.5 * AliHLTTPCTransform::GetPadLength(padrow);
1025 resZLength[nRes] = AliHLTTPCTransform::GetZLength();
1026 padrowsLength[(2*nRes)] = (Double_t) padrow;
1027 padrowsLength[(2*nRes)+1] = (Double_t) padrow;
1029 // FILL RESIDUALS HISTOGRAM
1030 fHistallresidualsY->Fill(resY[nRes]);
1031 fHistallresidualsZ->Fill(resZ[nRes]);
1032 if (resY[nRes] > maxResidualY ) maxResidualY = resY[nRes];
1033 if (resZ[nRes] > maxResidualZ ) maxResidualZ = resZ[nRes];
1038 gtrack->Rotate(slice,kFALSE);
1039 // --- RESIDUALS ---
1041 // Draw last point of Track
1042 pmL->SetMarkerSize(3);
1043 pmL->SetMarkerColor(4);
1046 // Draw first point of Track
1047 pmF->SetMarkerSize(3);
1048 pmF->SetMarkerColor(5);
1052 // Draw Track -- as polymarker
1053 pmT->SetMarkerSize(3);
1054 pmT->SetMarkerColor(3);
1057 // Draw Track -- as line
1058 TPolyLine3D *currentline = &(line[j]);
1059 currentline = new TPolyLine3D(nTrackPoints,xT,yT,zT,"");
1060 currentline->SetLineColor(4);
1061 currentline->SetLineWidth(2);
1062 currentline->Draw("same");
1065 // Draw Track -- as helix
1066 // works ok, execpt for very small dipangles -> track almost horizontal
1070 hrange[0] = xyzF[2];
1071 hrange[1] = xyzL[2];
1072 v0[0] = gtrack->GetPx();
1073 v0[1] = gtrack->GetPy();
1074 v0[2] = gtrack->GetPz();
1075 omega = AliHLTTPCTransform::GetBFieldValue() * gtrack->GetCharge();
1077 THelix *currenthelix = &(helix[j]);
1078 currenthelix = new THelix(xyzF,v0,omega,hrange,kHelixZ,0);
1079 currenthelix->SetLineColor(6);
1080 currenthelix->SetLineWidth(1);
1081 currenthelix->Draw("same");
1085 if ( fGraphresidualsY){
1086 delete fGraphresidualsY;
1087 fGraphresidualsY = NULL;
1090 if ( fGraphresidualsZ){
1091 delete fGraphresidualsZ;
1092 fGraphresidualsZ = NULL;
1095 if ( fGraphresidualsYLength){
1096 delete fGraphresidualsYLength;
1097 fGraphresidualsYLength = NULL;
1100 if ( fGraphresidualsZLength){
1101 delete fGraphresidualsZLength;
1102 fGraphresidualsZLength = NULL;
1107 // FILL Y RESIDUALS GRAPH
1108 fGraphresidualsY = new TGraph(nRes-1,padrows,resY);
1109 fGraphresidualsYLength = new TGraph((2*nRes)-2,padrowsLength,resYLength);
1110 // FILL Z RESIDUALS GRAPH
1111 fGraphresidualsZ = new TGraph(nRes-1,padrows,resZ);
1112 fGraphresidualsZLength = new TGraph(nRes-1,padrows,resZLength);
1120 fHistallresidualsY->SetAxisRange(-maxResidualY,maxResidualY);
1121 fHistallresidualsZ->SetAxisRange(-maxResidualZ,maxResidualZ);
1123 } // END - DRAW 3D Tracks
1125 //--------------------------------------------------------------------------------------------
1127 //--------------------------------------------------------------------------------------------
1128 if (fSwitch3DGeometry){
1130 for (Int_t slice=0; slice <= 17; slice++){
1131 if (!fSliceArray[slice]) continue;
1132 DrawGeomSector(slice);
1134 } // END - DRAW 3D GEOMETRY
1136 //--------------------------------------------------------------------------------------------
1138 //--------------------------------------------------------------------------------------------
1139 if (fSwitch3DPadRow && fSliceArray[fSlicePadRow]){
1140 Int_t markercolor = 51;
1142 for (UInt_t ii=0;ii < 20;ii++){
1143 if (fcolorbin[ii]> 0){
1145 TPolyMarker3D *pm = new TPolyMarker3D(fcolorbin[ii], fpmarr[ii], 7 );
1147 pm->SetMarkerColor(markercolor);
1151 // in order to have the SetPalette(1), so called "pretty"
1152 if (ii % 2 == 0 ) markercolor += 2;
1153 else markercolor += 3;
1157 //--------------------------------------------------------------------------------------------
1159 //--------------------------------------------------------------------------------------------
1164 // ---------------------------------------------------
1165 // In order to be backward compatible
1166 // ---------------------------------------------------
1168 void AliHLTTPCDisplay::DisplayClusters(Bool_t x3don,Float_t* etaRange) {
1170 fc1 = new TCanvas("c1","",900,900);
1174 fSwitch3DTracks = kFALSE;
1175 fSwitch3DCluster = kTRUE;
1176 fSwitch3DPadRow = kFALSE;
1177 fSwitch3DGeometry = kFALSE;
1181 // ---------------------------------------------------
1182 void AliHLTTPCDisplay::DisplayTracks(Int_t minhits,Bool_t x3don,Float_t thr) {
1184 fc1 = new TCanvas("c1","",900,900);
1190 fSwitch3DTracks = kTRUE;
1191 fSwitch3DCluster = kFALSE;
1192 fSwitch3DPadRow = kFALSE;
1193 fSwitch3DGeometry = kFALSE;
1197 // ---------------------------------------------------
1198 void AliHLTTPCDisplay::DisplayAll(Int_t minhits,Bool_t clusterswitch,Bool_t trackswitch,Bool_t x3don, Float_t thr, Float_t* etaRange){
1200 fc1 = new TCanvas("c1","",900,900);
1206 fSwitch3DTracks = trackswitch;
1207 fSwitch3DCluster = clusterswitch;
1208 fSwitch3DPadRow = kFALSE;
1209 fSwitch3DGeometry = kFALSE;
1214 // ---------------------------------------------------