]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/comp/AliHLTTPCCompModelDeconverterComponent.cxx
bugfix: missing function implemented; next strike against warnings
[u/mrichter/AliRoot.git] / HLT / TPCLib / comp / AliHLTTPCCompModelDeconverterComponent.cxx
1 // $Id$
2
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 //**************************************************************************
18
19 /** @file   AliHLTTPCCompModelDeconverterComponent.cxx
20     @author Timm Steinbeck
21     @date   
22     @brief  A copy processing component for the HLT. */
23
24 #if __GNUC__ >= 3
25 using namespace std;
26 #endif
27
28 #include "AliHLTTPCCompModelDeconverterComponent.h"
29 #include "AliHLTTPCDefinitions.h"
30 #include <stdlib.h>
31 #include <errno.h>
32
33 /**
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 
39  */
40
41 // this is a global object used for automatic component registration, do not use this
42 AliHLTTPCCompModelDeconverterComponent gAliHLTTPCCompClusterModelDeconverterComponent;
43
44 ClassImp(AliHLTTPCCompModelDeconverterComponent)
45     
46 AliHLTTPCCompModelDeconverterComponent::AliHLTTPCCompModelDeconverterComponent():
47   fDeconverter(),
48   fOutputTracks(kTRUE)
49     {
50       // see header file for class documentation
51     }
52
53 AliHLTTPCCompModelDeconverterComponent::~AliHLTTPCCompModelDeconverterComponent()
54     {
55       // see header file for class documentation
56     }
57
58 const char* AliHLTTPCCompModelDeconverterComponent::GetComponentID()
59     {
60       // see header file for class documentation
61       return "TPCCompModelDeconverter"; // The ID of this component
62     }
63
64 void AliHLTTPCCompModelDeconverterComponent::GetInputDataTypes( vector<AliHLTComponent_DataType>& list)
65     {
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 );
70     }
71
72 AliHLTComponent_DataType AliHLTTPCCompModelDeconverterComponent::GetOutputDataType()
73     {
74       // see header file for class documentation
75       return AliHLTTPCDefinitions::fgkClustersDataType;
76     }
77
78 void AliHLTTPCCompModelDeconverterComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
79     {
80       // see header file for class documentation
81       constBase = 8+216*4; // Track count + clusters count
82       inputMultiplier = 4.;
83 #warning Adapt input Multiplier to something more realistic
84     }
85
86 // Spawn function, return new instance of this class
87 AliHLTComponent* AliHLTTPCCompModelDeconverterComponent::Spawn()
88     {
89       // see header file for class documentation
90       return new AliHLTTPCCompModelDeconverterComponent;
91     };
92
93 int AliHLTTPCCompModelDeconverterComponent::DoInit( int argc, const char** argv )
94     {
95       // see header file for class documentation
96       Int_t i = 0;
97       //Char_t* cpErr;
98       
99       while ( i < argc )
100         {      
101           if ( !strcmp( argv[i], "notracks" ) )
102             {
103               fOutputTracks = kFALSE;
104               ++i;
105               continue;
106             }
107           Logging(kHLTLogError, "HLT::TPCCompModelDeconverter::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] );
108           return EINVAL;
109         }
110       return 0;
111     }
112
113 int AliHLTTPCCompModelDeconverterComponent::DoDeinit()
114     {
115       // see header file for class documentation
116       return 0;
117     }
118
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 )
122     {
123       // see header file for class documentation
124       fDeconverter.Init();
125       // Process an event
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++ )
129         {
130           AliHLTUInt8_t slice, patch;
131           if ( blocks[n].fDataType == AliHLTTPCDefinitions::fgkRemainingClustersModelDataType ||
132                blocks[n].fDataType == AliHLTTPCDefinitions::fgkClusterTracksModelDataType )
133             {
134               slice = AliHLTTPCDefinitions::GetMinSliceNr( blocks[n].fSpecification );
135               patch = AliHLTTPCDefinitions::GetMinPatchNr( blocks[n].fSpecification );
136               if ( minSlice==0xFF || slice<minSlice )
137                 minSlice = slice;
138               if ( maxSlice==0xFF || slice>maxSlice )
139                 maxSlice = slice;
140               if ( minPatch==0xFF || patch<minPatch )
141                 minPatch = patch;
142               if ( maxPatch==0xFF || patch>maxPatch )
143                 maxPatch = patch;
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 )
148                 minSlice = slice;
149               if ( maxSlice==0xFF || slice>maxSlice )
150                 maxSlice = slice;
151               if ( minPatch==0xFF || patch<minPatch )
152                 minPatch = patch;
153               if ( maxPatch==0xFF || patch>maxPatch )
154                 maxPatch = patch;
155               HLTDebug( "Slice: %u - Patch: %u", (unsigned)slice, (unsigned)patch );
156             }
157           if ( blocks[n].fDataType == AliHLTTPCDefinitions::fgkClusterTracksModelDataType )
158             {
159               HLTDebug( "Tracks" );
160               fDeconverter.SetTrackClusterModelInputData( (AliHLTUInt8_t*)blocks[n].fPtr, blocks[n].fSize );
161             }
162           if ( blocks[n].fDataType == AliHLTTPCDefinitions::fgkRemainingClustersModelDataType )
163             {
164               HLTDebug( "Clusters" );
165               fDeconverter.SetRemainingClustersModelInputData( (AliHLTUInt8_t*)blocks[n].fPtr, blocks[n].fSize );
166             }
167         }
168       
169       HLTDebug( "min slice: %u - max slice: %u - min patch: %u - max patch: %u",
170                 (unsigned)minSlice, (unsigned)maxSlice, (unsigned)minPatch, (unsigned)maxPatch );
171       
172       UInt_t blockSize = size;
173       UInt_t outputSize = 0;
174       Int_t ret;
175       if ( fOutputTracks )
176         {
177           ret = fDeconverter.DeconvertTracks( outputPtr, blockSize );
178           if ( !ret )
179             {
180               if ( outputSize+blockSize > size )
181                 {
182                   HLTError( "Output data too large. (%lu used instead of %u available)",
183                             (unsigned long)blockSize, (unsigned long)size );
184                   return ENOBUFS;
185                 }
186               
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.
191               FillBlockData( ob );
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;
203             }
204           else
205             HLTError( "Error deconverting tracks: %s (%d)", strerror(ret), (int)ret );
206         }
207       
208       for ( UInt_t slice=minSlice; slice<=maxSlice; slice++ )
209         {
210           for ( UInt_t patch=minPatch; patch<=maxPatch; patch++ )
211             {
212               blockSize = size-outputSize;
213               ret = fDeconverter.DeconvertClusters( slice, patch, outputPtr+outputSize, blockSize );
214               if ( !ret )
215                 {
216                   if ( outputSize+blockSize > size )
217                     {
218                       HLTError( "Output data too large. (%lu used instead of %u available)",
219                                 (unsigned long)blockSize, (unsigned long)size );
220                       return ENOBUFS;
221                     }
222                   
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.
227                   FillBlockData( ob );
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;
239                 }
240               else
241                 HLTError( "Error deconverting clusters for slice %u, patch %u: %s (%d)", 
242                           (unsigned)slice, (unsigned)patch, strerror(ret), (int)ret );
243             }
244         }
245       
246       // Finally we set the total size of output memory we consumed.
247       size = outputSize;
248       return 0;
249     }