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;
421 void AliHLTTPCCADisplay::SliceHitXYZ(int iRow, int iHit, double &x, double &y, double &z )
423 // get xyz of the hit
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 y = y0 + fSlice->HitDataY( row, iHit ) * stepY;
433 z = z0 + fSlice->HitDataZ( row, iHit ) * stepZ;
436 void AliHLTTPCCADisplay::DrawSliceHit( int iRow, int iHit, int color, Size_t width )
439 if ( !fSlice ) return;
442 SliceHitXYZ( iRow, iHit, x, y, z );
444 SetSliceTransform( fSlice );
448 //AliHLTTPCCAPerformance::AliHLTTPCCAHitLabel lab
449 //= fPerf->GetClusterLabel( fSlice->Param().ISlice(), fSlice->HitInputID( row, iHit ) );
450 //color = GetColor( lab[0] + 1 );
451 //if ( lab[0] >= 0 ) {
452 //AliHLTTPCCAMCTrack &mc = fPerf->MCTracks()[lab];
453 //if ( mc.P() >= 1. ) color = kRed;
454 //else if ( fDrawOnlyRef ) return;
456 } else color = GetColorZ( z );
458 if ( width > 0 )fMarker.SetMarkerSize( width );
459 else fMarker.SetMarkerSize( .3 );
460 fMarker.SetMarkerColor( color );
462 Slice2View( x, y, &vx, &vy );
464 fMarker.DrawMarker( vx, vy );
466 fMarker.DrawMarker( z, vy );
469 void AliHLTTPCCADisplay::DrawSliceHits( int color, Size_t width )
474 for ( int iRow = 0; iRow < fSlice->Param().NRows(); iRow++ ) {
475 const AliHLTTPCCARow &row = fSlice->Row( iRow );
476 for ( int ih = 0; ih < row.NHits(); ih++ ) {
477 DrawSliceHit( iRow, ih, color, width );
483 void AliHLTTPCCADisplay::DrawSliceLink( int iRow, int iHit, int colorUp, int colorDn, int width )
485 // draw link between clusters
487 //if ( !fPerf ) return;
488 //AliHLTTPCCAGBTracker &tracker = *fGB;
489 if ( width < 0 ) width = 1.;
490 fLine.SetLineWidth( width );
491 int colUp = colorUp >= 0 ? colorUp : kMagenta;
492 int colDn = colorDn >= 0 ? colorDn : kBlack;
493 if ( iRow < 2 || iRow >= fSlice->Param().NRows() - 2 ) return;
495 const AliHLTTPCCARow& row = fSlice->Data().Row( iRow );
497 short iUp = fSlice->HitLinkUpData( row, iHit );
498 short iDn = fSlice->HitLinkDownData( row, iHit );
501 double p1[3], p2[3], p3[3];
502 SliceHitXYZ( iRow, iHit, p1[0],p1[1],p1[2]);
504 double vx, vy, vx1, vy1;
505 Slice2View( p1[0], p1[1], &vx, &vy );
508 SliceHitXYZ( iRow+2, iUp, p2[0],p2[1],p2[2]);
509 Slice2View( p2[0], p2[1], &vx1, &vy1 );
510 fLine.SetLineColor( colUp );
512 fLine.DrawLine( vx - .1, vy, vx1 - .1, vy1 );
514 fLine.DrawLine( p1[2] - 1., vy, p2[2] - 1., vy1 );
517 SliceHitXYZ( iRow-2, iDn, p3[0],p3[1],p3[2]);
518 Slice2View( p3[0], p3[1], &vx1, &vy1 );
519 fLine.SetLineColor( colDn );
521 fLine.DrawLine( vx + .1, vy, vx1 + .1, vy1 );
523 fLine.DrawLine( p1[2] + 1., vy, p3[2] + 1., vy1 );
529 void AliHLTTPCCADisplay::DrawSliceLinks( int colorUp, int colorDn, int width )
531 // draw links between clusters
533 for ( int iRow = 1; iRow < fSlice->Param().NRows() - 1; iRow++ ) {
534 const AliHLTTPCCARow& row = fSlice->Row( iRow );
535 for ( int ih = 0; ih < row.NHits(); ih++ ) {
536 DrawSliceLink( iRow, ih, colorUp, colorDn, width );
543 int AliHLTTPCCADisplay::GetTrackMC( const AliHLTTPCCADisplayTmpHit */*vHits*/, int /*NHits*/ )
545 // get MC label for the track
548 AliHLTTPCCAGBTracker &tracker = *fGB;
552 int *lb = new int[NHits*3];
554 //std::cout<<"\n\nTrack hits mc: "<<std::endl;
555 for ( int ihit = 0; ihit < NHits; ihit++ ) {
556 const AliHLTTPCCAGBHit &h = tracker.Hits()[vHits[ihit].ID()];
557 AliHLTTPCCAPerformance::AliHLTTPCCAHitLabel &l = fPerf->HitLabels()[h.ID()];
558 if ( l.fLab[0] >= 0 ) lb[nla++] = l.fLab[0];
559 if ( l.fLab[1] >= 0 ) lb[nla++] = l.fLab[1];
560 if ( l.fLab[2] >= 0 ) lb[nla++] = l.fLab[2];
561 //std::cout<<ihit<<": "<<l.fLab[0]<<" "<<l.fLab[1]<<" "<<l.fLab[2]<<std::endl;
563 sort( lb, lb + nla );
564 int labmax = -1, labcur = -1, lmax = 0, lcurr = 0, nh = 0;
565 //std::cout<<"MC track IDs :"<<std::endl;
566 for ( int i = 0; i < nla; i++ ) {
567 if ( lb[i] != labcur ) {
568 if ( 0 && i > 0 && lb[i-1] >= 0 ) {
569 AliHLTTPCCAMCTrack &mc = fPerf->MCTracks()[lb[i-1]];
570 std::cout << lb[i-1] << ": nhits=" << nh << ", pdg=" << mc.PDG() << ", Pt=" << mc.Pt() << ", P=" << mc.P()
571 << ", par=" << mc.Par()[0] << " " << mc.Par()[1] << " " << mc.Par()[2]
572 << " " << mc.Par()[3] << " " << mc.Par()[4] << " " << mc.Par()[5] << " " << mc.Par()[6] << std::endl;
576 if ( labcur >= 0 && lmax < lcurr ) {
586 if ( 0 && nla - 1 > 0 && lb[nla-1] >= 0 ) {
587 AliHLTTPCCAMCTrack &mc = fPerf->MCTracks()[lb[nla-1]];
588 std::cout << lb[nla-1] << ": nhits=" << nh << ", pdg=" << mc.PDG() << ", Pt=" << mc.Pt() << ", P=" << mc.P()
589 << ", par=" << mc.Par()[0] << " " << mc.Par()[1] << " " << mc.Par()[2]
590 << " " << mc.Par()[3] << " " << mc.Par()[4] << " " << mc.Par()[5] << " " << mc.Par()[6] << std::endl;
593 if ( labcur >= 0 && lmax < lcurr ) {
598 for ( int ihit = 0; ihit < NHits; ihit++ ) {
599 const AliHLTTPCCAGBHit &h = tracker.Hits()[vHits[ihit].ID()];
600 AliHLTTPCCAPerformance::AliHLTTPCCAHitLabel &l = fPerf->HitLabels()[h.ID()];
601 if ( l.fLab[0] == labmax || l.fLab[1] == labmax || l.fLab[2] == labmax
605 purity = ( ( NHits > 0 ) ? double( lmax ) / double( NHits ) : 0 );
606 if ( lb ) delete[] lb;
607 if ( purity < .9 ) label = -1;
612 bool AliHLTTPCCADisplay::DrawTrack( AliHLTTPCCATrackParam /*t*/, double /*Alpha*/, const AliHLTTPCCADisplayTmpHit */*vHits*/,
613 int /*NHits*/, int /*color*/, int /*width*/, bool /*pPoint*/ )
618 if ( NHits < 2 ) return 0;
620 //AliHLTTPCCAGBTracker &tracker = *fGB;
621 if ( width < 0 ) width = 2;
623 if ( fDrawOnlyRef ) {
624 int lab = GetTrackMC( vHits, NHits );
625 if ( lab < 0 ) return 0;
626 AliHLTTPCCAMCTrack &mc = fPerf->MCTracks()[lab];
627 if ( mc.P() < 1 ) return 0;
631 //color = GetColorZ( (vz[0]+vz[mHits-1])/2. );
632 //color = GetColorK(t.GetKappa());
633 int lab = GetTrackMC( vHits, NHits );
634 color = GetColor( lab + 1 );
636 AliHLTTPCCAMCTrack &mc = fPerf->MCTracks()[lab];
637 if ( mc.P() >= 1. ) color = kRed;
641 if ( t.SinPhi() > .999 ) t.SetSinPhi( .999 );
642 else if ( t.SinPhi() < -.999 ) t.SetSinPhi( -.999 );
644 // int iSlice = fSlice->Param().ISlice();
646 //sort(vHits, vHits + NHits, AliHLTTPCCADisplayTmpHit::CompareHitZ );
648 double vx[2000], vy[2000], vz[2000];
652 double alpha = ( TMath::Abs( Alpha + 1 ) < 1.e-4 ) ? fSlice->Param().Alpha() : Alpha;
653 AliHLTTPCCATrackParam tt = t;
655 for ( int iHit = 0; iHit < NHits; iHit++ ) {
657 const AliHLTTPCCAGBHit &h = tracker.Hits()[vHits[iHit].ID()];
659 double hCos = TMath::Cos( alpha - tracker.Slices()[h.ISlice()].Param().Alpha() );
660 double hSin = TMath::Sin( alpha - tracker.Slices()[h.ISlice()].Param().Alpha() );
661 double x0 = h.X(), y0 = h.Y(), z1 = h.Z();
662 double x1 = x0 * hCos + y0 * hSin;
663 double y1 = y0 * hCos - x0 * hSin;
666 double dx = x1 - tt.X();
667 double dy = y1 - tt.Y();
668 if ( dx*dx + dy*dy > 1. ) {
669 double dalpha = TMath::ATan2( dy, dx );
670 if ( tt.Rotate( dalpha ) ) {
672 hCos = TMath::Cos( alpha - tracker.Slices()[h.ISlice()].Param().Alpha() );
673 hSin = TMath::Sin( alpha - tracker.Slices()[h.ISlice()].Param().Alpha() );
674 x1 = x0 * hCos + y0 * hSin;
675 y1 = y0 * hCos - x0 * hSin;
679 SetSliceTransform( alpha );
681 //t.GetDCAPoint( x1, y1, z1, x1, y1, z1 );
682 std::cout << "mark 3" << std::endl;
683 bool ok = tt.TransportToX( x1, .999 );
684 std::cout << "mark 4" << std::endl;
691 Slice2View( x1, y1, &x1, &y1 );
696 for ( int j = 0; j < 0; j++ ) {
697 x0 = h.X() + j; y0 = h.Y(); z1 = h.Z();
698 x1 = x0 * hCos + y0 * hSin;
699 y1 = y0 * hCos - x0 * hSin;
700 ok = tt.TransportToX( x1, .999 );
707 Slice2View( x1, y1, &x1, &y1 );
715 double x1 = t.X(), y1 = t.Y(), z1 = t.Z();
716 double a = ( TMath::Abs( Alpha + 1 ) < 1.e-4 ) ? fSlice->Param().Alpha() : Alpha;
717 SetSliceTransform( a );
719 Slice2View( x1, y1, &x1, &y1 );
720 double dx = x1 - vx[0];
721 double dy = y1 - vy[0];
722 //std::cout<<x1<<" "<<y1<<" "<<vx[0]<<" "<<vy[0]<<" "<<dx<<" "<<dy<<std::endl;
723 double d0 = dx * dx + dy * dy;
724 dx = x1 - vx[mHits-1];
725 dy = y1 - vy[mHits-1];
726 //std::cout<<x1<<" "<<y1<<" "<<vx[mHits-1]<<" "<<vy[mHits-1]<<" "<<dx<<" "<<dy<<std::endl;
727 double d1 = dx * dx + dy * dy;
728 //std::cout<<"d0, d1="<<d0<<" "<<d1<<std::endl;
735 for ( int i = mHits; i > 0; i-- ) {
748 fLine.SetLineColor( color );
749 fLine.SetLineWidth( width );
750 fArc.SetFillStyle( 0 );
751 fArc.SetLineColor( color );
752 fArc.SetLineWidth( width );
754 pl.SetLineColor( color );
755 pl.SetLineWidth( width );
757 plZ.SetLineColor( color );
758 plZ.SetLineWidth( width );
760 fMarker.SetMarkerSize( width / 2. );
761 fMarker.SetMarkerColor( color );
764 pl.DrawPolyLine( mHits, vx, vy );
766 fMarker.DrawMarker( vx[0], vy[0] );
767 fMarker.DrawMarker( vx[mHits-1], vy[mHits-1] );
770 plZ.DrawPolyLine( mHits, vz, vy );
771 fMarker.DrawMarker( vz[0], vy[0] );
772 fMarker.DrawMarker( vz[mHits-1], vy[mHits-1] );
774 fLine.SetLineWidth( 1 );
780 bool AliHLTTPCCADisplay::DrawTracklet( AliHLTTPCCATrackParam &/*track*/, const int */*hitstore*/, int /*color*/, int /*width*/, bool /*pPoint*/ )
784 AliHLTTPCCAGBTracker &tracker = *fGB;
785 AliHLTTPCCADisplayTmpHit vHits[200];
787 for ( int iRow = 0; iRow < fSlice->Param().NRows(); iRow++ ) {
788 int iHit = hitstore[iRow];
789 if ( iHit < 0 ) continue;
790 const AliHLTTPCCARow &row = fSlice->Row( iRow );
791 int id = fSlice->HitInputID( row, iHit );
792 int iGBHit = tracker.FirstSliceHit()[fSlice->Param().ISlice()] + id;
793 const AliHLTTPCCAGBHit &h = tracker.Hits()[iGBHit];
794 vHits[nHits].SetID( iGBHit );
795 vHits[nHits].SetS( 0 );
796 vHits[nHits].SetZ( h.Z() );
799 return DrawTrack( track, -1, vHits, nHits, color, width, pPoint );
805 void AliHLTTPCCADisplay::DrawSliceOutTrack( AliHLTTPCCATrackParam &/*t*/, double /*alpha*/, int /*itr*/, int /*color*/, int /*width*/ )
809 AliHLTTPCCAOutTrack &track = fSlice->OutTracks()[itr];
810 if ( track.NHits() < 2 ) return;
812 AliHLTTPCCAGBTracker &tracker = *fGB;
813 AliHLTTPCCADisplayTmpHit vHits[200];
815 for ( int ih = 0; ih < track.NHits(); ih++ ) {
816 int id = tracker.FirstSliceHit()[fSlice->Param().ISlice()] + fSlice->OutTrackHit(track.FirstHitRef()+ih);
817 const AliHLTTPCCAGBHit &h = tracker.Hits()[id];
818 vHits[ih].SetID( id );
820 vHits[ih].SetZ( h.Z() );
823 DrawTrack( t, alpha, vHits, track.NHits(), color, width, 1 );
827 void AliHLTTPCCADisplay::DrawSliceOutTrack( int /*itr*/, int /*color*/, int /*width*/ )
831 AliHLTTPCCAOutTrack &track = fSlice->OutTracks()[itr];
832 if ( track.NHits() < 2 ) return;
834 AliHLTTPCCAGBTracker &tracker = *fGB;
835 AliHLTTPCCADisplayTmpHit vHits[200];
837 for ( int ih = 0; ih < track.NHits(); ih++ ) {
838 int id = tracker.FirstSliceHit()[fSlice->Param().ISlice()] + fSlice->OutTrackHit(track.FirstHitRef()+ih);
839 const AliHLTTPCCAGBHit &h = tracker.Hits()[id];
840 vHits[ih].SetID( id );
842 vHits[ih].SetZ( h.Z() );
845 DrawTrack( track.StartPoint(), -1, vHits, track.NHits(), color, width );
850 void AliHLTTPCCADisplay::DrawSliceTrack( int /*itr*/, int /*color*/ )
854 const AliHLTTPCCATrack &track = fSlice->Tracks()[itr];
855 if ( track.NHits() < 2 ) return;
857 AliHLTTPCCAGBTracker &tracker = *fGB;
858 AliHLTTPCCADisplayTmpHit vHits[200];
859 for ( int ith = 0; ith < track.NHits(); ith++ ) {
860 AliHLTTPCCAHitId ic = ( fSlice->TrackHits()[track.FirstHitID()+ith] );
861 const AliHLTTPCCARow &row = fSlice->Row( ic );
862 int ih = ic.HitIndex();
863 int id = fSlice->HitInputID( row, ih );
864 int gbID = tracker.FirstSliceHit()[fSlice->Param().ISlice()] + id;
865 const AliHLTTPCCAGBHit &h = tracker.Hits()[gbID];
866 vHits[ith].SetID( gbID );
867 vHits[ith].SetS( 0 );
868 vHits[ith].SetZ( h.Z() );
871 DrawTrack( track.Param(), -1, vHits, track.NHits(), color, -1 );
872 //track.Param().Print();