]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Adding event modulo option to all components.
authoraszostak <aszostak@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 8 Nov 2011 18:55:20 +0000 (18:55 +0000)
committeraszostak <aszostak@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 8 Nov 2011 18:55:20 +0000 (18:55 +0000)
HLT/BASE/AliHLTComponent.cxx
HLT/BASE/AliHLTComponent.h

index c9e982126eae0f862f910b164476613f9ccaf5e3..a8d4f78faaae8a13f7af4bf1c29baef1a132a12f 100644 (file)
@@ -102,7 +102,8 @@ AliHLTComponent::AliHLTComponent()
   , fLastObjectSize(0)
   , fpCTPData(NULL)
   , fPushbackPeriod(0)
-  , fLastPushBackTime(-1)
+  , fLastPushBackTime(-1),
+  fEventModulo(-1)
 {
   // see header file for class documentation
   // or
@@ -245,6 +246,19 @@ int AliHLTComponent::Init(const AliHLTAnalysisEnvironment* comenv, void* environ
          } else {
            HLTError("wrong parameter for argument -pushback-period, number expected");
          }
+         // -event-modulo
+       } else if (argument.BeginsWith("-event-modulo=")) {
+         argument.ReplaceAll("-event-modulo=", "");
+         if (argument.IsDigit()) {
+           fEventModulo=argument.Atoi();
+           if (fEventModulo < 1)
+           {
+             fEventModulo = -1;
+             HLTError("number passed in -event-modulo must be a positive integer greater or equal to 1.");
+           }
+         } else {
+           HLTError("wrong parameter for argument -event-modulo, integer number expected");
+         }
          // -disable-component-stat
        } else if (argument.CompareTo("-disable-component-stat")==0) {
          fFlags|=kDisableComponentStat;
@@ -2054,6 +2068,15 @@ int AliHLTComponent::ProcessEvent( const AliHLTComponentEventData& evtData,
     // increment CTP trigger counters if available
     if (IsDataEvent()) fpCTPData->Increment(trigData);
   }
+  
+  // Check if the event processing should be skipped because of the
+  // down scaling from the event modulo argument. Using a prime number
+  // as pre divisor to pseudo-randomise the event number to get a more
+  // uniform distribution.
+  if (fEventModulo > 1)
+  {
+    bSkipDataProcessing |= ( ((AliHLTUInt64_t(fCurrentEvent) / AliHLTUInt64_t(4789)) % AliHLTUInt64_t(fEventModulo)) == 0 );
+  }
 
   AliHLTComponentBlockDataList blockData;
   if (iResult>=0 && !bSkipDataProcessing)
index c444fe35d3905c948342d070daf30b06ffce0486..ed63b4e5d794a3aa72eb077908adfd0d3fe358dd 100644 (file)
@@ -382,6 +382,10 @@ typedef vector<AliHLTMemoryFile*>         AliHLTMemoryFilePList;
  * \li -pushback-period=period     <br>
  *      scale down for PushBack of objects, shipped only for one event
  *      every <i>period</i> seconds
+ * \li -event-module=number     <br>
+ *      This option reduces the event processing rate by processing only n'th event
+ *      based on the modulo number <i>number</i>. The scale down should be about
+ *      1/<i>number</i>, where <i>number</i> is a positive integer.
  *
  * @ingroup alihlt_component
  * @section alihltcomponent-members Class members
@@ -1819,6 +1823,9 @@ class AliHLTComponent : public AliHLTLogging {
   int fPushbackPeriod;                                             //! transient
   /// time of last executed PushBack
   int fLastPushBackTime;                                           //! transient
+  
+  /// Event modulo for down scaling the processing rate.
+  int fEventModulo;                                                //! transient
 
   ClassDef(AliHLTComponent, 0)
 };