LCOV - code coverage report
Current view: top level - HLT/TPCLib/tracking-ca - AliHLTTPCCAGlobalMergerComponent.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 5 233 2.1 %
Date: 2016-06-14 17:26:59 Functions: 4 19 21.1 %

          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             : //                  Matthias Kretz <kretz@kde.org>                          *
       9             : //                  for The ALICE HLT Project.                              *
      10             : //                                                                          *
      11             : // Permission to use, copy, modify and distribute this software and its     *
      12             : // documentation strictly for non-commercial purposes is hereby granted     *
      13             : // without fee, provided that the above copyright notice appears in all     *
      14             : // copies and that both the copyright notice and this permission notice     *
      15             : // appear in the supporting documentation. The authors make no claims       *
      16             : // about the suitability of this software for any purpose. It is            *
      17             : // provided "as is" without express or implied warranty.                    *
      18             : //                                                                          *
      19             : //***************************************************************************
      20             : 
      21             : /// @file   AliHLTTPCCAGlobalMergerComponent.cxx
      22             : /// @author Matthias Kretz
      23             : /// @date
      24             : /// @brief  HLT TPC CA global merger component.
      25             : ///
      26             : 
      27             : #include "AliHLTTPCCAGlobalMergerComponent.h"
      28             : #include "AliHLTTPCCASliceOutput.h"
      29             : 
      30             : #include "AliHLTTPCCADef.h"
      31             : #include "AliHLTTPCCAMerger.h"
      32             : #include "AliHLTTPCCAMergerOutput.h"
      33             : #include "AliHLTTPCCATrackConvertor.h"
      34             : 
      35             : #include "AliHLTTPCGMMerger.h"
      36             : #include "AliHLTTPCGMMergedTrack.h"
      37             : 
      38             : #include "AliHLTTPCDefinitions.h"
      39             : #include "AliHLTTPCGeometry.h"
      40             : 
      41             : #include "AliExternalTrackParam.h"
      42             : #include "AliCDBEntry.h"
      43             : #include "AliCDBManager.h"
      44             : #include "TObjString.h"
      45             : #include "TObjArray.h"
      46             : #include "AliHLTExternalTrackParam.h"
      47             : 
      48             : #include <climits>
      49             : #include <cstdlib>
      50             : #include <cerrno>
      51             : 
      52             : using namespace std;
      53             : 
      54             : // ROOT macro for the implementation of ROOT specific class methods
      55           6 : ClassImp( AliHLTTPCCAGlobalMergerComponent )
      56             : 
      57             : 
      58             : AliHLTTPCCAGlobalMergerComponent::AliHLTTPCCAGlobalMergerComponent()
      59           6 : : AliHLTProcessor(), fVersion(1), fGlobalMergerVersion0( 0 ), fGlobalMerger(0), fSolenoidBz( 0 ), fClusterErrorCorrectionY(0), fClusterErrorCorrectionZ(0), fBenchmark("GlobalMerger")
      60          15 : {
      61             :   // see header file for class documentation
      62           6 : }
      63             : 
      64           0 : AliHLTTPCCAGlobalMergerComponent::AliHLTTPCCAGlobalMergerComponent( const AliHLTTPCCAGlobalMergerComponent & ):AliHLTProcessor(), fVersion(1), fGlobalMergerVersion0( 0 ), fGlobalMerger(0), fSolenoidBz( 0 ), fClusterErrorCorrectionY(0), fClusterErrorCorrectionZ(0), fBenchmark("GlobalMerger")
      65           0 : {
      66             : // dummy
      67           0 : }
      68             : 
      69             : AliHLTTPCCAGlobalMergerComponent &AliHLTTPCCAGlobalMergerComponent::operator=( const AliHLTTPCCAGlobalMergerComponent & )
      70             : {
      71             :   // dummy
      72           0 :   return *this;
      73             : }
      74             : 
      75             : // Public functions to implement AliHLTComponent's interface.
      76             : // These functions are required for the registration process
      77             : 
      78             : const char *AliHLTTPCCAGlobalMergerComponent::GetComponentID()
      79             : {
      80             :   // see header file for class documentation
      81         540 :   return "TPCCAGlobalMerger";
      82             : }
      83             : 
      84             : void AliHLTTPCCAGlobalMergerComponent::GetInputDataTypes( AliHLTComponentDataTypeList &list )
      85             : {
      86             :   // see header file for class documentation
      87           0 :   list.clear();
      88           0 :   list.push_back( AliHLTTPCCADefinitions::fgkTrackletsDataType );
      89             :   //list.push_back( AliHLTTPCDefinitions::fgkTrackSegmentsDataType );
      90             :   //list.push_back( AliHLTTPCDefinitions::fgkVertexDataType );
      91           0 : }
      92             : 
      93             : AliHLTComponentDataType AliHLTTPCCAGlobalMergerComponent::GetOutputDataType()
      94             : {
      95             :   // see header file for class documentation
      96             :   //return AliHLTTPCDefinitions::fgkTracksDataType; // old
      97           0 :   return kAliHLTDataTypeTrack|kAliHLTDataOriginTPC;
      98             : }
      99             : 
     100             : void AliHLTTPCCAGlobalMergerComponent::GetOutputDataSize( unsigned long &constBase, double &inputMultiplier )
     101             : {
     102             :   // see header file for class documentation
     103             :   // XXX TODO: Find more realistic values.
     104           0 :   constBase = 0;
     105           0 :   inputMultiplier = 1.0;
     106           0 : }
     107             : 
     108             : AliHLTComponent *AliHLTTPCCAGlobalMergerComponent::Spawn()
     109             : {
     110             :   // see header file for class documentation
     111           0 :   return new AliHLTTPCCAGlobalMergerComponent;
     112           0 : }
     113             : 
     114             : 
     115             : void AliHLTTPCCAGlobalMergerComponent::SetDefaultConfiguration()
     116             : {
     117             :   // Set default configuration for the CA merger component
     118             :   // Some parameters can be later overwritten from the OCDB
     119             : 
     120           0 :   fVersion = 1;
     121           0 :   fSolenoidBz = -5.00668;
     122           0 :   fClusterErrorCorrectionY = 0;
     123           0 :   fClusterErrorCorrectionZ = 1.1;
     124           0 :   fBenchmark.Reset();
     125           0 :   fBenchmark.SetTimer(0,"total");
     126           0 :   fBenchmark.SetTimer(1,"reco");    
     127           0 : }
     128             : 
     129             : int AliHLTTPCCAGlobalMergerComponent::ReadConfigurationString(  const char* arguments )
     130             : {
     131             :   // Set configuration parameters for the CA merger component from the string
     132             : 
     133             :   int iResult = 0;
     134           0 :   if ( !arguments ) return iResult;
     135             : 
     136           0 :   TString allArgs = arguments;
     137           0 :   TString argument;
     138             :   int bMissingParam = 0;
     139             : 
     140           0 :   TObjArray* pTokens = allArgs.Tokenize( " " );
     141             : 
     142           0 :   int nArgs =  pTokens ? pTokens->GetEntries() : 0;
     143             : 
     144           0 :   for ( int i = 0; i < nArgs; i++ ) {
     145           0 :     argument = ( ( TObjString* )pTokens->At( i ) )->GetString();
     146           0 :     if ( argument.IsNull() ) continue;
     147             : 
     148           0 :     if ( argument.CompareTo( "-version" ) == 0 ) {
     149           0 :       if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break;
     150           0 :       fVersion  = ( ( TObjString* )pTokens->At( i ) )->GetString().Atoi();
     151           0 :       HLTInfo( "Merger version set to: %d", fVersion );
     152             :       continue;
     153             :     }
     154             : 
     155           0 :     if ( argument.CompareTo( "-solenoidBz" ) == 0 ) {
     156           0 :       if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break;
     157           0 :       HLTWarning("argument -solenoidBz is deprecated, magnetic field set up globally (%f)", GetBz());
     158             :       continue;
     159             :     }
     160             : 
     161           0 :     if ( argument.CompareTo( "-errorCorrectionY" ) == 0 ) {
     162           0 :       if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break;
     163           0 :       fClusterErrorCorrectionY = ( ( TObjString* )pTokens->At( i ) )->GetString().Atof();
     164           0 :       HLTInfo( "Cluster Y error correction factor set to: %f", fClusterErrorCorrectionY );
     165             :       continue;
     166             :     }
     167             : 
     168           0 :    if ( argument.CompareTo( "-errorCorrectionZ" ) == 0 ) {
     169           0 :       if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break;
     170           0 :       fClusterErrorCorrectionZ = ( ( TObjString* )pTokens->At( i ) )->GetString().Atof();
     171           0 :       HLTInfo( "Cluster Z error correction factor set to: %f", fClusterErrorCorrectionZ );
     172             :       continue;
     173             :     }
     174             : 
     175           0 :     HLTError( "Unknown option \"%s\"", argument.Data() );
     176             :     iResult = -EINVAL;
     177           0 :   }
     178           0 :   delete pTokens;
     179             : 
     180           0 :   if ( bMissingParam ) {
     181           0 :     HLTError( "Specifier missed for parameter \"%s\"", argument.Data() );
     182             :     iResult = -EINVAL;
     183           0 :   }
     184             : 
     185             :   return iResult;
     186           0 : }
     187             : 
     188             : 
     189             : int AliHLTTPCCAGlobalMergerComponent::ReadCDBEntry( const char* cdbEntry, const char* chainId )
     190             : {
     191             :   // see header file for class documentation
     192             : 
     193             :   const char* defaultNotify = "";
     194             : 
     195           0 :   if ( !cdbEntry ) {
     196             :     cdbEntry = "HLT/ConfigTPC/TPCCAGlobalMerger";
     197             :     defaultNotify = " (default)";
     198             :     chainId = 0;
     199           0 :   }
     200             : 
     201           0 :   HLTInfo( "configure from entry \"%s\"%s, chain id %s", cdbEntry, defaultNotify, ( chainId != NULL && chainId[0] != 0 ) ? chainId : "<none>" );
     202           0 :   AliCDBEntry *pEntry = AliCDBManager::Instance()->Get( cdbEntry );//,GetRunNo());
     203             : 
     204           0 :   if ( !pEntry ) {
     205           0 :     HLTError( "cannot fetch object \"%s\" from CDB", cdbEntry );
     206           0 :     return -EINVAL;
     207             :   }
     208             : 
     209           0 :   TObjString* pString = dynamic_cast<TObjString*>( pEntry->GetObject() );
     210             : 
     211           0 :   if ( !pString ) {
     212           0 :     HLTError( "configuration object \"%s\" has wrong type, required TObjString", cdbEntry );
     213           0 :     return -EINVAL;
     214             :   }
     215             : 
     216           0 :   HLTInfo( "received configuration object string: \"%s\"", pString->GetString().Data() );
     217             : 
     218           0 :   return  ReadConfigurationString( pString->GetString().Data() );
     219           0 : }
     220             : 
     221             : 
     222             : 
     223             : int AliHLTTPCCAGlobalMergerComponent::Configure( const char* cdbEntry, const char* chainId, const char *commandLine )
     224             : {
     225             :   // Configure the component
     226             :   // There are few levels of configuration,
     227             :   // parameters which are set on one step can be overwritten on the next step
     228             : 
     229             :   //* read hard-coded values
     230             : 
     231           0 :   SetDefaultConfiguration();
     232             : 
     233             :   //* read the default CDB entry
     234             : 
     235           0 :   int iResult1 = ReadCDBEntry( NULL, chainId );
     236             : 
     237             :   //* read magnetic field
     238             : 
     239           0 :   fSolenoidBz = GetBz();
     240             : 
     241             :   //* read the actual CDB entry if required
     242             : 
     243           0 :   int iResult2 = ( cdbEntry ) ? ReadCDBEntry( cdbEntry, chainId ) : 0;
     244             : 
     245             :   //* read extra parameters from input (if they are)
     246             : 
     247             :   int iResult3 = 0;
     248             : 
     249           0 :   if ( commandLine && commandLine[0] != '\0' ) {
     250           0 :     HLTInfo( "received configuration string from HLT framework: \"%s\"", commandLine );
     251           0 :     iResult3 = ReadConfigurationString( commandLine );
     252           0 :   }
     253             : 
     254             : 
     255             :   // Initialize the merger
     256             : 
     257           0 :   AliHLTTPCCAParam param;
     258             : 
     259             :   {
     260             :     // get gemetry
     261             :     int iSec = 0;
     262             :     float inRmin = 83.65;
     263             :     float outRmax = 247.7;
     264             :     float plusZmin = 0.0529937;
     265             :     float plusZmax = 249.778;
     266             :     //float minusZmin = -249.645;
     267             :     //float minusZmax = -0.0799937;
     268             :     float dalpha = 0.349066;
     269             :     float alpha = 0.174533 + dalpha * iSec;
     270             :     //bool zPlus = ( iSec < 18 );
     271             :     float zMin =  plusZmin; //zPlus ? plusZmin : minusZmin;
     272             :     float zMax =  plusZmax; //zPlus ? plusZmax : minusZmax;
     273           0 :     int nRows = AliHLTTPCGeometry::GetNRows();
     274             :     float padPitch = 0.4;
     275             :     float sigmaZ = 0.228808;
     276           0 :     float *rowX = new float [nRows];
     277           0 :     for ( int irow = 0; irow < nRows; irow++ ) {
     278           0 :       rowX[irow] = AliHLTTPCGeometry::Row2X( irow );
     279             :     }
     280             : 
     281           0 :     param.Initialize( iSec, nRows, rowX, alpha, dalpha,
     282           0 :                       inRmin, outRmax, zMin, zMax, padPitch, sigmaZ, fSolenoidBz );
     283             : 
     284           0 :     if( fClusterErrorCorrectionY>1.e-4 ) param.SetClusterError2CorrectionY( fClusterErrorCorrectionY*fClusterErrorCorrectionY );
     285           0 :     if( fClusterErrorCorrectionZ>1.e-4 ) param.SetClusterError2CorrectionZ( fClusterErrorCorrectionZ*fClusterErrorCorrectionZ );
     286           0 :     param.Update();
     287             : 
     288           0 :     delete[] rowX;
     289             :   }
     290             : 
     291             : 
     292           0 :   if( fVersion==0 ) fGlobalMergerVersion0->SetSliceParam( param );
     293           0 :   else fGlobalMerger->SetSliceParam( param );
     294             : 
     295           0 :   return iResult1 ? iResult1 : ( iResult2 ? iResult2 : iResult3 );
     296           0 : }
     297             : 
     298             : 
     299             : 
     300             : 
     301             : int AliHLTTPCCAGlobalMergerComponent::DoInit( int argc, const char** argv )
     302             : {
     303             :   // see header file for class documentation
     304             : 
     305           0 :   if ( fGlobalMergerVersion0 || fGlobalMerger ) {
     306           0 :     return EINPROGRESS;
     307             :   }
     308             : 
     309           0 :   fGlobalMergerVersion0 = new AliHLTTPCCAMerger();
     310           0 :   fGlobalMerger         = new AliHLTTPCGMMerger();
     311             : 
     312           0 :   TString arguments = "";
     313           0 :   for ( int i = 0; i < argc; i++ ) {
     314           0 :     if ( !arguments.IsNull() ) arguments += " ";
     315           0 :     arguments += argv[i];
     316             :   }
     317             : 
     318           0 :   return Configure( NULL, NULL, arguments.Data()  );
     319           0 : }
     320             : 
     321             : int AliHLTTPCCAGlobalMergerComponent::Reconfigure( const char* cdbEntry, const char* chainId )
     322             : {
     323             :   // Reconfigure the component from OCDB
     324             : 
     325           0 :   return Configure( cdbEntry, chainId, NULL );
     326             : }
     327             : 
     328             : 
     329             : 
     330             : int AliHLTTPCCAGlobalMergerComponent::DoDeinit()
     331             : {
     332             :   // see header file for class documentation
     333           0 :   delete fGlobalMergerVersion0;
     334           0 :   fGlobalMergerVersion0 = 0;
     335           0 :   delete fGlobalMerger;
     336           0 :   fGlobalMerger = 0;
     337             : 
     338           0 :   return 0;
     339             : }
     340             : 
     341             : int AliHLTTPCCAGlobalMergerComponent::DoEvent( const AliHLTComponentEventData &evtData,
     342             :     const AliHLTComponentBlockData *blocks, AliHLTComponentTriggerData &/*trigData*/,
     343             :     AliHLTUInt8_t *outputPtr, AliHLTUInt32_t &size, AliHLTComponentBlockDataList &outputBlocks )
     344             : {
     345             :   // see header file for class documentation
     346             :   int iResult = 0;
     347           0 :   unsigned int maxBufferSize = size;
     348             : 
     349           0 :   size = 0;
     350             : 
     351           0 :   if ( !outputPtr ) {
     352           0 :     return -ENOSPC;
     353             :   }
     354           0 :   if ( !IsDataEvent() ) {
     355           0 :     return 0;
     356             :   }
     357           0 :   fBenchmark.StartNewEvent();
     358           0 :   fBenchmark.Start(0);
     359             : 
     360           0 :   if( fVersion==0 )  fGlobalMergerVersion0->Clear();
     361           0 :   else fGlobalMerger->Clear();
     362             : 
     363           0 :   const AliHLTComponentBlockData *const blocksEnd = blocks + evtData.fBlockCnt;
     364           0 :   for ( const AliHLTComponentBlockData *block = blocks; block < blocksEnd; ++block ) {
     365           0 :     if ( block->fDataType != AliHLTTPCCADefinitions::fgkTrackletsDataType ) {
     366             :       continue;
     367             :     }
     368             : 
     369           0 :     fBenchmark.AddInput(block->fSize);
     370             : 
     371           0 :     int slice = AliHLTTPCDefinitions::GetMinSliceNr( *block );
     372           0 :     if ( slice < 0 || slice >= AliHLTTPCGeometry::GetNSlice() ) {
     373           0 :       HLTError( "invalid slice number %d extracted from specification 0x%08lx,  skipping block of type %s",
     374             :                 slice, block->fSpecification, DataType2Text( block->fDataType ).c_str() );
     375             :       // just remember the error, if there are other valid blocks ignore the error, return code otherwise
     376             :       iResult = -EBADF;
     377           0 :       continue;
     378             :     }
     379             : 
     380           0 :     if ( slice != AliHLTTPCDefinitions::GetMaxSliceNr( *block ) ) {
     381             :       // the code was not written for/ never used with multiple slices in one data block/ specification
     382           0 :       HLTWarning( "specification 0x%08lx indicates multiple slices in data block %s: never used before, please audit the code",
     383             :                   block->fSpecification, DataType2Text( block->fDataType ).c_str() );
     384             :     }
     385           0 :     AliHLTTPCCASliceOutput *sliceOut =  reinterpret_cast<AliHLTTPCCASliceOutput *>( block->fPtr );
     386             :     //sliceOut->SetPointers();
     387           0 :     if( fVersion==0 ) fGlobalMergerVersion0->SetSliceData( slice, sliceOut );
     388           0 :     else fGlobalMerger->SetSliceData( slice, sliceOut );
     389             : 
     390             :         /*char filename[256];
     391             :         sprintf(filename, "debug%d.out", slice);
     392             :         FILE* fp = fopen(filename, "w+b");
     393             :         if (fp == NULL) printf("Error!!!\n");
     394             :         fwrite(sliceOut, 1, sliceOut->EstimateSize(sliceOut->NTracks(), sliceOut->NTrackClusters()), fp);
     395             :         fclose(fp);*/
     396           0 :   }
     397           0 :   fBenchmark.Start(1);
     398           0 :   if( fVersion==0 ) fGlobalMergerVersion0->Reconstruct();
     399           0 :   else fGlobalMerger->Reconstruct();
     400           0 :   fBenchmark.Stop(1);
     401             : 
     402             :   // Fill output 
     403             : 
     404           0 :   if( fVersion==0 ){
     405             : 
     406           0 :     const AliHLTTPCCAMergerOutput *mergerOutput = fGlobalMergerVersion0->Output();
     407             : 
     408             :     unsigned int mySize = 0;
     409             :     {
     410           0 :       AliHLTTracksData* outPtr = ( AliHLTTracksData* )( outputPtr );
     411             :       
     412           0 :       AliHLTExternalTrackParam* currOutTrack = outPtr->fTracklets;
     413             :       
     414           0 :       mySize =   ( ( AliHLTUInt8_t * )currOutTrack ) -  ( ( AliHLTUInt8_t * )outputPtr );
     415             :       
     416           0 :       outPtr->fCount = 0;
     417             :       
     418           0 :       int nTracks = mergerOutput->NTracks();
     419             :       
     420           0 :       for ( int itr = 0; itr < nTracks; itr++ ) {
     421             :         
     422             :         // convert AliHLTTPCCAMergedTrack to AliHLTTrack
     423             :         
     424           0 :         const AliHLTTPCCAMergedTrack &track = mergerOutput->Track( itr );
     425             :         
     426           0 :         unsigned int dSize = sizeof( AliHLTExternalTrackParam ) + track.NClusters() * sizeof( unsigned int );
     427             :         
     428           0 :         if ( mySize + dSize > maxBufferSize ) {
     429           0 :           HLTWarning( "Output buffer size exceed (buffer size %d, current size %d), %d tracks are not stored", maxBufferSize, mySize, nTracks - itr + 1 );
     430             :           iResult = -ENOSPC;
     431           0 :           break;
     432             :         }
     433             :         
     434             :         // first convert to AliExternalTrackParam
     435             :         
     436           0 :         AliExternalTrackParam tp, tpEnd;
     437           0 :         AliHLTTPCCATrackConvertor::GetExtParam( track.InnerParam(), tp,  track.InnerAlpha() );
     438           0 :         AliHLTTPCCATrackConvertor::GetExtParam( track.OuterParam(), tpEnd, track.OuterAlpha() );
     439             :         
     440             :         // normalize the angle to +-Pi
     441             :         
     442           0 :         currOutTrack->fAlpha = tp.GetAlpha() - CAMath::Nint(tp.GetAlpha()/CAMath::TwoPi())*CAMath::TwoPi();      
     443           0 :         currOutTrack->fX = tp.GetX();
     444           0 :         currOutTrack->fY = tp.GetY();
     445           0 :         currOutTrack->fZ = tp.GetZ();      
     446             :         {
     447           0 :           float sinA = TMath::Sin( track.OuterAlpha() - track.InnerAlpha());
     448           0 :           float cosA = TMath::Cos( track.OuterAlpha() - track.InnerAlpha());
     449           0 :           currOutTrack->fLastX = tpEnd.GetX()*cosA - tpEnd.GetY()*sinA;
     450           0 :           currOutTrack->fLastY = tpEnd.GetX()*sinA + tpEnd.GetY()*cosA;
     451           0 :           currOutTrack->fLastZ = tpEnd.GetZ();
     452             :         }
     453           0 :         currOutTrack->fq1Pt = tp.GetSigned1Pt();
     454           0 :         currOutTrack->fSinPsi = tp.GetSnp();
     455           0 :         currOutTrack->fTgl = tp.GetTgl();
     456           0 :         for( int i=0; i<15; i++ ) currOutTrack->fC[i] = tp.GetCovariance()[i];
     457           0 :         currOutTrack->fTrackID = itr;
     458           0 :         currOutTrack->fFlags = 0;
     459           0 :         currOutTrack->fNPoints = track.NClusters();    
     460           0 :         for ( int i = 0; i < track.NClusters(); i++ ) currOutTrack->fPointIDs[i] = mergerOutput->ClusterId( track.FirstClusterRef() + i );
     461             :         
     462           0 :         currOutTrack = ( AliHLTExternalTrackParam* )( (( Byte_t * )currOutTrack) + dSize );
     463             :         mySize += dSize;
     464           0 :         outPtr->fCount++;
     465           0 :       }    
     466             : 
     467           0 :       AliHLTComponentBlockData resultData;
     468           0 :       FillBlockData( resultData );
     469           0 :       resultData.fOffset = 0;
     470           0 :       resultData.fSize = mySize;
     471           0 :       resultData.fDataType = kAliHLTDataTypeTrack|kAliHLTDataOriginTPC;
     472           0 :       resultData.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( 0, 35, 0, 5 );
     473           0 :       outputBlocks.push_back( resultData );
     474           0 :       fBenchmark.AddOutput(resultData.fSize);
     475             :       
     476           0 :       size = resultData.fSize;
     477           0 :     }
     478             :     
     479           0 :     HLTInfo( "CAGlobalMerger:: output %d tracks", mergerOutput->NTracks() );
     480           0 :     fGlobalMergerVersion0->Clear();
     481             : 
     482           0 :   } else { // new merger 
     483             : 
     484             :     unsigned int mySize = 0;
     485             :     {
     486           0 :       AliHLTTracksData* outPtr = ( AliHLTTracksData* )( outputPtr );
     487           0 :       AliHLTExternalTrackParam* currOutTrack = outPtr->fTracklets;
     488           0 :       mySize =   ( ( AliHLTUInt8_t * )currOutTrack ) -  ( ( AliHLTUInt8_t * )outputPtr );
     489           0 :       outPtr->fCount = 0;   
     490           0 :       int nTracks = fGlobalMerger->NOutputTracks();
     491             : 
     492           0 :       for ( int itr = 0; itr < nTracks; itr++ ) {
     493             : 
     494             :         // convert AliHLTTPCGMMergedTrack to AliHLTTrack
     495             :         
     496           0 :         const AliHLTTPCGMMergedTrack &track = fGlobalMerger->OutputTracks()[ itr ];
     497           0 :         if( !track.OK() ) continue;
     498           0 :         unsigned int dSize = sizeof( AliHLTExternalTrackParam ) + track.NClusters() * sizeof( unsigned int );
     499             :         
     500           0 :         if ( mySize + dSize > maxBufferSize ) {
     501           0 :           HLTWarning( "Output buffer size exceed (buffer size %d, current size %d), %d tracks are not stored", maxBufferSize, mySize, nTracks - itr + 1 );
     502             :           iResult = -ENOSPC;
     503           0 :           break;
     504             :         }
     505             : 
     506             :         // first convert to AliExternalTrackParam
     507             : 
     508           0 :         AliExternalTrackParam tp;
     509           0 :         track.GetParam().GetExtParam( tp,  track.GetAlpha() );
     510             :       
     511             :         // normalize the angle to +-Pi
     512             :               
     513           0 :         currOutTrack->fAlpha = tp.GetAlpha() - CAMath::Nint(tp.GetAlpha()/CAMath::TwoPi())*CAMath::TwoPi();      
     514           0 :         currOutTrack->fX = tp.GetX();
     515           0 :         currOutTrack->fY = tp.GetY();
     516           0 :         currOutTrack->fZ = tp.GetZ();      
     517           0 :         currOutTrack->fLastX = track.LastX();
     518           0 :         currOutTrack->fLastY = track.LastY();
     519           0 :         currOutTrack->fLastZ = track.LastZ();
     520             :       
     521           0 :         currOutTrack->fq1Pt = tp.GetSigned1Pt();
     522           0 :         currOutTrack->fSinPsi = tp.GetSnp();
     523           0 :         currOutTrack->fTgl = tp.GetTgl();
     524           0 :         for( int i=0; i<15; i++ ) currOutTrack->fC[i] = tp.GetCovariance()[i];
     525           0 :         currOutTrack->fTrackID = itr;
     526           0 :         currOutTrack->fFlags = 0;
     527           0 :         currOutTrack->fNPoints = track.NClusters();    
     528           0 :         for ( int i = 0; i < track.NClusters(); i++ ) currOutTrack->fPointIDs[i] = fGlobalMerger->OutputClusterIds()[track.FirstClusterRef() + i ];
     529             :         
     530           0 :         currOutTrack = ( AliHLTExternalTrackParam* )( (( Byte_t * )currOutTrack) + dSize );
     531             :         mySize += dSize;
     532           0 :         outPtr->fCount++;
     533           0 :       }
     534             :   
     535           0 :       AliHLTComponentBlockData resultData;
     536           0 :       FillBlockData( resultData );
     537           0 :       resultData.fOffset = 0;
     538           0 :       resultData.fSize = mySize;
     539           0 :       resultData.fDataType = kAliHLTDataTypeTrack|kAliHLTDataOriginTPC;
     540           0 :       resultData.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( 0, 35, 0, 5 );
     541           0 :       outputBlocks.push_back( resultData );
     542           0 :       fBenchmark.AddOutput(resultData.fSize);
     543             :       
     544           0 :       size = resultData.fSize;
     545           0 :     }
     546             : 
     547           0 :     HLTInfo( "CAGlobalMerger:: output %d tracks", fGlobalMerger->NOutputTracks() );
     548             : 
     549           0 :     fGlobalMerger->Clear();
     550             :   }
     551             : 
     552           0 :   fBenchmark.Stop(0);
     553           0 :   HLTInfo( fBenchmark.GetStatistics() );
     554             :   return iResult;
     555           0 : }
     556             : 

Generated by: LCOV version 1.11