]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Adding the trigger menu for the HLT global trigger.
authoraszostak <aszostak@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 19 Dec 2008 18:21:47 +0000 (18:21 +0000)
committeraszostak <aszostak@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 19 Dec 2008 18:21:47 +0000 (18:21 +0000)
Adding abstract base class for the global trigger implementation.
Modified AliHLTGlobalTriggerComponent to auto generate a global trigger implementation class during initialisation.

13 files changed:
HLT/libAliHLTTrigger.pkg
HLT/trigger/AliHLTGlobalTrigger.cxx [new file with mode: 0644]
HLT/trigger/AliHLTGlobalTrigger.h [new file with mode: 0644]
HLT/trigger/AliHLTGlobalTriggerComponent.cxx
HLT/trigger/AliHLTGlobalTriggerComponent.h
HLT/trigger/AliHLTGlobalTriggerDecision.h
HLT/trigger/AliHLTTriggerLinkDef.h
HLT/trigger/AliHLTTriggerMenu.cxx [new file with mode: 0644]
HLT/trigger/AliHLTTriggerMenu.h [new file with mode: 0644]
HLT/trigger/AliHLTTriggerMenuItem.cxx [new file with mode: 0644]
HLT/trigger/AliHLTTriggerMenuItem.h [new file with mode: 0644]
HLT/trigger/test/testGlobalTriggerComponent.C [new file with mode: 0644]
HLT/trigger/test/testTriggerDomain.C

index ffa4ce4df692659d47c3fc024c96033d642e73c2..7af06364451868c9fd90a394d068ecd69cd6cfa4 100644 (file)
@@ -14,7 +14,10 @@ CLASS_HDRS:= \
                 AliHLTTriggerDomain.h                       \
                 AliHLTDomainEntry.h                         \
                 AliHLTReadoutList.h                         \
+                AliHLTTriggerMenu.h                         \
+                AliHLTTriggerMenuItem.h                     \
                 AliHLTGlobalTriggerDecision.h               \
+                AliHLTGlobalTrigger.h                       \
                 AliHLTGlobalTriggerComponent.h              \
                 AliHLTTriggerAgent.h                        \
                 AliHLTEventSummary.h                        \
