LCOV - code coverage report
Current view: top level - HLT/BASE - AliHLTCTPData.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 318 0.3 %
Date: 2016-06-14 17:26:59 Functions: 1 42 2.4 %

          Line data    Source code
       1             : // $Id$
       2             : 
       3             : //**************************************************************************
       4             : //* This file is property of and copyright by the ALICE HLT Project        * 
       5             : //* ALICE Experiment at CERN, All rights reserved.                         *
       6             : //*                                                                        *
       7             : //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
       8             : //*                  for The ALICE HLT Project.                            *
       9             : //*                                                                        *
      10             : //* Permission to use, copy, modify and distribute this software and its   *
      11             : //* documentation strictly for non-commercial purposes is hereby granted   *
      12             : //* without fee, provided that the above copyright notice appears in all   *
      13             : //* copies and that both the copyright notice and this permission notice   *
      14             : //* appear in the supporting documentation. The authors make no claims     *
      15             : //* about the suitability of this software for any purpose. It is          *
      16             : //* provided "as is" without express or implied warranty.                  *
      17             : //**************************************************************************
      18             : 
      19             : //  @file   AliHLTCTPData.cxx
      20             : //  @author Matthias Richter
      21             : //  @date   2009-08-20
      22             : //  @brief  Container for CTP trigger classes and counters
      23             : //  @note
      24             : 
      25             : #include "AliHLTCTPData.h"
      26             : #include "TClass.h"
      27             : #include "TObjString.h"
      28             : #include "TFormula.h"
      29             : #include "AliHLTComponent.h"
      30             : #include "AliHLTCDHWrapper.h"
      31             : #include "TPRegexp.h"
      32             : #include <limits>
      33             : #include <sstream>
      34             : #include <RVersion.h>
      35             : 
      36             : /** ROOT macro for the implementation of ROOT specific class methods */
      37         126 : ClassImp(AliHLTCTPData)
      38             : 
      39             : AliHLTCTPData::AliHLTCTPData()
      40           0 :   : TNamed("AliHLTCTPData", "HLT counters for the CTP")
      41           0 :   , AliHLTLogging()
      42           0 :   , fMask(0)
      43           0 :   , fTriggers(0)
      44           0 :   , fClassIds(AliHLTReadoutList::Class(), gkNCTPTriggerClasses)
      45           0 :   , fCounters(gkNCTPTriggerClasses)
      46           0 :   , fMap()
      47           0 : {
      48             :   // constructor
      49             :   // see header file for class documentation
      50             :   // or
      51             :   // refer to README to build package
      52             :   // or
      53             :   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
      54           0 : }
      55             : 
      56             : AliHLTCTPData::AliHLTCTPData(const char* parameter)
      57           0 :   : TNamed("AliHLTCTPData", "HLT counters for the CTP")
      58           0 :   , AliHLTLogging()
      59           0 :   , fMask(0)
      60           0 :   , fTriggers(0)
      61           0 :   , fClassIds(AliHLTReadoutList::Class(), gkNCTPTriggerClasses)
      62           0 :   , fCounters(gkNCTPTriggerClasses)
      63           0 :   , fMap()
      64           0 : {
      65             :   // constructor, init the CTP trigger classes
      66           0 :   InitCTPTriggerClasses(parameter);
      67           0 : }
      68             : 
      69           0 : AliHLTCTPData::~AliHLTCTPData()
      70           0 : {
      71             :   // destructor
      72           0 :   fClassIds.Delete();
      73           0 : }
      74             : 
      75             : AliHLTCTPData::AliHLTCTPData(const AliHLTCTPData& src)
      76           0 :   : TNamed(src.GetName(), src.GetTitle())
      77           0 :   , AliHLTLogging()
      78           0 :   , fMask(src.Mask())
      79           0 :   , fTriggers(src.fTriggers)
      80           0 :   , fClassIds(src.fClassIds)
      81           0 :   , fCounters(src.Counters())
      82           0 :   , fMap()
      83           0 : {
      84             :   // copy constructor
      85           0 :   ReadMap();
      86           0 : }
      87             : 
      88             : AliHLTCTPData& AliHLTCTPData::operator=(const AliHLTCTPData& src)
      89             : {
      90             :   // assignment operator, clone content
      91           0 :   if (this!=&src) {
      92           0 :     SetName(src.GetName());
      93           0 :     SetTitle(src.GetTitle());
      94           0 :     fMask=src.Mask();
      95           0 :     fClassIds.Delete();
      96           0 :     fClassIds.ExpandCreate(gkNCTPTriggerClasses);
      97           0 :     for (int i=0; i<gkNCTPTriggerClasses; i++) {
      98           0 :       if (i>src.fClassIds.GetLast()) break;
      99           0 :       ((TNamed*)fClassIds.At(i))->SetName(src.fClassIds.At(i)->GetName());
     100           0 :       ((TNamed*)fClassIds.At(i))->SetTitle(src.fClassIds.At(i)->GetTitle());
     101             :     }
     102           0 :     fCounters=src.Counters();
     103           0 :   }
     104             : 
     105           0 :   ReadMap();
     106           0 :   return *this;
     107             : }
     108             : 
     109             : int AliHLTCTPData::Add(const AliHLTCTPData& src, int factor, int &skipped)
     110             : {
     111             :   // see header file for class documentation
     112             :   
     113           0 :   skipped=0;
     114           0 :   for (int i=0; i<gkNCTPTriggerClasses; i++) {
     115           0 :     TString c;
     116           0 :     c=fClassIds.At(i)->GetName();
     117           0 :     if (c.IsNull()) continue;
     118           0 :     if (c.CompareTo(src.fClassIds.At(i)->GetName())==0) {
     119           0 :       fCounters[i]+=factor*src.Counter(i);
     120           0 :     } else {
     121           0 :       skipped++;
     122             :     }
     123           0 :   }
     124           0 :   return 0;
     125           0 : }
     126             : 
     127             : AliHLTCTPData& AliHLTCTPData::operator += (const AliHLTCTPData& src)
     128             : {
     129             :   // see header file for class documentation
     130             :   
     131           0 :   int nofInconsistencies=0;
     132           0 :   Add(src, 1, nofInconsistencies);
     133           0 :   if (nofInconsistencies>0) {
     134           0 :     HLTError("Inconsistent operants: skipping %d of %d CTP classes for operation", nofInconsistencies, gkNCTPTriggerClasses);
     135             :   }
     136           0 :   return *this;
     137           0 : }
     138             : 
     139             : AliHLTCTPData& AliHLTCTPData::operator -= (const AliHLTCTPData& src)
     140             : {
     141             :   // see header file for class documentation
     142             :   
     143           0 :   int nofInconsistencies=0;
     144           0 :   Add(src, -1, nofInconsistencies);
     145           0 :   if (nofInconsistencies>0) {
     146           0 :     HLTError("Inconsistent operants: skipping %d of %d CTP classes for operation", nofInconsistencies, gkNCTPTriggerClasses);
     147             :   }
     148           0 :   return *this;
     149           0 : }
     150             : 
     151             : AliHLTCTPData AliHLTCTPData::operator + (const AliHLTCTPData& src) const
     152             : {
     153             :   // see header file for class documentation
     154             : 
     155           0 :   AliHLTCTPData result(*this);
     156           0 :   result+=src;
     157             :   return result;
     158           0 : }
     159             : 
     160             : AliHLTCTPData AliHLTCTPData::operator - (const AliHLTCTPData& src) const
     161             : {
     162             :   // see header file for class documentation
     163             : 
     164           0 :   AliHLTCTPData result(*this);
     165           0 :   result-=src;
     166             :   return result;
     167           0 : }
     168             : 
     169             : int AliHLTCTPData::InitCTPTriggerClasses(const char* ctpString)
     170             : {
     171             :   // see header file for function documentation
     172           0 :   if (!ctpString) return -EINVAL;
     173             : 
     174           0 :   HLTInfo("ECS Parameter: %s", ctpString);
     175             : 
     176           0 :   fMask=0;
     177           0 :   fClassIds.Delete();
     178           0 :   fClassIds.ExpandCreate(gkNCTPTriggerClasses);
     179             : 
     180             :   // general format of the CTP_TRIGGER_CLASS parameter
     181             :   // <bit position>:<Trigger class identifier string>:<detector-id-nr>-<detector-id-nr>-...,<bit position>:<Trigger class identifier string>:<detector-id-nr>-<detector-id-nr>-...,...
     182             :   HLTDebug(": %s", ctpString);
     183           0 :   TString string=ctpString;
     184           0 :   if (string.BeginsWith("CTP_TRIGGER_CLASS=")) string.ReplaceAll("CTP_TRIGGER_CLASS=", "");
     185           0 :   TObjArray* classEntries=string.Tokenize(",");
     186           0 :   if (classEntries) {
     187             :     enum {kBit=0, kName, kDetectors};
     188           0 :     for (int i=0; i<classEntries->GetEntriesFast(); i++) {
     189           0 :       TString entry=((TObjString*)classEntries->At(i))->GetString();
     190           0 :       TObjArray* entryParams=entry.Tokenize(":");
     191           0 :       if (entryParams) {
     192           0 :         if (entryParams->GetEntriesFast()==3 &&
     193           0 :             (((TObjString*)entryParams->At(kBit))->GetString()).IsDigit()) {
     194           0 :           int index=(((TObjString*)entryParams->At(kBit))->GetString()).Atoi();
     195           0 :           if (index<gkNCTPTriggerClasses) {
     196           0 :             AliHLTReadoutList* pCTPClass=dynamic_cast<AliHLTReadoutList*>(fClassIds.At(index));
     197           0 :             if (pCTPClass) {
     198           0 :               fMask.set(index);
     199           0 :               pCTPClass->SetTitle("CTP Class");
     200           0 :               pCTPClass->SetName((((TObjString*)entryParams->At(kName))->GetString()).Data());
     201           0 :               TObjArray* detectors=(((TObjString*)entryParams->At(kDetectors))->GetString()).Tokenize("-");
     202           0 :               if (detectors) {
     203           0 :                 for (int dix=0; dix<detectors->GetEntriesFast(); dix++) {
     204           0 :                   if (!(((TObjString*)detectors->At(dix))->GetString()).IsDigit()) {
     205           0 :                     HLTError("invalid detector list format: trigger class entry %s", entry.Data());
     206           0 :                     break;
     207             :                   }
     208             :                   // see AliHLTReadoutList::EDetectorId for defines of detectors
     209           0 :                   pCTPClass->Enable(0x1<<(((TObjString*)detectors->At(dix))->GetString()).Atoi());
     210             :                 }
     211           0 :                 delete detectors;
     212             :               }
     213           0 :             } else {
     214             :             }
     215           0 :           } else {
     216             :             // the trigger bitfield is fixed to 100 bits (gkNCTPTriggerClasses)
     217           0 :             HLTError("invalid trigger class entry %s, index width of trigger bitfield exceeded (%d)", entry.Data(), gkNCTPTriggerClasses);
     218             :           }
     219           0 :         } else {
     220           0 :           HLTError("invalid trigger class entry %s", entry.Data());
     221             :         }
     222           0 :         delete entryParams;
     223             :       }
     224           0 :     }
     225           0 :     delete classEntries;
     226             :   }
     227             : 
     228           0 :   ResetCounters();
     229           0 :   ReadMap();
     230             : 
     231             :   return 0;
     232           0 : }
     233             : 
     234             : AliHLTTriggerMask_t AliHLTCTPData::ActiveTriggers(const AliHLTComponentTriggerData& trigData)
     235             : {
     236             :   // extract active triggers from the trigger data
     237           0 :   AliHLTCDHWrapper cdh;
     238           0 :   if (AliHLTComponent::ExtractTriggerData(trigData, NULL, NULL, &cdh, NULL) != 0) return 0x0;
     239           0 :   if ((cdh.GetL1TriggerMessage() & 0x1) == 0x1) return 0x0;  // invalid for software triggers.
     240             : 
     241           0 :   AliHLTTriggerMask_t triggerLow(cdh.GetTriggerClasses()); //low bits
     242           0 :   AliHLTTriggerMask_t triggerHigh(cdh.GetTriggerClassesNext50()); // high bits
     243             : 
     244           0 :   return triggerLow | (triggerHigh << 50);
     245           0 : }
     246             : 
     247             : bool AliHLTCTPData::EvaluateCTPTriggerClass(const char* expression, const AliHLTComponentTriggerData& trigData) const
     248             : {
     249             :   // see header file for function documentation
     250             :   
     251           0 :   AliHLTCDHWrapper cdh;
     252           0 :   if (AliHLTComponent::ExtractTriggerData(trigData, NULL, NULL, &cdh, NULL, true) != 0) return false;
     253           0 :   if ((cdh.GetL1TriggerMessage() & 0x1) == 0x1) return false;  // invalid for software triggers.
     254             : 
     255           0 :   AliHLTTriggerMask_t triggerMask(cdh.GetTriggerClasses());
     256           0 :   AliHLTTriggerMask_t triggerHigh(cdh.GetTriggerClassesNext50());
     257           0 :   triggerMask |= (triggerHigh << 50);
     258             : 
     259           0 :   if (fMask!=0 && (triggerMask & fMask)==0) {
     260           0 :     AliHLTEventTriggerData* evtData=reinterpret_cast<AliHLTEventTriggerData*>(trigData.fData);
     261           0 :     HLTWarning("invalid trigger mask %s, unknown CTP trigger, initialized %s", 
     262             :                TriggerMaskToString(triggerMask).c_str(), TriggerMaskToString(fMask).c_str() );
     263           0 :     for (int i=0; i<evtData->fCommonHeaderWordCnt; i++) HLTWarning("\t CDH[%d]=0x%lx", i, evtData->fCommonHeader[i]);
     264             :     return false;
     265             :   }
     266             : 
     267           0 :   return EvaluateCTPTriggerClass(expression, triggerMask);
     268           0 : }
     269             : 
     270             : bool AliHLTCTPData::EvaluateCTPTriggerClass(const char* expression, AliHLTTriggerMask_t triggerMask) const
     271             : {
     272             :   // see header file for function documentation
     273             : 
     274             :   // use a TFormula to interprete the expression
     275             :   // all classname are replaced by '[n]' which means the n'th parameter in the formula
     276             :   // the parameters are set to 0 or 1 depending on the bit in the trigger mask
     277           0 :   const vector<unsigned> *pMap=&fMap;
     278           0 :   vector<unsigned> tmp;
     279           0 :   if (fMap.size()==0 && fClassIds.GetLast()>=0) {
     280             :     // read map into temporary array and use it
     281           0 :     ReadMap(tmp);
     282             :     pMap=&tmp;
     283             :     static bool suppressWarning=false;
     284           0 :     if (!suppressWarning) HLTWarning("map not yet initialized, creating local map (slow), suppressing further warnings");
     285           0 :     suppressWarning=true;
     286           0 :   }
     287           0 :   vector<Double_t> par;
     288           0 :   TString condition=expression;
     289           0 :   for (unsigned index=0; index<pMap->size(); index++) {
     290           0 :     const char* className=Name((*pMap)[index]);
     291           0 :     if (className && strlen(className)>0) {
     292             :       //HLTDebug("checking trigger class %s", className.Data());
     293           0 :       if (condition.Contains(className)) {
     294           0 :         TString replace; replace.Form("[%d]", (int)par.size());
     295             :         //HLTDebug("replacing %s with %s in \"%s\"", className.Data(), replace.Data(), condition.Data());
     296           0 :         condition.ReplaceAll(className, replace);
     297           0 :         if ( triggerMask.test((*pMap)[index]) ) par.push_back(1.0);
     298           0 :         else par.push_back(0.0);
     299           0 :       }
     300             :     }
     301             :   }
     302             : 
     303           0 :   TFormula form("trigger expression", condition);
     304             : #if ROOT_VERSION_CODE >= ROOT_VERSION(6,3,0)
     305             :   if (form.IsValid()!=0) {
     306             : #else
     307           0 :   if (form.Compile()!=0) {
     308             : #endif
     309           0 :     HLTError("invalid expression %s", expression);
     310           0 :     return false;
     311             :   }
     312           0 :   if (form.EvalPar(&par[0], &par[0])>0.5) return true;
     313           0 :   return false;
     314           0 : }
     315             : 
     316             : void AliHLTCTPData::ResetCounters()
     317             : {
     318             :   // see header file for function documentation
     319           0 :   fCounters.Set(gkNCTPTriggerClasses);
     320           0 :   fCounters.Reset();
     321           0 : }
     322             : 
     323             : int AliHLTCTPData::Index(const char* name) const
     324             : {
     325             :   // see header file for function documentation
     326           0 :   TObject* obj=fClassIds.FindObject(name);
     327           0 :   return obj!=NULL?fClassIds.IndexOf(obj):-1;
     328             : }
     329             : 
     330             : int AliHLTCTPData::CheckTrigger(const char* name) const
     331             : {
     332             :   // check status of a trigger class
     333           0 :   int index=Index(name);
     334           0 :   if (index<0) return index;
     335           0 :   return ( fTriggers.test(index) ? 1 : 0 );
     336           0 : }
     337             : 
     338             : void AliHLTCTPData::Increment(const char* classIds)
     339             : {
     340             :   // see header file for function documentation
     341           0 :   TString string=classIds;
     342           0 :   TObjArray* classEntries=string.Tokenize(",");
     343           0 :   if (classEntries) {
     344           0 :     for (int i=0; i<classEntries->GetEntriesFast(); i++) {
     345           0 :       int index=Index(((TObjString*)classEntries->At(i))->GetString().Data());
     346           0 :       if (index>=0 && index<fCounters.GetSize()) fCounters[index]++;
     347             :     }
     348           0 :     delete classEntries;
     349             :   }
     350           0 : }
     351             : 
     352             : void AliHLTCTPData::Increment(AliHLTTriggerMask_t triggerPattern)
     353             : {
     354             :   // see header file for function documentation
     355           0 :   AliHLTTriggerMask_t pattern=triggerPattern&fMask;
     356           0 :   for (int i=0; i<fCounters.GetSize(); i++) {
     357           0 :     if (!pattern.test(i)) continue;
     358           0 :     fCounters[i]++;    
     359           0 :   }
     360           0 : }
     361             : 
     362             : void AliHLTCTPData::Increment(int classIdx)
     363             : {
     364             :   // see header file for function documentation
     365           0 :   if (classIdx<fCounters.GetSize() &&
     366           0 :       fMask.test(classIdx)) {
     367           0 :     fCounters[classIdx]++;    
     368           0 :   }
     369             :   
     370           0 : }
     371             : 
     372             : int AliHLTCTPData::Increment(AliHLTComponentTriggerData& trigData)
     373             : {
     374             :   // see header file for function documentation
     375           0 :   AliHLTCDHWrapper cdh;
     376           0 :   int result = AliHLTComponent::ExtractTriggerData(trigData, NULL, NULL, &cdh, NULL, true);
     377           0 :   if (result != 0) return result;
     378           0 :   if ((cdh.GetL1TriggerMessage() & 0x1) == 0x1) return 0;  // invalid for software triggers.
     379             : 
     380           0 :   AliHLTTriggerMask_t triggerMask(cdh.GetTriggerClasses());
     381           0 :   AliHLTTriggerMask_t triggerHigh(cdh.GetTriggerClassesNext50());
     382           0 :   triggerMask |= (triggerHigh << 50);
     383             : 
     384           0 :   if (fMask.any() && (triggerMask & fMask).none()) {
     385           0 :     AliHLTEventTriggerData* evtData=reinterpret_cast<AliHLTEventTriggerData*>(trigData.fData);
     386           0 :     HLTWarning("invalid trigger mask %s, unknown CTP trigger, initialized %s", 
     387             :                TriggerMaskToString(triggerMask).c_str(), TriggerMaskToString(fMask).c_str());
     388           0 :     for (int i=0; i<evtData->fCommonHeaderWordCnt; i++) 
     389           0 :       HLTWarning("\t CDH[%d]=0x%lx", i, evtData->fCommonHeader[i]);
     390           0 :   }
     391           0 :   Increment(triggerMask);
     392             :   return 0;
     393           0 : }
     394             : 
     395             : AliHLTUInt64_t AliHLTCTPData::Counter(int index) const
     396             : {
     397             :   // see header file for function documentation
     398           0 :   if (index>=0 && index<Counters().GetSize()) return Counters()[index];
     399           0 :   return 0;
     400           0 : }
     401             : 
     402             : AliHLTUInt64_t AliHLTCTPData::Counter(const char* classId) const
     403             : {
     404             :   // see header file for function documentation
     405           0 :   return Counter(Index(classId));
     406             : }
     407             : 
     408             : const char* AliHLTCTPData::Name(int index) const
     409             : {
     410             :   // see header file for function documentation
     411           0 :   if (index>fClassIds.GetLast()) return NULL;
     412           0 :   return fClassIds.At(index)->GetName();
     413           0 : }
     414             : 
     415             : int AliHLTCTPData::ReadMap(vector<unsigned> &map) const
     416             : {
     417             :   // read the index map for class names
     418             :   // for nested class names (e.g. 'myclass' is contained in
     419             :   // 'myclassA') the longer names is added first to the map.
     420           0 :   for (int index=0; index<=fClassIds.GetLast(); index++) {
     421           0 :     vector<unsigned>::iterator element=map.begin();
     422           0 :     for (; element!=map.end(); element++) {
     423           0 :       TString name=Name(index);
     424           0 :       if (name.Contains(Name(*element))) {
     425             :         // current name contains another one already in the map
     426             :         // -> add before and go to next entry
     427           0 :         element=map.insert(element, index);
     428           0 :         break;
     429             :       }
     430           0 :     }
     431             : 
     432           0 :     if (element==map.end()) {
     433             :       // unique class name, append to map
     434           0 :       map.push_back(index);
     435           0 :     }
     436           0 :   }
     437           0 :   return 0;
     438           0 : }
     439             : 
     440             : 
     441             : AliHLTReadoutList AliHLTCTPData::ReadoutList(const AliHLTComponentTriggerData& trigData) const
     442             : {
     443             :   // see header file for function documentation
     444             : 
     445           0 :   AliHLTCDHWrapper cdh;
     446           0 :   if (AliHLTComponent::ExtractTriggerData(trigData, NULL, NULL, &cdh, NULL, true) != 0) return AliHLTReadoutList();
     447             :   // Check if we are dealing with a software trigger. If so then we need to return
     448             :   // a readout list with everything set because the CTP trigger bits are invalid.
     449             :   // Thus we assume that everything should be read out.
     450           0 :   if ((cdh.GetL1TriggerMessage() & 0x1) == 0x1) return ~ AliHLTReadoutList();
     451             : 
     452           0 :   AliHLTTriggerMask_t triggerMask(cdh.GetTriggerClasses());
     453           0 :   AliHLTTriggerMask_t triggerHigh(cdh.GetTriggerClassesNext50());
     454           0 :   triggerMask |= (triggerHigh << 50);
     455             : 
     456           0 :   if (fMask.any() && (triggerMask & fMask).none()) {
     457           0 :     AliHLTEventTriggerData* evtData=reinterpret_cast<AliHLTEventTriggerData*>(trigData.fData);
     458           0 :     HLTWarning("invalid trigger mask %s, unknown CTP trigger, initialized %s",
     459             :                TriggerMaskToString(triggerMask).c_str(), TriggerMaskToString(fMask).c_str());
     460           0 :     for (int i=0; i<evtData->fCommonHeaderWordCnt; i++)
     461           0 :       HLTWarning("\t CDH[%d]=0x%lx", i, evtData->fCommonHeader[i]);
     462           0 :   }
     463             : 
     464           0 :   return ReadoutList(triggerMask);
     465           0 : }
     466             : 
     467             : AliHLTReadoutList AliHLTCTPData::ReadoutList(AliHLTTriggerMask_t  triggerMask) const
     468             : {
     469             :   // take an 'OR' of all active trigger classes 
     470           0 :   AliHLTReadoutList list;
     471           0 :   for (int i=0; i<gkNCTPTriggerClasses; i++) {
     472           0 :     if (i>fClassIds.GetLast()) break;
     473           0 :     if (! triggerMask.test(i)) continue;
     474           0 :     AliHLTReadoutList* tcrl=(AliHLTReadoutList*)fClassIds.At(i);
     475           0 :     list.OrEq(*tcrl);
     476           0 :   }
     477             : 
     478             :   return list;
     479           0 : }
     480             : 
     481             : 
     482             : void AliHLTCTPData::Print(Option_t* /*option*/) const
     483             : {
     484             :   // see header file for function documentation
     485           0 :   cout << GetTitle() << endl;
     486           0 :   cout << "\tactive trigger mask: 0x" << hex << fTriggers << dec << endl;
     487             :   int count=0;
     488           0 :   for (int i=0; i<gkNCTPTriggerClasses; i++) {
     489           0 :     if (i>=Counters().GetSize()) break;
     490           0 :     if (i>fClassIds.GetLast()) break;
     491           0 :     if (! fMask.test(i)) continue;
     492           0 :     count++;
     493           0 :     cout << "\t" << i << "\t" << Name(i) << "\t" << Counter(i) << endl;
     494           0 :   }
     495           0 :   if (count==0) cout << "\t(none)" << endl;
     496           0 : }
     497             : 
     498             : 
     499             : std::string AliHLTCTPData::TriggerMaskToString(AliHLTTriggerMask_t mask) const
     500             : {
     501           0 :   AliHLTTriggerMask_t max(std::numeric_limits<unsigned long>::max());
     502             :   int digits = std::numeric_limits<unsigned long>::digits;
     503           0 :   int numberOfWords = (mask.size() + digits - 1)/digits;
     504           0 :   std::stringstream stream;
     505           0 :   stream << "0x";
     506           0 :   stream << std::hex << std::right;
     507           0 :   for(int i=numberOfWords-1; i>=0; --i){
     508           0 :     stream.width(digits/4);
     509           0 :     stream.fill('0');
     510           0 :     stream << ((mask >> (digits*i)) & max).to_ulong() << " ";
     511             :   }
     512           0 :   return stream.str();
     513           0 : }
     514             : 
     515             : Bool_t AliHLTCTPData::Globncmp(const char* triggerName, const char* glob, int triggerNameSize, int globSize ) const
     516             : {
     517           0 :   if (globSize == 0) return kFALSE;
     518           0 :   for (int i=0; i<((triggerNameSize<globSize)?triggerNameSize:globSize); i++)
     519             :   {
     520           0 :     if (!(glob[i]=='*' || triggerName[i]==glob[i])) {return kFALSE;}
     521             :   }
     522           0 :   return kTRUE;
     523           0 : }
     524             : 
     525             : int AliHLTCTPData::MatchTriggerGlob(const char* glob) const
     526             : {
     527             :   //return 1 on (first) match, 0 otherwise
     528             :   //only take what is not masked
     529           0 :   AliHLTTriggerMask_t triggers = fTriggers;
     530           0 :   triggers &= fMask;
     531             : 
     532           0 :   int globsize = strnlen(glob,100);
     533           0 :   if (globsize==0) return 1;
     534             : 
     535             :   //check every fired trigger agains the expressions
     536           0 :   for (int i=0; i<NCTPTRIGGERCLASSES; i++)
     537             :   {
     538           0 :     if (!triggers.test(i)) continue;
     539             : 
     540           0 :     const char* triggerName = Name(i);
     541             :     
     542           0 :     if (Globncmp(triggerName, glob, strnlen(triggerName,100), globsize))
     543             :     {
     544           0 :       return 1;
     545             :     }
     546           0 :   }
     547           0 :   return 0;
     548           0 : }
     549             : 
     550             : int AliHLTCTPData::MatchTriggerRE(const char* restr) const
     551             : {
     552             :   //return 1 on (first) match, 0 otherwise
     553             :   //only take what is not masked
     554           0 :   AliHLTTriggerMask_t triggers = fTriggers;
     555           0 :   triggers &= fMask;
     556             : 
     557             :   //compile the regex
     558           0 :   TPRegexp re(restr);
     559             :   
     560             :   //if pattern empty: accept
     561           0 :   if (re.GetPattern().IsNull()) return 1;
     562             : 
     563             :   //check every fired trigger agains the expressions
     564           0 :   for (int i=0; i<NCTPTRIGGERCLASSES; i++)
     565             :   {
     566           0 :     if (!triggers.test(i)) continue;
     567             : 
     568           0 :     const char* triggerName = Name(i);
     569             :     
     570           0 :     if (re.Match(triggerName)>0)
     571             :     {
     572           0 :       return 1;
     573             :     }
     574           0 :   }
     575           0 :   return 0;
     576           0 : }
     577             : 
     578             : void AliHLTCTPData::GetTriggerMaskAll(ULong64_t& low,ULong64_t& high) const
     579             : {
     580           0 :   low = 0; high = 0;
     581           0 :   AliHLTTriggerMask_t active = fTriggers;// & fMask;
     582           0 :   AliHLTTriggerMask_t bh = active>>50;
     583           0 :   high=bh.to_ulong();
     584           0 :   AliHLTTriggerMask_t low50 = 0x3FFFFFFFFFFFF;
     585           0 :   active &= low50;
     586           0 :   low=active.to_ulong();
     587           0 : }
     588             : 
     589             : int AliHLTCTPData::GetFiredTriggerClasses(std::string& string) const
     590             : {
     591             :   int nTrgClasses = 0;
     592           0 :   string.clear();
     593           0 :   AliHLTTriggerMask_t activeTriggers = fTriggers;// & fMask;
     594           0 :   for (int index=0; index<gkNCTPTriggerClasses; index++) {
     595           0 :     if (!activeTriggers.test(index)) continue;
     596           0 :     string+=Name(index);
     597           0 :     string+=" ";
     598           0 :     nTrgClasses++;
     599           0 :   }
     600           0 :   return nTrgClasses;
     601           0 : }

Generated by: LCOV version 1.11