2 // **************************************************************************
3 // This file is property of and copyright by the ALICE HLT Project *
4 // ALICE Experiment at CERN, All rights reserved. *
6 // Primary Authors: Sergey Gorbunov <sergey.gorbunov@kip.uni-heidelberg.de> *
7 // Ivan Kisel <kisel@kip.uni-heidelberg.de> *
8 // for The ALICE HLT Project. *
10 // Permission to use, copy, modify and distribute this software and its *
11 // documentation strictly for non-commercial purposes is hereby granted *
12 // without fee, provided that the above copyright notice appears in all *
13 // copies and that both the copyright notice and this permission notice *
14 // appear in the supporting documentation. The authors make no claims *
15 // about the suitability of this software for any purpose. It is *
16 // provided "as is" without express or implied warranty. *
18 //***************************************************************************
21 #include "AliHLTTPCCADisplay.h"
24 #include "AliHLTTPCCATracker.h"
25 #include "AliHLTTPCCAStandaloneFramework.h"
26 #include "AliHLTTPCCARow.h"
27 #include "AliHLTTPCCATrack.h"
28 #include "AliHLTTPCCAPerformance.h"
29 #include "AliHLTTPCCAMCTrack.h"
32 #include "Riostream.h"
36 #include "TApplication.h"
39 class AliHLTTPCCADisplay::AliHLTTPCCADisplayTmpHit
44 int ID() const { return fHitID; }
45 double S() const { return fS; }
46 double Z() const { return fZ; }
48 void SetID( int v ) { fHitID = v; }
49 void SetS( double v ) { fS = v; }
50 void SetZ( double v ) { fZ = v; }
52 static bool CompareHitDS( const AliHLTTPCCADisplayTmpHit &a,
53 const AliHLTTPCCADisplayTmpHit &b ) {
54 return ( a.fS < b.fS );
57 static bool CompareHitZ( const AliHLTTPCCADisplayTmpHit &a,
58 const AliHLTTPCCADisplayTmpHit &b ) {
59 return ( a.fZ < b.fZ );
65 double fS; // hit position on the XY track curve
66 double fZ; // hit Z position
72 AliHLTTPCCADisplay &AliHLTTPCCADisplay::Instance()
74 // reference to static object
75 static AliHLTTPCCADisplay gAliHLTTPCCADisplay;
76 static bool firstCall = 1;
78 if ( !gApplication ) new TApplication( "myapp", 0, 0 );
79 gAliHLTTPCCADisplay.Init();
82 return gAliHLTTPCCADisplay;
85 AliHLTTPCCADisplay::AliHLTTPCCADisplay() : fYX( 0 ), fZX( 0 ), fAsk( 1 ), fSliceView( 1 ), fSlice( 0 ), fPerf( 0 ),
86 fCos( 1 ), fSin( 0 ), fZMin( -250 ), fZMax( 250 ), fYMin( -250 ), fYMax( 250 ), fSliceCos( 1 ), fSliceSin( 0 ),
87 fRInnerMin( 83.65 ), fRInnerMax( 133.3 ), fROuterMin( 133.5 ), fROuterMax( 247.7 ),
88 fTPCZMin( -250. ), fTPCZMax( 250 ), fArc(), fLine(), fPLine(), fMarker(), fBox(), fCrown(), fLatex(), fDrawOnlyRef( 0 )
90 fPerf = &( AliHLTTPCCAPerformance::Instance() );
94 AliHLTTPCCADisplay::~AliHLTTPCCADisplay()
101 void AliHLTTPCCADisplay::Init()
104 gStyle->SetCanvasBorderMode( 0 );
105 gStyle->SetCanvasBorderSize( 1 );
106 gStyle->SetCanvasColor( 0 );
107 fYX = new TCanvas ( "YX", "YX window", -1, 0, 600, 600 );
108 fZX = new TCanvas ( "ZX", "ZX window", -610, 0, 590, 600 );
109 fMarker = TMarker( 0.0, 0.0, 20 );//6);
113 void AliHLTTPCCADisplay::Update()
119 fYX->Print( "YX.pdf" );
120 fZX->Print( "ZX.pdf" );
124 void AliHLTTPCCADisplay::ClearView()
131 void AliHLTTPCCADisplay::Ask()
133 // wait for the pressed key, when "r" pressed, don't ask anymore
137 std::cout << "ask> " << std::endl;
139 std::cin.get( symbol );
142 } while ( symbol != '\n' );
147 void AliHLTTPCCADisplay::SetSliceView()
149 // switch to slice view
153 void AliHLTTPCCADisplay::SetTPCView()
155 // switch to full TPC view
166 void AliHLTTPCCADisplay::SetCurrentSlice( AliHLTTPCCATracker *slice )
168 // set reference to the current CA tracker, and read the current slice geometry
170 SetSliceTransform( slice );
172 fCos = slice->Param().SinAlpha();
173 fSin = slice->Param().CosAlpha();
174 fZMin = slice->Param().ZMin();
175 fZMax = slice->Param().ZMax();
177 double r0 = .5 * ( slice->Param().RMax() + slice->Param().RMin() );
178 double dr = .5 * ( slice->Param().RMax() - slice->Param().RMin() );
183 double cz = .5 * ( slice->Param().ZMax() + slice->Param().ZMin() );
184 double dz = .5 * ( slice->Param().ZMax() - slice->Param().ZMin() ) * 1.2;
185 fYX->Range( cx - dr, cy - dr*1.05, cx + dr, cy + dr );
186 fZX->Range( cz - dz, cy - dr*1.05, cz + dz, cy + dr );
188 //fYX->Range(cx-dr*.3, cy-dr*1.05, cx+dr*.3, cy-dr*.35);
189 //fZX->Range(cz-dz, cy-dr*1.05, cz+dz, cy-dr*.3);
191 //fYX->Range(cx-dr*.3, cy-dr*.8, cx-dr*.1, cy-dr*.75);
192 //fZX->Range(cz-dz*0, cy-dr*.8, cz+dz, cy-dr*.75);
194 //fYX->Range(cx-dr*.08, cy-dr*1., cx-dr*.02, cy-dr*0.7);
195 //fZX->Range(cz-dz*.2, cy-dr*1., cz-dz*.05, cy-dr*0.7);
197 //double x0 = cx-dr*.1, x1 = cx-dr*.05;
198 //double y0 = cy-dr*1.05, y1 = cy-dr*0.7;
199 //double z0 = cz-dz*.3, z1 = cz;
200 //double xc = (x0+x1)/2, yc= (y0+y1)/2, zc=(z0+z1)/2;
201 //double d = TMath::Max((x1-x0)/2,TMath::Max((y1-y0)/2,(z1-z0)/2));
202 //fYX->Range(xc-d, yc-d, xc+d, yc+d);
203 //fZX->Range(zc-d, yc-d, zc+d, yc+d);
208 void AliHLTTPCCADisplay::SetSliceTransform( double alpha )
210 fSliceCos = TMath::Cos( alpha );
211 fSliceSin = TMath::Sin( alpha );
214 void AliHLTTPCCADisplay::SetSliceTransform( AliHLTTPCCATracker *slice )
216 SetSliceTransform( slice->Param().Alpha() );
220 void AliHLTTPCCADisplay::DrawTPC()
222 // schematically draw TPC detector
223 fYX->Range( -fROuterMax, -fROuterMax, fROuterMax, fROuterMax );
224 //fYX->Range( -fROuterMax*.7, -fROuterMax, fROuterMax*0., -fROuterMax*.5);
227 fArc.SetLineColor( kBlack );
228 fArc.SetFillStyle( 0 );
230 for ( int iSlice = 0; iSlice < 18; iSlice++ ) {
231 fCrown.SetLineColor( kBlack );
232 fCrown.SetFillStyle( 0 );
233 fCrown.DrawCrown( 0, 0, fRInnerMin, fRInnerMax, 360. / 18.*iSlice, 360. / 18.*( iSlice + 1 ) );
234 fCrown.DrawCrown( 0, 0, fROuterMin, fROuterMax, 360. / 18.*iSlice, 360. / 18.*( iSlice + 1 ) );
238 fZX->Range( fTPCZMin, -fROuterMax, fTPCZMax*1.1, fROuterMax );
239 //fZX->Range( fTPCZMax*.1, -fROuterMax, fTPCZMax*.3, -fROuterMax*0.5 );
243 void AliHLTTPCCADisplay::DrawSlice( AliHLTTPCCATracker *slice, bool DrawRows )
245 // draw current the TPC slice
247 double r0 = .5 * ( slice->Param().RMax() + slice->Param().RMin() );
248 double dr = .5 * ( slice->Param().RMax() - slice->Param().RMin() );
249 double cx = r0 * slice->Param().CosAlpha();
250 double cy = r0 * slice->Param().SinAlpha();
251 double raddeg = 180. / 3.1415;
252 double a0 = raddeg * .5 * ( slice->Param().AngleMax() + slice->Param().AngleMin() );
253 double da = raddeg * .5 * ( slice->Param().AngleMax() - slice->Param().AngleMin() );
257 fLatex.DrawLatex( cx - dr + dr*.05, cy - dr + dr*.05, Form( "YX, Slice %2i", slice->Param().ISlice() ) );
259 a0 += raddeg * TMath::ATan2( fSin, fCos );
261 fArc.SetLineColor( kBlack );
262 fArc.SetFillStyle( 0 );
263 fCrown.SetLineColor( kBlack );
264 fCrown.SetFillStyle( 0 );
265 fCrown.DrawCrown( 0, 0, fRInnerMin, fRInnerMax, a0 - da, a0 + da );
266 fCrown.DrawCrown( 0, 0, fROuterMin, fROuterMax, a0 - da, a0 + da );
267 //fCrown.DrawCrown(0,0, slice->Param().RMin(),slice->Param().RMax(), a0-da, a0+da );
269 fLine.SetLineColor( kBlack );
273 double cz = .5 * ( slice->Param().ZMax() + slice->Param().ZMin() );
274 double dz = .5 * ( slice->Param().ZMax() - slice->Param().ZMin() ) * 1.2;
275 //fLine.DrawLine(cz+dz, cy-dr, cz+dz, cy+dr );
276 if ( fSliceView ) fLatex.DrawLatex( cz - dz + dz*.05, cy - dr + dr*.05, Form( "ZX, Slice %2i", slice->Param().ISlice() ) );
279 fLine.SetLineWidth( 1 );
280 fLine.SetLineColor( kBlack );
281 SetSliceTransform( fSlice );
282 for ( int iRow = 0; iRow < fSlice->Param().NRows(); iRow++ ) {
283 double x = fSlice->Row( iRow ).X();
284 double y = fSlice->Row( iRow ).MaxY();
285 double vx0, vy0, vx1, vy1;
286 Slice2View( x, y, &vx0, &vy0 );
287 Slice2View( x, -y, &vx1, &vy1 );
289 fLine.DrawLine( vx0, vy0, vx1, vy1 );
291 fLine.DrawLine( fTPCZMin, vy0, fTPCZMax, vy1 );
298 void AliHLTTPCCADisplay::Set2Slices( AliHLTTPCCATracker * const slice )
300 //* Set view for two neighbouring slices
304 fCos = TMath::Cos( TMath::Pi() / 2 - ( slice->Param().Alpha() + 10. / 180.*TMath::Pi() ) );
305 fSin = TMath::Sin( TMath::Pi() / 2 - ( slice->Param().Alpha() + 10. / 180.*TMath::Pi() ) );
306 fZMin = slice->Param().ZMin();
307 fZMax = slice->Param().ZMax();
309 double r0 = .5 * ( slice->Param().RMax() + slice->Param().RMin() );
310 double dr = .5 * ( slice->Param().RMax() - slice->Param().RMin() );
313 fYX->Range( cx - 1.3*dr, cy - 1.1*dr, cx + 1.3*dr, cy + 1.1*dr );
315 int islice = slice->Param().ISlice();
316 int jslice = slice->Param().ISlice() + 1;
317 if ( islice == 17 ) jslice = 0;
318 else if ( islice == 35 ) jslice = 18;
319 fLatex.DrawLatex( cx - 1.3*dr + 1.3*dr*.05, cy - dr + dr*.05, Form( "YX, Slices %2i/%2i", islice, jslice ) );
320 double cz = .5 * ( slice->Param().ZMax() + slice->Param().ZMin() );
321 double dz = .5 * ( slice->Param().ZMax() - slice->Param().ZMin() ) * 1.2;
322 fZX->Range( cz - dz, cy - 1.1*dr, cz + dz, cy + 1.1*dr );//+dr);
324 fLatex.DrawLatex( cz - dz + dz*.05, cy - dr + dr*.05, Form( "ZX, Slices %2i/%2i", islice, jslice ) );
327 int AliHLTTPCCADisplay::GetColor( int i ) const
329 // Get color with respect to Z coordinate
330 const Color_t kMyColor[9] = { kGreen, kBlue, kYellow, kCyan, kOrange,
331 kSpring, kTeal, kAzure, kViolet
334 if ( i == 0 ) return kBlack;
335 return kMyColor[( i-1 )%9];
338 int AliHLTTPCCADisplay::GetColorZ( double z ) const
340 // Get color with respect to Z coordinate
341 const Color_t kMyColor[11] = { kGreen, kBlue, kYellow, kMagenta, kCyan,
342 kOrange, kSpring, kTeal, kAzure, kViolet, kPink
345 double zz = ( z - fZMin ) / ( fZMax - fZMin );
346 int iz = ( int ) ( zz * 11 );
347 if ( iz < 0 ) iz = 0;
348 if ( iz > 10 ) iz = 10;
352 int AliHLTTPCCADisplay::GetColorY( double y ) const
354 // Get color with respect to Z coordinate
355 const Color_t kMyColor[11] = { kGreen, kBlue, kYellow, kMagenta, kCyan,
356 kOrange, kSpring, kTeal, kAzure, kViolet, kPink
359 double yy = ( y - fYMin ) / ( fYMax - fYMin );
360 int iy = ( int ) ( yy * 11 );
361 if ( iy < 0 ) iy = 0;
362 if ( iy > 10 ) iy = 10;
366 int AliHLTTPCCADisplay::GetColorK( double k ) const
368 // Get color with respect to Z coordinate
369 const Color_t kMyColor[11] = { kRed, kBlue, kYellow, kMagenta, kCyan,
370 kOrange, kSpring, kTeal, kAzure, kViolet, kPink
372 const double kCLight = 0.000299792458;
373 const double kBz = 5;
375 if ( TMath::Abs( kBz ) > 1.e-4 ) k2QPt = 1. / ( kBz * kCLight );
376 double qPt = k * k2QPt;
378 if ( TMath::Abs( qPt ) > 1.e-4 ) pt = 1. / TMath::Abs( qPt );
380 double yy = ( pt - 0.1 ) / ( 1. - 0.1 );
381 int iy = ( int ) ( yy * 11 );
382 if ( iy < 0 ) iy = 0;
383 if ( iy > 10 ) iy = 10;
387 void AliHLTTPCCADisplay::Global2View( double x, double y, double *xv, double *yv ) const
389 // convert coordinates global->view
390 *xv = x * fCos + y * fSin;
391 *yv = y * fCos - x * fSin;
395 void AliHLTTPCCADisplay::Slice2View( double x, double y, double *xv, double *yv ) const
397 // convert coordinates slice->view
398 double xg = x * fSliceCos - y * fSliceSin;
399 double yg = y * fSliceCos + x * fSliceSin;
400 *xv = xg * fCos - yg * fSin;
401 *yv = yg * fCos + xg * fSin;
404 void AliHLTTPCCADisplay::SliceHitXYZ(int iRow, int iHit, double &x, double &y, double &z )
406 // get xyz of the hit
408 if ( !fSlice ) return;
409 const AliHLTTPCCARow &row = fSlice->Row( iRow );
410 float y0 = row.Grid().YMin();
411 float z0 = row.Grid().ZMin();
412 float stepY = row.HstepY();
413 float stepZ = row.HstepZ();
415 y = y0 + fSlice->HitDataY( row, iHit ) * stepY;
416 z = z0 + fSlice->HitDataZ( row, iHit ) * stepZ;
419 void AliHLTTPCCADisplay::DrawSliceHit( int iRow, int iHit, int color, Size_t width )
422 if ( !fSlice ) return;
425 SliceHitXYZ( iRow, iHit, x, y, z );
427 SetSliceTransform( fSlice );
430 //if ( 0 && fPerf ) {
431 //AliHLTTPCCAPerformance::AliHLTTPCCAHitLabel lab
432 //= fPerf->GetClusterLabel( fSlice->Param().ISlice(), fSlice->HitInputID( row, iHit ) );
433 //color = GetColor( lab[0] + 1 );
434 //if ( lab[0] >= 0 ) {
435 //AliHLTTPCCAMCTrack &mc = fPerf->MCTracks()[lab];
436 //if ( mc.P() >= 1. ) color = kRed;
437 //else if ( fDrawOnlyRef ) return;
440 color = GetColorZ( z );
442 if ( width > 0 )fMarker.SetMarkerSize( width );
443 else fMarker.SetMarkerSize( .3 );
444 fMarker.SetMarkerColor( color );
446 Slice2View( x, y, &vx, &vy );
448 fMarker.DrawMarker( vx, vy );
450 fMarker.DrawMarker( z, vy );
453 void AliHLTTPCCADisplay::DrawSliceHits( int color, Size_t width )
458 for ( int iRow = 0; iRow < fSlice->Param().NRows(); iRow++ ) {
459 const AliHLTTPCCARow &row = fSlice->Row( iRow );
460 for ( int ih = 0; ih < row.NHits(); ih++ ) {
461 DrawSliceHit( iRow, ih, color, width );
467 void AliHLTTPCCADisplay::DrawSliceLink( int iRow, int iHit, int colorUp, int colorDn, int width )
469 // draw link between clusters
471 //if ( !fPerf ) return;
472 //AliHLTTPCCAGBTracker &tracker = *fGB;
473 if ( width < 0 ) width = 1;
474 fLine.SetLineWidth( width );
475 int colUp = colorUp >= 0 ? colorUp : kMagenta;
476 int colDn = colorDn >= 0 ? colorDn : kBlack;
477 if ( iRow < 2 || iRow >= fSlice->Param().NRows() - 2 ) return;
479 const AliHLTTPCCARow& row = fSlice->Data().Row( iRow );
481 short iUp = fSlice->HitLinkUpData( row, iHit );
482 short iDn = fSlice->HitLinkDownData( row, iHit );
485 double p1[3], p2[3], p3[3];
486 SliceHitXYZ( iRow, iHit, p1[0],p1[1],p1[2]);
488 double vx, vy, vx1, vy1;
489 Slice2View( p1[0], p1[1], &vx, &vy );
492 SliceHitXYZ( iRow+2, iUp, p2[0],p2[1],p2[2]);
493 Slice2View( p2[0], p2[1], &vx1, &vy1 );
494 fLine.SetLineColor( colUp );
496 fLine.DrawLine( vx - .1, vy, vx1 - .1, vy1 );
498 fLine.DrawLine( p1[2] - 1., vy, p2[2] - 1., vy1 );
501 SliceHitXYZ( iRow-2, iDn, p3[0],p3[1],p3[2]);
502 Slice2View( p3[0], p3[1], &vx1, &vy1 );
503 fLine.SetLineColor( colDn );
505 fLine.DrawLine( vx + .1, vy, vx1 + .1, vy1 );
507 fLine.DrawLine( p1[2] + 1., vy, p3[2] + 1., vy1 );
513 void AliHLTTPCCADisplay::DrawSliceLinks( int colorUp, int colorDn, int width )
515 // draw links between clusters
517 for ( int iRow = 1; iRow < fSlice->Param().NRows() - 1; iRow++ ) {
518 const AliHLTTPCCARow& row = fSlice->Row( iRow );
519 for ( int ih = 0; ih < row.NHits(); ih++ ) {
520 DrawSliceLink( iRow, ih, colorUp, colorDn, width );
527 int AliHLTTPCCADisplay::GetTrackMC( const AliHLTTPCCADisplayTmpHit */*vHits*/, int /*NHits*/ )
529 // get MC label for the track
532 AliHLTTPCCAGBTracker &tracker = *fGB;
536 int *lb = new int[NHits*3];
538 //std::cout<<"\n\nTrack hits mc: "<<std::endl;
539 for ( int ihit = 0; ihit < NHits; ihit++ ) {
540 const AliHLTTPCCAGBHit &h = tracker.Hits()[vHits[ihit].ID()];
541 AliHLTTPCCAPerformance::AliHLTTPCCAHitLabel &l = fPerf->HitLabels()[h.ID()];
542 if ( l.fLab[0] >= 0 ) lb[nla++] = l.fLab[0];
543 if ( l.fLab[1] >= 0 ) lb[nla++] = l.fLab[1];
544 if ( l.fLab[2] >= 0 ) lb[nla++] = l.fLab[2];
545 //std::cout<<ihit<<": "<<l.fLab[0]<<" "<<l.fLab[1]<<" "<<l.fLab[2]<<std::endl;
547 sort( lb, lb + nla );
548 int labmax = -1, labcur = -1, lmax = 0, lcurr = 0, nh = 0;
549 //std::cout<<"MC track IDs :"<<std::endl;
550 for ( int i = 0; i < nla; i++ ) {
551 if ( lb[i] != labcur ) {
552 if ( 0 && i > 0 && lb[i-1] >= 0 ) {
553 AliHLTTPCCAMCTrack &mc = fPerf->MCTracks()[lb[i-1]];
554 std::cout << lb[i-1] << ": nhits=" << nh << ", pdg=" << mc.PDG() << ", Pt=" << mc.Pt() << ", P=" << mc.P()
555 << ", par=" << mc.Par()[0] << " " << mc.Par()[1] << " " << mc.Par()[2]
556 << " " << mc.Par()[3] << " " << mc.Par()[4] << " " << mc.Par()[5] << " " << mc.Par()[6] << std::endl;
560 if ( labcur >= 0 && lmax < lcurr ) {
570 if ( 0 && nla - 1 > 0 && lb[nla-1] >= 0 ) {
571 AliHLTTPCCAMCTrack &mc = fPerf->MCTracks()[lb[nla-1]];
572 std::cout << lb[nla-1] << ": nhits=" << nh << ", pdg=" << mc.PDG() << ", Pt=" << mc.Pt() << ", P=" << mc.P()
573 << ", par=" << mc.Par()[0] << " " << mc.Par()[1] << " " << mc.Par()[2]
574 << " " << mc.Par()[3] << " " << mc.Par()[4] << " " << mc.Par()[5] << " " << mc.Par()[6] << std::endl;
577 if ( labcur >= 0 && lmax < lcurr ) {
582 for ( int ihit = 0; ihit < NHits; ihit++ ) {
583 const AliHLTTPCCAGBHit &h = tracker.Hits()[vHits[ihit].ID()];
584 AliHLTTPCCAPerformance::AliHLTTPCCAHitLabel &l = fPerf->HitLabels()[h.ID()];
585 if ( l.fLab[0] == labmax || l.fLab[1] == labmax || l.fLab[2] == labmax
589 purity = ( ( NHits > 0 ) ? double( lmax ) / double( NHits ) : 0 );
590 if ( lb ) delete[] lb;
591 if ( purity < .9 ) label = -1;
596 bool AliHLTTPCCADisplay::DrawTrack( AliHLTTPCCATrackParam /*t*/, double /*Alpha*/, const AliHLTTPCCADisplayTmpHit */*vHits*/,
597 int /*NHits*/, int /*color*/, int /*width*/, bool /*pPoint*/ )
602 if ( NHits < 2 ) return 0;
604 //AliHLTTPCCAGBTracker &tracker = *fGB;
605 if ( width < 0 ) width = 2;
607 if ( fDrawOnlyRef ) {
608 int lab = GetTrackMC( vHits, NHits );
609 if ( lab < 0 ) return 0;
610 AliHLTTPCCAMCTrack &mc = fPerf->MCTracks()[lab];
611 if ( mc.P() < 1 ) return 0;
615 //color = GetColorZ( (vz[0]+vz[mHits-1])/2. );
616 //color = GetColorK(t.GetKappa());
617 int lab = GetTrackMC( vHits, NHits );
618 color = GetColor( lab + 1 );
620 AliHLTTPCCAMCTrack &mc = fPerf->MCTracks()[lab];
621 if ( mc.P() >= 1. ) color = kRed;
625 if ( t.SinPhi() > .999 ) t.SetSinPhi( .999 );
626 else if ( t.SinPhi() < -.999 ) t.SetSinPhi( -.999 );
628 // int iSlice = fSlice->Param().ISlice();
630 //sort(vHits, vHits + NHits, AliHLTTPCCADisplayTmpHit::CompareHitZ );
632 double vx[2000], vy[2000], vz[2000];
636 double alpha = ( TMath::Abs( Alpha + 1 ) < 1.e-4 ) ? fSlice->Param().Alpha() : Alpha;
637 AliHLTTPCCATrackParam tt = t;
639 for ( int iHit = 0; iHit < NHits; iHit++ ) {
641 const AliHLTTPCCAGBHit &h = tracker.Hits()[vHits[iHit].ID()];
643 double hCos = TMath::Cos( alpha - tracker.Slices()[h.ISlice()].Param().Alpha() );
644 double hSin = TMath::Sin( alpha - tracker.Slices()[h.ISlice()].Param().Alpha() );
645 double x0 = h.X(), y0 = h.Y(), z1 = h.Z();
646 double x1 = x0 * hCos + y0 * hSin;
647 double y1 = y0 * hCos - x0 * hSin;
650 double dx = x1 - tt.X();
651 double dy = y1 - tt.Y();
652 if ( dx*dx + dy*dy > 1. ) {
653 double dalpha = TMath::ATan2( dy, dx );
654 if ( tt.Rotate( dalpha ) ) {
656 hCos = TMath::Cos( alpha - tracker.Slices()[h.ISlice()].Param().Alpha() );
657 hSin = TMath::Sin( alpha - tracker.Slices()[h.ISlice()].Param().Alpha() );
658 x1 = x0 * hCos + y0 * hSin;
659 y1 = y0 * hCos - x0 * hSin;
663 SetSliceTransform( alpha );
665 //t.GetDCAPoint( x1, y1, z1, x1, y1, z1 );
666 std::cout << "mark 3" << std::endl;
667 bool ok = tt.TransportToX( x1, .999 );
668 std::cout << "mark 4" << std::endl;
675 Slice2View( x1, y1, &x1, &y1 );
680 for ( int j = 0; j < 0; j++ ) {
681 x0 = h.X() + j; y0 = h.Y(); z1 = h.Z();
682 x1 = x0 * hCos + y0 * hSin;
683 y1 = y0 * hCos - x0 * hSin;
684 ok = tt.TransportToX( x1, .999 );
691 Slice2View( x1, y1, &x1, &y1 );
699 double x1 = t.X(), y1 = t.Y(), z1 = t.Z();
700 double a = ( TMath::Abs( Alpha + 1 ) < 1.e-4 ) ? fSlice->Param().Alpha() : Alpha;
701 SetSliceTransform( a );
703 Slice2View( x1, y1, &x1, &y1 );
704 double dx = x1 - vx[0];
705 double dy = y1 - vy[0];
706 //std::cout<<x1<<" "<<y1<<" "<<vx[0]<<" "<<vy[0]<<" "<<dx<<" "<<dy<<std::endl;
707 double d0 = dx * dx + dy * dy;
708 dx = x1 - vx[mHits-1];
709 dy = y1 - vy[mHits-1];
710 //std::cout<<x1<<" "<<y1<<" "<<vx[mHits-1]<<" "<<vy[mHits-1]<<" "<<dx<<" "<<dy<<std::endl;
711 double d1 = dx * dx + dy * dy;
712 //std::cout<<"d0, d1="<<d0<<" "<<d1<<std::endl;
719 for ( int i = mHits; i > 0; i-- ) {
732 fLine.SetLineColor( color );
733 fLine.SetLineWidth( width );
734 fArc.SetFillStyle( 0 );
735 fArc.SetLineColor( color );
736 fArc.SetLineWidth( width );
738 pl.SetLineColor( color );
739 pl.SetLineWidth( width );
741 plZ.SetLineColor( color );
742 plZ.SetLineWidth( width );
744 fMarker.SetMarkerSize( width / 2. );
745 fMarker.SetMarkerColor( color );
748 pl.DrawPolyLine( mHits, vx, vy );
750 fMarker.DrawMarker( vx[0], vy[0] );
751 fMarker.DrawMarker( vx[mHits-1], vy[mHits-1] );
754 plZ.DrawPolyLine( mHits, vz, vy );
755 fMarker.DrawMarker( vz[0], vy[0] );
756 fMarker.DrawMarker( vz[mHits-1], vy[mHits-1] );
758 fLine.SetLineWidth( 1 );
764 bool AliHLTTPCCADisplay::DrawTracklet( AliHLTTPCCATrackParam &/*track*/, const int */*hitstore*/, int /*color*/, int /*width*/, bool /*pPoint*/ )
768 AliHLTTPCCAGBTracker &tracker = *fGB;
769 AliHLTTPCCADisplayTmpHit vHits[200];
771 for ( int iRow = 0; iRow < fSlice->Param().NRows(); iRow++ ) {
772 int iHit = hitstore[iRow];
773 if ( iHit < 0 ) continue;
774 const AliHLTTPCCARow &row = fSlice->Row( iRow );
775 int id = fSlice->HitInputID( row, iHit );
776 int iGBHit = tracker.FirstSliceHit()[fSlice->Param().ISlice()] + id;
777 const AliHLTTPCCAGBHit &h = tracker.Hits()[iGBHit];
778 vHits[nHits].SetID( iGBHit );
779 vHits[nHits].SetS( 0 );
780 vHits[nHits].SetZ( h.Z() );
783 return DrawTrack( track, -1, vHits, nHits, color, width, pPoint );
789 void AliHLTTPCCADisplay::DrawSliceOutTrack( AliHLTTPCCATrackParam &/*t*/, double /*alpha*/, int /*itr*/, int /*color*/, int /*width*/ )
793 AliHLTTPCCAOutTrack &track = fSlice->OutTracks()[itr];
794 if ( track.NHits() < 2 ) return;
796 AliHLTTPCCAGBTracker &tracker = *fGB;
797 AliHLTTPCCADisplayTmpHit vHits[200];
799 for ( int ih = 0; ih < track.NHits(); ih++ ) {
800 int id = tracker.FirstSliceHit()[fSlice->Param().ISlice()] + fSlice->OutTrackHit(track.FirstHitRef()+ih);
801 const AliHLTTPCCAGBHit &h = tracker.Hits()[id];
802 vHits[ih].SetID( id );
804 vHits[ih].SetZ( h.Z() );
807 DrawTrack( t, alpha, vHits, track.NHits(), color, width, 1 );
811 void AliHLTTPCCADisplay::DrawSliceOutTrack( int /*itr*/, int /*color*/, int /*width*/ )
815 AliHLTTPCCAOutTrack &track = fSlice->OutTracks()[itr];
816 if ( track.NHits() < 2 ) return;
818 AliHLTTPCCAGBTracker &tracker = *fGB;
819 AliHLTTPCCADisplayTmpHit vHits[200];
821 for ( int ih = 0; ih < track.NHits(); ih++ ) {
822 int id = tracker.FirstSliceHit()[fSlice->Param().ISlice()] + fSlice->OutTrackHit(track.FirstHitRef()+ih);
823 const AliHLTTPCCAGBHit &h = tracker.Hits()[id];
824 vHits[ih].SetID( id );
826 vHits[ih].SetZ( h.Z() );
829 DrawTrack( track.StartPoint(), -1, vHits, track.NHits(), color, width );
834 void AliHLTTPCCADisplay::DrawSliceTrack( int /*itr*/, int /*color*/ )
838 const AliHLTTPCCATrack &track = fSlice->Tracks()[itr];
839 if ( track.NHits() < 2 ) return;
841 AliHLTTPCCAGBTracker &tracker = *fGB;
842 AliHLTTPCCADisplayTmpHit vHits[200];
843 for ( int ith = 0; ith < track.NHits(); ith++ ) {
844 AliHLTTPCCAHitId ic = ( fSlice->TrackHits()[track.FirstHitID()+ith] );
845 const AliHLTTPCCARow &row = fSlice->Row( ic );
846 int ih = ic.HitIndex();
847 int id = fSlice->HitInputID( row, ih );
848 int gbID = tracker.FirstSliceHit()[fSlice->Param().ISlice()] + id;
849 const AliHLTTPCCAGBHit &h = tracker.Hits()[gbID];
850 vHits[ith].SetID( gbID );
851 vHits[ith].SetS( 0 );
852 vHits[ith].SetZ( h.Z() );
855 DrawTrack( track.Param(), -1, vHits, track.NHits(), color, -1 );
856 //track.Param().Print();