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"
32 ClassImp(AliHLTTrigger)
35 AliHLTTrigger::AliHLTTrigger() :
41 fTriggerEventResult(0),
46 // Default constructor sets pointers to NULL.
50 AliHLTTrigger::~AliHLTTrigger()
52 // Default destructor.
56 void AliHLTTrigger::GetInputDataTypes(AliHLTComponentDataTypeList& list) const
58 // Returns the kAliHLTAnyDataType type as input.
59 list.push_back(kAliHLTAnyDataType);
63 void AliHLTTrigger::GetOutputDataTypes(AliHLTComponentDataTypeList& list) const
65 // Returns the kAliHLTDataTypeTriggerDecision type as output.
66 list.push_back(kAliHLTDataTypeTriggerDecision);
70 void AliHLTTrigger::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
72 // Returns output data size estimate.
73 // See header file for more details.
75 // Matthias 2009-07-03 this is presumably to small as the streamed object might be
76 // bigger. This is actually the case in root v5-24-00
77 // Just take 2x the size of the object
78 constBase = 2*sizeof(AliHLTTriggerDecision);
83 int AliHLTTrigger::DoEvent(const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData)
85 // Sets the pointers to the evtData and trigData, then calls the DoTrigger to
86 // execute the actual trigger algorithm.
88 fEventData = &evtData;
89 fTriggerData = &trigData;
90 fDecisionMade = false;
91 fTriggerEventResult = 0;
92 // Reset the description, readout list and trigger domain used by TriggerEvent
93 // if requested to do so.
98 fTriggerDomain.Clear();
101 int result = DoTrigger();
102 if (result != 0) return result;
104 // Fill in a default decision of false if none was made.
105 if (not fDecisionMade)
113 return fTriggerEventResult;
117 int AliHLTTrigger::TriggerEvent(bool value)
119 // Sets the trigger decision for the current event.
120 // See header file for more details.
122 if (fTriggerEventResult != 0) return fTriggerEventResult; // Do not do anything if a previous call failed.
123 AliHLTTriggerDecision triggerResult(value, GetTriggerName(), fTriggerDomain, fDescription);
124 // Append the readout list if it contains anything.
125 triggerResult.TriggerDomain().Add(fReadoutList);
126 return TriggerEvent(&triggerResult, kAliHLTDataTypeTObject|kAliHLTDataOriginOut);
130 int AliHLTTrigger::TriggerEvent(
131 AliHLTTriggerDecision* result, const AliHLTComponentDataType& type,
135 // Sets a custom trigger decision for the current event.
136 // See header file for more details.
138 if (fTriggerEventResult != 0) return fTriggerEventResult; // Do not do anything if a previous call failed.
139 fTriggerEventResult = PushBack(result, type, spec);
140 if (fTriggerEventResult == 0) {
141 fTriggerEventResult = PushBack(result->ReadoutList().Buffer(), result->ReadoutList().BufferSize(), kAliHLTDataTypeReadoutList);
144 if (fTriggerEventResult == 0) fDecisionMade = true;
145 return fTriggerEventResult;
149 void AliHLTTrigger::GetInputDataTypes(AliHLTComponentDataTypeList& list)
151 // Calls the const version of this method.
153 // Assign to const temporary variable to make sure we call the constant version
154 // of the GetOutputDataTypes method.
155 const AliHLTTrigger* t = this;
156 t->GetInputDataTypes(list);
160 int AliHLTTrigger::GetOutputDataTypes(AliHLTComponentDataTypeList& list)
162 // Calls the const version of this method.
164 // Assign to const temporary variable to make sure we call the constant version
165 // of the GetOutputDataTypes method.
166 const AliHLTTrigger* t = this;
167 t->GetOutputDataTypes(list);
168 list.push_back(kAliHLTDataTypeReadoutList);
172 int AliHLTTrigger::CreateEventDoneReadoutFilter(const AliHLTTriggerDomain& domain, unsigned type)
174 // add a readout filter to the EventDoneData
176 unsigned nofEntries=domain.GetNofEntries();
178 // 1 word eventually for the monitor event command
179 // 1 word for the readout filter command
180 // 1 word for the readout filter size
181 // 4*n words for the filter list
182 if ((iResult=ReserveEventDoneData((nofEntries*4 + 3) * sizeof(AliHLTUInt32_t)))<0) return iResult;
183 AliHLTUInt32_t eddbuffer[4];
185 // in the case of the monitoring filter we also add the monitor event command
187 if ((iResult=PushEventDoneData(eddbuffer[0]))<0) return iResult;
190 // now the readout list command and the block count
192 if ((iResult=PushEventDoneData(eddbuffer[0]))<0) return iResult;
194 // find the valid entries
196 vector<const AliHLTDomainEntry*> entries;
197 for (block=0; block<nofEntries; block++) {
198 // skip all DAQ readout entries as they are handled by the readout list
199 if (domain[block]==AliHLTDomainEntry(kAliHLTDataTypeDAQRDOUT)) continue;
200 if (domain[block].Exclusive()) {
201 HLTWarning("exclusive trigger domain entries are currently not handled, skipping entry %s", domain[block].AsString().Data());
204 entries.push_back(&(domain[block]));
206 eddbuffer[0]=entries.size();
207 if ((iResult=PushEventDoneData(eddbuffer[0]))<0) return iResult;
209 for (vector<const AliHLTDomainEntry*>::iterator entry=entries.begin();
210 entry!=entries.end(); entry++) {
211 (*entry)->AsBinary(eddbuffer);
212 for (int n=0; n<4; n++)
213 if ((iResult=PushEventDoneData(eddbuffer[n]))<0) return iResult;