// $Id: AliHLTTPCCADisplay.cxx,v 1.3 2010/08/16 21:23:57 ikulakov Exp $ // ************************************************************************** // This file is property of and copyright by the ALICE HLT Project * // ALICE Experiment at CERN, All rights reserved. * // * // Primary Authors: Sergey Gorbunov * // Ivan Kisel * // for The ALICE HLT Project. * // * // Developed by: Igor Kulakov * // Maksym Zyzak * // * // Permission to use, copy, modify and distribute this software and its * // documentation strictly for non-commercial purposes is hereby granted * // without fee, provided that the above copyright notice appears in all * // copies and that both the copyright notice and this permission notice * // appear in the supporting documentation. The authors make no claims * // about the suitability of this software for any purpose. It is * // provided "as is" without express or implied warranty. * // * //*************************************************************************** // TODO now we use right CS, so z change sign, but it wasn't changed everywhere in the Display-code #include "AliHLTTPCCADisplay.h" //#define DRAW_3D // infrequent use for drawing 3D pictures #include "AliHLTTPCCAParameters.h" using namespace AliHLTTPCCAParameters; #include "AliHLTTPCCAGBTracker.h" #include "AliHLTTPCCAGBTrack.h" #include "AliHLTTPCCAGBHit.h" #include "AliHLTTPCCAPerformance.h" #include "AliHLTTPCCAMCTrack.h" #include "AliHLTTPCCAParam.h" #include "AliHLTTPCCAClusterData.h" #include "AliHLTTPCCATrackPerformanceBase.h" #include "ITSCAHits.h" #include "ITSCAHitsV.h" #include "ITSCASingletsV.h" #include "ITSCADoubletsV.h" #include "ITSCATripletsV.h" #include "ITSCATracks.h" #include "TString.h" #include "Riostream.h" #include "TMath.h" #include "TStyle.h" #include "TCanvas.h" #include "TApplication.h" #include "TLatex.h" #ifdef DRAW_3D #include "TVector3.h" #endif // DRAW_3D class AliHLTTPCCADisplay::AliHLTTPCCADisplayTmpHit { public: int ID() const { return fHitID; } double S() const { return fS; } double Z() const { return fZ; } void SetID( int v ) { fHitID = v; } void SetS( double v ) { fS = v; } void SetZ( double v ) { fZ = v; } static bool CompareHitDS( const AliHLTTPCCADisplayTmpHit &a, const AliHLTTPCCADisplayTmpHit &b ) { return ( a.fS < b.fS ); } static bool CompareHitZ( const AliHLTTPCCADisplayTmpHit &a, const AliHLTTPCCADisplayTmpHit &b ) { return ( a.fZ < b.fZ ); } private: int fHitID; // hit ID double fS; // hit position on the XY track curve double fZ; // hit Z position }; AliHLTTPCCADisplay &AliHLTTPCCADisplay::Instance() { // reference to static object static AliHLTTPCCADisplay gAliHLTTPCCADisplay; return gAliHLTTPCCADisplay; } AliHLTTPCCADisplay::AliHLTTPCCADisplay() : fYX( 0 ), fZX( 0 ), fAsk( 1 ), fGB( 0 ), fPerf( 0 ), fZMin( -60 ), fZMax( 60 ), fYMin( -210 ), fYMax( 210 ), fRInnerMin( 50. ), fRInnerMax( 133.3 ), fROuterMin( 50 ), fROuterMax( 50 ), fTPCZMin( -60. ), fTPCZMax( 60 ), fArc(), fLine(), fPLine(), fMarker(), fBox(), fCrown(), fLatex(), fDrawOnlyRef( 0 ) // iklm. This is just default. If they are not correct SetTPC(...) can and should be used! { fPerf = &( AliHLTTPCCAPerformance::Instance() ); // constructor } AliHLTTPCCADisplay::~AliHLTTPCCADisplay() { // destructor delete fYX; delete fZX; } void AliHLTTPCCADisplay::Init() { static bool firstCall = 1; if ( firstCall ) { if ( !gApplication ) new TApplication( "myapp", 0, 0 ); // initialization gStyle->SetCanvasBorderMode( 0 ); gStyle->SetCanvasBorderSize( 1 ); gStyle->SetCanvasColor( 0 ); fCanvas = new TCanvas( "CA", "CA Display", 1280, 645 ); fCanvas->Divide( 2, 1 ); fYX = static_cast( fCanvas->GetPrimitive( "CA_1" ) ); // ("YX", "YX window", -1, 0, 600, 600); fZX = static_cast( fCanvas->GetPrimitive( "CA_2" ) ); // ("ZX", "ZX window", -610, 0, 590, 600); fYX->SetCanvas( fCanvas ); fYX->SetTitle( "YX" ); fZX->SetCanvas( fCanvas ); fZX->SetTitle( "ZX" ); fMarker = TMarker( 0.0, 0.0, 20 );//6); fDrawOnlyRef = 0; firstCall = 0; } } void AliHLTTPCCADisplay::Update() { // update windows if ( !fAsk ) return; fYX->Update(); fZX->Update(); //X fYX->Print( "YX.pdf" ); //X fZX->Print( "ZX.pdf" ); } void AliHLTTPCCADisplay::ClearView() { // clear windows fYX->Clear(); fZX->Clear(); } void AliHLTTPCCADisplay::Ask() { // wait for the pressed key, when "r" pressed, don't ask anymore char symbol; if ( fAsk ) { Update(); std::cout << "ask> "; do { std::cin.get( symbol ); if ( symbol == 'r' ) fAsk = false; } while ( symbol != '\n' ); } } void AliHLTTPCCADisplay::SetTPCView() { // switch to full TPC view fZMin = fTPCZMin; fZMax = fTPCZMax; fYMin = -fROuterMax; fYMax = fROuterMax; } void AliHLTTPCCADisplay::SetGB( const AliHLTTPCCAGBTracker * GBTracker ) { fGB = GBTracker; } void AliHLTTPCCADisplay::DrawTPC() { // schematically draw TPC detector fYX->Range( -fROuterMax-2, -fROuterMax-2, fROuterMax+2, fROuterMax+2 ); //fYX->Range( -fROuterMax*.7, -fROuterMax, fROuterMax*0., -fROuterMax*.5); fYX->Clear(); { fArc.SetLineColor( kBlack ); fArc.SetFillStyle( 0 ); fYX->cd(); TLatex Tl; Tl.SetTextSize(0.02); Tl.SetTextAlign(22); } fZX->cd(); fZX->Range( fZMin*1.01, -fROuterMax*1.01, fZMax*1.01, fROuterMax*1.01 ); //std::cout << fTPCZMin<<" "<Range( fTPCZMax*.1, -fROuterMax, fTPCZMax*.3, -fROuterMax*0.5 ); fZX->Clear(); TBox ZX; ZX.SetFillStyle( 0 ); ZX.SetFillColor(0); ZX.SetLineWidth(0.1); ZX.DrawBox(fZMin,-fROuterMax,fZMax,fROuterMax); } void AliHLTTPCCADisplay::DrawArc(float x, float y, float r, int Start, Size_t width ) { fArc.SetLineWidth( width ); fArc.SetLineColor( 2 + Start); fYX->cd(); fArc.DrawArc( x, y, r ); } void AliHLTTPCCADisplay::DrawPoint(float x, float y, float z, int Start, Size_t width ) { fMarker.SetMarkerSize( width ); fMarker.SetMarkerColor( 2 + Start); fYX->cd(); fMarker.DrawMarker( x, y ); fZX->cd(); fMarker.DrawMarker( z, y ); } void AliHLTTPCCADisplay::DrawGBPoint(float x, float y, float z, int Start, Size_t width ) { fMarker.SetMarkerSize( width ); fMarker.SetMarkerColor( 2 + Start); fYX->cd(); fMarker.DrawMarker( x, y ); fZX->cd(); fMarker.DrawMarker( z, y ); } void AliHLTTPCCADisplay::DrawGBPoint(float x, float y, float z, float angle, int Start, Size_t width ) { fMarker.SetMarkerSize( width ); fMarker.SetMarkerColor( 2 + Start); // fArrow.SetAngle(h.Angle()); fArrow.SetFillColor( 2 + Start ); fArrow.SetLineColor( 2 + Start ); fArrow.SetLineWidth( 1*width ); double cosa = TMath::Cos(angle); double sina = TMath::Sin(angle); double ax2 = 0; double ay2 = -3; double ax0 = x + ax2*cosa - ay2*sina; double ay0 = y + ax2*sina + ay2*cosa; double ax1 = 0; double ay1 = 3; double ax = x + ax1*cosa - ay1*sina; double ay = y + ax1*sina + ay1*cosa; fYX->cd(); fMarker.DrawMarker( x, y ); fArrow.DrawArrow(ax0, ay0, ax, ay, 0.003, "|>"); fZX->cd(); fMarker.DrawMarker( z, y ); } void AliHLTTPCCADisplay::DrawGBLine(float x, float y, float z, float x2, float y2, float z2, int Start, Size_t width ) { fLine.SetLineWidth( width ); fLine.SetLineColor( Start); fYX->cd(); fLine.DrawLine( x, y, x2, y2 ); fZX->cd(); fLine.DrawLine( z, y, z2, y2 ); } int AliHLTTPCCADisplay::GetColor( int i ) const { // Get color with respect to Z coordinate const Color_t kMyColor[9] = { kGreen, kBlue, kYellow, kCyan, kOrange, kSpring, kTeal, kAzure, kViolet }; if ( i < 0 ) i = 0; if ( i == 0 ) return kBlack; return kMyColor[( i-1 )%9]; } int AliHLTTPCCADisplay::GetColorZ( double z ) const { // Get color with respect to Z coordinate const Color_t kMyColor[11] = { kGreen, kBlue, kYellow, kMagenta, kCyan, kOrange, kSpring, kTeal, kAzure, kViolet, kPink }; double zz = ( z - fZMin ) / ( fZMax - fZMin ); int iz = ( int ) ( zz * 11 ); if ( iz < 0 ) iz = 0; if ( iz > 10 ) iz = 10; return kMyColor[iz]; } int AliHLTTPCCADisplay::GetColorY( double y ) const { // Get color with respect to Z coordinate const Color_t kMyColor[11] = { kGreen, kBlue, kYellow, kMagenta, kCyan, kOrange, kSpring, kTeal, kAzure, kViolet, kPink }; double yy = ( y - fYMin ) / ( fYMax - fYMin ); int iy = ( int ) ( yy * 11 ); if ( iy < 0 ) iy = 0; if ( iy > 10 ) iy = 10; return kMyColor[iy]; } int AliHLTTPCCADisplay::GetColorK( double k ) const { // Get color with respect to Z coordinate const Color_t kMyColor[11] = { kRed, kBlue, kYellow, kMagenta, kCyan, kOrange, kSpring, kTeal, kAzure, kViolet, kPink }; const double kCLight = 0.000299792458; const double kBz = 5; double k2QPt = 100; if ( TMath::Abs( kBz ) > 1.e-4 ) k2QPt = 1. / ( kBz * kCLight ); double qPt = k * k2QPt; double pt = 100; if ( TMath::Abs( qPt ) > 1.e-4 ) pt = 1. / TMath::Abs( qPt ); double yy = ( pt - 0.1 ) / ( 1. - 0.1 ); int iy = ( int ) ( yy * 11 ); if ( iy < 0 ) iy = 0; if ( iy > 10 ) iy = 10; return kMyColor[iy]; } void AliHLTTPCCADisplay::DrawGBHit( const AliHLTTPCCAGBTracker &tracker, int iHit, int color, Size_t width ) { // draw hit const AliHLTTPCCAGBHit &h = tracker.Hits()[iHit]; if ( color < 0 ) { if ( fPerf ) { int lab = fPerf->HitLabel( h.ID() ).fLab[0]; color = GetColor( lab + 1 ); if ( lab >= 0 ) { const AliHLTTPCCAMCTrack &mc = fPerf->MCTrack( lab ); if ( mc.P() >= 1. ) color = kRed; else if ( fDrawOnlyRef ) return; } } else color = GetColorZ( h.Z() ); } if ( width > 0 )fMarker.SetMarkerSize( width ); else fMarker.SetMarkerSize( .3 ); fMarker.SetMarkerColor( color ); double vx = h.X(), vy = h.Y(); fYX->cd(); fMarker.DrawMarker( vx, vy ); fZX->cd(); fMarker.DrawMarker( h.Z(), vy ); } void AliHLTTPCCADisplay::DrawGBHits( const AliHLTTPCCAGBTracker &tracker, int color, Size_t width, int hitsType) { // draw hits if ( !fPerf ) return; if ( width < 0 ) width = .6; for ( int iHit = 0; iHit < tracker.NHits(); iHit++ ) { const AliHLTTPCCAGBHit &h = tracker.Hits()[iHit]; // if ((hitsType == 1) && (h.ISlice() >= 12)) continue; // if ((hitsType == 2) && (h.ISlice() < 12) ) continue; int imc = fPerf->HitLabel( h.ID() ).fLab[0]; const AliHLTTPCCAMCTrack *mc = ( imc >= 0 ) ? &( fPerf->MCTrack( imc ) ) : 0; if ( fDrawOnlyRef && ( !mc || ( mc->P() < 1 ) ) ) continue; int col = color; if ( color < 0 ) { if (hitsType == 1) { if (h.Z() >= 0) col = kBlue; if (h.Z() < 0) col = 8; } else{ col = GetColor( imc + 1 ) ; if ( mc && ( mc->P() >= PParameters::RefThreshold ) ) col = kRed; } } fMarker.SetMarkerSize( width ); fMarker.SetMarkerColor( col ); double vx = h.X(), vy = h.Y(); // fArrow.SetAngle(h.Angle()); fArrow.SetFillColor( col ); fArrow.SetLineColor( col ); fArrow.SetLineWidth( 1*width ); double ax, ay; double cosA = TMath::Cos(h.Angle()); double sinA = TMath::Sin(h.Angle()); double ax1 = 0; double ay1 = 3; ax = vx + ax1*cosA - ay1*sinA; ay = vy + ax1*sinA + ay1*cosA; fYX->cd(); fMarker.DrawMarker( vx, vy ); // fArrow.DrawArrow(vx, vy, ax, ay, 0.003, "|>"); // draw module direction fZX->cd(); fMarker.DrawMarker( h.Z(), vy ); } } void AliHLTTPCCADisplay::HitToGlobal( const ITSCAHit& h, float& x, float& y, float &z ) { CALocalToGlobal(h.X0(), h.X1(), h.X2(), h.Angle(), x, y, z); } void AliHLTTPCCADisplay::HitToGlobal( const ITSCAHitV& h, int iV, float& x, float& y, float &z ) { CALocalToGlobal(h.X0()[iV], h.X1()[iV], h.X2()[iV], h.Angle()[iV], x, y, z); } void AliHLTTPCCADisplay::DrawGBHits(const ITSCAHitsV& all) { for( int iS = 0, iColor = 0; iS < all.NStations(); ++iS, iColor++ ) { if ( iColor == kYellow ) iColor++; if ( iColor == kWhite ) iColor++; const ITSCAElementsOnStation& s = all.OnStation( iS ); for( unsigned int i = 0; i < s.size(); ++i ) { const ITSCAHitV &h = s[i]; foreach_bit( int iV, h.IsValid() ) { float gx, gy, gz; HitToGlobal( h, iV, gx, gy, gz ); DrawGBPoint( gx, gy, gz, iS, 0.5 ); // std::cout << iS << " " << i << " " << iV << " " << h.X1()[iV] << " " << h.X2()[iV] << " " << h.X0()[iV] << std::endl; // dbg } } } } void AliHLTTPCCADisplay::DrawGBSinglets(const ITSCASingletsV& all) { for( int iS = 0; iS < all.NStations(); ++iS ) { const ITSCAElementsOnStation& s = all.OnStation( iS ); for( unsigned int i = 0; i < s.size(); ++i ) { foreach_bit( int iV, s[i].IsValid() ) { float gx, gy, gz; HitToGlobal( s.GetHit( iV, 0, i ), gx, gy, gz ); DrawGBLine( 0,0,0, gx, gy, gz, kYellow, 1 ); // std::cout << iS << " " << i << " " << iV << " " << hit0.GX() << " " << hit0.GY() << " " << hit0.GZ() << std::endl; // dbg } } } } void AliHLTTPCCADisplay::DrawGBDoublets(const ITSCADoubletsV& all) { for( int iS = 0; iS < all.NStations(); ++iS ) { const ITSCAElementsOnStation& s = all.OnStation( iS ); for( unsigned int i = 0; i < s.size(); ++i ) { foreach_bit( int iV, s[i].IsValid() ) { float gx0, gy0, gz0, gx1, gy1, gz1; HitToGlobal( s.GetHit( iV, 0, i ), gx0, gy0, gz0 ); HitToGlobal( s.GetHit( iV, 1, i ), gx1, gy1, gz1 ); DrawGBLine( gx0, gy0, gz0, gx1, gy1, gz1, kGreen, 1 ); } } } } void AliHLTTPCCADisplay::DrawGBTriplets(const ITSCATripletsV& all) { for( int iS = 0; iS < all.NStations(); ++iS ) { const ITSCAElementsOnStation& s = all.OnStation( iS ); for( unsigned int i = 0; i < s.size(); ++i ) { foreach_bit( int iV, s[i].IsValid() ) { float gx0, gy0, gz0, gx1, gy1, gz1, gx2, gy2, gz2; HitToGlobal( s.GetHit( iV, 0, i ), gx0, gy0, gz0 ); HitToGlobal( s.GetHit( iV, 1, i ), gx1, gy1, gz1 ); HitToGlobal( s.GetHit( iV, 2, i ), gx2, gy2, gz2 ); DrawGBLine( gx0, gy0, gz0, gx1, gy1, gz1, kBlue, 1 ); DrawGBLine( gx1, gy1, gz1, gx2, gy2, gz2, kBlue, 1 ); } } // Ask(); } } void AliHLTTPCCADisplay::DrawGBTracks(const ITSCATracks& all) { for( unsigned int i = 0; i < all.size(); ++i ) { const ITSCATrack& t = all[i]; const unsigned int NTHits = t.NHits(); ITSCAHit hitP = all.Hit(0, i); for( unsigned int iH=1; iH < NTHits; iH++) { const ITSCAHit& hit = all.Hit(iH, i); float gx0, gy0, gz0, gx1, gy1, gz1; HitToGlobal( hitP, gx0, gy0, gz0 ); HitToGlobal( hit, gx1, gy1, gz1 ); DrawGBLine( gx0, gy0, gz0, gx1, gy1, gz1, kRed, 1.5 ); hitP = hit; } } } int AliHLTTPCCADisplay::GetTrackMC( const AliHLTTPCCADisplayTmpHit *vHits, int NHits ) { // get MC label for the track const AliHLTTPCCAGBTracker &tracker = *fGB; int label = -1; double purity = 0; int *lb = new int[NHits*3]; int nla = 0; //std::cout<<"\n\nTrack hits mc: "<HitLabel( h.ID() ); if ( l.fLab[0] >= 0 ) lb[nla++] = l.fLab[0]; if ( l.fLab[1] >= 0 ) lb[nla++] = l.fLab[1]; if ( l.fLab[2] >= 0 ) lb[nla++] = l.fLab[2]; //std::cout< 0 && lb[i-1] >= 0 ) { const AliHLTTPCCAMCTrack &mc = fPerf->MCTrack( lb[i-1] ); std::cout << lb[i-1] << ": nhits=" << nh << ", pdg=" << mc.PDG() << ", Pt=" << mc.Pt() << ", P=" << mc.P() << ", par=" << mc.Par()[0] << " " << mc.Par()[1] << " " << mc.Par()[2] << " " << mc.Par()[3] << " " << mc.Par()[4] << " " << mc.Par()[5] << " " << mc.Par()[6] << std::endl; } nh = 0; if ( labcur >= 0 && lmax < lcurr ) { lmax = lcurr; labmax = labcur; } labcur = lb[i]; lcurr = 0; } lcurr++; nh++; } if ( 0 && nla - 1 > 0 && lb[nla-1] >= 0 ) { const AliHLTTPCCAMCTrack &mc = fPerf->MCTrack( lb[nla-1] ); std::cout << lb[nla-1] << ": nhits=" << nh << ", pdg=" << mc.PDG() << ", Pt=" << mc.Pt() << ", P=" << mc.P() << ", par=" << mc.Par()[0] << " " << mc.Par()[1] << " " << mc.Par()[2] << " " << mc.Par()[3] << " " << mc.Par()[4] << " " << mc.Par()[5] << " " << mc.Par()[6] << std::endl; } if ( labcur >= 0 && lmax < lcurr ) { lmax = lcurr; labmax = labcur; } lmax = 0; for ( int ihit = 0; ihit < NHits; ihit++ ) { const AliHLTTPCCAGBHit &h = tracker.Hits()[vHits[ihit].ID()]; const AliHLTTPCCAPerformance::AliHLTTPCCAHitLabel &l = fPerf->HitLabel( h.ID() ); if ( l.fLab[0] == labmax || l.fLab[1] == labmax || l.fLab[2] == labmax ) lmax++; } label = labmax; purity = ( ( NHits > 0 ) ? double( lmax ) / double( NHits ) : 0 ); if ( lb ) delete[] lb; if ( purity < .9 ) label = -1; return label; } bool AliHLTTPCCADisplay::DrawTrack( AliHLTTPCCATrackParam t, double Alpha, const AliHLTTPCCADisplayTmpHit *vHits, int NHits, int color, Size_t width, bool pPoint ) { // // draw track // #ifndef DRAW_3D // bool drawEndPoints = 1; // #else const bool drawEndPoints = 0; // #endif // DRAW_3D if ( NHits < 2 ) return 0; const AliHLTTPCCAGBTracker &tracker = *fGB; if ( width < 0 ) width = 2; if ( fDrawOnlyRef ) { int lab = GetTrackMC( vHits, NHits ); if ( lab < 0 ) return 0; const AliHLTTPCCAMCTrack &mc = fPerf->MCTrack( lab ); if ( mc.P() < 1 ) return 0; } if ( color < 0 ) { //color = GetColorZ( (vz[0]+vz[mHits-1])/2. ); //color = GetColorK(t.Kappa()); int lab = GetTrackMC( vHits, NHits ); color = GetColor( lab + 1 ); if ( lab >= 0 ) { const AliHLTTPCCAMCTrack &mc = fPerf->MCTrack( lab ); if ( mc.P() >= PParameters::RefThreshold ) color = kRed; } } if ( t.SinPhi() > .999 ) t.SetSinPhi( .999 ); else if ( t.SinPhi() < -.999 ) t.SetSinPhi( -.999 ); // int iSlice = fSlice->Param().ISlice(); //sort(vHits, vHits + NHits, AliHLTTPCCADisplayTmpHit::CompareHitZ ); vector vx(NHits), vy(NHits), vz(NHits); int mHits = 0; //int oldSlice = -1; double alpha = Alpha; AliHLTTPCCATrackParam tt = t; for ( int iHit = 0; iHit < NHits; iHit++ ) { const AliHLTTPCCAGBHit &h = tracker.Hits()[vHits[iHit].ID()]; double hCos = TMath::Cos( alpha ); double hSin = TMath::Sin( alpha ); double x0 = h.X(), y0 = h.Y(), z1 = h.Z(); double x1 = x0 * hCos + y0 * hSin; double y1 = y0 * hCos - x0 * hSin; { double dx = x1 - tt.X(); double dy = y1 - tt.Y(); if ( dx*dx + dy*dy > 1. ) { double dalpha = TMath::ATan2( dy, dx ); if ( tt.Rotate( dalpha ) ) { alpha += dalpha; hCos = TMath::Cos( alpha ); hSin = TMath::Sin( alpha ); x1 = x0 * hCos + y0 * hSin; y1 = y0 * hCos - x0 * hSin; } } } bool ok; vx[mHits] = x1; vy[mHits] = y1; vz[mHits] = z1; mHits++; } if ( pPoint ) { double x1 = t.X(), y1 = t.Y(), z1 = t.Z(); double dx = x1 - vx[0]; double dy = y1 - vy[0]; //std::cout< 0; i-- ) { vx[i] = vx[i-1]; vy[i] = vy[i-1]; vz[i] = vz[i-1]; } vx[0] = x1; vy[0] = y1; vz[0] = z1; mHits++; } } #ifdef DRAW_3D const float zoom = 0.6; const float z_zoom = 1.2; const float z0_zoom = 1000.; for ( int i = mHits - 1; i >= 0; i-- ) { TVector3 v(vx[i], -vz[i], vy[i]); v.RotateX(TMath::Pi()/70); v.RotateZ(TMath::Pi()/12); vx[i] = v.X()*zoom; vy[i] = v.Z()*zoom; vz[i] = -v.Y()*zoom; vx[i] *= (z0_zoom-vz[i])/z0_zoom * z_zoom; vy[i] *= (z0_zoom-vz[i])/z0_zoom * z_zoom; } #endif // DRAW_3D fLine.SetLineColor( color ); fLine.SetLineWidth( width ); fArc.SetFillStyle( 0 ); fArc.SetLineColor( color ); fArc.SetLineWidth( width ); TPolyLine pl; pl.SetLineColor( color ); pl.SetLineWidth( width ); TPolyLine plZ; plZ.SetLineColor( color ); plZ.SetLineWidth( width ); fMarker.SetMarkerSize( width / 2. ); fMarker.SetMarkerColor( color ); fYX->cd(); pl.DrawPolyLine( mHits, &vx[0], &vy[0] ); if (drawEndPoints) { fMarker.DrawMarker( vx[0], vy[0] ); fMarker.DrawMarker( vx[mHits-1], vy[mHits-1] ); } fZX->cd(); plZ.DrawPolyLine( mHits, &vz[0], &vy[0] ); if (drawEndPoints) { fMarker.DrawMarker( vz[0], vy[0] ); fMarker.DrawMarker( vz[mHits-1], vy[mHits-1] ); } fLine.SetLineWidth( 1 ); return 1; } void AliHLTTPCCADisplay::DrawHelix(float p0, float c, float z, float zStart, float z0, float xc, float yc, float r, float b, int color, Size_t width) { fLine.SetLineColor(color); fLine.SetLineWidth(width); // draw slice track float x,y,p; p = p0 + c*(zStart-z0)/b; y = yc + r*sin(p); x = xc + c*r*cos(p); float zPrev = zStart; float xPrev = x; float yPrev = y; float zEnd = z; for(int i=1; i<100; i++) { z = zStart + (zEnd-zStart)/100*i; p = p0 + c*(z-z0)/b; y = yc + r*sin(p); x = xc + c*r*cos(p); fYX->cd(); fLine.DrawLine( x, y, xPrev, yPrev); fZX->cd(); fLine.DrawLine( z, y, zPrev, yPrev); xPrev = x; yPrev = y; zPrev = z; } } void AliHLTTPCCADisplay::DrawGBTrack( int itr, int color, int width ) { // draw global track const AliHLTTPCCAGBTracker &tracker = *fGB; const AliHLTTPCCAGBTrack &track = tracker.Track( itr ); if ( track.NHits() < 2 ) return; vector vHits( track.NHits() ); for ( int ih = 0; ih < track.NHits(); ih++ ) { const int i = tracker.TrackHit( track.FirstHitRef() + ih ); const AliHLTTPCCAGBHit &h = tracker.Hit( i ); vHits[ih].SetID( i ); vHits[ih].SetS( 0 ); vHits[ih].SetZ( h.Z() ); } DrawTrack( track.Param(), track.Param().Angle(), &(vHits[0]), track.NHits(), color, width ); } void AliHLTTPCCADisplay::DrawRecoTrack( int itr, int color, int width ) { const AliHLTTPCCAGBTracker &tracker = *fGB; const AliHLTTPCCAGBTrack &track = tracker.Track( itr ); if ( track.NHits() < 2 ) return; AliHLTTPCCAGBHit hLast = tracker.Hit( tracker.TrackHit( track.FirstHitRef() ) ); for ( int ih = 1; ih < track.NHits(); ih++ ) { const int i = tracker.TrackHit( track.FirstHitRef() + ih ); const AliHLTTPCCAGBHit& h = tracker.Hit( i ); DrawGBLine( hLast.X(), hLast.Y(), hLast.Z(), h.X(), h.Y(), h.Z(), color, width ); hLast = h; } } void AliHLTTPCCADisplay::DrawMCTrack( int itr, int color, int width ) { AliHLTTPCCAPerformance& perf = AliHLTTPCCAPerformance::Instance(); const AliHLTResizableArray& mcTs = *perf.GetMCTracks(); const AliHLTResizableArray& mcPs = *perf.GetMCPoints(); const AliHLTTPCCAMCTrack &track = mcTs[itr]; if ( track.NMCPoints() < 2 ) return; AliHLTTPCCALocalMCPoint mcPLast = mcPs[ track.FirstMCPointID() ]; for ( int ih = 1; ih < track.NMCPoints(); ih++ ) { const AliHLTTPCCALocalMCPoint& mcP = mcPs[ track.FirstMCPointID() + ih ]; DrawGBLine( mcPLast.X(), mcPLast.Y(), mcPLast.Z(), mcP.X(), mcP.Y(), mcP.Z(), color, width ); mcPLast = mcP; } } void AliHLTTPCCADisplay::DrawGBTrackFast( const AliHLTTPCCAGBTracker &tracker, int itr, int color ) { // draw global track AliHLTTPCCAGBTrack &track = tracker.Tracks()[itr]; if ( track.NHits() < 2 ) return; int width = 1; AliHLTTPCCADisplayTmpHit *vHits = new AliHLTTPCCADisplayTmpHit[track.NHits()]; AliHLTTPCCATrackParam t = track.Param(); for ( int ih = 0; ih < track.NHits(); ih++ ) { int i = tracker.TrackHits()[ track.FirstHitRef() + ih]; const AliHLTTPCCAGBHit *h = &( tracker.Hits()[i] ); vHits[ih].SetID( i ); vHits[ih].SetS( 0 ); vHits[ih].SetZ( h->Z() ); } sort( vHits, vHits + track.NHits(), AliHLTTPCCADisplayTmpHit::CompareHitZ ); int colorY = color; { const AliHLTTPCCAGBHit &h1 = tracker.Hits()[ vHits[0].ID()]; const AliHLTTPCCAGBHit &h2 = tracker.Hits()[ vHits[track.NHits()-1].ID()]; if ( color < 0 ) color = GetColorZ( ( h1.Z() + h2.Z() ) / 2. ); double gy1 = h1.Y(), gy2 = h2.Y(); if ( colorY < 0 ) colorY = GetColorY( ( gy1 + gy2 ) / 2. ); color = colorY = GetColorK( t.GetQPt() ); } fMarker.SetMarkerColor( color );//kBlue); fMarker.SetMarkerSize( 1. ); fLine.SetLineColor( color ); fLine.SetLineWidth( width ); fArc.SetFillStyle( 0 ); fArc.SetLineColor( color ); fArc.SetLineWidth( width ); TPolyLine pl; pl.SetLineColor( colorY ); pl.SetLineWidth( width ); // YX { const AliHLTTPCCAGBHit &h1 = tracker.Hits()[vHits[0].ID()]; const AliHLTTPCCAGBHit &h2 = tracker.Hits()[vHits[track.NHits()-1].ID()]; float x1, y1, z1, x2, y2, z2; double vx1, vy1, vx2, vy2; t.GetDCAPoint( h1.X(), h1.Y(), h1.Z(), x1, y1, z1, tracker.GetParameters().Bz() ); vx1 = x1; vy1 = y1; t.GetDCAPoint( h2.X(), h2.Y(), h2.Z(), x2, y2, z2, tracker.GetParameters().Bz() ); vx2 = x2; vy2 = y2; double x0 = t.GetX(); double y0 = t.GetY(); double sinPhi = t.GetSinPhi(); double k = t.GetKappa( tracker.GetParameters().Bz() ); double ex = t.GetCosPhi(); double ey = sinPhi; if ( TMath::Abs( k ) > 1.e-4 ) { fYX->cd(); double r = 1 / TMath::Abs( k ); double xc = x0 - ey * ( 1 / k ); double yc = y0 + ex * ( 1 / k ); double vx = xc, vy = yc; double a1 = TMath::ATan2( vy1 - vy, vx1 - vx ) / TMath::Pi() * 180.; double a2 = TMath::ATan2( vy2 - vy, vx2 - vx ) / TMath::Pi() * 180.; if ( a1 < 0 ) a1 += 360; if ( a2 < 0 ) a2 += 360; if ( a2 < a1 ) a2 += 360; double da = TMath::Abs( a2 - a1 ); if ( da > 360 ) da -= 360; if ( da > 180 ) { da = a1; a1 = a2; a2 = da; if ( a2 < a1 ) a2 += 360; } fArc.DrawArc( vx, vy, r, a1, a2, "only" ); //fArc.DrawArc(vx,vy,r, 0,360,"only"); } else { fYX->cd(); fLine.DrawLine( vx1, vy1, vx2, vy2 ); } } // ZX AliHLTResizableArray py( track.NHits() ), pz( track.NHits() ); for ( int iHit = 0; iHit < track.NHits(); iHit++ ) { const AliHLTTPCCAGBHit &h1 = tracker.Hits()[vHits[iHit].ID()]; float x1, y1, z1; double vx1, vy1; t.GetDCAPoint( h1.X(), h1.Y(), h1.Z(), x1, y1, z1, tracker.GetParameters().Bz() ); vx1 = x1; vy1 = y1; py[iHit] = vy1; pz[iHit] = z1; } fZX->cd(); pl.DrawPolyLine( track.NHits(), pz.Data(), py.Data() ); fLine.SetLineWidth( 1 ); delete[] vHits; } void AliHLTTPCCADisplay::DrawTrackParam( TrackParam t, int color ) { const AliHLTTPCCAGBTracker &tracker = *fGB; for ( int i = 0; i < 100; ++i ) { double x = t.GetX(); double y = t.GetY(); double sinPhi = t.GetSinPhi(); double z = t.GetZ(); double dzds = t.GetDzDs(); double ex = t.GetCosPhi(); double ey = sinPhi; fLine.SetLineWidth( 1 ); fLine.SetLineColor( color ); double vx = x, vy = y, vex = ex, vey = ey; double d = CAMath::RSqrt( vex * vex + vey * vey ); vex *= d; vey *= d; fYX->cd(); fLine.DrawLine( vx, vy, vx + vex*4, vy + vey*4 ); fZX->cd(); fLine.DrawLine( z, vy, z + dzds*4, vy + vey*4 ); t.TransportToX( x + ex * CAMath::RSqrt( ex * ex + ey * ey ), tracker.GetParameters().cBz() ); } } void AliHLTTPCCADisplay::SaveCanvasToFile( TString fileName){ fCanvas->SaveAs(fileName); } void AliHLTTPCCADisplay::SetTPC( const AliHLTTPCCAParam& tpcParam){ // iklm UNUSED_PARAM1(tpcParam); // TODO fZMin = -60; fZMax = 60; fYMin = -250; // s potolka? fYMax = 250; fRInnerMin = //tpcParam.RMin(); fRInnerMax = 123.; // approximate TODO: from file! fROuterMin = 123.; fROuterMax = 50;//tpcParam.RMax(); }