diff --git a/HLT/trigger/AliHLTGlobalTrigger.cxx b/HLT/trigger/AliHLTGlobalTrigger.cxx
new file mode 100644 (file)
index 0000000..21feb02
--- /dev/null
@@ -0,0 +1,101 @@
+/**************************************************************************
+ * This file is property of and copyright by the ALICE HLT Project        *
+ * ALICE Experiment at CERN, All rights reserved.                         *
+ *                                                                        *
+ * Primary Authors: Artur Szostak <artursz@iafrica.com>                   *
+ *                  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   AliHLTGlobalTrigger.cxx
+/// @author Artur Szostak <artursz@iafrica.com>
+/// @date   19 Dec 2008
+/// @brief  Implementation of the AliHLTGlobalTrigger base class.
+///
+/// The AliHLTGlobalTriggerComponent class is an abstract class from which a
+/// derived class is constructed by AliHLTTriggerMenu on the fly. The derived
+/// class then implements triggering based on the particular trigger menu.
+
+#include "AliHLTGlobalTrigger.h"
+#include "AliHLTGlobalTriggerDecision.h"
+#include <cstring>
+
+ClassImp(AliHLTGlobalTrigger)
+
+// Static factory array.
+AliHLTGlobalTrigger::Factory*
+AliHLTGlobalTrigger::Factory::fFactory[AliHLTGlobalTrigger::Factory::kMaxFactories]
+  = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
+
+
+AliHLTGlobalTrigger::AliHLTGlobalTrigger() :
+  fCounters()
+{
+  // Default constructor.
+}
+
+
+AliHLTGlobalTrigger::~AliHLTGlobalTrigger()
+{
+  // Default destructor.
+}
+
+
+AliHLTGlobalTrigger* AliHLTGlobalTrigger::Factory::CreateNew(const char* name)
+{
+  // Creates a new instance of the named trigger class.
+  
+  for (int i = 0; i < kMaxFactories; i++)
+  {
+    if (fFactory[i] != NULL)
+    {
+      if (strcmp(fFactory[i]->ClassName(), name) == 0)
+      {
+        return fFactory[i]->New();
+      }
+    }
+  }
+  return NULL;
+}
+
+
+AliHLTGlobalTrigger::Factory::Factory()
+{
+  // Default constructor resisters the class factory.
+  
+  for (int i = 0; i < kMaxFactories; i++)
+  {
+    if (fFactory[i] == NULL)
+    {
+      fFactory[i] = this;
+      return;
+    }
+  }
+  
+  HLTFatal("Trying to register too many global trigger factories.");
+}
+
+
+AliHLTGlobalTrigger::Factory::~Factory()
+{
+  // The default destructor deregisters the factory.
+  
+  for (int i = 0; i < kMaxFactories; i++)
+  {
+    if (fFactory[i] == this)
+    {
+      fFactory[i] = NULL;
+      return;
+    }
+  }
+  
+  HLTFatal("Could not find factory to deregister.");
+}
+
diff --git a/HLT/trigger/AliHLTGlobalTrigger.h b/HLT/trigger/AliHLTGlobalTrigger.h
new file mode 100644 (file)
index 0000000..5e9ba80
--- /dev/null
@@ -0,0 +1,144 @@
+#ifndef ALIHLTGLOBALTRIGGER_H
+#define ALIHLTGLOBALTRIGGER_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   AliHLTGlobalTrigger.h
+/// @author Artur Szostak <artursz@iafrica.com>
+/// @date   19 Dec 2008
+/// @brief  Declaration of the AliHLTGlobalTrigger base class.
+
+#include "TObject.h"
+#include "TArrayL64.h"
+#include "AliHLTDataTypes.h"
+#include "AliHLTLogging.h"
+
+class AliHLTTriggerDecision;
+class AliHLTGlobalTriggerDecision;
+
+/**
+ * \class AliHLTGlobalTrigger
+ * This class is an abstract class. Classes which derive from this class should
+ * implement the logic for a particular trigger menu. The AliHLTTriggerMenu class
+ * creates a class deriving from AliHLTGlobalTrigger on the fly to implement the
+ * trigger logic for that particular trigger menu.
+ */
+class AliHLTGlobalTrigger
+{
+ public:
+  
+  /**
+   * Default constructor.
+   */
+  AliHLTGlobalTrigger();
+  
+  /**
+   * Default destructor.
+   */
+  virtual ~AliHLTGlobalTrigger();
+  
+  /**
+   * Abstract method to indicate that a new event is being processed and the
+   * internal buffers should be cleared or reset.
+   */
+  virtual void NewEvent() = 0;
+  
+  /**
+   * Abstract method which should fill in the internal attributes from the given
+   * trigger decision.
+   * \param  decision  The trigger decision to fill from.
+   */
+  virtual void Add(const AliHLTTriggerDecision* decision) = 0;
+  
+  /**
+   * Abstract method which should fill in the internal attributes from the given
+   * object.
+   * \param  object  The object to fill from.
+   * \param  type  The data block type the object was found in.
+   * \param  spec  The data block specification the object was found in.
+   */
+  virtual void Add(
+      const TObject* object,
+      const AliHLTComponentDataType& type,
+      AliHLTUInt32_t spec
+    ) = 0;
+  
+  /**
+   * Abstract method that calculates the trigger decision
+   * \returns The global HLT trigger decision result.
+   */
+  virtual AliHLTGlobalTriggerDecision* CalculateTriggerDecision() = 0;
+  
+  /**
+   * Creates a new instance of a particular trigger class.
+   * \param name  The name of the class to create.
+   * \returns the new trigger class instance which needs to be deleted by the
+   *    caller with the delete operator.
+   */
+  static AliHLTGlobalTrigger* CreateNew(const char* name) { return Factory::CreateNew(name); }
+  
+ protected:
+  
+  /**
+   * The factory object is used to create new instances of classes via the
+   * AliHLTGlobalTrigger::CreateNew method.
+   * A single static instance of a factory must be created by classes deriving
+   * from AliHLTGlobalTrigger so that AliHLTGlobalTrigger::CreateNew will work
+   * properly.
+   */
+  class Factory : public AliHLTLogging
+  {
+   public:
+    
+    /**
+     * Default constructor registers a class factory for the creation of new
+     * instances of classes deriving from AliHLTGlobalTrigger.
+     */
+    Factory();
+    
+    /**
+     * The default destructor deregisters the factory from the class factory list.
+     */
+    ~Factory();
+    
+    /**
+     * Creates a new instance of a particular trigger class.
+     * \param name  The name of the class to create.
+     * \returns the new trigger class instance which needs to be deleted by the
+     *    caller with the delete operator.
+     */
+    static AliHLTGlobalTrigger* CreateNew(const char* name);
+    
+    /**
+     * Returns the class name of the object returned by the New() method.
+     */
+    virtual const char* ClassName() const = 0;
+    
+    /**
+     * Creates and returns a new instance of a trigger class.
+     * The returned object should be deleted via the delete operator.
+     */
+    virtual AliHLTGlobalTrigger* New() const = 0;
+    
+   private:
+    
+    enum {kMaxFactories = 8}; /// The maximum number of factories that can be registered.
+    
+    static Factory* fFactory[kMaxFactories];
+  };
+  
+  /// Not implemented. Do not allow copying of this object.
+  AliHLTGlobalTrigger(const AliHLTGlobalTrigger& obj);
+  /// Not implemented. Do not allow copying of this object.
+  AliHLTGlobalTrigger& operator = (const AliHLTGlobalTrigger& obj);
+  
+ private:
+  
+  TArrayL64 fCounters; //! Event trigger counters. One counter for each trigger class.
+  
+  ClassDef(AliHLTGlobalTrigger, 0) // Global HLT trigger base class which implements logic for a particular trigger menu.
+};
+
+#endif // ALIHLTGLOBALTRIGGER_H
+
index 47e9341e79d41f6dc76a16ba0f1acd4deba06313..39a88999b30323d5140bf3ec3d0720e7bbcbbc43 100644 (file)
 /// trigger information produced by components deriving from AliHLTTrigger.
 
 #include "AliHLTGlobalTriggerComponent.h"
