+// $Id$
/**************************************************************************
* This file is property of and copyright by the ALICE HLT Project *
* ALICE Experiment at CERN, All rights reserved. *
#include "AliHLTGlobalTrigger.h"
#include "AliHLTGlobalTriggerConfig.h"
#include "AliHLTTriggerMenu.h"
+#include "AliHLTCTPData.h"
+#include "AliCDBManager.h"
+#include "AliCDBStorage.h"
+#include "AliCDBEntry.h"
#include "TUUID.h"
#include "TROOT.h"
+#include "TSystem.h"
#include "TRegexp.h"
#include "TClonesArray.h"
#include "TObjString.h"
#include "TSystem.h"
#include "TInterpreter.h"
+#include "TDatime.h"
#include <fstream>
#include <cerrno>
ClassImp(AliHLTGlobalTriggerComponent)
+const char* AliHLTGlobalTriggerComponent::fgkTriggerMenuCDBPath = "HLT/ConfigHLT/HLTGlobalTrigger";
+
AliHLTGlobalTriggerComponent::AliHLTGlobalTriggerComponent() :
AliHLTTrigger(),
fTrigger(NULL),
- fDebugMode(false)
+ fDebugMode(false),
+ fCodeFileName()
{
// Default constructor.
+
+ ClearInfoForNewEvent(false);
}
// Initialises the global trigger component.
fDebugMode = false;
+ bool bSkipCTPCounters=false;
const char* configFileName = NULL;
const char* codeFileName = NULL;
TString classname;
i += 2;
continue;
}
-
+
+ if (strcmp(argv[i], "-skipctp") == 0)
+ {
+ HLTInfo("Skipping CTP counters in trigger decision");
+ bSkipCTPCounters=true;
+ continue;
+ }
+
HLTError("Unknown option '%s'.", argv[i]);
return -EINVAL;
} // for loop
menu = AliHLTGlobalTriggerConfig::Menu();
}
+ // Try load the trigger menu from the CDB if it is not loaded yet with the
+ // -config option
+ if (menu == NULL and AliCDBManager::Instance() != NULL)
+ {
+ 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(fgkTriggerMenuCDBPath, GetRunNo());
+ Int_t subVersion = store->GetLatestSubVersion(fgkTriggerMenuCDBPath, GetRunNo(), version);
+ AliCDBEntry* entry = AliCDBManager::Instance()->Get(fgkTriggerMenuCDBPath, GetRunNo(), version, subVersion);
+ if (entry == NULL)
+ {
+ HLTError("Could not get the CDB entry for \"%s\".", fgkTriggerMenuCDBPath);
+ return -EIO;
+ }
+ TObject* obj = entry->GetObject();
+ if (obj == NULL)
+ {
+ HLTError("Configuration object for \"%s\" is missing.", fgkTriggerMenuCDBPath);
+ return -ENOENT;
+ }
+ if (obj->IsA() != AliHLTTriggerMenu::Class())
+ {
+ HLTError("Wrong type for configuration object in \"%s\". Found a %s but we expect a AliHLTTriggerMenu.",
+ fgkTriggerMenuCDBPath, obj->ClassName()
+ );
+ return -EPROTO;
+ }
+ menu = dynamic_cast<AliHLTTriggerMenu*>(obj);
+ }
+
if (menu == NULL)
{
HLTError("No trigger menu configuration found or specified.");
fTrigger->FillFromMenu(*menu);
fTrigger->ResetCounters(menu->NumberOfItems());
+
+ // setup the CTP accounting in AliHLTComponent
+ if (!bSkipCTPCounters) SetupCTPData();
+
+ // Set the default values from the trigger menu.
+ SetDescription(menu->DefaultDescription());
+ SetTriggerDomain(menu->DefaultTriggerDomain());
return 0;
}
delete fTrigger;
fTrigger = NULL;
}
+
+ if (!fCodeFileName.IsNull() && gSystem->AccessPathName(fCodeFileName)==0 && !fDebugMode) {
+ fCodeFileName.ReplaceAll(".cxx", "*");
+ TString command="rm "; command+=fCodeFileName;
+ gSystem->Exec(command);
+ }
+ fCodeFileName="";
return 0;
}
HLTFatal("Global trigger implementation object is NULL!");
return -EIO;
}
-
+
+ AliHLTUInt32_t eventType=0;
+ if (!IsDataEvent(&eventType)) {
+ if (eventType==gkAliEventTypeEndOfRun) PrintStatistics(fTrigger, kHLTLogImportant, 0);
+ return 0;
+ }
+
fTrigger->NewEvent();
// Fill in the input data.
// Calculate the global trigger result and trigger domain, then create and push
// back the new global trigger decision object.
TString description;
- GetTriggerDomain().Clear();
- bool triggerResult = fTrigger->CalculateTriggerDecision(GetTriggerDomain(), description);
- SetDescription(description.Data());
-
- AliHLTGlobalTriggerDecision decision(triggerResult, GetTriggerDomain(), GetDescription());
- decision.SetCounters(fTrigger->Counters());
+ AliHLTTriggerDomain triggerDomain;
+ bool triggerResult = fTrigger->CalculateTriggerDecision(triggerDomain, description);
+
+ AliHLTGlobalTriggerDecision decision(
+ triggerResult,
+ // The following will cause the decision to be generated with default values
+ // (set in fTriggerDomain and fDescription) if the trigger result is false.
+ (triggerResult == true) ? triggerDomain : GetTriggerDomain(),
+ (triggerResult == true) ? description.Data() : GetDescription()
+ );
+ decision.SetCounters(fTrigger->Counters(), GetEventCount()+1);
+ static UInt_t lastTime=0;
+ TDatime time;
+ if (time.Get()-lastTime>5) {
+ lastTime=time.Get();
+ PrintStatistics(fTrigger);
+ }
// Add the input objects used to the global decision.
obj = GetFirstInputObject();
}
obj = GetNextInputObject();
}
-
+
+ if (CTPData()) decision.AddInputObject(CTPData());
+
+ CreateEventDoneReadoutFilter(decision.TriggerDomain(), 3);
+ CreateEventDoneReadoutFilter(decision.TriggerDomain(), 4);
TriggerEvent(&decision);
return 0;
}
// Create the name of the new class.
name = "AliHLTGlobalTriggerImpl_";
name += uuidstr;
- TString filename = name + ".cxx";
+ fCodeFileName = name + ".cxx";
// Open a text file to write the code and generate the new class.
- fstream code(filename.Data(), ios_base::out | ios_base::trunc);
+ fstream code(fCodeFileName.Data(), ios_base::out | ios_base::trunc);
if (not code.good())
{
- HLTError("Could not open file '%s' for writing.", filename.Data());
+ HLTError("Could not open file '%s' for writing.", fCodeFileName.Data());
return -EIO;
}
// Add any include files that were specified on the command line.
for (Int_t i = 0; i < includeFiles.GetEntriesFast(); i++)
{
- TString file = static_cast<const TObjString*>(includeFiles.UncheckedAt(i))->String();
+ TString file = static_cast<TObjString*>(includeFiles.UncheckedAt(i))->String();
code << "#include \"" << file.Data() << "\"" << endl;
}
code.close();
// Now we need to compile and load the new class.
- result = LoadTriggerClass(filename, includePaths);
+ result = LoadTriggerClass(fCodeFileName, includePaths);
return result;
}
// Add any include paths that were specified on the command line.
for (Int_t i = 0; i < includePaths.GetEntriesFast(); i++)
{
- TString path = static_cast<const TObjString*>(includePaths.UncheckedAt(i))->String();
+ TString path = static_cast<TObjString*>(includePaths.UncheckedAt(i))->String();
includePath += " ";
includePath += path;
}
}
TRegexp exp("[_a-zA-Z][_a-zA-Z0-9]*");
+ TRegexp hexexp("x[a-fA-F0-9]+");
for (UInt_t i = 0; i < menu->NumberOfItems(); i++)
{
const AliHLTTriggerMenuItem* item = menu->Item(i);
Ssiz_t length = 0;
Ssiz_t pos = exp.Index(str, &length, start);
if (pos == kNPOS) break;
- TString s = str(pos, length);
start = pos+length;
+ // Check if there is a numerical character before the found
+ // regular expression. If so, then the symbol is not a valid one
+ // and should be skipped.
+ if (pos > 0)
+ {
+ bool notValid = false;
+ switch (str[pos-1])
+ {
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ notValid = true;
+ break;
+ default:
+ notValid = false;
+ break;
+ }
+ if (notValid) continue;
+ }
+ TString s = str(pos, length);
+
if (s == "and" or s == "and_eq" or s == "bitand" or s == "bitor" or
s == "compl" or s == "not" or s == "not_eq" or s == "or" or
s == "or_eq" or s == "xor" or s == "xor_eq" or s == "true" or
// Ignore iso646.h and other keywords.
continue;
}
-
+
if (FindSymbol(s.Data(), list) == -1)
{
AliHLTTriggerMenuSymbol newSymbol;
return 0;
}
+int AliHLTGlobalTriggerComponent::PrintStatistics(const AliHLTGlobalTrigger* pTrigger, AliHLTComponentLogSeverity level, int offset) const
+{
+ // print some statistics
+ ULong64_t count=0;
+ for (int i=0; i<pTrigger->Counters().GetSize(); i++) {
+ count+=pTrigger->Counters()[i];
+ }
+ int totalEvents=GetEventCount()+offset;
+ float ratio=0;
+ if (totalEvents>0) ratio=100*(float)count/totalEvents;
+ HLTLog(level, "total events: %d - triggered events: %llu (%.1f%%)", totalEvents, count, ratio);
+ return 0;
+}