]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/comp/AliHLTTPCCompModelInflaterComponent.cxx
correcting the drift time transformation; optional output of cluster id array in...
[u/mrichter/AliRoot.git] / HLT / TPCLib / comp / AliHLTTPCCompModelInflaterComponent.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   AliHLTTPCCompModelInflaterComponent.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 "AliHLTTPCCompModelInflaterComponent.h"
29 #include "AliHLTTPCDefinitions.h"
30 #include <stdlib.h>
31 #include <errno.h>
32
33 /** ROOT macro for the implementation of ROOT specific class methods */
34 ClassImp(AliHLTTPCCompModelInflaterComponent);
35     
36 AliHLTTPCCompModelInflaterComponent::AliHLTTPCCompModelInflaterComponent()
37   :
38   fModelInflater()
39     {
40       // see header file for class documentation
41     }
42
43 AliHLTTPCCompModelInflaterComponent::~AliHLTTPCCompModelInflaterComponent()
44     {
45       // see header file for class documentation
46     }
47
48 const char* AliHLTTPCCompModelInflaterComponent::GetComponentID()
49     {
50       // see header file for class documentation
51       return "TPCCompModelInflater"; // The ID of this component
52     }
53
54 void AliHLTTPCCompModelInflaterComponent::GetInputDataTypes( vector<AliHLTComponent_DataType>& list)
55     {
56       // see header file for class documentation
57       list.clear(); // We do not have any requirements for our input data type(s).
58       list.push_back( AliHLTTPCDefinitions::fgkClusterTracksCompressedDataType );
59       list.push_back( AliHLTTPCDefinitions::fgkRemainingClustersCompressedDataType );
60     }
61
62 AliHLTComponent_DataType AliHLTTPCCompModelInflaterComponent::GetOutputDataType()
63     {
64       // see header file for class documentation 
65       return AliHLTTPCDefinitions::fgkClusterTracksModelDataType;
66     }
67
68 void AliHLTTPCCompModelInflaterComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
69     {
70       // see header file for class documentation
71       constBase = 4+4; // Format versions
72       inputMultiplier = 20.;
73       //#warning Adapt input Multiplier to something more realistic
74     }
75
76 // Spawn function, return new instance of this class
77 AliHLTComponent* AliHLTTPCCompModelInflaterComponent::Spawn()
78     {
79       // see header file for class documentation
80       return new AliHLTTPCCompModelInflaterComponent;
81     };
82
83 int AliHLTTPCCompModelInflaterComponent::DoInit( int argc, const char** argv )
84     {
85       // see header file for class documentation
86       //char* cpErr;
87       if ( argc )
88         {
89           Logging( kHLTLogDebug, "HLT::TPCCompModelInflater::DoInit", "Arguments", "argv[0] == %s", argv[0] );
90           Logging(kHLTLogError, "HLT::TPCCompModelInflater::DoInit", "Unknown Option", "Unknown option '%s'", argv[0] );
91           return EINVAL;
92         }
93       return 0;
94     }
95
96 int AliHLTTPCCompModelInflaterComponent::DoDeinit()
97     {
98       // see header file for class documentation
99       return 0;
100     }
101
102 int AliHLTTPCCompModelInflaterComponent::DoEvent( const AliHLTComponent_EventData& evtData, const AliHLTComponent_BlockData* blocks, 
103                                                    AliHLTComponent_TriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, 
104                                       AliHLTUInt32_t& size, vector<AliHLTComponent_BlockData>& outputBlocks )
105     {
106       // see header file for class documentation
107       // Process an event
108       // Loop over all input blocks in the event
109       AliHLTUInt8_t* writePtr = outputPtr;
110       AliHLTUInt32_t outputSize = 0, blockSize;
111       int ret;
112       AliHLTComponent_BlockData ob;
113       
114       for ( unsigned long n = 0; n < evtData.fBlockCnt; n++ )
115         {
116           if ( blocks[n].fDataType == AliHLTTPCDefinitions::fgkClusterTracksCompressedDataType )
117             {
118               blockSize = size-outputSize;
119               ret = fModelInflater.DecompressTracks( (AliHLTUInt8_t*)blocks[n].fPtr, blocks[n].fSize, writePtr, blockSize );
120               HLTDebug( "fModelInflater.DecompressTracks: ret: %d - blockSize: %u", ret, (unsigned)blockSize );
121               if ( !ret )
122                 {
123                   // Let the structure be filled with the default values.
124                   // This takes care of setting the shared memory and data type values to default values,
125                   // so that they can be filled in by the calling code.
126                   FillBlockData( ob );
127                   // This block's start (offset) is after all other blocks written so far
128                   ob.fOffset = outputSize;
129                   // the size of this block's data.
130                   ob.fSize = blockSize;
131                   // The specification of the data is copied from the input block.
132                   ob.fSpecification = blocks[n].fSpecification;
133                   // The type of the data is copied from the input block.
134                   ob.fDataType = AliHLTTPCDefinitions::fgkClusterTracksModelDataType;
135                   // Place this block into the list of output blocks
136                   outputBlocks.push_back( ob );
137                   writePtr += blockSize;
138                   outputSize += blockSize;
139                 }
140               continue;
141             }
142           if ( blocks[n].fDataType == AliHLTTPCDefinitions::fgkRemainingClustersCompressedDataType )
143             {
144               blockSize = size-outputSize;
145               ret = fModelInflater.DecompressRemainingClusters( (AliHLTUInt8_t*)blocks[n].fPtr, blocks[n].fSize, writePtr, blockSize );
146               HLTDebug( "ret: %d - blockSize: %u - blocks[%u].fSize: %u", ret, (unsigned)blockSize, (unsigned)n, (unsigned)blocks[n].fSize );
147               if ( !ret )
148                 {
149                   // Let the structure be filled with the default values.
150                   // This takes care of setting the shared memory and data type values to default values,
151                   // so that they can be filled in by the calling code.
152                   FillBlockData( ob );
153                   // This block's start (offset) is after all other blocks written so far
154                   ob.fOffset = outputSize;
155                   // the size of this block's data.
156                   ob.fSize = blockSize;
157                   // The specification of the data is copied from the input block.
158                   ob.fSpecification = blocks[n].fSpecification;
159                   // The type of the data is copied from the input block.
160                   ob.fDataType = AliHLTTPCDefinitions::fgkRemainingClustersModelDataType;
161                   // Place this block into the list of output blocks
162                   outputBlocks.push_back( ob );
163                   writePtr += blockSize;
164                   outputSize += blockSize;
165                 }
166               continue;
167             }
168         }
169       
170       // Finally we set the total size of output memory we consumed.
171       size = outputSize;
172       return 0;
173     }