+#include "AliHLTGlobalTriggerDecision.h"
+#include "AliHLTGlobalTrigger.h"
+#include "TUUID.h"
+#include "TROOT.h"
+#include "TSystem.h"
+#include <fstream>
+#include <cerrno>
 
 ClassImp(AliHLTGlobalTriggerComponent)
 
 
 AliHLTGlobalTriggerComponent::AliHLTGlobalTriggerComponent() :
-       AliHLTTrigger()
+       AliHLTTrigger(),
+       fTrigger(NULL)
 {
   // Default constructor.
 }
@@ -37,6 +45,8 @@ AliHLTGlobalTriggerComponent::AliHLTGlobalTriggerComponent() :
 AliHLTGlobalTriggerComponent::~AliHLTGlobalTriggerComponent()
 {
   // Default destructor.
+  
+  if (fTrigger != NULL) delete fTrigger;
 }
 
 
@@ -44,16 +54,41 @@ void AliHLTGlobalTriggerComponent::GetOutputDataSize(unsigned long& constBase, d
 {
   // Returns the output data size estimate.
 
-  constBase = strlen(GetTriggerName()) + 1;
+  constBase = sizeof(AliHLTGlobalTriggerDecision);
   inputMultiplier = 1;
 }
 
 
-int AliHLTGlobalTriggerComponent::DoTrigger()
+Int_t AliHLTGlobalTriggerComponent::DoInit(int /*argc*/, const char** /*argv*/)
 {
-  // This method will apply the global trigger decision.
+  // Initialises the global trigger component.
+  
+  AliHLTTriggerMenu* menu = NULL;
+  TString classname;
+  int result = GenerateTrigger(menu, classname);
+  if (result != 0) return result;
+  
+  fTrigger = AliHLTGlobalTrigger::CreateNew(classname.Data());
+  if (fTrigger == NULL)
+  {
+    HLTError("Could not create a new instance of '%s'.", classname.Data());
+    return -EIO;
+  }
+  
+  return 0;
+}
+
 
-  //TODO
+Int_t AliHLTGlobalTriggerComponent::DoDeinit()
+{
+  // Cleans up the global trigger component.
+  
+  if (fTrigger != NULL)
+  {
+    delete fTrigger;
+    fTrigger = NULL;
+  }
+  
   return 0;
 }
 
@@ -65,3 +100,114 @@ AliHLTComponent* AliHLTGlobalTriggerComponent::Spawn()
   return new AliHLTGlobalTriggerComponent;
 }
 
