LCOV - code coverage report
Current view: top level - HLT/BASE - AliHLTTriggerMenu.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 11 146 7.5 %
Date: 2016-06-14 17:26:59 Functions: 3 12 25.0 %

          Line data    Source code
       1             : // $Id$
       2             : /**************************************************************************
       3             :  * This file is property of and copyright by the ALICE HLT Project        *
       4             :  * ALICE Experiment at CERN, All rights reserved.                         *
       5             :  *                                                                        *
       6             :  * Primary Authors: Artur Szostak <artursz@iafrica.com>                   *
       7             :  *                  for The ALICE HLT Project.                            *
       8             :  *                                                                        *
       9             :  * Permission to use, copy, modify and distribute this software and its   *
      10             :  * documentation strictly for non-commercial purposes is hereby granted   *
      11             :  * without fee, provided that the above copyright notice appears in all   *
      12             :  * copies and that both the copyright notice and this permission notice   *
      13             :  * appear in the supporting documentation. The authors make no claims     *
      14             :  * about the suitability of this software for any purpose. It is          *
      15             :  * provided "as is" without express or implied warranty.                  *
      16             :  **************************************************************************/
      17             : 
      18             : /// @file   AliHLTTriggerMenu.cxx
      19             : /// @author Artur Szostak <artursz@iafrica.com>
      20             : /// @date   19 Dec 2008
      21             : /// @brief  Implementation of the AliHLTTriggerMenu base class.
      22             : ///
      23             : /// The AliHLTTriggerMenu class implements the HLT global trigger menu,
      24             : /// which defines how and on what events the HLT triggers.
      25             : 
      26             : #include "AliHLTTriggerMenu.h"
      27             : #include "Riostream.h"
      28             : #include <sstream>
      29             : 
      30         126 : ClassImp(AliHLTTriggerMenu)
      31             : 
      32             : 
      33             : AliHLTTriggerMenu::AliHLTTriggerMenu() :
      34           2 :   TObject(),
      35           2 :   fName("Unknown"),
      36           4 :   fSymbols(AliHLTTriggerMenuSymbol::Class(), 100),
      37           4 :   fItems(AliHLTTriggerMenuItem::Class(), 100),
      38           2 :   fDefaultDescription(),
      39           2 :   fDefaultDomain(),
      40           2 :   fDefaultConditionOperator("||"),
      41           2 :   fDefaultDomainOperator("|")
      42          10 : {
      43             :   // Default constructor.
      44           4 : }
      45             : 
      46             : 
      47             : AliHLTTriggerMenu::~AliHLTTriggerMenu()
      48           0 : {
      49             :   // Default destructor.
      50           0 : }
      51             : 
      52             : 
      53             : AliHLTTriggerMenu::AliHLTTriggerMenu(const AliHLTTriggerMenu& obj) :
      54           0 :   TObject(obj),
      55           0 :   fName(obj.fName),
      56           0 :   fSymbols(AliHLTTriggerMenuSymbol::Class(), obj.fSymbols.GetEntriesFast()),
      57           0 :   fItems(AliHLTTriggerMenuItem::Class(), obj.fItems.GetEntriesFast()),
      58           0 :   fDefaultDescription(obj.fDefaultDescription),
      59           0 :   fDefaultDomain(obj.fDefaultDomain),
      60           0 :   fDefaultConditionOperator(obj.fDefaultConditionOperator),
      61           0 :   fDefaultDomainOperator(obj.fDefaultDomainOperator)
      62           0 : {
      63             :   // Copy constructor performs a deep copy.
      64             :   
      65           0 :   for (UInt_t i = 0; i < obj.NumberOfSymbols(); i++)
      66             :   {
      67           0 :     AddSymbol(*obj.Symbol(i));
      68             :   }
      69           0 :   for (UInt_t i = 0; i < obj.NumberOfItems(); i++)
      70             :   {
      71           0 :     AddItem(*obj.Item(i));
      72             :   }
      73           0 : }
      74             : 
      75             : 
      76             : AliHLTTriggerMenu& AliHLTTriggerMenu::operator = (const AliHLTTriggerMenu& obj)
      77             : {
      78             :   // Assignment operator performs a deep copy.
      79             :   
      80           0 :   if (this != &obj)
      81             :   {
      82           0 :     TObject::operator = (obj);
      83           0 :     fName = obj.fName;
      84           0 :     fSymbols.Clear();
      85           0 :     for (UInt_t i = 0; i < obj.NumberOfSymbols(); i++)
      86             :     {
      87           0 :       AddSymbol(*obj.Symbol(i));
      88             :     }
      89           0 :     fItems.Clear();
      90           0 :     for (UInt_t i = 0; i < obj.NumberOfItems(); i++)
      91             :     {
      92           0 :       AddItem(*obj.Item(i));
      93             :     }
      94           0 :     fDefaultDescription = obj.fDefaultDescription;
      95           0 :     fDefaultDomain = obj.fDefaultDomain;
      96           0 :     fDefaultConditionOperator = obj.fDefaultConditionOperator;
      97           0 :     fDefaultDomainOperator = obj.fDefaultDomainOperator;
      98           0 :   }
      99           0 :   return *this;
     100             : }
     101             : 
     102             : 
     103             : void AliHLTTriggerMenu::Print(Option_t* option) const
     104             : {
     105             :   // Prints the contents of the trigger menu.
     106             :   
     107           0 :   cout << "HLT Trigger Menu: " << fName.Data();
     108           0 :   TString opt = option;
     109           0 :   if (opt.Contains("short"))
     110             :   {
     111           0 :     cout << ", contains " << NumberOfItems() << " entries." << endl;
     112           0 :     return;
     113             :   }
     114           0 :   cout << endl;
     115             :   
     116             :   size_t prescalarColWidth = 9;
     117             :   size_t scaledownColWidth = 9;
     118             :   size_t priorityColWidth = 8;
     119             :   size_t resultColWidth = 6;
     120             :   size_t conditionColWidth = 17;
     121             :   size_t mergexprColWidth = 23;
     122             :   size_t descColWidth = 11;
     123             :   // Find out the required widths of the columns:
     124           0 :   for (UInt_t i = 0; i < NumberOfItems(); i++)
     125             :   {
     126           0 :     std::stringstream buf;
     127           0 :     buf.copyfmt(cout);
     128           0 :     buf << Item(i)->PreScalar();
     129           0 :     if (buf.str().length() > prescalarColWidth) prescalarColWidth = buf.str().length();
     130           0 :     buf.str("");
     131           0 :     buf << Item(i)->ScaleDown();
     132           0 :     if (buf.str().length()+1 > scaledownColWidth) scaledownColWidth = buf.str().length()+1;
     133           0 :     buf.str("");
     134           0 :     buf << Item(i)->Priority();
     135           0 :     if (buf.str().length() > priorityColWidth) priorityColWidth = buf.str().length();
     136           0 :     size_t len = strlen(Item(i)->TriggerCondition());
     137           0 :     if (len > conditionColWidth and len < 128) conditionColWidth = len;
     138           0 :     len = strlen(Item(i)->MergeExpression());
     139           0 :     if (len > mergexprColWidth and len < 128) mergexprColWidth = len;
     140           0 :     len = strlen(Item(i)->Description());
     141           0 :     if (len > descColWidth and len < 128) descColWidth = len;
     142           0 :   }
     143           0 :   cout << setw(prescalarColWidth) << "Prescalar" << " | "
     144           0 :        << setw(scaledownColWidth) << "Scaledown" << " | "
     145           0 :        << setw(priorityColWidth) << "Priority" << " | "
     146           0 :        << setw(resultColWidth) << "Result" << " | "
     147           0 :        << setw(conditionColWidth) << "Trigger condition" << " | "
     148           0 :        << setw(mergexprColWidth) << "Domain merge expression" << " | "
     149           0 :        << setw(descColWidth) << "Description" << setw(0) << endl;
     150           0 :   cout << setfill('-') << setw(prescalarColWidth) << "-" << "-+-"
     151           0 :        << setw(scaledownColWidth) << "-" << "-+-"
     152           0 :        << setw(priorityColWidth) << "-" << "-+-"
     153           0 :        << setw(resultColWidth) << "-" << "-+-"
     154           0 :        << setw(conditionColWidth) << "-" << "-+-"
     155           0 :        << setw(mergexprColWidth) << "-" << "-+-"
     156           0 :        << setw(descColWidth) << "-" << setw(0) << setfill(' ') << endl;
     157           0 :   for (UInt_t i = 0; i < NumberOfItems(); i++)
     158             :   {
     159           0 :     if (Item(i)->PreScalar() == 0)
     160           0 :       cout << setw(prescalarColWidth) << "off" << " | ";
     161             :     else
     162           0 :       cout << setw(prescalarColWidth) << Item(i)->PreScalar() << " | ";
     163           0 :     if (Item(i)->ScaleDown() == 1)
     164           0 :       cout << setw(scaledownColWidth) << "none" << " | ";
     165             :     else
     166           0 :       cout << setw(scaledownColWidth-1) << Item(i)->ScaleDown()*100 << "% | ";
     167           0 :     cout << setw(priorityColWidth) << Item(i)->Priority() << " | "
     168           0 :          << setw(resultColWidth) << (Item(i)->DefaultResult() ? "true" : "false") << " | "
     169           0 :          << setw(conditionColWidth) << Item(i)->TriggerCondition() << " | "
     170           0 :          << setw(mergexprColWidth) << Item(i)->MergeExpression() << " | "
     171           0 :          << setw(descColWidth) << Item(i)->Description() << setw(0) << endl;
     172             :   }
     173           0 :   if (NumberOfItems() == 0) cout << "(none)" << endl;
     174             :   
     175           0 :   cout << "Symbol list:" << endl;
     176             :   size_t nameColWidth = 4;
     177             :   size_t typeColWidth = 9;
     178             :   size_t classColWidth = 10;
     179             :   size_t assignColWidth = 14;
     180             :   size_t valueColWidth = 13;
     181             :   // Find out the required widths of the columns:
     182           0 :   for (UInt_t i = 0; i < NumberOfSymbols(); i++)
     183             :   {
     184           0 :     size_t len = strlen(Symbol(i)->RealName());
     185           0 :     if (len > nameColWidth and len < 128) nameColWidth = len;
     186           0 :     len = strlen(Symbol(i)->Type());
     187           0 :     if (len > typeColWidth and len < 128) typeColWidth = len;
     188           0 :     len = strlen(Symbol(i)->ObjectClass());
     189           0 :     if (len > classColWidth and len < 128) classColWidth = len;
     190           0 :     len = strlen(Symbol(i)->AssignExpression());
     191           0 :     if (len > assignColWidth and len < 128) assignColWidth = len;
     192           0 :     len = strlen(Symbol(i)->DefaultValue());
     193           0 :     if (len > valueColWidth and len < 128) valueColWidth = len;
     194             :   }
     195           0 :   cout << setw(nameColWidth) << "Name"
     196           0 :        << " | " << setw(typeColWidth) << "Data type"
     197           0 :        << " | " << setw(24) << "Block type & spec"
     198           0 :        << " | " << setw(classColWidth) << "Class name"
     199           0 :        << " | " << setw(assignColWidth) << "Assigned value"
     200           0 :        << " | " << setw(valueColWidth) << "Default value"
     201           0 :        << setw(0) << endl;
     202           0 :   cout << setw(nameColWidth) << setfill('-') << "-"
     203           0 :        << "-+-" << setw(typeColWidth) << "-"
     204           0 :        << "-+-" << setw(24) << "-"
     205           0 :        << "-+-" << setw(classColWidth) << "-"
     206           0 :        << "-+-" << setw(assignColWidth) << "-"
     207           0 :        << "-+-" << setw(valueColWidth) << "-"
     208           0 :        << setw(0) << setfill(' ') << endl;
     209           0 :   for (UInt_t i = 0; i < NumberOfSymbols(); i++)
     210             :   {
     211           0 :     cout << setw(nameColWidth) << Symbol(i)->RealName() << " | "
     212           0 :          << setw(typeColWidth) << Symbol(i)->Type() << " | ";
     213           0 :     Symbol(i)->BlockType().Print("noendl");
     214           0 :     cout << " | " << setw(classColWidth) << Symbol(i)->ObjectClass()
     215           0 :          << " | " << setw(assignColWidth) << Symbol(i)->AssignExpression()
     216           0 :          << " | " << setw(valueColWidth) << Symbol(i)->DefaultValue()
     217           0 :          << setw(0) << endl;
     218             :   }
     219           0 :   if (NumberOfSymbols() == 0) cout << "(none)" << endl;
     220             :   
     221           0 :   cout << "Default trigger condition operator: " << fDefaultConditionOperator << endl;
     222           0 :   cout << "   Default trigger domain operator: " << fDefaultDomainOperator << endl;
     223           0 :   cout << "       Default trigger description: \"" << fDefaultDescription << "\"" << endl;
     224           0 :   cout << "     Default global trigger result: " << (DefaultResult() ? "true" : "false") << "" << endl;
     225           0 :   cout << "Default "; fDefaultDomain.Print();
     226           0 : }
     227             : 
     228             : 
     229             : void AliHLTTriggerMenu::Clear(Option_t* option)
     230             : {
     231             :   // Clears the internal symbol and items arrays.
     232             :   
     233           0 :   fSymbols.Clear(option);
     234           0 :   fItems.Clear(option);
     235           0 : }
     236             : 
     237             : 
     238             : void AliHLTTriggerMenu::AddSymbol(const AliHLTTriggerMenuSymbol& entry)
     239             : {
     240             :   // Adds a new symbol to the trigger menu.
     241             :   
     242           0 :   for (Int_t i = 0; i < fSymbols.GetEntriesFast(); i++)
     243             :   {
     244           0 :     const char* symbolname = static_cast<AliHLTTriggerMenuSymbol*>(fSymbols.UncheckedAt(i))->Name();
     245           0 :     if ( strcmp(symbolname, entry.Name()) == 0 )
     246             :     {
     247           0 :       Warning("AliHLTTriggerMenu::AddSymbol",
     248             :               "The symbol '%s' already exists in the trigger menu. Will not add the new entry.",
     249           0 :               entry.RealName()
     250             :              );
     251           0 :       return;
     252             :     }
     253           0 :   }
     254           0 :   new (fSymbols[fSymbols.GetEntriesFast()]) AliHLTTriggerMenuSymbol(entry);
     255           0 : }
     256             : 

Generated by: LCOV version 1.11