]>
Commit | Line | Data |
---|---|---|
d15fb21a | 1 | // $Id$ |
0c7d42ab | 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: Jochen Thaeder <thaeder@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 AliHLTITSCompressRawDataSDDComponent.cxx | |
20 | @author Jochen Thaeder <thaeder@kip.uni-heidelberg.de> | |
21 | @date | |
22 | @brief Component to run data compression for SDD | |
23 | */ | |
24 | ||
0c7d42ab | 25 | #include "AliHLTITSCompressRawDataSDDComponent.h" |
26 | ||
27 | #include "AliCDBEntry.h" | |
28 | #include "AliCDBManager.h" | |
29 | ||
30 | #include <cstdlib> | |
31 | #include <cerrno> | |
32 | #include "TString.h" | |
33 | #include "TObjString.h" | |
34 | #include <sys/time.h> | |
35 | ||
8e0f6ca3 | 36 | using namespace std; |
37 | ||
0c7d42ab | 38 | /** ROOT macro for the implementation of ROOT specific class methods */ |
39 | ClassImp(AliHLTITSCompressRawDataSDDComponent); | |
40 | ||
41 | AliHLTITSCompressRawDataSDDComponent::AliHLTITSCompressRawDataSDDComponent() | |
42 | : | |
43 | fDataCompressor(NULL), | |
44 | fRawReader(NULL) { | |
45 | // see header file for class documentation | |
46 | // or | |
47 | // refer to README to build package | |
48 | // or | |
49 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
50 | } | |
51 | ||
52 | AliHLTITSCompressRawDataSDDComponent::~AliHLTITSCompressRawDataSDDComponent() { | |
53 | // see header file for class documentation | |
54 | } | |
55 | ||
56 | // Public functions to implement AliHLTComponent's interface. | |
57 | // These functions are required for the registration process | |
58 | ||
59 | const char* AliHLTITSCompressRawDataSDDComponent::GetComponentID() | |
60 | { | |
61 | // see header file for class documentation | |
62 | ||
63 | return "ITSDataCompressorSDD"; | |
64 | } | |
65 | ||
66 | void AliHLTITSCompressRawDataSDDComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) { | |
67 | // see header file for class documentation | |
68 | list.clear(); | |
69 | list.push_back( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginITS ); | |
70 | ||
71 | } | |
72 | ||
73 | AliHLTComponentDataType AliHLTITSCompressRawDataSDDComponent::GetOutputDataType() { | |
74 | // see header file for class documentation | |
75 | return (kAliHLTDataTypeDDLRaw| kAliHLTDataOriginITS); | |
76 | } | |
77 | ||
78 | void AliHLTITSCompressRawDataSDDComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) { | |
79 | // see header file for class documentation | |
80 | ||
81 | constBase = 0; | |
859fbc05 | 82 | inputMultiplier = 0.3; |
0c7d42ab | 83 | } |
84 | ||
85 | AliHLTComponent* AliHLTITSCompressRawDataSDDComponent::Spawn() { | |
86 | // see header file for class documentation | |
87 | return new AliHLTITSCompressRawDataSDDComponent(); | |
88 | } | |
89 | ||
90 | Int_t AliHLTITSCompressRawDataSDDComponent::DoInit( int /*argc*/, const char** /*argv*/ ) { | |
91 | // see header file for class documentation | |
92 | ||
93 | if ( fDataCompressor ) | |
94 | return EINPROGRESS; | |
95 | ||
96 | fDataCompressor = new AliITSCompressRawDataSDD(); | |
97 | ||
98 | if ( fRawReader ) | |
99 | return EINPROGRESS; | |
100 | ||
101 | fRawReader = new AliRawReaderMemory(); | |
102 | ||
103 | return 0; | |
104 | } | |
105 | ||
106 | Int_t AliHLTITSCompressRawDataSDDComponent::DoDeinit() { | |
107 | // see header file for class documentation | |
108 | ||
109 | if ( fRawReader ) | |
110 | delete fRawReader; | |
111 | fRawReader = NULL; | |
112 | ||
113 | if ( fDataCompressor ) | |
114 | delete fDataCompressor; | |
115 | fDataCompressor = NULL; | |
116 | ||
117 | return 0; | |
118 | } | |
119 | ||
120 | Int_t AliHLTITSCompressRawDataSDDComponent::DoEvent( const AliHLTComponentEventData& evtData, | |
121 | const AliHLTComponentBlockData* blocks, | |
122 | AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, | |
123 | AliHLTUInt32_t& size, | |
124 | vector<AliHLTComponentBlockData>& outputBlocks ) { | |
125 | // see header file for class documentation | |
126 | ||
127 | if(GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR )){ | |
128 | size=0; | |
129 | return 0; | |
130 | } | |
131 | ||
132 | // -- Iterator over Data Blocks -- | |
133 | const AliHLTComponentBlockData* iter = NULL; | |
134 | ||
135 | // -- Ptr to output shm region -- | |
136 | AliHLTUInt8_t* outShmPtr = outputPtr; | |
137 | ||
138 | // -- Initialize out sizes | |
139 | UInt_t offset = 0; // offset of current outblock | |
140 | UInt_t mySize = 0; // out size produced from current block | |
141 | UInt_t totalSize = 0; // total out size of this event | |
142 | UInt_t availSize = 0; // still availible out size for this event | |
143 | ||
144 | // -- Loop over blocks | |
145 | for ( ULong_t ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) { | |
146 | ||
147 | iter = blocks+ndx; | |
148 | ||
149 | mySize = 0; | |
150 | offset = totalSize; | |
151 | availSize = size - totalSize; | |
152 | ||
153 | // -- Debug output of datatype -- | |
154 | HLTDebug("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s", | |
859fbc05 | 155 | evtData.fEventID, evtData.fEventID, |
156 | DataType2Text(iter->fDataType).c_str(), | |
157 | DataType2Text(kAliHLTDataTypeDDLRaw | kAliHLTDataOriginITSSDD).c_str()); | |
0c7d42ab | 158 | |
159 | // -- Check for the correct data type | |
859fbc05 | 160 | if ( iter->fDataType != (kAliHLTDataTypeDDLRaw | kAliHLTDataOriginITSSDD) ) |
0c7d42ab | 161 | continue; |
0c7d42ab | 162 | |
163 | // -- Set RawReader | |
164 | fRawReader->SetMemory( (UChar_t*) iter->fPtr, iter->fSize ); | |
165 | ||
166 | // -- Get equipment ID out of specification | |
167 | AliHLTUInt32_t spec = iter->fSpecification; | |
168 | ||
169 | Int_t id = 256; | |
170 | for ( Int_t ii = 0; ii < 24 ; ii++ ) { | |
171 | if ( spec & 0x00000001 ) { | |
172 | id += ii; | |
173 | break; | |
174 | } | |
175 | spec = spec >> 1 ; | |
176 | } | |
177 | ||
178 | // -- Set equipment ID to the raw reader | |
179 | fRawReader->SetEquipmentID( id ); | |
180 | ||
181 | // -- Set raw reader | |
182 | fDataCompressor->SetRawReader( fRawReader ); | |
183 | ||
184 | // -- Set ptr to output shm | |
185 | fDataCompressor->SetPointerToData( (UChar_t*) outShmPtr ); | |
186 | ||
187 | // -- Set availible outputspace | |
188 | fDataCompressor->SetSize( (UInt_t) availSize ); | |
189 | ||
190 | // -- Compress event | |
191 | mySize = fDataCompressor->CompressEvent( (UChar_t*) iter->fPtr ); | |
192 | ||
193 | // -- Fill output blocks | |
194 | AliHLTComponentBlockData bd; | |
195 | FillBlockData( bd ); | |
196 | bd.fOffset = offset; | |
197 | bd.fSize = mySize; | |
198 | bd.fSpecification = iter->fSpecification; | |
199 | bd.fDataType = iter->fDataType; | |
200 | outputBlocks.push_back( bd ); | |
201 | ||
202 | // -- Increase size counters | |
203 | totalSize += mySize; | |
204 | ||
205 | // -- Increase output shm ptr | |
206 | outShmPtr += mySize; | |
859fbc05 | 207 | |
0c7d42ab | 208 | // -- Check if data was written over allowed buffer |
209 | if ( totalSize > size ) { | |
859fbc05 | 210 | HLTError( "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu.", totalSize, size ); |
0c7d42ab | 211 | return EMSGSIZE; |
212 | } | |
213 | ||
214 | } // for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) { | |
215 | ||
216 | // -- Set total output size | |
217 | size = totalSize; | |
218 | ||
219 | return 0; | |
220 | } |