]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/trigger/AliHLTGlobalTriggerComponent.cxx
Updated macros for PHOS alignment calculation
[u/mrichter/AliRoot.git] / HLT / trigger / AliHLTGlobalTriggerComponent.cxx
index 2b212eb059b9abb7ebfda11623da790be23eba29..83f8e2503b5c5c7cbf380147240ea52ced5bc5bd 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="";
@@ -493,17 +492,20 @@ int AliHLTGlobalTriggerComponent::DoTrigger()
 
   AliHLTUInt32_t eventType=0;
   if (!IsDataEvent(&eventType)) {
-    if (eventType==gkAliEventTypeEndOfRun) PrintStatistics(fTrigger, kHLTLogImportant, 0);
     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();
@@ -609,11 +611,16 @@ int AliHLTGlobalTriggerComponent::DoTrigger()
   
   static UInt_t lastTime=0;
   TDatime time;
-  if (time.Get()-lastTime>60) {
+  if (time.Get()-lastTime>60)
+  {
     lastTime=time.Get();
     PrintStatistics(fTrigger, kHLTLogImportant);
   }
-
+  else if (eventType==gkAliEventTypeEndOfRun)
+  {
+    PrintStatistics(fTrigger, kHLTLogImportant);
+  }
+  
   // add readout filter to event done data
   CreateEventDoneReadoutFilter(decision.TriggerDomain(), 3);
 
@@ -643,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)
   {
@@ -716,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;
@@ -741,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;
@@ -757,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);
@@ -1456,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)
@@ -1856,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)
@@ -1880,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;
 }
@@ -1889,7 +1897,7 @@ bool AliHLTGlobalTriggerComponent::FillSoftwareTrigger()
 int AliHLTGlobalTriggerComponent::PrintStatistics(const AliHLTGlobalTrigger* pTrigger, AliHLTComponentLogSeverity level, int offset) const
 {
   // print some statistics
-  int totalEvents=GetEventCount()+offset;
+  int totalEvents=fTotalEventCounter+offset;
   const TArrayL64& counters = pTrigger->GetCounters();
   if (pTrigger->CallFailed()) return -EPROTO;
   for (int i = 0; i < counters.GetSize(); i++) {
@@ -1906,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
     {
@@ -1931,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) {
@@ -1946,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;
@@ -1954,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);