]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
- randomize seed of DataGenerator by using ChainId CRC value
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 15 Jan 2009 11:17:35 +0000 (11:17 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 15 Jan 2009 11:17:35 +0000 (11:17 +0000)
- extended CompStatCollector to fill branches with input/output ration etc.
- rec-hlt-tpc.C: added optional CompStatCollector
- added helper macro to post-format compstat raw data block
- added macro for HLT chain benchmark using DataGenerator

HLT/BASE/util/AliHLTCompStatCollector.cxx
HLT/BASE/util/AliHLTCompStatCollector.h
HLT/BASE/util/AliHLTDataGenerator.cxx
HLT/TPCLib/macros/rec-hlt-tpc.C
HLT/benchmark/macros/bench-hlt-hierarchy.C [new file with mode: 0644]
HLT/benchmark/macros/format-statistics.C [new file with mode: 0644]

index bb2cd9641e44d26de6ebb4cb60290819f58f01d8..456848c57fd06754b7aebbaea6c961fa942594cb 100644 (file)
@@ -64,8 +64,11 @@ AliHLTCompStatCollector::AliHLTCompStatCollector()
   fpCTimeArray(NULL),
   fpInputBlockCountArray(NULL),
   fpTotalInputSizeArray(NULL),
+  fpNormalizedInputSizeArray(NULL),
   fpOutputBlockCountArray(NULL),
   fpTotalOutputSizeArray(NULL)
+  , fpInputOutputRatioArray(NULL)
+  , fpNormalizedInputOutputRatioArray(NULL)
   , fpComponentCycleTimeArray(NULL)
   , fpEventTypeArray(NULL)
   , fpEventCountArray(NULL)
@@ -171,6 +174,18 @@ int AliHLTCompStatCollector::DoInit( int argc, const char** argv )
        HLTError("expecting number as parameter for option %s", argument.Data());
        iResult=-EINVAL;
       }
