]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/util/AliHLTBlockFilterComponent.cxx
tracking at slice borders improved
[u/mrichter/AliRoot.git] / HLT / BASE / util / AliHLTBlockFilterComponent.cxx
index 1366fab7a626777cf4db3469d5f9b08904f32f69..191c71bf02bf00a5cd1ed10d33788681b7a40644 100644 (file)
@@ -1,32 +1,26 @@
-// @(#) $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>        *
- *                  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.                  *
- **************************************************************************/
+// $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>        *
+//*                  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   AliHLTBlockFilterComponent.cxx
     @author Matthias Richter
     @date   
     @brief  A simple data block filter and merger, merges block descriptors
-
-                                                                          */
-// see header file for class documentation
-// or
-// refer to README to build package
-// or
-// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+*/
 
 #include <cstdlib>
 #include "AliHLTBlockFilterComponent.h"
 ClassImp(AliHLTBlockFilterComponent)
 
 AliHLTBlockFilterComponent::AliHLTBlockFilterComponent()
-  :
-  fFilterRules()
+  : AliHLTProcessor()
+  , fFilterRules()
+  , fPrescalar(0)
+  , fFirstEvent(0)
 {
   // see header file for class documentation
   // or
@@ -62,7 +58,7 @@ AliHLTComponentDataType AliHLTBlockFilterComponent::GetOutputDataType()
 {
   // see header file for class documentation
   if (fFilterRules.size()==1) return fFilterRules[0].fDataType;
-  if (fFilterRules.size()==0) return kAliHLTVoidDataType;
+  if (fFilterRules.size()==0) return kAliHLTAnyDataType;
   return kAliHLTMultipleDataType;
 }
 
@@ -105,7 +101,7 @@ int AliHLTBlockFilterComponent::DoInit( int argc, const char** argv )
     if (argument.CompareTo("-datatype")==0) {
       if ((bMissingParam=(i+2>=argc))) break;
 
-      if (rule.fDataType!=kAliHLTAnyDataType) {
+      if (!MatchExactly(rule.fDataType,kAliHLTAnyDataType)) {
        // the data type has already been set, add to list
        // and reset
        fFilterRules.push_back(rule);
@@ -115,6 +111,34 @@ int AliHLTBlockFilterComponent::DoInit( int argc, const char** argv )
       SetDataType(rule.fDataType, argv[i+1], argv[i+2]);
       i+=2;
 
+      // -origin
+    } else if (argument.CompareTo("-origin")==0) {
+      if ((bMissingParam=(i+1>=argc))) break;
+
+      if (!MatchExactly(rule.fDataType,kAliHLTAnyDataType)) {
+       // the data type has already been set, add to list
+       // and reset
+       fFilterRules.push_back(rule);
+       FillBlockData(rule);
+      }
+
+      SetDataType(rule.fDataType, NULL, argv[i+1]);
+      i+=1;
+
+      // -typeid
+    } else if (argument.CompareTo("-typeid")==0) {
+      if ((bMissingParam=(i+1>=argc))) break;
+
+      if (!MatchExactly(rule.fDataType,kAliHLTAnyDataType)) {
+       // the data type has already been set, add to list
+       // and reset
+       fFilterRules.push_back(rule);
+       FillBlockData(rule);
+      }
+
+      SetDataType(rule.fDataType, argv[i+1], NULL);
+      i+=1;
+
       // -dataspec
     } else if (argument.CompareTo("-dataspec")==0) {
       if ((bMissingParam=(++i>=argc))) break;
@@ -134,13 +158,23 @@ int AliHLTBlockFilterComponent::DoInit( int argc, const char** argv )
        HLTError("invalid parameter/remnant (%s) for argument %s, number expected", pRemnant, argument.Data());
        iResult=-EINVAL;
       }
+      // -prescalar
+    } else if (argument.CompareTo("-prescalar")==0) {
+      if ((bMissingParam=(++i>=argc))) break;
+      TString parameter(argv[i]);
+      fPrescalar=parameter.Atoi();
+      // -skip-events
+    } else if (argument.CompareTo("-skip-events")==0) {
+      if ((bMissingParam=(++i>=argc))) break;
+      TString parameter(argv[i]);
+      fFirstEvent=parameter.Atoi();
     } else {
       HLTError("unknown argument %s", argument.Data());
       iResult=-EINVAL;
       break;
     }
   }
-  if (iResult>=0 && (rule.fSpecification!=kAliHLTVoidDataSpec || rule.fDataType!=kAliHLTAnyDataType)) {
+  if (iResult>=0 && (rule.fSpecification!=kAliHLTVoidDataSpec || !MatchExactly(rule.fDataType,kAliHLTAnyDataType))) {
     // add the pending rule
     fFilterRules.push_back(rule);
     FillBlockData(rule);
@@ -155,15 +189,17 @@ int AliHLTBlockFilterComponent::DoDeinit()
   return iResult;
 }
 
-int AliHLTBlockFilterComponent::DoEvent( const AliHLTComponentEventData& evtData,
-                                        const AliHLTComponentBlockData* blocks
+int AliHLTBlockFilterComponent::DoEvent( const AliHLTComponentEventData& /*evtData*/,
+                                        const AliHLTComponentBlockData* /*blocks*/
                                         AliHLTComponentTriggerData& /*trigData*/,
                                         AliHLTUInt8_t* /*outputPtr*/, 
                                         AliHLTUInt32_t& size,
-                                        AliHLTComponentBlockDataList& outputBlocks )
+                                        AliHLTComponentBlockDataList& /*outputBlocks*/ )
 {
   // see header file for class documentation
   int iResult=0;
+  if ((fPrescalar==0 || ((GetEventCount())%fPrescalar)==0) &&
+      GetEventCount()>=(int)fFirstEvent) {
   for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock();
        pBlock!=NULL; 
        pBlock=GetNextInputBlock()) {
@@ -176,16 +212,7 @@ int AliHLTBlockFilterComponent::DoEvent( const AliHLTComponentEventData& evtData
       HLTDebug("block type %s %#x discarded by filter rules", DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification);
     }
   }
-//   for (int n=0; n<(int)evtData.fBlockCnt; n++ ) {
-//     if (IsSelected(blocks[n])) {
-//       HLTDebug("block %d type %s %#x (ptr=%p offset=%d size=%d) selected by filter rules", 
-//            n, DataType2Text(blocks[n].fDataType).c_str(), blocks[n].fSpecification, 
-//            blocks[n].fPtr, blocks[n].fOffset, blocks[n].fSize);
-//       outputBlocks.push_back(blocks[n]);
-//     } else {
-//       HLTDebug("block %d type %s %#x discarded by filter rules", n, DataType2Text(blocks[n].fDataType).c_str(), blocks[n].fSpecification);
-//     }
-//   }
+  }
   size=0;
   return iResult;
 }
@@ -202,9 +229,9 @@ int AliHLTBlockFilterComponent::IsSelected(const AliHLTComponentBlockData& block
     // 2. data spec match or filter data wpec not set
     // 3. either filter data type or spec is set
     //HLTDebug("check rule : %s spec %#x", DataType2Text((*desc).fDataType, 2).c_str(), block.fSpecification);
-    if (((*desc).fDataType==block.fDataType || (*desc).fDataType==kAliHLTAnyDataType) &&
+    if (((*desc).fDataType==block.fDataType) &&
        ((*desc).fSpecification==block.fSpecification || (*desc).fSpecification==kAliHLTVoidDataSpec) &&
-       ((*desc).fDataType!=kAliHLTAnyDataType || (*desc).fSpecification!=kAliHLTVoidDataSpec)) {
+       (!MatchExactly((*desc).fDataType,kAliHLTAnyDataType) || (*desc).fSpecification!=kAliHLTVoidDataSpec)) {
       return 1;
     }
   } while (++desc!=fFilterRules.end());