+ UInt_t i = priorityGroup[n][m];
+ const AliHLTTriggerMenuItem* item = menu->Item(i);
+ TString triggerCondition = item->TriggerCondition();
+ TString mergeExpr = item->MergeExpression();
+ // Replace the symbols found in the trigger condition and merging expressions
+ // with appropriate compilable versions.
+ for (Int_t j = 0; j < symbols.GetEntriesFast(); j++)
+ {
+ AliHLTTriggerMenuSymbol* symbol = static_cast<AliHLTTriggerMenuSymbol*>( symbols.UncheckedAt(j) );
+ bool symbolNamesDifferent = strcmp(symbol->RealName(), symbol->Name()) != 0;
+ if (strcmp(symbol->ObjectClass(), "AliHLTTriggerDecision") == 0)
+ {
+ TString newname = symbol->Name();
+ newname += "TriggerDomain";
+ mergeExpr.ReplaceAll(symbol->RealName(), newname);
+ }
+ else
+ {
+ if (symbolNamesDifferent) mergeExpr.ReplaceAll(symbol->RealName(), symbol->Name());
+ }
+ if (symbolNamesDifferent) triggerCondition.ReplaceAll(symbol->RealName(), symbol->Name());
+ }
+ // We allow the trigger conditions and merging expressions to have trailing operators.
+ // Thus, we need to extract the operators and cleanup the expressions so that they will
+ // compile. This means that we silently ignore the trailing operator if not needed.
+ if (ExtractedOperator(triggerCondition, conditionOperator[m]))
+ {
+ // If the trailing operator is the same as the default operator then reset
+ // the value in the operator list so that the default is used in the generated
+ // code. This creates more compact code.
+ if (conditionOperator[m] == menu->DefaultConditionOperator()) conditionOperator[m] = "";
+ }
+ if (ExtractedOperator(mergeExpr, domainOperator[m]))
+ {
+ if (domainOperator[m] == menu->DefaultDomainOperator()) domainOperator[m] = "";
+ }
+ if (fDebugMode)
+ {
+ code << " HLTDebug(Form(\"Trying trigger condition " << i
+ << " (Description = '%s').\", fMenuItemDescription" << i << ".Data()));"
+ << endl;
+ }
+ code << " ";
+ if (n == 0 and m == 0) code << "bool ";
+ code << "_item_result_ = false;" << endl;
+ code << " if (" << triggerCondition << ") {" << endl;
+ code << " ++fCounter[" << i << "];" << endl;
+ const char* indentation = "";
+ if (item->PreScalar() != 0)
+ {
+ indentation = " ";
+ code << " if ((fCounter[" << i << "] % " << item->PreScalar() << ") == 1) {" << endl;
+ }
+ code << indentation << " _item_result_ = true;" << endl;
+ if (fDebugMode)
+ {
+ code << indentation << " HLTDebug(Form(\"Matched trigger condition " << i
+ << " (Description = '%s').\", fMenuItemDescription" << i << ".Data()));" << endl;
+ }
+ if (item->PreScalar() != 0)
+ {
+ code << " }" << endl;
+ }
+ code << " }" << endl;
+ if (m == 0)
+ {
+ // Since this is the first item of the trigger group,
+ // the generated trigger logic can be simplified a little.
+ code << " _group_result_ = _item_result_;" << endl;
+ code << " if (_item_result_) {" << endl;
+ code << " _domain_ = " << mergeExpr.Data() << ";" << endl;
+ code << " _description_ = fMenuItemDescription" << i << ";" << endl;
+ code << " _previous_match_ = " << i << ";" << endl;
+ code << " _trigger_matched_ = true;" << endl;
+ code << " }" << endl;
+ }
+ else
+ {
+ if (conditionOperator[m-1] == "")
+ {
+ code << " _group_result_ = _group_result_ "
+ << menu->DefaultConditionOperator() << " _item_result_;" << endl;
+ }
+ else
+ {
+ code << " _group_result_ = _group_result_ "
+ << conditionOperator[m-1] << " _item_result_;" << endl;
+ }
+ code << " if (_item_result_) {" << endl;
+ code << " if (_trigger_matched_) {" << endl;
+ bool switchWillBeEmpty = true;
+ for (size_t k = 0; k < m; k++)
+ {
+ if (domainOperator[k] == "") continue;
+ switchWillBeEmpty = false;
+ }
+ if (switchWillBeEmpty)
+ {
+ code << " _domain_ = _domain_ " << menu->DefaultDomainOperator() << " "
+ << mergeExpr.Data() << ";" << endl;
+ }
+ else
+ {
+ code << " switch(_previous_match_) {" << endl;
+ for (size_t k = 0; k < m; k++)
+ {
+ if (domainOperator[k] == "") continue;
+ code << " case " << k << ": _domain_ = _domain_ "
+ << domainOperator[k] << " " << mergeExpr.Data() << "; break;" << endl;
+ }
+ code << " default: _domain_ = _domain_ "
+ << menu->DefaultDomainOperator() << " " << mergeExpr.Data() << ";" << endl;
+ code << " }" << endl;
+ }
+ code << " _description_ += \",\";" << endl;
+ code << " _description_ += fMenuItemDescription" << i << ";" << endl;
+ code << " } else {" << endl;
+ code << " _domain_ = " << mergeExpr.Data() << ";" << endl;
+ code << " _description_ = fMenuItemDescription" << i << ";" << endl;
+ code << " }" << endl;
+ code << " _previous_match_ = " << i << ";" << endl;
+ code << " _trigger_matched_ = true;" << endl;
+ code << " }" << endl;
+ }