]>
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() | |
46 | { | |
47 | fRawMemoryReader = NULL; | |
48 | fTPCRawStream = NULL; | |
49 | } | |
50 | ||
51 | AliHLTTPCRawDataUnpackerComponent::~AliHLTTPCRawDataUnpackerComponent() | |
52 | { | |
53 | } | |
54 | ||
55 | // Public functions to implement AliHLTComponent's interface. | |
56 | // These functions are required for the registration process | |
57 | ||
58 | const char* AliHLTTPCRawDataUnpackerComponent::GetComponentID() | |
59 | { | |
60 | return "TPCRawDataUnpacker"; | |
61 | } | |
62 | ||
8ede8717 | 63 | void AliHLTTPCRawDataUnpackerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) |
71d7c760 | 64 | { |
65 | list.clear(); | |
96bda103 | 66 | list.push_back( AliHLTTPCDefinitions::fgkDDLPackedRawDataType ); |
71d7c760 | 67 | } |
68 | ||
8ede8717 | 69 | AliHLTComponentDataType AliHLTTPCRawDataUnpackerComponent::GetOutputDataType() |
71d7c760 | 70 | { |
96bda103 | 71 | return AliHLTTPCDefinitions::fgkUnpackedRawDataType; |
71d7c760 | 72 | } |
73 | ||
74 | void AliHLTTPCRawDataUnpackerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) | |
75 | { | |
76 | // XXX TODO: Find more realistic values. | |
77 | constBase = 0; | |
a6c02c85 | 78 | inputMultiplier = 6.0; |
71d7c760 | 79 | } |
80 | ||
81 | AliHLTComponent* AliHLTTPCRawDataUnpackerComponent::Spawn() | |
82 | { | |
83 | return new AliHLTTPCRawDataUnpackerComponent; | |
84 | } | |
85 | ||
86 | int AliHLTTPCRawDataUnpackerComponent::DoInit( int argc, const char** argv ) | |
87 | { | |
88 | if ( fRawMemoryReader || fTPCRawStream ) | |
89 | return EINPROGRESS; | |
90 | ||
91 | int i = 0; | |
a6c02c85 | 92 | // const char* tableFileBaseDir = NULL; |
71d7c760 | 93 | while ( i < argc ) |
94 | { | |
a6c02c85 | 95 | // if ( !strcmp( argv[i], "table-dir" ) ) |
5a9b6c00 | 96 | // { |
97 | // if ( i+1>=argc ) | |
98 | // { | |
99 | // Logging(kHLTLogError, "HLT::TPCRawDataUnpacker::DoInit", "Missing Argument", "Missing -table-dir parameter"); | |
100 | // return ENOTSUP; | |
101 | // } | |
102 | // tableFileBaseDir = argv[i+1]; | |
103 | // i += 2; | |
104 | // continue; | |
105 | // } | |
71d7c760 | 106 | Logging(kHLTLogError, "HLT::TPCRawDataUnpacker::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] ); |
107 | return EINVAL; | |
108 | } | |
109 | ||
5a9b6c00 | 110 | // if ( !tableFileBaseDir ) |
111 | // { | |
112 | // Logging(kHLTLogError, "HLT::TPCRawDataUnpacker::DoInit", "Table file directory missing ", | |
113 | // "Table file base directory has to be set using the -table-dir component parameter." ); | |
114 | // return EINVAL; | |
115 | // } | |
71d7c760 | 116 | |
117 | fRawMemoryReader = new AliRawReaderMemory; | |
118 | //fTPCRawStream = new AliTPCRawStream( fRawMemoryReader, tableFileBaseDir ); | |
119 | fTPCRawStream = new AliTPCRawStream( fRawMemoryReader ); | |
120 | ||
121 | return 0; | |
122 | } | |
123 | ||
124 | int AliHLTTPCRawDataUnpackerComponent::DoDeinit() | |
125 | { | |
126 | if ( fRawMemoryReader ) | |
127 | delete fRawMemoryReader; | |
128 | fRawMemoryReader = NULL; | |
129 | if ( fTPCRawStream ) | |
130 | delete fTPCRawStream; | |
131 | fTPCRawStream = NULL; | |
132 | return 0; | |
133 | } | |
134 | ||
8ede8717 | 135 | int AliHLTTPCRawDataUnpackerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, |
136 | AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, | |
137 | AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks ) | |
71d7c760 | 138 | { |
8ede8717 | 139 | const AliHLTComponentBlockData* iter = NULL; |
71d7c760 | 140 | unsigned long ndx; |
141 | ||
142 | AliHLTUInt8_t* outBPtr; | |
143 | AliHLTTPCUnpackedRawData* outPtr; | |
a6c02c85 | 144 | AliHLTTPCDigitRowData* currentRow; |
145 | AliHLTTPCDigitData* currentDigit; | |
71d7c760 | 146 | unsigned long long outputSize = 0; |
147 | unsigned long blockOutputSize = 0; | |
148 | unsigned long rowSize = 0; | |
a6c02c85 | 149 | Int_t slice, patch, rows[2]; |
71d7c760 | 150 | outBPtr = outputPtr; |
151 | outPtr = (AliHLTTPCUnpackedRawData*)outputPtr; | |
152 | currentRow = outPtr->fDigits; | |
153 | currentDigit = currentRow->fDigitData; | |
a6c02c85 | 154 | |
155 | Logging( kHLTLogDebug, "HLT::TPCRawDataUnpackerSubscriber::DoEvent", "Event received", | |
156 | "Event 0x%08LX (%Lu) received with %lu blocks. Output data size: %lu", | |
157 | evtData.fEventID, evtData.fEventID, evtData.fBlockCnt, size); | |
71d7c760 | 158 | for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) |
159 | { | |
160 | iter = blocks+ndx; | |
a6c02c85 | 161 | char tmp1[14], tmp2[14]; |
162 | DataType2Text( iter->fDataType, tmp1 ); | |
96bda103 | 163 | DataType2Text( AliHLTTPCDefinitions::fgkDDLPackedRawDataType, tmp2 ); |
a6c02c85 | 164 | Logging( kHLTLogDebug, "HLT::TPCRawDataUnpackerSubscriber::DoEvent", "Event received", |
165 | "Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s", | |
166 | evtData.fEventID, evtData.fEventID, tmp1, tmp2 ); | |
96bda103 | 167 | if ( iter->fDataType != AliHLTTPCDefinitions::fgkDDLPackedRawDataType ) |
71d7c760 | 168 | { |
169 | continue; | |
170 | } | |
171 | slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter ); | |
172 | patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter ); | |
a6c02c85 | 173 | rows[0] = AliHLTTPCTransform::GetFirstRow( patch ); |
174 | rows[1] = AliHLTTPCTransform::GetLastRow( patch ); | |
71d7c760 | 175 | blockOutputSize = 0; |
176 | ||
a6c02c85 | 177 | Logging( kHLTLogDebug, "HLT::TPCRawDataUnpackerSubscriber::DoEvent", "Input Raw Packed Data", |
178 | "Input: Slice/Patch/RowMin/RowMax: %d/%d/%d/%d.", | |
179 | slice, patch, rows[0], rows[1] ); | |
180 | ||
71d7c760 | 181 | fRawMemoryReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize ); |
182 | bool readValue = true; | |
183 | readValue = fTPCRawStream->Next(); | |
184 | int row = -1, oldRow = -1; | |
185 | Int_t rowOffset = 0; | |
186 | if ( patch >= 2 ) // Outer sector, patches 2, 3, 4, 5 | |
a6c02c85 | 187 | rowOffset = AliHLTTPCTransform::GetFirstRow( 2 ); |
71d7c760 | 188 | |
189 | while ( readValue ) | |
190 | { | |
191 | row = fTPCRawStream->GetRow(); | |
192 | if ( row != oldRow ) | |
193 | { | |
a6c02c85 | 194 | if ( oldRow!=-1 && rowSize != sizeof(AliHLTTPCDigitRowData)+currentRow->fNDigit*sizeof(AliHLTTPCDigitData) ) |
71d7c760 | 195 | { |
a6c02c85 | 196 | Logging( kHLTLogFatal, "HLT::TPCRawDataUnpackerSubscriber::DoEvent", "Size inconsistency", |
71d7c760 | 197 | "Size inconsistency for row %d data: %lu != %lu (%lu digits).", oldRow, rowSize, |
a6c02c85 | 198 | sizeof(AliHLTTPCDigitRowData)+currentRow->fNDigit*sizeof(AliHLTTPCDigitData), currentRow->fNDigit ); |
71d7c760 | 199 | } |
200 | rowSize = 0; | |
a6c02c85 | 201 | if ( size < outputSize+sizeof(AliHLTTPCDigitRowData) ) |
71d7c760 | 202 | { |
a6c02c85 | 203 | Logging( kHLTLogFatal, "HLT::TPCRawDataUnpackerSubscriber::DoEvent", "Too much data", |
71d7c760 | 204 | "Output data too big, output memory full. Aborting event 0x%08lX (%lu)" , |
205 | evtData.fEventID, evtData.fEventID ); | |
206 | return 0; | |
207 | } | |
a6c02c85 | 208 | currentRow = (AliHLTTPCDigitRowData*)(outBPtr+outputSize); |
71d7c760 | 209 | currentDigit = currentRow->fDigitData; |
210 | currentRow->fRow = row+rowOffset; | |
211 | currentRow->fNDigit = 0; | |
212 | oldRow = row; | |
a6c02c85 | 213 | outputSize += sizeof(AliHLTTPCDigitRowData); |
214 | blockOutputSize += sizeof(AliHLTTPCDigitRowData); | |
215 | rowSize += sizeof(AliHLTTPCDigitRowData); | |
71d7c760 | 216 | } |
a6c02c85 | 217 | if ( size < outputSize+sizeof(AliHLTTPCDigitData) ) |
71d7c760 | 218 | { |
a6c02c85 | 219 | Logging( kHLTLogFatal, "HLT::TPCRawDataUnpackerSubscriber::DoEvent", "Too much data", |
71d7c760 | 220 | "Output data too big, output memory full. Aborting event 0x%08lX (%lu)" , |
221 | evtData.fEventID, evtData.fEventID ); | |
222 | return 0; | |
223 | } | |
224 | currentDigit->fCharge = fTPCRawStream->GetSignal(); | |
225 | currentDigit->fPad = fTPCRawStream->GetPad(); | |
226 | currentDigit->fTime = fTPCRawStream->GetTime(); | |
227 | currentRow->fNDigit++; | |
228 | currentDigit++; | |
a6c02c85 | 229 | outputSize += sizeof(AliHLTTPCDigitData); |
230 | blockOutputSize += sizeof(AliHLTTPCDigitData); | |
231 | rowSize += sizeof(AliHLTTPCDigitData); | |
71d7c760 | 232 | readValue = fTPCRawStream->Next(); |
233 | } | |
a6c02c85 | 234 | if ( oldRow!=-1 && rowSize != sizeof(AliHLTTPCDigitRowData)+currentRow->fNDigit*sizeof(AliHLTTPCDigitData) ) |
71d7c760 | 235 | { |
a6c02c85 | 236 | Logging( kHLTLogFatal, "HLT::TPCRawDataUnpackerSubscriber::DoEvent", "Size inconsistency", |
71d7c760 | 237 | "Size inconsistency for row %d data: %lu != %lu (%lu digits).", oldRow, rowSize, |
a6c02c85 | 238 | sizeof(AliHLTTPCDigitRowData)+currentRow->fNDigit*sizeof(AliHLTTPCDigitData), currentRow->fNDigit ); |
71d7c760 | 239 | } |
240 | ||
8ede8717 | 241 | AliHLTComponentBlockData bd; |
71d7c760 | 242 | FillBlockData( bd ); |
243 | bd.fOffset = outputSize-blockOutputSize; | |
244 | bd.fSize = blockOutputSize; | |
245 | bd.fSpecification = iter->fSpecification; | |
a6c02c85 | 246 | Logging( kHLTLogDebug, "HLT::TPCRawDataUnpackerSubscriber::DoEvent", "Event received", |
247 | "Event 0x%08LX (%Lu) output data block %lu of %lu bytes at offset %lu", | |
248 | evtData.fEventID, evtData.fEventID, ndx, blockOutputSize, outputSize-blockOutputSize ); | |
71d7c760 | 249 | //AliHLTSubEventDescriptor::FillBlockAttributes( bd.fAttributes ); |
250 | outputBlocks.push_back( bd ); | |
251 | } | |
252 | ||
253 | ||
254 | size = outputSize; | |
255 | return 0; | |
256 | } | |
257 | ||
258 |