+
+int AliHLTGlobalTriggerComponent::DoTrigger()
+{
+  // This method will apply the global trigger decision.
+
+  if (fTrigger == NULL)
+  {
+    HLTFatal("Global trigger implementation object is NULL!");
+    return -EIO;
+  }
+  
+  fTrigger->NewEvent();
+  
+  // Fill in the input data.
+  const TObject* obj = GetFirstInputObject();
+  while (obj != NULL)
+  {
+    if (obj->IsA() == AliHLTTriggerDecision::Class())
+    {
+      const AliHLTTriggerDecision* decision = static_cast<const AliHLTTriggerDecision*>(obj);
+      fTrigger->Add(decision);
+    }
+    else
+    {
+      fTrigger->Add(obj, GetDataType(), GetSpecification());
+    }
+    obj = GetNextInputObject();
+  }
+
+  // Apply the trigger.
+  TriggerEvent(fTrigger->CalculateTriggerDecision());
+  return 0;
+}
+
+
+int AliHLTGlobalTriggerComponent::GenerateTrigger(const AliHLTTriggerMenu* /*menu*/, TString& name)
+{
+  // Generates the global trigger class that will implement the specified trigger menu.
+  
+  // Create a new UUID and replace the '-' characters with '_' to make it a valid
+  // C++ symbol name.
+  TUUID uuid;
+  TString uuidstr = uuid.AsString();
+  for (Int_t i = 0; i < uuidstr.Length(); i++)
+  {
+    if (uuidstr[i] == '-') uuidstr[i] = '_';
+  }
+  
+  // Create the name of the new class.
+  name = "AliHLTGlobalTriggerImpl_";
+  name += uuidstr;
+  TString filename = name + ".cxx";
+  
+  fstream code(filename.Data(), ios_base::out | ios_base::trunc);
+  if (not code.good())
+  {
+    HLTError("Could not open file '%s' for writing.", filename.Data());
+    return -EIO;
+  }
+  
+  code << "#include \"AliHLTGlobalTrigger.h\"" << endl;
+  code << "#include \"AliHLTGlobalTriggerDecision.h\"" << endl;
+  code << "class " << name << " : public AliHLTGlobalTrigger" << endl;
+  code << "{" << endl;
+  code << "public:" << endl;
+  code << "  " << name << "() : AliHLTGlobalTrigger(), fDecision() {" << endl;
+  code << "  }" << endl;
+  code << "  virtual ~" << name << "() {" << endl;
+  code << "  }" << endl;
+  code << "  virtual void NewEvent() {" << endl;
+  //code << "    ;" << endl;
+  code << "  }" << endl;
+  code << "  virtual void Add(const AliHLTTriggerDecision* decision) {" << endl;
+  //code << "    ;" << endl;
+  code << "  }" << endl;
+  code << "  virtual void Add(const TObject* object, const AliHLTComponentDataType& type, AliHLTUInt32_t spec) {" << endl;
+  //code << "    ;" << endl;
+  code << "  }" << endl;
+  code << "  virtual AliHLTGlobalTriggerDecision* CalculateTriggerDecision() {" << endl;
+  code << "    return &fDecision;" << endl;
+  code << "  }" << endl;
+  code << "  class FactoryImpl : public AliHLTGlobalTrigger::Factory" << endl;
+  code << "  {" << endl;
+  code << "  public:" << endl;
+  code << "    virtual const char* ClassName() const {" << endl;
+  code << "      return \"" << name << "\";" << endl;
+  code << "    }" << endl;
+  code << "    virtual AliHLTGlobalTrigger* New() const {" << endl;
+  code << "      return new " << name << "();" << endl;
+  code << "    }" << endl;
+  code << "  private:" << endl;
+  code << "    static FactoryImpl fFactoryImpl; // for registration only." << endl;
+  code << "  };" << endl;
+  code << "private:" << endl;
+  code << "  AliHLTGlobalTriggerDecision fDecision;" << endl;
+  code << "};" << endl;
+  code << name << "::FactoryImpl " << name << "::FactoryImpl::fFactoryImpl;" << endl;
+  
+  TString includePath = "-I${ALICE_ROOT}/include -I${ALICE_ROOT}/HLT/BASE -I${ALICE_ROOT}/HLT/trigger";
+  gSystem->SetIncludePath(includePath);
+  
+  TString cmd = ".L ";
+  cmd += filename;
+  cmd += "++";
+  gROOT->ProcessLine(cmd);
+  
+  code.close();
+  
+  return 0;
+}
+
index b2de81c2376095cd7ff45387ce2531d8e6ee082c..11a36d9be72bfae83951a3ba5300c6311725f955 100644 (file)
@@ -11,6 +11,9 @@
 
 #include "AliHLTTrigger.h"
 
+class AliHLTTriggerMenu;
+class AliHLTGlobalTrigger;
+
 /**
  * \class AliHLTGlobalTriggerComponent
  * This class applies the global HLT trigger to all trigger information produced
@@ -30,17 +33,7 @@ class AliHLTGlobalTriggerComponent : public AliHLTTrigger
    * @return string containing the global trigger name.
    */
   virtual const char* GetTriggerName() const { return "HLTGlobalTrigger"; };
-
-  /**
-   * Returns extra output data types this trigger generates.
-   * This returns an kAliHLTDataTypeTObject in <i>list</i>.
-   * @param list <i>[out]</i>: The list of data types to be filled.
-   */
-  virtual void GetOutputDataTypes(AliHLTComponentDataTypeList& list) const
-  {
-    list.push_back(kAliHLTDataTypeTObject);
-  }
-
+  
   /**
    * Get a ratio by how much the data volume is shrunk or enhanced.
    * The method returns a size proportional to the trigger name string length
@@ -51,6 +44,20 @@ class AliHLTGlobalTriggerComponent : public AliHLTTrigger
    */
   virtual void GetOutputDataSize(unsigned long& constBase, double& inputMultiplier);
   
