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 AliHLTTPCCompModelDeconverterComponent.cxx
20 @author Timm Steinbeck
22 @brief A copy processing component for the HLT. */
28 #include "AliHLTTPCCompModelDeconverterComponent.h"
29 #include "AliHLTTPCDefinitions.h"
34 * An implementiation of a deconverter component that
35 * deconverts the tracks and clusters from the Vestbo-model
36 * into the standard HLT cluster track format again
37 * in order to evaluate the loss of the model
38 * due to the Vestbo-compression
41 // this is a global object used for automatic component registration, do not use this
42 AliHLTTPCCompModelDeconverterComponent gAliHLTTPCCompClusterModelDeconverterComponent;
44 ClassImp(AliHLTTPCCompModelDeconverterComponent)
46 AliHLTTPCCompModelDeconverterComponent::AliHLTTPCCompModelDeconverterComponent():
50 // see header file for class documentation
53 AliHLTTPCCompModelDeconverterComponent::~AliHLTTPCCompModelDeconverterComponent()
55 // see header file for class documentation
58 const char* AliHLTTPCCompModelDeconverterComponent::GetComponentID()
60 // see header file for class documentation
61 return "TPCCompModelDeconverter"; // The ID of this component
64 void AliHLTTPCCompModelDeconverterComponent::GetInputDataTypes( vector<AliHLTComponent_DataType>& list)
66 // see header file for class documentation
67 list.clear(); // We do not have any requirements for our input data type(s).
68 list.push_back( AliHLTTPCDefinitions::fgkClusterTracksModelDataType );
69 list.push_back( AliHLTTPCDefinitions::fgkRemainingClustersModelDataType );
72 AliHLTComponent_DataType AliHLTTPCCompModelDeconverterComponent::GetOutputDataType()
74 // see header file for class documentation
75 return AliHLTTPCDefinitions::fgkClustersDataType;
78 void AliHLTTPCCompModelDeconverterComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
80 // see header file for class documentation
81 constBase = 8+216*4; // Track count + clusters count
83 #warning Adapt input Multiplier to something more realistic
86 // Spawn function, return new instance of this class
87 AliHLTComponent* AliHLTTPCCompModelDeconverterComponent::Spawn()
89 // see header file for class documentation
90 return new AliHLTTPCCompModelDeconverterComponent;
93 int AliHLTTPCCompModelDeconverterComponent::DoInit( int argc, const char** argv )
95 // see header file for class documentation
101 if ( !strcmp( argv[i], "notracks" ) )
103 fOutputTracks = kFALSE;
107 Logging(kHLTLogError, "HLT::TPCCompModelDeconverter::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] );
113 int AliHLTTPCCompModelDeconverterComponent::DoDeinit()
115 // see header file for class documentation
119 int AliHLTTPCCompModelDeconverterComponent::DoEvent( const AliHLTComponent_EventData& evtData, const AliHLTComponent_BlockData* blocks,
120 AliHLTComponent_TriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr,
121 AliHLTUInt32_t& size, vector<AliHLTComponent_BlockData>& outputBlocks )
123 // see header file for class documentation
126 // Loop over all input blocks in the event
127 AliHLTUInt8_t minSlice=0xFF, maxSlice=0xFF, minPatch=0xFF, maxPatch=0xFF;
128 for ( unsigned long n = 0; n < evtData.fBlockCnt; n++ )
130 AliHLTUInt8_t slice, patch;
131 if ( blocks[n].fDataType == AliHLTTPCDefinitions::fgkRemainingClustersModelDataType ||
132 blocks[n].fDataType == AliHLTTPCDefinitions::fgkClusterTracksModelDataType )
134 slice = AliHLTTPCDefinitions::GetMinSliceNr( blocks[n].fSpecification );
135 patch = AliHLTTPCDefinitions::GetMinPatchNr( blocks[n].fSpecification );
136 if ( minSlice==0xFF || slice<minSlice )
138 if ( maxSlice==0xFF || slice>maxSlice )
140 if ( minPatch==0xFF || patch<minPatch )
142 if ( maxPatch==0xFF || patch>maxPatch )
144 HLTDebug( "Slice: %u - Patch: %u", (unsigned)slice, (unsigned)patch );
145 slice = AliHLTTPCDefinitions::GetMaxSliceNr( blocks[n].fSpecification );
146 patch = AliHLTTPCDefinitions::GetMaxPatchNr( blocks[n].fSpecification );
147 if ( minSlice==0xFF || slice<minSlice )
149 if ( maxSlice==0xFF || slice>maxSlice )
151 if ( minPatch==0xFF || patch<minPatch )
153 if ( maxPatch==0xFF || patch>maxPatch )
155 HLTDebug( "Slice: %u - Patch: %u", (unsigned)slice, (unsigned)patch );
157 if ( blocks[n].fDataType == AliHLTTPCDefinitions::fgkClusterTracksModelDataType )
159 HLTDebug( "Tracks" );
160 fDeconverter.SetTrackClusterModelInputData( (AliHLTUInt8_t*)blocks[n].fPtr, blocks[n].fSize );
162 if ( blocks[n].fDataType == AliHLTTPCDefinitions::fgkRemainingClustersModelDataType )
164 HLTDebug( "Clusters" );
165 fDeconverter.SetRemainingClustersModelInputData( (AliHLTUInt8_t*)blocks[n].fPtr, blocks[n].fSize );
169 HLTDebug( "min slice: %u - max slice: %u - min patch: %u - max patch: %u",
170 (unsigned)minSlice, (unsigned)maxSlice, (unsigned)minPatch, (unsigned)maxPatch );
172 UInt_t blockSize = size;
173 UInt_t outputSize = 0;
177 ret = fDeconverter.DeconvertTracks( outputPtr, blockSize );
180 if ( outputSize+blockSize > size )
182 HLTError( "Output data too large. (%lu used instead of %u available)",
183 (unsigned long)blockSize, (unsigned long)size );
187 AliHLTComponent_BlockData ob;
188 // Let the structure be filled with the default values.
189 // This takes care of setting the shared memory and data type values to default values,
190 // so that they can be filled in by the calling code.
192 // This block's start (offset) is after all other blocks written so far
193 ob.fOffset = outputSize;
194 // the size of this block's data.
195 ob.fSize = blockSize;
196 // The specification of the data is copied from the input block.
197 ob.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( minSlice, maxSlice, minPatch, maxPatch );
198 // The type of the data is copied from the input block.
199 ob.fDataType = AliHLTTPCDefinitions::fgkTracksDataType;
200 // Place this block into the list of output blocks
201 outputBlocks.push_back( ob );
202 outputSize += blockSize;
205 HLTError( "Error deconverting tracks: %s (%d)", strerror(ret), (int)ret );
208 for ( UInt_t slice=minSlice; slice<=maxSlice; slice++ )
210 for ( UInt_t patch=minPatch; patch<=maxPatch; patch++ )
212 blockSize = size-outputSize;
213 ret = fDeconverter.DeconvertClusters( slice, patch, outputPtr+outputSize, blockSize );
216 if ( outputSize+blockSize > size )
218 HLTError( "Output data too large. (%lu used instead of %u available)",
219 (unsigned long)blockSize, (unsigned long)size );
223 AliHLTComponent_BlockData ob;
224 // Let the structure be filled with the default values.
225 // This takes care of setting the shared memory and data type values to default values,
226 // so that they can be filled in by the calling code.
228 // This block's start (offset) is after all other blocks written so far
229 ob.fOffset = outputSize;
230 // the size of this block's data.
231 ob.fSize = blockSize;
232 // The specification of the data is copied from the input block.
233 ob.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, patch, patch );
234 // The type of the data is copied from the input block.
235 ob.fDataType = AliHLTTPCDefinitions::fgkClustersDataType;
236 // Place this block into the list of output blocks
237 outputBlocks.push_back( ob );
238 outputSize += blockSize;
241 HLTError( "Error deconverting clusters for slice %u, patch %u: %s (%d)",
242 (unsigned)slice, (unsigned)patch, strerror(ret), (int)ret );
246 // Finally we set the total size of output memory we consumed.