]>
Commit | Line | Data |
---|---|---|
7e914051 | 1 | // $Id$ |
ff2f0f94 | 2 | |
892210c7 | 3 | //************************************************************************** |
4 | //* This file is property of and copyright by the ALICE HLT Project * | |
5 | //* ALICE Experiment at CERN, All rights reserved. * | |
6 | //* * | |
7 | //* Primary Authors: Timm Steinbeck <timm@kip.uni-heidelberg.de> * | |
8 | //* for The ALICE HLT Project. * | |
9 | //* * | |
10 | //* Permission to use, copy, modify and distribute this software and its * | |
11 | //* documentation strictly for non-commercial purposes is hereby granted * | |
12 | //* without fee, provided that the above copyright notice appears in all * | |
13 | //* copies and that both the copyright notice and this permission notice * | |
14 | //* appear in the supporting documentation. The authors make no claims * | |
15 | //* about the suitability of this software for any purpose. It is * | |
16 | //* provided "as is" without express or implied warranty. * | |
17 | //************************************************************************** | |
ff2f0f94 | 18 | |
19 | /** @file AliHLTTPCCompModelConverterComponent.cxx | |
20 | @author Timm Steinbeck | |
21 | @author changed by J. Wagner | |
22 | @date 17-11-2007 | |
23 | @brief A copy processing component for the HLT. */ | |
24 | ||
25 | #if __GNUC__ >= 3 | |
26 | using namespace std; | |
27 | #endif | |
28 | ||
29 | #include "AliHLTTPCCompModelConverterComponent.h" | |
30 | #include "AliHLTTPCDefinitions.h" | |
31 | //#include "AliHLTTPCCompModelAnalysis.h" | |
32 | #include <errno.h> | |
892210c7 | 33 | /** An implementiation of a converter component that |
34 | * takes in clusters and tracks in the standard HLT format | |
35 | * and converts them into the Vestbo-format | |
36 | * such that the Vestbo compression can then be | |
37 | * applied to these tracks and clusters | |
38 | */ | |
ff2f0f94 | 39 | |
40 | // this is a global object used for automatic component registration, do not use this | |
41 | AliHLTTPCCompModelConverterComponent gAliHLTTPCCompClusterModelConverterComponent; | |
42 | ||
43 | ClassImp(AliHLTTPCCompModelConverterComponent) | |
44 | ||
45 | AliHLTTPCCompModelConverterComponent::AliHLTTPCCompModelConverterComponent() : | |
46 | fConverter(NULL), | |
47 | fModelAnalysisInstance(NULL), | |
48 | fDumpFileName(), | |
49 | fGraphFileName(), | |
50 | fModelAnalysis(0), | |
51 | fTrackAnalysis(0), | |
52 | fFillingFirstTrackArray(0) | |
53 | { | |
54 | // see header file for class documentation | |
55 | } | |
56 | ||
57 | AliHLTTPCCompModelConverterComponent::~AliHLTTPCCompModelConverterComponent() | |
58 | { | |
59 | // see header file for class documentation | |
60 | } | |
61 | ||
62 | const char* AliHLTTPCCompModelConverterComponent::GetComponentID() | |
63 | { | |
64 | // see header file for class documentation | |
65 | return "TPCCompModelConverter"; // The ID of this component | |
66 | } | |
67 | ||
68 | void AliHLTTPCCompModelConverterComponent::GetInputDataTypes( vector<AliHLTComponent_DataType>& list) | |
69 | { | |
70 | // see header file for class documentation | |
71 | list.clear(); // We do not have any requirements for our input data type(s). | |
72 | list.push_back( AliHLTTPCDefinitions::fgkClustersDataType ); | |
73 | list.push_back( AliHLTTPCDefinitions::fgkTracksDataType ); | |
74 | } | |
75 | ||
76 | AliHLTComponent_DataType AliHLTTPCCompModelConverterComponent::GetOutputDataType() | |
77 | { | |
78 | // see header file for class documentation | |
79 | return AliHLTTPCDefinitions::fgkClusterTracksModelDataType; | |
80 | } | |
81 | ||
82 | void AliHLTTPCCompModelConverterComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) | |
83 | { | |
84 | // see header file for class documentation | |
85 | constBase = 4+4+216; // Format versions + 1 byte per patch | |
86 | inputMultiplier = 4.; | |
87 | //#warning Adapt input Multiplier to something more realistic | |
88 | } | |
89 | ||
90 | // Spawn function, return new instance of this class | |
91 | AliHLTComponent* AliHLTTPCCompModelConverterComponent::Spawn() | |
92 | { | |
93 | // see header file for class documentation | |
94 | return new AliHLTTPCCompModelConverterComponent; | |
95 | }; | |
96 | ||
97 | int AliHLTTPCCompModelConverterComponent::DoInit( int argc, const char** argv ) | |
98 | { | |
99 | // see header file for class documentation | |
100 | Int_t i = 0; | |
101 | // get input argument either -modelanalysis or -trackanalysis | |
102 | while(i < argc) | |
103 | { | |
104 | if ( !strcmp( argv[i], "-modelanalysis" ) ) | |
105 | { | |
106 | fModelAnalysis = 1; | |
107 | HLTInfo("Model analysis starting."); | |
108 | ++i; | |
109 | continue; | |
110 | } | |
111 | ||
112 | ||
113 | if ( !strcmp( argv[i], "-trackanalysis" ) ) | |
114 | { | |
115 | fTrackAnalysis = 1; | |
116 | fFillingFirstTrackArray = 1; | |
117 | HLTInfo("Tracking analysis starting."); | |
118 | ++i; | |
119 | continue; | |
120 | } | |
121 | ||
122 | if ( !strcmp( argv[i], "-dumptofile" ) ) | |
123 | { | |
124 | ||
125 | //check if any analysis has been specified (otherwise -dumptofile makes no sense!) | |
126 | if(!fTrackAnalysis && !fModelAnalysis) | |
127 | { | |
128 | HLTError("Dump to file called without any model analysis specified."); | |
129 | return EINVAL; | |
130 | } | |
131 | ||
132 | // read in filename (including path) | |
133 | if ( argc <= i+1 ) | |
134 | { | |
135 | HLTError("Missing filename to write analysis results"); | |
136 | return ENOTSUP; | |
137 | } | |
138 | ||
139 | fDumpFileName = argv[i+1]; | |
140 | HLTInfo("File name of dump file for results set to %s.", fDumpFileName.Data()); | |
141 | ++i; | |
142 | ++i; | |
143 | continue; | |
144 | } | |
145 | ||
146 | // specify if graphical output is wanted (histograms, saved in a root file) | |
147 | if ( !strcmp( argv[i], "-graphs" ) ) | |
148 | { | |
149 | ||
150 | //check if any analysis has been specified (otherwise -graphs makes no sense!) | |
151 | if(!fTrackAnalysis && !fModelAnalysis) | |
152 | { | |
153 | HLTError("Creation of histgrams called without any model analysis specified."); | |
154 | return EINVAL; | |
155 | } | |
156 | ||
157 | // read in filename (including path like /afsuser/johndoe/TrackModelHistograms.root) | |
158 | if ( argc <= i+1 ) | |
159 | { | |
160 | HLTError("Missing filename to write histograms"); | |
161 | return ENOTSUP; | |
162 | } | |
163 | ||
164 | fGraphFileName = argv[i+1]; | |
165 | HLTInfo("File name of file for graphical results set to %s.", fGraphFileName.Data()); | |
166 | ++i; | |
167 | ++i; | |
168 | continue; | |
169 | } | |
170 | ||
171 | HLTError("Unknown Option '%s'", argv[i] ); | |
172 | return EINVAL; | |
173 | ||
174 | } | |
175 | ||
176 | // start new analysis by intialising respective arrays | |
177 | if(fModelAnalysis || fTrackAnalysis) | |
178 | { | |
179 | fModelAnalysisInstance = new AliHLTTPCCompModelAnalysis(fModelAnalysis, fTrackAnalysis, fDumpFileName, fGraphFileName); | |
180 | fModelAnalysisInstance->Init(); | |
181 | fConverter = new AliHLTTPCCompModelConverter(fModelAnalysisInstance); | |
182 | ||
183 | if(fModelAnalysis) | |
184 | { | |
185 | HLTInfo("Model Analysis initiated, calculating loss due to convertion to Vestbo-Model."); | |
186 | } | |
187 | else | |
188 | { | |
189 | HLTInfo("Track Analysis initiated, showing influence of Vestbo-Model on tracking."); | |
190 | } | |
191 | } | |
192 | else | |
193 | { | |
194 | fConverter = new AliHLTTPCCompModelConverter(); | |
195 | } | |
196 | ||
197 | /*if ( argc ) | |
198 | { | |
199 | Logging( kHLTLogDebug, "HLT::TPCCompModelConverter::DoInit", "Arguments", "argv[0] == %s", argv[0] ); | |
200 | Logging(kHLTLogError, "HLT::TPCCompModelConverter::DoInit", "Unknown Option", "Unknown option '%s'", argv[0] ); | |
201 | return EINVAL; | |
202 | }*/ | |
203 | ||
204 | return 0; | |
205 | } | |
206 | ||
207 | int AliHLTTPCCompModelConverterComponent::DoDeinit() | |
208 | { | |
209 | // see header file for class documentation | |
210 | // display results | |
211 | if(fModelAnalysisInstance) | |
212 | { | |
213 | fModelAnalysisInstance->DisplayResults(); | |
214 | ||
215 | delete fModelAnalysisInstance; | |
216 | fModelAnalysisInstance = NULL; | |
217 | }; | |
218 | ||
219 | if(fConverter) | |
220 | { | |
221 | delete fConverter; | |
222 | fConverter = NULL; | |
223 | } | |
224 | ||
225 | return 0; | |
226 | } | |
227 | ||
228 | int AliHLTTPCCompModelConverterComponent::DoEvent( const AliHLTComponent_EventData& evtData, const AliHLTComponent_BlockData* blocks, | |
229 | AliHLTComponent_TriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, | |
230 | AliHLTUInt32_t& size, vector<AliHLTComponent_BlockData>& outputBlocks ) | |
231 | { | |
232 | // see header file for class documentation | |
233 | fConverter->Init(); | |
234 | // Process an event | |
235 | // Loop over all input blocks in the event | |
236 | AliHLTUInt8_t minSlice=0xFF, maxSlice=0xFF, minPatch=0xFF, maxPatch=0xFF; | |
237 | for ( unsigned long n = 0; n < evtData.fBlockCnt; n++ ) | |
238 | { | |
5eefc803 | 239 | AliHLTUInt8_t slice = 0; |
240 | AliHLTUInt8_t patch = 0; | |
241 | ||
ff2f0f94 | 242 | if ( blocks[n].fDataType == AliHLTTPCDefinitions::fgkClustersDataType || |
243 | blocks[n].fDataType == AliHLTTPCDefinitions::fgkTracksDataType ) | |
244 | { | |
245 | slice = AliHLTTPCDefinitions::GetMinSliceNr( blocks[n].fSpecification ); | |
246 | patch = AliHLTTPCDefinitions::GetMinPatchNr( blocks[n].fSpecification ); | |
247 | if ( minSlice==0xFF || slice<minSlice ) | |
248 | minSlice = slice; | |
249 | if ( maxSlice==0xFF || slice>maxSlice ) | |
250 | maxSlice = slice; | |
251 | if ( minPatch==0xFF || patch<minPatch ) | |
252 | minPatch = patch; | |
253 | if ( maxPatch==0xFF || patch>maxPatch ) | |
254 | maxPatch = patch; | |
255 | } | |
256 | if ( blocks[n].fDataType == AliHLTTPCDefinitions::fgkClustersDataType ) | |
257 | { | |
258 | fConverter->SetInputClusters( (AliHLTTPCClusterData*)blocks[n].fPtr, slice, patch ); | |
259 | } | |
260 | if ( blocks[n].fDataType == AliHLTTPCDefinitions::fgkTracksDataType ) | |
261 | { | |
262 | fConverter->SetInputTracks( (AliHLTTPCTrackletData*)blocks[n].fPtr ); | |
263 | ||
264 | // if track analysis is desired, fill tracklets into track arrays of ModelAnalysis class to be compared | |
265 | if(fTrackAnalysis) | |
266 | { | |
267 | fModelAnalysisInstance->SetTracks((AliHLTTPCTrackletData*)blocks[n].fPtr, fFillingFirstTrackArray); | |
268 | ||
269 | // set flag for filling first array to zero --> second array is filled then | |
270 | fFillingFirstTrackArray = 0; | |
271 | } | |
272 | } | |
273 | } | |
274 | ||
275 | if(fTrackAnalysis) | |
276 | { | |
277 | if(fModelAnalysis == 0) // stop processing if not required | |
278 | return 0; | |
279 | }; | |
280 | ||
281 | fConverter->Convert(); | |
282 | ||
283 | unsigned long outputSize = fConverter->GetOutputModelDataSize(); | |
284 | if ( outputSize> size ) | |
285 | { | |
286 | HLTError( "Not enough output memory size for clusters&tracks model data. %lu needed", | |
287 | outputSize ); | |
288 | return ENOBUFS; | |
289 | } | |
290 | ||
291 | fConverter->OutputModelData( outputPtr ); | |
292 | ||
293 | AliHLTComponent_BlockData ob; | |
294 | // Let the structure be filled with the default values. | |
295 | // This takes care of setting the shared memory and data type values to default values, | |
296 | // so that they can be filled in by the calling code. | |
297 | FillBlockData( ob ); | |
298 | // This block's start (offset) is after all other blocks written so far | |
299 | ob.fOffset = 0; | |
300 | // the size of this block's data. | |
301 | ob.fSize = outputSize; | |
302 | // The specification of the data is copied from the input block. | |
303 | ob.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( minSlice, maxSlice, minPatch, maxPatch ); | |
304 | // The type of the data is copied from the input block. | |
305 | ob.fDataType = AliHLTTPCDefinitions::fgkClusterTracksModelDataType; | |
306 | // Place this block into the list of output blocks | |
307 | outputBlocks.push_back( ob ); | |
308 | ||
309 | outputPtr += ob.fSize; | |
310 | ||
311 | if ( outputSize+fConverter->GetRemainingClustersOutputDataSize()>size ) | |
312 | { | |
313 | HLTError( "Not enough output memory size for remaining clusters model data. %lu needed in total (clusters&tracks + rem. clusters)", | |
314 | outputSize+fConverter->GetRemainingClustersOutputDataSize() ); | |
315 | return ENOBUFS; | |
316 | } | |
317 | unsigned long clusterSize = size-outputSize; | |
318 | printf( "clusterSize0: %lu\n", clusterSize ); | |
319 | fConverter->GetRemainingClusters( outputPtr, clusterSize ); | |
320 | printf( "clusterSize1: %lu\n", clusterSize ); | |
321 | ||
322 | FillBlockData( ob ); | |
323 | // This block's start (offset) is after all other blocks written so far | |
324 | ob.fOffset = outputSize; | |
325 | // the size of this block's data. | |
326 | ob.fSize = clusterSize; | |
327 | // The specification of the data is copied from the input block. | |
328 | ob.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( minSlice, maxSlice, minPatch, maxPatch ); | |
329 | // The type of the data is copied from the input block. | |
330 | ob.fDataType = AliHLTTPCDefinitions::fgkRemainingClustersModelDataType; | |
331 | // Place this block into the list of output blocks | |
332 | outputBlocks.push_back( ob ); | |
333 | ||
334 | outputSize += ob.fSize; | |
335 | ||
336 | // Finally we set the total size of output memory we consumed. | |
337 | size = outputSize; | |
338 | return 0; | |
339 | } |