+  /**
+   * Initialise the component.
+   * \param argc  The number of arguments in argv.
+   * \param argv  Array of component argument strings.
+   * \returns  Zero on success and negative number on failure.
+   */
+  virtual Int_t DoInit(int argc, const char** argv);
+  
+  /**
+   * Cleanup the component.
+   * \returns  Zero on success and negative number on failure.
+   */
+  virtual Int_t DoDeinit();
+  
   /**
    * Spawn function creates a new object.
    * @return new class instance.
@@ -72,6 +79,22 @@ class AliHLTGlobalTriggerComponent : public AliHLTTrigger
   
  private:
   
+  /**
+   * Generates the code for the global trigger to apply the given trigger menu.
+   * The code will then be compiled on the fly and loaded. The name of the new
+   * class is returned so that a new instance of the class can be created via:
+   * \code
+   *  AliHLTGlobalTrigger::CreateNew(name)
+   * \endcode
+   * where name is the name of the generated class as returned by this method.
+   * \param  menu  The trigger menu to create the global trigger class from.
+   * \param  name  The name of the generated class.
+   * \returns  The error code suitable to return in DoInit. Zero on success.
+   */
+  int GenerateTrigger(const AliHLTTriggerMenu* menu, TString& name);
+  
+  AliHLTGlobalTrigger* fTrigger;  //! Trigger object which implements the global trigger menu.
+  
   ClassDef(AliHLTGlobalTriggerComponent, 0) // Global HLT trigger component class which produces the final trigger decision and readout list.
 };
 
index c9254d0a79913248f6b829b4fbc419774bffe889..ca2c93326bdd17038c25814743d5b79edb1ba0da 100644 (file)
@@ -10,7 +10,7 @@
 /// @brief  Declaration of the AliHLTGlobalTriggerDecision class storing the global HLT decision.
 
 #include "AliHLTTriggerDecision.h"
-#include "TArrayL.h"
+#include "TArrayL64.h"
 
 class AliHLTGlobalTriggerDecision : public AliHLTTriggerDecision
 {
@@ -75,12 +75,12 @@ class AliHLTGlobalTriggerDecision : public AliHLTTriggerDecision
   /**
    * Returns the event trigger counters associated with the global trigger classes.
    */
-  const TArrayL& Counters() const { return fCounters; }
+  const TArrayL64& Counters() const { return fCounters; }
   
  private:
   
   TClonesArray fContributingTriggers;  /// The list of contributing trigger decisions from all AliHLTTrigger components that were considered.
-  TArrayL fCounters;  /// Event trigger counters. One counter for each trigger class in the global trigger.
+  TArrayL64 fCounters;  /// Event trigger counters. One counter for each trigger class in the global trigger.
   
   ClassDef(AliHLTGlobalTriggerDecision, 1) // Contains the HLT global trigger decision and information contributing to the decision.
 };
index 3c1f7ffad40946955406c58b36b93d89b389c473..b99d2f089b7951bd0e8f2acd246edfb5e7e9b299 100644 (file)
@@ -10,6 +10,7 @@
 #pragma link C++ struct AliHLTEventDDL+;
 #pragma link C++ class AliHLTReadoutList+;
 #pragma link C++ class AliHLTGlobalTriggerDecision+;
+#pragma link C++ class AliHLTGlobalTrigger+;
 #pragma link C++ class AliHLTGlobalTriggerComponent+;
 #pragma link C++ class AliHLTTriggerAgent+;
 #pragma link C++ class AliHLTEventSummary+;
@@ -18,4 +19,6 @@
 #pragma link C++ class AliHLTRunSummaryProducerComponent+;
 #pragma link C++ class AliHLTTriggerSelectiveReadoutComponent+;
 #pragma link C++ class AliHLTTriggerMonitoringComponent+;
+#pragma link C++ class AliHLTTriggerMenu+;
+#pragma link C++ class AliHLTTriggerMenuItem+;
 #endif
