]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/TPCLib/AliHLTTPCGlobalMergerComponent.cxx
Adding TDC histos
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCGlobalMergerComponent.cxx
index 7c066985c5ab21f52589f975bd78e877459a425c..db322e267f14524a2cfbc45871b61817ca4c0bb2 100644 (file)
@@ -1,21 +1,21 @@
 // $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
     @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"
-//#include "AliHLTTPCTransform.h"
+#include "AliHLTTPCTransform.h"
 #include "AliHLTTPCGlobalMerger.h"
 #include "AliHLTTPCVertex.h"
 #include "AliHLTTPCVertexData.h"
@@ -138,6 +133,12 @@ int AliHLTTPCGlobalMergerComponent::DoEvent( const AliHLTComponentEventData& evt
                                              AliHLTUInt32_t& size, AliHLTComponentBlockDataList& outputBlocks )
 {
   // see header file for class documentation
+  int iResult=0;
+  AliHLTUInt32_t capacity=size;
+  size=0;
+
+  if (!IsDataEvent()) return 0;
+
   const AliHLTComponentBlockData* iter = NULL;
   const AliHLTComponentBlockData* lastVertexBlock = NULL;
   unsigned long ndx;
@@ -156,7 +157,28 @@ int AliHLTTPCGlobalMergerComponent::DoEvent( const AliHLTComponentEventData& evt
   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 );
+      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();
@@ -182,7 +204,7 @@ int AliHLTTPCGlobalMergerComponent::DoEvent( const AliHLTComponentEventData& evt
        }
       if ( sdIter->fSlice == slice )
        {
-         if ( iter->fDataType == AliHLTTPCDefinitions::fgkTrackSegmentsDataType )
+         if (bIsTrackSegDataBlock)
            {
              if ( !sdIter->fTrackletBlock )
                {
@@ -196,7 +218,7 @@ int AliHLTTPCGlobalMergerComponent::DoEvent( const AliHLTComponentEventData& evt
                           slice, evtData.fEventID, evtData.fEventID, sdIter->fTrackletBlockIndex, ndx );
                }
            }
-         if ( iter->fDataType == AliHLTTPCDefinitions::fgkVertexDataType )
+         if (bIsVertexDataBlock)
            {
              lastVertexBlock = iter;
              if ( !sdIter->fVertexBlock )
@@ -214,6 +236,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 );
 
@@ -264,7 +292,11 @@ int AliHLTTPCGlobalMergerComponent::DoEvent( const AliHLTComponentEventData& evt
   fGlobalMerger->Merge();
   fGlobalMerger->AddAllTracks();
 
-  UInt_t ntracks0=0;
+  // check if there was enough space in the output buffer
+  UInt_t ntracks0=fGlobalMerger->GetOutTracks()->GetNTracks();
+  if (outputPtr==NULL || (sizeof(AliHLTTPCTrackletData)+ntracks0*sizeof(AliHLTTPCTrackSegmentData)>capacity)) {
+    iResult=-ENOSPC;
+  } else {
   outPtr = (AliHLTTPCTrackletData*)(outputPtr);
 
   tSize = fGlobalMerger->GetOutTracks()->WriteTracks( ntracks0, outPtr->fTracklets );
@@ -278,9 +310,10 @@ int AliHLTTPCGlobalMergerComponent::DoEvent( const AliHLTComponentEventData& evt
   bd.fSize = tSize;
   bd.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( minSlice, maxSlice, 0, 5 );
   outputBlocks.push_back( bd );
+  }
 
   size = tSize;
-  return 0;
+  return iResult;
 }