// $Id$ //************************************************************************** //* This file is property of and copyright by the ALICE HLT Project * //* ALICE Experiment at CERN, All rights reserved. * //* * //* Primary Authors: Matthias Richter * //* Timm Steinbeck * //* 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 AliHLTCTPData.cxx @author Matthias Richter @date 2009-08-20 @brief Container for CTP trigger classes and counters */ #include "AliHLTCTPData.h" #include "TClass.h" #include "TNamed.h" #include "TObjString.h" #include "TFormula.h" /** ROOT macro for the implementation of ROOT specific class methods */ ClassImp(AliHLTCTPData) AliHLTCTPData::AliHLTCTPData() : TNamed("AliHLTCTPData", "HLT counters for the CTP") , AliHLTLogging() , fMask(0) , fClassIds(TNamed::Class(), gkNCTPTriggerClasses) , fCounters() { // see header file for class documentation // or // refer to README to build package // or // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt } AliHLTCTPData::AliHLTCTPData(const char* parameter) : TNamed("AliHLTCTPData", "HLT counters for the CTP") , AliHLTLogging() , fMask(0) , fClassIds(TNamed::Class(), gkNCTPTriggerClasses) , fCounters() { // see header file for class documentation InitCTPTriggerClasses(parameter); } AliHLTCTPData::~AliHLTCTPData() { // see header file for class documentation fClassIds.Delete(); } int AliHLTCTPData::InitCTPTriggerClasses(const char* ctpString) { // see header file for function documentation if (!ctpString) return -EINVAL; fMask=0; fClassIds.Delete(); fClassIds.ExpandCreate(gkNCTPTriggerClasses); // general format of the CTP_TRIGGER_CLASS parameter // ::--...,::--...,... // the detector ids are ignored for the moment HLTDebug(": %s", ctpString); TString string=ctpString; TObjArray* classEntries=string.Tokenize(","); if (classEntries) { for (int i=0; iGetEntries(); i++) { TString entry=((TObjString*)classEntries->At(i))->GetString(); TObjArray* entryParams=entry.Tokenize(":"); if (entryParams) { if (entryParams->GetEntries()==3 && (((TObjString*)entryParams->At(0))->GetString()).IsDigit()) { int index=(((TObjString*)entryParams->At(0))->GetString()).Atoi(); if (indexSetTitle("TriggerClass"); ((TNamed*)fClassIds.At(index))->SetName((((TObjString*)entryParams->At(1))->GetString()).Data()); } else { // the trigger bitfield is fixed to 50 bits (gkNCTPTriggerClasses) HLTError("invalid trigger class entry %s, index width of trigger bitfield", entry.Data()); } } else { HLTError("invalid trigger class entry %s", entry.Data()); } delete entryParams; } } delete classEntries; } ResetCounters(); return 0; } bool AliHLTCTPData::EvaluateCTPTriggerClass(const char* expression, AliHLTComponentTriggerData& trigData) const { // see header file for function documentation if (trigData.fDataSize != sizeof(AliHLTEventTriggerData)) { HLTError("invalid trigger data size: %d expected %d", trigData.fDataSize, sizeof(AliHLTEventTriggerData)); return false; } // trigger mask is 50 bit wide and is stored in word 5 and 6 of the CDH AliHLTEventTriggerData* evtData=reinterpret_cast(trigData.fData); AliHLTUInt64_t triggerMask=evtData->fCommonHeader[6]; triggerMask<<=32; triggerMask|=evtData->fCommonHeader[5]; if (fMask!=0 && (triggerMask & fMask)==0) { HLTWarning("invalid trigger mask 0x%llx, unknown CTP trigger", triggerMask); return false; } // use a TFormula to interprete the expression // all classname are replaced by '[n]' which means the n'th parameter in the formula // the parameters are set to 0 or 1 depending on the bit in the trigger mask // // TODO: this will most likely fail for class names like 'base', 'baseA', 'baseB' // the class names must be fully unique, none must be contained as substring in // another class name. Probably not needed for the moment but needs to be extended. vector par; TString condition=expression; for (int i=0; i0) { //HLTDebug("checking trigger class %s", className.Data()); if (condition.Contains(className)) { TString replace; replace.Form("[%d]", par.size()); //HLTDebug("replacing %s with %s in \"%s\"", className.Data(), replace.Data(), condition.Data()); condition.ReplaceAll(className, replace); if (triggerMask&((AliHLTUInt64_t)0x1<0.5) return true; return false; } void AliHLTCTPData::ResetCounters() { // see header file for function documentation fCounters.Set(gkNCTPTriggerClasses); fCounters.Reset(); } int AliHLTCTPData::Index(const char* name) const { // see header file for function documentation TObject* obj=fClassIds.FindObject(name); return obj!=NULL?fClassIds.IndexOf(obj):-1; } void AliHLTCTPData::Increment(const char* classIds) { // see header file for function documentation TString string=classIds; TObjArray* classEntries=string.Tokenize(","); if (classEntries) { for (int i=0; iGetEntries(); i++) { int index=Index(((TObjString*)classEntries->At(i))->GetString().Data()); if (index>=0 && index(trigData.fData); AliHLTUInt64_t triggerMask=evtData->fCommonHeader[6]; triggerMask<<=32; triggerMask|=evtData->fCommonHeader[5]; if (fMask!=0 && (triggerMask & fMask)==0) { HLTWarning("invalid trigger mask 0x%llx, unknown CTP trigger, initialized 0x%llx", triggerMask, fMask); } Increment(triggerMask); return 0; } AliHLTUInt64_t AliHLTCTPData::Counter(int index) const { // see header file for function documentation if (index>=0 && indexfClassIds.GetLast()) return NULL; return fClassIds.At(index)->GetName(); } void AliHLTCTPData::Print(Option_t* /*option*/) const { // see header file for function documentation cout << "CTP counters:" << endl; int count=0; for (int i=0; i=Counters().GetSize()) break; if (i>fClassIds.GetLast()) break; if ((fMask&((AliHLTUInt64_t)0x1<