2 /**************************************************************************
3 * This file is property of and copyright by the ALICE HLT Project *
4 * ALICE Experiment at CERN, All rights reserved. *
6 * Primary Authors: Artur Szostak <artursz@iafrica.com> *
7 * for The ALICE HLT Project. *
9 * Permission to use, copy, modify and distribute this software and its *
10 * documentation strictly for non-commercial purposes is hereby granted *
11 * without fee, provided that the above copyright notice appears in all *
12 * copies and that both the copyright notice and this permission notice *
13 * appear in the supporting documentation. The authors make no claims *
14 * about the suitability of this software for any purpose. It is *
15 * provided "as is" without express or implied warranty. *
16 **************************************************************************/
18 /// @file AliHLTTrigger.h
19 /// @author Artur Szostak <artursz@iafrica.com>
21 /// @brief Implementation of the AliHLTTrigger base component class.
23 /// The AliHLTTrigger class is the base class from which all HLT trigger components
24 /// should be derived.
26 #include "AliHLTTrigger.h"
27 #include "AliHLTTriggerDecision.h"
28 #include "AliHLTReadoutList.h"
29 #include "AliHLTTriggerDomain.h"
30 #include "AliHLTDomainEntry.h"
31 #include "AliHLTCTPData.h"
33 ClassImp(AliHLTTrigger)
36 AliHLTTrigger::AliHLTTrigger() :
42 fTriggerEventResult(0),
46 fReadoutListSpecBits(kAliHLTVoidDataSpec)
48 // Default constructor sets pointers to NULL.
52 AliHLTTrigger::~AliHLTTrigger()
54 // Default destructor.
58 void AliHLTTrigger::GetInputDataTypes(AliHLTComponentDataTypeList& list) const
60 // Returns the kAliHLTAnyDataType type as input.
61 list.push_back(kAliHLTAnyDataType);
65 void AliHLTTrigger::GetOutputDataTypes(AliHLTComponentDataTypeList& list) const
67 // Returns the kAliHLTDataTypeTriggerDecision type as output.
68 list.push_back(kAliHLTDataTypeTriggerDecision);
72 void AliHLTTrigger::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
74 // Returns output data size estimate.
75 // See header file for more details.
77 // Matthias 2009-07-03 this is presumably to small as the streamed object might be
78 // bigger. This is actually the case in root v5-24-00
79 // Just take 2x the size of the object
80 constBase = 2*sizeof(AliHLTTriggerDecision);
85 int AliHLTTrigger::DoEvent(const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData)
87 // Sets the pointers to the evtData and trigData, then calls the DoTrigger to
88 // execute the actual trigger algorithm.
90 fEventData = &evtData;
91 fTriggerData = &trigData;
92 fDecisionMade = false;
93 fTriggerEventResult = 0;
94 // Reset the description, readout list and trigger domain used by TriggerEvent
95 // if requested to do so.
100 fTriggerDomain.Clear();
103 int result = DoTrigger();
104 if (result != 0) return result;
106 // Fill in a default decision of false if none was made.
107 if (not fDecisionMade)
115 return fTriggerEventResult;
119 int AliHLTTrigger::TriggerEvent(bool value)
121 // Sets the trigger decision for the current event.
122 // See header file for more details.
124 if (fTriggerEventResult != 0) return fTriggerEventResult; // Do not do anything if a previous call failed.
125 AliHLTTriggerDecision triggerResult(value, GetTriggerName(), fTriggerDomain, fDescription);
126 // Append the readout list if it contains anything.
127 triggerResult.TriggerDomain().Add(fReadoutList);
128 return TriggerEvent(&triggerResult, kAliHLTDataTypeTriggerDecision);
132 int AliHLTTrigger::TriggerEvent(
133 AliHLTTriggerDecision* result, const AliHLTComponentDataType& type,
137 // Sets a custom trigger decision for the current event.
138 // See header file for more details.
140 if (fTriggerEventResult != 0) return fTriggerEventResult; // Do not do anything if a previous call failed.
142 AliHLTReadoutList readoutlist = result->ReadoutList();
144 fTriggerEventResult = PushBack(result, type, spec);
145 if (fTriggerEventResult == 0) {
146 fTriggerEventResult = PushBack(readoutlist.Buffer(), readoutlist.BufferSize(), kAliHLTDataTypeReadoutList, fReadoutListSpecBits);
149 if (fTriggerEventResult == 0) fDecisionMade = true;
150 return fTriggerEventResult;
154 void AliHLTTrigger::GetInputDataTypes(AliHLTComponentDataTypeList& list)
156 // Calls the const version of this method.
158 // Assign to const temporary variable to make sure we call the constant version
159 // of the GetOutputDataTypes method.
160 const AliHLTTrigger* t = this;
161 t->GetInputDataTypes(list);
165 int AliHLTTrigger::GetOutputDataTypes(AliHLTComponentDataTypeList& list)
167 // Calls the const version of this method.
169 // Assign to const temporary variable to make sure we call the constant version
170 // of the GetOutputDataTypes method.
171 const AliHLTTrigger* t = this;
172 t->GetOutputDataTypes(list);
173 list.push_back(kAliHLTDataTypeReadoutList);
177 int AliHLTTrigger::CreateEventDoneReadoutFilter(const AliHLTTriggerDomain& domain, unsigned type)
179 // add a readout filter to the EventDoneData
181 unsigned nofEntries=0;
185 /* monitoring filter */
187 nofEntries=domain.GetNofEntries();
189 /* monitoring event command */
193 HLTError("unknown event done data command code 0x%08x", type);
198 // 1 word for the filter command: readout filter, monitoring filter, monitoring event
199 // 1 word for the readout filter size
200 // 4*n words for the filter list
201 if ((iResult=ReserveEventDoneData((nofEntries*4 + 2) * sizeof(AliHLTUInt32_t)))<0) return iResult;
202 AliHLTUInt32_t eddbuffer[4];
204 // add the specific command
206 if ((iResult=PushEventDoneData(eddbuffer[0]))<0) return iResult;
208 // find the valid entries
210 vector<const AliHLTDomainEntry*> entries;
211 for (block=0; block<nofEntries; block++) {
212 // skip all DAQ readout entries as they are handled by the readout list
213 // 2009-12-03: this turned out to cause a bug, since all blocks with data type
214 // id 'any' will also match this condition. In fact, it is not necessary to
215 // filter the entries, disable this condition. Code can be cleaned up later
216 // if this schema has been established and tested
217 // https://savannah.cern.ch/bugs/index.php?60082
218 //if (domain[block]==AliHLTDomainEntry(kAliHLTDataTypeDAQRDOUT)) continue;
219 if (domain[block].Exclusive()) {
220 // 2009-12-03 comment out that warning for the moment
221 // there are suddenly exclusive entries in the list
222 // https://savannah.cern.ch/bugs/index.php?60083
223 //HLTWarning("exclusive trigger domain entries are currently not handled, skipping entry %s", domain[block].AsString().Data());
226 entries.push_back(&(domain[block]));
229 // add the number of blocks if not monitoring event command
231 eddbuffer[0]=entries.size();
232 if ((iResult=PushEventDoneData(eddbuffer[0]))<0) return iResult;
235 for (vector<const AliHLTDomainEntry*>::iterator entry=entries.begin();
236 entry!=entries.end(); entry++) {
237 (*entry)->AsBinary(eddbuffer);
238 for (int n=0; n<4; n++)
239 if ((iResult=PushEventDoneData(eddbuffer[n]))<0) return iResult;