]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/tracking-ca/AliHLTTPCCADisplay.cxx
code cleanup, removing unused functionality; fully implemented in the AliHLTTPCDataCo...
[u/mrichter/AliRoot.git] / HLT / TPCLib / tracking-ca / AliHLTTPCCADisplay.cxx
CommitLineData
d54804bf 1// $Id$
ce565086 2// **************************************************************************
fbb9b71b 3// This file is property of and copyright by the ALICE HLT Project *
d54804bf 4// ALICE Experiment at CERN, All rights reserved. *
5// *
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. *
9// *
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. *
ce565086 17// *
d54804bf 18//***************************************************************************
326c2d4b 19
326c2d4b 20
4687b8fc 21#include "AliHLTTPCCADisplay.h"
00d07bcd 22
00d07bcd 23
4687b8fc 24#include "AliHLTTPCCATracker.h"
6de2bc40 25#include "AliHLTTPCCAStandaloneFramework.h"
4687b8fc 26#include "AliHLTTPCCARow.h"
27#include "AliHLTTPCCATrack.h"
693d2443 28#include "AliHLTTPCCAPerformance.h"
29#include "AliHLTTPCCAMCTrack.h"
d54804bf 30
4687b8fc 31#include "TString.h"
32#include "Riostream.h"
33#include "TMath.h"
34#include "TStyle.h"
35#include "TCanvas.h"
ce565086 36#include "TApplication.h"
37
38
e1f2d1c3 39class AliHLTTPCCADisplay::AliHLTTPCCADisplayTmpHit
40{
41
fbb9b71b 42 public:
e1f2d1c3 43
fbb9b71b 44 int ID() const { return fHitID; }
45 double S() const { return fS; }
46 double Z() const { return fZ; }
47
48 void SetID( int v ) { fHitID = v; }
49 void SetS( double v ) { fS = v; }
50 void SetZ( double v ) { fZ = v; }
e1f2d1c3 51
fbb9b71b 52 static bool CompareHitDS( const AliHLTTPCCADisplayTmpHit &a,
4acc2401 53 const AliHLTTPCCADisplayTmpHit &b ) {
fbb9b71b 54 return ( a.fS < b.fS );
55 }
56
57 static bool CompareHitZ( const AliHLTTPCCADisplayTmpHit &a,
4acc2401 58 const AliHLTTPCCADisplayTmpHit &b ) {
fbb9b71b 59 return ( a.fZ < b.fZ );
60 }
e1f2d1c3 61
fbb9b71b 62 private:
63
64 int fHitID; // hit ID
65 double fS; // hit position on the XY track curve
66 double fZ; // hit Z position
e1f2d1c3 67
68};
69
326c2d4b 70
326c2d4b 71
72AliHLTTPCCADisplay &AliHLTTPCCADisplay::Instance()
73{
74 // reference to static object
75 static AliHLTTPCCADisplay gAliHLTTPCCADisplay;
fbb9b71b 76 static bool firstCall = 1;
77 if ( firstCall ) {
78 if ( !gApplication ) new TApplication( "myapp", 0, 0 );
ce565086 79 gAliHLTTPCCADisplay.Init();
80 firstCall = 0;
81 }
fbb9b71b 82 return gAliHLTTPCCADisplay;
326c2d4b 83}
84
6de2bc40 85AliHLTTPCCADisplay::AliHLTTPCCADisplay() : fYX( 0 ), fZX( 0 ), fAsk( 1 ), fSliceView( 1 ), fSlice( 0 ), fPerf( 0 ),
fbb9b71b 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 )
326c2d4b 89{
fbb9b71b 90 fPerf = &( AliHLTTPCCAPerformance::Instance() );
326c2d4b 91 // constructor
fbb9b71b 92}
d54804bf 93
326c2d4b 94AliHLTTPCCADisplay::~AliHLTTPCCADisplay()
95{
96 // destructor
fbb9b71b 97 delete fYX;
dc4788ec 98 delete fZX;
326c2d4b 99}
100
101void AliHLTTPCCADisplay::Init()
102{
103 // initialization
fbb9b71b 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);
ce565086 110 fDrawOnlyRef = 0;
326c2d4b 111}
112
113void AliHLTTPCCADisplay::Update()
114{
115 // update windows
fbb9b71b 116 if ( !fAsk ) return;
dc4788ec 117 fYX->Update();
118 fZX->Update();
fbb9b71b 119 fYX->Print( "YX.pdf" );
120 fZX->Print( "ZX.pdf" );
121
326c2d4b 122}
123
d54804bf 124void AliHLTTPCCADisplay::ClearView()
326c2d4b 125{
126 // clear windows
dc4788ec 127 fYX->Clear();
128 fZX->Clear();
326c2d4b 129}
130
131void AliHLTTPCCADisplay::Ask()
132{
4acc2401 133 // wait for the pressed key, when "r" pressed, don't ask anymore
326c2d4b 134 char symbol;
fbb9b71b 135 if ( fAsk ) {
326c2d4b 136 Update();
fbb9b71b 137 std::cout << "ask> " << std::endl;
138 do {
139 std::cin.get( symbol );
140 if ( symbol == 'r' )
141 fAsk = false;
142 } while ( symbol != '\n' );
326c2d4b 143 }
144}
145
146
d54804bf 147void AliHLTTPCCADisplay::SetSliceView()
326c2d4b 148{
d54804bf 149 // switch to slice view
150 fSliceView = 1;
326c2d4b 151}
152
153void AliHLTTPCCADisplay::SetTPCView()
154{
155 // switch to full TPC view
d54804bf 156 fSliceView = 0;
326c2d4b 157 fCos = 1;
158 fSin = 0;
159 fZMin = fTPCZMin;
160 fZMax = fTPCZMax;
4687b8fc 161 fYMin = -fROuterMax;
162 fYMax = fROuterMax;
326c2d4b 163}
164
693d2443 165
d54804bf 166void AliHLTTPCCADisplay::SetCurrentSlice( AliHLTTPCCATracker *slice )
326c2d4b 167{
d54804bf 168 // set reference to the current CA tracker, and read the current slice geometry
169 fSlice = slice;
170 SetSliceTransform( slice );
fbb9b71b 171 if ( fSliceView ) {
d54804bf 172 fCos = slice->Param().SinAlpha();
173 fSin = slice->Param().CosAlpha();
174 fZMin = slice->Param().ZMin();
175 fZMax = slice->Param().ZMax();
176 ClearView();
fbb9b71b 177 double r0 = .5 * ( slice->Param().RMax() + slice->Param().RMin() );
178 double dr = .5 * ( slice->Param().RMax() - slice->Param().RMin() );
4687b8fc 179 fYMin = -dr;
180 fYMax = dr;
fbb9b71b 181 double cx = 0;
182 double cy = r0;
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 );
187
ce565086 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);
190
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);
193
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);
fbb9b71b 196
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));
693d2443 202 //fYX->Range(xc-d, yc-d, xc+d, yc+d);
203 //fZX->Range(zc-d, yc-d, zc+d, yc+d);
fbb9b71b 204
205 }
d54804bf 206}
326c2d4b 207
fbb9b71b 208void AliHLTTPCCADisplay::SetSliceTransform( double alpha )
4687b8fc 209{
210 fSliceCos = TMath::Cos( alpha );
211 fSliceSin = TMath::Sin( alpha );
fbb9b71b 212}
4687b8fc 213
214void AliHLTTPCCADisplay::SetSliceTransform( AliHLTTPCCATracker *slice )
215{
fbb9b71b 216 SetSliceTransform( slice->Param().Alpha() );
4687b8fc 217}
218
219
220void AliHLTTPCCADisplay::DrawTPC()
221{
222 // schematically draw TPC detector
fbb9b71b 223 fYX->Range( -fROuterMax, -fROuterMax, fROuterMax, fROuterMax );
693d2443 224 //fYX->Range( -fROuterMax*.7, -fROuterMax, fROuterMax*0., -fROuterMax*.5);
4687b8fc 225 fYX->Clear();
226 {
fbb9b71b 227 fArc.SetLineColor( kBlack );
228 fArc.SetFillStyle( 0 );
229 fYX->cd();
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 ) );
4687b8fc 235 }
236 }
237 fZX->cd();
693d2443 238 fZX->Range( fTPCZMin, -fROuterMax, fTPCZMax*1.1, fROuterMax );
239 //fZX->Range( fTPCZMax*.1, -fROuterMax, fTPCZMax*.3, -fROuterMax*0.5 );
4687b8fc 240 fZX->Clear();
241}
242
fbb9b71b 243void AliHLTTPCCADisplay::DrawSlice( AliHLTTPCCATracker *slice, bool DrawRows )
244{
4687b8fc 245 // draw current the TPC slice
246 fYX->cd();
fbb9b71b 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() );
254 if ( fSliceView ) {
4687b8fc 255 cx = 0; cy = r0;
256 a0 = 90.;
fbb9b71b 257 fLatex.DrawLatex( cx - dr + dr*.05, cy - dr + dr*.05, Form( "YX, Slice %2i", slice->Param().ISlice() ) );
4687b8fc 258 } else {
fbb9b71b 259 a0 += raddeg * TMath::ATan2( fSin, fCos );
4687b8fc 260 }
fbb9b71b 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 );
693d2443 267 //fCrown.DrawCrown(0,0, slice->Param().RMin(),slice->Param().RMax(), a0-da, a0+da );
fbb9b71b 268
269 fLine.SetLineColor( kBlack );
270
4687b8fc 271 fZX->cd();
272
fbb9b71b 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() ) );
277
278 if ( DrawRows ) {
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 );
693d2443 288 fYX->cd();
fbb9b71b 289 fLine.DrawLine( vx0, vy0, vx1, vy1 );
693d2443 290 fZX->cd();
fbb9b71b 291 fLine.DrawLine( fTPCZMin, vy0, fTPCZMax, vy1 );
693d2443 292 }
293 }
294
4687b8fc 295}
296
297
ce565086 298void AliHLTTPCCADisplay::Set2Slices( AliHLTTPCCATracker * const slice )
d54804bf 299{
300 //* Set view for two neighbouring slices
301
302 fSlice = slice;
303 fSliceView = 0;
fbb9b71b 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() ) );
d54804bf 306 fZMin = slice->Param().ZMin();
307 fZMax = slice->Param().ZMax();
308 ClearView();
fbb9b71b 309 double r0 = .5 * ( slice->Param().RMax() + slice->Param().RMin() );
310 double dr = .5 * ( slice->Param().RMax() - slice->Param().RMin() );
311 double cx = 0;
312 double cy = r0;
313 fYX->Range( cx - 1.3*dr, cy - 1.1*dr, cx + 1.3*dr, cy + 1.1*dr );
d54804bf 314 fYX->cd();
fbb9b71b 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);
323 fZX->cd();
324 fLatex.DrawLatex( cz - dz + dz*.05, cy - dr + dr*.05, Form( "ZX, Slices %2i/%2i", islice, jslice ) );
326c2d4b 325}
326
fbb9b71b 327int AliHLTTPCCADisplay::GetColor( int i ) const
693d2443 328{
329 // Get color with respect to Z coordinate
fbb9b71b 330 const Color_t kMyColor[9] = { kGreen, kBlue, kYellow, kCyan, kOrange,
331 kSpring, kTeal, kAzure, kViolet
332 };
333 if ( i < 0 ) i = 0;
334 if ( i == 0 ) return kBlack;
335 return kMyColor[( i-1 )%9];
693d2443 336}
d54804bf 337
fbb9b71b 338int AliHLTTPCCADisplay::GetColorZ( double z ) const
326c2d4b 339{
340 // Get color with respect to Z coordinate
fbb9b71b 341 const Color_t kMyColor[11] = { kGreen, kBlue, kYellow, kMagenta, kCyan,
342 kOrange, kSpring, kTeal, kAzure, kViolet, kPink
343 };
344
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;
dc4788ec 349 return kMyColor[iz];
326c2d4b 350}
351
fbb9b71b 352int AliHLTTPCCADisplay::GetColorY( double y ) const
326c2d4b 353{
4687b8fc 354 // Get color with respect to Z coordinate
fbb9b71b 355 const Color_t kMyColor[11] = { kGreen, kBlue, kYellow, kMagenta, kCyan,
356 kOrange, kSpring, kTeal, kAzure, kViolet, kPink
357 };
358
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;
4687b8fc 363 return kMyColor[iy];
326c2d4b 364}
365
fbb9b71b 366int AliHLTTPCCADisplay::GetColorK( double k ) const
d54804bf 367{
4687b8fc 368 // Get color with respect to Z coordinate
fbb9b71b 369 const Color_t kMyColor[11] = { kRed, kBlue, kYellow, kMagenta, kCyan,
370 kOrange, kSpring, kTeal, kAzure, kViolet, kPink
371 };
372 const double kCLight = 0.000299792458;
373 const double kBz = 5;
374 double k2QPt = 100;
375 if ( TMath::Abs( kBz ) > 1.e-4 ) k2QPt = 1. / ( kBz * kCLight );
376 double qPt = k * k2QPt;
377 double pt = 100;
378 if ( TMath::Abs( qPt ) > 1.e-4 ) pt = 1. / TMath::Abs( qPt );
379
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;
4687b8fc 384 return kMyColor[iy];
385}
d54804bf 386
fbb9b71b 387void AliHLTTPCCADisplay::Global2View( double x, double y, double *xv, double *yv ) const
d54804bf 388{
4687b8fc 389 // convert coordinates global->view
fbb9b71b 390 *xv = x * fCos + y * fSin;
391 *yv = y * fCos - x * fSin;
d54804bf 392}
393
4687b8fc 394
fbb9b71b 395void AliHLTTPCCADisplay::Slice2View( double x, double y, double *xv, double *yv ) const
326c2d4b 396{
d54804bf 397 // convert coordinates slice->view
fbb9b71b 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;
326c2d4b 402}
403
f0fb467d 404void AliHLTTPCCADisplay::SliceHitXYZ(int iRow, int iHit, double &x, double &y, double &z )
693d2443 405{
f0fb467d 406 // get xyz of the hit
407
fbb9b71b 408 if ( !fSlice ) return;
409 const AliHLTTPCCARow &row = fSlice->Row( iRow );
ddba06bc 410 float y0 = row.Grid().YMin();
411 float z0 = row.Grid().ZMin();
412 float stepY = row.HstepY();
413 float stepZ = row.HstepZ();
f0fb467d 414 x = row.X();
415 y = y0 + fSlice->HitDataY( row, iHit ) * stepY;
416 z = z0 + fSlice->HitDataZ( row, iHit ) * stepZ;
417}
418
419void AliHLTTPCCADisplay::DrawSliceHit( int iRow, int iHit, int color, Size_t width )
420{
421 // draw hit
422 if ( !fSlice ) return;
423
424 double x,y,z;
425 SliceHitXYZ( iRow, iHit, x, y, z );
fbb9b71b 426
427 SetSliceTransform( fSlice );
428
429 if ( color < 0 ) {
ce06381a 430 //if ( 0 && fPerf ) {
6de2bc40 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;
438 //}
ce06381a 439 //} else
440 color = GetColorZ( z );
ddba06bc 441 }
fbb9b71b 442 if ( width > 0 )fMarker.SetMarkerSize( width );
443 else fMarker.SetMarkerSize( .3 );
444 fMarker.SetMarkerColor( color );
445 double vx, vy;
446 Slice2View( x, y, &vx, &vy );
ddba06bc 447 fYX->cd();
fbb9b71b 448 fMarker.DrawMarker( vx, vy );
449 fZX->cd();
450 fMarker.DrawMarker( z, vy );
693d2443 451}
452
fbb9b71b 453void AliHLTTPCCADisplay::DrawSliceHits( int color, Size_t width )
693d2443 454{
693d2443 455
fbb9b71b 456 // draw hits
693d2443 457
fbb9b71b 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 );
693d2443 462 }
fbb9b71b 463 }
693d2443 464}
465
ce565086 466
f0fb467d 467void AliHLTTPCCADisplay::DrawSliceLink( int iRow, int iHit, int colorUp, int colorDn, int width )
ce565086 468{
fbb9b71b 469 // draw link between clusters
f0fb467d 470
471 //if ( !fPerf ) return;
472 //AliHLTTPCCAGBTracker &tracker = *fGB;
5c2dca91 473 if ( width < 0 ) width = 1;
ce565086 474 fLine.SetLineWidth( width );
fbb9b71b 475 int colUp = colorUp >= 0 ? colorUp : kMagenta;
476 int colDn = colorDn >= 0 ? colorDn : kBlack;
4acc2401 477 if ( iRow < 2 || iRow >= fSlice->Param().NRows() - 2 ) return;
fbb9b71b 478
f0fb467d 479 const AliHLTTPCCARow& row = fSlice->Data().Row( iRow );
fbb9b71b 480
4acc2401 481 short iUp = fSlice->HitLinkUpData( row, iHit );
482 short iDn = fSlice->HitLinkDownData( row, iHit );
fbb9b71b 483
f0fb467d 484
485 double p1[3], p2[3], p3[3];
486 SliceHitXYZ( iRow, iHit, p1[0],p1[1],p1[2]);
487
488 double vx, vy, vx1, vy1;
489 Slice2View( p1[0], p1[1], &vx, &vy );
490
fbb9b71b 491 if ( iUp >= 0 ) {
f0fb467d 492 SliceHitXYZ( iRow+2, iUp, p2[0],p2[1],p2[2]);
493 Slice2View( p2[0], p2[1], &vx1, &vy1 );
ce565086 494 fLine.SetLineColor( colUp );
495 fYX->cd();
fbb9b71b 496 fLine.DrawLine( vx - .1, vy, vx1 - .1, vy1 );
ce565086 497 fZX->cd();
f0fb467d 498 fLine.DrawLine( p1[2] - 1., vy, p2[2] - 1., vy1 );
ce565086 499 }
f0fb467d 500 if ( iDn >= 0 ) {
501 SliceHitXYZ( iRow-2, iDn, p3[0],p3[1],p3[2]);
502 Slice2View( p3[0], p3[1], &vx1, &vy1 );
ce565086 503 fLine.SetLineColor( colDn );
504 fYX->cd();
fbb9b71b 505 fLine.DrawLine( vx + .1, vy, vx1 + .1, vy1 );
ce565086 506 fZX->cd();
f0fb467d 507 fLine.DrawLine( p1[2] + 1., vy, p3[2] + 1., vy1 );
ce565086 508 }
f0fb467d 509
ce565086 510}
511
512
fbb9b71b 513void AliHLTTPCCADisplay::DrawSliceLinks( int colorUp, int colorDn, int width )
ce565086 514{
fbb9b71b 515 // draw links between clusters
ce565086 516
fbb9b71b 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++ ) {
ce565086 520 DrawSliceLink( iRow, ih, colorUp, colorDn, width );
521 }
522 }
523}
524
525
526
6de2bc40 527int AliHLTTPCCADisplay::GetTrackMC( const AliHLTTPCCADisplayTmpHit */*vHits*/, int /*NHits*/ )
693d2443 528{
529 // get MC label for the track
6de2bc40 530 return 0;
531#ifdef XXX
693d2443 532 AliHLTTPCCAGBTracker &tracker = *fGB;
533
fbb9b71b 534 int label = -1;
535 double purity = 0;
536 int *lb = new int[NHits*3];
537 int nla = 0;
693d2443 538 //std::cout<<"\n\nTrack hits mc: "<<std::endl;
fbb9b71b 539 for ( int ihit = 0; ihit < NHits; ihit++ ) {
4acc2401 540 const AliHLTTPCCAGBHit &h = tracker.Hits()[vHits[ihit].ID()];
693d2443 541 AliHLTTPCCAPerformance::AliHLTTPCCAHitLabel &l = fPerf->HitLabels()[h.ID()];
fbb9b71b 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];
693d2443 545 //std::cout<<ihit<<": "<<l.fLab[0]<<" "<<l.fLab[1]<<" "<<l.fLab[2]<<std::endl;
546 }
fbb9b71b 547 sort( lb, lb + nla );
548 int labmax = -1, labcur = -1, lmax = 0, lcurr = 0, nh = 0;
693d2443 549 //std::cout<<"MC track IDs :"<<std::endl;
fbb9b71b 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;
557
693d2443 558 }
fbb9b71b 559 nh = 0;
560 if ( labcur >= 0 && lmax < lcurr ) {
561 lmax = lcurr;
562 labmax = labcur;
693d2443 563 }
564 labcur = lb[i];
565 lcurr = 0;
566 }
567 lcurr++;
568 nh++;
569 }
fbb9b71b 570 if ( 0 && nla - 1 > 0 && lb[nla-1] >= 0 ) {
693d2443 571 AliHLTTPCCAMCTrack &mc = fPerf->MCTracks()[lb[nla-1]];
fbb9b71b 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;
575
693d2443 576 }
fbb9b71b 577 if ( labcur >= 0 && lmax < lcurr ) {
693d2443 578 lmax = lcurr;
579 labmax = labcur;
580 }
581 lmax = 0;
fbb9b71b 582 for ( int ihit = 0; ihit < NHits; ihit++ ) {
4acc2401 583 const AliHLTTPCCAGBHit &h = tracker.Hits()[vHits[ihit].ID()];
693d2443 584 AliHLTTPCCAPerformance::AliHLTTPCCAHitLabel &l = fPerf->HitLabels()[h.ID()];
fbb9b71b 585 if ( l.fLab[0] == labmax || l.fLab[1] == labmax || l.fLab[2] == labmax
586 ) lmax++;
693d2443 587 }
588 label = labmax;
fbb9b71b 589 purity = ( ( NHits > 0 ) ? double( lmax ) / double( NHits ) : 0 );
590 if ( lb ) delete[] lb;
591 if ( purity < .9 ) label = -1;
693d2443 592 return label;
6de2bc40 593#endif
693d2443 594}
4687b8fc 595
6de2bc40 596bool AliHLTTPCCADisplay::DrawTrack( AliHLTTPCCATrackParam /*t*/, double /*Alpha*/, const AliHLTTPCCADisplayTmpHit */*vHits*/,
597 int /*NHits*/, int /*color*/, int /*width*/, bool /*pPoint*/ )
693d2443 598{
599 // draw track
6de2bc40 600 return 1;
601#ifdef XXX
fbb9b71b 602 if ( NHits < 2 ) return 0;
693d2443 603
6de2bc40 604 //AliHLTTPCCAGBTracker &tracker = *fGB;
fbb9b71b 605 if ( width < 0 ) width = 2;
693d2443 606
fbb9b71b 607 if ( fDrawOnlyRef ) {
608 int lab = GetTrackMC( vHits, NHits );
609 if ( lab < 0 ) return 0;
693d2443 610 AliHLTTPCCAMCTrack &mc = fPerf->MCTracks()[lab];
fbb9b71b 611 if ( mc.P() < 1 ) return 0;
693d2443 612 }
613
fbb9b71b 614 if ( color < 0 ) {
693d2443 615 //color = GetColorZ( (vz[0]+vz[mHits-1])/2. );
616 //color = GetColorK(t.GetKappa());
fbb9b71b 617 int lab = GetTrackMC( vHits, NHits );
618 color = GetColor( lab + 1 );
619 if ( lab >= 0 ) {
693d2443 620 AliHLTTPCCAMCTrack &mc = fPerf->MCTracks()[lab];
fbb9b71b 621 if ( mc.P() >= 1. ) color = kRed;
622 }
693d2443 623 }
15d2e9cf 624
fbb9b71b 625 if ( t.SinPhi() > .999 ) t.SetSinPhi( .999 );
626 else if ( t.SinPhi() < -.999 ) t.SetSinPhi( -.999 );
693d2443 627
fbb9b71b 628 // int iSlice = fSlice->Param().ISlice();
693d2443 629
630 //sort(vHits, vHits + NHits, AliHLTTPCCADisplayTmpHit::CompareHitZ );
631
fbb9b71b 632 double vx[2000], vy[2000], vz[2000];
633 int mHits = 0;
693d2443 634
fbb9b71b 635 //int oldSlice = -1;
636 double alpha = ( TMath::Abs( Alpha + 1 ) < 1.e-4 ) ? fSlice->Param().Alpha() : Alpha;
693d2443 637 AliHLTTPCCATrackParam tt = t;
638
fbb9b71b 639 for ( int iHit = 0; iHit < NHits; iHit++ ) {
693d2443 640
4acc2401 641 const AliHLTTPCCAGBHit &h = tracker.Hits()[vHits[iHit].ID()];
693d2443 642
fbb9b71b 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;
693d2443 648
649 {
fbb9b71b 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 ) ) {
655 alpha += 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;
660 }
693d2443 661 }
662 }
663 SetSliceTransform( alpha );
664
fbb9b71b 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;
669 if ( 1 || ok ) {
693d2443 670 x1 = tt.X();
671 y1 = tt.Y();
672 z1 = tt.Z();
673 }
674
fbb9b71b 675 Slice2View( x1, y1, &x1, &y1 );
693d2443 676 vx[mHits] = x1;
677 vy[mHits] = y1;
678 vz[mHits] = z1;
679 mHits++;
fbb9b71b 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 );
685 if ( ok ) {
686 x1 = tt.X();
687 y1 = tt.Y();
688 z1 = tt.Z();
693d2443 689 }
fbb9b71b 690
691 Slice2View( x1, y1, &x1, &y1 );
693d2443 692 vx[mHits] = x1;
693 vy[mHits] = y1;
694 vz[mHits] = z1;
695 mHits++;
696 }
697 }
fbb9b71b 698 if ( pPoint ) {
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;
693d2443 701 SetSliceTransform( a );
702
fbb9b71b 703 Slice2View( x1, y1, &x1, &y1 );
704 double dx = x1 - vx[0];
705 double dy = y1 - vy[0];
693d2443 706 //std::cout<<x1<<" "<<y1<<" "<<vx[0]<<" "<<vy[0]<<" "<<dx<<" "<<dy<<std::endl;
fbb9b71b 707 double d0 = dx * dx + dy * dy;
693d2443 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;
fbb9b71b 711 double d1 = dx * dx + dy * dy;
693d2443 712 //std::cout<<"d0, d1="<<d0<<" "<<d1<<std::endl;
fbb9b71b 713 if ( d1 < d0 ) {
693d2443 714 vx[mHits] = x1;
715 vy[mHits] = y1;
fbb9b71b 716 vz[mHits] = z1;
693d2443 717 mHits++;
718 } else {
fbb9b71b 719 for ( int i = mHits; i > 0; i-- ) {
720 vx[i] = vx[i-1];
721 vy[i] = vy[i-1];
722 vz[i] = vz[i-1];
693d2443 723 }
724 vx[0] = x1;
725 vy[0] = y1;
fbb9b71b 726 vz[0] = z1;
693d2443 727 mHits++;
fbb9b71b 728 }
4687b8fc 729 }
fbb9b71b 730
731
732 fLine.SetLineColor( color );
733 fLine.SetLineWidth( width );
734 fArc.SetFillStyle( 0 );
735 fArc.SetLineColor( color );
736 fArc.SetLineWidth( width );
737 TPolyLine pl;
738 pl.SetLineColor( color );
739 pl.SetLineWidth( width );
4687b8fc 740 TPolyLine plZ;
fbb9b71b 741 plZ.SetLineColor( color );
742 plZ.SetLineWidth( width );
743
744 fMarker.SetMarkerSize( width / 2. );
745 fMarker.SetMarkerColor( color );
4687b8fc 746
693d2443 747 fYX->cd();
fbb9b71b 748 pl.DrawPolyLine( mHits, vx, vy );
693d2443 749 {
fbb9b71b 750 fMarker.DrawMarker( vx[0], vy[0] );
751 fMarker.DrawMarker( vx[mHits-1], vy[mHits-1] );
693d2443 752 }
753 fZX->cd();
fbb9b71b 754 plZ.DrawPolyLine( mHits, vz, vy );
755 fMarker.DrawMarker( vz[0], vy[0] );
756 fMarker.DrawMarker( vz[mHits-1], vy[mHits-1] );
757
758 fLine.SetLineWidth( 1 );
693d2443 759 return 1;
6de2bc40 760#endif
693d2443 761}
4687b8fc 762
4687b8fc 763
6de2bc40 764bool AliHLTTPCCADisplay::DrawTracklet( AliHLTTPCCATrackParam &/*track*/, const int */*hitstore*/, int /*color*/, int /*width*/, bool /*pPoint*/ )
693d2443 765{
766 // draw tracklet
6de2bc40 767#ifdef XXX
693d2443 768 AliHLTTPCCAGBTracker &tracker = *fGB;
769 AliHLTTPCCADisplayTmpHit vHits[200];
fbb9b71b 770 int nHits = 0;
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 );
4acc2401 775 int id = fSlice->HitInputID( row, iHit );
fbb9b71b 776 int iGBHit = tracker.FirstSliceHit()[fSlice->Param().ISlice()] + id;
4acc2401 777 const AliHLTTPCCAGBHit &h = tracker.Hits()[iGBHit];
693d2443 778 vHits[nHits].SetID( iGBHit );
779 vHits[nHits].SetS( 0 );
780 vHits[nHits].SetZ( h.Z() );
781 nHits++;
782 }
fbb9b71b 783 return DrawTrack( track, -1, vHits, nHits, color, width, pPoint );
6de2bc40 784#endif
785 return 1;
693d2443 786}
4687b8fc 787
4687b8fc 788
6de2bc40 789void AliHLTTPCCADisplay::DrawSliceOutTrack( AliHLTTPCCATrackParam &/*t*/, double /*alpha*/, int /*itr*/, int /*color*/, int /*width*/ )
693d2443 790{
791 // draw slice track
6de2bc40 792#ifdef XXX
693d2443 793 AliHLTTPCCAOutTrack &track = fSlice->OutTracks()[itr];
fbb9b71b 794 if ( track.NHits() < 2 ) return;
4687b8fc 795
693d2443 796 AliHLTTPCCAGBTracker &tracker = *fGB;
797 AliHLTTPCCADisplayTmpHit vHits[200];
4687b8fc 798
fbb9b71b 799 for ( int ih = 0; ih < track.NHits(); ih++ ) {
b22af1bf 800 int id = tracker.FirstSliceHit()[fSlice->Param().ISlice()] + fSlice->OutTrackHit(track.FirstHitRef()+ih);
4acc2401 801 const AliHLTTPCCAGBHit &h = tracker.Hits()[id];
693d2443 802 vHits[ih].SetID( id );
803 vHits[ih].SetS( 0 );
804 vHits[ih].SetZ( h.Z() );
326c2d4b 805 }
693d2443 806
807 DrawTrack( t, alpha, vHits, track.NHits(), color, width, 1 );
6de2bc40 808#endif
693d2443 809}
810
6de2bc40 811void AliHLTTPCCADisplay::DrawSliceOutTrack( int /*itr*/, int /*color*/, int /*width*/ )
693d2443 812{
813 // draw slice track
6de2bc40 814#ifdef XXX
693d2443 815 AliHLTTPCCAOutTrack &track = fSlice->OutTracks()[itr];
fbb9b71b 816 if ( track.NHits() < 2 ) return;
693d2443 817
818 AliHLTTPCCAGBTracker &tracker = *fGB;
819 AliHLTTPCCADisplayTmpHit vHits[200];
820
fbb9b71b 821 for ( int ih = 0; ih < track.NHits(); ih++ ) {
b22af1bf 822 int id = tracker.FirstSliceHit()[fSlice->Param().ISlice()] + fSlice->OutTrackHit(track.FirstHitRef()+ih);
4acc2401 823 const AliHLTTPCCAGBHit &h = tracker.Hits()[id];
693d2443 824 vHits[ih].SetID( id );
825 vHits[ih].SetS( 0 );
826 vHits[ih].SetZ( h.Z() );
827 }
828
829 DrawTrack( track.StartPoint(), -1, vHits, track.NHits(), color, width );
6de2bc40 830#endif
693d2443 831}
832
833
6de2bc40 834void AliHLTTPCCADisplay::DrawSliceTrack( int /*itr*/, int /*color*/ )
693d2443 835{
836 // draw slice track
6de2bc40 837#ifdef XXX
4acc2401 838 const AliHLTTPCCATrack &track = fSlice->Tracks()[itr];
fbb9b71b 839 if ( track.NHits() < 2 ) return;
693d2443 840
841 AliHLTTPCCAGBTracker &tracker = *fGB;
fbb9b71b 842 AliHLTTPCCADisplayTmpHit vHits[200];
843 for ( int ith = 0; ith < track.NHits(); ith++ ) {
4acc2401 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 );
fbb9b71b 848 int gbID = tracker.FirstSliceHit()[fSlice->Param().ISlice()] + id;
4acc2401 849 const AliHLTTPCCAGBHit &h = tracker.Hits()[gbID];
693d2443 850 vHits[ith].SetID( gbID );
851 vHits[ith].SetS( 0 );
852 vHits[ith].SetZ( h.Z() );
853 }
854
fbb9b71b 855 DrawTrack( track.Param(), -1, vHits, track.NHits(), color, -1 );
693d2443 856 //track.Param().Print();
00d07bcd 857#endif
326c2d4b 858}