]> 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 0e8cad99c4ff3f56525829d6006b9cd649c34ebe..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="";
@@ -502,8 +501,11 @@ int AliHLTGlobalTriggerComponent::DoTrigger()
   }
   
   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();
@@ -648,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)
   {
@@ -721,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;
@@ -746,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;
@@ -1442,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)
@@ -1512,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;
@@ -1842,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)
@@ -1866,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;
 }
@@ -1878,19 +1900,12 @@ int AliHLTGlobalTriggerComponent::PrintStatistics(const AliHLTGlobalTrigger* pTr
   int totalEvents=fTotalEventCounter+offset;
   const TArrayL64& counters = pTrigger->GetCounters();
   if (pTrigger->CallFailed()) return -EPROTO;
-  TString msg;
   for (int i = 0; i < counters.GetSize(); i++) {
     ULong64_t count = counters[i];
     float ratio=0;
     if (totalEvents>0) ratio=100*(float)count/totalEvents;
-    if (i != 0) msg += "\n";
-    //NOTE: the %%%% printed for the percent is necessary since HLTLog will interpret the string
-    // as a printf format like string. So after Form() this becomes %% which just prints the
-    // percentage sign. If just single %% is used then we get stack corruption and a crash because
-    // the string is interpreted a formating token.
-    msg += Form("Item %d: total events: %d - counted events: %llu (%.1f%%%%)", i, totalEvents, count, ratio);
-  }
-  HLTLog(level, msg.Data());
+    HLTLog(level, "Item %d: total events: %d - counted events: %llu (%.1f%%)", i, totalEvents, count, ratio);
+  }
   return 0;
 }
 
@@ -1899,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
     {
@@ -1924,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) {
@@ -1939,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;
@@ -1947,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);