]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/SampleLib/AliHLTSampleComponent1.cxx
ALIROOT-5792 data/galice.cuts modified for ZDC
[u/mrichter/AliRoot.git] / HLT / SampleLib / AliHLTSampleComponent1.cxx
index 195a9eeb04afa3da1782294519efdbc98db04a72..6e693689a16cc4e8afc5ec14f8e23631d25f7b6b 100644 (file)
 // $Id$
 
-/**************************************************************************
- * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
- *                                                                        *
- * Authors: Matthias Richter <Matthias.Richter@ift.uib.no>                *
- *          Timm Steinbeck <timm@kip.uni-heidelberg.de>                   *
- *          for The ALICE Off-line 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   AliHLTSampleComponent1.cxx
-    @author Matthias Richter, Timm M. Steinbeck
-    @date   
-    @brief  A sample processing component for the HLT. */
-
-#if __GNUC__== 3
-using namespace std;
-#endif
+//**************************************************************************
+//* This file is property of and copyright by the                          * 
+//* ALICE Experiment at CERN, All rights reserved.                         *
+//*                                                                        *
+//* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
+//*                  Timm Steinbeck <timm@kip.uni-heidelberg.de>           *
+//*                  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   AliHLTSampleComponent1.cxx
+//  @author Matthias Richter, Timm M. Steinbeck
+//  @date   
+//  @brief  A sample processing component for the HLT.
+//          Component illustrates the basic functionality and component
+//          initialization. 
 
 #include "AliHLTSampleComponent1.h"
+#include "TString.h"
+#include "TObjString.h"
+#include "TMap.h"
 
-/**
- * The global object used for automatic component registration, 
- * @note DO NOT use this component for calculation!
- */
-AliHLTSampleComponent1 gAliHLTSampleComponent1;
+using namespace std;
 
+/** ROOT macro for the implementation of ROOT specific class methods */
 ClassImp(AliHLTSampleComponent1)
 
-const AliHLTComponentDataType AliHLTSampleComponent1::fgInputDataTypes[]={kAliHLTVoidDataType,
-                                                                       {0,"",""}}; //'zero' terminated array
-
 AliHLTSampleComponent1::AliHLTSampleComponent1()
+  : AliHLTProcessor()
+  , fArgument1(0)
+  , fArgument2(0)
 {
-  // see header file for class documentation
+  // an example component which implements the ALICE HLT processor
+  // interface and illustrates the basic interface methods
+  //
+  //
+  // NOTE: all helper classes should be instantiated in DoInit()
 }
 
 AliHLTSampleComponent1::~AliHLTSampleComponent1()
 {
-  // see header file for class documentation
+  // destructor
+  //
+  // NOTE: implement proper cleanup in DoDeinit()
+}
+
+const char* AliHLTSampleComponent1::GetComponentID()
+{ 
+  // component property: id
+  return "Sample-component1";
+}
+
+void AliHLTSampleComponent1::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
+{
+  // component property: list of input data types
+    list.push_back(kAliHLTAnyDataType);
+}
+
+AliHLTComponentDataType AliHLTSampleComponent1::GetOutputDataType()
+{
+  // component property: output data type
+  return kAliHLTVoidDataType;
 }
 
