]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/trigger/AliHLTGlobalTriggerComponent.cxx
Update master to aliroot
[u/mrichter/AliRoot.git] / HLT / trigger / AliHLTGlobalTriggerComponent.cxx
index c166dbaf7253f812823a4b46ca8bce75d4ec25a2..da09ba583c2bc643664a8d6cc03f1b3d0acf519d 100644 (file)
@@ -32,7 +32,6 @@
 #include "AliCDBManager.h"
 #include "AliCDBStorage.h"
 #include "AliCDBEntry.h"
-#include "AliRawDataHeader.h"
 #include "TUUID.h"
 #include "TROOT.h"
 #include "TSystem.h"
@@ -453,8 +452,8 @@ Int_t AliHLTGlobalTriggerComponent::DoDeinit()
   if (result != 0) return result;
   
   if (fDeleteCodeFile and !fCodeFileName.IsNull() && gSystem->AccessPathName(fCodeFileName)==0 && !fDebugMode) {
-    fCodeFileName.ReplaceAll(".cxx", "*");
-    TString command="rm "; command+=fCodeFileName;
+    TString command="rm -f ";
+    command+=fCodeFileName + " " + TString(fCodeFileName).ReplaceAll(".cxx", "_cxx.d");
     gSystem->Exec(command);
   }
   fCodeFileName="";
@@ -495,14 +494,18 @@ int AliHLTGlobalTriggerComponent::DoTrigger()
   if (!IsDataEvent(&eventType)) {
     if (fDataEventsOnly)
     {
+      if (eventType == gkAliEventTypeEndOfRun) PrintStatistics(fTrigger, kHLTLogImportant);
       IgnoreEvent();  // dont generate any trigger decision.
       return 0;
     }
   }
   
   fCDH = NULL;  // have to reset this in case ExtractTriggerData fails.
-  ExtractTriggerData(*GetTriggerData(), NULL, NULL, &fCDH, NULL);
-
+  int triggerSuccess=ExtractTriggerData(*GetTriggerData(), NULL, NULL, &fCDH, NULL, true);
+  if(triggerSuccess<0){
+    HLTError("Couldn't extract CDH from trigger data: %s", strerror(-triggerSuccess));
+    return -EPROTO;
+  }
   // Copy the trigger counters in case we need to set them back to their original
   // value because the PushBack method fails with ENOSPC.
   TArrayL64 originalCounters = fTrigger->GetCounters();
@@ -647,23 +650,39 @@ int AliHLTGlobalTriggerComponent::DoTrigger()
   // If we are dealing with a software trigger on the other hand then
   // mask with the participating detector list.
   // In both cases we must make sure that HLT is part of the readout mask.
+  AliHLTReadoutList readoutlist = decision.ReadoutList();
+  AliHLTReadoutList readoutMask;
   if (CTPData() != NULL and CTPData()->Mask() != 0x0)
   {
-    AliHLTReadoutList readoutlist = decision.ReadoutList();
-    AliHLTReadoutList ctpreadout = CTPData()->ReadoutList(*GetTriggerData());
-    ctpreadout.Enable(AliHLTReadoutList::kHLT);
-    readoutlist.AndEq(ctpreadout);
-    decision.ReadoutList(readoutlist); // override the readout list with the masked one.
+    readoutMask = CTPData()->ReadoutList(*GetTriggerData());
+    readoutMask.Enable(AliHLTReadoutList::kHLT);
   }
   else if (softwareTriggerIsValid)
   {
-    assert(fCDH != NULL);
-    AliHLTReadoutList readoutlist = decision.ReadoutList();
-    UInt_t detectors = fCDH->GetSubDetectors();
-    AliHLTReadoutList softwareReadout(Int_t(detectors | AliHLTReadoutList::kHLT));
-    readoutlist.AndEq(softwareReadout);
-    decision.ReadoutList(readoutlist); // override the readout list with the masked one.
+    UInt_t detectors = fCDH.GetSubDetectors();
+    readoutMask = AliHLTReadoutList(Int_t(detectors | AliHLTReadoutList::kHLT));
+  }
+  readoutlist.AndEq(readoutMask);
+  decision.ReadoutList(readoutlist); // override the readout list with the masked one.
+    
+  // Also check whether the final readout list equals a full readout of detectors
+  // irrespective of HLT.
+  // Calculate the difference between the input and output list (xor)
+  // and check if any bits are set (ignoring HLT).
+  AliHLTReadoutList::EDetectorId minDetector = ( readoutlist ^ readoutMask ).GetFirstUsedDetector();
+  // Create the readout list specification word:
+  // Bit 0:    Original Data Present (bit 15 of CDH status & error bit to be set)
+  // Bit 1-31: Reserved for future use
+  AliHLTUInt32_t spec = 0x0;
+  if ( AliHLTReadoutList::kNoDetector == minDetector || AliHLTReadoutList::kHLT == minDetector )  // Any bits set after XOR?
+  {
+    spec |=  (AliHLTUInt32_t) 0x1;
   }
