From 52f67e50974f7976321a5eee3aaeb63e92df120e Mon Sep 17 00:00:00 2001 From: aszostak Date: Mon, 5 Jan 2009 15:44:57 +0000 Subject: [PATCH] Finished code for global HLT trigger and the trigger menu implementation. The HLT global trigger component now auto generates a AliHLTGlobalTrigger implementation on the fly from the trigger menu. This auto generated class performs the actual trigger logic required. Removed the readout list (which is a subset of a trigger domain) from the AliHLTTriggerDomain. An AliHLTReadoutList class can now be auto generated from the trigger domain through the typecast operator. Adding a simple TriggerConfig.C macro which is used to test the global trigger component via testGlobalTriggerComponent.C. The AliHLTGlobalTriggerConfig class is added for use in trigger configuration macros such as TriggerConfig.C. This class makes it more user friendly to define a global HLT trigger configuration and pass it to AliHLTGlobalTriggerComponent. Also added AliHLTTriggerMenuSymbol and a list of symbols to AliHLTTriggerMenu so that variables can be defined, filled from input TObjects and used in global HLT trigger expressions easily. --- HLT/libAliHLTTrigger.pkg | 2 + HLT/trigger/AliHLTDomainEntry.cxx | 45 +- HLT/trigger/AliHLTDomainEntry.h | 9 + HLT/trigger/AliHLTEventSummary.h | 9 +- HLT/trigger/AliHLTGlobalTrigger.cxx | 15 +- HLT/trigger/AliHLTGlobalTrigger.h | 46 +- HLT/trigger/AliHLTGlobalTriggerComponent.cxx | 568 +++++++++++++++++- HLT/trigger/AliHLTGlobalTriggerComponent.h | 97 ++- HLT/trigger/AliHLTGlobalTriggerConfig.cxx | 208 +++++++ HLT/trigger/AliHLTGlobalTriggerConfig.h | 204 +++++++ HLT/trigger/AliHLTGlobalTriggerDecision.cxx | 57 +- HLT/trigger/AliHLTGlobalTriggerDecision.h | 42 +- HLT/trigger/AliHLTReadoutList.cxx | 46 ++ HLT/trigger/AliHLTReadoutList.h | 8 + HLT/trigger/AliHLTRunSummary.h | 11 +- HLT/trigger/AliHLTTrigger.cxx | 3 +- HLT/trigger/AliHLTTriggerDecision.cxx | 9 +- HLT/trigger/AliHLTTriggerDecision.h | 24 +- HLT/trigger/AliHLTTriggerDomain.cxx | 184 ++++++ HLT/trigger/AliHLTTriggerDomain.h | 45 ++ HLT/trigger/AliHLTTriggerLinkDef.h | 2 + HLT/trigger/AliHLTTriggerMenu.cxx | 39 +- HLT/trigger/AliHLTTriggerMenu.h | 45 +- HLT/trigger/AliHLTTriggerMenuItem.cxx | 14 +- HLT/trigger/AliHLTTriggerMenuItem.h | 13 +- HLT/trigger/AliHLTTriggerMenuSymbol.cxx | 75 +++ HLT/trigger/AliHLTTriggerMenuSymbol.h | 157 +++++ HLT/trigger/test/TriggerConfig.C | 11 + HLT/trigger/test/testGlobalTriggerComponent.C | 26 +- 29 files changed, 1886 insertions(+), 128 deletions(-) create mode 100644 HLT/trigger/AliHLTGlobalTriggerConfig.cxx create mode 100644 HLT/trigger/AliHLTGlobalTriggerConfig.h create mode 100644 HLT/trigger/AliHLTTriggerMenuSymbol.cxx create mode 100644 HLT/trigger/AliHLTTriggerMenuSymbol.h create mode 100644 HLT/trigger/test/TriggerConfig.C diff --git a/HLT/libAliHLTTrigger.pkg b/HLT/libAliHLTTrigger.pkg index 7af06364451..aa9dd4f5d24 100644 --- a/HLT/libAliHLTTrigger.pkg +++ b/HLT/libAliHLTTrigger.pkg @@ -16,8 +16,10 @@ CLASS_HDRS:= \ AliHLTReadoutList.h \ AliHLTTriggerMenu.h \ AliHLTTriggerMenuItem.h \ + AliHLTTriggerMenuSymbol.h \ AliHLTGlobalTriggerDecision.h \ AliHLTGlobalTrigger.h \ + AliHLTGlobalTriggerConfig.h \ AliHLTGlobalTriggerComponent.h \ AliHLTTriggerAgent.h \ AliHLTEventSummary.h \ diff --git a/HLT/trigger/AliHLTDomainEntry.cxx b/HLT/trigger/AliHLTDomainEntry.cxx index d4ec3adca09..07ca2874b3a 100644 --- a/HLT/trigger/AliHLTDomainEntry.cxx +++ b/HLT/trigger/AliHLTDomainEntry.cxx @@ -291,52 +291,59 @@ void AliHLTDomainEntry::Print(Option_t* option) const // Inherited from TObject. Prints the domain entry contents. // See header file for more information. + cout << AsString().Data(); + TString opt(option); + if (opt.Contains("noendl")) return; + cout << endl; +} + + +TString AliHLTDomainEntry::AsString() const +{ + // Returns a string representation of the domain entry. + // See header file for more information. + + TString str; if (strncmp(&fType.fID[0], kAliHLTAnyDataTypeID, kAliHLTComponentDataTypefIDsize) == 0) { - for (int i = 0; i < kAliHLTComponentDataTypefIDsize; i++) cout << "*"; + for (int i = 0; i < kAliHLTComponentDataTypefIDsize; i++) str += "*"; } else { for (int i = 0; i < kAliHLTComponentDataTypefIDsize; i++) { if (fType.fID[i] != '\0') - cout << fType.fID[i]; + str += fType.fID[i]; else - cout << "\\0"; + str += "\\0"; } } - cout << ":"; + str += ":"; if (strncmp(&fType.fOrigin[0], kAliHLTDataOriginAny, kAliHLTComponentDataTypefOriginSize) == 0) { - for (int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++) cout << "*"; + for (int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++) str += "*"; } else { for (int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++) { if (fType.fOrigin[i] != '\0') - cout << fType.fOrigin[i]; + str += fType.fOrigin[i]; else - cout << "\\0"; + str += "\\0"; } } - cout << ":"; + str += ":"; if (fUseSpec) { - ios_base::fmtflags oldflags = cout.flags(); - char oldfill = cout.fill(); - streamsize oldwidth = cout.width(); - cout << "0x" << hex << setw(8) << setfill('0') << fSpecification; - cout.flags(oldflags); - cout.fill(oldfill); - cout.width(oldwidth); + char num[16]; + sprintf(num, "0x%8.8X", fSpecification); + str += num; } else { - cout << "**********"; + str += "**********"; } - TString opt(option); - if (opt.Contains("noendl")) return; - cout << endl; + return str; } diff --git a/HLT/trigger/AliHLTDomainEntry.h b/HLT/trigger/AliHLTDomainEntry.h index 56da6b8978b..d559b8e2a5c 100644 --- a/HLT/trigger/AliHLTDomainEntry.h +++ b/HLT/trigger/AliHLTDomainEntry.h @@ -12,6 +12,8 @@ #include "TObject.h" #include "AliHLTDataTypes.h" +class TString; + /** * \class AliHLTDomainEntry * The AliHLTDomainEntry class is used to store information identifying a particular @@ -314,6 +316,13 @@ class AliHLTDomainEntry : public TObject */ virtual void Print(Option_t* option = "") const; + /** + * Converts the domain entry type, origin and specification into a string + * representation. + * \returns A string in the format \:\:\ + */ + TString AsString() const; + private: Bool_t fExclude; /// Indicates if the domain entry is exclusive, indicating data blocks that should not be readout. diff --git a/HLT/trigger/AliHLTEventSummary.h b/HLT/trigger/AliHLTEventSummary.h index da8a9d6d384..aee8868b076 100644 --- a/HLT/trigger/AliHLTEventSummary.h +++ b/HLT/trigger/AliHLTEventSummary.h @@ -58,7 +58,7 @@ public: /** Check event is accepted * @return kTRUE if accepted, kFALSE if rejected */ - Bool_t IsAccepted() { return fRejected;} + Bool_t IsAccepted() const { return fRejected;} // -- run parameters ------------------------ @@ -70,7 +70,7 @@ public: /** Get Run Number * @return run number */ - AliHLTUInt32_t GetRunNumber() { return fRunNumber;} + AliHLTUInt32_t GetRunNumber() const { return fRunNumber;} /** Set Run Type * @param i run type @@ -80,7 +80,7 @@ public: /** Get Run Type s * @return run type */ - AliHLTUInt32_t GetRunType() { return fRunType; } + AliHLTUInt32_t GetRunType() const { return fRunType; } // -- trigger parameters ------------------------ @@ -93,13 +93,14 @@ public: /** Get ocurrance of trigger classes * @return ptr to array of trigger classes */ - AliHLTUInt64_t GetTriggerClasses() { return fTriggerClass; } + AliHLTUInt64_t GetTriggerClasses() const { return fTriggerClass; } // -- detector parameters ------------------------ /** Detector run statistics classes * @return ptr to Detector arry */ + const TObjArray* GetDetectorArray () const { return fDetectorArray; } TObjArray* GetDetectorArray () { return fDetectorArray; } /** Rest the Detector array, all elements are removed */ diff --git a/HLT/trigger/AliHLTGlobalTrigger.cxx b/HLT/trigger/AliHLTGlobalTrigger.cxx index 21feb02b00c..6d3b345b94e 100644 --- a/HLT/trigger/AliHLTGlobalTrigger.cxx +++ b/HLT/trigger/AliHLTGlobalTrigger.cxx @@ -36,6 +36,7 @@ AliHLTGlobalTrigger::Factory::fFactory[AliHLTGlobalTrigger::Factory::kMaxFactori AliHLTGlobalTrigger::AliHLTGlobalTrigger() : + AliHLTLogging(), fCounters() { // Default constructor. @@ -66,7 +67,7 @@ AliHLTGlobalTrigger* AliHLTGlobalTrigger::Factory::CreateNew(const char* name) } -AliHLTGlobalTrigger::Factory::Factory() +AliHLTGlobalTrigger::Factory::Factory() : AliHLTLogging() { // Default constructor resisters the class factory. @@ -99,3 +100,15 @@ AliHLTGlobalTrigger::Factory::~Factory() HLTFatal("Could not find factory to deregister."); } + +void AliHLTGlobalTrigger::ResetCounters(UInt_t number) +{ + // Resets the trigger counters. + + fCounters.Set(number); + for (UInt_t i = 0; i < number; i++) + { + fCounters[i] = 0; + } +} + diff --git a/HLT/trigger/AliHLTGlobalTrigger.h b/HLT/trigger/AliHLTGlobalTrigger.h index 5e9ba808293..232b6470579 100644 --- a/HLT/trigger/AliHLTGlobalTrigger.h +++ b/HLT/trigger/AliHLTGlobalTrigger.h @@ -14,8 +14,11 @@ #include "AliHLTDataTypes.h" #include "AliHLTLogging.h" +class AliHLTTriggerDomain; class AliHLTTriggerDecision; class AliHLTGlobalTriggerDecision; +class AliHLTTriggerMenu; +class TClonesArray; /** * \class AliHLTGlobalTrigger @@ -24,7 +27,7 @@ class AliHLTGlobalTriggerDecision; * creates a class deriving from AliHLTGlobalTrigger on the fly to implement the * trigger logic for that particular trigger menu. */ -class AliHLTGlobalTrigger +class AliHLTGlobalTrigger : public AliHLTLogging { public: @@ -39,17 +42,17 @@ class AliHLTGlobalTrigger virtual ~AliHLTGlobalTrigger(); /** - * Abstract method to indicate that a new event is being processed and the - * internal buffers should be cleared or reset. + * Abstract method to fill values from a trigger menu. Specifically, the description + * strings and domain entry values will be copied over. + * \param menu The trigger menu to fill from. */ - virtual void NewEvent() = 0; + virtual void FillFromMenu(const AliHLTTriggerMenu& menu) = 0; /** - * Abstract method which should fill in the internal attributes from the given - * trigger decision. - * \param decision The trigger decision to fill from. + * Abstract method to indicate that a new event is being processed and the + * internal buffers should be cleared or reset. */ - virtual void Add(const AliHLTTriggerDecision* decision) = 0; + virtual void NewEvent() = 0; /** * Abstract method which should fill in the internal attributes from the given @@ -66,9 +69,11 @@ class AliHLTGlobalTrigger /** * Abstract method that calculates the trigger decision + * \param domain The resultant trigger domain for the global HLT result. + * \param description The resultant description for the global HLT result. * \returns The global HLT trigger decision result. */ - virtual AliHLTGlobalTriggerDecision* CalculateTriggerDecision() = 0; + virtual bool CalculateTriggerDecision(AliHLTTriggerDomain& domain, TString& description) = 0; /** * Creates a new instance of a particular trigger class. @@ -78,6 +83,17 @@ class AliHLTGlobalTrigger */ static AliHLTGlobalTrigger* CreateNew(const char* name) { return Factory::CreateNew(name); } + /** + * Sets the number of trigger counters and resets them all to zero. + * \param number The number of counters to use. + */ + void ResetCounters(UInt_t number = 0); + + /** + * Returns the array of trigger counters. + */ + const TArrayL64& Counters() const { return fCounters; } + protected: /** @@ -133,6 +149,18 @@ class AliHLTGlobalTrigger /// 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) { ++fCounters[i]; }; + + /** + * Returns a trigger counter's value. + * \param i The counter number to return. + */ + Long64_t GetCounter(UInt_t i) const { return fCounters[i]; }; + private: TArrayL64 fCounters; //! Event trigger counters. One counter for each trigger class. diff --git a/HLT/trigger/AliHLTGlobalTriggerComponent.cxx b/HLT/trigger/AliHLTGlobalTriggerComponent.cxx index 39a88999b30..cbf13310897 100644 --- a/HLT/trigger/AliHLTGlobalTriggerComponent.cxx +++ b/HLT/trigger/AliHLTGlobalTriggerComponent.cxx @@ -25,9 +25,15 @@ #include "AliHLTGlobalTriggerComponent.h" #include "AliHLTGlobalTriggerDecision.h" #include "AliHLTGlobalTrigger.h" +#include "AliHLTGlobalTriggerConfig.h" +#include "AliHLTTriggerMenu.h" #include "TUUID.h" #include "TROOT.h" +#include "TRegexp.h" +#include "TClonesArray.h" +#include "TObjString.h" #include "TSystem.h" +#include "TInterpreter.h" #include #include @@ -36,7 +42,8 @@ ClassImp(AliHLTGlobalTriggerComponent) AliHLTGlobalTriggerComponent::AliHLTGlobalTriggerComponent() : AliHLTTrigger(), - fTrigger(NULL) + fTrigger(NULL), + fDebugMode(false) { // Default constructor. } @@ -59,13 +66,126 @@ void AliHLTGlobalTriggerComponent::GetOutputDataSize(unsigned long& constBase, d } -Int_t AliHLTGlobalTriggerComponent::DoInit(int /*argc*/, const char** /*argv*/) +Int_t AliHLTGlobalTriggerComponent::DoInit(int argc, const char** argv) { // Initialises the global trigger component. - AliHLTTriggerMenu* menu = NULL; + fDebugMode = false; + const char* configFileName = NULL; + const char* codeFileName = NULL; TString classname; - int result = GenerateTrigger(menu, classname); + TClonesArray includePaths(TObjString::Class()); + TClonesArray includeFiles(TObjString::Class()); + + for (int i = 0; i < argc; i++) + { + if (strcmp(argv[i], "-config") == 0) + { + if (configFileName != NULL) + { + HLTWarning("Trigger configuration macro was already specified." + " Will replace previous value given by -config." + ); + } + if (argc <= i+1) + { + HLTError("The trigger configuration macro filename was not specified." ); + return -EINVAL; + } + configFileName = argv[i+1]; + i++; + continue; + } + + if (strcmp(argv[i], "-includepath") == 0) + { + if (argc <= i+1) + { + HLTError("The include path was not specified." ); + return -EINVAL; + } + new (includePaths[includePaths.GetEntriesFast()]) TObjString(argv[i+1]); + i++; + continue; + } + + if (strcmp(argv[i], "-include") == 0) + { + if (argc <= i+1) + { + HLTError("The include file name was not specified." ); + return -EINVAL; + } + new (includeFiles[includeFiles.GetEntriesFast()]) TObjString(argv[i+1]); + i++; + continue; + } + + if (strcmp(argv[i], "-debug") == 0) + { + if (fDebugMode == true) + { + HLTWarning("The debug flag was already specified. Ignoring this instance."); + } + fDebugMode = true; + i++; + continue; + } + + if (strcmp(argv[i], "-usecode") == 0) + { + if (codeFileName != NULL) + { + HLTWarning("Custom trigger code file was already specified." + " Will replace previous value given by -usecode." + ); + } + if (argc <= i+1) + { + HLTError("The custom trigger code filename was not specified." ); + return -EINVAL; + } + codeFileName = argv[i+1]; + if (argc <= i+2) + { + HLTError("The custom trigger class name was not specified." ); + return -EINVAL; + } + classname = argv[i+2]; + i += 2; + continue; + } + + HLTError("Unknown option '%s'.", argv[i]); + return -EINVAL; + } // for loop + + const AliHLTTriggerMenu* menu = NULL; + if (configFileName != NULL) + { + TString cmd = ".x "; + cmd += configFileName; + gROOT->ProcessLine(cmd); + menu = AliHLTGlobalTriggerConfig::Menu(); + } + + if (menu == NULL) + { + HLTError("No trigger menu configuration found or specified."); + return -ENOENT; + } + + int result = 0; + if (codeFileName == NULL) + { + HLTDebug("Generating custom HLT trigger class."); + result = GenerateTrigger(menu, classname, includePaths, includeFiles); + } + else + { + HLTDebug("Loading HLT trigger class from file '%s'.", codeFileName); + result = LoadTriggerClass(codeFileName, includePaths); + } if (result != 0) return result; fTrigger = AliHLTGlobalTrigger::CreateNew(classname.Data()); @@ -75,6 +195,9 @@ Int_t AliHLTGlobalTriggerComponent::DoInit(int /*argc*/, const char** /*argv*/) return -EIO; } + fTrigger->FillFromMenu(*menu); + fTrigger->ResetCounters(menu->NumberOfItems()); + return 0; } @@ -116,28 +239,48 @@ int AliHLTGlobalTriggerComponent::DoTrigger() // Fill in the input data. const TObject* obj = GetFirstInputObject(); while (obj != NULL) + { + fTrigger->Add(obj, GetDataType(), GetSpecification()); + obj = GetNextInputObject(); + } + + // 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()); + + // Add the input objects used to the global decision. + obj = GetFirstInputObject(); + while (obj != NULL) { if (obj->IsA() == AliHLTTriggerDecision::Class()) { - const AliHLTTriggerDecision* decision = static_cast(obj); - fTrigger->Add(decision); + decision.AddTriggerInput( *static_cast(obj) ); } else { - fTrigger->Add(obj, GetDataType(), GetSpecification()); + decision.AddInputObject(obj); } obj = GetNextInputObject(); } - - // Apply the trigger. - TriggerEvent(fTrigger->CalculateTriggerDecision()); + + TriggerEvent(&decision); return 0; } -int AliHLTGlobalTriggerComponent::GenerateTrigger(const AliHLTTriggerMenu* /*menu*/, TString& name) +int AliHLTGlobalTriggerComponent::GenerateTrigger( + const AliHLTTriggerMenu* menu, TString& name, + const TClonesArray& includePaths, const TClonesArray& includeFiles + ) { // Generates the global trigger class that will implement the specified trigger menu. + // See header for more details. // Create a new UUID and replace the '-' characters with '_' to make it a valid // C++ symbol name. @@ -153,6 +296,7 @@ int AliHLTGlobalTriggerComponent::GenerateTrigger(const AliHLTTriggerMenu* /*men name += uuidstr; TString filename = 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); if (not code.good()) { @@ -160,27 +304,247 @@ int AliHLTGlobalTriggerComponent::GenerateTrigger(const AliHLTTriggerMenu* /*men return -EIO; } + TClonesArray symbols(AliHLTTriggerMenuSymbol::Class()); + int result = BuildSymbolList(menu, symbols); + if (result != 0) return result; + + code << "#include " << endl; + code << "#include \"TString.h\"" << endl; + code << "#include \"TClonesArray.h\"" << endl; code << "#include \"AliHLTGlobalTrigger.h\"" << endl; code << "#include \"AliHLTGlobalTriggerDecision.h\"" << endl; + code << "#include \"AliHLTDomainEntry.h\"" << endl; + code << "#include \"AliHLTTriggerDomain.h\"" << endl; + code << "#include \"AliHLTReadoutList.h\"" << endl; + code << "#include \"AliHLTTriggerMenu.h\"" << endl; + code << "#include \"AliHLTTriggerMenuItem.h\"" << endl; + code << "#include \"AliHLTTriggerMenuSymbol.h\"" << endl; + + // Add any include files that were specified on the command line. + for (Int_t i = 0; i < includeFiles.GetEntriesFast(); i++) + { + TString file = static_cast(includeFiles.UncheckedAt(i))->String(); + code << "#include \"" << file.Data() << "\"" << endl; + } + code << "class " << name << " : public AliHLTGlobalTrigger" << endl; code << "{" << endl; code << "public:" << endl; - code << " " << name << "() : AliHLTGlobalTrigger(), fDecision() {" << endl; + + code << " " << name << "() : AliHLTGlobalTrigger()"; + // Write the symbols in the trigger menu in the initialisation list. + for (Int_t i = 0; i < symbols.GetEntriesFast(); i++) + { + code << "," << endl; + AliHLTTriggerMenuSymbol* symbol = static_cast( symbols.UncheckedAt(i) ); + code << " " << symbol->Name() << "()," << endl; + if (strcmp(symbol->ObjectClass(), "AliHLTTriggerDecision") == 0) + { + code << " " << symbol->Name() << "TriggerDomain()," << endl; + } + code << " " << symbol->Name() << "DomainEntry(kAliHLTAnyDataType)"; + } + for (UInt_t i = 0; i < menu->NumberOfItems(); i++) + { + code << "," << endl << " fMenuItemDescription" << i << "()"; + } + code << endl << " {" << endl; + if (fDebugMode) + { + code << " SetLocalLoggingLevel(kHLTLogAll);" << endl; + code << " HLTInfo(\"Creating new instance at %p.\", this);" << endl; + } code << " }" << endl; + code << " virtual ~" << name << "() {" << endl; + if (fDebugMode) + { + code << " HLTInfo(\"Deleting instance at %p.\", this);" << endl; + } code << " }" << endl; - code << " virtual void NewEvent() {" << endl; - //code << " ;" << endl; + + // Generate the FillFromMenu method. + code << " virtual void FillFromMenu(const AliHLTTriggerMenu& menu) {" << endl; + if (fDebugMode) + { + code << " HLTDebug(\"Filling description entries from trigger menu for global trigger %p.\", this);" << endl; + } + for (UInt_t i = 0; i < menu->NumberOfItems(); i++) + { + code << " fMenuItemDescription" << i << " = (menu.Item(" << i + << ") != NULL) ? menu.Item(" << i << ")->Description() : \"\";" << endl; + } + if (fDebugMode) + { + code << " HLTDebug(\"Finished filling description entries from trigger menu.\");" << endl; + code << " HLTDebug(\"Filling domain entries from trigger menu symbols for global trigger %p.\", this);" << endl; + } + code << " for (Int_t i = 0; i < menu.SymbolArray().GetEntriesFast(); i++) {" << endl; + code << " const AliHLTTriggerMenuSymbol* symbol = dynamic_cast(menu.SymbolArray().UncheckedAt(i));" << endl; + code << " if (symbol == NULL) continue;" << endl; + for (Int_t i = 0; i < symbols.GetEntriesFast(); i++) + { + AliHLTTriggerMenuSymbol* symbol = static_cast( symbols.UncheckedAt(i) ); + code << " if (strcmp(symbol->Name(), \"" << symbol->Name() << "\") == 0) {" << endl; + if (fDebugMode) + { + code << " HLTDebug(\"Assinging domain entry value to match for symbol '%s' to '%s'.\"," + " symbol->Name(), symbol->BlockType().AsString().Data());" << endl; + } + code << " " << symbol->Name() << "DomainEntry = symbol->BlockType();" << endl; + code << " continue;" << endl; + code << " }" << endl; + } + code << " }" << endl; + if (fDebugMode) + { + code << " HLTDebug(\"Finished filling domain entries from trigger menu symbols.\");" << endl; + } code << " }" << endl; - code << " virtual void Add(const AliHLTTriggerDecision* decision) {" << endl; - //code << " ;" << endl; + + // Generate the NewEvent method. + code << " virtual void NewEvent() {" << endl; + if (fDebugMode) + { + code << " HLTDebug(\"New event for global trigger object %p, initialising variables to default values.\", this);" << endl; + } + // Write code to initialise the symbols in the trigger menu to their default values. + for (Int_t i = 0; i < symbols.GetEntriesFast(); i++) + { + AliHLTTriggerMenuSymbol* symbol = static_cast( symbols.UncheckedAt(i) ); + code << " " << symbol->Name() << " = " << symbol->DefaultValue() << ";" << endl; + if (strcmp(symbol->ObjectClass(), "AliHLTTriggerDecision") == 0) + { + code << " " << symbol->Name() << "TriggerDomain.Clear();" << endl; + } + } + if (fDebugMode) + { + code << " HLTDebug(\"Finished initialising variables.\");" << endl; + } code << " }" << endl; - code << " virtual void Add(const TObject* object, const AliHLTComponentDataType& type, AliHLTUInt32_t spec) {" << endl; - //code << " ;" << endl; + + // Generate the Add method. + code << " virtual void Add(const TObject* _object_, const AliHLTComponentDataType& _type_, AliHLTUInt32_t _spec_) {" << endl; + code << " AliHLTDomainEntry _type_spec_(_type_, _spec_);" << endl; + if (fDebugMode) + { + code << " HLTDebug(\"Adding TObject %p, with class name '%s' from data block" + " '%s', to global trigger object %p\", _object_, _object_->ClassName()," + " _type_spec_.AsString().Data(), this);" << endl; + code << " _object_->Print();" << endl; + code << " bool _object_assigned_ = false;" << endl; + } + for (Int_t i = 0; i < symbols.GetEntriesFast(); i++) + { + // Write code to check if the block type, specification and class name is correct. + // Then write code to assign the variable from the input object. + AliHLTTriggerMenuSymbol* symbol = static_cast( symbols.UncheckedAt(i) ); + TString expr = symbol->AssignExpression(); + if (expr == "") continue; // Skip entries that have no assignment expression. + bool isTrigDecision = strcmp(symbol->ObjectClass(), "AliHLTTriggerDecision") == 0; + if (fDebugMode) + { + if (isTrigDecision) + { + code << " HLTDebug(\"Trying to match input object to class '" + << symbol->ObjectClass() << "', trigger name '" << symbol->Name() + << "' and block type '%s'\", " << symbol->Name() + << "DomainEntry.AsString().Data());" << endl; + } + else + { + code << " HLTDebug(\"Trying to match input object to class '" + << symbol->ObjectClass() << "' and block type '%s'\", " + << symbol->Name() << "DomainEntry.AsString().Data());" << endl; + } + } + code << " const " << symbol->ObjectClass() << "* " << symbol->Name() + << "_object_ = dynamic_castObjectClass() + << "*>(_object_);" << endl; + code << " if (" << symbol->Name() << "_object_ != NULL and "; + if (isTrigDecision) + { + code << "strcmp(" << symbol->Name() << "_object_->Name(), \"" + << symbol->Name() << "\") == 0 and "; + } + code << symbol->Name() << "DomainEntry == _type_spec_) {" << endl; + TString fullname = symbol->Name(); + fullname += "_object_"; + expr.ReplaceAll("this", fullname); + code << " this->" << symbol->Name() << " = " << expr.Data() << ";" << endl; + if (isTrigDecision) + { + code << " this->" << symbol->Name() << "TriggerDomain = " + << fullname.Data() << "->TriggerDomain();" << endl; + } + if (fDebugMode) + { + code << " HLTDebug(\"Added TObject %p with class name '%s' to variable " + << symbol->Name() << "\", _object_, _object_->ClassName());" << endl; + code << " _object_assigned_ = true;" << endl; + } + code << " }" << endl; + } + if (fDebugMode) + { + code << " if (not _object_assigned_) HLTDebug(\"Did not assign TObject %p" + " with class name '%s' to any variable.\", _object_, _object_->ClassName());" + << endl; + } code << " }" << endl; - code << " virtual AliHLTGlobalTriggerDecision* CalculateTriggerDecision() {" << endl; - code << " return &fDecision;" << endl; + + // Generate the CalculateTriggerDecision method. + code << " virtual bool CalculateTriggerDecision(AliHLTTriggerDomain& _domain_, TString& _description_) {" << endl; + if (fDebugMode) + { + code << " HLTDebug(\"Calculating global HLT trigger result with trigger object at %p.\", this);" << endl; + } + for (UInt_t i = 0; i < menu->NumberOfItems(); i++) + { + const AliHLTTriggerMenuItem* item = menu->Item(i); + TString mergeExpr = item->MergeExpression(); + for (Int_t j = 0; j < symbols.GetEntriesFast(); j++) + { + AliHLTTriggerMenuSymbol* symbol = static_cast( symbols.UncheckedAt(j) ); + if (strcmp(symbol->ObjectClass(), "AliHLTTriggerDecision") != 0) continue; + TString newname = symbol->Name(); + newname += "TriggerDomain"; + mergeExpr.ReplaceAll(symbol->Name(), newname); + } + if (fDebugMode) + { + code << " HLTDebug(\"Trying trigger condition " << i + << " (Description = '%s').\", fMenuItemDescription" << i << ".Data());" + << endl; + } + code << " if (" << item->TriggerCondision() << ") {" << endl; + code << " IncrementCounter(" << i << ");" << endl; + const char* indentation = ""; + if (item->PreScalar() != 0) + { + indentation = " "; + code << " if ((GetCounter(" << i << ") % " << item->PreScalar() << ") == 1) {" << endl; + } + code << indentation << " _domain_ = " << mergeExpr.Data() << ";" << endl; + code << indentation << " _description_ = fMenuItemDescription" << i << ";" << endl; + if (fDebugMode) + { + code << indentation << " HLTDebug(\"Matched trigger condition " << i + << " (Description = '%s').\", fMenuItemDescription" << i << ".Data());" << endl; + } + code << indentation << " return true;" << endl; + if (item->PreScalar() != 0) + { + code << " }" << endl; + } + code << " }" << endl; + } + code << " return false;" << endl; code << " }" << endl; + + // Generate the custom Factory class. code << " class FactoryImpl : public AliHLTGlobalTrigger::Factory" << endl; code << " {" << endl; code << " public:" << endl; @@ -190,24 +554,166 @@ int AliHLTGlobalTriggerComponent::GenerateTrigger(const AliHLTTriggerMenu* /*men code << " virtual AliHLTGlobalTrigger* New() const {" << endl; code << " return new " << name << "();" << endl; code << " }" << endl; - code << " private:" << endl; - code << " static FactoryImpl fFactoryImpl; // for registration only." << endl; code << " };" << endl; + code << "private:" << endl; - code << " AliHLTGlobalTriggerDecision fDecision;" << endl; + // Add the symbols in the trigger menu to the list of private variables. + for (Int_t i = 0; i < symbols.GetEntriesFast(); i++) + { + AliHLTTriggerMenuSymbol* symbol = static_cast( symbols.UncheckedAt(i) ); + code << " " << symbol->Type() << " " << symbol->Name() << ";" << endl; + if (strcmp(symbol->ObjectClass(), "AliHLTTriggerDecision") == 0) + { + code << " AliHLTTriggerDomain " << symbol->Name() << "TriggerDomain;" << endl; + } + code << " AliHLTDomainEntry " << symbol->Name() << "DomainEntry;" << endl; + } + for (UInt_t i = 0; i < menu->NumberOfItems(); i++) + { + code << " TString fMenuItemDescription" << i << ";" << endl; + } code << "};" << endl; - code << name << "::FactoryImpl " << name << "::FactoryImpl::fFactoryImpl;" << endl; - - TString includePath = "-I${ALICE_ROOT}/include -I${ALICE_ROOT}/HLT/BASE -I${ALICE_ROOT}/HLT/trigger"; - gSystem->SetIncludePath(includePath); - TString cmd = ".L "; - cmd += filename; - cmd += "++"; - gROOT->ProcessLine(cmd); + // Write a global object for the Factory class for automatic registration. + code << "namespace {" << endl; + code << " const " << name << "::FactoryImpl gkFactoryImpl;" << endl; + code << "};" << endl; code.close(); + // Now we need to compile and load the new class. + result = LoadTriggerClass(filename, includePaths); + return result; +} + + +int AliHLTGlobalTriggerComponent::LoadTriggerClass( + const char* filename, const TClonesArray& includePaths + ) +{ + // 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${ALICE_ROOT}/include -I${ALICE_ROOT}/HLT/BASE -I${ALICE_ROOT}/HLT/trigger"; + // Add any include paths that were specified on the command line. + for (Int_t i = 0; i < includePaths.GetEntriesFast(); i++) + { + TString path = static_cast(includePaths.UncheckedAt(i))->String(); + includePath += " "; + includePath += path; + } + gSystem->SetIncludePath(includePath); + gSystem->SetFlagsOpt("-O3 -DNDEBUG"); + gSystem->SetFlagsDebug("-g3 -DDEBUG -D__DEBUG"); + + int result = kTRUE; + if (fDebugMode) + { + result = gSystem->CompileMacro(filename, "g"); + } + else + { + result = gSystem->CompileMacro(filename, "O"); + } + if (result != kTRUE) + { + HLTFatal("Could not compile and load global trigger menu implementation."); + return -ENOENT; + } + } + else + { + // If we do not support the compiler then try interpret the class instead. + TString cmd = ".L "; + cmd += filename; + Int_t errorcode = TInterpreter::kNoError; + gROOT->ProcessLine(cmd, &errorcode); + if (errorcode != TInterpreter::kNoError) + { + HLTFatal("Could not load interpreted global trigger menu implementation" + " (Interpreter error code = %d).", + errorcode + ); + return -ENOENT; + } + } + + return 0; +} + + +int AliHLTGlobalTriggerComponent::FindSymbol(const char* name, const TClonesArray& list) +{ + // Searches for the named symbol in the given list. + // See header for more details. + + for (int i = 0; i < list.GetEntriesFast(); i++) + { + const AliHLTTriggerMenuSymbol* symbol = dynamic_cast( list.UncheckedAt(i) ); + if (symbol == NULL) continue; + if (strcmp(symbol->Name(), name) == 0) return i; + } + return -1; +} + + +int AliHLTGlobalTriggerComponent::BuildSymbolList(const AliHLTTriggerMenu* menu, TClonesArray& list) +{ + // Builds the list of symbols to use in the custom global trigger menu + // implementation class. + // See header for more details. + + for (UInt_t i = 0; i < menu->NumberOfSymbols(); i++) + { + const AliHLTTriggerMenuSymbol* symbol = menu->Symbol(i); + if (FindSymbol(symbol->Name(), list) != -1) + { + HLTError("Multiple symbols with the name '%s' defined in the trigger menu.", symbol->Name()); + return -EIO; + } + new (list[list.GetEntriesFast()]) AliHLTTriggerMenuSymbol(*symbol); + } + + TRegexp exp("[_a-zA-Z][_a-zA-Z0-9]*"); + for (UInt_t i = 0; i < menu->NumberOfItems(); i++) + { + const AliHLTTriggerMenuItem* item = menu->Item(i); + TString str = item->TriggerCondision(); + Ssiz_t start = 0; + do + { + Ssiz_t length = 0; + Ssiz_t pos = exp.Index(str, &length, start); + if (pos == kNPOS) break; + TString s = str(pos, length); + start = 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 + s == "false" + ) + { + // Ignore iso646.h and other keywords. + continue; + } + + if (FindSymbol(s.Data(), list) == -1) + { + AliHLTTriggerMenuSymbol newSymbol; + newSymbol.Name(s.Data()); + newSymbol.Type("bool"); + newSymbol.ObjectClass("AliHLTTriggerDecision"); + newSymbol.AssignExpression("this->Result()"); + newSymbol.DefaultValue("false"); + new (list[list.GetEntriesFast()]) AliHLTTriggerMenuSymbol(newSymbol); + } + } + while (start < str.Length()); + } + return 0; } diff --git a/HLT/trigger/AliHLTGlobalTriggerComponent.h b/HLT/trigger/AliHLTGlobalTriggerComponent.h index 11a36d9be72..d97e0733d6b 100644 --- a/HLT/trigger/AliHLTGlobalTriggerComponent.h +++ b/HLT/trigger/AliHLTGlobalTriggerComponent.h @@ -13,13 +13,61 @@ class AliHLTTriggerMenu; class AliHLTGlobalTrigger; +class TClonesArray; /** * \class AliHLTGlobalTriggerComponent * This class applies the global HLT trigger to all trigger information produced * by components deriving from AliHLTTrigger. * Any information delivered by other components in data blocks that contain - * TObjects can also be used for the trigger algorithm. + * TObjects can also be used for the trigger algorithm. In such cases a symbol + * needs to be defined in the global trigger menu which can then be used inside + * the trigger condition expressions. + * + *

