]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
added option to write extracted StreamerInfo to file at EOR
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 1 Dec 2009 13:49:25 +0000 (13:49 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 1 Dec 2009 13:49:25 +0000 (13:49 +0000)
HLT/BASE/util/AliHLTRootSchemaEvolutionComponent.cxx
HLT/BASE/util/AliHLTRootSchemaEvolutionComponent.h

index 1e628a6ac81c17f15ea6781f107e2dfaf395e10d..222dcce6e8f6f435402f23a8968372ab6188d128 100644 (file)
 #include "TObjArray.h"
 #include "TStreamerInfo.h"
 #include "TList.h"
+#include "TFile.h"
+
+#include "AliCDBStorage.h"
+#include "AliCDBManager.h"
+#include "AliCDBPath.h"
+#include "AliCDBId.h"
+#include "AliCDBMetaData.h"
+#include "AliCDBEntry.h"
 
 /** ROOT macro for the implementation of ROOT specific class methods */
 ClassImp(AliHLTRootSchemaEvolutionComponent)
@@ -36,6 +44,7 @@ AliHLTRootSchemaEvolutionComponent::AliHLTRootSchemaEvolutionComponent()
   , fFlags(0)
   , fpStreamerInfos(NULL)
   , fFXSPrescaler(0)
+  , fFileName()
 {
   // see header file for class documentation
   // or
@@ -100,6 +109,11 @@ int AliHLTRootSchemaEvolutionComponent::DoInit(int argc, const char** argv)
 int AliHLTRootSchemaEvolutionComponent::DoDeinit()
 {
   // see header file for class documentation
+  if (fFileName.IsNull()==0) {
+    WriteToFile(fFileName, fpStreamerInfos);
+    fFileName.Clear();
+  }
+
   if (fpStreamerInfos) {
     fpStreamerInfos->Clear();
     delete fpStreamerInfos;
@@ -135,10 +149,15 @@ int AliHLTRootSchemaEvolutionComponent::DoEvent( const AliHLTComponentEventData&
        (TestBits(kHLTOUTatEOR) && eventType==gkAliEventTypeEndOfRun)) {
       PushBack(fpStreamerInfos, kAliHLTDataTypeStreamerInfo);
     }
+  }
 
-    if (TestBits(kFXS) && eventType==gkAliEventTypeEndOfRun) {
-      // push to FXS, needs to be implemented in the base class
-    }
+  if (TestBits(kFXS) && eventType==gkAliEventTypeEndOfRun) {
+    // push to FXS, needs to be implemented in the base class
+  }
+
+  if (fFileName.IsNull()==0 && eventType==gkAliEventTypeEndOfRun) {
+    WriteToFile(fFileName, fpStreamerInfos);
+    fFileName.Clear();
   }
 
   return iResult;
@@ -217,6 +236,56 @@ int AliHLTRootSchemaEvolutionComponent::ScanConfigurationArgument(int argc, cons
     }
     return 1;
   }
+
+  // -file=<filename>
+  if (argument.Contains("-file=")) {
+    argument.ReplaceAll("-file=", "");
+    if (!argument.IsNull()) {
+      fFileName=argument;
+    } else {
+      HLTError("argument -file= expects file name");
+      return -EINVAL;
+    }
+    return 1;
+  }
   
   return iResult;
 }
+
+int AliHLTRootSchemaEvolutionComponent::WriteToFile(const char* filename, const TObjArray* infos) const
+{
+  // write aray of streamer infos to file
+  if (!filename || !infos) return -EINVAL;
+
+  TFile out(filename, "RECREATE");
+  if (out.IsZombie()) {
+    HLTError("failed to open file %s", filename);
+    return -EBADF;
+  }
+
+  const char* entrypath="HLT/Calib/StreamerInfo";
+  int version = -1;
+  AliCDBStorage* store = AliCDBManager::Instance()->GetDefaultStorage();
+  if (store) {
+    version = store->GetLatestVersion(entrypath, GetRunNo());
+  }
+  version++;
+
+  AliCDBPath cdbPath(entrypath);
+  AliCDBId cdbId(cdbPath, GetRunNo(), AliCDBRunRange::Infinity(), version, 0);
+  AliCDBMetaData* cdbMetaData=new AliCDBMetaData;
+  cdbMetaData->SetResponsible("ALICE HLT");
+  cdbMetaData->SetComment("Streamer info for HLTOUT payload");
+  AliCDBEntry* entry=new AliCDBEntry(infos->Clone(), cdbId, cdbMetaData, kTRUE);
+
+  out.cd();
+  entry->Write();
+  // this is a small memory leak
+  // seg fault in ROOT object handling if the two objects are deleted
+  // investigate later
+  //delete entry;
+  //delete cdbMetaData;
+  out.Close();
+
+  return 0;
+}
index 5f3fc99aef2e6f77897d45ac79ee908beccfccbc..8127f5907633965263235fe94789c44f155c7afe 100644 (file)
@@ -14,6 +14,7 @@
 */
 
 #include "AliHLTProcessor.h"
+#include "TString.h"
 
 class TObjArray;
 
@@ -39,6 +40,8 @@ class TObjArray;
  * \li -hltout<=[all,first,eor,off]> <br>
  *      push streamer info to output, the streamer info is stored in the
  *      events in all, the first, and/or the EOR.
+ * \li -file=<filename> <br>
+ *      write to file at EOR
  *
  * <h2>Configuration:</h2>
  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
@@ -118,6 +121,7 @@ class AliHLTRootSchemaEvolutionComponent : public AliHLTProcessor
   void SetBits(AliHLTUInt32_t b) {fFlags|=b;}
   void ClearBits(AliHLTUInt32_t b) {fFlags&=~b;}
   bool TestBits(AliHLTUInt32_t b) {return (fFlags&b) != 0;}
+  int WriteToFile(const char* filename, const TObjArray* infos) const;
 
 private:
   /** copy constructor prohibited */
@@ -131,8 +135,10 @@ private:
 
   AliHLTUInt32_t fFXSPrescaler; //! prescalar for the publishing to FXS
 
+  TString fFileName; //! file name for dump at EOR
+
   static const char* fgkConfigurationObject; //! configuration object
 
-  ClassDef(AliHLTRootSchemaEvolutionComponent, 1) // ROOT schema evolution component
+  ClassDef(AliHLTRootSchemaEvolutionComponent, 2) // ROOT schema evolution component
 };
 #endif