]>
Commit | Line | Data |
---|---|---|
2974f8dc | 1 | // $Id$ |
a9670afe | 2 | /************************************************************************** |
3 | * This file is property of and copyright by the ALICE HLT Project * | |
4 | * ALICE Experiment at CERN, All rights reserved. * | |
5 | * * | |
6 | * Primary Authors: Artur Szostak <artursz@iafrica.com> * | |
7 | * for The ALICE HLT Project. * | |
8 | * * | |
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 | **************************************************************************/ | |
5a806c0e | 17 | |
1b9a175e | 18 | /// @file AliHLTTrigger.h |
19 | /// @author Artur Szostak <artursz@iafrica.com> | |
20 | /// @date 12 Aug 2008 | |
21 | /// @brief Implementation of the AliHLTTrigger base component class. | |
22 | /// | |
23 | /// The AliHLTTrigger class is the base class from which all HLT trigger components | |
24 | /// should be derived. | |
25 | ||
4aa41877 | 26 | #include "AliHLTTrigger.h" |
1b9a175e | 27 | #include "AliHLTTriggerDecision.h" |
15ede44e | 28 | #include "AliHLTReadoutList.h" |
2974f8dc | 29 | #include "AliHLTTriggerDomain.h" |
30 | #include "AliHLTDomainEntry.h" | |
2f251ae6 | 31 | #include "AliHLTCTPData.h" |
5a806c0e | 32 | |
4aa41877 | 33 | ClassImp(AliHLTTrigger) |
5a806c0e | 34 | |
5a806c0e | 35 | |
a9670afe | 36 | AliHLTTrigger::AliHLTTrigger() : |
37 | AliHLTProcessor(), | |
38 | fEventData(NULL), | |
39 | fTriggerData(NULL), | |
40 | fDecisionMade(false), | |
acc7214e | 41 | fClearInfo(true), |
4adf50d6 | 42 | fTriggerEventResult(0), |
1b9a175e | 43 | fDescription(), |
44 | fReadoutList(), | |
45 | fTriggerDomain() | |
5a806c0e | 46 | { |
5d79eb88 | 47 | // Default constructor sets pointers to NULL. |
5a806c0e | 48 | } |
49 | ||
5a806c0e | 50 | |
a9670afe | 51 | AliHLTTrigger::~AliHLTTrigger() |
5a806c0e | 52 | { |
5d79eb88 | 53 | // Default destructor. |
4adf50d6 | 54 | } |
55 | ||
56 | ||
025443e0 | 57 | void AliHLTTrigger::GetInputDataTypes(AliHLTComponentDataTypeList& list) const |
58 | { | |
59 | // Returns the kAliHLTAnyDataType type as input. | |
60 | list.push_back(kAliHLTAnyDataType); | |
61 | } | |
62 | ||
63 | ||
64 | void AliHLTTrigger::GetOutputDataTypes(AliHLTComponentDataTypeList& list) const | |
65 | { | |
66 | // Returns the kAliHLTDataTypeTriggerDecision type as output. | |
67 | list.push_back(kAliHLTDataTypeTriggerDecision); | |
68 | } | |
69 | ||
70 | ||
4adf50d6 | 71 | void AliHLTTrigger::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier) |
72 | { | |
5d79eb88 | 73 | // Returns output data size estimate. |
74 | // See header file for more details. | |
4adf50d6 | 75 | |
61074420 | 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); | |
4adf50d6 | 80 | inputMultiplier = 1; |
5a806c0e | 81 | } |
82 | ||
5a806c0e | 83 | |
a9670afe | 84 | int AliHLTTrigger::DoEvent(const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData) |
5a806c0e | 85 | { |
5d79eb88 | 86 | // Sets the pointers to the evtData and trigData, then calls the DoTrigger to |
87 | // execute the actual trigger algorithm. | |
5a806c0e | 88 | |
a9670afe | 89 | fEventData = &evtData; |
90 | fTriggerData = &trigData; | |
91 | fDecisionMade = false; | |
92 | fTriggerEventResult = 0; | |
acc7214e | 93 | // Reset the description, readout list and trigger domain used by TriggerEvent |
94 | // if requested to do so. | |
95 | if (fClearInfo) | |
96 | { | |
97 | fDescription = ""; | |
98 | fReadoutList.Clear(); | |
99 | fTriggerDomain.Clear(); | |
100 | } | |
a9670afe | 101 | |
102 | int result = DoTrigger(); | |
103 | if (result != 0) return result; | |
104 | ||
105 | // Fill in a default decision of false if none was made. | |
106 | if (not fDecisionMade) | |
107 | { | |
108 | TriggerEvent(false); | |
109 | } | |
4adf50d6 | 110 | |
a9670afe | 111 | // Cleanup |
112 | fEventData = NULL; | |
113 | fTriggerData = NULL; | |
114 | return fTriggerEventResult; | |
5a806c0e | 115 | } |
116 | ||
5a806c0e | 117 | |
4654280e | 118 | int AliHLTTrigger::TriggerEvent(bool value) |
5a806c0e | 119 | { |
5d79eb88 | 120 | // Sets the trigger decision for the current event. |
121 | // See header file for more details. | |
5a806c0e | 122 | |
4654280e | 123 | if (fTriggerEventResult != 0) return fTriggerEventResult; // Do not do anything if a previous call failed. |
52f67e50 | 124 | AliHLTTriggerDecision triggerResult(value, GetTriggerName(), fTriggerDomain, fDescription); |
8b745301 | 125 | // Append the readout list if it contains anything. |
126 | triggerResult.TriggerDomain().Add(fReadoutList); | |
72e31932 | 127 | return TriggerEvent(&triggerResult, kAliHLTDataTypeTObject|kAliHLTDataOriginOut); |
5d79eb88 | 128 | } |
129 | ||
130 | ||
4654280e | 131 | int AliHLTTrigger::TriggerEvent( |
5d79eb88 | 132 | AliHLTTriggerDecision* result, const AliHLTComponentDataType& type, |
133 | AliHLTUInt32_t spec | |
134 | ) | |
135 | { | |
136 | // Sets a custom trigger decision for the current event. | |
137 | // See header file for more details. | |
138 | ||
222238b6 | 139 | if (fTriggerEventResult != 0) return fTriggerEventResult; // Do not do anything if a previous call failed. |
140 | ||
2f251ae6 | 141 | AliHLTReadoutList readoutlist = result->ReadoutList(); |
142 | // mask the readout list according to the CTP trigger | |
143 | // if the classes have been initialized (mask non-zero) | |
144 | if (CTPData() != NULL and CTPData()->Mask() != 0x0) { | |
89413559 | 145 | AliHLTReadoutList ctpreadout = CTPData()->ReadoutList(*GetTriggerData()); |
2f251ae6 | 146 | ctpreadout.Enable(AliHLTReadoutList::kHLT); |
147 | readoutlist.AndEq(ctpreadout); | |
148 | result->ReadoutList(readoutlist); // override the readout list with the masked one. | |
149 | } | |
150 | ||
5d79eb88 | 151 | fTriggerEventResult = PushBack(result, type, spec); |
f320d378 | 152 | if (fTriggerEventResult == 0) { |
2f251ae6 | 153 | fTriggerEventResult = PushBack(readoutlist.Buffer(), readoutlist.BufferSize(), kAliHLTDataTypeReadoutList); |
15ede44e | 154 | } |
155 | ||
5d79eb88 | 156 | if (fTriggerEventResult == 0) fDecisionMade = true; |
4654280e | 157 | return fTriggerEventResult; |
5d79eb88 | 158 | } |
159 | ||
160 | ||
161 | void AliHLTTrigger::GetInputDataTypes(AliHLTComponentDataTypeList& list) | |
162 | { | |
163 | // Calls the const version of this method. | |
164 | ||
165 | // Assign to const temporary variable to make sure we call the constant version | |
166 | // of the GetOutputDataTypes method. | |
167 | const AliHLTTrigger* t = this; | |
4a0b19b6 | 168 | t->GetInputDataTypes(list); |
5d79eb88 | 169 | } |
170 | ||
171 | ||
172 | int AliHLTTrigger::GetOutputDataTypes(AliHLTComponentDataTypeList& list) | |
173 | { | |
174 | // Calls the const version of this method. | |
175 | ||
176 | // Assign to const temporary variable to make sure we call the constant version | |
177 | // of the GetOutputDataTypes method. | |
178 | const AliHLTTrigger* t = this; | |
179 | t->GetOutputDataTypes(list); | |
025443e0 | 180 | list.push_back(kAliHLTDataTypeReadoutList); |
5d79eb88 | 181 | return list.size(); |
5a806c0e | 182 | } |
183 | ||
2974f8dc | 184 | int AliHLTTrigger::CreateEventDoneReadoutFilter(const AliHLTTriggerDomain& domain, unsigned type) |
185 | { | |
186 | // add a readout filter to the EventDoneData | |
187 | int iResult=0; | |
0744f75d | 188 | unsigned nofEntries=0; |
189 | switch (type) { | |
190 | /* readout filter */ | |
191 | case 3: | |
192 | /* monitoring filter */ | |
193 | case 4: | |
194 | nofEntries=domain.GetNofEntries(); | |
195 | break; | |
196 | /* monitoring event command */ | |
197 | case 5: | |
198 | break; | |
199 | default: | |
200 | HLTError("unknown event done data command code 0x%08x", type); | |
201 | return -EINVAL; | |
202 | } | |
203 | ||
2974f8dc | 204 | // we need: |
0744f75d | 205 | // 1 word for the filter command: readout filter, monitoring filter, monitoring event |
2974f8dc | 206 | // 1 word for the readout filter size |
207 | // 4*n words for the filter list | |
0744f75d | 208 | if ((iResult=ReserveEventDoneData((nofEntries*4 + 2) * sizeof(AliHLTUInt32_t)))<0) return iResult; |
2974f8dc | 209 | AliHLTUInt32_t eddbuffer[4]; |
2974f8dc | 210 | |
0744f75d | 211 | // add the specific command |
2974f8dc | 212 | eddbuffer[0]=type; |
213 | if ((iResult=PushEventDoneData(eddbuffer[0]))<0) return iResult; | |
2974f8dc | 214 | |
7b638b2a | 215 | // find the valid entries |
216 | unsigned block=0; | |
217 | vector<const AliHLTDomainEntry*> entries; | |
218 | for (block=0; block<nofEntries; block++) { | |
2974f8dc | 219 | // skip all DAQ readout entries as they are handled by the readout list |
44568d8a | 220 | // 2009-12-03: this turned out to cause a bug, since all blocks with data type |
221 | // id 'any' will also match this condition. In fact, it is not necessary to | |
222 | // filter the entries, disable this condition. Code can be cleaned up later | |
223 | // if this schema has been established and tested | |
224 | // https://savannah.cern.ch/bugs/index.php?60082 | |
225 | //if (domain[block]==AliHLTDomainEntry(kAliHLTDataTypeDAQRDOUT)) continue; | |
2974f8dc | 226 | if (domain[block].Exclusive()) { |
44568d8a | 227 | // 2009-12-03 comment out that warning for the moment |
228 | // there are suddenly exclusive entries in the list | |
229 | // https://savannah.cern.ch/bugs/index.php?60083 | |
230 | //HLTWarning("exclusive trigger domain entries are currently not handled, skipping entry %s", domain[block].AsString().Data()); | |
2974f8dc | 231 | continue; |
232 | } | |
7b638b2a | 233 | entries.push_back(&(domain[block])); |
234 | } | |
0744f75d | 235 | |
236 | // add the number of blocks if not monitoring event command | |
237 | if (type!=5) { | |
238 | eddbuffer[0]=entries.size(); | |
239 | if ((iResult=PushEventDoneData(eddbuffer[0]))<0) return iResult; | |
240 | } | |
7b638b2a | 241 | |
242 | for (vector<const AliHLTDomainEntry*>::iterator entry=entries.begin(); | |
243 | entry!=entries.end(); entry++) { | |
244 | (*entry)->AsBinary(eddbuffer); | |
2974f8dc | 245 | for (int n=0; n<4; n++) |
246 | if ((iResult=PushEventDoneData(eddbuffer[n]))<0) return iResult; | |
247 | } | |
248 | return iResult; | |
249 | } |