LCOV - code coverage report
Current view: top level - HLT/TPCLib/tracking-ca - AliHLTTPCCADisplay.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 258 0.0 %
Date: 2016-06-14 17:26:59 Functions: 0 35 0.0 %

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

Generated by: LCOV version 1.11