]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
correcting implementation of CTP trigger handling in the GlobalTrigger object, revert...
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 7 Oct 2009 08:33:09 +0000 (08:33 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 7 Oct 2009 08:33:09 +0000 (08:33 +0000)
- the TClonesArray of trigger decision objects designated for the CTP triggers is now owned by the trigger component
- proper fix for the header include problem (https://savannah.cern.ch/bugs/?56302): in case of HLT build system, include files are taken from the include directory of the installation
- minor bugfix AliHLTGlobalTriggerComponent command arg parsing: -debug skipped next argument
- bugfix AliHLTGlobalTriggerComponent: the -skipctp option is now only applied on the level of adding CTP info to the output trigger decision object. The CTPData object is needed in any case to perform the masking of the readout
list according to the detectors of the CTP trigger class
- added option '-cint' to switch to CINT interpretation of the generated trigger code instead of runtime compilation, some fixes regarding this, but did not get it working so far

HLT/trigger/AliHLTGlobalTrigger.cxx
HLT/trigger/AliHLTGlobalTrigger.h
HLT/trigger/AliHLTGlobalTriggerComponent.cxx
HLT/trigger/AliHLTGlobalTriggerComponent.h

index ce558bd451707af32f2e898e23d5cba9f7adfbe3..08914ef3030e6a369462a562c24c796a03a90869 100644 (file)
 
 #include "AliHLTGlobalTrigger.h"
 #include "AliHLTGlobalTriggerDecision.h"
-#include "AliHLTCTPData.h"
-#include "TArrayL64.h"
-#include "TClonesArray.h"
 #include <cstring>
-#include <cassert>
 
 ClassImp(AliHLTGlobalTrigger)
 
@@ -41,9 +37,8 @@ AliHLTGlobalTrigger::Factory::fFactory[AliHLTGlobalTrigger::Factory::kMaxFactori
 
 
 AliHLTGlobalTrigger::AliHLTGlobalTrigger() :
-  AliHLTLogging()
-  , fCTPDecisions(NULL)
-  , fCounters(NULL)
+  AliHLTLogging(),
+  fCounters()
 {
   // Default constructor.
 }
@@ -52,13 +47,6 @@ AliHLTGlobalTrigger::AliHLTGlobalTrigger() :
 AliHLTGlobalTrigger::~AliHLTGlobalTrigger()
 {
   // Default destructor.
-  if (fCounters) {
-    delete fCounters;
-  }
-  if (fCTPDecisions) {
-    fCTPDecisions->Delete();
-    delete fCTPDecisions;
-  }
 }
 
 
@@ -118,68 +106,10 @@ void AliHLTGlobalTrigger::ResetCounters(UInt_t number)
 {
   // Resets the trigger counters.
   
-  if (!fCounters) fCounters = new TArrayL64(number);
-  if (!fCounters) return;
-
-  fCounters->Set(number);
+  fCounters.Set(number);
   for (UInt_t i = 0; i < number; i++)
   {
-    (*fCounters)[i] = 0;
-  }
-}
-
-void AliHLTGlobalTrigger::IncrementCounter(UInt_t i) 
-{
-  // increment a specific counter
-  if (fCounters && i<(unsigned)fCounters->GetSize()) ++(*fCounters)[i]; 
-}
-
-Long64_t AliHLTGlobalTrigger::GetCounter(UInt_t i) const
-{
-  if (fCounters && i<(unsigned)fCounters->GetSize()) return (*fCounters)[i];
-  return 0;
-}
-
-int AliHLTGlobalTrigger::AddCTPDecisions(const AliHLTCTPData* pCTPData, const AliHLTComponentTriggerData* trigData)
-{
-  // add trigger decisions for the valid CTP classes
-  if (!pCTPData) return 0;
-
-  AliHLTUInt64_t triggerMask=pCTPData->Mask();
-  AliHLTUInt64_t bit0=0x1;
-  if (!fCTPDecisions) {
-    fCTPDecisions=new TClonesArray(AliHLTTriggerDecision::Class(), gkNCTPTriggerClasses);
-    if (!fCTPDecisions) return -ENOMEM;
-
-    fCTPDecisions->ExpandCreate(gkNCTPTriggerClasses);
-    for (int i=0; i<gkNCTPTriggerClasses; i++) {
-      const char* name=pCTPData->Name(i);
-      if (triggerMask&(bit0<<i) && name) {
-       AliHLTTriggerDecision* pDecision=dynamic_cast<AliHLTTriggerDecision*>(fCTPDecisions->At(i));
-       assert(pDecision);
-       if (!pDecision) return -ENOENT;
-       pDecision->Name(name);
-      }
-    }
-  }
-
-  for (int i=0; i<gkNCTPTriggerClasses; i++) {
-    const char* name=pCTPData->Name(i);
-    if ((triggerMask&(bit0<<i))==0 || name==NULL) continue;
-    AliHLTTriggerDecision* pDecision=dynamic_cast<AliHLTTriggerDecision*>(fCTPDecisions->At(i));
-    HLTDebug("updating CTP trigger decision %d %s (%p casted %p)", i, name, fCTPDecisions->At(i), pDecision);
-    if (!pDecision) return -ENOENT;
-
-    bool result=false;
-    if (trigData) result=pCTPData->EvaluateCTPTriggerClass(name, *trigData);
-    else result=pCTPData->EvaluateCTPTriggerClass(name);
-    pDecision->Result(result);
-    pDecision->TriggerDomain().Clear();
-    pDecision->TriggerDomain().Add(pCTPData->ReadoutList(*trigData));
-
-    Add(fCTPDecisions->At(i), kAliHLTDataTypeTriggerDecision, kAliHLTVoidDataSpec);
+    fCounters[i] = 0;
   }
-
-  return 0;
 }
 
index d4811f2e8b2932e6ef2412a0a2ae0e90d8f6a327..ee26b4556fbc05157a9a78ad9de87820bf206b2e 100644 (file)
@@ -12,6 +12,7 @@
 /// @brief  Declaration of the AliHLTGlobalTrigger base class.
 
 #include "TObject.h"
+#include "TArrayL64.h"
 #include "AliHLTDataTypes.h"
 #include "AliHLTLogging.h"
 
@@ -19,9 +20,7 @@ class AliHLTTriggerDomain;
 class AliHLTTriggerDecision;
 class AliHLTGlobalTriggerDecision;
 class AliHLTTriggerMenu;
-class AliHLTCTPData;
 class TClonesArray;
-class TArrayL64;
 
 /**
  * \class AliHLTGlobalTrigger
@@ -56,12 +55,7 @@ class AliHLTGlobalTrigger : public AliHLTLogging
    * internal buffers should be cleared or reset.
    */
   virtual void NewEvent() = 0;
-
-  /**
-   * Add trigger decisions according to the active CTP trigger classes
-   */
-  int AddCTPDecisions(const AliHLTCTPData* pCTPData, const AliHLTComponentTriggerData* trigData=NULL);
-
+  
   /**
    * Abstract method which should fill in the internal attributes from the given
    * object.
@@ -100,10 +94,8 @@ class AliHLTGlobalTrigger : public AliHLTLogging
   /**
    * Returns the array of trigger counters.
    */
-  const TArrayL64* Counters() const { return fCounters; }
+  const TArrayL64& Counters() const { return fCounters; }
   
-  TClonesArray* GetCTPDecisions() const {return fCTPDecisions; }
-
  protected:
   
   /**
@@ -154,26 +146,26 @@ class AliHLTGlobalTrigger : public AliHLTLogging
     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);
+  
   /**
    * Increments a trigger counter by one.
    * \param i  The counter to increment.
    */
-  void IncrementCounter(UInt_t i);
+  void IncrementCounter(UInt_t i) { ++fCounters[i]; };
   
   /**
    * Returns a trigger counter's value.
    * \param i  The counter number to return.
    */
-  Long64_t GetCounter(UInt_t i) const;
+  Long64_t GetCounter(UInt_t i) const { return fCounters[i]; };
   
  private:
-  /// 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);
-
-  TClonesArray* fCTPDecisions; //! AliHLTTriggerDecision objects for the CTP classes
-  TArrayL64* fCounters; //! Event trigger counters. One counter for each trigger class.
+  
+  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.
 };
index 7cd1bc802ef4d029f2da0db2e2df24e7b03bf78e..7e1b962406e51663b3181440296264ffde1c7e03 100644 (file)
@@ -43,6 +43,7 @@
 #include "TDatime.h"
 #include <fstream>
 #include <cerrno>
+#include <cassert>
 
 ClassImp(AliHLTGlobalTriggerComponent)
 
@@ -53,7 +54,10 @@ AliHLTGlobalTriggerComponent::AliHLTGlobalTriggerComponent() :
        AliHLTTrigger(),
        fTrigger(NULL),
        fDebugMode(false),
-       fCodeFileName()
+       fRuntimeCompile(true),
+       fSkipCTPCounters(false),
+       fCodeFileName(),
+       fCTPDecisions(NULL)
 {
   // Default constructor.
   
@@ -66,6 +70,11 @@ AliHLTGlobalTriggerComponent::~AliHLTGlobalTriggerComponent()
   // Default destructor.
   
   if (fTrigger != NULL) delete fTrigger;
+
+  if (fCTPDecisions) {
+    fCTPDecisions->Delete();
+    delete fCTPDecisions;
+  }
 }
 
 
@@ -83,7 +92,6 @@ Int_t AliHLTGlobalTriggerComponent::DoInit(int argc, const char** argv)
   // Initialises the global trigger component.
   
   fDebugMode = false;
-  bool bSkipCTPCounters=false;
   const char* configFileName = NULL;
   const char* codeFileName = NULL;
   TString classname;
@@ -141,7 +149,12 @@ Int_t AliHLTGlobalTriggerComponent::DoInit(int argc, const char** argv)
         HLTWarning("The debug flag was already specified. Ignoring this instance.");
       }
       fDebugMode = true;
-      i++;
+      continue;
+    }
+    
+    if (strcmp(argv[i], "-cint") == 0)
+    {
+      fRuntimeCompile = false;
       continue;
     }
     
