*/
#include "AliHLTCTPData.h"
+#include "AliHLTReadoutList.h"
#include "TClass.h"
-#include "TNamed.h"
#include "TObjString.h"
#include "TFormula.h"
ClassImp(AliHLTCTPData)
AliHLTCTPData::AliHLTCTPData()
-: TNamed("AliHLTCTPData", "HLT counters for the CTP")
+ : TNamed("AliHLTCTPData", "HLT counters for the CTP")
, AliHLTLogging()
, fMask(0)
- , fClassIds(TNamed::Class(), gkNCTPTriggerClasses)
+ , fClassIds(AliHLTReadoutList::Class(), gkNCTPTriggerClasses)
, fCounters()
{
// see header file for class documentation
: TNamed("AliHLTCTPData", "HLT counters for the CTP")
, AliHLTLogging()
, fMask(0)
- , fClassIds(TNamed::Class(), gkNCTPTriggerClasses)
+ , fClassIds(AliHLTReadoutList::Class(), gkNCTPTriggerClasses)
, fCounters()
{
// see header file for class documentation
// general format of the CTP_TRIGGER_CLASS parameter
// <bit position>:<Trigger class identifier string>:<detector-id-nr>-<detector-id-nr>-...,<bit position>:<Trigger class identifier string>:<detector-id-nr>-<detector-id-nr>-...,...
- // the detector ids are ignored for the moment
HLTDebug(": %s", ctpString);
TString string=ctpString;
+ if (string.BeginsWith("CTP_TRIGGER_CLASS=")) string.ReplaceAll("CTP_TRIGGER_CLASS=", "");
TObjArray* classEntries=string.Tokenize(",");
if (classEntries) {
+ enum {kBit=0, kName, kDetectors};
for (int i=0; i<classEntries->GetEntries(); 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();
+ (((TObjString*)entryParams->At(kBit))->GetString()).IsDigit()) {
+ int index=(((TObjString*)entryParams->At(kBit))->GetString()).Atoi();
if (index<gkNCTPTriggerClasses) {
- fMask|=(AliHLTUInt64_t)0x1 << index;
- ((TNamed*)fClassIds.At(index))->SetTitle("TriggerClass");
- ((TNamed*)fClassIds.At(index))->SetName((((TObjString*)entryParams->At(1))->GetString()).Data());
+ AliHLTReadoutList* pCTPClass=dynamic_cast<AliHLTReadoutList*>(fClassIds.At(index));
+ if (pCTPClass) {
+ fMask|=(AliHLTUInt64_t)0x1 << index;
+ pCTPClass->SetTitle("CTP Class");
+ pCTPClass->SetName((((TObjString*)entryParams->At(kName))->GetString()).Data());
+ TObjArray* detectors=(((TObjString*)entryParams->At(kDetectors))->GetString()).Tokenize("-");
+ if (detectors) {
+ for (int dix=0; dix<detectors->GetEntriesFast(); dix++) {
+ if (!(((TObjString*)detectors->At(dix))->GetString()).IsDigit()) {
+ HLTError("invalid detector list format: trigger class entry %s", entry.Data());
+ break;
+ }
+ // see AliHLTReadoutList::EDetectorId for defines of detectors
+ pCTPClass->Enable(0x1<<(((TObjString*)detectors->At(dix))->GetString()).Atoi());
+ }
+ delete detectors;
+ }
+ } else {
+ }
} else {
// the trigger bitfield is fixed to 50 bits (gkNCTPTriggerClasses)
- HLTError("invalid trigger class entry %s, index width of trigger bitfield", entry.Data());
+ HLTError("invalid trigger class entry %s, index width of trigger bitfield exceeded (%d)", entry.Data(), gkNCTPTriggerClasses);
}
} else {
HLTError("invalid trigger class entry %s", entry.Data());
return fClassIds.At(index)->GetName();
}
+AliHLTEventDDL AliHLTCTPData::ReadoutList(const 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));
+ AliHLTEventDDL dummy;
+ memset(&dummy, 0, sizeof(AliHLTEventDDL));
+ return dummy;
+ }
+
+ // trigger mask is 50 bit wide and is stored in word 5 and 6 of the CDH
+ AliHLTEventTriggerData* evtData=reinterpret_cast<AliHLTEventTriggerData*>(trigData.fData);
+ AliHLTUInt64_t triggerMask=evtData->fCommonHeader[6];
+ triggerMask<<=32;
+ triggerMask|=evtData->fCommonHeader[5];
+
+ // take an 'OR' of all active trigger classes
+ AliHLTReadoutList list;
+ for (int i=0; i<gkNCTPTriggerClasses; i++) {
+ if (i>fClassIds.GetLast()) break;
+ if ((triggerMask&((AliHLTUInt64_t)0x1<<i))==0) continue;
+ list|=*((AliHLTReadoutList*)fClassIds.At(i));
+ }
+
+ return list;
+}
+
void AliHLTCTPData::Print(Option_t* /*option*/) const
{
// see header file for function documentation
* This is a container for the CTP trigger classes, the mapping to the bit
* field, and counters.
*
+ * The class is initialized from CTP_TRIGGER_CLASSES part of the ECS parameters.
+ * and stores internally a list of trigger classes holding the information on bit
+ * position, class name and involved detectors. The general format og the parameter
+ * is as follows:
+ * <pre>
+ * [bit position]:[Trigger class identifier string]:[detector-id-nr]-[detector-id-nr]-...,[bit position]:.....
+ * </pre>
+ *
+ * The list of participating detectors is converted into an AliHLTReadoutList
+ * object named after the trigger class name, and can be used as mask for the
+ * readout list generated by a component.
+ *
* The object is also stored as part of the HLTGlobalTriggerDecision
* @ingroup alihlt_trigger
*/
*/
int Increment(AliHLTComponentTriggerData& trigData);
+ /**
+ * Return a readout list for the active trigger classes.
+ * The list is an 'OR' of the active trugger classes.
+ */
+ AliHLTEventDDL ReadoutList(const AliHLTComponentTriggerData& trigData) const;
+
/**
* Inherited from TObject, this prints the contents of the trigger decision.
*/
AliHLTReadoutList::AliHLTReadoutList() :
- TObject(),
+ TNamed("AliHLTReadoutList", "Readout list object used for manipulating and storing an AliHLTEventDDL structure."),
fReadoutList()
{
// Default constructor.
AliHLTReadoutList::AliHLTReadoutList(Int_t enabledDetectors) :
- TObject(),
+ TNamed("AliHLTReadoutList", "Readout list object used for manipulating and storing an AliHLTEventDDL structure."),
fReadoutList()
{
// Constructor to select which detectors to enable for readout.
AliHLTReadoutList::AliHLTReadoutList(const char* enabledList) :
- TObject(),
+ TNamed("AliHLTReadoutList", "Readout list object used for manipulating and storing an AliHLTEventDDL structure."),
fReadoutList()
{
// Constructor to select which detectors and DDLs to enable for readout.
AliHLTReadoutList::AliHLTReadoutList(const AliHLTEventDDL& list) :
- TObject(),
+ TNamed("AliHLTReadoutList", "Readout list object used for manipulating and storing an AliHLTEventDDL structure."),
fReadoutList()
{
// Constructor to create readout list from AliHLTEventDDL structure.
AliHLTReadoutList::AliHLTReadoutList(const AliHLTReadoutList& list) :
- TObject(list),
+ TNamed(list),
fReadoutList()
{
// Copy constructor performs a deep copy.