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"
30 #include "AliHLTTPCCAOutTrack.h"
33 #include "Riostream.h"
37 #include "TApplication.h"
40 class AliHLTTPCCADisplay::AliHLTTPCCADisplayTmpHit
45 int ID() const { return fHitID; }
46 double S() const { return fS; }
47 double Z() const { return fZ; }
49 void SetID( int v ) { fHitID = v; }
50 void SetS( double v ) { fS = v; }
51 void SetZ( double v ) { fZ = v; }
53 static bool CompareHitDS( const AliHLTTPCCADisplayTmpHit &a,
54 const AliHLTTPCCADisplayTmpHit &b ) {
55 return ( a.fS < b.fS );
58 static bool CompareHitZ( const AliHLTTPCCADisplayTmpHit &a,
59 const AliHLTTPCCADisplayTmpHit &b ) {
60 return ( a.fZ < b.fZ );
66 double fS; // hit position on the XY track curve
67 double fZ; // hit Z position
73 AliHLTTPCCADisplay &AliHLTTPCCADisplay::Instance()
75 // reference to static object
76 static AliHLTTPCCADisplay gAliHLTTPCCADisplay;
77 static bool firstCall = 1;
79 if ( !gApplication ) new TApplication( "myapp", 0, 0 );
80 gAliHLTTPCCADisplay.Init();
83 return gAliHLTTPCCADisplay;
86 AliHLTTPCCADisplay::AliHLTTPCCADisplay() : fYX( 0 ), fZX( 0 ), fAsk( 1 ), fSliceView( 1 ), fSlice( 0 ), fPerf( 0 ),
87 fCos( 1 ), fSin( 0 ), fZMin( -250 ), fZMax( 250 ), fYMin( -250 ), fYMax( 250 ), fSliceCos( 1 ), fSliceSin( 0 ),
88 fRInnerMin( 83.65 ), fRInnerMax( 133.3 ), fROuterMin( 133.5 ), fROuterMax( 247.7 ),
89 fTPCZMin( -250. ), fTPCZMax( 250 ), fArc(), fLine(), fPLine(), fMarker(), fBox(), fCrown(), fLatex(), fDrawOnlyRef( 0 )
91 fPerf = &( AliHLTTPCCAPerformance::Instance() );
96 AliHLTTPCCADisplay::AliHLTTPCCADisplay( const AliHLTTPCCADisplay& )
97 : fYX( 0 ), fZX( 0 ), fAsk( 1 ), fSliceView( 1 ), fSlice( 0 ), fPerf( 0 ),
98 fCos( 1 ), fSin( 0 ), fZMin( -250 ), fZMax( 250 ), fYMin( -250 ), fYMax( 250 ), fSliceCos( 1 ), fSliceSin( 0 ),
99 fRInnerMin( 83.65 ), fRInnerMax( 133.3 ), fROuterMin( 133.5 ), fROuterMax( 247.7 ),
100 fTPCZMin( -250. ), fTPCZMax( 250 ), fArc(), fLine(), fPLine(), fMarker(), fBox(), fCrown(), fLatex(), fDrawOnlyRef( 0 )
105 const AliHLTTPCCADisplay& AliHLTTPCCADisplay::operator=( const AliHLTTPCCADisplay& ) const
111 AliHLTTPCCADisplay::~AliHLTTPCCADisplay()
118 void AliHLTTPCCADisplay::Init()
121 gStyle->SetCanvasBorderMode( 0 );
122 gStyle->SetCanvasBorderSize( 1 );
123 gStyle->SetCanvasColor( 0 );
124 fYX = new TCanvas ( "YX", "YX window", -1, 0, 600, 600 );
125 fZX = new TCanvas ( "ZX", "ZX window", -610, 0, 590, 600 );
126 fMarker = TMarker( 0.0, 0.0, 20 );//6);
130 void AliHLTTPCCADisplay::Update()
136 fYX->Print( "YX.pdf" );
137 fZX->Print( "ZX.pdf" );
141 void AliHLTTPCCADisplay::ClearView()
148 void AliHLTTPCCADisplay::Ask()
150 // wait for the pressed key, when "r" pressed, don't ask anymore
154 std::cout << "ask> " << std::endl;
156 std::cin.get( symbol );
159 } while ( symbol != '\n' );
164 void AliHLTTPCCADisplay::SetSliceView()
166 // switch to slice view
170 void AliHLTTPCCADisplay::SetTPCView()
172 // switch to full TPC view
183 void AliHLTTPCCADisplay::SetCurrentSlice( AliHLTTPCCATracker *slice )
185 // set reference to the current CA tracker, and read the current slice geometry
187 SetSliceTransform( slice );
189 fCos = slice->Param().SinAlpha();
190 fSin = slice->Param().CosAlpha();
191 fZMin = slice->Param().ZMin();
192 fZMax = slice->Param().ZMax();
194 double r0 = .5 * ( slice->Param().RMax() + slice->Param().RMin() );
195 double dr = .5 * ( slice->Param().RMax() - slice->Param().RMin() );
200 double cz = .5 * ( slice->Param().ZMax() + slice->Param().ZMin() );
201 double dz = .5 * ( slice->Param().ZMax() - slice->Param().ZMin() ) * 1.2;
202 fYX->Range( cx - dr, cy - dr*1.05, cx + dr, cy + dr );
203 fZX->Range( cz - dz, cy - dr*1.05, cz + dz, cy + dr );
205 //fYX->Range(cx-dr*.3, cy-dr*1.05, cx+dr*.3, cy-dr*.35);
206 //fZX->Range(cz-dz, cy-dr*1.05, cz+dz, cy-dr*.3);
208 //fYX->Range(cx-dr*.3, cy-dr*.8, cx-dr*.1, cy-dr*.75);
209 //fZX->Range(cz-dz*0, cy-dr*.8, cz+dz, cy-dr*.75);
211 //fYX->Range(cx-dr*.08, cy-dr*1., cx-dr*.02, cy-dr*0.7);
212 //fZX->Range(cz-dz*.2, cy-dr*1., cz-dz*.05, cy-dr*0.7);
214 //double x0 = cx-dr*.1, x1 = cx-dr*.05;
215 //double y0 = cy-dr*1.05, y1 = cy-dr*0.7;
216 //double z0 = cz-dz*.3, z1 = cz;
217 //double xc = (x0+x1)/2, yc= (y0+y1)/2, zc=(z0+z1)/2;
218 //double d = TMath::Max((x1-x0)/2,TMath::Max((y1-y0)/2,(z1-z0)/2));
219 //fYX->Range(xc-d, yc-d, xc+d, yc+d);
220 //fZX->Range(zc-d, yc-d, zc+d, yc+d);
225 void AliHLTTPCCADisplay::SetSliceTransform( double alpha )
227 fSliceCos = TMath::Cos( alpha );
228 fSliceSin = TMath::Sin( alpha );
231 void AliHLTTPCCADisplay::SetSliceTransform( AliHLTTPCCATracker *slice )
233 SetSliceTransform( slice->Param().Alpha() );
237 void AliHLTTPCCADisplay::DrawTPC()
239 // schematically draw TPC detector
240 fYX->Range( -fROuterMax, -fROuterMax, fROuterMax, fROuterMax );
241 //fYX->Range( -fROuterMax*.7, -fROuterMax, fROuterMax*0., -fROuterMax*.5);
244 fArc.SetLineColor( kBlack );
245 fArc.SetFillStyle( 0 );
247 for ( int iSlice = 0; iSlice < 18; iSlice++ ) {
248 fCrown.SetLineColor( kBlack );
249 fCrown.SetFillStyle( 0 );
250 fCrown.DrawCrown( 0, 0, fRInnerMin, fRInnerMax, 360. / 18.*iSlice, 360. / 18.*( iSlice + 1 ) );
251 fCrown.DrawCrown( 0, 0, fROuterMin, fROuterMax, 360. / 18.*iSlice, 360. / 18.*( iSlice + 1 ) );
255 fZX->Range( fTPCZMin, -fROuterMax, fTPCZMax*1.1, fROuterMax );
256 //fZX->Range( fTPCZMax*.1, -fROuterMax, fTPCZMax*.3, -fROuterMax*0.5 );
260 void AliHLTTPCCADisplay::DrawSlice( AliHLTTPCCATracker *slice, bool DrawRows )
262 // draw current the TPC slice
264 double r0 = .5 * ( slice->Param().RMax() + slice->Param().RMin() );
265 double dr = .5 * ( slice->Param().RMax() - slice->Param().RMin() );
266 double cx = r0 * slice->Param().CosAlpha();
267 double cy = r0 * slice->Param().SinAlpha();
268 double raddeg = 180. / 3.1415;
269 double a0 = raddeg * .5 * ( slice->Param().AngleMax() + slice->Param().AngleMin() );
270 double da = raddeg * .5 * ( slice->Param().AngleMax() - slice->Param().AngleMin() );
274 fLatex.DrawLatex( cx - dr + dr*.05, cy - dr + dr*.05, Form( "YX, Slice %2i", slice->Param().ISlice() ) );
276 a0 += raddeg * TMath::ATan2( fSin, fCos );
278 fArc.SetLineColor( kBlack );
279 fArc.SetFillStyle( 0 );
280 fCrown.SetLineColor( kBlack );
281 fCrown.SetFillStyle( 0 );
282 fCrown.DrawCrown( 0, 0, fRInnerMin, fRInnerMax, a0 - da, a0 + da );
283 fCrown.DrawCrown( 0, 0, fROuterMin, fROuterMax, a0 - da, a0 + da );
284 //fCrown.DrawCrown(0,0, slice->Param().RMin(),slice->Param().RMax(), a0-da, a0+da );
286 fLine.SetLineColor( kBlack );
290 double cz = .5 * ( slice->Param().ZMax() + slice->Param().ZMin() );
291 double dz = .5 * ( slice->Param().ZMax() - slice->Param().ZMin() ) * 1.2;
292 //fLine.DrawLine(cz+dz, cy-dr, cz+dz, cy+dr );
293 if ( fSliceView ) fLatex.DrawLatex( cz - dz + dz*.05, cy - dr + dr*.05, Form( "ZX, Slice %2i", slice->Param().ISlice() ) );
296 fLine.SetLineWidth( 1 );
297 fLine.SetLineColor( kBlack );
298 SetSliceTransform( fSlice );
299 for ( int iRow = 0; iRow < fSlice->Param().NRows(); iRow++ ) {
300 double x = fSlice->Row( iRow ).X();
301 double y = fSlice->Row( iRow ).MaxY();
302 double vx0, vy0, vx1, vy1;
303 Slice2View( x, y, &vx0, &vy0 );
304 Slice2View( x, -y, &vx1, &vy1 );
306 fLine.DrawLine( vx0, vy0, vx1, vy1 );
308 fLine.DrawLine( fTPCZMin, vy0, fTPCZMax, vy1 );
315 void AliHLTTPCCADisplay::Set2Slices( AliHLTTPCCATracker * const slice )
317 //* Set view for two neighbouring slices
321 fCos = TMath::Cos( TMath::Pi() / 2 - ( slice->Param().Alpha() + 10. / 180.*TMath::Pi() ) );
322 fSin = TMath::Sin( TMath::Pi() / 2 - ( slice->Param().Alpha() + 10. / 180.*TMath::Pi() ) );
323 fZMin = slice->Param().ZMin();
324 fZMax = slice->Param().ZMax();
326 double r0 = .5 * ( slice->Param().RMax() + slice->Param().RMin() );
327 double dr = .5 * ( slice->Param().RMax() - slice->Param().RMin() );
330 fYX->Range( cx - 1.3*dr, cy - 1.1*dr, cx + 1.3*dr, cy + 1.1*dr );
332 int islice = slice->Param().ISlice();
333 int jslice = slice->Param().ISlice() + 1;
334 if ( islice == 17 ) jslice = 0;
335 else if ( islice == 35 ) jslice = 18;
336 fLatex.DrawLatex( cx - 1.3*dr + 1.3*dr*.05, cy - dr + dr*.05, Form( "YX, Slices %2i/%2i", islice, jslice ) );
337 double cz = .5 * ( slice->Param().ZMax() + slice->Param().ZMin() );
338 double dz = .5 * ( slice->Param().ZMax() - slice->Param().ZMin() ) * 1.2;
339 fZX->Range( cz - dz, cy - 1.1*dr, cz + dz, cy + 1.1*dr );//+dr);
341 fLatex.DrawLatex( cz - dz + dz*.05, cy - dr + dr*.05, Form( "ZX, Slices %2i/%2i", islice, jslice ) );
344 int AliHLTTPCCADisplay::GetColor( int i ) const
346 // Get color with respect to Z coordinate
347 const Color_t kMyColor[9] = { kGreen, kBlue, kYellow, kCyan, kOrange,
348 kSpring, kTeal, kAzure, kViolet
351 if ( i == 0 ) return kBlack;
352 return kMyColor[( i-1 )%9];
355 int AliHLTTPCCADisplay::GetColorZ( double z ) const
357 // Get color with respect to Z coordinate
358 const Color_t kMyColor[11] = { kGreen, kBlue, kYellow, kMagenta, kCyan,
359 kOrange, kSpring, kTeal, kAzure, kViolet, kPink
362 double zz = ( z - fZMin ) / ( fZMax - fZMin );
363 int iz = ( int ) ( zz * 11 );
364 if ( iz < 0 ) iz = 0;
365 if ( iz > 10 ) iz = 10;
369 int AliHLTTPCCADisplay::GetColorY( double y ) const
371 // Get color with respect to Z coordinate
372 const Color_t kMyColor[11] = { kGreen, kBlue, kYellow, kMagenta, kCyan,
373 kOrange, kSpring, kTeal, kAzure, kViolet, kPink
376 double yy = ( y - fYMin ) / ( fYMax - fYMin );
377 int iy = ( int ) ( yy * 11 );
378 if ( iy < 0 ) iy = 0;
379 if ( iy > 10 ) iy = 10;
383 int AliHLTTPCCADisplay::GetColorK( double k ) const
385 // Get color with respect to Z coordinate
386 const Color_t kMyColor[11] = { kRed, kBlue, kYellow, kMagenta, kCyan,
387 kOrange, kSpring, kTeal, kAzure, kViolet, kPink
389 const double kCLight = 0.000299792458;
390 const double kBz = 5;
392 if ( TMath::Abs( kBz ) > 1.e-4 ) k2QPt = 1. / ( kBz * kCLight );
393 double qPt = k * k2QPt;
395 if ( TMath::Abs( qPt ) > 1.e-4 ) pt = 1. / TMath::Abs( qPt );
397 double yy = ( pt - 0.1 ) / ( 1. - 0.1 );
398 int iy = ( int ) ( yy * 11 );
399 if ( iy < 0 ) iy = 0;
400 if ( iy > 10 ) iy = 10;
404 void AliHLTTPCCADisplay::Global2View( double x, double y, double *xv, double *yv ) const
406 // convert coordinates global->view
407 *xv = x * fCos + y * fSin;
408 *yv = y * fCos - x * fSin;
412 void AliHLTTPCCADisplay::Slice2View( double x, double y, double *xv, double *yv ) const
414 // convert coordinates slice->view
415 double xg = x * fSliceCos - y * fSliceSin;
416 double yg = y * fSliceCos + x * fSliceSin;
417 *xv = xg * fCos - yg * fSin;
418 *yv = yg * fCos + xg * fSin;
422 void AliHLTTPCCADisplay::DrawSliceHit( int iRow, int iHit, int color, Size_t width )
425 if ( !fSlice ) return;
426 const AliHLTTPCCARow &row = fSlice->Row( iRow );
427 float y0 = row.Grid().YMin();
428 float z0 = row.Grid().ZMin();
429 float stepY = row.HstepY();
430 float stepZ = row.HstepZ();
432 float y = y0 + fSlice->HitDataY( row, iHit ) * stepY;
433 float z = z0 + fSlice->HitDataZ( row, iHit ) * stepZ;
435 SetSliceTransform( fSlice );
439 //AliHLTTPCCAPerformance::AliHLTTPCCAHitLabel lab
440 //= fPerf->GetClusterLabel( fSlice->Param().ISlice(), fSlice->HitInputID( row, iHit ) );
441 //color = GetColor( lab[0] + 1 );
442 //if ( lab[0] >= 0 ) {
443 //AliHLTTPCCAMCTrack &mc = fPerf->MCTracks()[lab];
444 //if ( mc.P() >= 1. ) color = kRed;
445 //else if ( fDrawOnlyRef ) return;
447 } else color = GetColorZ( z );
449 if ( width > 0 )fMarker.SetMarkerSize( width );
450 else fMarker.SetMarkerSize( .3 );
451 fMarker.SetMarkerColor( color );
453 Slice2View( x, y, &vx, &vy );
455 fMarker.DrawMarker( vx, vy );
457 fMarker.DrawMarker( z, vy );
460 void AliHLTTPCCADisplay::DrawSliceHits( int color, Size_t width )
465 for ( int iRow = 0; iRow < fSlice->Param().NRows(); iRow++ ) {
466 const AliHLTTPCCARow &row = fSlice->Row( iRow );
467 for ( int ih = 0; ih < row.NHits(); ih++ ) {
468 DrawSliceHit( iRow, ih, color, width );
474 void AliHLTTPCCADisplay::DrawSliceLink( int /*iRow*/, int /*iHit*/, int /*colorUp*/, int /*colorDn*/, int /*width*/ )
476 // draw link between clusters
478 if ( !fPerf || !fGB ) return;
479 AliHLTTPCCAGBTracker &tracker = *fGB;
480 if ( width < 0 ) width = 1.;
481 fLine.SetLineWidth( width );
482 int colUp = colorUp >= 0 ? colorUp : kMagenta;
483 int colDn = colorDn >= 0 ? colorDn : kBlack;
484 if ( iRow < 2 || iRow >= fSlice->Param().NRows() - 2 ) return;
486 const AliHLTTPCCARow& row = fSlice->Row( iRow );
487 const AliHLTTPCCARow& rowUp = fSlice->Row( iRow + 2 );
488 const AliHLTTPCCARow& rowDn = fSlice->Row( iRow - 2 );
490 int id = fSlice->HitInputID( row, iHit );
491 const AliHLTTPCCAGBHit &h = tracker.Hits()[tracker.FirstSliceHit()[fSlice->Param().ISlice()] + id];
492 short iUp = fSlice->HitLinkUpData( row, iHit );
493 short iDn = fSlice->HitLinkDownData( row, iHit );
496 int id1 = fSlice->HitInputID( rowUp, iUp );
497 const AliHLTTPCCAGBHit &h1 = tracker.Hits()[tracker.FirstSliceHit()[fSlice->Param().ISlice()] + id1];
498 double vx, vy, vx1, vy1;
499 Slice2View( h.X(), h.Y(), &vx, &vy );
500 Slice2View( h1.X(), h1.Y(), &vx1, &vy1 );
501 fLine.SetLineColor( colUp );
503 fLine.DrawLine( vx - .1, vy, vx1 - .1, vy1 );
505 fLine.DrawLine( h.Z() - 1., vy, h1.Z() - 1., vy1 );
508 int id1 = fSlice->HitInputID( rowDn, iDn );
509 const AliHLTTPCCAGBHit &h1 = tracker.Hits()[tracker.FirstSliceHit()[fSlice->Param().ISlice()] + id1];
510 double vx, vy, vx1, vy1;
511 Slice2View( h.X(), h.Y(), &vx, &vy );
512 Slice2View( h1.X(), h1.Y(), &vx1, &vy1 );
513 fLine.SetLineColor( colDn );
515 fLine.DrawLine( vx + .1, vy, vx1 + .1, vy1 );
517 fLine.DrawLine( h.Z() + 1., vy, h1.Z() + 1., vy1 );
523 void AliHLTTPCCADisplay::DrawSliceLinks( int colorUp, int colorDn, int width )
525 // draw links between clusters
527 for ( int iRow = 1; iRow < fSlice->Param().NRows() - 1; iRow++ ) {
528 const AliHLTTPCCARow& row = fSlice->Row( iRow );
529 for ( int ih = 0; ih < row.NHits(); ih++ ) {
530 DrawSliceLink( iRow, ih, colorUp, colorDn, width );
537 int AliHLTTPCCADisplay::GetTrackMC( const AliHLTTPCCADisplayTmpHit */*vHits*/, int /*NHits*/ )
539 // get MC label for the track
542 AliHLTTPCCAGBTracker &tracker = *fGB;
546 int *lb = new int[NHits*3];
548 //std::cout<<"\n\nTrack hits mc: "<<std::endl;
549 for ( int ihit = 0; ihit < NHits; ihit++ ) {
550 const AliHLTTPCCAGBHit &h = tracker.Hits()[vHits[ihit].ID()];
551 AliHLTTPCCAPerformance::AliHLTTPCCAHitLabel &l = fPerf->HitLabels()[h.ID()];
552 if ( l.fLab[0] >= 0 ) lb[nla++] = l.fLab[0];
553 if ( l.fLab[1] >= 0 ) lb[nla++] = l.fLab[1];
554 if ( l.fLab[2] >= 0 ) lb[nla++] = l.fLab[2];
555 //std::cout<<ihit<<": "<<l.fLab[0]<<" "<<l.fLab[1]<<" "<<l.fLab[2]<<std::endl;
557 sort( lb, lb + nla );
558 int labmax = -1, labcur = -1, lmax = 0, lcurr = 0, nh = 0;
559 //std::cout<<"MC track IDs :"<<std::endl;
560 for ( int i = 0; i < nla; i++ ) {
561 if ( lb[i] != labcur ) {
562 if ( 0 && i > 0 && lb[i-1] >= 0 ) {
563 AliHLTTPCCAMCTrack &mc = fPerf->MCTracks()[lb[i-1]];
564 std::cout << lb[i-1] << ": nhits=" << nh << ", pdg=" << mc.PDG() << ", Pt=" << mc.Pt() << ", P=" << mc.P()
565 << ", par=" << mc.Par()[0] << " " << mc.Par()[1] << " " << mc.Par()[2]
566 << " " << mc.Par()[3] << " " << mc.Par()[4] << " " << mc.Par()[5] << " " << mc.Par()[6] << std::endl;
570 if ( labcur >= 0 && lmax < lcurr ) {
580 if ( 0 && nla - 1 > 0 && lb[nla-1] >= 0 ) {
581 AliHLTTPCCAMCTrack &mc = fPerf->MCTracks()[lb[nla-1]];
582 std::cout << lb[nla-1] << ": nhits=" << nh << ", pdg=" << mc.PDG() << ", Pt=" << mc.Pt() << ", P=" << mc.P()
583 << ", par=" << mc.Par()[0] << " " << mc.Par()[1] << " " << mc.Par()[2]
584 << " " << mc.Par()[3] << " " << mc.Par()[4] << " " << mc.Par()[5] << " " << mc.Par()[6] << std::endl;
587 if ( labcur >= 0 && lmax < lcurr ) {
592 for ( int ihit = 0; ihit < NHits; ihit++ ) {
593 const AliHLTTPCCAGBHit &h = tracker.Hits()[vHits[ihit].ID()];
594 AliHLTTPCCAPerformance::AliHLTTPCCAHitLabel &l = fPerf->HitLabels()[h.ID()];
595 if ( l.fLab[0] == labmax || l.fLab[1] == labmax || l.fLab[2] == labmax
599 purity = ( ( NHits > 0 ) ? double( lmax ) / double( NHits ) : 0 );
600 if ( lb ) delete[] lb;
601 if ( purity < .9 ) label = -1;
606 bool AliHLTTPCCADisplay::DrawTrack( AliHLTTPCCATrackParam /*t*/, double /*Alpha*/, const AliHLTTPCCADisplayTmpHit */*vHits*/,
607 int /*NHits*/, int /*color*/, int /*width*/, bool /*pPoint*/ )
612 if ( NHits < 2 ) return 0;
614 //AliHLTTPCCAGBTracker &tracker = *fGB;
615 if ( width < 0 ) width = 2;
617 if ( fDrawOnlyRef ) {
618 int lab = GetTrackMC( vHits, NHits );
619 if ( lab < 0 ) return 0;
620 AliHLTTPCCAMCTrack &mc = fPerf->MCTracks()[lab];
621 if ( mc.P() < 1 ) return 0;
625 //color = GetColorZ( (vz[0]+vz[mHits-1])/2. );
626 //color = GetColorK(t.GetKappa());
627 int lab = GetTrackMC( vHits, NHits );
628 color = GetColor( lab + 1 );
630 AliHLTTPCCAMCTrack &mc = fPerf->MCTracks()[lab];
631 if ( mc.P() >= 1. ) color = kRed;
635 if ( t.SinPhi() > .999 ) t.SetSinPhi( .999 );
636 else if ( t.SinPhi() < -.999 ) t.SetSinPhi( -.999 );
638 // int iSlice = fSlice->Param().ISlice();
640 //sort(vHits, vHits + NHits, AliHLTTPCCADisplayTmpHit::CompareHitZ );
642 double vx[2000], vy[2000], vz[2000];
646 double alpha = ( TMath::Abs( Alpha + 1 ) < 1.e-4 ) ? fSlice->Param().Alpha() : Alpha;
647 AliHLTTPCCATrackParam tt = t;
649 for ( int iHit = 0; iHit < NHits; iHit++ ) {
651 const AliHLTTPCCAGBHit &h = tracker.Hits()[vHits[iHit].ID()];
653 double hCos = TMath::Cos( alpha - tracker.Slices()[h.ISlice()].Param().Alpha() );
654 double hSin = TMath::Sin( alpha - tracker.Slices()[h.ISlice()].Param().Alpha() );
655 double x0 = h.X(), y0 = h.Y(), z1 = h.Z();
656 double x1 = x0 * hCos + y0 * hSin;
657 double y1 = y0 * hCos - x0 * hSin;
660 double dx = x1 - tt.X();
661 double dy = y1 - tt.Y();
662 if ( dx*dx + dy*dy > 1. ) {
663 double dalpha = TMath::ATan2( dy, dx );
664 if ( tt.Rotate( dalpha ) ) {
666 hCos = TMath::Cos( alpha - tracker.Slices()[h.ISlice()].Param().Alpha() );
667 hSin = TMath::Sin( alpha - tracker.Slices()[h.ISlice()].Param().Alpha() );
668 x1 = x0 * hCos + y0 * hSin;
669 y1 = y0 * hCos - x0 * hSin;
673 SetSliceTransform( alpha );
675 //t.GetDCAPoint( x1, y1, z1, x1, y1, z1 );
676 std::cout << "mark 3" << std::endl;
677 bool ok = tt.TransportToX( x1, .999 );
678 std::cout << "mark 4" << std::endl;
685 Slice2View( x1, y1, &x1, &y1 );
690 for ( int j = 0; j < 0; j++ ) {
691 x0 = h.X() + j; y0 = h.Y(); z1 = h.Z();
692 x1 = x0 * hCos + y0 * hSin;
693 y1 = y0 * hCos - x0 * hSin;
694 ok = tt.TransportToX( x1, .999 );
701 Slice2View( x1, y1, &x1, &y1 );
709 double x1 = t.X(), y1 = t.Y(), z1 = t.Z();
710 double a = ( TMath::Abs( Alpha + 1 ) < 1.e-4 ) ? fSlice->Param().Alpha() : Alpha;
711 SetSliceTransform( a );
713 Slice2View( x1, y1, &x1, &y1 );
714 double dx = x1 - vx[0];
715 double dy = y1 - vy[0];
716 //std::cout<<x1<<" "<<y1<<" "<<vx[0]<<" "<<vy[0]<<" "<<dx<<" "<<dy<<std::endl;
717 double d0 = dx * dx + dy * dy;
718 dx = x1 - vx[mHits-1];
719 dy = y1 - vy[mHits-1];
720 //std::cout<<x1<<" "<<y1<<" "<<vx[mHits-1]<<" "<<vy[mHits-1]<<" "<<dx<<" "<<dy<<std::endl;
721 double d1 = dx * dx + dy * dy;
722 //std::cout<<"d0, d1="<<d0<<" "<<d1<<std::endl;
729 for ( int i = mHits; i > 0; i-- ) {
742 fLine.SetLineColor( color );
743 fLine.SetLineWidth( width );
744 fArc.SetFillStyle( 0 );
745 fArc.SetLineColor( color );
746 fArc.SetLineWidth( width );
748 pl.SetLineColor( color );
749 pl.SetLineWidth( width );
751 plZ.SetLineColor( color );
752 plZ.SetLineWidth( width );
754 fMarker.SetMarkerSize( width / 2. );
755 fMarker.SetMarkerColor( color );
758 pl.DrawPolyLine( mHits, vx, vy );
760 fMarker.DrawMarker( vx[0], vy[0] );
761 fMarker.DrawMarker( vx[mHits-1], vy[mHits-1] );
764 plZ.DrawPolyLine( mHits, vz, vy );
765 fMarker.DrawMarker( vz[0], vy[0] );
766 fMarker.DrawMarker( vz[mHits-1], vy[mHits-1] );
768 fLine.SetLineWidth( 1 );
774 bool AliHLTTPCCADisplay::DrawTracklet( AliHLTTPCCATrackParam &/*track*/, const int */*hitstore*/, int /*color*/, int /*width*/, bool /*pPoint*/ )
778 AliHLTTPCCAGBTracker &tracker = *fGB;
779 AliHLTTPCCADisplayTmpHit vHits[200];
781 for ( int iRow = 0; iRow < fSlice->Param().NRows(); iRow++ ) {
782 int iHit = hitstore[iRow];
783 if ( iHit < 0 ) continue;
784 const AliHLTTPCCARow &row = fSlice->Row( iRow );
785 int id = fSlice->HitInputID( row, iHit );
786 int iGBHit = tracker.FirstSliceHit()[fSlice->Param().ISlice()] + id;
787 const AliHLTTPCCAGBHit &h = tracker.Hits()[iGBHit];
788 vHits[nHits].SetID( iGBHit );
789 vHits[nHits].SetS( 0 );
790 vHits[nHits].SetZ( h.Z() );
793 return DrawTrack( track, -1, vHits, nHits, color, width, pPoint );
799 void AliHLTTPCCADisplay::DrawSliceOutTrack( AliHLTTPCCATrackParam &/*t*/, double /*alpha*/, int /*itr*/, int /*color*/, int /*width*/ )
803 AliHLTTPCCAOutTrack &track = fSlice->OutTracks()[itr];
804 if ( track.NHits() < 2 ) return;
806 AliHLTTPCCAGBTracker &tracker = *fGB;
807 AliHLTTPCCADisplayTmpHit vHits[200];
809 for ( int ih = 0; ih < track.NHits(); ih++ ) {
810 int id = tracker.FirstSliceHit()[fSlice->Param().ISlice()] + fSlice->OutTrackHits()[track.FirstHitRef()+ih];
811 const AliHLTTPCCAGBHit &h = tracker.Hits()[id];
812 vHits[ih].SetID( id );
814 vHits[ih].SetZ( h.Z() );
817 DrawTrack( t, alpha, vHits, track.NHits(), color, width, 1 );
821 void AliHLTTPCCADisplay::DrawSliceOutTrack( int /*itr*/, int /*color*/, int /*width*/ )
825 AliHLTTPCCAOutTrack &track = fSlice->OutTracks()[itr];
826 if ( track.NHits() < 2 ) return;
828 AliHLTTPCCAGBTracker &tracker = *fGB;
829 AliHLTTPCCADisplayTmpHit vHits[200];
831 for ( int ih = 0; ih < track.NHits(); ih++ ) {
832 int id = tracker.FirstSliceHit()[fSlice->Param().ISlice()] + fSlice->OutTrackHits()[track.FirstHitRef()+ih];
833 const AliHLTTPCCAGBHit &h = tracker.Hits()[id];
834 vHits[ih].SetID( id );
836 vHits[ih].SetZ( h.Z() );
839 DrawTrack( track.StartPoint(), -1, vHits, track.NHits(), color, width );
844 void AliHLTTPCCADisplay::DrawSliceTrack( int /*itr*/, int /*color*/ )
848 const AliHLTTPCCATrack &track = fSlice->Tracks()[itr];
849 if ( track.NHits() < 2 ) return;
851 AliHLTTPCCAGBTracker &tracker = *fGB;
852 AliHLTTPCCADisplayTmpHit vHits[200];
853 for ( int ith = 0; ith < track.NHits(); ith++ ) {
854 AliHLTTPCCAHitId ic = ( fSlice->TrackHits()[track.FirstHitID()+ith] );
855 const AliHLTTPCCARow &row = fSlice->Row( ic );
856 int ih = ic.HitIndex();
857 int id = fSlice->HitInputID( row, ih );
858 int gbID = tracker.FirstSliceHit()[fSlice->Param().ISlice()] + id;
859 const AliHLTTPCCAGBHit &h = tracker.Hits()[gbID];
860 vHits[ith].SetID( gbID );
861 vHits[ith].SetS( 0 );
862 vHits[ith].SetZ( h.Z() );
865 DrawTrack( track.Param(), -1, vHits, track.NHits(), color, -1 );
866 //track.Param().Print();