+
+    // -arraysize
+    } else if (argument.CompareTo("-arraysize")==0) {
+      if ((bMissingParam=(++i>=argc))) break;
+      TString param=argv[i];
+      if (param.IsDigit()) {
+       fArraySize=param.Atoi();
+      } else {
+       HLTError("expecting number as parameter for option %s", argument.Data());
+       iResult=-EINVAL;
+      }
+
     } else {
       HLTError("unknown argument %s", argument.Data());
       iResult=-EINVAL;
@@ -190,8 +205,11 @@ int AliHLTCompStatCollector::DoInit( int argc, const char** argv )
     fpCTimeArray=new UInt_t[fArraySize];
     fpInputBlockCountArray=new UInt_t[fArraySize];
     fpTotalInputSizeArray=new UInt_t[fArraySize];
+    fpNormalizedInputSizeArray=new UInt_t[fArraySize];
     fpOutputBlockCountArray=new UInt_t[fArraySize];
     fpTotalOutputSizeArray=new UInt_t[fArraySize];
+    fpInputOutputRatioArray=new UInt_t[fArraySize];
+    fpNormalizedInputOutputRatioArray=new UInt_t[fArraySize];
     fpComponentCycleTimeArray=new UInt_t[fArraySize];
     fpEventTypeArray=new UInt_t[fArraySize];
     fpEventCountArray=new UInt_t[fArraySize];
@@ -209,8 +227,11 @@ int AliHLTCompStatCollector::DoInit( int argc, const char** argv )
       fpStatTree->Branch("CTime",            fpCTimeArray, "CTime[nofSets]/i");
       fpStatTree->Branch("InputBlockCount",  fpInputBlockCountArray, "InputBlockCount[nofSets]/i");
       fpStatTree->Branch("TotalInputSize",   fpTotalInputSizeArray, "TotalInputSize[nofSets]/i");
+      fpStatTree->Branch("NormalizedInputSize",   fpNormalizedInputSizeArray, "NormalizedInputSize[nofSets]/i");
       fpStatTree->Branch("OutputBlockCount", fpOutputBlockCountArray, "OutputBlockCount[nofSets]/i");
       fpStatTree->Branch("TotalOutputSize",  fpTotalOutputSizeArray, "TotalOutputSize[nofSets]/i");
+      fpStatTree->Branch("InputOutputRatio",  fpInputOutputRatioArray, "InputOutputRatio[nofSets]/i");
+      fpStatTree->Branch("NormalizedInputOutputRatio",  fpNormalizedInputOutputRatioArray, "NormalizedInputOutputRatio[nofSets]/i");
       fpStatTree->Branch("ComponentCycleTime",fpComponentCycleTimeArray, "ComponentCycleTime[nofSets]/i");
       fpStatTree->Branch("EventType",fpEventTypeArray, "EventType[nofSets]/i");
       fpStatTree->Branch("EventCount",fpEventCountArray, "EventCount[nofSets]/i");
@@ -453,8 +474,11 @@ void AliHLTCompStatCollector::ResetFillingVariables()
   memset(fpCTimeArray, 0, sizeof(UInt_t)*fArraySize);
   memset(fpInputBlockCountArray, 0, sizeof(UInt_t)*fArraySize);
   memset(fpTotalInputSizeArray, 0, sizeof(UInt_t)*fArraySize);
+  memset(fpNormalizedInputSizeArray, 0, sizeof(UInt_t)*fArraySize);
   memset(fpOutputBlockCountArray, 0, sizeof(UInt_t)*fArraySize);
   memset(fpTotalOutputSizeArray, 0, sizeof(UInt_t)*fArraySize);
+  memset(fpInputOutputRatioArray, 0, sizeof(UInt_t)*fArraySize);
+  memset(fpNormalizedInputOutputRatioArray, 0, sizeof(UInt_t)*fArraySize);
   memset(fpComponentCycleTimeArray, 0, sizeof(UInt_t)*fArraySize);
   memset(fpEventTypeArray, 0, sizeof(UInt_t)*fArraySize);
   memset(fpEventCountArray, 0, sizeof(UInt_t)*fArraySize);
@@ -495,8 +519,15 @@ int AliHLTCompStatCollector::FillVariablesSorted(void* ptr, int size, AliHLTUInt
       fpCTimeArray[i]=pStat[*element].fCTime;
       fpInputBlockCountArray[i]=pStat[*element].fInputBlockCount;
       fpTotalInputSizeArray[i]=pStat[*element].fTotalInputSize;
+      fpNormalizedInputSizeArray[i]=pStat[*element].fTotalInputSize;
+      if (pStat[*element].fInputBlockCount>0) 
+       fpNormalizedInputSizeArray[i]/=pStat[*element].fInputBlockCount;
       fpOutputBlockCountArray[i]=pStat[*element].fOutputBlockCount;
       fpTotalOutputSizeArray[i]=pStat[*element].fTotalOutputSize;
+      if (pStat[*element].fTotalOutputSize>0)
+       fpInputOutputRatioArray[i]=pStat[*element].fTotalInputSize/pStat[*element].fTotalOutputSize;
+      if (pStat[*element].fInputBlockCount>0)
+       fpNormalizedInputOutputRatioArray[i]=fpInputOutputRatioArray[i]*pStat[*element].fOutputBlockCount/pStat[*element].fInputBlockCount;
       fpComponentCycleTimeArray[i]=pStat[*element].fComponentCycleTime;
       fpEventTypeArray[i]=eventType;
       fpEventCountArray[i]=GetEventCount();
@@ -529,8 +560,11 @@ void AliHLTCompStatCollector::ClearAll()
   if (fpCTimeArray) delete fpCTimeArray; fpCTimeArray=NULL;
   if (fpInputBlockCountArray) delete fpInputBlockCountArray; fpInputBlockCountArray=NULL;
   if (fpTotalInputSizeArray) delete fpTotalInputSizeArray; fpTotalInputSizeArray=NULL;
+  if (fpNormalizedInputSizeArray) delete fpNormalizedInputSizeArray; fpNormalizedInputSizeArray=NULL;
   if (fpOutputBlockCountArray) delete fpOutputBlockCountArray; fpOutputBlockCountArray=NULL;
   if (fpTotalOutputSizeArray) delete fpTotalOutputSizeArray; fpTotalOutputSizeArray=NULL;
+  if (fpInputOutputRatioArray) delete fpInputOutputRatioArray; fpInputOutputRatioArray=NULL;
+  if (fpNormalizedInputOutputRatioArray) delete fpNormalizedInputOutputRatioArray; fpNormalizedInputOutputRatioArray=NULL;
   if (fpComponentCycleTimeArray) delete fpComponentCycleTimeArray; fpComponentCycleTimeArray=NULL;
   if (fpEventTypeArray) delete fpEventTypeArray; fpEventTypeArray=NULL;
   if (fpEventCountArray) delete fpEventCountArray; fpEventCountArray=NULL;
index 74fba1251ec9338bdcbe8891e0883f3e12547f1f..f4739ee1de8386588f1b47c6546755295c73f5a4 100644 (file)
@@ -178,10 +178,16 @@ class AliHLTCompStatCollector : public AliHLTProcessor
   /** branch filling variable */
   UInt_t* fpTotalInputSizeArray; //!transient
   /** branch filling variable */
+  UInt_t* fpNormalizedInputSizeArray; //!transient
+  /** branch filling variable */
   UInt_t* fpOutputBlockCountArray; //!transient
   /** branch filling variable */
   UInt_t* fpTotalOutputSizeArray; //!transient
   /** branch filling variable */
+  UInt_t* fpInputOutputRatioArray; //!transient
+  /** branch filling variable */
+  UInt_t* fpNormalizedInputOutputRatioArray; //!transient
+  /** branch filling variable */
   UInt_t* fpComponentCycleTimeArray; //!transient
   /** branch filling variable */
   UInt_t* fpEventTypeArray; //!transient
index ace2a9626bef9a62503adb35ef703a17d06c3d64..d1c21e94ac8fd1231fd43c96e82854414efbb784 100644 (file)
@@ -240,8 +240,10 @@ int AliHLTDataGenerator::DoInit( int argc, const char** argv )
     fpDice=new TRandom;
     if (fpDice) {
       TDatime dt;
-      // just take the pointer value as seed combined with time 
-      unsigned int seed=0;//(int)(this);
+      // take a component specific property together with the time to
+      // create a seed
+      const char* chainId=GetChainId();
+      unsigned int seed=CalculateChecksum((const AliHLTUInt8_t*)chainId, strlen(chainId));
       fpDice->SetSeed(seed^dt.Get());
     } else {
        iResult=-ENOMEM;
index 13a5dc729b66dde85a0bdf5d8f7be3e1d9934a38..7a789fe41252360231629d15b512995db865ca3b 100644 (file)
@@ -72,7 +72,19 @@ void rec_hlt_tpc(const char* input="./", char* opt="decoder ESD")
     for (int i=0; i<pTokens->GetEntries(); i++) {
       argument=((TObjString*)pTokens->At(i))->GetString();
       if (argument.IsNull()) continue;
-    
+      if (argument.Contains("-statistics=")) {
+       argument.ReplaceAll("-statistics=", "");
+       if (argument.Contains("root")) {
+         if (option.Length()>0) option+=",";
+         option+="statroot";
+       }
+       if (argument.Contains("raw")) {
+         if (option.Length()>0) option+=",";
+         option+="statraw";
+       }
+       continue;
+      }
       if (argument.CompareTo("decoder",TString::kIgnoreCase)==0) {
        bUseClusterFinderDecoder = kTRUE;
        continue;
@@ -126,6 +138,13 @@ void rec_hlt_tpc(const char* input="./", char* opt="decoder ESD")
       }
     }
   }
+  if (!histout && !dumpout && !esdout && !chout && !cdout) {
+    cout << "you need to specify an output option, on or more out of: ESD, TrackHistogram, TrackDump, ClusterHisto, ClusterDump" << endl;
+    return;
+  }
+  if ((option.Contains("statroot") || option.Contains("statraw")) && !esdout) {
+    cout << "!!!!!!!! Warning: HLT statistics are only collected for output type ESD !!!!!!!!" << endl;
+  }
 
   ///////////////////////////////////////////////////////////////////////////////////////////////////
   //
@@ -213,6 +232,10 @@ void rec_hlt_tpc(const char* input="./", char* opt="decoder ESD")
       
       // the root file writer configuration
       AliHLTConfiguration sink("sink1", "EsdCollector"   , "esd-converter", "-directory hlt-tpc-esd");
+
+      // optional component statistics
+      AliHLTConfiguration statroot("statroot", "StatisticsCollector"   , "esd-converter", "-file HLT.statistics.root -publish 0");
+      AliHLTConfiguration statraw("statraw", "FileWriter"   , "esd-converter", "-datatype COMPSTAT PRIV -datafile HLT.statistics.raw -concatenate-blocks -concatenate-events");
     }
   }
   //Chain with Track Histogram
