When Pt is bad defined (ex. no field), the multiple scattering effect is calculated...
[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"
30#include "AliHLTTPCCAOutTrack.h"
d54804bf 31
4687b8fc 32#include "TString.h"
33#include "Riostream.h"
34#include "TMath.h"
35#include "TStyle.h"
36#include "TCanvas.h"
ce565086 37#include "TApplication.h"
38
39
e1f2d1c3 40class AliHLTTPCCADisplay::AliHLTTPCCADisplayTmpHit
41{
42
fbb9b71b 43 public:
e1f2d1c3 44
fbb9b71b 45 int ID() const { return fHitID; }
46 double S() const { return fS; }
47 double Z() const { return fZ; }
48
49 void SetID( int v ) { fHitID = v; }
50 void SetS( double v ) { fS = v; }
51 void SetZ( double v ) { fZ = v; }
e1f2d1c3 52
fbb9b71b 53 static bool CompareHitDS( const AliHLTTPCCADisplayTmpHit &a,
4acc2401 54 const AliHLTTPCCADisplayTmpHit &b ) {
fbb9b71b 55 return ( a.fS < b.fS );
56 }
57
58 static bool CompareHitZ( const AliHLTTPCCADisplayTmpHit &a,
4acc2401 59 const AliHLTTPCCADisplayTmpHit &b ) {
fbb9b71b 60 return ( a.fZ < b.fZ );
61 }
e1f2d1c3 62
fbb9b71b 63 private:
64
65 int fHitID; // hit ID
66 double fS; // hit position on the XY track curve
67 double fZ; // hit Z position
e1f2d1c3 68
69};
70
326c2d4b 71
326c2d4b 72
73AliHLTTPCCADisplay &AliHLTTPCCADisplay::Instance()
74{
75 // reference to static object
76 static AliHLTTPCCADisplay gAliHLTTPCCADisplay;
fbb9b71b 77 static bool firstCall = 1;
78 if ( firstCall ) {
79 if ( !gApplication ) new TApplication( "myapp", 0, 0 );
ce565086 80 gAliHLTTPCCADisplay.Init();
81 firstCall = 0;
82 }
fbb9b71b 83 return gAliHLTTPCCADisplay;
326c2d4b 84}
85
6de2bc40 86AliHLTTPCCADisplay::AliHLTTPCCADisplay() : fYX( 0 ), fZX( 0 ), fAsk( 1 ), fSliceView( 1 ), fSlice( 0 ), fPerf( 0 ),
fbb9b71b 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 )
326c2d4b 90{
fbb9b71b 91 fPerf = &( AliHLTTPCCAPerformance::Instance() );
326c2d4b 92 // constructor
fbb9b71b 93}
d54804bf 94
326c2d4b 95
fbb9b71b 96AliHLTTPCCADisplay::AliHLTTPCCADisplay( const AliHLTTPCCADisplay& )
6de2bc40 97 : fYX( 0 ), fZX( 0 ), fAsk( 1 ), fSliceView( 1 ), fSlice( 0 ), fPerf( 0 ),
fbb9b71b 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 )
326c2d4b 101{
102 // dummy
103}
104
fbb9b71b 105const AliHLTTPCCADisplay& AliHLTTPCCADisplay::operator=( const AliHLTTPCCADisplay& ) const
326c2d4b 106{
107 // dummy
108 return *this;
109}
fbb9b71b 110
326c2d4b 111AliHLTTPCCADisplay::~AliHLTTPCCADisplay()
112{
113 // destructor
fbb9b71b 114 delete fYX;
dc4788ec 115 delete fZX;
326c2d4b 116}
117
118void AliHLTTPCCADisplay::Init()
119{
120 // initialization
fbb9b71b 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);
ce565086 127 fDrawOnlyRef = 0;
326c2d4b 128}
129
130void AliHLTTPCCADisplay::Update()
131{
132 // update windows
fbb9b71b 133 if ( !fAsk ) return;
dc4788ec 134 fYX->Update();
135 fZX->Update();
fbb9b71b 136 fYX->Print( "YX.pdf" );
137 fZX->Print( "ZX.pdf" );
138
326c2d4b 139}
140
d54804bf 141void AliHLTTPCCADisplay::ClearView()
326c2d4b 142{
143 // clear windows
dc4788ec 144 fYX->Clear();
145 fZX->Clear();
326c2d4b 146}
147
148void AliHLTTPCCADisplay::Ask()
149{
4acc2401 150 // wait for the pressed key, when "r" pressed, don't ask anymore
326c2d4b 151 char symbol;
fbb9b71b 152 if ( fAsk ) {
326c2d4b 153 Update();
fbb9b71b 154 std::cout << "ask> " << std::endl;
155 do {
156 std::cin.get( symbol );
157 if ( symbol == 'r' )
158 fAsk = false;
159 } while ( symbol != '\n' );
326c2d4b 160 }
161}
162
163
d54804bf 164void AliHLTTPCCADisplay::SetSliceView()
326c2d4b 165{
d54804bf 166 // switch to slice view
167 fSliceView = 1;
326c2d4b 168}
169
170void AliHLTTPCCADisplay::SetTPCView()
171{
172 // switch to full TPC view
d54804bf 173 fSliceView = 0;
326c2d4b 174 fCos = 1;
175 fSin = 0;
176 fZMin = fTPCZMin;
177 fZMax = fTPCZMax;
4687b8fc 178 fYMin = -fROuterMax;
179 fYMax = fROuterMax;
326c2d4b 180}
181
693d2443 182
d54804bf 183void AliHLTTPCCADisplay::SetCurrentSlice( AliHLTTPCCATracker *slice )
326c2d4b 184{
d54804bf 185 // set reference to the current CA tracker, and read the current slice geometry
186 fSlice = slice;
187 SetSliceTransform( slice );
fbb9b71b 188 if ( fSliceView ) {
d54804bf 189 fCos = slice->Param().SinAlpha();
190 fSin = slice->Param().CosAlpha();
191 fZMin = slice->Param().ZMin();
192 fZMax = slice->Param().ZMax();
193 ClearView();
fbb9b71b 194 double r0 = .5 * ( slice->Param().RMax() + slice->Param().RMin() );
195 double dr = .5 * ( slice->Param().RMax() - slice->Param().RMin() );
4687b8fc 196 fYMin = -dr;
197 fYMax = dr;
fbb9b71b 198 double cx = 0;
199 double cy = r0;
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 );
204
ce565086 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);
207
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);
210
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);
fbb9b71b 213
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));
693d2443 219 //fYX->Range(xc-d, yc-d, xc+d, yc+d);
220 //fZX->Range(zc-d, yc-d, zc+d, yc+d);
fbb9b71b 221
222 }
d54804bf 223}
326c2d4b 224
fbb9b71b 225void AliHLTTPCCADisplay::SetSliceTransform( double alpha )
4687b8fc 226{
227 fSliceCos = TMath::Cos( alpha );
228 fSliceSin = TMath::Sin( alpha );
fbb9b71b 229}
4687b8fc 230
231void AliHLTTPCCADisplay::SetSliceTransform( AliHLTTPCCATracker *slice )
232{
fbb9b71b 233 SetSliceTransform( slice->Param().Alpha() );
4687b8fc 234}
235
236
237void AliHLTTPCCADisplay::DrawTPC()
238{
239 // schematically draw TPC detector
fbb9b71b 240 fYX->Range( -fROuterMax, -fROuterMax, fROuterMax, fROuterMax );
693d2443 241 //fYX->Range( -fROuterMax*.7, -fROuterMax, fROuterMax*0., -fROuterMax*.5);
4687b8fc 242 fYX->Clear();
243 {
fbb9b71b 244 fArc.SetLineColor( kBlack );
245 fArc.SetFillStyle( 0 );
246 fYX->cd();
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 ) );
4687b8fc 252 }
253 }
254 fZX->cd();
693d2443 255 fZX->Range( fTPCZMin, -fROuterMax, fTPCZMax*1.1, fROuterMax );
256 //fZX->Range( fTPCZMax*.1, -fROuterMax, fTPCZMax*.3, -fROuterMax*0.5 );
4687b8fc 257 fZX->Clear();
258}
259
fbb9b71b 260void AliHLTTPCCADisplay::DrawSlice( AliHLTTPCCATracker *slice, bool DrawRows )
261{
4687b8fc 262 // draw current the TPC slice
263 fYX->cd();
fbb9b71b 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() );
271 if ( fSliceView ) {
4687b8fc 272 cx = 0; cy = r0;
273 a0 = 90.;
fbb9b71b 274 fLatex.DrawLatex( cx - dr + dr*.05, cy - dr + dr*.05, Form( "YX, Slice %2i", slice->Param().ISlice() ) );
4687b8fc 275 } else {
fbb9b71b 276 a0 += raddeg * TMath::ATan2( fSin, fCos );
4687b8fc 277 }
fbb9b71b 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 );
693d2443 284 //fCrown.DrawCrown(0,0, slice->Param().RMin(),slice->Param().RMax(), a0-da, a0+da );
fbb9b71b 285
286 fLine.SetLineColor( kBlack );
287
4687b8fc 288 fZX->cd();
289
fbb9b71b 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() ) );
294
295 if ( DrawRows ) {
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 );
693d2443 305 fYX->cd();
fbb9b71b 306 fLine.DrawLine( vx0, vy0, vx1, vy1 );
693d2443 307 fZX->cd();
fbb9b71b 308 fLine.DrawLine( fTPCZMin, vy0, fTPCZMax, vy1 );
693d2443 309 }
310 }
311
4687b8fc 312}
313
314
ce565086 315void AliHLTTPCCADisplay::Set2Slices( AliHLTTPCCATracker * const slice )
d54804bf 316{
317 //* Set view for two neighbouring slices
318
319 fSlice = slice;
320 fSliceView = 0;
fbb9b71b 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() ) );
d54804bf 323 fZMin = slice->Param().ZMin();
324 fZMax = slice->Param().ZMax();
325 ClearView();
fbb9b71b 326 double r0 = .5 * ( slice->Param().RMax() + slice->Param().RMin() );
327 double dr = .5 * ( slice->Param().RMax() - slice->Param().RMin() );
328 double cx = 0;
329 double cy = r0;
330 fYX->Range( cx - 1.3*dr, cy - 1.1*dr, cx + 1.3*dr, cy + 1.1*dr );
d54804bf 331 fYX->cd();
fbb9b71b 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);
340 fZX->cd();
341 fLatex.DrawLatex( cz - dz + dz*.05, cy - dr + dr*.05, Form( "ZX, Slices %2i/%2i", islice, jslice ) );
326c2d4b 342}
343
fbb9b71b 344int AliHLTTPCCADisplay::GetColor( int i ) const
693d2443 345{
346 // Get color with respect to Z coordinate
fbb9b71b 347 const Color_t kMyColor[9] = { kGreen, kBlue, kYellow, kCyan, kOrange,
348 kSpring, kTeal, kAzure, kViolet
349 };
350 if ( i < 0 ) i = 0;
351 if ( i == 0 ) return kBlack;
352 return kMyColor[( i-1 )%9];
693d2443 353}
d54804bf 354
fbb9b71b 355int AliHLTTPCCADisplay::GetColorZ( double z ) const
326c2d4b 356{
357 // Get color with respect to Z coordinate
fbb9b71b 358 const Color_t kMyColor[11] = { kGreen, kBlue, kYellow, kMagenta, kCyan,
359 kOrange, kSpring, kTeal, kAzure, kViolet, kPink
360 };
361
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;
dc4788ec 366 return kMyColor[iz];
326c2d4b 367}
368
fbb9b71b 369int AliHLTTPCCADisplay::GetColorY( double y ) const
326c2d4b 370{
4687b8fc 371 // Get color with respect to Z coordinate
fbb9b71b 372 const Color_t kMyColor[11] = { kGreen, kBlue, kYellow, kMagenta, kCyan,
373 kOrange, kSpring, kTeal, kAzure, kViolet, kPink
374 };
375
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;
4687b8fc 380 return kMyColor[iy];
326c2d4b 381}
382
fbb9b71b 383int AliHLTTPCCADisplay::GetColorK( double k ) const
d54804bf 384{
4687b8fc 385 // Get color with respect to Z coordinate
fbb9b71b 386 const Color_t kMyColor[11] = { kRed, kBlue, kYellow, kMagenta, kCyan,
387 kOrange, kSpring, kTeal, kAzure, kViolet, kPink
388 };
389 const double kCLight = 0.000299792458;
390 const double kBz = 5;
391 double k2QPt = 100;
392 if ( TMath::Abs( kBz ) > 1.e-4 ) k2QPt = 1. / ( kBz * kCLight );
393 double qPt = k * k2QPt;
394 double pt = 100;
395 if ( TMath::Abs( qPt ) > 1.e-4 ) pt = 1. / TMath::Abs( qPt );
396
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;
4687b8fc 401 return kMyColor[iy];
402}
d54804bf 403
fbb9b71b 404void AliHLTTPCCADisplay::Global2View( double x, double y, double *xv, double *yv ) const
d54804bf 405{
4687b8fc 406 // convert coordinates global->view
fbb9b71b 407 *xv = x * fCos + y * fSin;
408 *yv = y * fCos - x * fSin;
d54804bf 409}
410
4687b8fc 411
fbb9b71b 412void AliHLTTPCCADisplay::Slice2View( double x, double y, double *xv, double *yv ) const
326c2d4b 413{
d54804bf 414 // convert coordinates slice->view
fbb9b71b 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;
326c2d4b 419}
420
f0fb467d 421void AliHLTTPCCADisplay::SliceHitXYZ(int iRow, int iHit, double &x, double &y, double &z )
693d2443 422{
f0fb467d 423 // get xyz of the hit
424
fbb9b71b 425 if ( !fSlice ) return;
426 const AliHLTTPCCARow &row = fSlice->Row( iRow );
ddba06bc 427 float y0 = row.Grid().YMin();
428 float z0 = row.Grid().ZMin();
429 float stepY = row.HstepY();
430 float stepZ = row.HstepZ();
f0fb467d 431 x = row.X();
432 y = y0 + fSlice->HitDataY( row, iHit ) * stepY;
433 z = z0 + fSlice->HitDataZ( row, iHit ) * stepZ;
434}
435
436void AliHLTTPCCADisplay::DrawSliceHit( int iRow, int iHit, int color, Size_t width )
437{
438 // draw hit
439 if ( !fSlice ) return;
440
441 double x,y,z;
442 SliceHitXYZ( iRow, iHit, x, y, z );
fbb9b71b 443
444 SetSliceTransform( fSlice );
445
446 if ( color < 0 ) {
6de2bc40 447 if ( 0 && fPerf ) {
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;
455 //}
fbb9b71b 456 } else color = GetColorZ( z );
ddba06bc 457 }
fbb9b71b 458 if ( width > 0 )fMarker.SetMarkerSize( width );
459 else fMarker.SetMarkerSize( .3 );
460 fMarker.SetMarkerColor( color );
461 double vx, vy;
462 Slice2View( x, y, &vx, &vy );
ddba06bc 463 fYX->cd();
fbb9b71b 464 fMarker.DrawMarker( vx, vy );
465 fZX->cd();
466 fMarker.DrawMarker( z, vy );
693d2443 467}
468
fbb9b71b 469void AliHLTTPCCADisplay::DrawSliceHits( int color, Size_t width )
693d2443 470{
693d2443 471
fbb9b71b 472 // draw hits
693d2443 473
fbb9b71b 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 );
693d2443 478 }
fbb9b71b 479 }
693d2443 480}
481
ce565086 482
f0fb467d 483void AliHLTTPCCADisplay::DrawSliceLink( int iRow, int iHit, int colorUp, int colorDn, int width )
ce565086 484{
fbb9b71b 485 // draw link between clusters
f0fb467d 486
487 //if ( !fPerf ) return;
488 //AliHLTTPCCAGBTracker &tracker = *fGB;
fbb9b71b 489 if ( width < 0 ) width = 1.;
ce565086 490 fLine.SetLineWidth( width );
fbb9b71b 491 int colUp = colorUp >= 0 ? colorUp : kMagenta;
492 int colDn = colorDn >= 0 ? colorDn : kBlack;
4acc2401 493 if ( iRow < 2 || iRow >= fSlice->Param().NRows() - 2 ) return;
fbb9b71b 494
f0fb467d 495 const AliHLTTPCCARow& row = fSlice->Data().Row( iRow );
fbb9b71b 496
4acc2401 497 short iUp = fSlice->HitLinkUpData( row, iHit );
498 short iDn = fSlice->HitLinkDownData( row, iHit );
fbb9b71b 499
f0fb467d 500
501 double p1[3], p2[3], p3[3];
502 SliceHitXYZ( iRow, iHit, p1[0],p1[1],p1[2]);
503
504 double vx, vy, vx1, vy1;
505 Slice2View( p1[0], p1[1], &vx, &vy );
506
fbb9b71b 507 if ( iUp >= 0 ) {
f0fb467d 508 SliceHitXYZ( iRow+2, iUp, p2[0],p2[1],p2[2]);
509 Slice2View( p2[0], p2[1], &vx1, &vy1 );
ce565086 510 fLine.SetLineColor( colUp );
511 fYX->cd();
fbb9b71b 512 fLine.DrawLine( vx - .1, vy, vx1 - .1, vy1 );
ce565086 513 fZX->cd();
f0fb467d 514 fLine.DrawLine( p1[2] - 1., vy, p2[2] - 1., vy1 );
ce565086 515 }
f0fb467d 516 if ( iDn >= 0 ) {
517 SliceHitXYZ( iRow-2, iDn, p3[0],p3[1],p3[2]);
518 Slice2View( p3[0], p3[1], &vx1, &vy1 );
ce565086 519 fLine.SetLineColor( colDn );
520 fYX->cd();
fbb9b71b 521 fLine.DrawLine( vx + .1, vy, vx1 + .1, vy1 );
ce565086 522 fZX->cd();
f0fb467d 523 fLine.DrawLine( p1[2] + 1., vy, p3[2] + 1., vy1 );
ce565086 524 }
f0fb467d 525
ce565086 526}
527
528
fbb9b71b 529void AliHLTTPCCADisplay::DrawSliceLinks( int colorUp, int colorDn, int width )
ce565086 530{
fbb9b71b 531 // draw links between clusters
ce565086 532
fbb9b71b 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++ ) {
ce565086 536 DrawSliceLink( iRow, ih, colorUp, colorDn, width );
537 }
538 }
539}
540
541
542
6de2bc40 543int AliHLTTPCCADisplay::GetTrackMC( const AliHLTTPCCADisplayTmpHit */*vHits*/, int /*NHits*/ )
693d2443 544{
545 // get MC label for the track
6de2bc40 546 return 0;
547#ifdef XXX
693d2443 548 AliHLTTPCCAGBTracker &tracker = *fGB;
549
fbb9b71b 550 int label = -1;
551 double purity = 0;
552 int *lb = new int[NHits*3];
553 int nla = 0;
693d2443 554 //std::cout<<"\n\nTrack hits mc: "<<std::endl;
fbb9b71b 555 for ( int ihit = 0; ihit < NHits; ihit++ ) {
4acc2401 556 const AliHLTTPCCAGBHit &h = tracker.Hits()[vHits[ihit].ID()];
693d2443 557 AliHLTTPCCAPerformance::AliHLTTPCCAHitLabel &l = fPerf->HitLabels()[h.ID()];
fbb9b71b 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];
693d2443 561 //std::cout<<ihit<<": "<<l.fLab[0]<<" "<<l.fLab[1]<<" "<<l.fLab[2]<<std::endl;
562 }
fbb9b71b 563 sort( lb, lb + nla );
564 int labmax = -1, labcur = -1, lmax = 0, lcurr = 0, nh = 0;
693d2443 565 //std::cout<<"MC track IDs :"<<std::endl;
fbb9b71b 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;
573
693d2443 574 }
fbb9b71b 575 nh = 0;
576 if ( labcur >= 0 && lmax < lcurr ) {
577 lmax = lcurr;
578 labmax = labcur;
693d2443 579 }
580 labcur = lb[i];
581 lcurr = 0;
582 }
583 lcurr++;
584 nh++;
585 }
fbb9b71b 586 if ( 0 && nla - 1 > 0 && lb[nla-1] >= 0 ) {
693d2443 587 AliHLTTPCCAMCTrack &mc = fPerf->MCTracks()[lb[nla-1]];
fbb9b71b 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;
591
693d2443 592 }
fbb9b71b 593 if ( labcur >= 0 && lmax < lcurr ) {
693d2443 594 lmax = lcurr;
595 labmax = labcur;
596 }
597 lmax = 0;
fbb9b71b 598 for ( int ihit = 0; ihit < NHits; ihit++ ) {
4acc2401 599 const AliHLTTPCCAGBHit &h = tracker.Hits()[vHits[ihit].ID()];
693d2443 600 AliHLTTPCCAPerformance::AliHLTTPCCAHitLabel &l = fPerf->HitLabels()[h.ID()];
fbb9b71b 601 if ( l.fLab[0] == labmax || l.fLab[1] == labmax || l.fLab[2] == labmax
602 ) lmax++;
693d2443 603 }
604 label = labmax;
fbb9b71b 605 purity = ( ( NHits > 0 ) ? double( lmax ) / double( NHits ) : 0 );
606 if ( lb ) delete[] lb;
607 if ( purity < .9 ) label = -1;
693d2443 608 return label;
6de2bc40 609#endif
693d2443 610}
4687b8fc 611
6de2bc40 612bool AliHLTTPCCADisplay::DrawTrack( AliHLTTPCCATrackParam /*t*/, double /*Alpha*/, const AliHLTTPCCADisplayTmpHit */*vHits*/,
613 int /*NHits*/, int /*color*/, int /*width*/, bool /*pPoint*/ )
693d2443 614{
615 // draw track
6de2bc40 616 return 1;
617#ifdef XXX
fbb9b71b 618 if ( NHits < 2 ) return 0;
693d2443 619
6de2bc40 620 //AliHLTTPCCAGBTracker &tracker = *fGB;
fbb9b71b 621 if ( width < 0 ) width = 2;
693d2443 622
fbb9b71b 623 if ( fDrawOnlyRef ) {
624 int lab = GetTrackMC( vHits, NHits );
625 if ( lab < 0 ) return 0;
693d2443 626 AliHLTTPCCAMCTrack &mc = fPerf->MCTracks()[lab];
fbb9b71b 627 if ( mc.P() < 1 ) return 0;
693d2443 628 }
629
fbb9b71b 630 if ( color < 0 ) {
693d2443 631 //color = GetColorZ( (vz[0]+vz[mHits-1])/2. );
632 //color = GetColorK(t.GetKappa());
fbb9b71b 633 int lab = GetTrackMC( vHits, NHits );
634 color = GetColor( lab + 1 );
635 if ( lab >= 0 ) {
693d2443 636 AliHLTTPCCAMCTrack &mc = fPerf->MCTracks()[lab];
fbb9b71b 637 if ( mc.P() >= 1. ) color = kRed;
638 }
693d2443 639 }
15d2e9cf 640
fbb9b71b 641 if ( t.SinPhi() > .999 ) t.SetSinPhi( .999 );
642 else if ( t.SinPhi() < -.999 ) t.SetSinPhi( -.999 );
693d2443 643
fbb9b71b 644 // int iSlice = fSlice->Param().ISlice();
693d2443 645
646 //sort(vHits, vHits + NHits, AliHLTTPCCADisplayTmpHit::CompareHitZ );
647
fbb9b71b 648 double vx[2000], vy[2000], vz[2000];
649 int mHits = 0;
693d2443 650
fbb9b71b 651 //int oldSlice = -1;
652 double alpha = ( TMath::Abs( Alpha + 1 ) < 1.e-4 ) ? fSlice->Param().Alpha() : Alpha;
693d2443 653 AliHLTTPCCATrackParam tt = t;
654
fbb9b71b 655 for ( int iHit = 0; iHit < NHits; iHit++ ) {
693d2443 656
4acc2401 657 const AliHLTTPCCAGBHit &h = tracker.Hits()[vHits[iHit].ID()];
693d2443 658
fbb9b71b 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;
693d2443 664
665 {
fbb9b71b 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 ) ) {
671 alpha += 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;
676 }
693d2443 677 }
678 }
679 SetSliceTransform( alpha );
680
fbb9b71b 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;
685 if ( 1 || ok ) {
693d2443 686 x1 = tt.X();
687 y1 = tt.Y();
688 z1 = tt.Z();
689 }
690
fbb9b71b 691 Slice2View( x1, y1, &x1, &y1 );
693d2443 692 vx[mHits] = x1;
693 vy[mHits] = y1;
694 vz[mHits] = z1;
695 mHits++;
fbb9b71b 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 );
701 if ( ok ) {
702 x1 = tt.X();
703 y1 = tt.Y();
704 z1 = tt.Z();
693d2443 705 }
fbb9b71b 706
707 Slice2View( x1, y1, &x1, &y1 );
693d2443 708 vx[mHits] = x1;
709 vy[mHits] = y1;
710 vz[mHits] = z1;
711 mHits++;
712 }
713 }
fbb9b71b 714 if ( pPoint ) {
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;
693d2443 717 SetSliceTransform( a );
718
fbb9b71b 719 Slice2View( x1, y1, &x1, &y1 );
720 double dx = x1 - vx[0];
721 double dy = y1 - vy[0];
693d2443 722 //std::cout<<x1<<" "<<y1<<" "<<vx[0]<<" "<<vy[0]<<" "<<dx<<" "<<dy<<std::endl;
fbb9b71b 723 double d0 = dx * dx + dy * dy;
693d2443 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;
fbb9b71b 727 double d1 = dx * dx + dy * dy;
693d2443 728 //std::cout<<"d0, d1="<<d0<<" "<<d1<<std::endl;
fbb9b71b 729 if ( d1 < d0 ) {
693d2443 730 vx[mHits] = x1;
731 vy[mHits] = y1;
fbb9b71b 732 vz[mHits] = z1;
693d2443 733 mHits++;
734 } else {
fbb9b71b 735 for ( int i = mHits; i > 0; i-- ) {
736 vx[i] = vx[i-1];
737 vy[i] = vy[i-1];
738 vz[i] = vz[i-1];
693d2443 739 }
740 vx[0] = x1;
741 vy[0] = y1;
fbb9b71b 742 vz[0] = z1;
693d2443 743 mHits++;
fbb9b71b 744 }
4687b8fc 745 }
fbb9b71b 746
747
748 fLine.SetLineColor( color );
749 fLine.SetLineWidth( width );
750 fArc.SetFillStyle( 0 );
751 fArc.SetLineColor( color );
752 fArc.SetLineWidth( width );
753 TPolyLine pl;
754 pl.SetLineColor( color );
755 pl.SetLineWidth( width );
4687b8fc 756 TPolyLine plZ;
fbb9b71b 757 plZ.SetLineColor( color );
758 plZ.SetLineWidth( width );
759
760 fMarker.SetMarkerSize( width / 2. );
761 fMarker.SetMarkerColor( color );
4687b8fc 762
693d2443 763 fYX->cd();
fbb9b71b 764 pl.DrawPolyLine( mHits, vx, vy );
693d2443 765 {
fbb9b71b 766 fMarker.DrawMarker( vx[0], vy[0] );
767 fMarker.DrawMarker( vx[mHits-1], vy[mHits-1] );
693d2443 768 }
769 fZX->cd();
fbb9b71b 770 plZ.DrawPolyLine( mHits, vz, vy );
771 fMarker.DrawMarker( vz[0], vy[0] );
772 fMarker.DrawMarker( vz[mHits-1], vy[mHits-1] );
773
774 fLine.SetLineWidth( 1 );
693d2443 775 return 1;
6de2bc40 776#endif
693d2443 777}
4687b8fc 778
4687b8fc 779
6de2bc40 780bool AliHLTTPCCADisplay::DrawTracklet( AliHLTTPCCATrackParam &/*track*/, const int */*hitstore*/, int /*color*/, int /*width*/, bool /*pPoint*/ )
693d2443 781{
782 // draw tracklet
6de2bc40 783#ifdef XXX
693d2443 784 AliHLTTPCCAGBTracker &tracker = *fGB;
785 AliHLTTPCCADisplayTmpHit vHits[200];
fbb9b71b 786 int nHits = 0;
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 );
4acc2401 791 int id = fSlice->HitInputID( row, iHit );
fbb9b71b 792 int iGBHit = tracker.FirstSliceHit()[fSlice->Param().ISlice()] + id;
4acc2401 793 const AliHLTTPCCAGBHit &h = tracker.Hits()[iGBHit];
693d2443 794 vHits[nHits].SetID( iGBHit );
795 vHits[nHits].SetS( 0 );
796 vHits[nHits].SetZ( h.Z() );
797 nHits++;
798 }
fbb9b71b 799 return DrawTrack( track, -1, vHits, nHits, color, width, pPoint );
6de2bc40 800#endif
801 return 1;
693d2443 802}
4687b8fc 803
4687b8fc 804
6de2bc40 805void AliHLTTPCCADisplay::DrawSliceOutTrack( AliHLTTPCCATrackParam &/*t*/, double /*alpha*/, int /*itr*/, int /*color*/, int /*width*/ )
693d2443 806{
807 // draw slice track
6de2bc40 808#ifdef XXX
693d2443 809 AliHLTTPCCAOutTrack &track = fSlice->OutTracks()[itr];
fbb9b71b 810 if ( track.NHits() < 2 ) return;
4687b8fc 811
693d2443 812 AliHLTTPCCAGBTracker &tracker = *fGB;
813 AliHLTTPCCADisplayTmpHit vHits[200];
4687b8fc 814
fbb9b71b 815 for ( int ih = 0; ih < track.NHits(); ih++ ) {
b22af1bf 816 int id = tracker.FirstSliceHit()[fSlice->Param().ISlice()] + fSlice->OutTrackHit(track.FirstHitRef()+ih);
4acc2401 817 const AliHLTTPCCAGBHit &h = tracker.Hits()[id];
693d2443 818 vHits[ih].SetID( id );
819 vHits[ih].SetS( 0 );
820 vHits[ih].SetZ( h.Z() );
326c2d4b 821 }
693d2443 822
823 DrawTrack( t, alpha, vHits, track.NHits(), color, width, 1 );
6de2bc40 824#endif
693d2443 825}
826
6de2bc40 827void AliHLTTPCCADisplay::DrawSliceOutTrack( int /*itr*/, int /*color*/, int /*width*/ )
693d2443 828{
829 // draw slice track
6de2bc40 830#ifdef XXX
693d2443 831 AliHLTTPCCAOutTrack &track = fSlice->OutTracks()[itr];
fbb9b71b 832 if ( track.NHits() < 2 ) return;
693d2443 833
834 AliHLTTPCCAGBTracker &tracker = *fGB;
835 AliHLTTPCCADisplayTmpHit vHits[200];
836
fbb9b71b 837 for ( int ih = 0; ih < track.NHits(); ih++ ) {
b22af1bf 838 int id = tracker.FirstSliceHit()[fSlice->Param().ISlice()] + fSlice->OutTrackHit(track.FirstHitRef()+ih);
4acc2401 839 const AliHLTTPCCAGBHit &h = tracker.Hits()[id];
693d2443 840 vHits[ih].SetID( id );
841 vHits[ih].SetS( 0 );
842 vHits[ih].SetZ( h.Z() );
843 }
844
845 DrawTrack( track.StartPoint(), -1, vHits, track.NHits(), color, width );
6de2bc40 846#endif
693d2443 847}
848
849
6de2bc40 850void AliHLTTPCCADisplay::DrawSliceTrack( int /*itr*/, int /*color*/ )
693d2443 851{
852 // draw slice track
6de2bc40 853#ifdef XXX
4acc2401 854 const AliHLTTPCCATrack &track = fSlice->Tracks()[itr];
fbb9b71b 855 if ( track.NHits() < 2 ) return;
693d2443 856
857 AliHLTTPCCAGBTracker &tracker = *fGB;
fbb9b71b 858 AliHLTTPCCADisplayTmpHit vHits[200];
859 for ( int ith = 0; ith < track.NHits(); ith++ ) {
4acc2401 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 );
fbb9b71b 864 int gbID = tracker.FirstSliceHit()[fSlice->Param().ISlice()] + id;
4acc2401 865 const AliHLTTPCCAGBHit &h = tracker.Hits()[gbID];
693d2443 866 vHits[ith].SetID( gbID );
867 vHits[ith].SetS( 0 );
868 vHits[ith].SetZ( h.Z() );
869 }
870
fbb9b71b 871 DrawTrack( track.Param(), -1, vHits, track.NHits(), color, -1 );
693d2443 872 //track.Param().Print();
00d07bcd 873#endif
326c2d4b 874}