3 //**************************************************************************
4 //* This file is property of and copyright by the ALICE HLT Project *
5 //* ALICE Experiment at CERN, All rights reserved. *
7 //* Primary Authors: Timm Steinbeck <timm@kip.uni-heidelberg.de> *
8 //* for The ALICE HLT Project. *
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 //**************************************************************************
19 /** @file AliHLTTPCCompModelConverterComponent.cxx
20 @author Timm Steinbeck
21 @author changed by J. Wagner
23 @brief A copy processing component for the HLT. */
29 #include "AliHLTTPCCompModelConverterComponent.h"
30 #include "AliHLTTPCDefinitions.h"
31 //#include "AliHLTTPCCompModelAnalysis.h"
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
40 /** ROOT macro for the implementation of ROOT specific class methods */
41 ClassImp(AliHLTTPCCompModelConverterComponent)
43 AliHLTTPCCompModelConverterComponent::AliHLTTPCCompModelConverterComponent() :
45 fModelAnalysisInstance(NULL),
50 fFillingFirstTrackArray(0)
52 // see header file for class documentation
55 AliHLTTPCCompModelConverterComponent::~AliHLTTPCCompModelConverterComponent()
57 // see header file for class documentation
60 const char* AliHLTTPCCompModelConverterComponent::GetComponentID()
62 // see header file for class documentation
63 return "TPCCompModelConverter"; // The ID of this component
66 void AliHLTTPCCompModelConverterComponent::GetInputDataTypes( vector<AliHLTComponent_DataType>& list)
68 // see header file for class documentation
69 list.clear(); // We do not have any requirements for our input data type(s).
70 list.push_back( AliHLTTPCDefinitions::fgkClustersDataType );
71 list.push_back( AliHLTTPCDefinitions::fgkTracksDataType );
74 AliHLTComponent_DataType AliHLTTPCCompModelConverterComponent::GetOutputDataType()
76 // see header file for class documentation
77 return AliHLTTPCDefinitions::fgkClusterTracksModelDataType;
80 void AliHLTTPCCompModelConverterComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
82 // see header file for class documentation
83 constBase = 4+4+216; // Format versions + 1 byte per patch
85 //#warning Adapt input Multiplier to something more realistic
88 // Spawn function, return new instance of this class
89 AliHLTComponent* AliHLTTPCCompModelConverterComponent::Spawn()
91 // see header file for class documentation
92 return new AliHLTTPCCompModelConverterComponent;
95 int AliHLTTPCCompModelConverterComponent::DoInit( int argc, const char** argv )
97 // see header file for class documentation
99 // get input argument either -modelanalysis or -trackanalysis
102 if ( !strcmp( argv[i], "-modelanalysis" ) )
105 HLTInfo("Model analysis starting.");
111 if ( !strcmp( argv[i], "-trackanalysis" ) )
114 fFillingFirstTrackArray = 1;
115 HLTInfo("Tracking analysis starting.");
120 if ( !strcmp( argv[i], "-dumptofile" ) )
123 //check if any analysis has been specified (otherwise -dumptofile makes no sense!)
124 if(!fTrackAnalysis && !fModelAnalysis)
126 HLTError("Dump to file called without any model analysis specified.");
130 // read in filename (including path)
133 HLTError("Missing filename to write analysis results");
137 fDumpFileName = argv[i+1];
138 HLTInfo("File name of dump file for results set to %s.", fDumpFileName.Data());
144 // specify if graphical output is wanted (histograms, saved in a root file)
145 if ( !strcmp( argv[i], "-graphs" ) )
148 //check if any analysis has been specified (otherwise -graphs makes no sense!)
149 if(!fTrackAnalysis && !fModelAnalysis)
151 HLTError("Creation of histgrams called without any model analysis specified.");
155 // read in filename (including path like /afsuser/johndoe/TrackModelHistograms.root)
158 HLTError("Missing filename to write histograms");
162 fGraphFileName = argv[i+1];
163 HLTInfo("File name of file for graphical results set to %s.", fGraphFileName.Data());
169 HLTError("Unknown Option '%s'", argv[i] );
174 // start new analysis by intialising respective arrays
175 if(fModelAnalysis || fTrackAnalysis)
177 fModelAnalysisInstance = new AliHLTTPCCompModelAnalysis(fModelAnalysis, fTrackAnalysis, fDumpFileName, fGraphFileName);
178 fModelAnalysisInstance->Init();
179 fConverter = new AliHLTTPCCompModelConverter(fModelAnalysisInstance);
183 HLTInfo("Model Analysis initiated, calculating loss due to convertion to Vestbo-Model.");
187 HLTInfo("Track Analysis initiated, showing influence of Vestbo-Model on tracking.");
192 fConverter = new AliHLTTPCCompModelConverter();
197 Logging( kHLTLogDebug, "HLT::TPCCompModelConverter::DoInit", "Arguments", "argv[0] == %s", argv[0] );
198 Logging(kHLTLogError, "HLT::TPCCompModelConverter::DoInit", "Unknown Option", "Unknown option '%s'", argv[0] );
205 int AliHLTTPCCompModelConverterComponent::DoDeinit()
207 // see header file for class documentation
209 if(fModelAnalysisInstance)
211 fModelAnalysisInstance->DisplayResults();
213 delete fModelAnalysisInstance;
214 fModelAnalysisInstance = NULL;
226 int AliHLTTPCCompModelConverterComponent::DoEvent( const AliHLTComponent_EventData& evtData, const AliHLTComponent_BlockData* blocks,
227 AliHLTComponent_TriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr,
228 AliHLTUInt32_t& size, vector<AliHLTComponent_BlockData>& outputBlocks )
230 // see header file for class documentation
233 // Loop over all input blocks in the event
234 AliHLTUInt8_t minSlice=0xFF, maxSlice=0xFF, minPatch=0xFF, maxPatch=0xFF;
235 for ( unsigned long n = 0; n < evtData.fBlockCnt; n++ )
237 AliHLTUInt8_t slice = 0;
238 AliHLTUInt8_t patch = 0;
240 if ( blocks[n].fDataType == AliHLTTPCDefinitions::fgkClustersDataType ||
241 blocks[n].fDataType == AliHLTTPCDefinitions::fgkTracksDataType )
243 slice = AliHLTTPCDefinitions::GetMinSliceNr( blocks[n].fSpecification );
244 patch = AliHLTTPCDefinitions::GetMinPatchNr( blocks[n].fSpecification );
245 if ( minSlice==0xFF || slice<minSlice )
247 if ( maxSlice==0xFF || slice>maxSlice )
249 if ( minPatch==0xFF || patch<minPatch )
251 if ( maxPatch==0xFF || patch>maxPatch )
254 if ( blocks[n].fDataType == AliHLTTPCDefinitions::fgkClustersDataType )
256 fConverter->SetInputClusters( (AliHLTTPCClusterData*)blocks[n].fPtr, slice, patch );
258 if ( blocks[n].fDataType == AliHLTTPCDefinitions::fgkTracksDataType )
260 fConverter->SetInputTracks( (AliHLTTPCTrackletData*)blocks[n].fPtr );
262 // if track analysis is desired, fill tracklets into track arrays of ModelAnalysis class to be compared
265 fModelAnalysisInstance->SetTracks((AliHLTTPCTrackletData*)blocks[n].fPtr, fFillingFirstTrackArray);
267 // set flag for filling first array to zero --> second array is filled then
268 fFillingFirstTrackArray = 0;
275 if(fModelAnalysis == 0) // stop processing if not required
279 fConverter->Convert();
281 unsigned long outputSize = fConverter->GetOutputModelDataSize();
282 if ( outputSize> size )
284 HLTError( "Not enough output memory size for clusters&tracks model data. %lu needed",
289 fConverter->OutputModelData( outputPtr );
291 AliHLTComponent_BlockData ob;
292 // Let the structure be filled with the default values.
293 // This takes care of setting the shared memory and data type values to default values,
294 // so that they can be filled in by the calling code.
296 // This block's start (offset) is after all other blocks written so far
298 // the size of this block's data.
299 ob.fSize = outputSize;
300 // The specification of the data is copied from the input block.
301 ob.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( minSlice, maxSlice, minPatch, maxPatch );
302 // The type of the data is copied from the input block.
303 ob.fDataType = AliHLTTPCDefinitions::fgkClusterTracksModelDataType;
304 // Place this block into the list of output blocks
305 outputBlocks.push_back( ob );
307 outputPtr += ob.fSize;
309 if ( outputSize+fConverter->GetRemainingClustersOutputDataSize()>size )
311 HLTError( "Not enough output memory size for remaining clusters model data. %lu needed in total (clusters&tracks + rem. clusters)",
312 outputSize+fConverter->GetRemainingClustersOutputDataSize() );
315 unsigned long clusterSize = size-outputSize;
316 printf( "clusterSize0: %lu\n", clusterSize );
317 fConverter->GetRemainingClusters( outputPtr, clusterSize );
318 printf( "clusterSize1: %lu\n", clusterSize );
321 // This block's start (offset) is after all other blocks written so far
322 ob.fOffset = outputSize;
323 // the size of this block's data.
324 ob.fSize = clusterSize;
325 // The specification of the data is copied from the input block.
326 ob.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( minSlice, maxSlice, minPatch, maxPatch );
327 // The type of the data is copied from the input block.
328 ob.fDataType = AliHLTTPCDefinitions::fgkRemainingClustersModelDataType;
329 // Place this block into the list of output blocks
330 outputBlocks.push_back( ob );
332 outputSize += ob.fSize;
334 // Finally we set the total size of output memory we consumed.