@@ -172,7 +185,7 @@ Int_t AliHLTGlobalTriggerComponent::DoInit(int argc, const char** argv)
     if (strcmp(argv[i], "-skipctp") == 0)
     {
       HLTInfo("Skipping CTP counters in trigger decision");
-      bSkipCTPCounters=true;
+      fSkipCTPCounters=true;
       continue;
     }
         
@@ -253,7 +266,7 @@ Int_t AliHLTGlobalTriggerComponent::DoInit(int argc, const char** argv)
   fTrigger->ResetCounters(menu->NumberOfItems());
 
   // setup the CTP accounting in AliHLTComponent
-  if (!bSkipCTPCounters) SetupCTPData();
+  SetupCTPData();
 
   // Set the default values from the trigger menu.
   SetDescription(menu->DefaultDescription());
@@ -280,6 +293,12 @@ Int_t AliHLTGlobalTriggerComponent::DoDeinit()
   }
   fCodeFileName="";
   
+  if (fCTPDecisions) {
+    fCTPDecisions->Delete();
+    delete fCTPDecisions;
+  }
+  fCTPDecisions=NULL;
+
   return 0;
 }
 
@@ -321,7 +340,7 @@ int AliHLTGlobalTriggerComponent::DoTrigger()
   // add trigger decisions for every CTP class
   const AliHLTCTPData* pCTPData=CTPData();
   if (pCTPData) {
-    fTrigger->AddCTPDecisions(pCTPData, GetTriggerData());
+    AddCTPDecisions(fTrigger, pCTPData, GetTriggerData());
   }
 
   // Calculate the global trigger result and trigger domain, then create and push
