]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
adding publishing of histograms, by default all histograms are sent as separate objec...
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 13 Oct 2011 23:47:04 +0000 (23:47 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 13 Oct 2011 23:47:04 +0000 (23:47 +0000)
HLT/TPCLib/comp/AliHLTTPCDataCompressionMonitorComponent.cxx
HLT/TPCLib/comp/AliHLTTPCDataCompressionMonitorComponent.h

index 978053602f4192657396c6b2b075d9481da9b54e..bff6862d62b4a295498fed6e1de91bc06f2f6c64 100644 (file)
@@ -43,6 +43,7 @@
 #include "TH3F.h"
 #include "TFile.h"
 #include "TObjArray.h"
+#include "TList.h"
 #include <memory>
 
 ClassImp(AliHLTTPCDataCompressionMonitorComponent)
@@ -53,10 +54,11 @@ AliHLTTPCDataCompressionMonitorComponent::AliHLTTPCDataCompressionMonitorCompone
   , fHistoHWCFDataSize(NULL)
   , fHistoHWCFReductionFactor(NULL)
   , fHistoNofClusters(NULL)
-  , fHistogramFile("HLT.TPC-compression-statistics.root")
+  , fHistogramFile()
   , fMonitoringContainer(NULL)
   , fVerbosity(0)
   , fFlags(0)
+  , fPublishingMode(kPublishSeparate)
 {
 }
 
@@ -101,7 +103,7 @@ int AliHLTTPCDataCompressionMonitorComponent::GetOutputDataTypes(AliHLTComponent
 void AliHLTTPCDataCompressionMonitorComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
 {
   /// inherited from AliHLTComponent: output data size estimator
-  constBase=0;
+  constBase=100000;
   inputMultiplier=1.0;
 }
 
@@ -223,6 +225,74 @@ int AliHLTTPCDataCompressionMonitorComponent::DoEvent( const AliHLTComponentEven
   if (fHistoNofClusters)         fHistoNofClusters        ->Fill(hwclustersDataSize/1024, nofClusters);
   HLTInfo("raw data %d, hwcf data %d, comp data %d, ratio %f, %d clusters\n", rawDataSize, hwclustersDataSize, compDataSize, ratio, nofClusters);
 
+  if (iResult>=0 && fPublishingMode!=kPublishOff) {
+    iResult=Publish(fPublishingMode);
+  }
+
+  return iResult;
+}
+
+int AliHLTTPCDataCompressionMonitorComponent::Publish(int mode)
+{
+  /// publish to output
+
+  // FIXME: code needs to be optimized, maybe a bit to much new and delete for the
+  // moment, the data type might need adjustment
+  int iResult=0;
+  TObjArray* pArray=mode==kPublishArray?(new TObjArray):NULL;
+  TList* pList=mode==kPublishList?(new TList):NULL;
+  if (mode==kPublishSeparate) {
+    if (fHistoHWCFDataSize)        PushBack(fHistoHWCFDataSize       , kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC);
+    if (fHistoHWCFReductionFactor) PushBack(fHistoHWCFReductionFactor, kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC);
+    if (fHistoNofClusters)         PushBack(fHistoNofClusters        , kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC);
+  } else if (pList) {
+    if (fHistoHWCFDataSize)        pList->Add(fHistoHWCFDataSize->Clone());
+    if (fHistoHWCFReductionFactor) pList->Add(fHistoHWCFReductionFactor->Clone());
+    if (fHistoNofClusters)         pList->Add(fHistoNofClusters->Clone());
+  } else if (pArray) {
+    if (fHistoHWCFDataSize)        pArray->Add(fHistoHWCFDataSize->Clone());
+    if (fHistoHWCFReductionFactor) pArray->Add(fHistoHWCFReductionFactor->Clone());
+    if (fHistoNofClusters)         pArray->Add(fHistoNofClusters->Clone());
+  }
+
+  if (fMonitoringContainer) {
+    static const char* searchIds[] = {"fHistograms", "fHistograms2D", "fHistograms3D", NULL};
+    const char** searchId=searchIds;
+    while (*searchId && iResult>=0) {
+      const TObject* o=fMonitoringContainer->FindObject(*searchId);
+      if (o) {
+       const TObjArray* histograms=dynamic_cast<const TObjArray*>(o);
+       if (histograms) {
+         for (int i=0; i<histograms->GetEntriesFast() && iResult>=0; i++) {
+           if (!histograms->At(i)) continue;
+           if (mode==kPublishSeparate) {
+             iResult=PushBack(histograms->At(i), kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC);
+           } else if (pList) {
+             pList->Add(histograms->At(i)->Clone());
+           } else if (pArray) {
+             pArray->Add(histograms->At(i)->Clone());
+           }
+         }
+       }
+      } else {
+       HLTError("failed to find object \"%s\"", *searchId);
+      }
+      searchId++;
+    }
+  }
+
+  if (pArray) {
+    iResult=PushBack(pArray, kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC);
+    pArray->SetOwner(kTRUE);
+    delete pArray;
+    pArray=NULL;
+  }
+  if (pList) {
+    iResult=PushBack(pList, kAliHLTDataTypeTObject|kAliHLTDataOriginTPC);
+    pList->SetOwner(kTRUE);
+    delete pList;
+    pList=NULL;
+  }
   return iResult;
 }
 
@@ -281,13 +351,9 @@ int AliHLTTPCDataCompressionMonitorComponent::DoInit( int argc, const char** arg
     if (yaxis) yaxis->SetTitle("N. of clusters");
   }
 
-  // initialize the histograms if stored at the end
-  // condition might be extended
-  if (!fHistogramFile.IsNull()) {
-    fHistoHWCFDataSize=histoHWCFDataSize.release();
-    fHistoHWCFReductionFactor=histoHWCFReductionFactor.release();
-    fHistoNofClusters=histoNofClusters.release();
-  }
+  fHistoHWCFDataSize=histoHWCFDataSize.release();
+  fHistoHWCFReductionFactor=histoHWCFReductionFactor.release();
+  fHistoNofClusters=histoNofClusters.release();
 
   fpHWClusterDecoder=hwClusterDecoder.release();
   fMonitoringContainer=dataContainer.release();
@@ -351,7 +417,21 @@ int AliHLTTPCDataCompressionMonitorComponent::ScanConfigurationArgument(int argc
     if (argument.CompareTo("-histogram-file")==0) {
       if ((bMissingParam=(++i>=argc))) break;
       fHistogramFile=argv[i++];
-      return 2;
+      return i;
+    }
+    // -publishing-mode
+    if (argument.CompareTo("-publishing-mode")==0) {
+      if ((bMissingParam=(++i>=argc))) break;
+      TString option=argv[i++];
+      if (option.CompareTo("off")==0)           fPublishingMode=kPublishOff     ;
+      else if (option.CompareTo("separate")==0) fPublishingMode=kPublishSeparate;
+      else if (option.CompareTo("list")==0)     fPublishingMode=kPublishList    ;
+      else if (option.CompareTo("array")==0)    fPublishingMode=kPublishArray   ;
+      else {
+       HLTError("invalid option \"%s\" for argument \"%s\", expecting 'off', 'separate', 'list', or 'array'", option.Data(), argument.Data());
+       return -EPROTO;
+      }
+      return i;
     }
   } while (0); // using do-while only to have break available
 
@@ -724,6 +804,7 @@ void AliHLTTPCDataCompressionMonitorComponent::AliDataContainer::Clear(Option_t
 TObject* AliHLTTPCDataCompressionMonitorComponent::AliDataContainer::FindObject(const char *name) const
 {
   /// get histogram object  
+  if (!name) return NULL;
   if ( strcmp(name,"fHistograms")   == 0 )
     return fHistograms;
   if ( strcmp(name,"fHistograms2D") == 0 )
index 1448f95342d096136d13e82dbb8f88a40a500140..c99570cf216bcf02b32f5d801423dff5cdeab165 100644 (file)
@@ -83,6 +83,14 @@ public:
     kHaveHWClusters = 0x2
   };
 
+  enum {
+    kPublishOff      = 0,
+    kPublishSeparate = 1,
+    kPublishList     = 2,
+    kPublishArray    = 3,
+    kPublishInvalid  = 4    
+  };
+
   enum {
     kHistogramPadrow,
     kHistogramPad,
@@ -267,6 +275,9 @@ protected:
   /// inherited from AliHLTComponent: argument scan
   int ScanConfigurationArgument(int argc, const char** argv);
 
+  /// publish to output
+  int Publish(int mode);
+    
 private:
   AliHLTTPCDataCompressionMonitorComponent(const AliHLTTPCDataCompressionMonitorComponent&);
   AliHLTTPCDataCompressionMonitorComponent& operator=(const AliHLTTPCDataCompressionMonitorComponent&);
@@ -282,6 +293,7 @@ private:
   /// verbosity
   int fVerbosity;  //! verbosity for debug printout
   unsigned fFlags; //! flags to indicate various conditions
+  int fPublishingMode; //! publishing mode
 
   static const AliHistogramDefinition fgkHistogramDefinitions[]; //! histogram definitions
   static const AliHistogramDefinition2D fgkHistogramDefinitions2D[]; //! histogram definitions