]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
adding an example component illustrating some ESD analysis and corresponding macro...
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 18 Apr 2010 10:59:44 +0000 (10:59 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 18 Apr 2010 10:59:44 +0000 (10:59 +0000)
HLT/SampleLib/AliHLTSampleESDAnalysisComponent.cxx [new file with mode: 0644]
HLT/SampleLib/AliHLTSampleESDAnalysisComponent.h [new file with mode: 0644]
HLT/exa/sampleEsdAnalysis.C [new file with mode: 0644]
HLT/libAliHLTSample.pkg

diff --git a/HLT/SampleLib/AliHLTSampleESDAnalysisComponent.cxx b/HLT/SampleLib/AliHLTSampleESDAnalysisComponent.cxx
new file mode 100644 (file)
index 0000000..ad5e070
--- /dev/null
@@ -0,0 +1,231 @@
+// $Id$
+
+//**************************************************************************
+//* This file is property of and copyright by the ALICE HLT Project        * 
+//* ALICE Experiment at CERN, All rights reserved.                         *
+//*                                                                        *
+//* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
+//*                  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   AliHLTSampleESDAnalysisComponent.cxx
+//  @author Matthias Richter
+//  @date   2010-04-17
+//  @brief  A sample processing component for ESD analysis.
+//  @ingroup alihlt_tutorial
+
+#if __GNUC__== 3
+using namespace std;
+#endif
+
+#include "AliHLTSampleESDAnalysisComponent.h"
+#include "AliESDEvent.h"
+#include "AliESDtrack.h"
+#include "AliLog.h"
+#include "TMap.h"
+#include "TObjString.h"
+
+/** ROOT macro for the implementation of ROOT specific class methods */
+ClassImp(AliHLTSampleESDAnalysisComponent)
+
+/** one global instance used for registration */
+AliHLTSampleESDAnalysisComponent gAliHLTSampleESDAnalysisComponent;
+
+AliHLTSampleESDAnalysisComponent::AliHLTSampleESDAnalysisComponent()
+{
+  // an example component which implements the ALICE HLT processor
+  // interface and does some analysis on the input ESD
+  //
+  // see header file for class documentation
+  // or
+  // refer to README to build package
+  // or
+  // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+  //
+  // NOTE: all helper classes should be instantiated in DoInit()
+}
+
+AliHLTSampleESDAnalysisComponent::~AliHLTSampleESDAnalysisComponent()
+{
+  // destructor
+  //
+  // NOTE: implement proper cleanup in DoDeinit()
+}
+
+const char* AliHLTSampleESDAnalysisComponent::GetComponentID()
+{ 
+  // component property: id
+  return "SampleESDAnalysis";
+}
+
+void AliHLTSampleESDAnalysisComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
+{
+  // component property: list of input data types
+    list.push_back(kAliHLTDataTypeESDObject);
+}
+
+AliHLTComponentDataType AliHLTSampleESDAnalysisComponent::GetOutputDataType()
+{
+  // component property: output data type
+  return kAliHLTDataTypeTObjArray|kAliHLTDataOriginSample;
+}
+
+void AliHLTSampleESDAnalysisComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
+{
+  // component property: output size estimator
+  constBase = 0;
+  inputMultiplier = 0;
+}
+
+void AliHLTSampleESDAnalysisComponent::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/SampleESDAnalysis"),
+               new TObjString("configuration object"));
+  targetMap->Add(new TObjString("GRP/GRP/Data"),
+               new TObjString("GRP object"));
+}
+
+AliHLTComponent* AliHLTSampleESDAnalysisComponent::Spawn()
+{
+  // Spawn function, return new class instance
+  return new AliHLTSampleESDAnalysisComponent;
+}
+
+int AliHLTSampleESDAnalysisComponent::DoInit( int argc, const char** argv )
+{
+  // see header file for class documentation
+  int iResult=0;
+
+  // init stage 1: default values for all data members
+
+  // init stage 2: read configuration object
+  // ScanConfigurationArgument() needs to be implemented
+  TString cdbPath="HLT/ConfigSample/";
+  cdbPath+=GetComponentID();
+  iResult=ConfigureFromCDBTObjString(cdbPath);
+
+  // init stage 3: read the component arguments
+  if (iResult>=0) {
+    iResult=ConfigureFromArgumentString(argc, argv);
+  }
+
+  if (iResult>=0) {
+    // implement the component initialization
+  }
+
+  if (iResult<0) {
+    // implement cleanup
+  }
+
+  return iResult;
+}
+
+int AliHLTSampleESDAnalysisComponent::ScanConfigurationArgument(int argc, const char** argv)
+{
+  // Scan configuration arguments
+  // Return the number of processed arguments
+  //        -EPROTO if argument format error (e.g. number expected but not found)
+  //
+  // The AliHLTComponent base class implements a parsing loop for argument strings and
+  // arrays of strings which is invoked by ConfigureFromArgumentString/ConfigureFromCDBTObjString
+  // The component needs to implement ScanConfigurationArgument in order to decode the arguments.
+
+  int i=0;
+  TString argument=argv[i];
+
+  if (argument.IsNull()) return 0;
+
+  // -mandatory1 arg
+  if (argument.CompareTo("-mandatory1")==0) {
+    if (++i>=argc) return -EINVAL;
+    HLTInfo("got \'-mandatory1\' argument: %s", argv[i]);
+    return 2; // keyword + 1 argument
+  }
+
+  // -optional1 arg
+  if (argument.CompareTo("-optional1")==0) {
+    if (++i>=argc) return -EINVAL;
+    HLTInfo("got \'-optional1\' argument: %s", argv[i]);
+    return 2; // keyword + 1 argument
+  }
+
+  // -optional2
+  if (argument.CompareTo("-optional2")==0) {
+    HLTInfo("got \'-optional2\' argument");
+    return 1; // only keyword
+  }
+
+  return 0;
+}
+
+int AliHLTSampleESDAnalysisComponent::DoDeinit()
+{
+  // component cleanup, delete all instances of helper classes here
+
+  return 0;
+}
+
+int AliHLTSampleESDAnalysisComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/,
+                                             AliHLTComponentTriggerData& /*trigData*/)
+{
+  // event processing function
+
+  // check if this is a data event, there are a couple of special events
+  // which should be ignored for normal processing
+  if (!IsDataEvent()) return 0;
+
+  const TObject* obj = GetFirstInputObject(kAliHLTAllDataTypes, "AliESDEvent");
+
+  // input objects are not supposed to be changed by the component, so they
+  // are defined const. However, the implementation of AliESDEvent does not
+  // support this and we need the const_cast
+  AliESDEvent* esd = dynamic_cast<AliESDEvent*>(const_cast<TObject*>(obj));
+  TObjArray output;
+  if (esd != NULL) {
+    AliInfoClass(Form("==================== event %3d ================================", GetEventCount()));
+    esd->GetStdContent();
+    for (Int_t i = 0; i < esd->GetNumberOfTracks(); i++) {
+      AliESDtrack* track = esd->GetTrack(i);
+      AliInfoClass(Form("-------------------- track %3d --------------------------------", i));
+      track->Print("");
+      output.Add(track);
+    }
+  }
+
+  // publish the array of tracks as output
+  PushBack(&output, kAliHLTDataTypeTObjArray|kAliHLTDataOriginSample);
+
+  return 0;
+}
+
+int AliHLTSampleESDAnalysisComponent::Reconfigure(const char* cdbEntry, const char* chainId)
+{
+  // reconfigure the component from the specified CDB entry, or default CDB entry
+  HLTInfo("reconfigure '%s' from entry %s", chainId, cdbEntry);
+
+  return 0;
+}
+
+int AliHLTSampleESDAnalysisComponent::ReadPreprocessorValues(const char* modules)
+{
+  // read the preprocessor values for the detectors in the modules list
+  int iResult=0;
+  TString detectors(modules!=NULL?modules:"");
+  HLTInfo("read preprocessor values for detector(s): %s", detectors.IsNull()?"none":detectors.Data());
+  return iResult;
+}
diff --git a/HLT/SampleLib/AliHLTSampleESDAnalysisComponent.h b/HLT/SampleLib/AliHLTSampleESDAnalysisComponent.h
new file mode 100644 (file)
index 0000000..8d0ac17
--- /dev/null
@@ -0,0 +1,112 @@
+//-*- Mode: C++ -*-
+// $Id$
+#ifndef ALIHLTSAMPLEESDANALYSISCOMPONENT_H
+#define ALIHLTSAMPLEESDANALYSISCOMPONENT_H
+
+//* This file is property of and copyright by the ALICE HLT Project        * 
+//* ALICE Experiment at CERN, All rights reserved.                         *
+//* See cxx source for full Copyright notice                               */
+
+//  @file   AliHLTSampleESDAnalysisComponent.h
+//  @author Matthias Richter
+//  @date   2010-04-17
+//  @brief  A sample processing component for ESD analysis.
+//  @ingroup alihlt_tutorial
+
+#include "AliHLTProcessor.h"
+
+/**
+ * @class AliHLTSampleESDAnalysisComponent
+ * An example how to implement an HLT ESD analysis component.
+ * The class features the AliHLTComponent interface for HLT processing
+ * components. The interface allows to run such components in either
+ * the (sequential) AliSimulation/AliReconstruction framework or the
+ * parallel HLT online processing framework.
+ *
+ * An example to run the component can be found in macro sampleEsdAnalysis.C
+ * in the folder HLT/exa.
+ *
+ * Component fetches the ESD from the input objects, loops over tracks and
+ * publishes the tracks in a TObjArray of AliESDtrack.
+ *
+ * <h2>General properties:</h2>
+ *
+ * Component ID: \b Sample-ESDAnalysis <br>
+ * Library: \b libAliHLTSample.so     <br>
+ * Input Data Types: @ref kAliHLTDataTypeESDObject <br>
+ * Output Data Types: @ref kAliHLTDataTypeTObjArray|kAliHLTDataOriginSample
+ *                         {ROOTOBAR:SMPL} <br>
+ *
+ * <h2>Mandatory arguments:</h2>
+ * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
+ * Argument scan is implemented in the function ScanConfigurationArgument().
+ * see @ref alihltcomponent-initialization-ocdb.
+ * Please provide specific descriptions and implementations.
+ * \li -mandatory1     <i> teststring   </i> <br>
+ *      an argument with one parameter
+ *
+ * <h2>Optional arguments:</h2>
+ * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
+ * \li -optional1      <i> teststring   </i> <br>
+ *      an argument with one parameter
+ * \li -optional2                            <br>
+ *      an argument without parameters
+ *
+ * <h2>Configuration:</h2>
+ * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
+ *
+ * <h2>Default CDB entries:</h2>
+ * The component has just one default CDB entry in 
+ * <tt>HLT/ConfigSample/SampleESDAnalysis</tt>.
+ * It does not load any configuration from the global <tt>ConfigHLT</tt>
+ * folder.
+ * \li -TObjString object holding a string with the configuration parameters
+ *      explained above
+ *
+ * <h2>Performance:</h2>
+ * The component does not any event data processing.
+ *
+ * <h2>Memory consumption:</h2>
+ * The component does not any event data processing.
+ *
+ * <h2>Output size:</h2>
+ * The component has no output data.
+ *
+ *
+ * @ingroup alihlt_tutorial
+ */
+class AliHLTSampleESDAnalysisComponent : public AliHLTProcessor {
+public:
+  AliHLTSampleESDAnalysisComponent();
+  virtual ~AliHLTSampleESDAnalysisComponent();
+
+  // AliHLTComponent interface functions
+  const char* GetComponentID();
+  void GetInputDataTypes( vector<AliHLTComponentDataType>& list);
+  AliHLTComponentDataType GetOutputDataType();
+  void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier );
+  void GetOCDBObjectDescription( TMap* const targetMap);
+
+  // Spawn function, return new class instance
+  AliHLTComponent* Spawn();
+
+ protected:
+  // AliHLTComponent interface functions
+  int DoInit( int argc, const char** argv );
+  int DoDeinit();
+  int DoEvent( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData);
+  int ScanConfigurationArgument(int argc, const char** argv);
+  int Reconfigure(const char* cdbEntry, const char* chainId);
+  int ReadPreprocessorValues(const char* modules);
+
+  using AliHLTProcessor::DoEvent;
+
+private:
+  /** copy constructor prohibited */
+  AliHLTSampleESDAnalysisComponent(const AliHLTSampleESDAnalysisComponent&);
+  /** assignment operator prohibited */
+  AliHLTSampleESDAnalysisComponent& operator=(const AliHLTSampleESDAnalysisComponent&);
+
+  ClassDef(AliHLTSampleESDAnalysisComponent, 0)
+};
+#endif
diff --git a/HLT/exa/sampleEsdAnalysis.C b/HLT/exa/sampleEsdAnalysis.C
new file mode 100644 (file)
index 0000000..8132131
--- /dev/null
@@ -0,0 +1,139 @@
+// $Id$
+/**
+ * @file sampleEsdAnalysis.C
+ * @brief Example macro to run the AliHLTSampleESDAnalysisComponent in
+ * AliReconstruction.
+ *
+ * The component subscribes to the output of the default HLT reconstruction
+ * chain and extracts the ESD from the input.
+ *
+ * <pre>
+ * Usage: aliroot -b -q -l \
+ *     sampleEsdAnalysis.C'("file", "cdb", minEvent, maxEvent)'
+ *
+ * Examples:
+ *     sampleEsdAnalysis.C'("alien:///alice/data/2009/.../....root")' 
+ *     sampleEsdAnalysis.C'("raw.root", "local://$PWD", minEvent, MaxEvent)'
+ *
+ * Defaults
+ *     cdb="raw://"  -> take OCDB from GRID
+ *     minEvent=-1   -> no lower event selection
+ *     maxEvent=-1   -> no upper event selection
+ *
+ * </pre>
+ *
+ * The input file can be a file on the grid, indicated by the tag
+ * 'alien://' indicates. By default also the OCDB is set to the GRID.
+ * If either the file or the OCDB is taken from the GRID, the macros
+ * connects to the Grid in the beginning.
+ *
+ * As for the OCDB it is always a good idea to use the OCDB from the
+ * Grid as this will contain all the necessary objects and the latest
+ * calibration. The special URI 'raw://' is most advisable as it selects
+ * the storage automatically from the run number. Other options are e.g.
+ * - "alien://folder=/alice/data/2010/OCDB"
+ * - "local://$ALICE_ROOT/OCDB"
+ *
+ * Note: You need a valid GRID token, if you want to access files directly
+ * from the Grid, use 'alien-token-init' of your alien installation.
+ *
+ * @author Matthias.Richter@ift.uib.no
+ * @ingroup alihlt_tutorial
+ */
+void sampleEsdAnalysis(const char *filename,
+                      const char *cdbURI,
+                      int minEvent=-1,
+                      int maxEvent=-1)
+{
+  // connect to the GRID if we use a file or OCDB from the GRID
+  TString struri=cdbURI;
+  TString strfile=filename;
+  if (struri.BeginsWith("raw://") ||
+      strfile.Contains("://") && !strfile.Contains("local://")) {
+    TGrid::Connect("alien");
+  }
+
+  // Set the CDB storage location
+  AliCDBManager * man = AliCDBManager::Instance();
+  man->SetDefaultStorage(cdbURI);
+  if (struri.BeginsWith("local://") && !gSystem->AccessPathName("GRP/GRP/Data")) {
+    // set specific storage for GRP entry
+    man->SetSpecificStorage("GRP/GRP/Data", "local://$PWD");
+  }
+
+  //////////////////////////////////////////////////////////////////////////////////////
+  //
+  // Reconstruction settings
+  AliReconstruction rec;
+
+  if (minEvent>=0 || maxEvent>minEvent) {
+    if (minEvent<0) minEvent=0;
+    if (maxEvent<minEvent) maxEvent=minEvent;
+    rec.SetEventRange(minEvent,maxEvent);
+  }
+  rec.SetRunReconstruction("HLT ITS TPC");
+  rec.SetWriteESDfriend(kFALSE);
+  rec.SetInput(filename);
+
+  // QA options
+  rec.SetRunQA(":") ;
+  //rec.SetQARefDefaultStorage("local://$ALICE_ROOT/QAref") ;
+
+  //////////////////////////////////////////////////////////////////////////////////////
+  //
+  // setup the HLT system
+  AliHLTSystem* pHLT=AliHLTPluginBase::GetInstance();
+
+  // define a configuration for the SampleESDAnalysis component
+  // arguments:
+  //  1) id of the configuartion, later used to refer to this configuration
+  //  2) id of the component to run
+  //  3) parents, here the configuration 'GLOBAL-esd-converter' of the libAliHLTGlobal
+  //  4) optional component arguments
+  AliHLTConfiguration esdanalysis("ESD-Analysis", "SampleESDAnalysis", "GLOBAL-esd-converter", "");
+
+  // set option for the HLT module in AliReconstruction
+  // arguments
+  //  - ignore-hltout : ignore the HLTOUT payload from the HLT DDLs
+  //  - libraries to be used as plugins
+  //  - loglevel=0x79 : Important, Warning, Error, Fatal
+  //  - chains=ESD-Analysis : chains to be run
+  rec.SetOption("HLT",
+               "ignore-hltout " 
+               "libAliHLTUtil.so libAliHLTGlobal.so libAliHLTSample.so "
+               "loglevel=0x79 "
+               "chains=ESD-Analysis "
+               );
+
+  rec.SetRunPlaneEff(kFALSE);
+
+  // switch off cleanESD
+  rec.SetCleanESD(kFALSE);
+
+  AliLog::Flush();
+  rec.Run();
+
+}
+
+void sampleEsdAnalysis(const char *filename,
+                      int minEvent=-1,
+                      int maxEvent=-1)
+{
+  sampleEsdAnalysis(filename, "raw://", minEvent, maxEvent, modules, hltOptions);
+}
+
+void sampleEsdAnalysis()
+{
+  cout << "sampleEsdAnalysis: Run HLT component 'SampleESDAnalyis' in AliReconstruction" << endl;
+  cout << " Usage: aliroot -b -q -l \\" << endl;
+  cout << "     sampleEsdAnalysis.C'(\"file\", \"cdb\", minEvent, maxEvent)'" << endl;
+  cout << "" << endl;
+  cout << " Examples:" << endl;
+  cout << "     sampleEsdAnalysis.C'(\"alien:///alice/data/2009/.../....root\")' " << endl;
+  cout << "     sampleEsdAnalysis.C'(\"raw.root\", \"local://$PWD\", minEvent, MaxEvent)'" << endl;
+  cout << "" << endl;
+  cout << " Defaults" << endl;
+  cout << "     cdb=\"raw://\"  -> take OCDB from GRID" << endl;
+  cout << "     minEvent=-1   -> no lower event selection" << endl;
+  cout << "     maxEvent=-1   -> no upper event selection" << endl;
+}
index d1dbda0646cbd225672ac79c1b2131e05e22e9ba..5e4c1ef33852885a9b488bc5b569d9825d27f6b3 100644 (file)
@@ -10,6 +10,7 @@
 # will be created from the names of the header files
 CLASS_HDRS:=   AliHLTSampleComponent1.h \
                AliHLTSampleComponent2.h \
+               AliHLTSampleESDAnalysisComponent.h \
                AliHLTSampleMonitoringComponent.h \
                AliHLTAgentSample.h \
                AliHLTSamplePreprocessor.h \
@@ -36,7 +37,7 @@ MODULE_HDRS:=         $(CLASS_HDRS)
 # enable automatic generation. 
 MODULE_DHDR:=
 
-EINCLUDE := HLT/BASE HLT/shuttle HLT/SampleLib
+EINCLUDE := HLT/BASE HLT/shuttle HLT/SampleLib STEER
 
 LIBRARY_DEP := -lHLTbase -lCDB -lSTEERBase