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),
47 // Default constructor sets pointers to NULL.
51 AliHLTTrigger::~AliHLTTrigger()
53 // Default destructor.
57 void AliHLTTrigger::GetInputDataTypes(AliHLTComponentDataTypeList& list) const
59 // Returns the kAliHLTAnyDataType type as input.
60 list.push_back(kAliHLTAnyDataType);
64 void AliHLTTrigger::GetOutputDataTypes(AliHLTComponentDataTypeList& list) const
66 // Returns the kAliHLTDataTypeTriggerDecision type as output.
67 list.push_back(kAliHLTDataTypeTriggerDecision);
71 void AliHLTTrigger::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
73 // Returns output data size estimate.
74 // See header file for more details.
76 // Matthias 2009-07-03 this is presumably to small as the streamed object might be
77 // bigger. This is actually the case in root v5-24-00
78 // Just take 2x the size of the object
79 constBase = 2*sizeof(AliHLTTriggerDecision);
84 int AliHLTTrigger::DoEvent(const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData)
86 // Sets the pointers to the evtData and trigData, then calls the DoTrigger to
87 // execute the actual trigger algorithm.
89 fEventData = &evtData;
90 fTriggerData = &trigData;
91 fDecisionMade = false;
92 fTriggerEventResult = 0;
93 // Reset the description, readout list and trigger domain used by TriggerEvent
94 // if requested to do so.
99 fTriggerDomain.Clear();
102 int result = DoTrigger();
103 if (result != 0) return result;
105 // Fill in a default decision of false if none was made.
106 if (not fDecisionMade)
114 return fTriggerEventResult;
118 int AliHLTTrigger::TriggerEvent(bool value)
120 // Sets the trigger decision for the current event.
121 // See header file for more details.
123 if (fTriggerEventResult != 0) return fTriggerEventResult; // Do not do anything if a previous call failed.
124 AliHLTTriggerDecision triggerResult(value, GetTriggerName(), fTriggerDomain, fDescription);
125 // Append the readout list if it contains anything.
126 triggerResult.TriggerDomain().Add(fReadoutList);
127 return TriggerEvent(&triggerResult, kAliHLTDataTypeTriggerDecision);
131 int AliHLTTrigger::TriggerEvent(
132 AliHLTTriggerDecision* result, const AliHLTComponentDataType& type,
136 // Sets a custom trigger decision for the current event.
137 // See header file for more details.
139 if (fTriggerEventResult != 0) return fTriggerEventResult; // Do not do anything if a previous call failed.
141 AliHLTReadoutList readoutlist = result->ReadoutList();
143 fTriggerEventResult = PushBack(result, type, spec);
144 if (fTriggerEventResult == 0) {
145 fTriggerEventResult = PushBack(readoutlist.Buffer(), readoutlist.BufferSize(), kAliHLTDataTypeReadoutList);
148 if (fTriggerEventResult == 0) fDecisionMade = true;
149 return fTriggerEventResult;
153 void AliHLTTrigger::GetInputDataTypes(AliHLTComponentDataTypeList& list)
155 // Calls the const version of this method.
157 // Assign to const temporary variable to make sure we call the constant version
158 // of the GetOutputDataTypes method.
159 const AliHLTTrigger* t = this;
160 t->GetInputDataTypes(list);
164 int AliHLTTrigger::GetOutputDataTypes(AliHLTComponentDataTypeList& list)
166 // Calls the const version of this method.
168 // Assign to const temporary variable to make sure we call the constant version
169 // of the GetOutputDataTypes method.
170 const AliHLTTrigger* t = this;
171 t->GetOutputDataTypes(list);
172 list.push_back(kAliHLTDataTypeReadoutList);
176 int AliHLTTrigger::CreateEventDoneReadoutFilter(const AliHLTTriggerDomain& domain, unsigned type)
178 // add a readout filter to the EventDoneData
180 unsigned nofEntries=0;
184 /* monitoring filter */
186 nofEntries=domain.GetNofEntries();
188 /* monitoring event command */
192 HLTError("unknown event done data command code 0x%08x", type);
197 // 1 word for the filter command: readout filter, monitoring filter, monitoring event
198 // 1 word for the readout filter size
199 // 4*n words for the filter list
200 if ((iResult=ReserveEventDoneData((nofEntries*4 + 2) * sizeof(AliHLTUInt32_t)))<0) return iResult;
201 AliHLTUInt32_t eddbuffer[4];
203 // add the specific command
205 if ((iResult=PushEventDoneData(eddbuffer[0]))<0) return iResult;
207 // find the valid entries
209 vector<const AliHLTDomainEntry*> entries;
210 for (block=0; block<nofEntries; block++) {
211 // skip all DAQ readout entries as they are handled by the readout list
212 // 2009-12-03: this turned out to cause a bug, since all blocks with data type
213 // id 'any' will also match this condition. In fact, it is not necessary to
214 // filter the entries, disable this condition. Code can be cleaned up later
215 // if this schema has been established and tested
216 // https://savannah.cern.ch/bugs/index.php?60082
217 //if (domain[block]==AliHLTDomainEntry(kAliHLTDataTypeDAQRDOUT)) continue;
218 if (domain[block].Exclusive()) {
219 // 2009-12-03 comment out that warning for the moment
220 // there are suddenly exclusive entries in the list
221 // https://savannah.cern.ch/bugs/index.php?60083
222 //HLTWarning("exclusive trigger domain entries are currently not handled, skipping entry %s", domain[block].AsString().Data());
225 entries.push_back(&(domain[block]));
228 // add the number of blocks if not monitoring event command
230 eddbuffer[0]=entries.size();
231 if ((iResult=PushEventDoneData(eddbuffer[0]))<0) return iResult;
234 for (vector<const AliHLTDomainEntry*>::iterator entry=entries.begin();
235 entry!=entries.end(); entry++) {
236 (*entry)->AsBinary(eddbuffer);
237 for (int n=0; n<4; n++)
238 if ((iResult=PushEventDoneData(eddbuffer[n]))<0) return iResult;