]>
Commit | Line | Data |
---|---|---|
0528e93a | 1 | /************************************************************************** |
2 | * This file is property of and copyright by the ALICE HLT Project * | |
3 | * All rights reserved. * | |
4 | * * | |
5 | * Primary Authors: * | |
6 | * Artur Szostak <artursz@iafrica.com> * | |
7 | * * | |
8 | * Permission to use, copy, modify and distribute this software and its * | |
9 | * documentation strictly for non-commercial purposes is hereby granted * | |
10 | * without fee, provided that the above copyright notice appears in all * | |
11 | * copies and that both the copyright notice and this permission notice * | |
12 | * appear in the supporting documentation. The authors make no claims * | |
13 | * about the suitability of this software for any purpose. It is * | |
14 | * provided "as is" without express or implied warranty. * | |
15 | **************************************************************************/ | |
16 | ||
17 | /* $Id$ */ | |
18 | ||
19 | /// | |
20 | /// @file AliHLTMUONEmptyEventFilterComponent.cxx | |
21 | /// @author Artur Szostak <artursz@iafrica.com> | |
22 | /// @date 2007-12-12 | |
23 | /// @brief Implementation of the empty event filter component. | |
24 | /// | |
25 | /// This component is used to forward events for where there is at least one | |
26 | /// non-empty dHLT data block. | |
27 | /// | |
28 | ||
29 | #include "AliHLTMUONEmptyEventFilterComponent.h" | |
0528e93a | 30 | #include "AliHLTMUONConstants.h" |
31 | #include "AliHLTLogging.h" | |
32 | #include "AliHLTSystem.h" | |
33 | #include "AliHLTDefinitions.h" | |
34 | #include <cstdlib> | |
35 | #include <cerrno> | |
36 | #include <cassert> | |
37 | ||
38 | ClassImp(AliHLTMUONEmptyEventFilterComponent) | |
39 | ||
40 | ||
41 | AliHLTMUONEmptyEventFilterComponent::AliHLTMUONEmptyEventFilterComponent() : | |
154cba94 | 42 | AliHLTMUONProcessor(), |
0528e93a | 43 | fSendOnEmpty(false) |
44 | { | |
45 | /// | |
46 | /// Default constructor. | |
47 | /// | |
48 | } | |
49 | ||
50 | ||
51 | AliHLTMUONEmptyEventFilterComponent::~AliHLTMUONEmptyEventFilterComponent() | |
52 | { | |
53 | /// | |
54 | /// Default destructor. | |
55 | /// | |
56 | } | |
57 | ||
58 | const char* AliHLTMUONEmptyEventFilterComponent::GetComponentID() | |
59 | { | |
60 | /// | |
61 | /// Inherited from AliHLTComponent. Returns the component ID. | |
62 | /// | |
63 | ||
64 | return AliHLTMUONConstants::EmptyEventFilterComponentId(); | |
65 | } | |
66 | ||
67 | ||
ffb64d3e | 68 | void AliHLTMUONEmptyEventFilterComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list) |
0528e93a | 69 | { |
70 | /// | |
71 | /// Inherited from AliHLTProcessor. Returns the list of expected input data types. | |
72 | /// At the moment this list is "any data type" since it is not known before | |
73 | /// hand what kind of input blocks we will get. | |
74 | ||
75 | assert( list.empty() ); | |
76 | list.push_back( kAliHLTAnyDataType ); | |
77 | } | |
78 | ||
79 | ||
80 | AliHLTComponentDataType AliHLTMUONEmptyEventFilterComponent::GetOutputDataType() | |
81 | { | |
82 | /// | |
83 | /// Inherited from AliHLTComponent. Returns the output data type of | |
84 | /// "any data type" with MUON origin. | |
85 | ||
86 | return kAliHLTAnyDataType | kAliHLTDataOriginMUON; | |
87 | } | |
88 | ||
89 | ||
90 | void AliHLTMUONEmptyEventFilterComponent::GetOutputDataSize( | |
91 | unsigned long& constBase, double& inputMultiplier | |
92 | ) | |
93 | { | |
94 | /// | |
95 | /// Inherited from AliHLTComponent. | |
96 | /// Returns an estimate of the expected output data size. | |
97 | ||
98 | // Both of these are zero because we will only ever pass on input data blocks | |
99 | // and never generate data in this component. | |
100 | constBase = 0; | |
101 | inputMultiplier = 0; | |
102 | } | |
103 | ||
104 | ||
105 | AliHLTComponent* AliHLTMUONEmptyEventFilterComponent::Spawn() | |
106 | { | |
107 | /// | |
108 | /// Inherited from AliHLTComponent. Creates a new object instance. | |
109 | /// | |
110 | ||
111 | return new AliHLTMUONEmptyEventFilterComponent; | |
112 | } | |
113 | ||
114 | ||
ffb64d3e | 115 | bool AliHLTMUONEmptyEventFilterComponent::IgnoreArgument(const char* arg) const |
116 | { | |
117 | /// Return true if the argument is one of -cdbpath -run or -delaysetup | |
118 | /// to prevent the parent class from parsing these arguments in DoInit. | |
119 | ||
558cf470 | 120 | if (strcmp(arg, "-cdbpath") == 0 or strcmp(arg, "-run") == 0 or |
121 | strcmp(arg, "-delaysetup") == 0) | |
ffb64d3e | 122 | { |
123 | return true; | |
124 | } | |
125 | else | |
126 | { | |
127 | return false; | |
128 | } | |
129 | } | |
130 | ||
131 | ||
0528e93a | 132 | int AliHLTMUONEmptyEventFilterComponent::DoInit(int argc, const char** argv) |
133 | { | |
134 | /// | |
135 | /// Inherited from AliHLTComponent. | |
136 | /// Parses the command line parameters and initialises the component. | |
137 | /// | |
138 | ||
ffb64d3e | 139 | HLTInfo("Initialising dHLT event filter component."); |
140 | ||
141 | // Inherit the parents functionality. | |
142 | int result = AliHLTMUONProcessor::DoInit(argc, argv); | |
143 | if (result != 0) return result; | |
144 | ||
0528e93a | 145 | fSendOnEmpty = false; // Set to the default value. |
146 | ||
147 | for (int i = 0; i < argc; i++) | |
148 | { | |
ffb64d3e | 149 | if (ArgumentAlreadyHandled(i, argv[i])) continue; |
150 | ||
0528e93a | 151 | if (strcmp(argv[i], "-sendempty") == 0) |
152 | { | |
153 | fSendOnEmpty = true; | |
154 | HLTInfo("Turning on anti-filtering. Will be passing all data on empty dHLT results."); | |
155 | continue; | |
156 | } | |
157 | ||
158 | HLTError("Unknown option '%s'.", argv[i]); | |
432fff31 | 159 | return -EINVAL; |
0528e93a | 160 | } |
161 | ||
162 | return 0; | |
163 | } | |
164 | ||
165 | ||
166 | int AliHLTMUONEmptyEventFilterComponent::DoDeinit() | |
167 | { | |
168 | /// | |
169 | /// Inherited from AliHLTComponent. Performs a cleanup of the component. | |
170 | /// | |
ffb64d3e | 171 | |
172 | HLTInfo("Deinitialising dHLT event filter component."); | |
0528e93a | 173 | |
174 | return 0; | |
175 | } | |
176 | ||
177 | ||
178 | int AliHLTMUONEmptyEventFilterComponent::DoEvent( | |
179 | const AliHLTComponentEventData& evtData, | |
180 | const AliHLTComponentBlockData* blocks, | |
ffb64d3e | 181 | AliHLTComponentTriggerData& trigData, |
182 | AliHLTUInt8_t* outputPtr, | |
0528e93a | 183 | AliHLTUInt32_t& size, |
ffb64d3e | 184 | AliHLTComponentBlockDataList& outputBlocks |
0528e93a | 185 | ) |
186 | { | |
187 | /// Inherited from AliHLTProcessor. Processes the new event data. | |
188 | /// Here we go through the list of input data blocks looking for blocks | |
189 | /// containing dHLT results. If all of these blocks are empty then we | |
190 | /// mark the event for filtering. | |
191 | /// What we actually do with the whole event will depend on the fSendOnEmpty | |
192 | /// flag. If it is set to false (the default) then we will copy all the | |
193 | /// input data blocks to output if the dHLT results were NOT empty. | |
194 | /// If fSendOnEmpty is true then we will copy all the input data blocks | |
195 | /// to the output if the dHLT results ARE empty. | |
196 | ||
197 | HLTDebug("Processing event %llu with %u input data blocks.", | |
198 | evtData.fEventID, evtData.fBlockCnt | |
199 | ); | |
200 | ||
201 | bool emptyEvent = true; | |
202 | ||
203 | for (AliHLTUInt32_t n = 0; n < evtData.fBlockCnt; n++) | |
204 | { | |
154cba94 | 205 | HLTDebug("Handling block: %u, with fDataType = '%s', fPtr = %p and fSize = %u bytes.", |
432fff31 | 206 | n, DataType2Text(blocks[n].fDataType).c_str(), blocks[n].fPtr, blocks[n].fSize |
0528e93a | 207 | ); |
208 | ||
209 | if (blocks[n].fDataType == AliHLTMUONConstants::TriggerRecordsBlockDataType()) | |
210 | { | |
211 | AliHLTMUONTriggerRecordsBlockReader inblock(blocks[n].fPtr, blocks[n].fSize); | |
ffb64d3e | 212 | if (not BlockStructureOk(inblock)) |
213 | { | |
214 | if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks); | |
215 | continue; | |
216 | } | |
0528e93a | 217 | if (inblock.Nentries() != 0) emptyEvent = false; |
218 | } | |
219 | else if (blocks[n].fDataType == AliHLTMUONConstants::RecHitsBlockDataType()) | |
220 | { | |
221 | AliHLTMUONRecHitsBlockReader inblock(blocks[n].fPtr, blocks[n].fSize); | |
ffb64d3e | 222 | if (not BlockStructureOk(inblock)) |
223 | { | |
224 | if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks); | |
225 | continue; | |
226 | } | |
0528e93a | 227 | if (inblock.Nentries() != 0) emptyEvent = false; |
228 | } | |
229 | else if (blocks[n].fDataType == AliHLTMUONConstants::MansoTracksBlockDataType()) | |
230 | { | |
231 | AliHLTMUONMansoTracksBlockReader inblock(blocks[n].fPtr, blocks[n].fSize); | |
ffb64d3e | 232 | if (not BlockStructureOk(inblock)) |
233 | { | |
234 | if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks); | |
235 | continue; | |
236 | } | |
0528e93a | 237 | if (inblock.Nentries() != 0) emptyEvent = false; |
238 | } | |
239 | else if (blocks[n].fDataType == AliHLTMUONConstants::SinglesDecisionBlockDataType()) | |
240 | { | |
241 | AliHLTMUONSinglesDecisionBlockReader inblock(blocks[n].fPtr, blocks[n].fSize); | |
ffb64d3e | 242 | if (not BlockStructureOk(inblock)) |
243 | { | |
244 | if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks); | |
245 | continue; | |
246 | } | |
0528e93a | 247 | if (inblock.Nentries() != 0) emptyEvent = false; |
248 | } | |
249 | else if (blocks[n].fDataType == AliHLTMUONConstants::PairsDecisionBlockDataType()) | |
250 | { | |
251 | AliHLTMUONPairsDecisionBlockReader inblock(blocks[n].fPtr, blocks[n].fSize); | |
ffb64d3e | 252 | if (not BlockStructureOk(inblock)) |
253 | { | |
254 | if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks); | |
255 | continue; | |
256 | } | |
0528e93a | 257 | if (inblock.Nentries() != 0) emptyEvent = false; |
258 | } | |
259 | } | |
260 | ||
261 | // If we are filtering or required to send only empty events then | |
262 | // copy all the input blocks to the output. | |
263 | if (emptyEvent and fSendOnEmpty or not emptyEvent and not fSendOnEmpty) | |
264 | { | |
265 | for (AliHLTUInt32_t n = 0; n < evtData.fBlockCnt; n++) | |
266 | { | |
267 | outputBlocks.push_back(blocks[n]); | |
268 | } | |
269 | } | |
270 | ||
271 | // Finally we set the total size of output memory we consumed which is | |
272 | // zero since we just copied the input descriptors to output if anything. | |
273 | size = 0; | |
274 | return 0; | |
275 | } | |
276 |