diff --git a/HLT/trigger/AliHLTTriggerMenu.cxx b/HLT/trigger/AliHLTTriggerMenu.cxx
new file mode 100644 (file)
index 0000000..1584ffe
--- /dev/null
@@ -0,0 +1,101 @@
+/**************************************************************************
+ * This file is property of and copyright by the ALICE HLT Project        *
+ * ALICE Experiment at CERN, All rights reserved.                         *
+ *                                                                        *
+ * Primary Authors: Artur Szostak <artursz@iafrica.com>                   *
+ *                  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   AliHLTTriggerMenu.cxx
+/// @author Artur Szostak <artursz@iafrica.com>
+/// @date   19 Dec 2008
+/// @brief  Implementation of the AliHLTTriggerMenu base class.
+///
+/// The AliHLTTriggerMenu class implements the HLT global trigger menu,
+/// which defines how and on what events the HLT triggers.
+
+#include "AliHLTTriggerMenu.h"
+#include "Riostream.h"
+
+ClassImp(AliHLTTriggerMenu)
+
+
+AliHLTTriggerMenu::AliHLTTriggerMenu() :
+  TObject(),
+  fName("Unknown"),
+  fItems(AliHLTTriggerMenuItem::Class(), 100)
+{
+  // Default constructor.
+}
+
+
+AliHLTTriggerMenu::~AliHLTTriggerMenu()
+{
+  // Default destructor.
+}
+
+
+AliHLTTriggerMenu::AliHLTTriggerMenu(const AliHLTTriggerMenu& obj) :
+  TObject(obj),
+  fName(obj.fName),
+  fItems(AliHLTTriggerMenuItem::Class(), obj.fItems.GetEntriesFast())
+{
+  // Copy constructor performs a deep copy.
+  
+  for (UInt_t i = 0; i < obj.NumberOfItems(); i++)
+  {
+    AddItem(*obj.Item(i));
+  }
+}
+
+
+AliHLTTriggerMenu& AliHLTTriggerMenu::operator = (const AliHLTTriggerMenu& obj)
+{
+  // Assignment operator performs a deep copy.
+  
+  if (this != &obj)
+  {
+    TObject::operator = (obj);
+    fName = obj.fName;
+    fItems.Clear();
+    for (UInt_t i = 0; i < obj.NumberOfItems(); i++)
+    {
+      AddItem(*obj.Item(i));
+    }
+  }
+  return *this;
+}
+
+
+void AliHLTTriggerMenu::Print(Option_t* option) const
+{
+  // Prints the contents of the trigger menu.
+  
+  cout << "HLT Trigger Menu: " << fName.Data();
+  TString opt = option;
+  if (opt.Contains("short"))
+  {
+    cout << ", contains " << NumberOfItems() << " entries." << endl;
+    return;
+  }
+  cout << endl;
+  cout << setw(10) << "Prescalar" <<  " | "
+       << setw(30) << "Trigger condision" << " | "
+       << setw(30) << "Domain merge expression" << setw(0) << endl;
+  cout << setfill('-') << setw(10) << "-" <<  "-+-"
+       << setw(30) << "-" << "-+-"
+       << setw(30) << "-" << setw(0) << endl;
+  for (UInt_t i = 0; i < NumberOfItems(); i++)
+  {
+    Item(i)->Print("compact");
+  }
+}
+
diff --git a/HLT/trigger/AliHLTTriggerMenu.h b/HLT/trigger/AliHLTTriggerMenu.h
new file mode 100644 (file)
index 0000000..0ed714a
--- /dev/null
@@ -0,0 +1,112 @@
+#ifndef ALIHLTTRIGGERMENU_H
+#define ALIHLTTRIGGERMENU_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   AliHLTTriggerMenu.h
+/// @author Artur Szostak <artursz@iafrica.com>
+/// @date   19 Dec 2008
+/// @brief  Declaration of the AliHLTTriggerMenu base class.
+
+#include "TObject.h"
+#include "TString.h"
+#include "TClonesArray.h"
+#include "AliHLTTriggerMenuItem.h"
+
+/**
+ * \class AliHLTTriggerMenu
+ * This class is an abstract class. Classes which derive from this class should
+ * implement the logic for a particular trigger menu. The AliHLTTriggerMenu class
+ * creates a class deriving from AliHLTTriggerMenu on the fly to implement the
+ * trigger logic for that particular trigger menu.
+ */
+class AliHLTTriggerMenu : public TObject
+{
+ public:
+  
+  /**
+   * Default constructor.
+   */
+  AliHLTTriggerMenu();
+  
+  /**
+   * Default destructor.
+   */
+  virtual ~AliHLTTriggerMenu();
+  
+  /**
+   * Inherited from TObject, this prints the contents of the trigger menu.
+   * \param option  Can be "short" which will print the short format.
+   */
+  virtual void Print(Option_t* option = "") const;
+
+  /**
+   * Copy constructor performs a deep copy of the object.
+   * \param  obj  Object to copy from.
+   */
+  AliHLTTriggerMenu(const AliHLTTriggerMenu& obj);
+  
+  /**
+   * Assignment operator performs a deep copy of the object.
+   * \param  obj  Object to copy from.
+   * \return  This object is returned after being replaced by a copy of <i>obj</i>.
+   */
+  AliHLTTriggerMenu& operator = (const AliHLTTriggerMenu& obj);
+  
+  /**
+   * Inherited from TObject. Returns the name of the trigger menu.
+   */
+  virtual const char* GetName() const { return fName.Data(); }
+  
+  /**
+   * Returns the name of the trigger menu.
+   */
+  const char* Name() const { return fName.Data(); }
+  
+  /**
+   * Sets the name of the trigger menu.
+   */
+  void Name(const char* name) { fName = name; }
+  
+  /**
+   * Returns the number of items in the trigger menu.
+   */
+  UInt_t NumberOfItems() const { return UInt_t(fItems.GetEntriesFast()); }
+  
+  /**
+   * Fetches the i'th trigger menu item.
+   */
+  const AliHLTTriggerMenuItem* Item(UInt_t i) const
+  {
+    if (i >= UInt_t(fItems.GetEntriesFast())) return NULL;
+    return static_cast<const AliHLTTriggerMenuItem*>( fItems.UncheckedAt(Int_t(i)) );
+  }
+  
+  /**
+   * Fetches the i'th trigger menu item for editing.
+   */
+  AliHLTTriggerMenuItem* Item(UInt_t i)
+  {
+    if (i >= UInt_t(fItems.GetEntriesFast())) return NULL;
+    return static_cast<AliHLTTriggerMenuItem*>( fItems.UncheckedAt(Int_t(i)) );
+  }
+  
+  /**
+   * Adds a new entry to the trigger menu.
+   */
+  void AddItem(const AliHLTTriggerMenuItem& entry)
+  {
+    new (fItems[fItems.GetEntriesFast()]) AliHLTTriggerMenuItem(entry);
+  }
+  
+ private:
+  
+  TString fName;  /// Name of the trigger menu.
+  TClonesArray fItems;  /// List of trigger menu items.
+  
+  ClassDef(AliHLTTriggerMenu, 1) // Trigger menu for the global HLT trigger.
+};
+
+#endif // ALIHLTTRIGGERMENU_H
+
diff --git a/HLT/trigger/AliHLTTriggerMenuItem.cxx b/HLT/trigger/AliHLTTriggerMenuItem.cxx
new file mode 100644 (file)
index 0000000..77652e6
--- /dev/null
@@ -0,0 +1,65 @@
+/**************************************************************************
+ * This file is property of and copyright by the ALICE HLT Project        *
+ * ALICE Experiment at CERN, All rights reserved.                         *
+ *                                                                        *
+ * Primary Authors: Artur Szostak <artursz@iafrica.com>                   *
+ *                  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   AliHLTTriggerMenuItem.cxx
+/// @author Artur Szostak <artursz@iafrica.com>
+/// @date   19 Dec 2008
+/// @brief  Implementation of the AliHLTTriggerMenuItem class.
+///
+/// The AliHLTTriggerMenuItem contains information about a entry in the global
+/// HLT trigger menu.
+
+#include "AliHLTTriggerMenuItem.h"
+#include "Riostream.h"
+
+ClassImp(AliHLTTriggerMenuItem)
+
+
+AliHLTTriggerMenuItem::AliHLTTriggerMenuItem() :
+  TObject(),
+  fConditionExpr(),
+  fDomainExpr(),
+  fPrescalar(0)
+{
+  // Default constructor.
+}
+
+
+AliHLTTriggerMenuItem::~AliHLTTriggerMenuItem()
+{
+  // Default destructor.
+}
+
+
+void AliHLTTriggerMenuItem::Print(Option_t* option) const
+{
+  // Prints the contents of the trigger menu item.
+  
+  TString opt = option;
+  if (opt.Contains("compact"))
+  {
+    cout << "   Trigger condision expression = " << fConditionExpr.Data();
+    cout << "Trigger domain merge expression = " << fDomainExpr.Data();
+    cout << "                     Pre-scalar = " << fPrescalar;
+  }
+  else
+  {
+    cout << setw(10) << fPrescalar << " | "
+         << setw(30) << fConditionExpr.Data() << " | "
+         << setw(30) << fDomainExpr.Data() << setw(0) << endl;
+  }
+}
+
diff --git a/HLT/trigger/AliHLTTriggerMenuItem.h b/HLT/trigger/AliHLTTriggerMenuItem.h
new file mode 100644 (file)
index 0000000..fabaef5
--- /dev/null
@@ -0,0 +1,80 @@
+#ifndef ALIHLTTRIGGERMENUITEM_H
+#define ALIHLTTRIGGERMENUITEM_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   AliHLTTriggerMenuItem.h
+/// @author Artur Szostak <artursz@iafrica.com>
+/// @date   19 Dec 2008
+/// @brief  Declaration of the AliHLTTriggerMenuItem class.
+
+#include "TObject.h"
+#include "TString.h"
+#include "TArrayL.h"
+
+/**
+ * \class AliHLTTriggerMenuItem
+ * TODO
+ */
+class AliHLTTriggerMenuItem : public TObject
+{
+ public:
+  
+  /**
+   * Default constructor.
+   */
+  AliHLTTriggerMenuItem();
+  
+  /**
+   * Default destructor.
+   */
+  virtual ~AliHLTTriggerMenuItem();
+  
+  /**
+   * Inherited from TObject, this prints the contents of the menu item.
+   * \param option  Can be "compact", which will print in the compact format.
+   */
+  virtual void Print(Option_t* option = "") const;
+  
+  /**
+   * Returns the trigger condition expression.
+   */
+  const char* TriggerCondision() const { return fConditionExpr.Data(); }
+  
+  /**
+   * Set the trigger condition expression.
+   */
+  void TriggerCondision(const char* value) { fConditionExpr = value; }
+  
+  /**
+   * Returns the trigger domain merging expression.
+   */
+  const char* MergeExpression() const { return fDomainExpr.Data(); }
+  
+  /**
+   * Set the trigger domain merging expression.
+   */
+  void MergeExpression(const char* value) { fDomainExpr = value; }
+  
+  /**
+   * Returns the pre-scalar value.
+   */
+  UInt_t PreScalar() const { return fPrescalar; }
+  
+  /**
+   * Set the pre-scalar value. A value of zero turns off the prescalar.
+   */
+  void PreScalar(UInt_t value) { fPrescalar = value; }
+
+ private:
+  
+  TString fConditionExpr;  /// The trigger condition expression.
+  TString fDomainExpr;  /// Trigger domain merging expression.
+  UInt_t fPrescalar;  /// Pre-scalar value used to optionally reduce the trigger rate. Every modulus n'th event is triggered, where n equals the pre-scalar value.
+  
+  ClassDef(AliHLTTriggerMenuItem, 1) // Trigger menu item for global HLT trigger.
+};
+
+#endif // ALIHLTTRIGGERMENUITEM_H
+
diff --git a/HLT/trigger/test/testGlobalTriggerComponent.C b/HLT/trigger/test/testGlobalTriggerComponent.C
new file mode 100644 (file)
index 0000000..3295eca
--- /dev/null
@@ -0,0 +1,55 @@
+/**************************************************************************
+ * This file is property of and copyright by the ALICE HLT Project        *
+ * ALICE Experiment at CERN, All rights reserved.                         *
+ *                                                                        *
+ * Primary Authors: Artur Szostak <artursz@iafrica.com>                   *
+ *                  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   testGlobalTriggerComponent.C
+ * @author Artur Szostak <artursz@iafrica.com>
+ * @date   19 Dec 2008
+ *
+ * This macro is used to test the AliHLTGlobalTriggerComponent class.
+ */
+void testGlobalTriggerComponent()
+{
+       gSystem->Load("libAliHLTTrigger.so");
+
+       TFile* file = new TFile("testInputFile.root", "RECREATE");
+       
+       AliHLTReadoutList readoutList1("TPC");
+       AliHLTTriggerDomain triggerDomain1;
+       AliHLTTriggerDecision decision1(true, "Trigger1", readoutList1, triggerDomain1);
+       
+       AliHLTReadoutList readoutList2;
+       AliHLTTriggerDomain triggerDomain2;
+       triggerDomain2.Add("aaaa", "bbbb");
+       AliHLTTriggerDecision decision2(true, "Trigger2", readoutList2, triggerDomain2);
+       
+       decision1.Write("Trigger1");
+       decision2.Write("Trigger2");
+       delete file;
+
+       AliHLTSystem sys;
+       sys.LoadComponentLibraries("libAliHLTUtil.so");
+       sys.LoadComponentLibraries("libAliHLTTrigger.so");
+       
+       AliHLTConfiguration pub("pub", "ROOTFilePublisher", NULL, " -datatype ROOTTOBJ 'HLT ' -datafile testInputFile.root");
+       AliHLTConfiguration proc("proc", "HLTGlobalTrigger", "pub", "");
+       AliHLTConfiguration sink("sink", "ROOTFileWriter", "proc", "-datafile testOutput.root");
+       
+       sys.BuildTaskList("sink");
+       sys.Run(1);
+}
+
index bd8ba2a9aa841ec556bf9b71a389543db68e311d..ab0bdc15b24cefcc5204eccb38370188e9d01293 100644 (file)
  **************************************************************************/
 
 /**
+ * @file   testGlobalTriggerComponent.C
+ * @author Artur Szostak <artursz@iafrica.com>
+ * @date   4 Dec 2008
+ *
  * This macro is used to test the behaviour of the AliHLTTriggerDomain class.
  * We specifically check that the AliHLTTriggerDomain operators behave correctly
  * as set operations.