//* 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"
, fTriggers(0)
, fClassIds(AliHLTReadoutList::Class(), gkNCTPTriggerClasses)
, fCounters(gkNCTPTriggerClasses)
+ , fMap()
{
+ // constructor
// see header file for class documentation
// or
// refer to README to build package
, 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();
}
, 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());
fCounters=src.Counters();
}
+ ReadMap();
return *this;
}
}
ResetCounters();
+ ReadMap();
return 0;
}
// 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<unsigned> *pMap=&fMap;
+ vector<unsigned> 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<Double_t> par;
TString condition=expression;
- for (int i=0; i<gkNCTPTriggerClasses; i++) {
- const char* className=Name(i);
+ for (unsigned index=0; index<pMap->size(); 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<<i)) par.push_back(1.0);
+ if (triggerMask&((AliHLTUInt64_t)0x1<<(*pMap)[index])) par.push_back(1.0);
else par.push_back(0.0);
}
}
return obj!=NULL?fClassIds.IndexOf(obj):-1;
}
+int AliHLTCTPData::CheckTrigger(const char* name) const
+{
+ // check status of a trigger class
+ int index=Index(name);
+ if (index<0) return index;
+ return (fTriggers&(0x1<<index))>0?1:0;
+}
+
void AliHLTCTPData::Increment(const char* classIds)
{
// see header file for function documentation
return fClassIds.At(index)->GetName();
}
+int AliHLTCTPData::ReadMap(vector<unsigned> &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<unsigned>::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
*/
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
*/
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<unsigned> &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<unsigned> fMap; //! index map for trigger expression evaluation
- ClassDef(AliHLTCTPData, 1)
+ ClassDef(AliHLTCTPData, 2)
};
#endif