LCOV - code coverage report
Current view: top level - HLT/TPCLib/tracking-ca - AliHLTTPCCATrackerComponent.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 30 375 8.0 %
Date: 2016-06-14 17:26:59 Functions: 8 24 33.3 %

          Line data    Source code
       1             : // @(#) $Id$
       2             : // **************************************************************************
       3             : // This file is property of and copyright by the ALICE HLT Project          *
       4             : // ALICE Experiment at CERN, All rights reserved.                           *
       5             : //                                                                          *
       6             : // Primary Authors: Sergey Gorbunov <sergey.gorbunov@kip.uni-heidelberg.de> *
       7             : //                  Ivan Kisel <kisel@kip.uni-heidelberg.de>                *
       8             : //                  for The ALICE HLT Project.                              *
       9             : //                                                                          *
      10             : // Permission to use, copy, modify and distribute this software and its     *
      11             : // documentation strictly for non-commercial purposes is hereby granted     *
      12             : // without fee, provided that the above copyright notice appears in all     *
      13             : // copies and that both the copyright notice and this permission notice     *
      14             : // appear in the supporting documentation. The authors make no claims       *
      15             : // about the suitability of this software for any purpose. It is            *
      16             : // provided "as is" without express or implied warranty.                    *
      17             : //                                                                          *
      18             : //***************************************************************************
      19             : 
      20             : 
      21             : ///////////////////////////////////////////////////////////////////////////////
      22             : //                                                                           //
      23             : // a TPC tracker processing component for the HLT based on CA by Ivan Kisel  //
      24             : //                                                                           //
      25             : ///////////////////////////////////////////////////////////////////////////////
      26             : 
      27             : #include "AliHLTTPCCATrackerComponent.h"
      28             : #include "AliHLTTPCGeometry.h"
      29             : #include "AliHLTTPCCATrackerFramework.h"
      30             : #include "AliHLTTPCCAParam.h"
      31             : #include "AliHLTTPCCATrackConvertor.h"
      32             : #include "AliHLTArray.h"
      33             : 
      34             : #include "AliHLTTPCSpacePointData.h"
      35             : #include "AliHLTTPCClusterDataFormat.h"
      36             : #include "AliHLTTPCCACompressedInputData.h"
      37             : #include "AliHLTTPCGeometry.h"
      38             : #include "AliHLTTPCDefinitions.h"
      39             : #include "AliExternalTrackParam.h"
      40             : #include "TMath.h"
      41             : #include "AliCDBEntry.h"
      42             : #include "AliCDBManager.h"
      43             : #include "TObjString.h"
      44             : #include "TObjArray.h"
      45             : #include "AliHLTTPCCASliceOutput.h"
      46             : #include "AliHLTTPCCAClusterData.h"
      47             : 
      48             : #if __GNUC__>= 3
      49             : using namespace std;
      50             : #endif
      51             : 
      52           6 : const AliHLTComponentDataType AliHLTTPCCADefinitions::fgkTrackletsDataType = AliHLTComponentDataTypeInitializer( "CATRACKL", kAliHLTDataOriginTPC );
      53             : 
      54             : /** ROOT macro for the implementation of ROOT specific class methods */
      55           6 : ClassImp( AliHLTTPCCATrackerComponent )
      56             : 
      57           3 :   AliHLTTPCCATrackerComponent::AliHLTTPCCATrackerComponent()
      58             :   :
      59           3 :   fTracker( NULL ),
      60           3 :   fClusterData( NULL ),
      61           3 :   fMinSlice( 0 ),
      62           3 :   fSliceCount( fgkNSlices ),
      63           3 :   fSolenoidBz( 0 ),
      64           3 :   fMinNTrackClusters( 30 ),
      65           3 :   fMinTrackPt(0.05),
      66           3 :   fClusterZCut( 500. ),
      67           3 :   fNeighboursSearchArea( 0 ), 
      68           3 :   fClusterErrorCorrectionY(0), 
      69           3 :   fClusterErrorCorrectionZ(0),
      70           3 :   fBenchmark("CATracker"), 
      71           3 :   fAllowGPU( 0),
      72           3 :   fGPUHelperThreads(-1),
      73           3 :   fCPUTrackers(0),
      74           3 :   fGlobalTracking(0),
      75           3 :   fGPUDeviceNum(-1),
      76           3 :   fGPULibrary("")
      77          15 : {
      78             :   // see header file for class documentation
      79             :   // or
      80             :   // refer to README to build package
      81             :   // or
      82             :   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
      83         222 :   for( int i=0; i<fgkNSlices; i++ ){
      84         108 :     fSliceOutput[i] = NULL;
      85             :   }
      86           6 : }
      87             : 
      88             : AliHLTTPCCATrackerComponent::AliHLTTPCCATrackerComponent( const AliHLTTPCCATrackerComponent& )
      89             :   :
      90           0 : AliHLTProcessor(),
      91           0 :   fTracker( NULL ),
      92           0 :   fClusterData( NULL ),
      93           0 :   fMinSlice( 0 ),
      94           0 :   fSliceCount( fgkNSlices ),
      95           0 :   fSolenoidBz( 0 ),
      96           0 :   fMinNTrackClusters( 30 ),
      97           0 :   fMinTrackPt( 0.05 ),
      98           0 :   fClusterZCut( 500. ),
      99           0 :   fNeighboursSearchArea(0),
     100           0 :   fClusterErrorCorrectionY(0), 
     101           0 :   fClusterErrorCorrectionZ(0),
     102           0 :   fBenchmark("CATracker"),
     103           0 :   fAllowGPU( 0),
     104           0 :   fGPUHelperThreads(-1),
     105           0 :   fCPUTrackers(0),
     106           0 :   fGlobalTracking(0),
     107           0 :   fGPUDeviceNum(-1),
     108           0 :   fGPULibrary("")
     109           0 : {
     110             :   // see header file for class documentation
     111           0 :   for( int i=0; i<fgkNSlices; i++ ){
     112           0 :     fSliceOutput[i] = NULL;
     113             :   }
     114           0 :   HLTFatal( "copy constructor untested" );
     115           0 : }
     116             : 
     117             : AliHLTTPCCATrackerComponent& AliHLTTPCCATrackerComponent::operator=( const AliHLTTPCCATrackerComponent& )
     118             : {
     119             :   // see header file for class documentation
     120           0 :   for( int i=0; i<fgkNSlices; i++ ){
     121           0 :     fSliceOutput[i] = NULL;
     122             :   }
     123           0 :   HLTFatal( "assignment operator untested" );
     124           0 :   return *this;
     125             : }
     126             : 
     127             : AliHLTTPCCATrackerComponent::~AliHLTTPCCATrackerComponent()
     128          18 : {
     129             :   // see header file for class documentation
     130           3 :   if (fTracker) delete fTracker;
     131           3 :   if (fClusterData) delete[] fClusterData;
     132           9 : }
     133             : 
     134             : //
     135             : // Public functions to implement AliHLTComponent's interface.
     136             : // These functions are required for the registration process
     137             : //
     138             : 
     139             : const char* AliHLTTPCCATrackerComponent::GetComponentID()
     140             : {
     141             :   // see header file for class documentation
     142         552 :   return "TPCCATracker";
     143             : }
     144             : 
     145             : void AliHLTTPCCATrackerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list )
     146             : {
     147             :   // see header file for class documentation
     148           0 :   list.clear();
     149           0 :   list.push_back( AliHLTTPCDefinitions::fgkClustersDataType );
     150           0 :   list.push_back( AliHLTTPCCADefinitions::fgkCompressedInputDataType );
     151           0 : }
     152             : 
     153             : AliHLTComponentDataType AliHLTTPCCATrackerComponent::GetOutputDataType()
     154             : {
     155             :   // see header file for class documentation
     156           0 :   return AliHLTTPCCADefinitions::fgkTrackletsDataType;
     157             : }
     158             : 
     159             : void AliHLTTPCCATrackerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
     160             : {
     161             :   // define guess for the output data size
     162           0 :   constBase = 1200;       // minimum size
     163           0 :   inputMultiplier = 0.6; // size relative to input
     164           0 : }
     165             : 
     166             : AliHLTComponent* AliHLTTPCCATrackerComponent::Spawn()
     167             : {
     168             :   // see header file for class documentation
     169           0 :   return new AliHLTTPCCATrackerComponent;
     170           0 : }
     171             : 
     172             : void AliHLTTPCCATrackerComponent::SetDefaultConfiguration()
     173             : {
     174             :   // Set default configuration for the CA tracker component
     175             :   // Some parameters can be later overwritten from the OCDB
     176             : 
     177           0 :   fSolenoidBz = -5.00668;
     178           0 :   fMinNTrackClusters = 30;
     179           0 :   fMinTrackPt = 0.05;
     180           0 :   fClusterZCut = 500.;
     181           0 :   fNeighboursSearchArea = 0;
     182           0 :   fClusterErrorCorrectionY = 0;
     183           0 :   fClusterErrorCorrectionZ = 0;
     184           0 :   fBenchmark.Reset();
     185           0 :   fBenchmark.SetTimer(0,"total");
     186           0 :   fBenchmark.SetTimer(1,"reco");
     187           0 : }
     188             : 
     189             : int AliHLTTPCCATrackerComponent::ReadConfigurationString(  const char* arguments )
     190             : {
     191             :   // Set configuration parameters for the CA tracker component from the string
     192             : 
     193             :   int iResult = 0;
     194           0 :   if ( !arguments ) return iResult;
     195             : 
     196           0 :   TString allArgs = arguments;
     197           0 :   TString argument;
     198             :   int bMissingParam = 0;
     199             : 
     200           0 :   TObjArray* pTokens = allArgs.Tokenize( " " );
     201             : 
     202           0 :   int nArgs =  pTokens ? pTokens->GetEntries() : 0;
     203             : 
     204           0 :   for ( int i = 0; i < nArgs; i++ ) {
     205           0 :     argument = ( ( TObjString* )pTokens->At( i ) )->GetString();
     206           0 :     if ( argument.IsNull() ) continue;
     207             : 
     208           0 :     if ( argument.CompareTo( "-solenoidBz" ) == 0 ) {
     209           0 :       if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break;
     210           0 :       HLTWarning("argument -solenoidBz is deprecated, magnetic field set up globally (%f)", GetBz());
     211             :       continue;
     212             :     }
     213             : 
     214           0 :     if ( argument.CompareTo( "-minNClustersOnTrack" ) == 0 ) {
     215           0 :       if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break;
     216           0 :       fMinNTrackClusters = ( ( TObjString* )pTokens->At( i ) )->GetString().Atoi();
     217           0 :       HLTInfo( "minNClustersOnTrack set to: %d", fMinNTrackClusters );
     218             :       continue;
     219             :     }
     220             : 
     221           0 :     if ( argument.CompareTo( "-minTrackPt" ) == 0 ) {
     222           0 :       if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break;
     223           0 :       fMinTrackPt = ( ( TObjString* )pTokens->At( i ) )->GetString().Atof();
     224           0 :       HLTInfo( "minTrackPt set to: %f", fMinTrackPt );
     225             :       continue;
     226             :     }
     227             : 
     228           0 :     if ( argument.CompareTo( "-clusterZCut" ) == 0 ) {
     229           0 :       if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break;
     230           0 :       fClusterZCut = TMath::Abs( ( ( TObjString* )pTokens->At( i ) )->GetString().Atof() );
     231           0 :       HLTInfo( "ClusterZCut set to: %f", fClusterZCut );
     232             :       continue;
     233             :     }
     234             : 
     235           0 :     if ( argument.CompareTo( "-neighboursSearchArea" ) == 0 ) {
     236           0 :       if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break;
     237           0 :       fNeighboursSearchArea = TMath::Abs( ( ( TObjString* )pTokens->At( i ) )->GetString().Atof() );
     238           0 :       HLTInfo( "NeighboursSearchArea set to: %f", fNeighboursSearchArea );
     239             :       continue;
     240             :     }
     241             : 
     242           0 :     if ( argument.CompareTo( "-errorCorrectionY" ) == 0 ) {
     243           0 :       if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break;
     244           0 :       fClusterErrorCorrectionY = ( ( TObjString* )pTokens->At( i ) )->GetString().Atof();
     245           0 :       HLTInfo( "Cluster Y error correction factor set to: %f", fClusterErrorCorrectionY );
     246             :       continue;
     247             :     }
     248             : 
     249           0 :     if ( argument.CompareTo( "-errorCorrectionZ" ) == 0 ) {
     250           0 :       if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break;
     251           0 :       fClusterErrorCorrectionZ = ( ( TObjString* )pTokens->At( i ) )->GetString().Atof();
     252           0 :       HLTInfo( "Cluster Z error correction factor set to: %f", fClusterErrorCorrectionZ );
     253             :       continue;
     254             :     }
     255             : 
     256           0 :     if (argument.CompareTo( "-allowGPU" ) == 0) {
     257           0 :       fAllowGPU = 1;
     258           0 :       HLTInfo( "Will try to run tracker on GPU" );
     259             :       continue;
     260             :     }
     261             : 
     262           0 :     if (argument.CompareTo( "-GlobalTracking" ) == 0) {
     263           0 :       fGlobalTracking = 1;
     264           0 :       HLTInfo( "Global Tracking Activated" );
     265             :       continue;
     266             :     }
     267             : 
     268           0 :     if ( argument.CompareTo( "-GPUHelperThreads" ) == 0 ) {
     269           0 :       if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break;
     270           0 :       fGPUHelperThreads = ( ( TObjString* )pTokens->At( i ) )->GetString().Atoi();
     271           0 :       HLTInfo( "Number of GPU Helper Threads set to: %d", fGPUHelperThreads );
     272             :       continue;
     273             :     }
     274             : 
     275           0 :     if ( argument.CompareTo( "-CPUTrackers" ) == 0 ) {
     276           0 :       if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break;
     277           0 :       fCPUTrackers = ( ( TObjString* )pTokens->At( i ) )->GetString().Atoi();
     278           0 :       HLTInfo( "Number of CPU Trackers set to: %d", fCPUTrackers );
     279             :       continue;
     280             :     }
     281             : 
     282           0 :     if ( argument.CompareTo( "-GPUDeviceNum" ) == 0 ) {
     283           0 :       if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break;
     284           0 :       fGPUDeviceNum = ( ( TObjString* )pTokens->At( i ) )->GetString().Atoi();
     285           0 :       HLTInfo( "Using GPU Device Number %d", fGPUDeviceNum );
     286             :       continue;
     287             :     }
     288             : 
     289           0 :     if ( argument.CompareTo( "-GPULibrary" ) == 0 ) {
     290           0 :       if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break;
     291           0 :       fGPULibrary = ( ( TObjString* )pTokens->At( i ) )->GetString();
     292           0 :       continue;
     293             :     }
     294             :         
     295           0 :         HLTError( "Unknown option \"%s\"", argument.Data() );
     296             :     iResult = -EINVAL;
     297           0 :   }
     298           0 :   delete pTokens;
     299             : 
     300           0 :   if ( bMissingParam ) {
     301           0 :     HLTError( "Specifier missed for parameter \"%s\"", argument.Data() );
     302             :     iResult = -EINVAL;
     303           0 :   }
     304             : 
     305             :   return iResult;
     306           0 : }
     307             : 
     308             : 
     309             : int AliHLTTPCCATrackerComponent::ReadCDBEntry( const char* cdbEntry, const char* chainId )
     310             : {
     311             :   // see header file for class documentation
     312             : 
     313             :   const char* defaultNotify = "";
     314             : 
     315           0 :   if ( !cdbEntry ) {
     316             :     cdbEntry = "HLT/ConfigTPC/TPCCATracker";
     317             :     defaultNotify = " (default)";
     318             :     chainId = 0;
     319           0 :   }
     320             : 
     321           0 :   HLTInfo( "configure from entry \"%s\"%s, chain id %s", cdbEntry, defaultNotify, ( chainId != NULL && chainId[0] != 0 ) ? chainId : "<none>" );
     322           0 :   AliCDBEntry *pEntry = AliCDBManager::Instance()->Get( cdbEntry );//,GetRunNo());
     323             : 
     324           0 :   if ( !pEntry ) {
     325           0 :     HLTError( "cannot fetch object \"%s\" from CDB", cdbEntry );
     326           0 :     return -EINVAL;
     327             :   }
     328             : 
     329           0 :   TObjString* pString = dynamic_cast<TObjString*>( pEntry->GetObject() );
     330             : 
     331           0 :   if ( !pString ) {
     332           0 :     HLTError( "configuration object \"%s\" has wrong type, required TObjString", cdbEntry );
     333           0 :     return -EINVAL;
     334             :   }
     335             : 
     336           0 :   HLTInfo( "received configuration object string: \"%s\"", pString->GetString().Data() );
     337             : 
     338           0 :   return  ReadConfigurationString( pString->GetString().Data() );
     339           0 : }
     340             : 
     341             : 
     342             : int AliHLTTPCCATrackerComponent::Configure( const char* cdbEntry, const char* chainId, const char *commandLine )
     343             : {
     344             :   // Configure the component
     345             :   // There are few levels of configuration,
     346             :   // parameters which are set on one step can be overwritten on the next step
     347             : 
     348             :   //* read hard-coded values
     349           0 :   SetDefaultConfiguration();
     350             : 
     351             :   //* read the default CDB entry
     352           0 :   int iResult1 = ReadCDBEntry( NULL, chainId );
     353             : 
     354             :   //* read magnetic field
     355           0 :   fSolenoidBz = GetBz();
     356             : 
     357             :   //* read the actual CDB entry if required
     358           0 :   int iResult2 = ( cdbEntry ) ? ReadCDBEntry( cdbEntry, chainId ) : 0;
     359             : 
     360             :   //* read extra parameters from input (if they are)
     361             :   int iResult3 = 0;
     362             : 
     363           0 :   if ( commandLine && commandLine[0] != '\0' ) {
     364           0 :     HLTInfo( "received configuration string from HLT framework: \"%s\"", commandLine );
     365           0 :     iResult3 = ReadConfigurationString( commandLine );
     366           0 :   }
     367             : 
     368           0 :   if (fTracker) ConfigureSlices();
     369             : 
     370           0 :   return iResult1 ? iResult1 : ( iResult2 ? iResult2 :  iResult3  );
     371             : }
     372             : 
     373             : void AliHLTTPCCATrackerComponent::ConfigureSlices()
     374             : {
     375             :   // Initialize the tracker slices
     376           0 :   for (int slice = 0;slice < fgkNSlices;slice++)
     377             :   {
     378             :     int iSec = slice;
     379             :     float inRmin = 83.65;
     380             :     //    float inRmax = 133.3;
     381             :     //    float outRmin = 133.5;
     382             :     float outRmax = 247.7;
     383             :     float plusZmin = 0.0529937;
     384             :     float plusZmax = 249.778;
     385             :     float minusZmin = -249.645;
     386             :     float minusZmax = -0.0799937;
     387             :     float dalpha = 0.349066;
     388           0 :     float alpha = 0.174533 + dalpha * iSec;
     389             : 
     390           0 :     bool zPlus = ( iSec < 18 );
     391           0 :     float zMin =  zPlus ? plusZmin : minusZmin;
     392           0 :     float zMax =  zPlus ? plusZmax : minusZmax;
     393             :     //TPCZmin = -249.645, ZMax = 249.778
     394             :     //    float rMin =  inRmin;
     395             :     //    float rMax =  outRmax;
     396           0 :     int nRows = AliHLTTPCGeometry::GetNRows();
     397             : 
     398             :     float padPitch = 0.4;
     399             :     float sigmaZ = 0.228808;
     400             : 
     401           0 :     float *rowX = new float [nRows];
     402           0 :     for ( int irow = 0; irow < nRows; irow++ ) {
     403           0 :       rowX[irow] = AliHLTTPCGeometry::Row2X( irow );
     404             :     }
     405             : 
     406           0 :     AliHLTTPCCAParam param;
     407             : 
     408           0 :     param.Initialize( iSec, nRows, rowX, alpha, dalpha,
     409           0 :       inRmin, outRmax, zMin, zMax, padPitch, sigmaZ, fSolenoidBz );
     410           0 :     param.SetHitPickUpFactor( 2 );
     411           0 :     if( fNeighboursSearchArea>0 ) param.SetNeighboursSearchArea( fNeighboursSearchArea );
     412           0 :     if( fClusterErrorCorrectionY>1.e-4 ) param.SetClusterError2CorrectionY( fClusterErrorCorrectionY*fClusterErrorCorrectionY );
     413           0 :     if( fClusterErrorCorrectionZ>1.e-4 ) param.SetClusterError2CorrectionZ( fClusterErrorCorrectionZ*fClusterErrorCorrectionZ );
     414           0 :     param.SetMinNTrackClusters( fMinNTrackClusters );
     415           0 :     param.SetMinTrackPt( fMinTrackPt );
     416             : 
     417           0 :     param.Update();
     418           0 :     fTracker->InitializeSliceParam( slice, param );
     419           0 :     delete[] rowX;
     420           0 :   }
     421           0 : }
     422             : 
     423             : int AliHLTTPCCATrackerComponent::DoInit( int argc, const char** argv )
     424             : {
     425           0 :   if ( fTracker ) return EINPROGRESS;
     426             : 
     427             :   // Configure the CA tracker component
     428           0 :   TString arguments = "";
     429           0 :   for ( int i = 0; i < argc; i++ ) {
     430           0 :     if ( !arguments.IsNull() ) arguments += " ";
     431           0 :     arguments += argv[i];
     432             :   }
     433             : 
     434           0 :   int retVal = Configure( NULL, NULL, arguments.Data() );
     435           0 :   if (retVal == 0)
     436             :   {
     437           0 :     fMinSlice = 0;
     438           0 :     fSliceCount = fgkNSlices;
     439             :     //Create tracker instance and set parameters
     440           0 :     fTracker = new AliHLTTPCCATrackerFramework(fAllowGPU, fGPULibrary, fGPUDeviceNum);
     441           0 :     if ( fAllowGPU && fTracker->GetGPUStatus() < 2 ) {
     442           0 :       HLTError("GPU Tracker requested but unavailable, aborting.");
     443           0 :       return -ENODEV;
     444             :     }
     445           0 :     fClusterData = new AliHLTTPCCAClusterData[fgkNSlices];
     446           0 :     if (fGPUHelperThreads != -1)
     447             :     {
     448           0 :       char cc[256] = "HelperThreads";
     449           0 :       fTracker->SetGPUTrackerOption(cc, fGPUHelperThreads);
     450           0 :     }
     451             :     {
     452           0 :       char cc[256] = "CPUTrackers";
     453           0 :       fTracker->SetGPUTrackerOption(cc, fCPUTrackers);
     454           0 :       char cc2[256] = "SlicesPerCPUTracker";
     455           0 :       fTracker->SetGPUTrackerOption(cc2, 1);
     456           0 :     }
     457           0 :     if (fGlobalTracking)
     458             :     {
     459           0 :       char cc[256] = "GlobalTracking";
     460           0 :       fTracker->SetGPUTrackerOption(cc, 1);
     461           0 :     }
     462             : 
     463           0 :     ConfigureSlices();
     464             :   }
     465             : 
     466           0 :   return(retVal);
     467           0 : }
     468             : 
     469             : int AliHLTTPCCATrackerComponent::DoDeinit()
     470             : {
     471             :   // see header file for class documentation
     472           0 :   if (fTracker) delete fTracker;
     473           0 :   fTracker = NULL;
     474           0 :   if (fClusterData) delete[] fClusterData;
     475           0 :   fClusterData = NULL;
     476           0 :   return 0;
     477             : }
     478             : 
     479             : int AliHLTTPCCATrackerComponent::Reconfigure( const char* cdbEntry, const char* chainId )
     480             : {
     481             :   // Reconfigure the component from OCDB .
     482           0 :   return Configure( cdbEntry, chainId, NULL );
     483             : }
     484             : 
     485             : int AliHLTTPCCATrackerComponent::DoEvent
     486             :   (
     487             :   const AliHLTComponentEventData& evtData,
     488             :   const AliHLTComponentBlockData* blocks,
     489             :   AliHLTComponentTriggerData& /*trigData*/,
     490             :   AliHLTUInt8_t* outputPtr,
     491             :   AliHLTUInt32_t& size,
     492             :   vector<AliHLTComponentBlockData>& outputBlocks )
     493             : {
     494             :   //* process event
     495           0 :   if (!fTracker)
     496             :   {
     497           0 :     HLTError( "CATracker not initialized properly" );
     498           0 :     return -ENOENT;
     499             :   }
     500             : 
     501           0 :   AliHLTUInt32_t maxBufferSize = size;
     502           0 :   size = 0; // output size
     503             : 
     504           0 :   if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) ) {
     505           0 :     return 0;
     506             :   }
     507             : 
     508           0 :   fBenchmark.StartNewEvent();
     509           0 :   fBenchmark.Start(0);
     510             : 
     511             :   //Logging( kHLTLogWarning, "HLT::TPCCATracker::DoEvent", "DoEvent", "CA::DoEvent()" );
     512           0 :   if ( evtData.fBlockCnt <= 0 ) {
     513           0 :     HLTWarning( "no blocks in event" );
     514           0 :     return 0;
     515             :   }
     516             : 
     517             :   const AliHLTComponentBlockData* iter = NULL;
     518           0 :   unsigned long ndx;
     519             : 
     520             :   // min and max patch numbers and row numbers
     521           0 :   int sliceminPatch[fgkNSlices];
     522           0 :   int slicemaxPatch[fgkNSlices];
     523           0 :   for (int i = 0;i < fSliceCount;i++)
     524             :   {
     525           0 :     sliceminPatch[i] = 100;
     526           0 :     slicemaxPatch[i] = -1;
     527             :   }
     528             : 
     529             :   //Prepare everything for all slices
     530             : 
     531           0 :   for (int islice = 0;islice < fSliceCount;islice++)
     532             :   {
     533           0 :     int slice = fMinSlice + islice;
     534             : 
     535             :     // total n Hits
     536             :     int nClustersTotal = 0;
     537             : 
     538             :     // sort patches
     539           0 :     std::vector<unsigned long> patchIndices;
     540             : 
     541           0 :     for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) {
     542           0 :       iter = blocks + ndx;
     543           0 :       if ( slice != AliHLTTPCDefinitions::GetMinSliceNr( *iter ) ) continue;
     544           0 :       if ( iter->fDataType == AliHLTTPCDefinitions::fgkClustersDataType ){
     545           0 :         AliHLTTPCClusterData* inPtrSP = ( AliHLTTPCClusterData* )( iter->fPtr );
     546           0 :         nClustersTotal += inPtrSP->fSpacePointCnt;
     547           0 :         fBenchmark.AddInput(iter->fSize);
     548           0 :       } else 
     549           0 :         if ( iter->fDataType == AliHLTTPCCADefinitions::fgkCompressedInputDataType){
     550           0 :           fBenchmark.AddInput(iter->fSize);
     551           0 :           const AliHLTUInt8_t * inPtr =  (const AliHLTUInt8_t *)iter->fPtr;
     552           0 :           while( inPtr< ((const AliHLTUInt8_t *) iter->fPtr) + iter->fSize ){
     553           0 :             AliHLTTPCCACompressedClusterRow *row = (AliHLTTPCCACompressedClusterRow*)inPtr;
     554           0 :             nClustersTotal+= row->fNClusters;    
     555           0 :             inPtr = (const AliHLTUInt8_t *)(row->fClusters+row->fNClusters);
     556             :           }
     557             :         }
     558             :         else continue;
     559             : 
     560           0 :         int patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
     561           0 :         if ( sliceminPatch[islice] > patch ) {
     562           0 :           sliceminPatch[islice] = patch;
     563           0 :         }
     564           0 :         if ( slicemaxPatch[islice] < patch ) {
     565           0 :           slicemaxPatch[islice] = patch;
     566           0 :         }
     567           0 :         std::vector<unsigned long>::iterator pIter = patchIndices.begin();
     568           0 :         while ( pIter != patchIndices.end() && AliHLTTPCDefinitions::GetMinPatchNr( blocks[*pIter] ) < patch ) {
     569           0 :           pIter++;
     570             :         }
     571           0 :         patchIndices.insert( pIter, ndx );
     572           0 :     }
     573             : 
     574             : 
     575             :     // pass event to CA Tracker
     576             : 
     577             : 
     578           0 :     Logging( kHLTLogDebug, "HLT::TPCCATracker::DoEvent", "Reading hits",
     579             :       "Total %d hits to read for slice %d", nClustersTotal, slice );
     580             : 
     581           0 :     if (nClustersTotal > 500000)
     582             :     {
     583           0 :       HLTWarning( "Too many clusters in tracker input: Slice %d, Number of Clusters %d, slice not included in tracking", slice, nClustersTotal );
     584           0 :       fClusterData[islice].StartReading( slice, 0 );
     585             :     }
     586             :     else
     587             :     {
     588           0 :       fClusterData[islice].StartReading( slice, nClustersTotal );
     589             : 
     590           0 :       for ( std::vector<unsigned long>::iterator pIter = patchIndices.begin(); pIter != patchIndices.end(); pIter++ ) {
     591           0 :         ndx = *pIter;
     592           0 :         iter = blocks + ndx;
     593           0 :         int patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
     594             :         int nPatchClust = 0;
     595             : 
     596           0 :         if ( iter->fDataType == AliHLTTPCDefinitions::fgkClustersDataType ) {
     597           0 :           AliHLTTPCCAClusterData::Data* pCluster = &fClusterData[islice].Clusters()[fClusterData[islice].NumberOfClusters()];
     598           0 :           AliHLTTPCClusterData* inPtrSP = ( AliHLTTPCClusterData* )( iter->fPtr );
     599           0 :           nPatchClust = inPtrSP->fSpacePointCnt;
     600           0 :           const AliHLTTPCSpacePointData* pLastSpacePoint = &inPtrSP->fSpacePoints[inPtrSP->fSpacePointCnt];
     601           0 :           for ( const AliHLTTPCSpacePointData* pSpacePoint = inPtrSP->fSpacePoints; pSpacePoint < pLastSpacePoint; pSpacePoint++ ) {
     602           0 :             if ( pSpacePoint->fZ > fClusterZCut || pSpacePoint->fZ < -fClusterZCut) continue;
     603           0 :             pCluster->fId = pSpacePoint->fID;
     604           0 :             pCluster->fRow = pSpacePoint->fPadRow;
     605           0 :             pCluster->fX = pSpacePoint->fX;
     606           0 :             pCluster->fY = pSpacePoint->fY;
     607           0 :             pCluster->fZ = pSpacePoint->fZ;
     608           0 :             pCluster->fAmp = pSpacePoint->fCharge;
     609           0 :             pCluster++;
     610           0 :           }
     611           0 :           fClusterData[islice].SetNumberOfClusters(pCluster - fClusterData[islice].Clusters());
     612           0 :         }
     613           0 :         else if ( iter->fDataType == AliHLTTPCCADefinitions::fgkCompressedInputDataType)
     614             :         {
     615           0 :           const AliHLTUInt8_t * inPtr = (const AliHLTUInt8_t *)iter->fPtr;
     616             :           nPatchClust=0;
     617           0 :           while( inPtr< ((const AliHLTUInt8_t *)iter->fPtr) + iter->fSize ){
     618           0 :             AliHLTTPCCACompressedClusterRow *row = (AliHLTTPCCACompressedClusterRow*)inPtr;
     619           0 :             UInt_t id = row->fSlicePatchRowID;
     620           0 :             UInt_t jslice = id>>10;    
     621           0 :             UInt_t jpatch = (id>>6) & 0x7;
     622           0 :             UInt_t jrow   =  id     & 0x3F;     
     623           0 :             jrow+= AliHLTTPCGeometry::GetFirstRow( jpatch );
     624           0 :             Double_t rowX = AliHLTTPCGeometry::Row2X( jrow );
     625             :             //cout<<"Read row: s "<<jslice<<" p "<<jpatch<<" r "<<jrow<<" x "<<row->fX<<" nclu "<<row->fNClusters<<" :"<<endl;
     626           0 :             if( jrow > 159 ) {
     627           0 :               HLTError( "Wrong TPC cluster with row number %d received", jrow );
     628           0 :               continue;
     629             :             }
     630           0 :             for ( unsigned int i = 0; i < row->fNClusters; i++ ) {
     631           0 :               AliHLTTPCCACompressedCluster *c = &( row->fClusters[i] );
     632             : 
     633           0 :               UInt_t ix0 = c->fP0 >>24;
     634           0 :               UInt_t ix1 = c->fP1 >>24;
     635           0 :               Double_t x = (ix1<<8) + ix0;
     636           0 :               Double_t y = c->fP0 & 0x00FFFFFF;
     637           0 :               Double_t z = c->fP1 & 0x00FFFFFF;
     638           0 :               x = (x - 32768.)*1.e-4 + rowX;
     639           0 :               y = (y - 8388608.)*1.e-4;
     640           0 :               z = (z - 8388608.)*1.e-4;
     641             : 
     642           0 :               UInt_t cluId = AliHLTTPCSpacePointData::GetID( jslice, jpatch, nPatchClust );
     643             :               //cout<<"clu "<<i<<": "<<x<<" "<<y<<" "<<z<<" "<<cluId<<endl;
     644           0 :               if ( CAMath::Abs( z ) <= fClusterZCut){
     645           0 :                 fClusterData[islice].ReadCluster( cluId, jrow, x, y, z, 0 );
     646             :               }
     647           0 :               nPatchClust++;      
     648             :             }
     649           0 :             inPtr = (const AliHLTUInt8_t *)(row->fClusters+row->fNClusters);
     650           0 :           }
     651           0 :         }
     652           0 :         Logging( kHLTLogInfo, "HLT::TPCCATracker::DoEvent", "Reading hits",
     653             :           "Read %d hits for slice %d - patch %d", nPatchClust, slice, patch );
     654             :       }
     655             :     }
     656           0 :   }
     657             : 
     658             :   //Prepare Output
     659           0 :   AliHLTTPCCASliceOutput::outputControlStruct outputControl;
     660           0 :   outputControl.fEndOfSpace = 0;
     661           0 :   outputControl.fOutputPtr =  (char*) outputPtr;
     662           0 :   outputControl.fOutputMaxSize = maxBufferSize;
     663           0 :   fTracker->SetOutputControl(&outputControl);
     664             : 
     665           0 :   memset(fSliceOutput, 0, fSliceCount * sizeof(AliHLTTPCCASliceOutput*));
     666             : 
     667             :   // reconstruct the event
     668           0 :   fBenchmark.Start(1);
     669           0 :   fTracker->ProcessSlices(fMinSlice, fSliceCount, fClusterData, fSliceOutput);
     670           0 :   fBenchmark.Stop(1);
     671             : 
     672             :   int ret = 0;
     673             :   unsigned int mySize = 0;
     674             :   int ntracks = 0;
     675             :   int error = 0;
     676             : 
     677           0 :   for (int islice = 0;islice < fSliceCount;islice++)
     678             :   {
     679           0 :     if (slicemaxPatch[islice] == -1) continue;
     680           0 :     int slice = fMinSlice + islice;
     681             : 
     682           0 :     if( outputControl.fEndOfSpace ){
     683           0 :       HLTWarning( "Output buffer size exceeded (buffer size %d, required size %d), tracks are not stored", maxBufferSize, mySize );
     684             :       ret = -ENOSPC;
     685             :       error = 1;
     686           0 :       break;     
     687             :     }
     688             : 
     689           0 :     if (fSliceOutput[islice])
     690             :     {
     691             :       // write reconstructed tracks
     692           0 :       Logging( kHLTLogDebug, "HLT::TPCCATracker::DoEvent", "Reconstruct", "%d tracks found for slice %d", fSliceOutput[islice]->NTracks(), slice );
     693             : 
     694           0 :       mySize += fSliceOutput[islice]->Size();
     695           0 :       ntracks += fSliceOutput[islice]->NTracks();    
     696             :     }
     697             :     else
     698             :     {
     699           0 :       HLTWarning( "Error during Tracking, no tracks stored" );
     700             :       mySize = 0;
     701             :       ret = -ENOSPC;
     702             :       ntracks = 0;
     703             :       error = 1;
     704           0 :       break;
     705             :     }
     706           0 :   }
     707             : 
     708           0 :   size = 0;
     709           0 :   if (error == 0)
     710             :   {
     711           0 :     for (int islice = 0;islice < fSliceCount && fSliceOutput[islice];islice++)
     712             :     {
     713           0 :       int slice = fMinSlice + islice;
     714             : 
     715           0 :       mySize = fSliceOutput[islice]->Size();
     716           0 :       if (mySize > 0)
     717             :       {
     718           0 :         AliHLTComponentBlockData bd;
     719           0 :         FillBlockData( bd );
     720           0 :         bd.fOffset = ((char*) fSliceOutput[islice] - (char*) outputPtr);
     721           0 :         bd.fSize = mySize;
     722           0 :         bd.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, sliceminPatch[islice], slicemaxPatch[islice] );
     723           0 :         bd.fDataType = GetOutputDataType();
     724           0 :         outputBlocks.push_back( bd );
     725           0 :         size += mySize;
     726           0 :         fBenchmark.AddOutput(bd.fSize);
     727           0 :       }
     728             :     }
     729           0 :   }
     730             : 
     731             :   //No longer needed
     732             : 
     733           0 :   fBenchmark.Stop(0);
     734             : 
     735             :   // Set log level to "Warning" for on-line system monitoring
     736             : 
     737             :   //Min and Max Patch are taken for first slice processed...
     738             : 
     739           0 :   fBenchmark.SetName(Form("CATracker"));
     740             : 
     741           0 :   HLTInfo(fBenchmark.GetStatistics());
     742             :   //No longer needed
     743             : 
     744             :   return ret;
     745           0 : }
     746             : 
     747             : 

Generated by: LCOV version 1.11