]>
Commit | Line | Data |
---|---|---|
71d7c760 | 1 | // $Id$ |
2 | ||
3 | /************************************************************************** | |
9be2600f | 4 | * This file is property of and copyright by the ALICE HLT Project * |
5 | * ALICE Experiment at CERN, All rights reserved. * | |
71d7c760 | 6 | * * |
9be2600f | 7 | * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> * |
8 | * Timm Steinbeck <timm@kip.uni-heidelberg.de> * | |
9 | * for The ALICE HLT Project. * | |
71d7c760 | 10 | * * |
11 | * Permission to use, copy, modify and distribute this software and its * | |
12 | * documentation strictly for non-commercial purposes is hereby granted * | |
13 | * without fee, provided that the above copyright notice appears in all * | |
14 | * copies and that both the copyright notice and this permission notice * | |
15 | * appear in the supporting documentation. The authors make no claims * | |
16 | * about the suitability of this software for any purpose. It is * | |
17 | * provided "as is" without express or implied warranty. * | |
18 | **************************************************************************/ | |
19 | ||
20 | /////////////////////////////////////////////////////////////////////////////// | |
21 | // // | |
22 | // a TPC cluster finder processing component for the HLT // | |
23 | // // | |
24 | /////////////////////////////////////////////////////////////////////////////// | |
25 | ||
26 | #if __GNUC__== 3 | |
27 | using namespace std; | |
28 | #endif | |
29 | ||
30 | #include "AliHLTTPCRawDataUnpackerComponent.h" | |
31 | #include "AliTPCRawStream.h" | |
32 | #include "AliRawDataHeader.h" | |
33 | #include "AliRawReaderMemory.h" | |
34 | #include "AliHLTTPCRawDataFormat.h" | |
a6c02c85 | 35 | #include "AliHLTTPCDigitData.h" |
36 | #include "AliHLTTPCTransform.h" | |
71d7c760 | 37 | #include <stdlib.h> |
38 | #include <errno.h> | |
39 | ||
40 | // this is a global object used for automatic component registration, do not use this | |
41 | AliHLTTPCRawDataUnpackerComponent gAliHLTTPCRawDataUnpackerComponent; | |
42 | ||
43 | ClassImp(AliHLTTPCRawDataUnpackerComponent) | |
44 | ||
45 | AliHLTTPCRawDataUnpackerComponent::AliHLTTPCRawDataUnpackerComponent() | |
e419b223 | 46 | : |
47 | fRawMemoryReader(NULL), | |
48 | fTPCRawStream(NULL) | |
49 | { | |
50 | } | |
51 | ||
52 | AliHLTTPCRawDataUnpackerComponent::AliHLTTPCRawDataUnpackerComponent(const AliHLTTPCRawDataUnpackerComponent&) | |
53 | : | |
54 | fRawMemoryReader(NULL), | |
55 | fTPCRawStream(NULL) | |
56 | { | |
57 | // see header file for class documentation | |
58 | } | |
59 | ||
60 | AliHLTTPCRawDataUnpackerComponent& AliHLTTPCRawDataUnpackerComponent::operator=(const AliHLTTPCRawDataUnpackerComponent&) | |
61 | { | |
62 | // see header file for class documentation | |
63 | return *this; | |
64 | } | |
71d7c760 | 65 | |
66 | AliHLTTPCRawDataUnpackerComponent::~AliHLTTPCRawDataUnpackerComponent() | |
e419b223 | 67 | { |
68 | } | |
71d7c760 | 69 | |
70 | // Public functions to implement AliHLTComponent's interface. | |
71 | // These functions are required for the registration process | |
72 | ||
73 | const char* AliHLTTPCRawDataUnpackerComponent::GetComponentID() | |
74 | { | |
75 | return "TPCRawDataUnpacker"; | |
76 | } | |
77 | ||
8ede8717 | 78 | void AliHLTTPCRawDataUnpackerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) |
71d7c760 | 79 | { |
80 | list.clear(); | |
96bda103 | 81 | list.push_back( AliHLTTPCDefinitions::fgkDDLPackedRawDataType ); |
71d7c760 | 82 | } |
83 | ||
8ede8717 | 84 | AliHLTComponentDataType AliHLTTPCRawDataUnpackerComponent::GetOutputDataType() |
71d7c760 | 85 | { |
96bda103 | 86 | return AliHLTTPCDefinitions::fgkUnpackedRawDataType; |
71d7c760 | 87 | } |
88 | ||
89 | void AliHLTTPCRawDataUnpackerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) | |
90 | { | |
91 | // XXX TODO: Find more realistic values. | |
92 | constBase = 0; | |
a6c02c85 | 93 | inputMultiplier = 6.0; |
71d7c760 | 94 | } |
95 | ||
96 | AliHLTComponent* AliHLTTPCRawDataUnpackerComponent::Spawn() | |
97 | { | |
98 | return new AliHLTTPCRawDataUnpackerComponent; | |
99 | } | |
100 | ||
101 | int AliHLTTPCRawDataUnpackerComponent::DoInit( int argc, const char** argv ) | |
102 | { | |
103 | if ( fRawMemoryReader || fTPCRawStream ) | |
104 | return EINPROGRESS; | |
105 | ||
106 | int i = 0; | |
a6c02c85 | 107 | // const char* tableFileBaseDir = NULL; |
71d7c760 | 108 | while ( i < argc ) |
109 | { | |
a6c02c85 | 110 | // if ( !strcmp( argv[i], "table-dir" ) ) |
5a9b6c00 | 111 | // { |
112 | // if ( i+1>=argc ) | |
113 | // { | |
114 | // Logging(kHLTLogError, "HLT::TPCRawDataUnpacker::DoInit", "Missing Argument", "Missing -table-dir parameter"); | |
115 | // return ENOTSUP; | |
116 | // } | |
117 | // tableFileBaseDir = argv[i+1]; | |
118 | // i += 2; | |
119 | // continue; | |
120 | // } | |
71d7c760 | 121 | Logging(kHLTLogError, "HLT::TPCRawDataUnpacker::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] ); |
122 | return EINVAL; | |
123 | } | |
124 | ||
5a9b6c00 | 125 | // if ( !tableFileBaseDir ) |
126 | // { | |
127 | // Logging(kHLTLogError, "HLT::TPCRawDataUnpacker::DoInit", "Table file directory missing ", | |
128 | // "Table file base directory has to be set using the -table-dir component parameter." ); | |
129 | // return EINVAL; | |
130 | // } | |
71d7c760 | 131 | |
132 | fRawMemoryReader = new AliRawReaderMemory; | |
133 | //fTPCRawStream = new AliTPCRawStream( fRawMemoryReader, tableFileBaseDir ); | |
134 | fTPCRawStream = new AliTPCRawStream( fRawMemoryReader ); | |
135 | ||
136 | return 0; | |
137 | } | |
138 | ||
139 | int AliHLTTPCRawDataUnpackerComponent::DoDeinit() | |
140 | { | |
141 | if ( fRawMemoryReader ) | |
142 | delete fRawMemoryReader; | |
143 | fRawMemoryReader = NULL; | |
144 | if ( fTPCRawStream ) | |
145 | delete fTPCRawStream; | |
146 | fTPCRawStream = NULL; | |
147 | return 0; | |
148 | } | |
149 | ||
8ede8717 | 150 | int AliHLTTPCRawDataUnpackerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, |
151 | AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, | |
152 | AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks ) | |
71d7c760 | 153 | { |
8ede8717 | 154 | const AliHLTComponentBlockData* iter = NULL; |
71d7c760 | 155 | unsigned long ndx; |
156 | ||
157 | AliHLTUInt8_t* outBPtr; | |
158 | AliHLTTPCUnpackedRawData* outPtr; | |
a6c02c85 | 159 | AliHLTTPCDigitRowData* currentRow; |
160 | AliHLTTPCDigitData* currentDigit; | |
71d7c760 | 161 | unsigned long long outputSize = 0; |
162 | unsigned long blockOutputSize = 0; | |
163 | unsigned long rowSize = 0; | |
a6c02c85 | 164 | Int_t slice, patch, rows[2]; |
71d7c760 | 165 | outBPtr = outputPtr; |
166 | outPtr = (AliHLTTPCUnpackedRawData*)outputPtr; | |
167 | currentRow = outPtr->fDigits; | |
168 | currentDigit = currentRow->fDigitData; | |
a6c02c85 | 169 | |
170 | Logging( kHLTLogDebug, "HLT::TPCRawDataUnpackerSubscriber::DoEvent", "Event received", | |
171 | "Event 0x%08LX (%Lu) received with %lu blocks. Output data size: %lu", | |
172 | evtData.fEventID, evtData.fEventID, evtData.fBlockCnt, size); | |
71d7c760 | 173 | for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) |
174 | { | |
175 | iter = blocks+ndx; | |
a6c02c85 | 176 | char tmp1[14], tmp2[14]; |
177 | DataType2Text( iter->fDataType, tmp1 ); | |
96bda103 | 178 | DataType2Text( AliHLTTPCDefinitions::fgkDDLPackedRawDataType, tmp2 ); |
a6c02c85 | 179 | Logging( kHLTLogDebug, "HLT::TPCRawDataUnpackerSubscriber::DoEvent", "Event received", |
180 | "Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s", | |
181 | evtData.fEventID, evtData.fEventID, tmp1, tmp2 ); | |
96bda103 | 182 | if ( iter->fDataType != AliHLTTPCDefinitions::fgkDDLPackedRawDataType ) |
71d7c760 | 183 | { |
184 | continue; | |
185 | } | |
186 | slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter ); | |
187 | patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter ); | |
a6c02c85 | 188 | rows[0] = AliHLTTPCTransform::GetFirstRow( patch ); |
189 | rows[1] = AliHLTTPCTransform::GetLastRow( patch ); | |
71d7c760 | 190 | blockOutputSize = 0; |
191 | ||
a6c02c85 | 192 | Logging( kHLTLogDebug, "HLT::TPCRawDataUnpackerSubscriber::DoEvent", "Input Raw Packed Data", |
193 | "Input: Slice/Patch/RowMin/RowMax: %d/%d/%d/%d.", | |
194 | slice, patch, rows[0], rows[1] ); | |
195 | ||
71d7c760 | 196 | fRawMemoryReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize ); |
197 | bool readValue = true; | |
198 | readValue = fTPCRawStream->Next(); | |
199 | int row = -1, oldRow = -1; | |
200 | Int_t rowOffset = 0; | |
201 | if ( patch >= 2 ) // Outer sector, patches 2, 3, 4, 5 | |
a6c02c85 | 202 | rowOffset = AliHLTTPCTransform::GetFirstRow( 2 ); |
71d7c760 | 203 | |
204 | while ( readValue ) | |
205 | { | |
206 | row = fTPCRawStream->GetRow(); | |
207 | if ( row != oldRow ) | |
208 | { | |
a6c02c85 | 209 | if ( oldRow!=-1 && rowSize != sizeof(AliHLTTPCDigitRowData)+currentRow->fNDigit*sizeof(AliHLTTPCDigitData) ) |
71d7c760 | 210 | { |
a6c02c85 | 211 | Logging( kHLTLogFatal, "HLT::TPCRawDataUnpackerSubscriber::DoEvent", "Size inconsistency", |
71d7c760 | 212 | "Size inconsistency for row %d data: %lu != %lu (%lu digits).", oldRow, rowSize, |
a6c02c85 | 213 | sizeof(AliHLTTPCDigitRowData)+currentRow->fNDigit*sizeof(AliHLTTPCDigitData), currentRow->fNDigit ); |
71d7c760 | 214 | } |
215 | rowSize = 0; | |
a6c02c85 | 216 | if ( size < outputSize+sizeof(AliHLTTPCDigitRowData) ) |
71d7c760 | 217 | { |
a6c02c85 | 218 | Logging( kHLTLogFatal, "HLT::TPCRawDataUnpackerSubscriber::DoEvent", "Too much data", |
71d7c760 | 219 | "Output data too big, output memory full. Aborting event 0x%08lX (%lu)" , |
220 | evtData.fEventID, evtData.fEventID ); | |
221 | return 0; | |
222 | } | |
a6c02c85 | 223 | currentRow = (AliHLTTPCDigitRowData*)(outBPtr+outputSize); |
71d7c760 | 224 | currentDigit = currentRow->fDigitData; |
225 | currentRow->fRow = row+rowOffset; | |
226 | currentRow->fNDigit = 0; | |
227 | oldRow = row; | |
a6c02c85 | 228 | outputSize += sizeof(AliHLTTPCDigitRowData); |
229 | blockOutputSize += sizeof(AliHLTTPCDigitRowData); | |
230 | rowSize += sizeof(AliHLTTPCDigitRowData); | |
71d7c760 | 231 | } |
a6c02c85 | 232 | if ( size < outputSize+sizeof(AliHLTTPCDigitData) ) |
71d7c760 | 233 | { |
a6c02c85 | 234 | Logging( kHLTLogFatal, "HLT::TPCRawDataUnpackerSubscriber::DoEvent", "Too much data", |
71d7c760 | 235 | "Output data too big, output memory full. Aborting event 0x%08lX (%lu)" , |
236 | evtData.fEventID, evtData.fEventID ); | |
237 | return 0; | |
238 | } | |
239 | currentDigit->fCharge = fTPCRawStream->GetSignal(); | |
240 | currentDigit->fPad = fTPCRawStream->GetPad(); | |
241 | currentDigit->fTime = fTPCRawStream->GetTime(); | |
242 | currentRow->fNDigit++; | |
243 | currentDigit++; | |
a6c02c85 | 244 | outputSize += sizeof(AliHLTTPCDigitData); |
245 | blockOutputSize += sizeof(AliHLTTPCDigitData); | |
246 | rowSize += sizeof(AliHLTTPCDigitData); | |
71d7c760 | 247 | readValue = fTPCRawStream->Next(); |
248 | } | |
a6c02c85 | 249 | if ( oldRow!=-1 && rowSize != sizeof(AliHLTTPCDigitRowData)+currentRow->fNDigit*sizeof(AliHLTTPCDigitData) ) |
71d7c760 | 250 | { |
a6c02c85 | 251 | Logging( kHLTLogFatal, "HLT::TPCRawDataUnpackerSubscriber::DoEvent", "Size inconsistency", |
71d7c760 | 252 | "Size inconsistency for row %d data: %lu != %lu (%lu digits).", oldRow, rowSize, |
a6c02c85 | 253 | sizeof(AliHLTTPCDigitRowData)+currentRow->fNDigit*sizeof(AliHLTTPCDigitData), currentRow->fNDigit ); |
71d7c760 | 254 | } |
255 | ||
8ede8717 | 256 | AliHLTComponentBlockData bd; |
71d7c760 | 257 | FillBlockData( bd ); |
258 | bd.fOffset = outputSize-blockOutputSize; | |
259 | bd.fSize = blockOutputSize; | |
260 | bd.fSpecification = iter->fSpecification; | |
a6c02c85 | 261 | Logging( kHLTLogDebug, "HLT::TPCRawDataUnpackerSubscriber::DoEvent", "Event received", |
262 | "Event 0x%08LX (%Lu) output data block %lu of %lu bytes at offset %lu", | |
263 | evtData.fEventID, evtData.fEventID, ndx, blockOutputSize, outputSize-blockOutputSize ); | |
71d7c760 | 264 | //AliHLTSubEventDescriptor::FillBlockAttributes( bd.fAttributes ); |
265 | outputBlocks.push_back( bd ); | |
266 | } | |
267 | ||
268 | ||
269 | size = outputSize; | |
270 | return 0; | |
271 | } | |
272 | ||
273 |