LCOV - code coverage report
Current view: top level - HLT/BASE/util - AliHLTGlobalBarrelTrack.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 315 0.3 %
Date: 2016-06-14 17:26:59 Functions: 1 29 3.4 %

          Line data    Source code
       1             : // $Id$
       2             : 
       3             : //**************************************************************************
       4             : //* This file is property of and copyright by the                          * 
       5             : //* ALICE Experiment at CERN, All rights reserved.                         *
       6             : //*                                                                        *
       7             : //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
       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             : /// @file   AliHLTGlobalBarrelTrack.cxx
      20             : /// @author Matthias Richter
      21             : /// @date   2009-06-24
      22             : /// @brief  An AliKalmanTrack implementation for global HLT barrel tracks.
      23             : ///
      24             : 
      25             : #include <cassert>
      26             : #include <memory>
      27             : #include <iostream>
      28             : #include "AliHLTGlobalBarrelTrack.h"
      29             : #include "AliHLTSpacePointContainer.h"
      30             : #include "AliHLTTrackGeometry.h"
      31             : #include "AliHLTMisc.h"
      32             : #include "TClonesArray.h"
      33             : #include "TFile.h"
      34             : #include "TArrayC.h"
      35             : #include "TMath.h"
      36             : #include "TMarker.h"
      37             : #include "TArc.h"
      38             : 
      39             : using namespace std;
      40             : 
      41             : /** ROOT macro for the implementation of ROOT specific class methods */
      42           8 : ClassImp(AliHLTGlobalBarrelTrack)
      43             : 
      44             : AliHLTGlobalBarrelTrack::AliHLTGlobalBarrelTrack()
      45           0 :   : AliKalmanTrack()
      46           0 :   , fPoints()
      47           0 :   , fLastX(0.0)
      48           0 :   , fLastY(0.0)
      49           0 :   , fTrackID(-1)
      50           0 :   , fHelixRadius(0.0)
      51           0 :   , fHelixCenterX(0.0)
      52           0 :   , fHelixCenterY(0.0)
      53           0 :   , fSpacePoints(NULL)
      54           0 :   , fTrackPoints(NULL)
      55           0 : {
      56             :   //  constructor
      57             :   //
      58             :   //  An AliKalmanTrack implementation for global HLT barrel tracks.
      59             :   //
      60             :   //
      61           0 : }
      62             : 
      63             : AliHLTGlobalBarrelTrack::AliHLTGlobalBarrelTrack(const AliHLTGlobalBarrelTrack& t)
      64           0 :   : AliKalmanTrack(t)
      65           0 :   , fPoints()
      66           0 :   , fLastX(t.GetLastPointX())
      67           0 :   , fLastY(t.GetLastPointY())
      68           0 :   , fTrackID(t.TrackID())
      69           0 :   , fHelixRadius(t.fHelixRadius)
      70           0 :   , fHelixCenterX(t.fHelixCenterX)
      71           0 :   , fHelixCenterY(t.fHelixCenterY)
      72           0 :   , fSpacePoints(NULL)
      73           0 :   , fTrackPoints(NULL)
      74           0 : {
      75             :   // copy constructor
      76           0 :   fPoints.assign(t.fPoints.begin(), t.fPoints.end());
      77           0 : }
      78             : 
      79             : AliHLTGlobalBarrelTrack::AliHLTGlobalBarrelTrack(const AliHLTExternalTrackParam& p )
      80           0 :   : AliKalmanTrack()
      81           0 :   , fPoints()
      82           0 :   , fLastX(p.fLastX)
      83           0 :   , fLastY(p.fLastY)
      84           0 :   , fTrackID(p.fTrackID)
      85           0 :   , fHelixRadius(0.0)
      86           0 :   , fHelixCenterX(0.0)
      87           0 :   , fHelixCenterY(0.0)
      88           0 :   , fSpacePoints(NULL)
      89           0 :   , fTrackPoints(NULL)
      90           0 : {
      91             :   // constructor from AliHLTExternalTrackParam
      92             : 
      93             :   // the 5 track parameters are named in the AliHLTExternalTrackParam
      94             :   // while AliExternalTrackParam just uses an array[5]
      95             :   // the members have the same order, fY is the first one
      96           0 :   Set(p.fX, p.fAlpha, &p.fY, p.fC);
      97           0 :   SetPoints(p.fPointIDs, p.fNPoints);
      98           0 :   SetNumberOfClusters(p.fNPoints);
      99             :   //SetIntegratedLength(GetPathLengthTo( GetLastPointX(), b);
     100           0 : }
     101             : 
     102             : AliHLTGlobalBarrelTrack::AliHLTGlobalBarrelTrack(const AliExternalTrackParam& p )
     103           0 :   : AliKalmanTrack()
     104           0 :   , fPoints()
     105           0 :   , fLastX(0)
     106           0 :   , fLastY(0)
     107           0 :   , fTrackID(0)
     108           0 :   , fHelixRadius(0.0)
     109           0 :   , fHelixCenterX(0.0)
     110           0 :   , fHelixCenterY(0.0)
     111           0 :   , fSpacePoints(NULL)
     112           0 :   , fTrackPoints(NULL)
     113           0 : {
     114             :   // constructor from AliExternalTrackParam
     115           0 :   *(dynamic_cast<AliExternalTrackParam*>(this))=p;
     116           0 : }
     117             : 
     118             : AliHLTGlobalBarrelTrack::~AliHLTGlobalBarrelTrack()
     119           0 : {
     120             :   // destructor
     121           0 : }
     122             : 
     123             : 
     124             : Double_t AliHLTGlobalBarrelTrack::GetPathLengthTo( Double_t x, Double_t b ) const
     125             : {
     126             :   // calculate the trajectory length for dx step
     127             :     
     128           0 :   Double_t dx = x - GetX();
     129           0 :   Double_t ey = GetSnp();
     130           0 :   if( TMath::Abs( ey )>=kAlmost1 ) return 0;
     131             : 
     132           0 :   Double_t ex = TMath::Sqrt(1-ey*ey);
     133           0 :   Double_t k  = GetC(b);
     134             : 
     135           0 :   Double_t ey1 = k * dx + ey;
     136             : 
     137             :   // check for intersection with X=x
     138             : 
     139           0 :   if ( TMath::Abs( ey1 ) >= kAlmost1  ) return 0;
     140             : 
     141           0 :   Double_t ex1 = TMath::Sqrt(1-ey1*ey1);
     142             : 
     143           0 :   Double_t ss = ey + ey1;
     144           0 :   Double_t cc = ex + ex1;
     145             : 
     146           0 :   if ( TMath::Abs( cc ) < 1.e-4  ) return 0;
     147             : 
     148           0 :   Double_t tg = ss / cc; 
     149           0 :   Double_t dl = dx * TMath::Sqrt( 1 + tg * tg );
     150           0 :   Double_t dSin = dl * k / 2;
     151           0 :   if ( dSin > 1 ) dSin = 1;
     152           0 :   if ( dSin < -1 ) dSin = -1;
     153           0 :   Double_t dS = ( TMath::Abs( k ) > 1.e-4 )  ? ( 2 * TMath::ASin( dSin ) / k ) : dl;
     154             : 
     155           0 :   return dS*TMath::Sqrt(1 + GetTgl()*GetTgl() );
     156           0 : }
     157             : 
     158             : 
     159             : 
     160             : 
     161             : int AliHLTGlobalBarrelTrack::ConvertTrackDataArray(const AliHLTTracksData* pTracks, unsigned sizeInByte, vector<AliHLTGlobalBarrelTrack> &tgtArray )
     162             : {
     163             :   // convert a binary data block to array of tracks
     164             :   int iResult=0;
     165           0 :   if (!pTracks || sizeInByte<sizeof(AliHLTTracksData) || pTracks->fCount==0) return 0;
     166             : 
     167           0 :   const AliHLTUInt8_t* pEnd=reinterpret_cast<const AliHLTUInt8_t*>(pTracks);
     168           0 :   pEnd+=sizeInByte;
     169             : 
     170           0 :   tgtArray.resize(pTracks->fCount + tgtArray.size());
     171           0 :   const AliHLTUInt8_t* pCurrent=reinterpret_cast<const AliHLTUInt8_t*>(pTracks->fTracklets);
     172           0 :   for (unsigned i=0; i<pTracks->fCount; i++) {
     173           0 :     if (pCurrent+sizeof(AliHLTExternalTrackParam)>pEnd) {
     174           0 :       iResult=-EINVAL; break;
     175             :     }
     176           0 :     const AliHLTExternalTrackParam* track=reinterpret_cast<const AliHLTExternalTrackParam*>(pCurrent);
     177           0 :     if (pCurrent+sizeof(AliHLTExternalTrackParam)+track->fNPoints*sizeof(UInt_t)>pEnd) {
     178           0 :       iResult=-EINVAL; break;
     179             :     }
     180           0 :     tgtArray[i]=*track;
     181           0 :     pCurrent+=sizeof(AliHLTExternalTrackParam)+track->fNPoints*sizeof(UInt_t);
     182           0 :   }
     183           0 :   if (iResult<0) tgtArray.clear();
     184           0 :   else iResult=tgtArray.size();
     185             :   return iResult;
     186           0 : }
     187             : 
     188             : UInt_t AliHLTGlobalBarrelTrack::GetNumberOfPoints() const
     189             : {
     190             :   // get number of assigned points
     191           0 :   return fPoints.size();
     192             : }
     193             : 
     194             : const UInt_t* AliHLTGlobalBarrelTrack::GetPoints() const
     195             : {
     196             :   // get array of points
     197           0 :   if (fPoints.size()==0) return NULL;
     198           0 :   return &fPoints[0];
     199           0 : }
     200             : 
     201             : int AliHLTGlobalBarrelTrack::SetPoints(const UInt_t* pArray, UInt_t arraySize)
     202             : {
     203             :   // copy the array of points to internal memory
     204           0 :   if (!pArray || arraySize==0) return 0;
     205           0 :   fPoints.resize(arraySize);
     206           0 :   for (unsigned i=0; i<arraySize; i++) fPoints[i]=pArray[i];
     207           0 :   return fPoints.size();
     208           0 : }
     209             : 
     210             : int AliHLTGlobalBarrelTrack::CalculateHelixParams()
     211             : {
     212             :   // calculate radius and center of the helix
     213             :   // using the global magnetic field
     214           0 :   return CalculateHelixParams(AliHLTMisc::Instance().GetBz());
     215             : }
     216             : 
     217             : int AliHLTGlobalBarrelTrack::CalculateHelixParams(float bfield)
     218             : {
     219             :   // calculate radius and center of the helix
     220           0 :   if (TMath::Abs(bfield)<kAlmost0) {
     221             :     // no magnetic field -> straight lines
     222           0 :     fHelixRadius=kVeryBig;
     223           0 :     fHelixCenterX=kVeryBig;
     224           0 :     fHelixCenterY=kVeryBig;
     225           0 :   } else {
     226           0 :     fHelixRadius = GetSignedPt()/(-kB2C*bfield);
     227           0 :     Double_t trackPhi = Phi()-GetAlpha();
     228             : 
     229             :     //cout << "Helix: phi=" << trackPhi << " x=" << GetX() << " y=" << GetY() << endl;
     230           0 :     fHelixCenterX = GetX() + fHelixRadius *  sin(trackPhi);
     231           0 :     fHelixCenterY = GetY() - fHelixRadius *  cos(trackPhi);
     232             :     //cout << "Helix: center" << " x=" << fHelixCenterX << " y=" << fHelixCenterY << endl;
     233             :   }
     234           0 :   return 0;
     235             : }
     236             : 
     237             : int AliHLTGlobalBarrelTrack::CalculateCrossingPoint(float xPlane, float alphaPlane, float& y, float& z)
     238             : {
     239             :   // calculate crossing point of helix with a plane in yz
     240             :   // in the local coordinates of the plane
     241             :   int iResult=0;
     242           0 :   if (TMath::Abs(fHelixRadius)<kAlmost0 &&
     243           0 :       (iResult=CalculateHelixParams())<0) {
     244           0 :     return iResult;
     245             :   }
     246             : 
     247           0 :   if (TMath::Abs(fHelixRadius)>=kVeryBig) {
     248             :     // no magnetic field -> straight lines
     249             :   } else {
     250             :     // rotate helix center to local coordinates of the plane reference frame
     251           0 :     float cosa=TMath::Cos(alphaPlane-GetAlpha());
     252           0 :     float sina=TMath::Sin(alphaPlane-GetAlpha());
     253           0 :     float cx= fHelixCenterX * cosa + fHelixCenterY * sina;
     254           0 :     float cy=-fHelixCenterX * sina + fHelixCenterY * cosa;
     255             : 
     256             :     // crossing point of helix with plane
     257           0 :     Double_t aa = (cx - xPlane)*(cx - xPlane);
     258           0 :     Double_t r2 = fHelixRadius*fHelixRadius;
     259           0 :     if(aa > r2) // no crossing
     260           0 :       return 0;
     261             : 
     262           0 :     Double_t aa2 = sqrt(r2 - aa);
     263           0 :     Double_t y1 = cy + aa2;
     264           0 :     Double_t y2 = cy - aa2;
     265           0 :     y = y1;
     266           0 :     if(TMath::Abs(y2) < TMath::Abs(y1)) y = y2;
     267             :   
     268             :     // calculate the arc length between (x,y) and (x0,y0) with radius (cx,cy)
     269             :     // reference point is (x0,y0) rotated by the diffence of the plane angle and
     270             :     // the track reference frame angle alpha
     271             :     // 1) angle of (x,y)
     272           0 :     Double_t angle1 = atan2((y - cy),(xPlane - cx));
     273           0 :     if(angle1 < 0) angle1 += TMath::TwoPi();
     274             : 
     275             :     // 2) angle of (x0,y0)
     276           0 :     float x0= GetX() * cosa + GetY() * sina;
     277           0 :     float y0=-GetX() * sina + GetY() * cosa;
     278           0 :     Double_t angle2 = atan2((y0 - cy),(x0 - cx));
     279           0 :     if(angle2 < 0) angle2 += TMath::TwoPi();
     280             : 
     281             :     // 3) angle between (x,y) and (x0,y0)
     282           0 :     Double_t diffangle = angle1 - angle2;
     283           0 :     diffangle = fmod(diffangle,TMath::TwoPi());
     284             : 
     285             :     // 4) arc length
     286           0 :     Double_t arclength = TMath::Abs(diffangle*fHelixRadius);
     287             : 
     288             :     // 5) direction depending on whether going outwards or inwards
     289           0 :     int direction=GetX()>xPlane?-1:1;
     290           0 :     z = GetZ() + direction*arclength*GetTgl();
     291             : 
     292             :     //cout << "x=" << xPlane << " y=" << y << " cx=" << cx << " cy=" << cy << " a1=" << angle1 << " a2=" << angle2 << " diffa=" << diffangle << " s=" << arclength << " z=" << z << endl;
     293           0 :   }
     294           0 :   return 1;
     295           0 : }
     296             : 
     297             : void AliHLTGlobalBarrelTrack::Print(Option_t* option) const
     298             : {
     299             :   // see header file for class documentation
     300           0 :   cout << "********* Track Id: " << fTrackID << " *******************" << endl;
     301           0 :   AliExternalTrackParam::Print(option);
     302             : //   cout << "  Alpha "     << GetAlpha();
     303             : //   cout << "  X "         << GetX();
     304             : //   cout << "  Y "         << GetY();
     305             : //   cout << "  Z "         << GetZ() << endl;
     306             : //   cout << "  Snp "       << GetSnp();
     307             : //   cout << "  Tgl "       << GetTgl();
     308             : //   cout << "  Signed1Pt " << GetSigned1Pt() << endl;
     309           0 : }
     310             : 
     311             : void AliHLTGlobalBarrelTrack::Draw(Option_t *option)
     312             : {
     313             :   /// Inherited from TObject, draw the track
     314             :   float scale=250;
     315           0 :   float center[2]={0.5,0.5};
     316             : 
     317           0 :   if (TMath::Abs(fHelixRadius)<kAlmost0 &&
     318           0 :       (CalculateHelixParams())<0) {
     319           0 :     return;
     320             :   }
     321             : 
     322           0 :   TString strOption(option);
     323           0 :   if (strOption.IsNull()) strOption="spacepoints trackarc";
     324           0 :   std::auto_ptr<TObjArray> tokens(strOption.Tokenize(" "));
     325           0 :   if (!tokens.get()) return;
     326           0 :   for (int i=0; i<tokens->GetEntriesFast(); i++) {
     327           0 :     if (!tokens->At(i)) continue;
     328             :     const char* key="";
     329           0 :     TString arg=tokens->At(i)->GetName();
     330             : 
     331             :     key="scale=";
     332           0 :     if (arg.BeginsWith(key)) {
     333           0 :       arg.ReplaceAll(key, "");
     334           0 :       scale=arg.Atof();
     335           0 :       continue;
     336             :     }
     337             :     key="centerx=";
     338           0 :     if (arg.BeginsWith(key)) {
     339           0 :       arg.ReplaceAll(key, "");
     340           0 :       center[0]=arg.Atof();
     341           0 :       continue;
     342             :     }
     343             :     key="centery=";
     344           0 :     if (arg.BeginsWith(key)) {
     345           0 :       arg.ReplaceAll(key, "");
     346           0 :       center[1]=arg.Atof();
     347           0 :       continue;
     348             :     }
     349             :     key="spacepoints";
     350           0 :     if (arg.CompareTo(key)==0) {
     351           0 :       if (fSpacePoints) DrawProjXYSpacePoints(option, fSpacePoints, scale, center);
     352           0 :       continue;
     353             :     }
     354             :     key="trackarc";
     355           0 :     if (arg.CompareTo(key)==0) {
     356           0 :       DrawProjXYTrack(option, scale, center);
     357           0 :       continue;
     358             :     }
     359           0 :   }
     360           0 : }
     361             : 
     362             : int AliHLTGlobalBarrelTrack::DrawProjXYSpacePoints(Option_t */*option*/, const AliHLTSpacePointContainer* spacePoints, const float scale, float center[2])
     363             : {
     364             :   /// draw space points
     365             :   int markerColor=3;
     366             : 
     367           0 :   if (!spacePoints) return -EINVAL;
     368             : 
     369           0 :   const UInt_t* pointids=GetPoints();
     370           0 :   for (unsigned i=0; i<GetNumberOfPoints() && pointids; i++) {
     371           0 :     float clusterphi=spacePoints->GetPhi(pointids[i]);
     372           0 :     float cosphi=TMath::Cos(clusterphi);
     373           0 :     float sinphi=TMath::Sin(clusterphi);
     374           0 :     float clusterx=spacePoints->GetX(pointids[i]);
     375           0 :     float clustery=spacePoints->GetY(pointids[i]);
     376             :     // rotate
     377           0 :     float pointx= clusterx*sinphi + clustery*cosphi;
     378           0 :     float pointy=-clusterx*cosphi + clustery*sinphi;
     379             : 
     380             :     // FIXME: cleanup of marker objects
     381           0 :     TMarker* m=new TMarker(pointx/(2*scale)+center[0], pointy/(2*scale)+center[1], 3);
     382           0 :     m->SetMarkerColor(markerColor);
     383           0 :     m->Draw("same");
     384             :   }
     385             :   return 0;
     386           0 : }
     387             : 
     388             : // FIXME: make this a general geometry definition
     389             : // through an abstract class interface
     390             : const Double_t gkTPCX[159] = {
     391             :   85.195,
     392             :   85.945,
     393             :   86.695,
     394             :   87.445,
     395             :   88.195,
     396             :   88.945,
     397             :   89.695,
     398             :   90.445,
     399             :   91.195,
     400             :   91.945,
     401             :   92.695,
     402             :   93.445,
     403             :   94.195,
     404             :   94.945,
     405             :   95.695,
     406             :   96.445,
     407             :   97.195,
     408             :   97.945,
     409             :   98.695,
     410             :   99.445,
     411             :   100.195,
     412             :   100.945,
     413             :   101.695,
     414             :   102.445,
     415             :   103.195,
     416             :   103.945,
     417             :   104.695,
     418             :   105.445,
     419             :   106.195,
     420             :   106.945,
     421             :   107.695,
     422             :   108.445,
     423             :   109.195,
     424             :   109.945,
     425             :   110.695,
     426             :   111.445,
     427             :   112.195,
     428             :   112.945,
     429             :   113.695,
     430             :   114.445,
     431             :   115.195,
     432             :   115.945,
     433             :   116.695,
     434             :   117.445,
     435             :   118.195,
     436             :   118.945,
     437             :   119.695,
     438             :   120.445,
     439             :   121.195,
     440             :   121.945,
     441             :   122.695,
     442             :   123.445,
     443             :   124.195,
     444             :   124.945,
     445             :   125.695,
     446             :   126.445,
     447             :   127.195,
     448             :   127.945,
     449             :   128.695,
     450             :   129.445,
     451             :   130.195,
     452             :   130.945,
     453             :   131.695,
     454             :   135.180,
     455             :   136.180,
     456             :   137.180,
     457             :   138.180,
     458             :   139.180,
     459             :   140.180,
     460             :   141.180,
     461             :   142.180,
     462             :   143.180,
     463             :   144.180,
     464             :   145.180,
     465             :   146.180,
     466             :   147.180,
     467             :   148.180,
     468             :   149.180,
     469             :   150.180,
     470             :   151.180,
     471             :   152.180,
     472             :   153.180,
     473             :   154.180,
     474             :   155.180,
     475             :   156.180,
     476             :   157.180,
     477             :   158.180,
     478             :   159.180,
     479             :   160.180,
     480             :   161.180,
     481             :   162.180,
     482             :   163.180,
     483             :   164.180,
     484             :   165.180,
     485             :   166.180,
     486             :   167.180,
     487             :   168.180,
     488             :   169.180,
     489             :   170.180,
     490             :   171.180,
     491             :   172.180,
     492             :   173.180,
     493             :   174.180,
     494             :   175.180,
     495             :   176.180,
     496             :   177.180,
     497             :   178.180,
     498             :   179.180,
     499             :   180.180,
     500             :   181.180,
     501             :   182.180,
     502             :   183.180,
     503             :   184.180,
     504             :   185.180,
     505             :   186.180,
     506             :   187.180,
     507             :   188.180,
     508             :   189.180,
     509             :   190.180,
     510             :   191.180,
     511             :   192.180,
     512             :   193.180,
     513             :   194.180,
     514             :   195.180,
     515             :   196.180,
     516             :   197.180,
     517             :   198.180,
     518             :   199.430,
     519             :   200.930,
     520             :   202.430,
     521             :   203.930,
     522             :   205.430,
     523             :   206.930,
     524             :   208.430,
     525             :   209.930,
     526             :   211.430,
     527             :   212.930,
     528             :   214.430,
     529             :   215.930,
     530             :   217.430,
     531             :   218.930,
     532             :   220.430,
     533             :   221.930,
     534             :   223.430,
     535             :   224.930,
     536             :   226.430,
     537             :   227.930,
     538             :   229.430,
     539             :   230.930,
     540             :   232.430,
     541             :   233.930,
     542             :   235.430,
     543             :   236.930,
     544             :   238.430,
     545             :   239.930,
     546             :   241.430,
     547             :   242.930,
     548             :   244.430,
     549             :   245.930
     550             : };
     551             : 
     552             : int AliHLTGlobalBarrelTrack::DrawProjXYTrack(Option_t *option, const float scale, float center[2])
     553             : {
     554             :   /// draw track
     555             :   bool bDrawArc=false; // draw TArc
     556             :   //bool bNoTrackPoints=false; // don't draw track points
     557           0 :   TString strOption(option);
     558           0 :   if (strOption.IsNull()) strOption="spacepoints trackarc";
     559           0 :   std::auto_ptr<TObjArray> tokens(strOption.Tokenize(" "));
     560           0 :   if (!tokens.get()) return 0;
     561           0 :   for (int i=0; i<tokens->GetEntriesFast(); i++) {
     562           0 :     if (!tokens->At(i)) continue;
     563             :     const char* key="";
     564           0 :     TString arg=tokens->At(i)->GetName();
     565             : 
     566             :     key="drawarc";
     567           0 :     if (arg.BeginsWith(key)) {
     568             :       bDrawArc=true;
     569           0 :       continue;
     570             :     }
     571             :     key="notrackpoints";
     572           0 :     if (arg.BeginsWith(key)) {
     573             :       //bNoTrackPoints=true;
     574           0 :       continue;
     575             :     }
     576           0 :   }
     577             : 
     578           0 :   float cosa=TMath::Cos(GetAlpha());
     579           0 :   float sina=TMath::Sin(GetAlpha());
     580             : 
     581             :   // first point
     582           0 :   float firstpoint[2];
     583           0 :   firstpoint[0]= GetX()*sina + GetY()*cosa;
     584           0 :   firstpoint[1]=-GetX()*cosa + GetY()*sina;
     585             :   {
     586             :     //cout << " first point alpha=" << GetAlpha() << " x: " << firstpoint[0] << " y: " << firstpoint[1] << endl;
     587             :     // FIXME: cleanup of marker objects
     588           0 :     TMarker* m=new TMarker(firstpoint[0]/(2*scale)+center[0], firstpoint[1]/(2*scale)+center[1], 29);
     589           0 :     m->SetMarkerSize(2);
     590           0 :     m->SetMarkerColor(2);
     591           0 :     m->Draw("same");
     592             :   }
     593             : 
     594             :   // draw points in step width and remember the last point
     595           0 :   float lastpoint[2]={0.0, 0.0};
     596             :   int firstpadrow=0;
     597           0 :   for (; firstpadrow<159 && gkTPCX[firstpadrow]<GetX(); firstpadrow++);
     598           0 :   DrawProjXYTrackPoints(option, scale, center, firstpadrow, -1, firstpoint);
     599           0 :   DrawProjXYTrackPoints(option, scale, center, firstpadrow, 1, lastpoint);
     600             : 
     601           0 :   if (bDrawArc) {
     602           0 :     if (TMath::Abs(fHelixRadius)>=kVeryBig) {
     603             :       // no magnetic field -> straight lines
     604             :     } else {
     605             :       // rotate helix center to local coordinates of the plane reference frame
     606           0 :       float cx= fHelixCenterX * sina + fHelixCenterY * cosa;
     607           0 :       float cy=-fHelixCenterX * cosa + fHelixCenterY * sina;
     608             : 
     609           0 :       float diffx=cx-firstpoint[0];
     610           0 :       float diffy=cy-firstpoint[1];
     611             :       float phimin=0.0;
     612           0 :       float phimax=2*TMath::Pi();
     613           0 :       if (TMath::Abs(diffx)<kAlmost0) {
     614           0 :         phimin=TMath::Pi()/2;
     615           0 :       } else {
     616           0 :         phimin=TMath::ATan(diffy/diffx);
     617             :       }
     618           0 :       if (diffx>0) phimin+=TMath::Pi();
     619             : 
     620           0 :       diffx=cx-lastpoint[0];
     621           0 :       diffy=cy-lastpoint[1];
     622           0 :       if (TMath::Abs(diffx)<kAlmost0) {
     623           0 :         phimax=TMath::Pi()/2;
     624           0 :       } else {
     625           0 :         phimax=TMath::ATan(diffy/diffx);
     626             :       }
     627             :       //cout << "diffx=" << diffx << " diffy=" << diffy << " phimin=" << phimin << " phimax=" << phimax << endl;
     628           0 :       if (diffx>0) phimax+=TMath::Pi();
     629           0 :       if (phimax<0 && phimin>=0 && 
     630           0 :           phimax+TMath::TwoPi()-phimin<TMath::Pi()) phimax+=TMath::TwoPi();
     631             :       //if (phimax<0 && TMath::Abs(phimax-phimin)<TMath::Pi()) phimax+=TMath::TwoPi();
     632           0 :       if (phimax-phimin>TMath::Pi()) phimax-=TMath::TwoPi();
     633             : 
     634             :       if (0/*phimin>phimax*/) {
     635             :         float tmp=phimin;
     636             :         phimin=phimax;
     637             :         phimax=tmp;
     638             :       }
     639           0 :       phimin*=360.0/(2*TMath::Pi());
     640           0 :       phimax*=360.0/(2*TMath::Pi());
     641             :       //cout << " cx=" << cx << " cy=" << cy << " r=" << fHelixRadius << " phimin=" << phimin << " phimax=" << phimax << endl;
     642             :       // FIXME: cleanup of graphics objects
     643           0 :       TArc* tarc=new TArc(cx/(2*scale)+center[0], cy/(2*scale)+center[1], TMath::Abs(fHelixRadius)/(2*scale), phimin, phimax);
     644           0 :       tarc->SetNoEdges();
     645           0 :       tarc->SetFillStyle(0);
     646           0 :       tarc->Draw("same");
     647             :     }
     648             :   }
     649             :   return 0;
     650           0 : }
     651             : 
     652             : int AliHLTGlobalBarrelTrack::DrawProjXYTrackPoints(Option_t */*option*/, const float scale, const float center[2], int firstpadrow, int step, float point[2])
     653             : {
     654             :   // draw points in step width and return the last point
     655             :   float offsetAlpha=0.0;
     656           0 :   float cosa=TMath::Cos(GetAlpha());
     657           0 :   float sina=TMath::Sin(GetAlpha());
     658             :   int markerColor=1;
     659           0 :   for (int padrow=firstpadrow; padrow>=0 && padrow<159; padrow+=step) {
     660           0 :     float x=gkTPCX[padrow];
     661           0 :     float y=0.0;
     662           0 :     float z=0.0;
     663             : 
     664             :     int maxshift=9;
     665             :     int shift=0;
     666             :     int result=0;
     667           0 :     do {
     668           0 :       if ((result=CalculateCrossingPoint(x, GetAlpha()-offsetAlpha, y, z))<1) break;
     669           0 :       float pointAlpha=TMath::ATan(y/x);
     670           0 :       if (TMath::Abs(pointAlpha)>TMath::Pi()/18) {
     671           0 :         offsetAlpha+=(pointAlpha>0?-1:1)*TMath::Pi()/9;
     672             :         result=0;
     673           0 :         markerColor++;
     674           0 :         cosa=TMath::Cos(GetAlpha()-offsetAlpha);
     675           0 :         sina=TMath::Sin(GetAlpha()-offsetAlpha);
     676           0 :       }
     677           0 :     } while (result==0 && shift++<maxshift);
     678           0 :     if (result<1) continue;
     679           0 :     point[0]= x*sina + y*cosa;
     680           0 :     point[1]=-x*cosa + y*sina;
     681             : 
     682             :     //cout << x << " : x=" << x << " y=" << y << endl;
     683             :     // FIXME: cleanup of TMarker objects?
     684           0 :     TMarker* m=new TMarker(point[0]/(2*scale)+center[0], point[1]/(2*scale)+center[1], z>=0?2:5);
     685           0 :     m->SetMarkerColor(markerColor);
     686           0 :     m->Draw("same");
     687           0 :   }
     688           0 :   return 0;
     689           0 : }
     690             : 
     691             : void AliHLTGlobalBarrelTrack::SetTrackGeometry(AliHLTTrackGeometry* points)
     692             : {
     693             :   /// set the instance to the track points container
     694           0 :   fTrackPoints=points; 
     695           0 :   if (!fTrackPoints) return; 
     696           0 :   fTrackPoints->SetTrackId(GetID());
     697           0 : }
     698             : 
     699             : int AliHLTGlobalBarrelTrack::AssociateSpacePoints(AliHLTTrackGeometry* trackpoints, AliHLTSpacePointContainer& spacepoints) const
     700             : {
     701             :   /// associate the track space points to the calculated track points
     702             :   AliHLTTrackGeometry* instance=trackpoints;
     703           0 :   if (!instance) instance=fTrackPoints;
     704           0 :   if (!instance) return 0;
     705             : 
     706           0 :   UInt_t nofIds=GetNumberOfPoints();
     707           0 :   const UInt_t* ids=GetPoints();
     708           0 :   int result=instance->AssociateSpacePoints(ids, nofIds, spacepoints);
     709             :   return result;
     710           0 : }
     711             : 
     712             : int AliHLTGlobalBarrelTrack::ReadTracks(const char* filename, TClonesArray& tgt, AliHLTComponentDataType /*dt*/, unsigned /*specification*/)
     713             : {
     714             :   // open block from file and add to collection
     715           0 :   if (!filename) return -EINVAL;
     716             :   
     717           0 :   TString input=filename;
     718           0 :   input+="?filetype=raw";
     719           0 :   std::auto_ptr<TFile> pFile(new TFile(input));
     720           0 :   if (!pFile.get()) return -ENOMEM;
     721           0 :   if (pFile->IsZombie()) return -ENOENT;
     722             : 
     723             :   int iResult=0;
     724           0 :   pFile->Seek(0);
     725           0 :   std::auto_ptr<TArrayC> buffer(new TArrayC);
     726           0 :   if (!buffer.get()) return -ENOMEM;
     727             : 
     728           0 :   buffer->Set(pFile->GetSize());
     729           0 :   if (pFile->ReadBuffer(buffer->GetArray(), buffer->GetSize())==0) {
     730           0 :     const AliHLTTracksData* pTracks=reinterpret_cast<const AliHLTTracksData*>(buffer->GetArray());
     731           0 :     vector<AliHLTGlobalBarrelTrack> tracks;
     732           0 :     iResult=ConvertTrackDataArray(pTracks, buffer->GetSize(), tracks);
     733           0 :     if (iResult>=0) {
     734           0 :       int offset=tgt.GetEntriesFast();
     735           0 :       tgt.ExpandCreate(offset+tracks.size());
     736           0 :       for (unsigned i=0; i<tracks.size(); i++) {
     737           0 :         new (tgt[offset+i]) AliHLTGlobalBarrelTrack(tracks[i]);
     738             :       }
     739           0 :       iResult=tracks.size();
     740           0 :     } else {
     741             :       //HLTError("failed to convert tracks from file %s size %d byte(s) ", filename, pFile->GetSize());
     742             :     }
     743           0 :   } else {
     744             :     //HLTError("failed reading %d byte(s) from file %s", pFile->GetSize(), filename);
     745             :     iResult=-ENODATA;
     746             :   }
     747             : 
     748           0 :   return iResult;
     749           0 : }
     750             : 
     751             : int AliHLTGlobalBarrelTrack::ReadTrackList(const char* listfile, TClonesArray& tgt, AliHLTComponentDataType dt, unsigned specification)
     752             : {
     753             :   // open blank separated list of files and read tracks
     754           0 :   ifstream list(listfile);
     755           0 :   if (!list.good()) return -ENOENT;
     756             : 
     757             :   int count=0;
     758           0 :   TString file;
     759           0 :   while (file.ReadLine(list)) {
     760             :     //HLTInfo("adding tracks from file %s", file.Data());
     761           0 :     int iResult=ReadTracks(file.Data(), tgt, dt, specification);
     762           0 :     if (iResult<0) {
     763             :       //HLTInfo("failed to add data from file %s: error %d", file.Data(), iResult);
     764           0 :       return iResult;
     765             :     }
     766           0 :     count+=iResult;
     767           0 :   }
     768             : 
     769           0 :   return count;
     770           0 : }

Generated by: LCOV version 1.11