diff --git a/HLT/benchmark/macros/bench-hlt-hierarchy.C b/HLT/benchmark/macros/bench-hlt-hierarchy.C
new file mode 100644 (file)
index 0000000..d29b33d
--- /dev/null
@@ -0,0 +1,76 @@
+// $Id$
+/**
+ * Benchmark macro for transportation of fake data blocks through an HLT
+ * hierarchy.
+ *
+ * Usage:
+ * <pre>
+ *   aliroot -b -q bench-hlt-hierarchy.C | tee bench-hlt-hierarchy.log
+ * </pre>
+ * Options:
+ * <pre>
+ *   aliroot -b -q bench-hlt-hierarchy.C'(2, "root raw")'
+ * </pre>
+ * First argument allows to specifiy the number of events, the second one
+ * is a string defining the output, "root" for a statistics in a root file
+ * and "raw" for just the raw data block. Can be combined. Default is "root".
+ *
+ * @ingroup alihlt_benchmark
+ * @author Matthias.Richter@ift.uib.no
+ */
+void bench_hlt_hierarchy(int events=100, const char* option="root")
+{
+  TString options=option;
+  AliHLTSystem gHLT(0x7c);
+  gHLT.LoadComponentLibraries("libAliHLTUtil.so");
+
+  ///////////////////////////////////////////////////////////////////////////////////////////////////
+  //
+  // define the analysis chain to be run
+  //
+  const int iNofLevel0=6;
+  const int iNofLevel1=18;
+  const int iNofLevel2=2;
+  TString level3Input;
+  TString arg, component;
+  for (int level2=0; level2<iNofLevel2; level2++) {
+    TString level2Input;
+    for (int level1=0; level1<iNofLevel1; level1++) {
+      TString level1Input;
+      for (int level0=0; level0<iNofLevel0; level0++) {
+       // level0 publisher component
+       arg.Form("-datatype DUMMYDAT FAKE -size 10000 -range 1000 -modulo 10 -decrement 1000");
+       component.Form("L0_%d_%02d_%d", level2, level1, level0);
+       AliHLTConfiguration l0conf(component.Data(), "DataGenerator", NULL , arg.Data());
+
+       if (level1Input.Length()>0) level1Input+=" ";
+       level1Input+=component;
+      }
+
+      // level 1 components
+      arg.Form("-datatype DUMMYDAT FAKE -multiplier 0.2");
+      component.Form("L1_%d_%02d", level2, level1);
+      AliHLTConfiguration l1conf(component.Data(), "DataGenerator", level1Input.Data(), arg.Data());
+      if (level2Input.Length()>0) level2Input+=" ";
+      level2Input+=component;
+    }
+
+    // level 2 components
+    arg.Form("-datatype DUMMYDAT FAKE -multiplier 1.0");
+    component.Form("L2_%d", level2);
+    AliHLTConfiguration l2conf(component.Data(),"DataGenerator",level2Input.Data(), arg.Data());
+    if (level3Input.Length()>0) level3Input+=" ";
+    level3Input+=component;
+  }
+
+  arg.Form("-datatype DUMMYDAT FAKE -multiplier 1.0");
+  AliHLTConfiguration l3conf("L3","DataGenerator",level3Input.Data(),arg.Data());
+  AliHLTConfiguration statroot("statroot", "StatisticsCollector"   , "L3", "-file HLT.statistics.root -publish 0");
+  AliHLTConfiguration statraw("statraw", "FileWriter"   , "L3", "-datafile HLT.statistics.raw -concatenate-events -concatenate-blocks -datatype COMPSTAT PRIV");
+
+  if (options.Contains("root"))
+      gHLT.BuildTaskList("statroot");
+  if (options.Contains("raw"))
+      gHLT.BuildTaskList("statraw");
+  gHLT.Run(events);
+}
diff --git a/HLT/benchmark/macros/format-statistics.C b/HLT/benchmark/macros/format-statistics.C
new file mode 100644 (file)
index 0000000..9ebe194
--- /dev/null
@@ -0,0 +1,37 @@
+// $Id$
+/**
+ * Helper macro to format a block of AliHLTComponentStatistics entries.
+ * The block is usually created by attaching a file writer to a chain,
+ * writing only COMPSTAT:PRIV data blocks.
+ *
+ * The macro translates the block into HLTruns a stand-alone chain
+ * Usage:
+ * <pre>
+ *   aliroot -b -q format-statistics.C | tee format-statistics.log
+ * </pre>
+ *
+ *
+ * @ingroup alihlt_benchmark
+ * @author Matthias.Richter@ift.uib.no
+ */
+void format_statistics(const char* infile, const char* outfile="HLT.statistics.root")
+{
+  AliHLTSystem gHLT;
+  gHLT.LoadComponentLibraries("libAliHLTUtil.so");
+  AliHLTConfiguration publisher("publisher", "FilePublisher", NULL, "-datatype 'COMPSTAT' 'PRIV' -datafile HLT.statistics.raw");
+
+  AliHLTConfiguration sink1("sink1", "StatisticsCollector", "publisher", "-file out.root -publish 0 -arraysize 200000");
+
+  gHLT.BuildTaskList("sink1");
+  gHLT.Run();
+}
+
+void format_statistics()
+{
+  cerr << "===============================================================" << endl;
+  cerr << "usage:" << endl;
+  cerr << "  aliroot -b -q -l format-statistics.C'(\"infile\", \"outfile\")'" << endl << endl;
+  cerr << "please provide input, e.g. \"HLT.statistics.raw\"" << endl;
+  cerr << "default output file is \"HLT.statistics.root\"" << endl;
+  cerr << "===============================================================" << endl;
+}