+  else
+  {
+    spec &= ~((AliHLTUInt32_t) 0x1);
+  }
+  SetReadoutListSpecBits(spec);
 
   if (TriggerEvent(&decision, kAliHLTDataTypeGlobalTrigger) == -ENOSPC)
   {
@@ -720,8 +739,8 @@ int AliHLTGlobalTriggerComponent::Reconfigure(const char* cdbEntry, const char*
     UnloadTriggerClass(codeFileName);
     if (not codeFileName.IsNull() and gSystem->AccessPathName(codeFileName)==0 and not fDebugMode)
     {
-      codeFileName.ReplaceAll(".cxx", "*");
-      TString command="rm "; command+=codeFileName;
+      TString command="rm -f ";
+      command+=codeFileName + " " + TString(codeFileName).ReplaceAll(".cxx", "_cxx.d");
       gSystem->Exec(command);
     }
     return -EIO;
@@ -745,8 +764,8 @@ int AliHLTGlobalTriggerComponent::Reconfigure(const char* cdbEntry, const char*
   UnloadTriggerClass(fCodeFileName);
   if (fDeleteCodeFile and not fCodeFileName.IsNull() and gSystem->AccessPathName(fCodeFileName)==0 and not fDebugMode)
   {
-    fCodeFileName.ReplaceAll(".cxx", "*");
-    TString command="rm "; command+=fCodeFileName;
+    TString command="rm -f ";
+    command+=fCodeFileName + " " + TString(fCodeFileName).ReplaceAll(".cxx", "_cxx.d");
     gSystem->Exec(command);
   }
   fCodeFileName = codeFileName;
@@ -761,26 +780,7 @@ int AliHLTGlobalTriggerComponent::LoadTriggerMenu(const char* cdbPath, const Ali
   // Loads the trigger menu object from the CDB path.
   
   HLTDebug("Trying to load trigger menu from '%s'.", cdbPath);
-  if (AliCDBManager::Instance() == NULL)
-  {
-    HLTError("CDB manager object not found.");
-    return -EIO;
-  }
-  AliCDBStorage* store = AliCDBManager::Instance()->GetDefaultStorage();
-  if (store == NULL)
-  {
-    HLTError("Could not get the the default storage for the CDB.");
-    return -EIO;
-  }
-  Int_t version = store->GetLatestVersion(cdbPath, GetRunNo());
-  Int_t subVersion = store->GetLatestSubVersion(cdbPath, GetRunNo(), version);
-  AliCDBEntry* entry = AliCDBManager::Instance()->Get(cdbPath, GetRunNo(), version, subVersion);
-  if (entry == NULL)
-  {
-    HLTError("Could not get the CDB entry for \"%s\".", cdbPath);
-    return -EIO;
-  }
-  TObject* obj = entry->GetObject();
+  TObject* obj = LoadAndExtractOCDBObject(cdbPath);
   if (obj == NULL)
   {
     HLTError("Configuration object for \"%s\" is missing.", cdbPath);
@@ -1460,7 +1460,12 @@ int AliHLTGlobalTriggerComponent::LoadTriggerClass(
   HLTDebug("Loading HLT trigger class from file '%s'.", filename);
   
   TString compiler = gSystem->GetBuildCompilerVersion();
-  if (fRuntimeCompile && (compiler.Contains("gcc") or compiler.Contains("icc")))
+  if (fRuntimeCompile 
+      && (compiler.Contains("gcc") 
+         || compiler.Contains("icc") 
+         || compiler.Contains("clang")
+         || compiler.Contains("c++")
+         ))
   {
     TString includePath;
 #if defined(PKGINCLUDEDIR)
@@ -1530,7 +1535,7 @@ int AliHLTGlobalTriggerComponent::UnloadTriggerClass(const char* filename)
   HLTDebug("Unloading HLT trigger class in file '%s'.", filename);
   
   TString compiler = gSystem->GetBuildCompilerVersion();
-  if (fRuntimeCompile && (compiler.Contains("gcc") or compiler.Contains("icc")))
+  if (fRuntimeCompile)
   {
     // Generate the library name.
     TString libname = filename;
@@ -1860,8 +1865,7 @@ bool AliHLTGlobalTriggerComponent::FillSoftwareTrigger()
 {
   // Fills the fSoftwareTrigger structure.
   
-  if (fCDH == NULL) return false;
-  UChar_t l1msg = fCDH->GetL1TriggerMessage();
+  UChar_t l1msg = fCDH.GetL1TriggerMessage();
   if ((l1msg & 0x1) == 0x0) return false;  // skip physics events.
   // From here on everything must be a software trigger.
   if (((l1msg >> 2) & 0xF) == 0xE)
@@ -1884,7 +1888,7 @@ bool AliHLTGlobalTriggerComponent::FillSoftwareTrigger()
     fSoftwareTrigger.Name("SOFTWARE");
     fSoftwareTrigger.Description("Generated internal software trigger.");
   }
-  UInt_t detectors = fCDH->GetSubDetectors();
+  UInt_t detectors = fCDH.GetSubDetectors();
   fSoftwareTrigger.ReadoutList( AliHLTReadoutList(Int_t(detectors)) );
   return true;
 }
@@ -1910,8 +1914,8 @@ int AliHLTGlobalTriggerComponent::AddCTPDecisions(AliHLTGlobalTrigger* pTrigger,
   // add trigger decisions for the valid CTP classes
   if (!pCTPData || !pTrigger) return 0;
 
-  AliHLTUInt64_t triggerMask=pCTPData->Mask();
-  AliHLTUInt64_t bit0=0x1;
+  AliHLTTriggerMask_t triggerMask=pCTPData->Mask();
+  AliHLTTriggerMask_t bit0(0x1);
   if (!fCTPDecisions) {
     try
     {
@@ -1935,7 +1939,7 @@ int AliHLTGlobalTriggerComponent::AddCTPDecisions(AliHLTGlobalTrigger* pTrigger,
     }
     for (int i=0; i<gkNCTPTriggerClasses; i++) {
       const char* name=pCTPData->Name(i);
-      if (triggerMask&(bit0<<i) && name) {
+      if ( (triggerMask&(bit0<<i)).any() && name) {
        AliHLTTriggerDecision* pDecision=dynamic_cast<AliHLTTriggerDecision*>(fCTPDecisions->At(i));
        assert(pDecision);
        if (!pDecision) {
@@ -1950,7 +1954,7 @@ int AliHLTGlobalTriggerComponent::AddCTPDecisions(AliHLTGlobalTrigger* pTrigger,
 
   for (int i=0; i<gkNCTPTriggerClasses; i++) {
     const char* name=pCTPData->Name(i);
-    if ((triggerMask&(bit0<<i))==0 || name==NULL) continue;
+    if ((triggerMask&(bit0<<i)).none() || 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;
@@ -1958,10 +1962,10 @@ int AliHLTGlobalTriggerComponent::AddCTPDecisions(AliHLTGlobalTrigger* pTrigger,
     bool result=false;
     // 13 March 2010 - Optimisation:
     // Dont use the EvaluateCTPTriggerClass method, which uses slow TFormula objects.
-    AliHLTUInt64_t triggers = 0;
+    AliHLTTriggerMask_t triggers = 0;
     if (trigData) triggers = pCTPData->ActiveTriggers(*trigData);
     else triggers = pCTPData->Triggers();
-    result = (triggers&((AliHLTUInt64_t)0x1<<i)) ? true : false;
+    result = (triggers&(bit0<<i)).any() ? true : false;
     //if (trigData) result=pCTPData->EvaluateCTPTriggerClass(name, *trigData);
     //else result=pCTPData->EvaluateCTPTriggerClass(name);
     pDecision->Result(result);