]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
bugfix: work only on known data types and ignore others; added output buffer protection
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 6 Aug 2008 00:59:01 +0000 (00:59 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 6 Aug 2008 00:59:01 +0000 (00:59 +0000)
HLT/TPCLib/AliHLTTPCGlobalMergerComponent.cxx
HLT/TPCLib/AliHLTTPCSliceTrackerComponent.cxx

index 5f9a4d46f39cde2fbc7b92c4dbfefa99e1b75009..9009af30c724482d4364b85b246681447dc870ef 100644 (file)
@@ -1,21 +1,21 @@
 // $Id$
 
 // $Id$
 
-/**************************************************************************
- * This file is property of and copyright by the ALICE HLT Project        * 
- * ALICE Experiment at CERN, All rights reserved.                         *
- *                                                                        *
- * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
- *                  Timm Steinbeck <timm@kip.uni-heidelberg.de>           *
- *                  for The ALICE HLT Project.                            *
- *                                                                        *
- * Permission to use, copy, modify and distribute this software and its   *
- * documentation strictly for non-commercial purposes is hereby granted   *
- * without fee, provided that the above copyright notice appears in all   *
- * copies and that both the copyright notice and this permission notice   *
- * appear in the supporting documentation. The authors make no claims     *
- * about the suitability of this software for any purpose. It is          *
- * provided "as is" without express or implied warranty.                  *
- **************************************************************************/
+//**************************************************************************
+//* This file is property of and copyright by the ALICE HLT Project        * 
+//* ALICE Experiment at CERN, All rights reserved.                         *
+//*                                                                        *
+//* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
+//*                  Timm Steinbeck <timm@kip.uni-heidelberg.de>           *
+//*                  for The ALICE HLT Project.                            *
+//*                                                                        *
+//* Permission to use, copy, modify and distribute this software and its   *
+//* documentation strictly for non-commercial purposes is hereby granted   *
+//* without fee, provided that the above copyright notice appears in all   *
+//* copies and that both the copyright notice and this permission notice   *
+//* appear in the supporting documentation. The authors make no claims     *
+//* about the suitability of this software for any purpose. It is          *
+//* provided "as is" without express or implied warranty.                  *
+//**************************************************************************
 
 /** @file   AliHLTTPCGlobalMergerComponent.cxx
     @author Timm Steinbeck, Matthias Richter
 
 /** @file   AliHLTTPCGlobalMergerComponent.cxx
     @author Timm Steinbeck, Matthias Richter
     @brief  HLT TPC global merger component.
 */
 
     @brief  HLT TPC global merger component.
 */
 
-// see header file for class documentation                                   //
-// or                                                                        //
-// refer to README to build package                                          //
-// or                                                                        //
-// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt                          //
-
 #if __GNUC__>= 3
 using namespace std;
 #endif
 
 #include <climits>
 #include "AliHLTTPCGlobalMergerComponent.h"
 #if __GNUC__>= 3
 using namespace std;
 #endif
 
 #include <climits>
 #include "AliHLTTPCGlobalMergerComponent.h"
-//#include "AliHLTTPCTransform.h"
+#include "AliHLTTPCTransform.h"
 #include "AliHLTTPCGlobalMerger.h"
 #include "AliHLTTPCVertex.h"
 #include "AliHLTTPCVertexData.h"
 #include "AliHLTTPCGlobalMerger.h"
 #include "AliHLTTPCVertex.h"
 #include "AliHLTTPCVertexData.h"
@@ -140,6 +134,8 @@ int AliHLTTPCGlobalMergerComponent::DoEvent( const AliHLTComponentEventData& evt
 {
   // see header file for class documentation
   int iResult=0;
 {
   // see header file for class documentation
   int iResult=0;
+  AliHLTUInt32_t capacity=size;
+  size=0;
   const AliHLTComponentBlockData* iter = NULL;
   const AliHLTComponentBlockData* lastVertexBlock = NULL;
   unsigned long ndx;
   const AliHLTComponentBlockData* iter = NULL;
   const AliHLTComponentBlockData* lastVertexBlock = NULL;
   unsigned long ndx;
@@ -158,7 +154,28 @@ int AliHLTTPCGlobalMergerComponent::DoEvent( const AliHLTComponentEventData& evt
   for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
     {
       iter = blocks+ndx;
   for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
     {
       iter = blocks+ndx;
+      bool bIsTrackSegDataBlock=false;
+      bool bIsVertexDataBlock=false;
+      if(!(bIsTrackSegDataBlock=(iter->fDataType==AliHLTTPCDefinitions::fgkTrackSegmentsDataType)) &&
+        !(bIsVertexDataBlock=(iter->fDataType==AliHLTTPCDefinitions::fgkVertexDataType))){
+       continue;
+      }
+
       slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
       slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
+      if (slice<0 || slice>=AliHLTTPCTransform::GetNSlice()) {
+       HLTError("invalid slice number %d extracted from specification 0x%08lx,  skipping block of type %s",
+                slice, iter->fSpecification, DataType2Text(iter->fDataType).c_str());
+       // just remember the error, if there are other valid blocks ignore the
+       // error, return code otherwise
+       iResult=-EBADF;
+       continue;
+      }
+      if (slice!=AliHLTTPCDefinitions::GetMaxSliceNr( *iter )) {
+       // the code was not written for/ never used with multiple slices
+       // in one data block/ specification
+       HLTWarning("specification 0x%08lx indicates multiple slices in data block %s: never used before, please audit the code",
+                  iter->fSpecification, DataType2Text(iter->fDataType).c_str());
+      }
       found=false;
       sdIter = slices.begin();
       sdEnd = slices.end();
       found=false;
       sdIter = slices.begin();
       sdEnd = slices.end();
@@ -184,7 +201,7 @@ int AliHLTTPCGlobalMergerComponent::DoEvent( const AliHLTComponentEventData& evt
        }
       if ( sdIter->fSlice == slice )
        {
        }
       if ( sdIter->fSlice == slice )
        {
-         if ( iter->fDataType == AliHLTTPCDefinitions::fgkTrackSegmentsDataType )
+         if (bIsTrackSegDataBlock)
            {
              if ( !sdIter->fTrackletBlock )
                {
            {
              if ( !sdIter->fTrackletBlock )
                {
@@ -198,7 +215,7 @@ int AliHLTTPCGlobalMergerComponent::DoEvent( const AliHLTComponentEventData& evt
                           slice, evtData.fEventID, evtData.fEventID, sdIter->fTrackletBlockIndex, ndx );
                }
            }
                           slice, evtData.fEventID, evtData.fEventID, sdIter->fTrackletBlockIndex, ndx );
                }
            }
-         if ( iter->fDataType == AliHLTTPCDefinitions::fgkVertexDataType )
+         if (bIsVertexDataBlock)
            {
              lastVertexBlock = iter;
              if ( !sdIter->fVertexBlock )
            {
              lastVertexBlock = iter;
              if ( !sdIter->fVertexBlock )
@@ -216,6 +233,12 @@ int AliHLTTPCGlobalMergerComponent::DoEvent( const AliHLTComponentEventData& evt
        }
     }
 
        }
     }
 
+  // skip the processing if there was no track segment data
+  if (slices.size()==0) {
+    return iResult;
+  }
+  iResult=0;
+
   //fGlobalMerger->Setup( minSlice, maxSlice );
   fGlobalMerger->Setup( 0, 35 );
 
   //fGlobalMerger->Setup( minSlice, maxSlice );
   fGlobalMerger->Setup( 0, 35 );
 
@@ -268,7 +291,7 @@ int AliHLTTPCGlobalMergerComponent::DoEvent( const AliHLTComponentEventData& evt
 
   // check if there was enough space in the output buffer
   UInt_t ntracks0=fGlobalMerger->GetOutTracks()->GetNTracks();
 
   // check if there was enough space in the output buffer
   UInt_t ntracks0=fGlobalMerger->GetOutTracks()->GetNTracks();
-  if (outputPtr==NULL || (sizeof(AliHLTTPCTrackletData)+ntracks0*sizeof(AliHLTTPCTrackSegmentData)>size)) {
+  if (outputPtr==NULL || (sizeof(AliHLTTPCTrackletData)+ntracks0*sizeof(AliHLTTPCTrackSegmentData)>capacity)) {
     iResult=-ENOSPC;
   } else {
   outPtr = (AliHLTTPCTrackletData*)(outputPtr);
     iResult=-ENOSPC;
   } else {
   outPtr = (AliHLTTPCTrackletData*)(outputPtr);
index ebc02d7fc368e8872ee053a9cfa698129fedf692..164cd11797656f56616e1ed5c0d4e9ca44304806 100644 (file)
@@ -1,21 +1,21 @@
 // $Id$
 
 // $Id$
 
-/**************************************************************************
- * This file is property of and copyright by the ALICE HLT Project        * 
- * ALICE Experiment at CERN, All rights reserved.                         *
- *                                                                        *
- * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
- *                  Timm Steinbeck <timm@kip.uni-heidelberg.de>           *
- *                  for The ALICE HLT Project.                            *
- *                                                                        *
- * Permission to use, copy, modify and distribute this software and its   *
- * documentation strictly for non-commercial purposes is hereby granted   *
- * without fee, provided that the above copyright notice appears in all   *
- * copies and that both the copyright notice and this permission notice   *
- * appear in the supporting documentation. The authors make no claims     *
- * about the suitability of this software for any purpose. It is          *
- * provided "as is" without express or implied warranty.                  *
- **************************************************************************/
+//**************************************************************************
+//* This file is property of and copyright by the ALICE HLT Project        * 
+//* ALICE Experiment at CERN, All rights reserved.                         *
+//*                                                                        *
+//* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
+//*                  Timm Steinbeck <timm@kip.uni-heidelberg.de>           *
+//*                  for The ALICE HLT Project.                            *
+//*                                                                        *
+//* Permission to use, copy, modify and distribute this software and its   *
+//* documentation strictly for non-commercial purposes is hereby granted   *
+//* without fee, provided that the above copyright notice appears in all   *
+//* copies and that both the copyright notice and this permission notice   *
+//* appear in the supporting documentation. The authors make no claims     *
+//* about the suitability of this software for any purpose. It is          *
+//* provided "as is" without express or implied warranty.                  *
+//**************************************************************************
 
 /** @file   AliHLTTPCSliceTrackerComponent.cxx
     @author Timm Steinbeck, Matthias Richter
 
 /** @file   AliHLTTPCSliceTrackerComponent.cxx
     @author Timm Steinbeck, Matthias Richter
     @brief  The TPC conformal mapping tracker component.
 */
 
     @brief  The TPC conformal mapping tracker component.
 */
 
-// see header file for class documentation
-// or
-// refer to README to build package
-// or
-// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
-
 #if __GNUC__>= 3
 using namespace std;
 #endif
 #if __GNUC__>= 3
 using namespace std;
 #endif
@@ -417,9 +411,12 @@ int AliHLTTPCSliceTrackerComponent::DoDeinit()
 int AliHLTTPCSliceTrackerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, 
                                              AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, 
                                              AliHLTUInt32_t& size, AliHLTComponentBlockDataList& outputBlocks )
 int AliHLTTPCSliceTrackerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, 
                                              AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, 
                                              AliHLTUInt32_t& size, AliHLTComponentBlockDataList& outputBlocks )
-    {
+{
   // see header file for class documentation
   // see header file for class documentation
-    Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoEvent", "DoEvent", "DoEvent()" );
+  int iResult=0;
+  AliHLTUInt32_t capacity=size;
+  size=0;
+
     if ( evtData.fBlockCnt<=0 )
       {
        Logging( kHLTLogWarning, "HLT::TPCSliceTracker::DoEvent", "DoEvent", "no blocks in event" );
     if ( evtData.fBlockCnt<=0 )
       {
        Logging( kHLTLogWarning, "HLT::TPCSliceTracker::DoEvent", "DoEvent", "no blocks in event" );
@@ -454,12 +451,28 @@ int AliHLTTPCSliceTrackerComponent::DoEvent( const AliHLTComponentEventData& evt
        {
        iter = blocks+ndx;
 
        {
        iter = blocks+ndx;
 
-       if(iter->fDataType!=AliHLTTPCDefinitions::fgkClustersDataType){
-         HLTDebug("Data block type is not of type AliHLTTPCDefinitions::fgkClustersDataType");
+       bool bIsClusterDataBlock=false;
+       bool bIsVertexDataBlock=false;
+       if(!(bIsClusterDataBlock=(iter->fDataType==AliHLTTPCDefinitions::fgkClustersDataType)) &&
+          !(bIsVertexDataBlock=(iter->fDataType==AliHLTTPCDefinitions::fgkVertexDataType))){
          continue;
        }
 
        slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
          continue;
        }
 
        slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
+       if (slice<0 || slice>=AliHLTTPCTransform::GetNSlice()) {
+         HLTError("invalid slice number %d extracted from specification 0x%08lx,  skipping block of type %s",
+                  slice, iter->fSpecification, DataType2Text(iter->fDataType).c_str());
+         // just remember the error, if there are other valid blocks ignore the
+         // error, return code otherwise
+         iResult=-EBADF;
+         continue;
+       }
+       if (slice!=AliHLTTPCDefinitions::GetMaxSliceNr( *iter )) {
+         // the code was not written for/ never used with multiple slices
+         // in one data block/ specification
+         HLTWarning("specification 0x%08lx indicates multiple slices in data block %s: never used before, please audit the code",
+                    iter->fSpecification, DataType2Text(iter->fDataType).c_str());
+       }
        found = false;
        slIter = slices.begin();
        slEnd = slices.end();
        found = false;
        slIter = slices.begin();
        slEnd = slices.end();
@@ -482,7 +495,7 @@ int AliHLTTPCSliceTrackerComponent::DoEvent( const AliHLTComponentEventData& evt
        else
            *slCntIter++;
 
        else
            *slCntIter++;
 
-       if ( iter->fDataType == AliHLTTPCDefinitions::fgkVertexDataType )
+       if (bIsVertexDataBlock)
            {
            inPtrV = (AliHLTTPCVertexData*)(iter->fPtr);
            vertexIter = iter;
            {
            inPtrV = (AliHLTTPCVertexData*)(iter->fPtr);
            vertexIter = iter;
@@ -490,7 +503,7 @@ int AliHLTTPCSliceTrackerComponent::DoEvent( const AliHLTComponentEventData& evt
            fVertex->Read( inPtrV );
            vertexSlice = slice;
            }
            fVertex->Read( inPtrV );
            vertexSlice = slice;
            }
-       if ( iter->fDataType == AliHLTTPCDefinitions::fgkClustersDataType )
+       if (bIsClusterDataBlock)
            {
            patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
            if ( minPatch>patch )
            {
            patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
            if ( minPatch>patch )
@@ -537,9 +550,13 @@ int AliHLTTPCSliceTrackerComponent::DoEvent( const AliHLTComponentEventData& evt
       }
     else
       {
       }
     else
       {
-       slice = -1;
+       // there is no sense in running the tracker without input, do not send an
+       // empty output block
+       return iResult;
       }
     
       }
     
+    iResult=0;
+
     if ( vertexSlice != slice )
        {
        // multiple vertex blocks in event and we used the wrong one...
     if ( vertexSlice != slice )
        {
        // multiple vertex blocks in event and we used the wrong one...
@@ -594,7 +611,6 @@ int AliHLTTPCSliceTrackerComponent::DoEvent( const AliHLTComponentEventData& evt
        pIter++;
        }
 
        pIter++;
        }
 
-    outPtr = (AliHLTTPCTrackletData*)(outBPtr);
 
     if ( fmainvertextracking == kTRUE && fnonvertextracking == kFALSE){        
       Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoEvent", "Tracking", " ---MAINVERTEXTRACKING---");
 
     if ( fmainvertextracking == kTRUE && fnonvertextracking == kFALSE){        
       Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoEvent", "Tracking", " ---MAINVERTEXTRACKING---");
@@ -629,6 +645,8 @@ int AliHLTTPCSliceTrackerComponent::DoEvent( const AliHLTComponentEventData& evt
     } 
     ntracks0=0;
     AliHLTTPCTrackArray* pArray=fTracker->GetTracks();
     } 
     ntracks0=0;
     AliHLTTPCTrackArray* pArray=fTracker->GetTracks();
+    if (pArray->GetOutSize()+sizeof(AliHLTTPCTrackletData)<=capacity) {
+    outPtr = (AliHLTTPCTrackletData*)(outBPtr);
     mysize = pArray->WriteTracks( ntracks0, outPtr->fTracklets );
     outPtr->fTrackletCnt = ntracks0;
 
     mysize = pArray->WriteTracks( ntracks0, outPtr->fTracklets );
     outPtr->fTrackletCnt = ntracks0;
 
@@ -638,16 +656,19 @@ int AliHLTTPCSliceTrackerComponent::DoEvent( const AliHLTComponentEventData& evt
 
     fTracker->Reset();
 
 
     fTracker->Reset();
 
-    tSize += mysize+sizeof(AliHLTTPCTrackletData);
-    outBPtr += mysize+sizeof(AliHLTTPCTrackletData);
-    
     AliHLTComponentBlockData bd;
     FillBlockData( bd );
     bd.fOffset = offset;
     AliHLTComponentBlockData bd;
     FillBlockData( bd );
     bd.fOffset = offset;
-    bd.fSize = tSize;
+    bd.fSize = mysize+sizeof(AliHLTTPCTrackletData);
     bd.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, minPatch, maxPatch );
     outputBlocks.push_back( bd );
 
     bd.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, minPatch, maxPatch );
     outputBlocks.push_back( bd );
 
+    tSize += bd.fSize;
+    outBPtr += bd.fSize;
+    } else {
+      iResult=-ENOSPC;
+    }
+
 #ifdef FORWARD_VERTEX_BLOCK
     if ( vertexIter )
        {
 #ifdef FORWARD_VERTEX_BLOCK
     if ( vertexIter )
        {
@@ -658,7 +679,7 @@ int AliHLTTPCSliceTrackerComponent::DoEvent( const AliHLTComponentEventData& evt
 #endif // FORWARD_VERTEX_BLOCK
 
     size = tSize;
 #endif // FORWARD_VERTEX_BLOCK
 
     size = tSize;
-    return 0;
+    return iResult;
     }
 
 int AliHLTTPCSliceTrackerComponent::Configure(const char* arguments)
     }
 
 int AliHLTTPCSliceTrackerComponent::Configure(const char* arguments)