-int AliHLTSampleComponent1::DoInit( int argc, const char** argv ){
+void AliHLTSampleComponent1::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
+{
+  // component property: output size estimator
+  constBase = 0;
+  inputMultiplier = 0;
+}
+
+void AliHLTSampleComponent1::GetOCDBObjectDescription( TMap* const targetMap)
+{
+  // Get a list of OCDB object description.
+  // The list of objects is provided in a TMap
+  // - key: complete OCDB path, e.g. GRP/GRP/Data
+  // - value: short description why the object is needed
+  // Key and value objects created inside this class go into ownership of
+  // target TMap.
+  if (!targetMap) return;
+  targetMap->Add(new TObjString("HLT/ConfigSample/SampleComponent1"),
+                new TObjString("configuration object"));
+}
+
+AliHLTComponent* AliHLTSampleComponent1::Spawn()
+{
+  // Spawn function, return new class instance
+  return new AliHLTSampleComponent1;
+}
+
+int AliHLTSampleComponent1::DoInit( int argc, const char** argv )
+{
   // see header file for class documentation
-  Logging(kHLTLogInfo, "HLT", "Sample", "Sample component1, DoInit");
-  if (argc==0 && argv==NULL) {
-    // this is just to get rid of the warning "unused parameter"
+  int iResult=0;
+
+  // init stage 1: default values for all data members
+  fArgument1=0;
+  fArgument2=0;
+
+  // init stage 2: read configuration object
+  // ScanConfigurationArgument() needs to be implemented
+  TString cdbPath="HLT/ConfigSample/SampleComponent1";
+  iResult=ConfigureFromCDBTObjString(cdbPath);
+
+  // init stage 3: read the component arguments
+  if (iResult>=0) {
+    iResult=ConfigureFromArgumentString(argc, argv);
   }
-  return 0;
+
+  if (iResult>=0) {
+    // implement the component initialization
+    if (!fArgument1) {
+      HLTError("mandatory argument \'-mandatory1\' missing");
+      iResult=-EPROTO;
+    }
+    if (!fArgument2) {
+      HLTError("mandatory argument \'-mandatory2\' missing");
+      iResult=-EPROTO;
+    }
+  }
+
+  if (iResult<0) {
+    // implement cleanup
+  }
+
+  return iResult;
 }
 
-int AliHLTSampleComponent1::DoDeinit(){
+int AliHLTSampleComponent1::ScanConfigurationArgument( int argc, const char** argv )
+{
   // see header file for class documentation
-  Logging(kHLTLogInfo, "HLT", "Sample", "Sample component1, DoDeinit");
+  TString argument="";
+  TString configuration=""; 
+  int i=0;
+    argument=argv[i];
+    if (argument.IsNull()) return 0;
+
+    // -mandatory1
+    if (argument.CompareTo("-mandatory1")==0) {
+      if (++i>=argc) return -EPROTO;
+      HLTInfo("got \'-mandatory1\' argument: %s", argv[i]);
+      fArgument1=1;
+
+      // -mandatory2
+    } else if (argument.CompareTo("-mandatory2")==0) {
+      fArgument2=1;
+      HLTInfo("got \'-mandatory2\' argument");
+
+      // -config1
+    } else if (argument.CompareTo("-config1")==0) {
+      if (++i>=argc) return -EPROTO;
+      HLTInfo("got \'%s\' argument: %s", argument.Data(), argv[i]);
+
+      // -config2
+    } else if (argument.CompareTo("-config2")==0) {
+      HLTInfo("got \'%s\' argument", argument.Data());
+
+    } else {
+      // no recognized argument
+      i--;
+    }
+
+  return i+1;
+}
+
+int AliHLTSampleComponent1::DoDeinit()
+{
+  // see header file for class documentation
+  HLTInfo("processing cleanup");
   return 0;
 }
 
 int AliHLTSampleComponent1::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, 
                                      AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, 
-                                     AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks ) {
+                                     AliHLTUInt32_t& size, AliHLTComponentBlockDataList& outputBlocks ) {
   // see header file for class documentation
-  Logging(kHLTLogInfo, "HLT", "Sample", "Sample component1, DoEvent");
+  HLTInfo("processing data");
   if (evtData.fStructSize==0 && blocks==NULL && trigData.fStructSize==0 &&
       outputPtr==0 && size==0)
   {
@@ -76,3 +192,28 @@ int AliHLTSampleComponent1::DoEvent( const AliHLTComponentEventData& evtData, co
   }
   return 0;
 }
+int AliHLTSampleComponent1::Reconfigure(const char* cdbEntry, const char* chainId)
+{
+  // see header file for class documentation
+  int iResult=0;
+  const char* path="HLT/ConfigSample/SampleComponent1";
+  const char* defaultNotify="";
+  if (cdbEntry) {
+    path=cdbEntry;
+    defaultNotify=" (default)";
+  }
+
+  HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
+  iResult=ConfigureFromCDBTObjString(path);
+
+  return iResult;
+}
+
+int AliHLTSampleComponent1::ReadPreprocessorValues(const char* modules)
+{
+  // see header file for class documentation
+  int iResult=0;
+  TString detectors(modules!=NULL?modules:"");
+  HLTInfo("read preprocessor values for detector(s): %s", detectors.IsNull()?"none":detectors.Data());
+  return iResult;
+}