@@ -349,10 +368,7 @@ int AliHLTGlobalTriggerComponent::DoTrigger()
     decision.ReadoutList(maskedList);
   }
 
-  const TArrayL64* counters=fTrigger->Counters();
-  if (counters) {
-    decision.SetCounters(*counters, GetEventCount()+1);
-  }
+  decision.SetCounters(fTrigger->Counters(), GetEventCount()+1);
   static UInt_t lastTime=0;
   TDatime time;
   if (time.Get()-lastTime>5) {
@@ -375,7 +391,7 @@ int AliHLTGlobalTriggerComponent::DoTrigger()
     obj = GetNextInputObject();
   }
 
-  if (CTPData()) decision.AddInputObject(CTPData());
+  if (!fSkipCTPCounters && CTPData()) decision.AddInputObject(CTPData());
 
   CreateEventDoneReadoutFilter(decision.TriggerDomain(), 3);
   CreateEventDoneReadoutFilter(decision.TriggerDomain(), 4);
@@ -418,6 +434,7 @@ int AliHLTGlobalTriggerComponent::GenerateTrigger(
   int result = BuildSymbolList(menu, symbols);
   if (result != 0) return result;
   
+  //code << "#ifndef __CINT__" << endl;
   code << "#include <cstring>" << endl;
   code << "#include \"TString.h\"" << endl;
   code << "#include \"TClonesArray.h\"" << endl;
@@ -429,6 +446,7 @@ int AliHLTGlobalTriggerComponent::GenerateTrigger(
   code << "#include \"AliHLTTriggerMenu.h\"" << endl;
   code << "#include \"AliHLTTriggerMenuItem.h\"" << endl;
   code << "#include \"AliHLTTriggerMenuSymbol.h\"" << endl;
+  //code << "#endif //__CINT__" << endl;
   
   // Add any include files that were specified on the command line.
   for (Int_t i = 0; i < includeFiles.GetEntriesFast(); i++)
@@ -704,9 +722,19 @@ int AliHLTGlobalTriggerComponent::LoadTriggerClass(
   // Loads the code for a custom global trigger class implementation on the fly.
   
   TString compiler = gSystem->GetBuildCompilerVersion();
-  if (compiler.Contains("gcc") or compiler.Contains("icc"))
-  {
-    TString includePath = "-I${ALIHLT_TOPDIR}/BASE -I${ALIHLT_TOPDIR}/trigger -I${ALICE_ROOT}/include -I${ALICE_ROOT}/HLT/BASE -I${ALICE_ROOT}/HLT/trigger";
+  if (fRuntimeCompile && (compiler.Contains("gcc") or compiler.Contains("icc")))
+  {
+    TString includePath;
+#if defined(PKGINCLUDEDIR)
+    // this is especially for the HLT build system where the package is installed
+    // in a specific directory including proper treatment of include files
+    includePath.Form("-I%s", PKGINCLUDEDIR);
+#else
+    // the default AliRoot behavior, all include files can be found in the
+    // $ALICE_ROOT subfolders
+    includePath = "-I${ALICE_ROOT}/include -I${ALICE_ROOT}/HLT/BASE -I${ALICE_ROOT}/HLT/trigger";
+#endif
+    HLTDebug("using include settings: %s", includePath.Data());
     // Add any include paths that were specified on the command line.
     for (Int_t i = 0; i < includePaths.GetEntriesFast(); i++)
     {
@@ -736,7 +764,7 @@ int AliHLTGlobalTriggerComponent::LoadTriggerClass(
   else
   {
     // If we do not support the compiler then try interpret the class instead.
-    TString cmd = ".L ";
+    TString cmd = ".x ";
     cmd += filename;
     Int_t errorcode = TInterpreter::kNoError;
     gROOT->ProcessLine(cmd, &errorcode);
@@ -851,9 +879,8 @@ int AliHLTGlobalTriggerComponent::PrintStatistics(const AliHLTGlobalTrigger* pTr
 {
   // print some statistics
   ULong64_t count=0;
-  const TArrayL64* counters=pTrigger->Counters();
-  for (int i=0; counters!=NULL && i<counters->GetSize(); i++) {
-    count+=(*counters)[i];
+  for (int i=0; i<pTrigger->Counters().GetSize(); i++) {
+    count+=pTrigger->Counters()[i];
   }
   int totalEvents=GetEventCount()+offset;
   float ratio=0;
@@ -861,3 +888,51 @@ int AliHLTGlobalTriggerComponent::PrintStatistics(const AliHLTGlobalTrigger* pTr
   HLTLog(level, "total events: %d - triggered events: %llu (%.1f%%)", totalEvents, count, ratio);
   return 0;
 }
+
+int AliHLTGlobalTriggerComponent::AddCTPDecisions(AliHLTGlobalTrigger* pTrigger, const AliHLTCTPData* pCTPData, const AliHLTComponentTriggerData* trigData)
+{
+  // add trigger decisions for the valid CTP classes
+  if (!pCTPData || !pTrigger) return 0;
+
+  AliHLTUInt64_t triggerMask=pCTPData->Mask();
+  AliHLTUInt64_t bit0=0x1;
+  if (!fCTPDecisions) {
+    fCTPDecisions=new TClonesArray(AliHLTTriggerDecision::Class(), gkNCTPTriggerClasses);
+    if (!fCTPDecisions) return -ENOMEM;
+
+    fCTPDecisions->ExpandCreate(gkNCTPTriggerClasses);
+    for (int i=0; i<gkNCTPTriggerClasses; i++) {
+      const char* name=pCTPData->Name(i);
+      if (triggerMask&(bit0<<i) && name) {
+       AliHLTTriggerDecision* pDecision=dynamic_cast<AliHLTTriggerDecision*>(fCTPDecisions->At(i));
+       assert(pDecision);
+       if (!pDecision) {
+         delete fCTPDecisions;
+         fCTPDecisions=NULL;
+         return -ENOENT;
+       }
+       pDecision->Name(name);
+      }
+    }
+  }
+
+  for (int i=0; i<gkNCTPTriggerClasses; i++) {
+    const char* name=pCTPData->Name(i);
+    if ((triggerMask&(bit0<<i))==0 || name==NULL) continue;
+    AliHLTTriggerDecision* pDecision=dynamic_cast<AliHLTTriggerDecision*>(fCTPDecisions->At(i));
+    HLTDebug("updating CTP trigger decision %d %s (%p casted %p)", i, name, fCTPDecisions->At(i), pDecision);
+    if (!pDecision) return -ENOENT;
+
+    bool result=false;
+    if (trigData) result=pCTPData->EvaluateCTPTriggerClass(name, *trigData);
+    else result=pCTPData->EvaluateCTPTriggerClass(name);
+    pDecision->Result(result);
+    pDecision->TriggerDomain().Clear();
+    if (trigData) pDecision->TriggerDomain().Add(pCTPData->ReadoutList(*trigData));
+    else pDecision->TriggerDomain().Add(pCTPData->ReadoutList());
+
+    pTrigger->Add(fCTPDecisions->At(i), kAliHLTDataTypeTriggerDecision, kAliHLTVoidDataSpec);
+  }
+
+  return 0;
+}
index 95b86463809348f0c799c40c90fa0da32385124b..201e92fe20f403bad806b80c290291c6e063f2ce 100644 (file)
@@ -48,6 +48,9 @@ class TClonesArray;
  * \li -debug <br>
  *      If specified the automatically generated class will contain extra debugging
  *      code and the ACLiC system will have debugging compilation turned on.
+ * \li -cint <br>
+ *      Use CINT to interprete the generated global trigger instead of compiling it.
+ *      This will also be the case if no compiler is available.
  * \li -usecode <i>filename</i> <i>classname</i> <br>
  *      Used to force the component to use an existing class for the global HLT trigger
  *      class implementation, with the name of <i>classname</i> and found in the file
@@ -185,6 +188,16 @@ class AliHLTGlobalTriggerComponent : public AliHLTTrigger
    */
   int BuildSymbolList(const AliHLTTriggerMenu* menu, TClonesArray& list);
 
+  /**
+   * Add trigger decisions according to the active CTP trigger classes
+   * An internal TclonesArray holds the trigger decisions to be added. The trigger
+   * decisions are updated according to the active CTP trigger mask.
+   * \param pTrigger  The instance of the global trigger
+   * \param pCTPData  Instance of the CTP data
+   * \param trigData  Current trigger data, if NULL, the active trigger data from the CTP data is used
+   */
+  int AddCTPDecisions(AliHLTGlobalTrigger* pTrigger, const AliHLTCTPData* pCTPData, const AliHLTComponentTriggerData* trigData);
+
   /**
    * Print some statistics based on the trigger counters
    */
@@ -192,8 +205,11 @@ class AliHLTGlobalTriggerComponent : public AliHLTTrigger
   
   AliHLTGlobalTrigger* fTrigger;  //! Trigger object which implements the global trigger menu.
   bool fDebugMode;  //! Indicates if the generated global trigger class should be in debug mode.
+  bool fRuntimeCompile;  //! Indicates if the generated global trigger class should be compiled
+  bool fSkipCTPCounters; //! Indicates whether to ship CTP info with the trigger decision
   TString fCodeFileName; //! base file name of the generated code for the global trigger
-  
+  TClonesArray* fCTPDecisions; //! AliHLTTriggerDecision objects for the CTP classes
+
   static const char* fgkTriggerMenuCDBPath; //! The path string to read the trigger menu from the CDB.
   
   ClassDef(AliHLTGlobalTriggerComponent, 0) // Global HLT trigger component class which produces the final trigger decision and readout list.