From: richterm Date: Thu, 8 Apr 2010 07:10:26 +0000 (+0000) Subject: adding support for similar class names (e.g 'mytrigger', 'mytriggerA'). This X-Git-Url: http://git.uio.no/git/?a=commitdiff_plain;h=ffda78e302a86aa9ff265ce8571d12358d789c0a;p=u%2Fmrichter%2FAliRoot.git adding support for similar class names (e.g 'mytrigger', 'mytriggerA'). This had been ommitted in the first implementation of EvaluateCTPTriggerClass Adding new method to check the status of a trigger. Can be used instead of EvaluateCTPTriggerClass as this function requires to have the exact class name present in the running trigger configuration. /** * Check state of a trigger class. * If the class name is not part of the current trigger setup (i.e. ECS parameter * does not contain a trigger definition for this class name) the function * returns -1 * @return -1 class name not initialized, * 0 trigger not active * 1 trigger active */ int CheckTrigger(const char* name) const; --- diff --git a/HLT/BASE/AliHLTCTPData.cxx b/HLT/BASE/AliHLTCTPData.cxx index d6a87249066..7f73f75c068 100644 --- a/HLT/BASE/AliHLTCTPData.cxx +++ b/HLT/BASE/AliHLTCTPData.cxx @@ -16,11 +16,11 @@ //* 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 -*/ +// @file AliHLTCTPData.cxx +// @author Matthias Richter +// @date 2009-08-20 +// @brief Container for CTP trigger classes and counters +// @note #include "AliHLTCTPData.h" #include "AliHLTReadoutList.h" @@ -38,7 +38,9 @@ AliHLTCTPData::AliHLTCTPData() , fTriggers(0) , fClassIds(AliHLTReadoutList::Class(), gkNCTPTriggerClasses) , fCounters(gkNCTPTriggerClasses) + , fMap() { + // constructor // see header file for class documentation // or // refer to README to build package @@ -53,14 +55,15 @@ AliHLTCTPData::AliHLTCTPData(const char* parameter) , fTriggers(0) , fClassIds(AliHLTReadoutList::Class(), gkNCTPTriggerClasses) , fCounters(gkNCTPTriggerClasses) + , fMap() { - // see header file for class documentation + // constructor, init the CTP trigger classes InitCTPTriggerClasses(parameter); } AliHLTCTPData::~AliHLTCTPData() { - // see header file for class documentation + // destructor fClassIds.Delete(); } @@ -71,13 +74,15 @@ AliHLTCTPData::AliHLTCTPData(const AliHLTCTPData& src) , fTriggers(src.fTriggers) , fClassIds(src.fClassIds) , fCounters(src.Counters()) + , fMap() { - // see header file for class documentation + // copy constructor + ReadMap(); } AliHLTCTPData& AliHLTCTPData::operator=(const AliHLTCTPData& src) { - // see header file for class documentation + // assignment operator, clone content if (this!=&src) { SetName(src.GetName()); SetTitle(src.GetTitle()); @@ -92,6 +97,7 @@ AliHLTCTPData& AliHLTCTPData::operator=(const AliHLTCTPData& src) fCounters=src.Counters(); } + ReadMap(); return *this; } @@ -215,6 +221,7 @@ int AliHLTCTPData::InitCTPTriggerClasses(const char* ctpString) } ResetCounters(); + ReadMap(); return 0; } @@ -263,21 +270,27 @@ bool AliHLTCTPData::EvaluateCTPTriggerClass(const char* expression, AliHLTUInt64 // 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. + const vector *pMap=&fMap; + vector tmp; + if (fMap.size()==0 && fClassIds.GetLast()>=0) { + // read map into temporary array and use it + ReadMap(tmp); + pMap=&tmp; + static bool suppressWarning=false; + if (!suppressWarning) HLTWarning("map not yet initialized, creating local map (slow), suppressing further warnings"); + suppressWarning=true; + } vector par; TString condition=expression; - for (int i=0; isize(); index++) { + const char* className=Name((*pMap)[index]); if (className && strlen(className)>0) { //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?1:0; +} + void AliHLTCTPData::Increment(const char* classIds) { // see header file for function documentation @@ -382,6 +403,32 @@ const char* AliHLTCTPData::Name(int index) const return fClassIds.At(index)->GetName(); } +int AliHLTCTPData::ReadMap(vector &map) const +{ + // read the index map for class names + // for nested class names (e.g. 'myclass' is contained in + // 'myclassA') the longer names is added first to the map. + for (int index=0; index<=fClassIds.GetLast(); index++) { + vector::iterator element=map.begin(); + for (; element!=map.end(); element++) { + TString name=Name(index); + if (name.Contains(Name(*element))) { + // current name contains another one already in the map + // -> add before and go to next entry + element=map.insert(element, index); + break; + } + } + + if (element==map.end()) { + // unique class name, append to map + map.push_back(index); + } + } + return 0; +} + + AliHLTEventDDL AliHLTCTPData::ReadoutList(const AliHLTComponentTriggerData& trigData) const { // see header file for function documentation diff --git a/HLT/BASE/AliHLTCTPData.h b/HLT/BASE/AliHLTCTPData.h index 2548376e667..427ff95fad4 100644 --- a/HLT/BASE/AliHLTCTPData.h +++ b/HLT/BASE/AliHLTCTPData.h @@ -99,6 +99,17 @@ class AliHLTCTPData: public TNamed, public AliHLTLogging */ int Index(const char* name) const; + /** + * Check state of a trigger class. + * If the class name is not part of the current trigger setup (i.e. ECS parameter + * does not contain a trigger definition for this class name) the function + * returns -1 + * @return -1 class name not initialized, + * 0 trigger not active + * 1 trigger active + */ + int CheckTrigger(const char* name) const; + /** * Increment counter for CTP trigger classes * @param classIds comma separated list of class ids @@ -169,12 +180,24 @@ class AliHLTCTPData: public TNamed, public AliHLTLogging */ int Add(const AliHLTCTPData& src, int factor, int &skipped); + /** + * Read the map of trigger class indexes + * The map is used in the generation of the TFormula from the trigger + * expression in order to handle similar class names correctly. + * For names like 'base', 'baseA', 'baseB' the class with the longer name + * has to be replaced first. + */ + int ReadMap(vector &map) const; + + int ReadMap() {return ReadMap(fMap);} + AliHLTUInt64_t fMask; /// mask of initialized trigger classes AliHLTUInt64_t fTriggers; /// current trigger TClonesArray fClassIds; /// array of trigger class ids TArrayL64 fCounters; /// trigger class counters + vector fMap; //! index map for trigger expression evaluation - ClassDef(AliHLTCTPData, 1) + ClassDef(AliHLTCTPData, 2) }; #endif