3 /**************************************************************************
4 * TPCCompModelConverterright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
6 * Authors: Timm Steinbeck <timm@kip.uni-heidelberg.de> *
7 * for The ALICE Off-line 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 AliHLTTPCCompModelConverterComponent.cxx
19 @author Timm Steinbeck
20 @author changed by J. Wagner
22 @brief A copy processing component for the HLT. */
28 #include "AliHLTTPCCompModelConverterComponent.h"
29 #include "AliHLTTPCDefinitions.h"
30 //#include "AliHLTTPCCompModelAnalysis.h"
33 // this is a global object used for automatic component registration, do not use this
34 AliHLTTPCCompModelConverterComponent gAliHLTTPCCompClusterModelConverterComponent;
36 ClassImp(AliHLTTPCCompModelConverterComponent)
38 AliHLTTPCCompModelConverterComponent::AliHLTTPCCompModelConverterComponent() :
40 fModelAnalysisInstance(NULL),
45 fFillingFirstTrackArray(0)
47 // see header file for class documentation
50 AliHLTTPCCompModelConverterComponent::~AliHLTTPCCompModelConverterComponent()
52 // see header file for class documentation
55 const char* AliHLTTPCCompModelConverterComponent::GetComponentID()
57 // see header file for class documentation
58 return "TPCCompModelConverter"; // The ID of this component
61 void AliHLTTPCCompModelConverterComponent::GetInputDataTypes( vector<AliHLTComponent_DataType>& list)
63 // see header file for class documentation
64 list.clear(); // We do not have any requirements for our input data type(s).
65 list.push_back( AliHLTTPCDefinitions::fgkClustersDataType );
66 list.push_back( AliHLTTPCDefinitions::fgkTracksDataType );
69 AliHLTComponent_DataType AliHLTTPCCompModelConverterComponent::GetOutputDataType()
71 // see header file for class documentation
72 return AliHLTTPCDefinitions::fgkClusterTracksModelDataType;
75 void AliHLTTPCCompModelConverterComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
77 // see header file for class documentation
78 constBase = 4+4+216; // Format versions + 1 byte per patch
80 //#warning Adapt input Multiplier to something more realistic
83 // Spawn function, return new instance of this class
84 AliHLTComponent* AliHLTTPCCompModelConverterComponent::Spawn()
86 // see header file for class documentation
87 return new AliHLTTPCCompModelConverterComponent;
90 int AliHLTTPCCompModelConverterComponent::DoInit( int argc, const char** argv )
92 // see header file for class documentation
94 // get input argument either -modelanalysis or -trackanalysis
97 if ( !strcmp( argv[i], "-modelanalysis" ) )
100 HLTInfo("Model analysis starting.");
106 if ( !strcmp( argv[i], "-trackanalysis" ) )
109 fFillingFirstTrackArray = 1;
110 HLTInfo("Tracking analysis starting.");
115 if ( !strcmp( argv[i], "-dumptofile" ) )
118 //check if any analysis has been specified (otherwise -dumptofile makes no sense!)
119 if(!fTrackAnalysis && !fModelAnalysis)
121 HLTError("Dump to file called without any model analysis specified.");
125 // read in filename (including path)
128 HLTError("Missing filename to write analysis results");
132 fDumpFileName = argv[i+1];
133 HLTInfo("File name of dump file for results set to %s.", fDumpFileName.Data());
139 // specify if graphical output is wanted (histograms, saved in a root file)
140 if ( !strcmp( argv[i], "-graphs" ) )
143 //check if any analysis has been specified (otherwise -graphs makes no sense!)
144 if(!fTrackAnalysis && !fModelAnalysis)
146 HLTError("Creation of histgrams called without any model analysis specified.");
150 // read in filename (including path like /afsuser/johndoe/TrackModelHistograms.root)
153 HLTError("Missing filename to write histograms");
157 fGraphFileName = argv[i+1];
158 HLTInfo("File name of file for graphical results set to %s.", fGraphFileName.Data());
164 HLTError("Unknown Option '%s'", argv[i] );
169 // start new analysis by intialising respective arrays
170 if(fModelAnalysis || fTrackAnalysis)
172 fModelAnalysisInstance = new AliHLTTPCCompModelAnalysis(fModelAnalysis, fTrackAnalysis, fDumpFileName, fGraphFileName);
173 fModelAnalysisInstance->Init();
174 fConverter = new AliHLTTPCCompModelConverter(fModelAnalysisInstance);
178 HLTInfo("Model Analysis initiated, calculating loss due to convertion to Vestbo-Model.");
182 HLTInfo("Track Analysis initiated, showing influence of Vestbo-Model on tracking.");
187 fConverter = new AliHLTTPCCompModelConverter();
192 Logging( kHLTLogDebug, "HLT::TPCCompModelConverter::DoInit", "Arguments", "argv[0] == %s", argv[0] );
193 Logging(kHLTLogError, "HLT::TPCCompModelConverter::DoInit", "Unknown Option", "Unknown option '%s'", argv[0] );
200 int AliHLTTPCCompModelConverterComponent::DoDeinit()
202 // see header file for class documentation
204 if(fModelAnalysisInstance)
206 fModelAnalysisInstance->DisplayResults();
208 delete fModelAnalysisInstance;
209 fModelAnalysisInstance = NULL;
221 int AliHLTTPCCompModelConverterComponent::DoEvent( const AliHLTComponent_EventData& evtData, const AliHLTComponent_BlockData* blocks,
222 AliHLTComponent_TriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr,
223 AliHLTUInt32_t& size, vector<AliHLTComponent_BlockData>& outputBlocks )
225 // see header file for class documentation
228 // Loop over all input blocks in the event
229 AliHLTUInt8_t minSlice=0xFF, maxSlice=0xFF, minPatch=0xFF, maxPatch=0xFF;
230 for ( unsigned long n = 0; n < evtData.fBlockCnt; n++ )
232 AliHLTUInt8_t slice, patch;
233 if ( blocks[n].fDataType == AliHLTTPCDefinitions::fgkClustersDataType ||
234 blocks[n].fDataType == AliHLTTPCDefinitions::fgkTracksDataType )
236 slice = AliHLTTPCDefinitions::GetMinSliceNr( blocks[n].fSpecification );
237 patch = AliHLTTPCDefinitions::GetMinPatchNr( blocks[n].fSpecification );
238 if ( minSlice==0xFF || slice<minSlice )
240 if ( maxSlice==0xFF || slice>maxSlice )
242 if ( minPatch==0xFF || patch<minPatch )
244 if ( maxPatch==0xFF || patch>maxPatch )
247 if ( blocks[n].fDataType == AliHLTTPCDefinitions::fgkClustersDataType )
249 fConverter->SetInputClusters( (AliHLTTPCClusterData*)blocks[n].fPtr, slice, patch );
251 if ( blocks[n].fDataType == AliHLTTPCDefinitions::fgkTracksDataType )
253 fConverter->SetInputTracks( (AliHLTTPCTrackletData*)blocks[n].fPtr );
255 // if track analysis is desired, fill tracklets into track arrays of ModelAnalysis class to be compared
258 fModelAnalysisInstance->SetTracks((AliHLTTPCTrackletData*)blocks[n].fPtr, fFillingFirstTrackArray);
260 // set flag for filling first array to zero --> second array is filled then
261 fFillingFirstTrackArray = 0;
268 if(fModelAnalysis == 0) // stop processing if not required
272 fConverter->Convert();
274 unsigned long outputSize = fConverter->GetOutputModelDataSize();
275 if ( outputSize> size )
277 HLTError( "Not enough output memory size for clusters&tracks model data. %lu needed",
282 fConverter->OutputModelData( outputPtr );
284 AliHLTComponent_BlockData ob;
285 // Let the structure be filled with the default values.
286 // This takes care of setting the shared memory and data type values to default values,
287 // so that they can be filled in by the calling code.
289 // This block's start (offset) is after all other blocks written so far
291 // the size of this block's data.
292 ob.fSize = outputSize;
293 // The specification of the data is copied from the input block.
294 ob.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( minSlice, maxSlice, minPatch, maxPatch );
295 // The type of the data is copied from the input block.
296 ob.fDataType = AliHLTTPCDefinitions::fgkClusterTracksModelDataType;
297 // Place this block into the list of output blocks
298 outputBlocks.push_back( ob );
300 outputPtr += ob.fSize;
302 if ( outputSize+fConverter->GetRemainingClustersOutputDataSize()>size )
304 HLTError( "Not enough output memory size for remaining clusters model data. %lu needed in total (clusters&tracks + rem. clusters)",
305 outputSize+fConverter->GetRemainingClustersOutputDataSize() );
308 unsigned long clusterSize = size-outputSize;
309 printf( "clusterSize0: %lu\n", clusterSize );
310 fConverter->GetRemainingClusters( outputPtr, clusterSize );
311 printf( "clusterSize1: %lu\n", clusterSize );
314 // This block's start (offset) is after all other blocks written so far
315 ob.fOffset = outputSize;
316 // the size of this block's data.
317 ob.fSize = clusterSize;
318 // The specification of the data is copied from the input block.
319 ob.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( minSlice, maxSlice, minPatch, maxPatch );
320 // The type of the data is copied from the input block.
321 ob.fDataType = AliHLTTPCDefinitions::fgkRemainingClustersModelDataType;
322 // Place this block into the list of output blocks
323 outputBlocks.push_back( ob );
325 outputSize += ob.fSize;
327 // Finally we set the total size of output memory we consumed.