General properties:

+ * + * Component ID: \b HLTGlobalTrigger
+ * Library: \b libAliHLTTrigger.so
+ * Input Data Types: ::kAliHLTAnyDataType
+ * Output Data Types: kAliHLTDataTypeTObject|kAliHLTDataOriginOut
+ * + *

Mandatory arguments:

+ * + *

Optional arguments:

+ * + * \li -config filename
+ * Indicates the configuration macro file to use for the global HLT trigger menu. + * \li -includepath path
+ * Indicates the include path to use if the automatically generated code that + * implements the global HLT trigger requires non-standard includes. + * \li -include filename
+ * Indicates a file name that should be included in the automatically generated + * trigger implementation code. + * \li -debug
+ * If specified the automatically generated class will contain extra debugging + * code and the ACLiC system will have debugging compilation turned on. + * \li -usecode filename classname
+ * Used to force the component to use an existing class for the global HLT trigger + * class implementation, with the name of classname and found in the file + * filename. + * + *

Configuration:

+ * + * Configuration by component arguments. + * + *

Default CDB entries:

+ * TODO + * + *

Performance:

+ * TODO + * + *

Memory consumption:

+ * TODO + * + *

Output size:

+ * TODO + * + * \ingroup alihlt_trigger_components */ class AliHLTGlobalTriggerComponent : public AliHLTTrigger { @@ -66,11 +114,6 @@ class AliHLTGlobalTriggerComponent : public AliHLTTrigger protected: - /// Not implemented. Do not allow copying of this object. - AliHLTGlobalTriggerComponent(const AliHLTGlobalTriggerComponent& obj); - /// Not implemented. Do not allow copying of this object. - AliHLTGlobalTriggerComponent& operator = (const AliHLTGlobalTriggerComponent& obj); - /** * Applies the global HLT trigger. * @return Zero is returned on success and a negative error code on failure. @@ -78,6 +121,11 @@ class AliHLTGlobalTriggerComponent : public AliHLTTrigger virtual int DoTrigger(); private: + + /// Not implemented. Do not allow copying of this object. + AliHLTGlobalTriggerComponent(const AliHLTGlobalTriggerComponent& obj); + /// Not implemented. Do not allow copying of this object. + AliHLTGlobalTriggerComponent& operator = (const AliHLTGlobalTriggerComponent& obj); /** * Generates the code for the global trigger to apply the given trigger menu. @@ -87,13 +135,46 @@ class AliHLTGlobalTriggerComponent : public AliHLTTrigger * AliHLTGlobalTrigger::CreateNew(name) * \endcode * where name is the name of the generated class as returned by this method. + * \param menu in The trigger menu to create the global trigger class from. + * \param name out The name of the generated class. + * \param includePaths in The list of include path strings. + * \param includeFiles in The list of include file strings. + * \returns The error code suitable to return in DoInit. Zero on success. + */ + int GenerateTrigger( + const AliHLTTriggerMenu* menu, TString& name, + const TClonesArray& includePaths, const TClonesArray& includeFiles + ); + + /** + * Loads the code for the generated HLT global trigger class. The code is compiled + * on the fly if possible, otherwise the CINT interpreter is used to interpret + * the class. + * \param filename The name of the file containing the code for the global trigger class. + * \param includePaths in The list of include path strings. + * \returns The error code suitable to return in DoInit. Zero on success. + */ + int LoadTriggerClass(const char* filename, const TClonesArray& includePaths); + + /** + * Searches for the specified symbol name in the given list. + * \param name The name of the symbol to find. + * \param list The list to search for the symbol in. + * \returns The position (index) of the symbol found or -1 if it was not found. + */ + int FindSymbol(const char* name, const TClonesArray& list); + + /** + * Builds the list of symbols to use in the custom global trigger menu + * implementation class. * \param menu The trigger menu to create the global trigger class from. - * \param name The name of the generated class. + * \param list The list to fill with symbols. * \returns The error code suitable to return in DoInit. Zero on success. */ - int GenerateTrigger(const AliHLTTriggerMenu* menu, TString& name); + int BuildSymbolList(const AliHLTTriggerMenu* menu, TClonesArray& list); AliHLTGlobalTrigger* fTrigger; //! Trigger object which implements the global trigger menu. + bool fDebugMode; //! Indicates if the generated global trigger class should be in debug mode. ClassDef(AliHLTGlobalTriggerComponent, 0) // Global HLT trigger component class which produces the final trigger decision and readout list. }; diff --git a/HLT/trigger/AliHLTGlobalTriggerConfig.cxx b/HLT/trigger/AliHLTGlobalTriggerConfig.cxx new file mode 100644 index 00000000000..ee219d61fd6 --- /dev/null +++ b/HLT/trigger/AliHLTGlobalTriggerConfig.cxx @@ -0,0 +1,208 @@ +/************************************************************************** + * This file is property of and copyright by the ALICE HLT Project * + * ALICE Experiment at CERN, All rights reserved. * + * * + * Primary Authors: Artur Szostak * + * for The ALICE HLT Project. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/// @file AliHLTGlobalTriggerConfig.cxx +/// @author Artur Szostak +/// @date 28 Dec 2008 +/// @brief Implementation of the AliHLTGlobalTriggerConfig class. +/// +/// The AliHLTGlobalTriggerConfigComponent class is an interface class used to create +/// global HLT trigger menu configurations. + +#include "AliHLTGlobalTriggerConfig.h" +#include "AliHLTTriggerMenu.h" + +ClassImp(AliHLTGlobalTriggerConfig) + +AliHLTTriggerMenu* AliHLTGlobalTriggerConfig::fgMenu = NULL; + + +AliHLTGlobalTriggerConfig::AliHLTGlobalTriggerConfig(const char* name) +{ + // Default constructor. + + NewMenu(name); +} + + +AliHLTGlobalTriggerConfig::~AliHLTGlobalTriggerConfig() +{ + // Default destructor. +} + + +void AliHLTGlobalTriggerConfig::NewMenu(const char* name) +{ + // Creates a new trigger menu. + + if (fgMenu != NULL) + { + delete fgMenu; + fgMenu = NULL; + } + fgMenu = new AliHLTTriggerMenu; + fgMenu->Name(name); +} + + +void AliHLTGlobalTriggerConfig::Clear() +{ + // Deletes the current trigger menu. + + if (fgMenu != NULL) + { + delete fgMenu; + fgMenu = NULL; + } +} + + +void AliHLTGlobalTriggerConfig::AddSymbol( + const char* name, const char* type, const char* assignExpr, + const char* defaultExpr, const char* className + ) +{ + // Adds a new symbol to the trigger menu. + + if (fgMenu == NULL) NewMenu(""); + + AliHLTTriggerMenuSymbol entry; + entry.Name(name); + entry.Type(type); + entry.ObjectClass(className); + entry.AssignExpression(assignExpr); + entry.DefaultValue(defaultExpr); + fgMenu->AddSymbol(entry); +} + + +void AliHLTGlobalTriggerConfig::AddSymbol( + const char* name, const char* type, const char* assignExpr, + const char* defaultExpr, const char* className, + const AliHLTComponentDataType& blockType + ) +{ + // Adds a new symbol to the trigger menu. + + if (fgMenu == NULL) NewMenu(""); + + AliHLTTriggerMenuSymbol entry; + entry.Name(name); + entry.Type(type); + entry.ObjectClass(className); + entry.AssignExpression(assignExpr); + entry.DefaultValue(defaultExpr); + entry.BlockType(blockType); + fgMenu->AddSymbol(entry); +} + + +void AliHLTGlobalTriggerConfig::AddSymbol( + const char* name, const char* type, const char* assignExpr, + const char* defaultExpr, const char* className, + const AliHLTComponentDataType& blockType, UInt_t spec + ) +{ + // Adds a new symbol to the trigger menu. + + if (fgMenu == NULL) NewMenu(""); + + AliHLTTriggerMenuSymbol entry; + entry.Name(name); + entry.Type(type); + entry.ObjectClass(className); + entry.AssignExpression(assignExpr); + entry.DefaultValue(defaultExpr); + entry.BlockType(blockType, spec); + fgMenu->AddSymbol(entry); +} + + +void AliHLTGlobalTriggerConfig::AddSymbol( + const char* name, const char* type, const char* assignExpr, + const char* defaultExpr, const char* className, + const char* blockType, const char* origin + ) +{ + // Adds a new symbol to the trigger menu. + + if (fgMenu == NULL) NewMenu(""); + + AliHLTTriggerMenuSymbol entry; + entry.Name(name); + entry.Type(type); + entry.ObjectClass(className); + entry.AssignExpression(assignExpr); + entry.DefaultValue(defaultExpr); + entry.BlockType(blockType, origin); + fgMenu->AddSymbol(entry); +} + + +void AliHLTGlobalTriggerConfig::AddSymbol( + const char* name, const char* type, const char* assignExpr, + const char* defaultExpr, const char* className, + const char* blockType, const char* origin, UInt_t spec + ) +{ + // Adds a new symbol to the trigger menu. + + if (fgMenu == NULL) NewMenu(""); + + AliHLTTriggerMenuSymbol entry; + entry.Name(name); + entry.Type(type); + entry.ObjectClass(className); + entry.AssignExpression(assignExpr); + entry.DefaultValue(defaultExpr); + entry.BlockType(blockType, origin, spec); + fgMenu->AddSymbol(entry); +} + + +void AliHLTGlobalTriggerConfig::AddItem( + const char* conditionExpr, const char* domainExpr, UInt_t prescalar, + const char* description + ) +{ + // Adds a new entry to the trigger menu. + + if (fgMenu == NULL) NewMenu(""); + + AliHLTTriggerMenuItem entry; + entry.TriggerCondision(conditionExpr); + entry.MergeExpression(domainExpr); + entry.PreScalar(prescalar); + if (description != NULL) entry.Description(description); + fgMenu->AddItem(entry); +} + + +void AliHLTGlobalTriggerConfig::AddItem( + const char* conditionExpr, const char* domainExpr, const char* description + ) +{ + // Adds a new entry to the trigger menu. + + if (fgMenu == NULL) NewMenu(""); + + AliHLTTriggerMenuItem entry; + entry.TriggerCondision(conditionExpr); + entry.MergeExpression(domainExpr); + if (description != NULL) entry.Description(description); + fgMenu->AddItem(entry); +} + diff --git a/HLT/trigger/AliHLTGlobalTriggerConfig.h b/HLT/trigger/AliHLTGlobalTriggerConfig.h new file mode 100644 index 00000000000..ed04e91415d --- /dev/null +++ b/HLT/trigger/AliHLTGlobalTriggerConfig.h @@ -0,0 +1,204 @@ +#ifndef ALIHLTGLOBALTRIGGERCONFIG_H +#define ALIHLTGLOBALTRIGGERCONFIG_H +/* This file is property of and copyright by the ALICE HLT Project * + * ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/// @file AliHLTGlobalTriggerConfig.h +/// @author Artur Szostak +/// @date 28 Dec 2008 +/// @brief Declaration of the AliHLTGlobalTriggerConfig class. + +#include "TObject.h" + +class AliHLTComponentDataType; +class AliHLTTriggerMenu; + +/** + * \class AliHLTGlobalTriggerConfig + * This class is a user interface class used to make it easy to create HLT global + * trigger configurations (trigger menus). + */ +class AliHLTGlobalTriggerConfig +{ + public: + + /** + * Default constructor. + */ + AliHLTGlobalTriggerConfig(const char* name = NULL); + + /** + * Default destructor. + */ + virtual ~AliHLTGlobalTriggerConfig(); + + /** + * Creates a new trigger menu. If a trigger menu is already active then the existing + * one is replaced with the new menu. + * \param name The name of the new trigger menu. + */ + static void NewMenu(const char* name); + + /** + * Deletes the current trigger menu. + */ + static void Clear(); + + /** + * Returns the current trigger menu. + */ + static const AliHLTTriggerMenu* Menu() { return fgMenu; } + + /** + * Adds a new symbol to the current trigger menu. + * \param name The name of the symbol. It must be a valid C++ variable name. + * \param type The data type of the symbol. It must be a valid C++ data type. + * \param assignExpr The assignment expression for the symbol. It must be a + * valid C++ expression. The 'this' keyword is used as a place holder for + * the object found in the data block. + * \param defaultExpr The default value to use for the symbol. It must be a + * valid C++ expression. + * \param className The class name of the object found in the data block from + * which to fetch the symbol's value. + */ + static void AddSymbol( + const char* name, const char* type, const char* assignExpr, + const char* defaultExpr, const char* className = "TObject" + ); + + /** + * Adds a new symbol to the current trigger menu. + * \param name The name of the symbol. It must be a valid C++ variable name. + * \param type The data type of the symbol. It must be a valid C++ data type. + * \param assignExpr The assignment expression for the symbol. It must be a + * valid C++ expression. The 'this' keyword is used as a place holder for + * the object found in the data block. + * \param defaultExpr The default value to use for the symbol. It must be a + * valid C++ expression. + * \param className The class name of the object found in the data block from + * which to fetch the symbol's value. + * \param blockType The data block type and origin from which to fetch the + * symbol's value. + */ + static void AddSymbol( + const char* name, const char* type, const char* assignExpr, + const char* defaultExpr, const char* className, + const AliHLTComponentDataType& blockType + ); + + /** + * Adds a new symbol to the current trigger menu. + * \param name The name of the symbol. It must be a valid C++ variable name. + * \param type The data type of the symbol. It must be a valid C++ data type. + * \param assignExpr The assignment expression for the symbol. It must be a + * valid C++ expression. The 'this' keyword is used as a place holder for + * the object found in the data block. + * \param defaultExpr The default value to use for the symbol. It must be a + * valid C++ expression. + * \param className The class name of the object found in the data block from + * which to fetch the symbol's value. + * \param blockType The data block type and origin from which to fetch the + * symbol's value. + * \param spec The data block specification to use. + */ + static void AddSymbol( + const char* name, const char* type, const char* assignExpr, + const char* defaultExpr, const char* className, + const AliHLTComponentDataType& blockType, UInt_t spec + ); + + /** + * Adds a new symbol to the current trigger menu. + * \param name The name of the symbol. It must be a valid C++ variable name. + * \param type The data type of the symbol. It must be a valid C++ data type. + * \param assignExpr The assignment expression for the symbol. It must be a + * valid C++ expression. The 'this' keyword is used as a place holder for + * the object found in the data block. + * \param defaultExpr The default value to use for the symbol. It must be a + * valid C++ expression. + * \param className The class name of the object found in the data block from + * which to fetch the symbol's value. + * \param blockType The data block type string of the data block. The value + * kAliHLTAnyDataTypeID can be used to specify the any type wild card value. + * \param origin The origin of the data block, such as the detector name. + * The value kAliHLTDataOriginAny can be used to specify the any origin + * wild card value. + */ + static void AddSymbol( + const char* name, const char* type, const char* assignExpr, + const char* defaultExpr, const char* className, + const char* blockType, const char* origin + ); + + /** + * Adds a new symbol to the current trigger menu. + * \param name The name of the symbol. It must be a valid C++ variable name. + * \param type The data type of the symbol. It must be a valid C++ data type. + * \param assignExpr The assignment expression for the symbol. It must be a + * valid C++ expression. The 'this' keyword is used as a place holder for + * the object found in the data block. + * \param defaultExpr The default value to use for the symbol. It must be a + * valid C++ expression. + * \param className The class name of the object found in the data block from + * which to fetch the symbol's value. + * \param blockType The data block type string of the data block. The value + * kAliHLTAnyDataTypeID can be used to specify the any type wild card value. + * \param origin The origin of the data block, such as the detector name. + * The value kAliHLTDataOriginAny can be used to specify the any origin + * wild card value. + * \param spec The data block specification to use. + */ + static void AddSymbol( + const char* name, const char* type, const char* assignExpr, + const char* defaultExpr, const char* className, + const char* blockType, const char* origin, UInt_t spec + ); + + /** + * Adds a new trigger menu item to the current trigger menu. + * \param conditionExpr The trigger condition expression. It must be a valid + * C++ expression, where the symbol names must be either defined in the + * menu or the names of AliHLTTrigger components. + * \param domainExpr The trigger domain merging expression. It must be a + * valid C++ expression, where the symbol names must be either defined in + * the menu or the names of AliHLTTrigger components. + * \param prescalar The prescalar value to use (Zero if not used). + * \param description Optional description string which will be used in the + * global result. + */ + static void AddItem( + const char* conditionExpr, const char* domainExpr, UInt_t prescalar, + const char* description = NULL + ); + + /** + * Adds a new trigger menu item to the current trigger menu. + * \param conditionExpr The trigger condition expression. It must be a valid + * C++ expression, where the symbol names must be either defined in the + * menu or the names of AliHLTTrigger components. + * \param domainExpr The trigger domain merging expression. It must be a + * valid C++ expression, where the symbol names must be either defined in + * the menu or the names of AliHLTTrigger components. + * \param description Optional description string which will be used in the + * global result. + */ + static void AddItem( + const char* conditionExpr, const char* domainExpr, + const char* description = NULL + ); + + private: + + /// Not implemented. Do not allow copying of this object. + AliHLTGlobalTriggerConfig(const AliHLTGlobalTriggerConfig& obj); + /// Not implemented. Do not allow copying of this object. + AliHLTGlobalTriggerConfig& operator = (const AliHLTGlobalTriggerConfig& obj); + + static AliHLTTriggerMenu* fgMenu; /// Trigger menu which is created by this interface class. + + ClassDef(AliHLTGlobalTriggerConfig, 0) // Interface class used to construct a global HLT trigger menu configuration. +}; + +#endif // ALIHLTGLOBALTRIGGERCONFIG_H + diff --git a/HLT/trigger/AliHLTGlobalTriggerDecision.cxx b/HLT/trigger/AliHLTGlobalTriggerDecision.cxx index e4e74609329..62d29472d7d 100644 --- a/HLT/trigger/AliHLTGlobalTriggerDecision.cxx +++ b/HLT/trigger/AliHLTGlobalTriggerDecision.cxx @@ -30,6 +30,7 @@ ClassImp(AliHLTGlobalTriggerDecision) AliHLTGlobalTriggerDecision::AliHLTGlobalTriggerDecision() : AliHLTTriggerDecision(), fContributingTriggers(AliHLTTriggerDecision::Class()), + fInputObjects(), fCounters() { // Default constructor. @@ -37,16 +38,17 @@ AliHLTGlobalTriggerDecision::AliHLTGlobalTriggerDecision() : AliHLTGlobalTriggerDecision::AliHLTGlobalTriggerDecision( - bool result, const AliHLTReadoutList& readoutList, - const AliHLTTriggerDomain& triggerDomain, const char* description + bool result, const AliHLTTriggerDomain& triggerDomain, const char* description ) : - AliHLTTriggerDecision(result, "HLTGlobalTrigger", readoutList, triggerDomain, description), + AliHLTTriggerDecision(result, "HLTGlobalTrigger", triggerDomain, description), fContributingTriggers(AliHLTTriggerDecision::Class()), + fInputObjects(), fCounters() { // Constructor specifying multiple information fields. Result(result); + fInputObjects.SetOwner(kTRUE); } @@ -61,32 +63,71 @@ void AliHLTGlobalTriggerDecision::Print(Option_t* option) const // Prints the contents of the trigger decision. TString opt(option); - if (opt.Contains("short")) + if (opt.Contains("compact")) + { + cout << "Global "; + AliHLTTriggerDecision::Print(""); + } + else if (opt.Contains("short")) { cout << "Global "; AliHLTTriggerDecision::Print(option); - cout << "==================== Input trigger decisions ===================="; + cout << "#################### Input trigger decisions ####################" << endl; for (Int_t i = 0; i < NumberOfTriggerInputs(); i++) { TriggerInput(i)->Print(option); } + if (NumberOfTriggerInputs() == 0) + { + cout << "(none)" << endl; + } + } + else if (opt.Contains("counters")) + { + cout << "Counter\tValue" << endl; + for (Int_t i = 0; i < fCounters.GetSize(); i++) + { + cout << i << "\t" << fCounters[i] << endl; + } + if (fCounters.GetSize() == 0) + { + cout << "(none)" << endl; + } } else { cout << "Global "; AliHLTTriggerDecision::Print(option); - cout << "#################### Input trigger decisions ####################"; + cout << "#################### Input trigger decisions ####################" << endl; for (Int_t i = 0; i < NumberOfTriggerInputs(); i++) { - cout << "-------------------- Input trigger decision " << i << " --------------------"; + cout << "-------------------- Input trigger decision " << i << " --------------------" << endl; TriggerInput(i)->Print(option); } - cout << "#################### Event class counters ####################"; + if (NumberOfTriggerInputs() == 0) + { + cout << "(none)" << endl; + } + cout << "###################### Other input objects ######################" << endl; + for (Int_t i = 0; i < NumberOfInputObjects(); i++) + { + cout << "------------------------ Input object " << i << " ------------------------" << endl; + InputObject(i)->Print(option); + } + if (NumberOfInputObjects() == 0) + { + cout << "(none)" << endl; + } + cout << "#################### Event class counters ####################" << endl; cout << "Counter\tValue" << endl; for (Int_t i = 0; i < fCounters.GetSize(); i++) { cout << i << "\t" << fCounters[i] << endl; } + if (fCounters.GetSize() == 0) + { + cout << "(none)" << endl; + } } } diff --git a/HLT/trigger/AliHLTGlobalTriggerDecision.h b/HLT/trigger/AliHLTGlobalTriggerDecision.h index ca2c93326bd..384f9cd68b6 100644 --- a/HLT/trigger/AliHLTGlobalTriggerDecision.h +++ b/HLT/trigger/AliHLTGlobalTriggerDecision.h @@ -11,6 +11,7 @@ #include "AliHLTTriggerDecision.h" #include "TArrayL64.h" +#include "TObjArray.h" class AliHLTGlobalTriggerDecision : public AliHLTTriggerDecision { @@ -24,13 +25,12 @@ class AliHLTGlobalTriggerDecision : public AliHLTTriggerDecision /** * Constructor specifying multiple information fields. * \param result The result of the global trigger decision. - * \param readoutList The DDL readout list for the global trigger decision. * \param triggerDomain The trigger domain for the global trigger decision. * \param description The description of (reason for) the global trigger decision. */ AliHLTGlobalTriggerDecision( - bool result, const AliHLTReadoutList& readoutList, - const AliHLTTriggerDomain& triggerDomain, const char* description = "" + bool result, const AliHLTTriggerDomain& triggerDomain, + const char* description = "" ); /** @@ -40,7 +40,9 @@ class AliHLTGlobalTriggerDecision : public AliHLTTriggerDecision /** * Inherited from TObject, this prints the contents of the trigger decision. - * \param option Can be "short" which will print the short format. + * \param option Can be "short" which will print the short format or "counters" + * which will print only the counters or "compact" which will print only the + * global information but not the lists of input objects. */ virtual void Print(Option_t* option = "") const; @@ -72,6 +74,37 @@ class AliHLTGlobalTriggerDecision : public AliHLTTriggerDecision new (fContributingTriggers[fContributingTriggers.GetEntriesFast()]) AliHLTTriggerDecision(decision); } + /** + * Returns the number of other input objects that contributed to this global trigger decision. + */ + Int_t NumberOfInputObjects() const { return fInputObjects.GetEntriesFast(); } + + /** + * Returns the i'th input object in fInputObjects. + */ + const TObject* InputObject(Int_t i) const { return fInputObjects[i]; } + + /** + * Returns the list of other input objects used when making the global HLT trigger decision. + */ + const TObjArray& InputObjects() const { return fInputObjects; } + + /** + * Adds a input object to the list of input objects that were considered when + * making this global trigger decision. + * \param object The input object to add. + * \note A copy of the object is made with TObject::Clone() and added. + */ + void AddInputObject(const TObject* object) + { + fInputObjects.Add(object->Clone()); + } + + /** + * Sets the counter array. + */ + void SetCounters(const TArrayL64& counters) { fCounters = counters; } + /** * Returns the event trigger counters associated with the global trigger classes. */ @@ -80,6 +113,7 @@ class AliHLTGlobalTriggerDecision : public AliHLTTriggerDecision private: TClonesArray fContributingTriggers; /// The list of contributing trigger decisions from all AliHLTTrigger components that were considered. + TObjArray fInputObjects; /// The list of other input objects. TArrayL64 fCounters; /// Event trigger counters. One counter for each trigger class in the global trigger. ClassDef(AliHLTGlobalTriggerDecision, 1) // Contains the HLT global trigger decision and information contributing to the decision. diff --git a/HLT/trigger/AliHLTReadoutList.cxx b/HLT/trigger/AliHLTReadoutList.cxx index c411e9f5e22..f60ca204e90 100644 --- a/HLT/trigger/AliHLTReadoutList.cxx +++ b/HLT/trigger/AliHLTReadoutList.cxx @@ -297,6 +297,52 @@ void AliHLTReadoutList::Disable(Int_t detector) } +bool AliHLTReadoutList::DetectorEnabled(Int_t detector) const +{ + // Checks if a particular detector's DDLs are enabled. + // See header file for more details. + + bool result = true; + if ((detector & kITSSPD) != 0) result &= fReadoutList.fList[0] == 0x000FFFFF; + if ((detector & kITSSDD) != 0) result &= fReadoutList.fList[1] == 0x00FFFFFF; + if ((detector & kITSSSD) != 0) result &= fReadoutList.fList[2] == 0x0000FFFF; + if ((detector & kTPC) != 0) + { + result &= fReadoutList.fList[3] == 0xFFFFFFFF; + result &= fReadoutList.fList[4] == 0xFFFFFFFF; + result &= fReadoutList.fList[5] == 0xFFFFFFFF; + result &= fReadoutList.fList[6] == 0xFFFFFFFF; + result &= fReadoutList.fList[7] == 0xFFFFFFFF; + result &= fReadoutList.fList[8] == 0xFFFFFFFF; + result &= fReadoutList.fList[9] == 0x00FFFFFF; + } + if ((detector & kTRD) != 0) result &= fReadoutList.fList[11] == 0x0003FFFF; + if ((detector & kTOF) != 0) + { + result &= fReadoutList.fList[12] == 0xFFFFFFFF; + result &= fReadoutList.fList[13] == 0xFFFFFFFF; + result &= fReadoutList.fList[14] == 0x000000FF; + } + if ((detector & kHMPID) != 0) result &= fReadoutList.fList[15] == 0x00003FFF; + if ((detector & kPHOS) != 0) result &= fReadoutList.fList[16] == 0x000FFFFF; + if ((detector & kCPV) != 0) result &= fReadoutList.fList[17] == 0x000003FF; + if ((detector & kPMD) != 0) result &= fReadoutList.fList[18] == 0x0000003F; + if ((detector & kMUONTRK) != 0) result &= fReadoutList.fList[19] == 0x000FFFFF; + if ((detector & kMUONTRG) != 0) result &= fReadoutList.fList[20] == 0x00000003; + if ((detector & kFMD) != 0) result &= fReadoutList.fList[21] == 0x00000007; + if ((detector & kT0) != 0) result &= fReadoutList.fList[22] == 0x00000001; + if ((detector & kV0) != 0) result &= fReadoutList.fList[23] == 0x00000001; + if ((detector & kZDC) != 0) result &= fReadoutList.fList[24] == 0x00000001; + if ((detector & kACORDE) != 0) result &= fReadoutList.fList[25] == 0x00000001; + if ((detector & kTRG) != 0) result &= fReadoutList.fList[26] == 0x00000001; + if ((detector & kEMCAL) != 0) result &= fReadoutList.fList[27] == 0x00FFFFFF; + if ((detector & kDAQTEST) != 0) result &= fReadoutList.fList[28] == 0x00000001; + if ((detector & kHLT) != 0) result &= fReadoutList.fList[29] == 0x000003FF; + + return result; +} + + void AliHLTReadoutList::Print(Option_t* /*option*/) const { // Prints the DDLs that will be readout according to this readout list. diff --git a/HLT/trigger/AliHLTReadoutList.h b/HLT/trigger/AliHLTReadoutList.h index 3117bcc5fe6..ebc50621054 100644 --- a/HLT/trigger/AliHLTReadoutList.h +++ b/HLT/trigger/AliHLTReadoutList.h @@ -171,6 +171,14 @@ class AliHLTReadoutList : public TObject */ void Disable(Int_t detector); + /** + * Checks if a particular detector's DDLs are enabled for readout. + * \param detector A bitmap of detectors to check. Should be any values from + * EDetectorId that can be or'ed together for multiple detector selection. + * \return true if all DDLs for the specified detectors are enabled for readout. + */ + bool DetectorEnabled(Int_t ddlId) const; + /** * Inherited from TObject. Prints the DDLs that will be readout according to * this readout list. diff --git a/HLT/trigger/AliHLTRunSummary.h b/HLT/trigger/AliHLTRunSummary.h index 3f8c4332101..b6146c9c07f 100644 --- a/HLT/trigger/AliHLTRunSummary.h +++ b/HLT/trigger/AliHLTRunSummary.h @@ -63,7 +63,7 @@ public: /** Get number of events * @return number of events */ - ULong_t GetNEvents() { return fNEvents; } + ULong_t GetNEvents() const { return fNEvents; } /** Set number of rejected events * @param i number of events rejected @@ -76,7 +76,7 @@ public: /** Get number of reejcted events * @return number of events rejected */ - ULong_t GetNEventsRejected() { return fNEventsRejected; } + ULong_t GetNEventsRejected() const { return fNEventsRejected; } // -- run parameters ------------------------ @@ -88,7 +88,7 @@ public: /** Get Run Number * @return run number */ - AliHLTUInt32_t GetRunNumber() { return fRunNumber;} + AliHLTUInt32_t GetRunNumber() const { return fRunNumber;} /** Set Run Type * @param i run type @@ -98,7 +98,7 @@ public: /** Get Run Type s * @return run type */ - AliHLTUInt32_t GetRunType() { return fRunType; } + AliHLTUInt32_t GetRunType() const { return fRunType; } // -- trigger parameters ------------------------ @@ -111,7 +111,8 @@ public: /** Get ocurrance of trigger classes * @return ptr to array of trigger classes */ - ULong_t* GetTriggerClasses() { return fTriggerClasses; } + const ULong_t* GetTriggerClasses() const { return fTriggerClasses; } + ULong_t* GetTriggerClasses() { return fTriggerClasses; } // -- detector parameters ------------------------ diff --git a/HLT/trigger/AliHLTTrigger.cxx b/HLT/trigger/AliHLTTrigger.cxx index 473d1227a18..c08eb2ca064 100644 --- a/HLT/trigger/AliHLTTrigger.cxx +++ b/HLT/trigger/AliHLTTrigger.cxx @@ -90,7 +90,8 @@ void AliHLTTrigger::TriggerEvent(bool value) // See header file for more details. if (fTriggerEventResult != 0) return; // Do not do anything if a previous call failed. - AliHLTTriggerDecision triggerResult(value, GetTriggerName(), fReadoutList, fTriggerDomain, fDescription); + AliHLTTriggerDecision triggerResult(value, GetTriggerName(), fTriggerDomain, fDescription); + triggerResult.ReadoutList(fReadoutList); // Append the readout list if it contains anything. fTriggerEventResult = PushBack(&triggerResult, kAliHLTDataTypeTObject|kAliHLTDataOriginOut); if (fTriggerEventResult == 0) fDecisionMade = true; } diff --git a/HLT/trigger/AliHLTTriggerDecision.cxx b/HLT/trigger/AliHLTTriggerDecision.cxx index f9aef3f1642..f055996fb3b 100644 --- a/HLT/trigger/AliHLTTriggerDecision.cxx +++ b/HLT/trigger/AliHLTTriggerDecision.cxx @@ -31,7 +31,6 @@ AliHLTTriggerDecision::AliHLTTriggerDecision() : TObject(), fName(), fDescription(), - fReadoutList(), fTriggerDomain() { // Default constructor. @@ -42,7 +41,6 @@ AliHLTTriggerDecision::AliHLTTriggerDecision(bool result, const char* name) : TObject(), fName(name), fDescription(), - fReadoutList(), fTriggerDomain() { // Constructor specifying the name and result of the trigger decision. @@ -52,13 +50,13 @@ AliHLTTriggerDecision::AliHLTTriggerDecision(bool result, const char* name) : AliHLTTriggerDecision::AliHLTTriggerDecision( - bool result, const char* name, const AliHLTReadoutList& readoutList, - const AliHLTTriggerDomain& triggerDomain, const char* description + bool result, const char* name, + const AliHLTTriggerDomain& triggerDomain, + const char* description ) : TObject(), fName(name), fDescription(description), - fReadoutList(readoutList), fTriggerDomain(triggerDomain) { // Constructor specifying all information fields. @@ -81,7 +79,6 @@ void AliHLTTriggerDecision::Print(Option_t* option) const TString opt(option); if (opt.Contains("short")) return; cout << "Description = \"" << fDescription.Data() << "\"" << endl; - fReadoutList.Print(); fTriggerDomain.Print(); } diff --git a/HLT/trigger/AliHLTTriggerDecision.h b/HLT/trigger/AliHLTTriggerDecision.h index dab60b92d0f..2523f7c7c4a 100644 --- a/HLT/trigger/AliHLTTriggerDecision.h +++ b/HLT/trigger/AliHLTTriggerDecision.h @@ -42,13 +42,12 @@ class AliHLTTriggerDecision : public TObject * \param result The result of the trigger decision. * \param name The name of the trigger decision. Should be the name of the * AliHLTTrigger component. - * \param readoutList The DDL readout list for the trigger decision. * \param triggerDomain The trigger domain for the trigger decision. * \param description The description of (reason for) the trigger decision. */ AliHLTTriggerDecision( - bool result, const char* name, const AliHLTReadoutList& readoutList, - const AliHLTTriggerDomain& triggerDomain, const char* description = "" + bool result, const char* name, const AliHLTTriggerDomain& triggerDomain, + const char* description = "" ); /** @@ -111,24 +110,26 @@ class AliHLTTriggerDecision : public TObject /** * Returns the DDL readout list associated with this trigger decision. */ - const AliHLTReadoutList& ReadoutList() const { return fReadoutList; } - - /** - * Returns the DDL readout list associated with this trigger decision for - * modification. - */ - AliHLTReadoutList& ReadoutList() { return fReadoutList; } + AliHLTReadoutList ReadoutList() const { return AliHLTReadoutList(fTriggerDomain); } /** * Sets the DDL readout list associated with this trigger decision. */ - void ReadoutList(const AliHLTReadoutList& value) { fReadoutList = value; } + void ReadoutList(const AliHLTReadoutList& value) + { + fTriggerDomain += AliHLTTriggerDomain(value); + } /** * Returns the trigger domain associated with this trigger decision. */ const AliHLTTriggerDomain& TriggerDomain() const { return fTriggerDomain; } + /** + * Returns the trigger domain associated with this trigger decision for editing. + */ + AliHLTTriggerDomain& TriggerDomain() { return fTriggerDomain; } + /** * Sets the trigger domain associated with this trigger decision. */ @@ -138,7 +139,6 @@ class AliHLTTriggerDecision : public TObject TString fName; /// The name of the trigger decision. Should be the name of the trigger component that generated it. TString fDescription; /// Optional descriptive text giving the reason for the trigger. - AliHLTReadoutList fReadoutList; /// The readout DDL list. AliHLTTriggerDomain fTriggerDomain; /// The trigger domain associated with this trigger. i.e. the HLT data blocks to read out. ClassDef(AliHLTTriggerDecision, 1) // HLT trigger decision object storing information about the readout list, trigger domain and result. diff --git a/HLT/trigger/AliHLTTriggerDomain.cxx b/HLT/trigger/AliHLTTriggerDomain.cxx index 9f8a9577c35..fc3fd9023ad 100644 --- a/HLT/trigger/AliHLTTriggerDomain.cxx +++ b/HLT/trigger/AliHLTTriggerDomain.cxx @@ -24,7 +24,11 @@ #include "AliHLTTriggerDomain.h" #include "AliHLTDomainEntry.h" +#include "AliHLTReadoutList.h" #include "Riostream.h" +#include "TObjArray.h" +#include "TObjString.h" +#include "AliDAQ.h" ClassImp(AliHLTTriggerDomain) @@ -36,6 +40,101 @@ AliHLTTriggerDomain::AliHLTTriggerDomain() : } +AliHLTTriggerDomain::AliHLTTriggerDomain(const char* list) : + TObject(), fEntries(AliHLTDomainEntry::Class(), 10) +{ + // Constructs the domain from a list of entries. + + TString lst = list; + TObjArray* entries = lst.Tokenize(","); + for (Int_t i = 0; i < entries->GetEntriesFast(); i++) + { + TString entry = static_cast(entries->UncheckedAt(i))->GetString(); + TObjArray* domainStrings = entry.Tokenize(":"); + if (domainStrings->GetEntriesFast() <= 0 or domainStrings->GetEntriesFast() > 3) + { + Error("AliHLTTriggerDomain", + "The domain string must contain 1, 2 or 3 fields separated by a ':'." + ); + delete domainStrings; + continue; + } + + bool inclusiveEntry = true; + TString typeString = "*******"; + if (domainStrings->GetEntriesFast() >= 1) + { + typeString = static_cast(domainStrings->UncheckedAt(0))->GetString(); + if (typeString.Length() > 0) + { + if (typeString[0] == '+') + { + inclusiveEntry = true; + typeString.Remove(0, 1); + } + if (typeString[0] == '-') + { + inclusiveEntry = false; + typeString.Remove(0, 1); + } + } + } + TString originString = "***"; + if (domainStrings->GetEntriesFast() >= 2) + { + originString = static_cast(domainStrings->UncheckedAt(1))->GetString(); + } + bool usespec = false; + UInt_t spec = 0; + if (domainStrings->GetEntriesFast() == 3) + { + TString specString = static_cast(domainStrings->UncheckedAt(2))->GetString(); + char* error = NULL; + spec = UInt_t( strtoul(specString.Data(), &error, 0) ); + if (error == NULL or *error != '\0') + { + Error("AliHLTTriggerDomain", + "The last field of the domain string must be a number, but we received '%s'.", + specString.Data() + ); + } + else + { + usespec = true; + } + } + + if (usespec) + { + if (inclusiveEntry) + Add(typeString.Data(), originString.Data(), spec); + else + Remove(typeString.Data(), originString.Data(), spec); + } + else + { + if (inclusiveEntry) + Add(typeString.Data(), originString.Data()); + else + Remove(typeString.Data(), originString.Data()); + } + + delete domainStrings; + } + delete entries; +} + + +AliHLTTriggerDomain::AliHLTTriggerDomain(const AliHLTReadoutList& list) : + TObject(), fEntries(AliHLTDomainEntry::Class(), 10) +{ + // Constructor creates a trigger domain from a readout list. + // See header file for more details. + + Add(list); +} + + AliHLTTriggerDomain::AliHLTTriggerDomain(const AliHLTTriggerDomain& domain) : TObject(domain), fEntries(AliHLTDomainEntry::Class(), domain.fEntries.GetEntriesFast()) @@ -57,6 +156,38 @@ AliHLTTriggerDomain::~AliHLTTriggerDomain() } +void AliHLTTriggerDomain::Add(const AliHLTReadoutList& list) +{ + // Adds the readout list to the trigger domain. + // See header file for more details. + + Int_t detId[AliDAQ::kNDetectors] = { + AliHLTReadoutList::kITSSPD, AliHLTReadoutList::kITSSDD, AliHLTReadoutList::kITSSSD, + AliHLTReadoutList::kTPC, AliHLTReadoutList::kTRD, AliHLTReadoutList::kTOF, + AliHLTReadoutList::kHMPID, AliHLTReadoutList::kPHOS, AliHLTReadoutList::kCPV, + AliHLTReadoutList::kPMD, AliHLTReadoutList::kMUONTRK, AliHLTReadoutList::kMUONTRG, + AliHLTReadoutList::kFMD, AliHLTReadoutList::kT0, AliHLTReadoutList::kV0, + AliHLTReadoutList::kZDC, AliHLTReadoutList::kACORDE, AliHLTReadoutList::kTRG, + AliHLTReadoutList::kEMCAL, AliHLTReadoutList::kDAQTEST, AliHLTReadoutList::kHLT + }; + + for (Int_t deti = 0; deti < AliDAQ::kNDetectors; deti++) + { + if (list.DetectorEnabled(detId[deti])) + { + Add("DAQRDOUT", AliDAQ::OnlineName(deti)); + } + else + { + for (Int_t i = 0; i < AliDAQ::NumberOfDdls(deti); i++) + { + Int_t ddlId = AliDAQ::DdlID(deti, i); + if (list.IsDDLEnabled(ddlId)) Add("DAQRDOUT", AliDAQ::OnlineName(deti), ddlId); + } + } + } +} + void AliHLTTriggerDomain::Add(const AliHLTDomainEntry& entry) { // Adds a new domain entry to the trigger domain. @@ -155,6 +286,39 @@ void AliHLTTriggerDomain::Add(const char* blocktype, const char* origin, UInt_t } +void AliHLTTriggerDomain::Remove(const AliHLTReadoutList& list) +{ + // Removes the entries in the readout list from the trigger domain that are enabled. + // See header file for more details. + + Int_t detId[AliDAQ::kNDetectors] = { + AliHLTReadoutList::kITSSPD, AliHLTReadoutList::kITSSDD, AliHLTReadoutList::kITSSSD, + AliHLTReadoutList::kTPC, AliHLTReadoutList::kTRD, AliHLTReadoutList::kTOF, + AliHLTReadoutList::kHMPID, AliHLTReadoutList::kPHOS, AliHLTReadoutList::kCPV, + AliHLTReadoutList::kPMD, AliHLTReadoutList::kMUONTRK, AliHLTReadoutList::kMUONTRG, + AliHLTReadoutList::kFMD, AliHLTReadoutList::kT0, AliHLTReadoutList::kV0, + AliHLTReadoutList::kZDC, AliHLTReadoutList::kACORDE, AliHLTReadoutList::kTRG, + AliHLTReadoutList::kEMCAL, AliHLTReadoutList::kDAQTEST, AliHLTReadoutList::kHLT + }; + + for (Int_t deti = 0; deti < AliDAQ::kNDetectors; deti++) + { + if (list.DetectorEnabled(detId[deti])) + { + Remove("DAQRDOUT", AliDAQ::OnlineName(deti)); + } + else + { + for (Int_t i = 0; i < AliDAQ::NumberOfDdls(deti); i++) + { + Int_t ddlId = AliDAQ::DdlID(deti, i); + if (list.IsDDLEnabled(ddlId)) Remove("DAQRDOUT", AliDAQ::OnlineName(deti), ddlId); + } + } + } +} + + void AliHLTTriggerDomain::Remove(const AliHLTDomainEntry& entry) { // Removes the given domain entry from the trigger domain. @@ -664,6 +828,26 @@ AliHLTTriggerDomain AliHLTTriggerDomain::operator & (const AliHLTTriggerDomain& } +AliHLTTriggerDomain::operator AliHLTReadoutList () const +{ + // Typecast operator which constructs a readout list from the trigger domain. + + AliHLTReadoutList result; + for (Int_t deti = 0; deti < AliDAQ::kNDetectors; deti++) + { + for (Int_t i = 0; i < AliDAQ::NumberOfDdls(deti); i++) + { + Int_t ddlId = AliDAQ::DdlID(deti, i); + if (Contains(AliHLTDomainEntry("DAQRDOUT", AliDAQ::OnlineName(deti), ddlId))) + { + result.EnableDDLBit(ddlId); + } + } + } + return result; +} + + void AliHLTTriggerDomain::MergeEntries( const bool* removeThisEntry, Int_t entriesCount, const bool* removeDomainEntry, Int_t startOfIntersects, diff --git a/HLT/trigger/AliHLTTriggerDomain.h b/HLT/trigger/AliHLTTriggerDomain.h index b12ff41f4d2..6b578a11c19 100644 --- a/HLT/trigger/AliHLTTriggerDomain.h +++ b/HLT/trigger/AliHLTTriggerDomain.h @@ -14,6 +14,7 @@ #include "AliHLTDataTypes.h" class AliHLTDomainEntry; +class AliHLTReadoutList; /** * \class AliHLTTriggerDomain @@ -55,6 +56,26 @@ class AliHLTTriggerDomain : public TObject */ AliHLTTriggerDomain(); + /** + * Constructs the trigger domain from a list of domain entries. + * \param list Comma separated list of domain entries of the form xxx:yyy:zzz + * Can optionaly have a '+' or '-' character just in front of the block + * type string, xxx in this case, to indicate inclusive or exclusive entries. + * \note If inclusive and exclusive entries are specified then they are applied + * in the order found in the list, from left to right. This means that subsequent + * includes can override previous excludes and visa versa. + */ + AliHLTTriggerDomain(const char* list); + + /** + * Constructor to create a trigger domain from a DDL readout list. + * The trigger domain will contain entries of the form "DAQRDOUT:xxxx:yyyy" + * where xxxx is the appropriate detector name given by AliDAQ::OnlineName() + * and yyyy is the DDL equipment ID number. + * \param list The read out list object + */ + AliHLTTriggerDomain(const AliHLTReadoutList& list); + /** * Copy constructor performs a deep copy. * \param domain The domain entry to copy from. @@ -66,6 +87,15 @@ class AliHLTTriggerDomain : public TObject */ virtual ~AliHLTTriggerDomain(); + /** + * Adds entries to the trigger domain to correspond to the DDL readout list. + * The trigger domain will contain entries of the form "DAQRDOUT:xxxx:yyyy" + * where xxxx is the appropriate detector name given by AliDAQ::OnlineName() + * and yyyy is the DDL equipment ID number. + * \param list The readout list object + */ + void Add(const AliHLTReadoutList& list); + /** * Adds the given entry to this trigger domain as an inclusive entry. * Existing entries are modified as required to optimise the trigger domain @@ -116,6 +146,16 @@ class AliHLTTriggerDomain : public TObject */ void Add(const char* blocktype, const char* origin, UInt_t spec); + /** + * Removes entries from the trigger domain that correspond to the DDL readout list. + * All entries of the form "DAQRDOUT:xxxx:yyyy" are removed, where xxxx is the + * appropriate detector name given by AliDAQ::OnlineName() and yyyy is the DDL + * equipment ID number, as long as the corresponding bit is set in the readout + * list. + * \param list The readout list object + */ + void Remove(const AliHLTReadoutList& list); + /** * Removes or modifies all entries from the trigger domain, such that data blocks * that match the given domain entry will not form part of this trigger domain. @@ -354,6 +394,11 @@ class AliHLTTriggerDomain : public TObject return result.operator -= (domain); } + /** + * Typecase operator to create a DDL readout list object from the trigger domain. + */ + operator AliHLTReadoutList () const; + private: /** diff --git a/HLT/trigger/AliHLTTriggerLinkDef.h b/HLT/trigger/AliHLTTriggerLinkDef.h index b99d2f089b7..41eea0a2a5a 100644 --- a/HLT/trigger/AliHLTTriggerLinkDef.h +++ b/HLT/trigger/AliHLTTriggerLinkDef.h @@ -11,6 +11,7 @@ #pragma link C++ class AliHLTReadoutList+; #pragma link C++ class AliHLTGlobalTriggerDecision+; #pragma link C++ class AliHLTGlobalTrigger+; +#pragma link C++ class AliHLTGlobalTriggerConfig+; #pragma link C++ class AliHLTGlobalTriggerComponent+; #pragma link C++ class AliHLTTriggerAgent+; #pragma link C++ class AliHLTEventSummary+; @@ -21,4 +22,5 @@ #pragma link C++ class AliHLTTriggerMonitoringComponent+; #pragma link C++ class AliHLTTriggerMenu+; #pragma link C++ class AliHLTTriggerMenuItem+; +#pragma link C++ class AliHLTTriggerMenuSymbol+; #endif diff --git a/HLT/trigger/AliHLTTriggerMenu.cxx b/HLT/trigger/AliHLTTriggerMenu.cxx index 1584ffe2415..8c30b233b79 100644 --- a/HLT/trigger/AliHLTTriggerMenu.cxx +++ b/HLT/trigger/AliHLTTriggerMenu.cxx @@ -31,6 +31,7 @@ ClassImp(AliHLTTriggerMenu) AliHLTTriggerMenu::AliHLTTriggerMenu() : TObject(), fName("Unknown"), + fSymbols(AliHLTTriggerMenuSymbol::Class(), 100), fItems(AliHLTTriggerMenuItem::Class(), 100) { // Default constructor. @@ -46,10 +47,15 @@ AliHLTTriggerMenu::~AliHLTTriggerMenu() AliHLTTriggerMenu::AliHLTTriggerMenu(const AliHLTTriggerMenu& obj) : TObject(obj), fName(obj.fName), + fSymbols(AliHLTTriggerMenuSymbol::Class(), obj.fSymbols.GetEntriesFast()), fItems(AliHLTTriggerMenuItem::Class(), obj.fItems.GetEntriesFast()) { // Copy constructor performs a deep copy. + for (UInt_t i = 0; i < obj.NumberOfSymbols(); i++) + { + AddSymbol(*obj.Symbol(i)); + } for (UInt_t i = 0; i < obj.NumberOfItems(); i++) { AddItem(*obj.Item(i)); @@ -66,6 +72,10 @@ AliHLTTriggerMenu& AliHLTTriggerMenu::operator = (const AliHLTTriggerMenu& obj) TObject::operator = (obj); fName = obj.fName; fItems.Clear(); + for (UInt_t i = 0; i < obj.NumberOfSymbols(); i++) + { + AddSymbol(*obj.Symbol(i)); + } for (UInt_t i = 0; i < obj.NumberOfItems(); i++) { AddItem(*obj.Item(i)); @@ -88,14 +98,35 @@ void AliHLTTriggerMenu::Print(Option_t* option) const } cout << endl; cout << setw(10) << "Prescalar" << " | " - << setw(30) << "Trigger condision" << " | " - << setw(30) << "Domain merge expression" << setw(0) << endl; + << setw(60) << "Trigger condition" << " | " + << setw(60) << "Domain merge expression" << setw(0) << endl; cout << setfill('-') << setw(10) << "-" << "-+-" - << setw(30) << "-" << "-+-" - << setw(30) << "-" << setw(0) << endl; + << setw(60) << "-" << "-+-" + << setw(60) << "-" << setw(0) << setfill(' ') << endl; for (UInt_t i = 0; i < NumberOfItems(); i++) { Item(i)->Print("compact"); } + if (NumberOfItems() == 0) cout << "(none)" << endl; + cout << "Symbol list:" << endl; + cout << setw(15) << "Name" + << " | " << setw(20) << "Data type" + << " | " << setw(24) << "Block type & spec" + << " | " << setw(20) << "Class name" + << " | " << setw(25) << "Assigned value" + << " | " << setw(25) << "Default value" + << setw(0) << endl; + cout << setw(15) << setfill('-') << "-" + << "-+-" << setw(20) << "-" + << "-+-" << setw(24) << "-" + << "-+-" << setw(20) << "-" + << "-+-" << setw(25) << "-" + << "-+-" << setw(25) << "-" + << setw(0) << setfill(' ') << endl; + for (UInt_t i = 0; i < NumberOfSymbols(); i++) + { + Symbol(i)->Print("compact"); + } + if (NumberOfSymbols() == 0) cout << "(none)" << endl; } diff --git a/HLT/trigger/AliHLTTriggerMenu.h b/HLT/trigger/AliHLTTriggerMenu.h index 0ed714a4abc..f4652d8d305 100644 --- a/HLT/trigger/AliHLTTriggerMenu.h +++ b/HLT/trigger/AliHLTTriggerMenu.h @@ -12,6 +12,7 @@ #include "TObject.h" #include "TString.h" #include "TClonesArray.h" +#include "AliHLTTriggerMenuSymbol.h" #include "AliHLTTriggerMenuItem.h" /** @@ -69,6 +70,42 @@ class AliHLTTriggerMenu : public TObject */ void Name(const char* name) { fName = name; } + /** + * Returns the number of symbols in the trigger menu. + */ + UInt_t NumberOfSymbols() const { return UInt_t(fSymbols.GetEntriesFast()); } + + /** + * Fetches the i'th trigger menu symbol. + */ + const AliHLTTriggerMenuSymbol* Symbol(UInt_t i) const + { + if (i >= UInt_t(fSymbols.GetEntriesFast())) return NULL; + return static_cast( fSymbols.UncheckedAt(Int_t(i)) ); + } + + /** + * Fetches the i'th trigger menu symbol for editing. + */ + AliHLTTriggerMenuSymbol* Symbol(UInt_t i) + { + if (i >= UInt_t(fSymbols.GetEntriesFast())) return NULL; + return static_cast( fSymbols.UncheckedAt(Int_t(i)) ); + } + + /** + * Adds a new symbol to the trigger menu. + */ + void AddSymbol(const AliHLTTriggerMenuSymbol& entry) + { + new (fSymbols[fSymbols.GetEntriesFast()]) AliHLTTriggerMenuSymbol(entry); + } + + /** + * Returns the array of symbols. + */ + const TClonesArray& SymbolArray() const { return fSymbols; } + /** * Returns the number of items in the trigger menu. */ @@ -100,12 +137,18 @@ class AliHLTTriggerMenu : public TObject new (fItems[fItems.GetEntriesFast()]) AliHLTTriggerMenuItem(entry); } + /** + * Returns the array of menu items. + */ + const TClonesArray& ItemsArray() const { return fItems; } + private: TString fName; /// Name of the trigger menu. + TClonesArray fSymbols; /// List of symbols used in trigger expressions. TClonesArray fItems; /// List of trigger menu items. - ClassDef(AliHLTTriggerMenu, 1) // Trigger menu for the global HLT trigger. + ClassDef(AliHLTTriggerMenu, 2) // Trigger menu for the global HLT trigger. }; #endif // ALIHLTTRIGGERMENU_H diff --git a/HLT/trigger/AliHLTTriggerMenuItem.cxx b/HLT/trigger/AliHLTTriggerMenuItem.cxx index 77652e68437..240e551d073 100644 --- a/HLT/trigger/AliHLTTriggerMenuItem.cxx +++ b/HLT/trigger/AliHLTTriggerMenuItem.cxx @@ -30,6 +30,7 @@ ClassImp(AliHLTTriggerMenuItem) AliHLTTriggerMenuItem::AliHLTTriggerMenuItem() : TObject(), + fDescription(), fConditionExpr(), fDomainExpr(), fPrescalar(0) @@ -51,15 +52,16 @@ void AliHLTTriggerMenuItem::Print(Option_t* option) const TString opt = option; if (opt.Contains("compact")) { - cout << " Trigger condision expression = " << fConditionExpr.Data(); - cout << "Trigger domain merge expression = " << fDomainExpr.Data(); - cout << " Pre-scalar = " << fPrescalar; + cout << setw(10) << fPrescalar << " | " + << setw(60) << fConditionExpr.Data() << " | " + << setw(60) << fDomainExpr.Data() << setw(0) << endl; } else { - cout << setw(10) << fPrescalar << " | " - << setw(30) << fConditionExpr.Data() << " | " - << setw(30) << fDomainExpr.Data() << setw(0) << endl; + cout << " Description = " << fDescription.Data() << endl; + cout << " Trigger condition expression = " << fConditionExpr.Data() << endl; + cout << "Trigger domain merge expression = " << fDomainExpr.Data() << endl; + cout << " Pre-scalar = " << fPrescalar << endl; } } diff --git a/HLT/trigger/AliHLTTriggerMenuItem.h b/HLT/trigger/AliHLTTriggerMenuItem.h index fabaef5b017..726b82a3dc7 100644 --- a/HLT/trigger/AliHLTTriggerMenuItem.h +++ b/HLT/trigger/AliHLTTriggerMenuItem.h @@ -37,6 +37,16 @@ class AliHLTTriggerMenuItem : public TObject */ virtual void Print(Option_t* option = "") const; + /** + * Returns the optional comment string. + */ + const char* Description() const { return fDescription.Data(); } + + /** + * Set the optional comment string. + */ + void Description(const char* value) { fDescription = value; } + /** * Returns the trigger condition expression. */ @@ -69,11 +79,12 @@ class AliHLTTriggerMenuItem : public TObject private: + TString fDescription; /// Optional description or comment string. TString fConditionExpr; /// The trigger condition expression. TString fDomainExpr; /// Trigger domain merging expression. UInt_t fPrescalar; /// Pre-scalar value used to optionally reduce the trigger rate. Every modulus n'th event is triggered, where n equals the pre-scalar value. - ClassDef(AliHLTTriggerMenuItem, 1) // Trigger menu item for global HLT trigger. + ClassDef(AliHLTTriggerMenuItem, 2) // Trigger menu item for global HLT trigger. }; #endif // ALIHLTTRIGGERMENUITEM_H diff --git a/HLT/trigger/AliHLTTriggerMenuSymbol.cxx b/HLT/trigger/AliHLTTriggerMenuSymbol.cxx new file mode 100644 index 00000000000..5ee78da07ca --- /dev/null +++ b/HLT/trigger/AliHLTTriggerMenuSymbol.cxx @@ -0,0 +1,75 @@ +/************************************************************************** + * This file is property of and copyright by the ALICE HLT Project * + * ALICE Experiment at CERN, All rights reserved. * + * * + * Primary Authors: Artur Szostak * + * for The ALICE HLT Project. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/// @file AliHLTTriggerMenuSymbol.cxx +/// @author Artur Szostak +/// @date 28 Dec 2008 +/// @brief Implementation of the AliHLTTriggerMenuSymbol class. +/// +/// The AliHLTTriggerMenuSymbol contains information about a symbol used in the +/// global HLT trigger menu. + +#include "AliHLTTriggerMenuSymbol.h" +#include "Riostream.h" + +ClassImp(AliHLTTriggerMenuSymbol) + + +AliHLTTriggerMenuSymbol::AliHLTTriggerMenuSymbol() : + TObject(), + fName(), + fType(), + fBlockType(kAliHLTAnyDataType), + fClass(), + fAssignExpr(), + fDefaultValue() +{ + // Default constructor. +} + + +AliHLTTriggerMenuSymbol::~AliHLTTriggerMenuSymbol() +{ + // Default destructor. +} + + +void AliHLTTriggerMenuSymbol::Print(Option_t* option) const +{ + // Prints the contents of the trigger menu item. + + TString opt = option; + if (opt.Contains("compact")) + { + cout << setw(15) << fName << " | " + << setw(20) << fType << " | "; + fBlockType.Print("noendl"); + cout << " | " << setw(20) << fClass.Data() + << " | " << setw(25) << fAssignExpr.Data() + << " | " << setw(25) << fDefaultValue.Data() + << setw(0) << endl; + } + else + { + cout << " Name = " << fName.Data() << endl; + cout << " Data type = " << fType.Data() << endl; + cout << " Block type = "; fBlockType.Print(); + cout << " Class type = " << fClass.Data() << endl; + cout << " Assignment expression = " << fAssignExpr.Data() << endl; + cout << "Default value expression = " << fDefaultValue.Data() << endl; + } +} + diff --git a/HLT/trigger/AliHLTTriggerMenuSymbol.h b/HLT/trigger/AliHLTTriggerMenuSymbol.h new file mode 100644 index 00000000000..99d2a664aa8 --- /dev/null +++ b/HLT/trigger/AliHLTTriggerMenuSymbol.h @@ -0,0 +1,157 @@ +#ifndef ALIHLTTRIGGERMENUSYMBOL_H +#define ALIHLTTRIGGERMENUSYMBOL_H +/* This file is property of and copyright by the ALICE HLT Project * + * ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/// @file AliHLTTriggerMenuSymbol.h +/// @author Artur Szostak +/// @date 28 Dec 2008 +/// @brief Declaration of the AliHLTTriggerMenuSymbol class. + +#include "TObject.h" +#include "TString.h" +#include "AliHLTDataTypes.h" +#include "AliHLTDomainEntry.h" + +/** + * \class AliHLTTriggerMenuSymbol + * TODO + */ +class AliHLTTriggerMenuSymbol : public TObject +{ + public: + + /** + * Default constructor. + */ + AliHLTTriggerMenuSymbol(); + + /** + * Default destructor. + */ + virtual ~AliHLTTriggerMenuSymbol(); + + /** + * Inherited from TObject, this prints the contents of the symbol. + * \param option Can be "compact", which will print in the compact format. + */ + virtual void Print(Option_t* option = "") const; + + /** + * Returns the symbol name. + */ + const char* Name() const { return fName.Data(); } + + /** + * Set the symbol name. + */ + void Name(const char* value) { fName = value; } + + /** + * Returns the symbol data type. + */ + const char* Type() const { return fType.Data(); } + + /** + * Set the symbol data type. + */ + void Type(const char* value) { fType = value; } + + /** + * Returns the data block type and specification from which the symbol is fetched. + */ + const AliHLTDomainEntry& BlockType() const { return fBlockType; } + + /** + * Set the data block type and specification from which the symbol is fetched. + * \param type The data block type and origin to use. + */ + void BlockType(const AliHLTComponentDataType& type) + { + fBlockType = AliHLTDomainEntry(type); + } + + /** + * Set the data block type and specification from which the symbol is fetched. + * \param blocktype The data block type string of the data block. The value + * kAliHLTAnyDataTypeID can be used to specify the any type wild card value. + * \param origin The origin of the data block, such as the detector name. + * The value kAliHLTDataOriginAny can be used to specify the any origin + * wild card value. + */ + void BlockType(const char* blocktype, const char* origin) + { + fBlockType = AliHLTDomainEntry(blocktype, origin); + } + + /** + * Set the data block type and specification from which the symbol is fetched. + * \param type The data block type and origin to use. + * \param spec The data block specification to use. + */ + void BlockType(const AliHLTComponentDataType& type, UInt_t spec) + { + fBlockType = AliHLTDomainEntry(type, spec); + } + + /** + * Set the data block type and specification from which the symbol is fetched. + * \param blocktype The data block type string of the data block. The value + * kAliHLTAnyDataTypeID can be used to specify the any type wild card value. + * \param origin The origin of the data block, such as the detector name. + * The value kAliHLTDataOriginAny can be used to specify the any origin + * wild card value. + * \param spec The data block specification to use. + */ + void BlockType(const char* blocktype, const char* origin, UInt_t spec) + { + fBlockType = AliHLTDomainEntry(blocktype, origin, spec); + } + + /** + * Returns the class name of the object in the data block. + */ + const char* ObjectClass() const { return fClass.Data(); } + + /** + * Set the class name of the object in the data block. + */ + void ObjectClass(const char* value) { fClass = value; } + + /** + * Returns the expression to assign the symbol value. + */ + const char* AssignExpression() const { return fAssignExpr.Data(); } + + /** + * Set the expression to assign the symbol value. + * The keyword 'this' is used as the place holder of the object in the matched + * data block. + */ + void AssignExpression(const char* value) { fAssignExpr = value; } + + /** + * Returns the default value expression. + */ + const char* DefaultValue() const { return fDefaultValue.Data(); } + + /** + * Set the default value expression. + */ + void DefaultValue(const char* value) { fDefaultValue = value; } + + private: + + TString fName; /// The name of the symbol (Must be a valid C++ variable name). + TString fType; /// The data type of the symbol (Must be a valid C++ type name). + AliHLTDomainEntry fBlockType; /// The data block type and specification this symbol is fetched from. + TString fClass; /// The class name of the object to read from (Must be a valid C++ class name). + TString fAssignExpr; /// The expression to assign to the symbol (Must be a valid C++ expression). + TString fDefaultValue; /// The default value this symbol is set to (this must be a valid C++ expression). + + ClassDef(AliHLTTriggerMenuSymbol, 2) // Trigger menu item for global HLT trigger. +}; + +#endif // ALIHLTTRIGGERMENUSYMBOL_H + diff --git a/HLT/trigger/test/TriggerConfig.C b/HLT/trigger/test/TriggerConfig.C new file mode 100644 index 00000000000..5f1ac6992c0 --- /dev/null +++ b/HLT/trigger/test/TriggerConfig.C @@ -0,0 +1,11 @@ + +void TriggerConfig() +{ + AliHLTGlobalTriggerConfig config("test Config"); + config.AddSymbol("domainAll", "AliHLTTriggerDomain", "", "AliHLTTriggerDomain(\"*******:***,-DAQRDOUT:TST\")"); + config.AddItem("true", "domainAll", 5, "Trigger Type: pass through"); + config.AddItem("Trigger1", "Trigger1 | Trigger2", 3, "Trigger Type: 1"); + config.AddItem("Trigger2", "Trigger2", 0, "Trigger Type: 2"); + config.Menu()->Print(); +} + diff --git a/HLT/trigger/test/testGlobalTriggerComponent.C b/HLT/trigger/test/testGlobalTriggerComponent.C index 3295eca0136..be2ed85a611 100644 --- a/HLT/trigger/test/testGlobalTriggerComponent.C +++ b/HLT/trigger/test/testGlobalTriggerComponent.C @@ -22,7 +22,7 @@ * This macro is used to test the AliHLTGlobalTriggerComponent class. */ -void testGlobalTriggerComponent() +void testGlobalTriggerComponent(bool debug = false) { gSystem->Load("libAliHLTTrigger.so"); @@ -30,12 +30,15 @@ void testGlobalTriggerComponent() AliHLTReadoutList readoutList1("TPC"); AliHLTTriggerDomain triggerDomain1; - AliHLTTriggerDecision decision1(true, "Trigger1", readoutList1, triggerDomain1); + triggerDomain1.Add("CLUSTERS", "TPC "); + triggerDomain1.Add(readoutList1); + AliHLTTriggerDecision decision1(true, "Trigger1", triggerDomain1, "Example trigger 1"); - AliHLTReadoutList readoutList2; + AliHLTReadoutList readoutList2("MUONTRK"); AliHLTTriggerDomain triggerDomain2; - triggerDomain2.Add("aaaa", "bbbb"); - AliHLTTriggerDecision decision2(true, "Trigger2", readoutList2, triggerDomain2); + triggerDomain2.Add("aaaaaaaa", "bbbb"); + triggerDomain2.Add(readoutList2); + AliHLTTriggerDecision decision2(true, "Trigger2", triggerDomain2, "Another example trigger 2"); decision1.Write("Trigger1"); decision2.Write("Trigger2"); @@ -44,12 +47,19 @@ void testGlobalTriggerComponent() AliHLTSystem sys; sys.LoadComponentLibraries("libAliHLTUtil.so"); sys.LoadComponentLibraries("libAliHLTTrigger.so"); + if (debug) + { + AliLog::SetGlobalLogLevel(AliLog::kMaxType); + sys.SetGlobalLoggingLevel(0x7F); + } AliHLTConfiguration pub("pub", "ROOTFilePublisher", NULL, " -datatype ROOTTOBJ 'HLT ' -datafile testInputFile.root"); - AliHLTConfiguration proc("proc", "HLTGlobalTrigger", "pub", ""); - AliHLTConfiguration sink("sink", "ROOTFileWriter", "proc", "-datafile testOutput.root"); + TString cmdline = "-config TriggerConfig.C -include AliHLTRunSummary.h"; + if (debug) cmdline += " -debug"; + AliHLTConfiguration proc("proc", "HLTGlobalTrigger", "pub", cmdline.Data()); + AliHLTConfiguration sink("sink", "ROOTFileWriter", "proc", "-datafile testOutput.root -concatenate-events"); sys.BuildTaskList("sink"); - sys.Run(1); + sys.Run(10); } -- 2.43.5