]>
Commit | Line | Data |
---|---|---|
10f165dc | 1 | // $Id$ |
2 | ||
afa4418c | 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: Kenneth Aamodt <Kenneth.Aamodt@student.uib.no> * | |
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 AliHLTTPCZeroSuppressionComponent.cxx | |
20 | @author Kenneth Aamodt | |
21 | @date | |
22 | @brief The TPC ZeroSuppression component | |
23 | */ | |
24 | ||
25 | // see header file for class documentation // | |
26 | // or // | |
27 | // refer to README to build package // | |
28 | // or // | |
29 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt // | |
30 | ||
31 | #if __GNUC__>= 3 | |
32 | using namespace std; | |
33 | #endif | |
34 | #include "AliHLTTPCZeroSuppressionComponent.h" | |
35 | #include "AliHLTTPCDigitReaderDecoder.h" | |
36 | #include "AliHLTTPCTransform.h" | |
37 | #include "AliHLTTPCDefinitions.h" | |
afa4418c | 38 | #include "AliHLTTPCDigitData.h" |
5cccaefd | 39 | #include "AliHLTTPCMapping.h" |
afa4418c | 40 | #include <cstdlib> |
41 | #include <cerrno> | |
5cccaefd | 42 | #include <cassert> |
afa4418c | 43 | #include "TString.h" |
44 | #include <sys/time.h> | |
092a1374 | 45 | #include "AliHLTAltroEncoder.h" |
46 | #include "AliRawDataHeader.h" | |
a74855c2 | 47 | |
afa4418c | 48 | /** ROOT macro for the implementation of ROOT specific class methods */ |
49 | ClassImp(AliHLTTPCZeroSuppressionComponent) | |
50 | ||
51 | AliHLTTPCZeroSuppressionComponent::AliHLTTPCZeroSuppressionComponent() | |
52 | : | |
a74855c2 | 53 | fDigitReader(NULL), |
54 | fRowPadVector(), | |
55 | fNumberOfPadsInRow(NULL), | |
56 | fNumberOfRows(0), | |
57 | fCurrentPatch(0), | |
58 | fFirstRow(0), | |
59 | fLastRow(0), | |
afa4418c | 60 | fStartTimeBin(0), |
61 | fEndTimeBin(AliHLTTPCTransform::GetNTimeBins()), | |
a74855c2 | 62 | fNTimeBins(0), |
afa4418c | 63 | fNRMSThreshold(0), |
64 | fSignalThreshold(0), | |
65 | fMinimumNumberOfSignals(AliHLTTPCTransform::GetNTimeBins()/2), | |
66 | fOldRCUFormat(0), | |
67 | fSortPads(0), | |
afa4418c | 68 | fVectorInitialized(kFALSE), |
afa4418c | 69 | fValueBelowAverage(5), |
70 | fLeftTimeBin(5), | |
a74855c2 | 71 | fRightTimeBin(5), |
72 | fGetActivePads(kFALSE), | |
3789100d | 73 | fSkipSendingZSData(kFALSE), |
74 | fSendHWList(kFALSE), | |
a74855c2 | 75 | fHwAddressList() |
afa4418c | 76 | { |
77 | // see header file for class documentation | |
78 | // or | |
79 | // refer to README to build package | |
80 | // or | |
81 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
82 | } | |
83 | ||
84 | AliHLTTPCZeroSuppressionComponent::~AliHLTTPCZeroSuppressionComponent() | |
85 | { | |
86 | // see header file for class documentation | |
87 | if(fVectorInitialized){ | |
88 | DeInitializePadArray(); | |
89 | } | |
90 | if(fNumberOfPadsInRow){ | |
91 | delete [] fNumberOfPadsInRow; | |
92 | fNumberOfPadsInRow=NULL; | |
93 | } | |
9b4f7f90 | 94 | if(fDigitReader){ |
95 | delete fDigitReader; | |
96 | fDigitReader=NULL; | |
97 | } | |
afa4418c | 98 | } |
99 | ||
100 | // Public functions to implement AliHLTComponent's interface. | |
101 | // These functions are required for the registration process | |
102 | ||
103 | const char* AliHLTTPCZeroSuppressionComponent::GetComponentID() | |
104 | { | |
105 | // see header file for class documentation | |
106 | return "TPCZeroSuppression"; | |
107 | } | |
108 | ||
109 | void AliHLTTPCZeroSuppressionComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) | |
110 | { | |
111 | // see header file for class documentation | |
112 | list.clear(); | |
113 | list.push_back( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC ); | |
114 | } | |
115 | ||
116 | AliHLTComponentDataType AliHLTTPCZeroSuppressionComponent::GetOutputDataType() | |
117 | { | |
118 | // see header file for class documentation | |
092a1374 | 119 | return kAliHLTMultipleDataType; |
120 | //return kAliHLTDataTypeDDLRaw; | |
121 | // return AliHLTTPCDefinitions::fgkUnpackedRawDataType; | |
afa4418c | 122 | } |
123 | ||
124 | int AliHLTTPCZeroSuppressionComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList) | |
125 | { | |
126 | // see header file for class documentation | |
127 | tgtList.clear(); | |
092a1374 | 128 | tgtList.push_back(kAliHLTDataTypeDDLRaw); |
129 | tgtList.push_back(kAliHLTDataTypeHwAddr16); | |
afa4418c | 130 | return tgtList.size(); |
131 | } | |
132 | ||
133 | void AliHLTTPCZeroSuppressionComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) | |
134 | { | |
135 | // see header file for class documentation | |
136 | constBase=0; | |
a74855c2 | 137 | inputMultiplier=2.0; |
afa4418c | 138 | } |
139 | ||
140 | AliHLTComponent* AliHLTTPCZeroSuppressionComponent::Spawn() | |
141 | { | |
142 | // see header file for class documentation | |
143 | return new AliHLTTPCZeroSuppressionComponent(); | |
144 | } | |
145 | ||
146 | int AliHLTTPCZeroSuppressionComponent::DoInit( int argc, const char** argv ) | |
147 | { | |
148 | // see header file for class documentation | |
149 | ||
150 | Int_t i = 0; | |
151 | Char_t* cpErr; | |
152 | ||
153 | while ( i < argc ) { | |
154 | ||
155 | // -- zero suppression threshold | |
3789100d | 156 | if ( !strcmp( argv[i], "-signal-threshold" ) || !strcmp( argv[i], "signal-threshold" ) ) { |
afa4418c | 157 | fSignalThreshold = strtoul( argv[i+1], &cpErr ,0); |
158 | if ( *cpErr ) { | |
159 | HLTError("Cannot convert signal-threshold specifier '%s'.", argv[i+1]); | |
160 | return EINVAL; | |
161 | } | |
162 | i+=2; | |
163 | continue; | |
164 | } | |
165 | ||
166 | // -- checking for nsigma-threshold, used in 2007 December run in ZeroSuppression | |
3789100d | 167 | if ( !strcmp( argv[i], "-rms-threshold" ) || !strcmp( argv[i], "rms-threshold" ) ) { |
afa4418c | 168 | fNRMSThreshold = strtoul( argv[i+1], &cpErr ,0); |
169 | if ( *cpErr ){ | |
170 | HLTError("Cannot convert rms-threshold specifier '%s'. Must be integer", argv[i+1]); | |
171 | return EINVAL; | |
172 | } | |
173 | i+=2; | |
174 | continue; | |
175 | } | |
176 | ||
177 | // -- number of timebins | |
fec96a66 | 178 | if ( !strcmp( argv[i], "-timebins" ) || !strcmp( argv[i], "ntimebins" ) || !strcmp( argv[i], "-ntimebins" )) { |
afa4418c | 179 | fNTimeBins = strtoul( argv[i+1], &cpErr ,0); |
fec96a66 | 180 | AliHLTTPCTransform::SetNTimeBins(fNTimeBins); |
181 | if(fEndTimeBin>AliHLTTPCTransform::GetNTimeBins()){ | |
182 | fEndTimeBin = AliHLTTPCTransform::GetNTimeBins(); | |
183 | } | |
afa4418c | 184 | if ( *cpErr ) { |
185 | HLTError("Cannot convert ntimebins specifier '%s'.", argv[i+1]); | |
186 | return EINVAL; | |
187 | } | |
188 | i+=2; | |
189 | continue; | |
190 | } | |
191 | ||
192 | // -- first timebin | |
3789100d | 193 | if ( !strcmp( argv[i], "-start-timebin" ) || !strcmp( argv[i], "start-timebin" ) ) { |
afa4418c | 194 | fStartTimeBin = strtoul( argv[i+1], &cpErr ,0); |
195 | if ( *cpErr ) { | |
196 | HLTError("Cannot convert start-timebin specifier '%s'.", argv[i+1]); | |
197 | return EINVAL; | |
198 | } | |
199 | i+=2; | |
200 | continue; | |
201 | } | |
202 | ||
203 | // -- last timebin | |
3789100d | 204 | if ( !strcmp( argv[i], "-end-timebin" ) || !strcmp( argv[i], "end-timebin" ) ) { |
a74855c2 | 205 | if(strtoul( argv[i+1], &cpErr ,0)<=(UInt_t)AliHLTTPCTransform::GetNTimeBins()){ |
206 | fEndTimeBin = strtoul( argv[i+1], &cpErr ,0); | |
207 | } | |
afa4418c | 208 | if ( *cpErr ) { |
209 | HLTError("Cannot convert end-timebin specifier '%s'.", argv[i+1]); | |
210 | return EINVAL; | |
211 | } | |
212 | i+=2; | |
213 | continue; | |
214 | } | |
215 | ||
216 | // -- timebins to keep left of signal | |
3789100d | 217 | if ( !strcmp( argv[i], "-timebin-left" ) || !strcmp( argv[i], "timebin-left" ) ) { |
afa4418c | 218 | fLeftTimeBin = strtoul( argv[i+1], &cpErr ,0); |
219 | if ( *cpErr ) { | |
220 | HLTError("Cannot convert timebin-left specifier '%s'.", argv[i+1]); | |
221 | return EINVAL; | |
222 | } | |
223 | i+=2; | |
224 | continue; | |
225 | } | |
226 | ||
227 | // -- timebin to keep right of signal | |
3789100d | 228 | if ( !strcmp( argv[i], "-timebin-right" ) || !strcmp( argv[i], "timebin-right" ) ) { |
afa4418c | 229 | fRightTimeBin = strtoul( argv[i+1], &cpErr ,0); |
230 | if ( *cpErr ) { | |
231 | HLTError("Cannot convert timebin-right specifier '%s'.", argv[i+1]); | |
232 | return EINVAL; | |
233 | } | |
234 | i+=2; | |
235 | continue; | |
236 | } | |
237 | ||
238 | // -- value below average to subtract | |
3789100d | 239 | if ( !strcmp( argv[i], "-value-below-average" ) || !strcmp( argv[i], "value-below-average" ) ) { |
afa4418c | 240 | fValueBelowAverage = strtoul( argv[i+1], &cpErr ,0); |
241 | if ( *cpErr ) { | |
242 | HLTError("Cannot convert value-below-average specifier '%s'.", argv[i+1]); | |
243 | return EINVAL; | |
244 | } | |
245 | i+=2; | |
246 | continue; | |
247 | } | |
248 | ||
249 | // -- pad occupancy limit | |
3789100d | 250 | if ( !strcmp( argv[i], "-occupancy-limit" ) || !strcmp( argv[i], "occupancy-limit" ) ) { |
afa4418c | 251 | fMinimumNumberOfSignals = strtoul( argv[i+1], &cpErr ,0); |
252 | if ( *cpErr ) { | |
253 | HLTError("Cannot convert occupancy-limit specifier '%s'.", argv[i+1]); | |
254 | return EINVAL; | |
255 | } | |
256 | i+=2; | |
257 | continue; | |
258 | } | |
259 | ||
260 | // -- checking for rcu format | |
261 | if ( !strcmp( argv[i], "oldrcuformat" ) ) { | |
262 | fOldRCUFormat = strtoul( argv[i+1], &cpErr ,0); | |
263 | if ( *cpErr ){ | |
264 | HLTError("Cannot convert oldrcuformat specifier '%s'. Should be 0(off) or 1(on), must be integer", argv[i+1]); | |
265 | return EINVAL; | |
266 | } | |
267 | i+=2; | |
268 | continue; | |
269 | } | |
270 | ||
3789100d | 271 | // -- checking for pad sorting |
272 | if ( !strcmp( argv[i], "-sort-pads" ) || !strcmp( argv[i], "sort-pads" ) ) { | |
afa4418c | 273 | fSortPads = strtoul( argv[i+1], &cpErr ,0); |
274 | if ( *cpErr ){ | |
275 | HLTError("Cannot convert sort-pads specifier '%s'. Should be 0(off) or 1(on), must be integer", argv[i+1]); | |
276 | return EINVAL; | |
277 | } | |
278 | i+=2; | |
279 | continue; | |
280 | } | |
3789100d | 281 | |
282 | // -- checking for skipZSdatashipping | |
283 | if ( !strcmp( argv[i], "-skip-sending-data" ) ) { | |
284 | fSkipSendingZSData = kTRUE; | |
436467f5 | 285 | i++; |
286 | continue; | |
3789100d | 287 | } |
288 | ||
289 | // -- checking for hw address shipping | |
290 | if ( !strcmp( argv[i], "-send-hw-list" ) ) { | |
291 | fSendHWList = kTRUE; | |
436467f5 | 292 | i++; |
293 | continue; | |
3789100d | 294 | } |
afa4418c | 295 | |
296 | Logging(kHLTLogError, "HLT::TPCClusterFinder::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] ); | |
297 | return EINVAL; | |
298 | ||
299 | } | |
300 | ||
3789100d | 301 | if(fSkipSendingZSData == kTRUE && fSendHWList == kFALSE){ |
302 | HLTError("Component will have no output, check your configuration."); | |
303 | } | |
fec96a66 | 304 | |
3789100d | 305 | |
afa4418c | 306 | HLTDebug("using AliHLTTPCDigitReaderDecoder"); |
307 | fDigitReader = new AliHLTTPCDigitReaderDecoder(); | |
308 | ||
a74855c2 | 309 | fHwAddressList.clear(); |
310 | ||
afa4418c | 311 | return 0; |
312 | } | |
313 | ||
314 | int AliHLTTPCZeroSuppressionComponent::DoDeinit() | |
315 | { | |
316 | // see header file for class documentation | |
afa4418c | 317 | return 0; |
318 | } | |
319 | ||
320 | Int_t AliHLTTPCZeroSuppressionComponent::DeInitializePadArray() | |
321 | { | |
322 | // see header file for class documentation | |
323 | if(fVectorInitialized){ | |
324 | for(Int_t i=0;i<fNumberOfRows;i++){ | |
325 | for(Int_t j=0;j<fNumberOfPadsInRow[i];j++){ | |
326 | delete fRowPadVector[i][j]; | |
327 | fRowPadVector[i][j]=NULL; | |
328 | } | |
329 | fRowPadVector[i].clear(); | |
330 | } | |
331 | fRowPadVector.clear(); | |
332 | } | |
afa4418c | 333 | return 1; |
334 | } | |
335 | ||
336 | void AliHLTTPCZeroSuppressionComponent::InitializePadArray(){ | |
337 | // see header file for class documentation | |
a74855c2 | 338 | if(fCurrentPatch>5){ |
afa4418c | 339 | HLTFatal("Patch is not set"); |
340 | return; | |
341 | } | |
342 | ||
343 | fFirstRow = AliHLTTPCTransform::GetFirstRow(fCurrentPatch); | |
344 | fLastRow = AliHLTTPCTransform::GetLastRow(fCurrentPatch); | |
345 | ||
346 | fNumberOfRows=fLastRow-fFirstRow+1; | |
a74855c2 | 347 | fNumberOfPadsInRow= new Int_t[fNumberOfRows]; |
afa4418c | 348 | |
349 | memset( fNumberOfPadsInRow, 0, sizeof(Int_t)*(fNumberOfRows)); | |
350 | ||
351 | for(Int_t i=0;i<fNumberOfRows;i++){ | |
352 | fNumberOfPadsInRow[i]=AliHLTTPCTransform::GetNPads(i+fFirstRow); | |
353 | AliHLTTPCPadVector tmpRow; | |
354 | for(Int_t j=0;j<fNumberOfPadsInRow[i];j++){ | |
355 | AliHLTTPCPad *tmpPad = new AliHLTTPCPad(); | |
356 | tmpPad->SetID(i,j); | |
357 | tmpRow.push_back(tmpPad); | |
358 | } | |
359 | fRowPadVector.push_back(tmpRow); | |
360 | } | |
361 | fVectorInitialized=kTRUE; | |
362 | } | |
363 | ||
364 | ||
365 | int AliHLTTPCZeroSuppressionComponent::DoEvent( const AliHLTComponentEventData& evtData, | |
366 | const AliHLTComponentBlockData* blocks, | |
367 | AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, | |
368 | AliHLTUInt32_t& size, | |
369 | vector<AliHLTComponentBlockData>& outputBlocks ) | |
370 | { | |
371 | // see header file for class documentation | |
5cccaefd | 372 | int iResult=0; |
373 | if (!fDigitReader) return -ENODEV; | |
374 | ||
375 | AliHLTUInt32_t capacity=size; | |
376 | size=0; | |
377 | if (!IsDataEvent()) return 0; | |
afa4418c | 378 | |
a74855c2 | 379 | // HLTInfo("Entered DoEvent in AliHLTTPCZeroSuppressionComponent"); |
afa4418c | 380 | |
381 | // == init iter (pointer to datablock) | |
382 | const AliHLTComponentBlockData* iter = NULL; | |
383 | unsigned long ndx; | |
384 | // HLTInfo("Number of blocks: ",evtData.fBlockCnt); | |
385 | ||
a74855c2 | 386 | fHwAddressList.clear(); |
afa4418c | 387 | //reading the data |
388 | for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) | |
389 | { | |
390 | iter = blocks+ndx; | |
391 | ||
392 | HLTDebug("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s", | |
393 | evtData.fEventID, evtData.fEventID, | |
394 | DataType2Text( iter->fDataType).c_str(), | |
395 | DataType2Text(kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC).c_str()); | |
396 | ||
5cccaefd | 397 | if ( iter->fDataType != (kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC)){ |
afa4418c | 398 | continue; |
399 | } | |
400 | ||
afa4418c | 401 | UInt_t slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter ); |
402 | UInt_t patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter ); | |
403 | ||
404 | if(!fVectorInitialized){ | |
405 | fCurrentPatch=patch; | |
406 | InitializePadArray(); | |
407 | } | |
408 | ||
436467f5 | 409 | if(fDigitReader->InitBlock(iter->fPtr,iter->fSize,patch,slice)<0){ |
410 | HLTWarning("Decoder failed to initialize, event aborted."); | |
411 | continue; | |
412 | } | |
5cccaefd | 413 | AliHLTTPCMapping mapping(patch); |
436467f5 | 414 | |
5cccaefd | 415 | int nTotalChannels=0; |
416 | int nSkippedChannels=0; | |
417 | short lowestOccupancy=-1; | |
418 | float sumOccupancy=0; | |
9b4f7f90 | 419 | |
afa4418c | 420 | //Here the reading of the data and the zerosuppression takes place |
421 | while(fDigitReader->NextChannel()){//Pad | |
1d7dab5e | 422 | int sumSignals=0; |
423 | int maxSignal=0; | |
424 | int nofSignals=0; | |
a74855c2 | 425 | Int_t row=fDigitReader->GetRow(); |
426 | Int_t pad=fDigitReader->GetPad(); | |
9b4f7f90 | 427 | if(row==1000 || pad==1000){ |
428 | continue; | |
429 | } | |
a74855c2 | 430 | if(row>=fNumberOfRows||row<0){ |
9b4f7f90 | 431 | continue; |
432 | } | |
a74855c2 | 433 | else if(pad>=fNumberOfPadsInRow[row]||pad<0){ |
436467f5 | 434 | continue; |
9b4f7f90 | 435 | } |
9b4f7f90 | 436 | |
1d7dab5e | 437 | AliHLTTPCPad *tmpPad = NULL; |
438 | if (!fSkipSendingZSData) tmpPad=fRowPadVector[row][pad]; | |
439 | if (tmpPad) tmpPad->SetDataToDefault(); | |
74b8bf74 | 440 | |
afa4418c | 441 | //reading data to pad |
442 | while(fDigitReader->NextBunch()){ | |
443 | const UInt_t *bunchData= fDigitReader->GetSignals(); | |
a74855c2 | 444 | Int_t time=fDigitReader->GetTime(); |
afa4418c | 445 | for(Int_t i=0;i<fDigitReader->GetBunchSize();i++){ |
446 | if(bunchData[i]>0){// disregarding 0 data. | |
447 | if(time+i>=fStartTimeBin && time+i<=fEndTimeBin){ | |
1d7dab5e | 448 | if (tmpPad) tmpPad->SetDataSignal(time+i,bunchData[i]); |
449 | sumSignals+=bunchData[i]; | |
450 | if (maxSignal<(int)bunchData[i]) maxSignal=bunchData[i]; | |
451 | nofSignals++; | |
afa4418c | 452 | } |
453 | } | |
454 | } | |
455 | } | |
5cccaefd | 456 | |
457 | nTotalChannels++; | |
1d7dab5e | 458 | if (lowestOccupancy<0 || lowestOccupancy>nofSignals) |
459 | lowestOccupancy=nofSignals; | |
460 | sumOccupancy+=nofSignals; | |
5cccaefd | 461 | |
1d7dab5e | 462 | if(nofSignals>=fMinimumNumberOfSignals){ |
463 | if (tmpPad) { | |
74b8bf74 | 464 | tmpPad->ZeroSuppress(fNRMSThreshold, fSignalThreshold, fMinimumNumberOfSignals, fStartTimeBin, fEndTimeBin, fLeftTimeBin, fRightTimeBin, fValueBelowAverage, fSkipSendingZSData); |
436467f5 | 465 | if(tmpPad->GetNAddedSignals()>0){ |
5cccaefd | 466 | assert((int)mapping.GetRow(fDigitReader->GetAltroBlockHWaddr())==row); |
467 | assert((int)mapping.GetPad(fDigitReader->GetAltroBlockHWaddr())==pad); | |
436467f5 | 468 | fHwAddressList.push_back((AliHLTUInt16_t)fDigitReader->GetAltroBlockHWaddr()); |
469 | } | |
1d7dab5e | 470 | } else { |
471 | assert(fSkipSendingZSData); | |
472 | if (nofSignals>0 && maxSignal>(sumSignals/nofSignals)+fSignalThreshold) { | |
473 | fHwAddressList.push_back((AliHLTUInt16_t)fDigitReader->GetAltroBlockHWaddr()); | |
474 | } | |
475 | } | |
5cccaefd | 476 | } else { |
477 | nSkippedChannels++; | |
afa4418c | 478 | } |
479 | } | |
5cccaefd | 480 | if (nSkippedChannels>0) { |
481 | HLTWarning("skipped %d of %d channels because of low occupancy: average %.2f, lowest %d, threshold %d", | |
482 | nSkippedChannels, nTotalChannels, sumOccupancy/nTotalChannels, lowestOccupancy, fMinimumNumberOfSignals); | |
483 | } | |
092a1374 | 484 | |
5cccaefd | 485 | AliHLTUInt32_t dataOffsetBeforeHW=0; |
486 | ||
487 | if(fSkipSendingZSData == kFALSE && iter->fSize>sizeof(AliRawDataHeader)) { | |
2fdb1ae7 | 488 | |
436467f5 | 489 | AliHLTAltroEncoder *altroEncoder = new AliHLTAltroEncoder; |
5cccaefd | 490 | altroEncoder->SetBuffer(outputPtr,capacity); //tests if one overwrite the buffer is done in the encoder |
491 | ||
492 | // set CDH from the beginning of buffer | |
493 | altroEncoder->SetCDH((AliHLTUInt8_t*)iter->fPtr,sizeof(AliRawDataHeader)); | |
436467f5 | 494 | |
495 | UChar_t *RCUTrailer=NULL; | |
496 | Int_t RCUTrailerSize=fDigitReader->GetRCUTrailerSize(); | |
436467f5 | 497 | if (RCUTrailerSize<=0 || !fDigitReader->GetRCUTrailerData( RCUTrailer )) { |
498 | if(RCUTrailer==NULL){ | |
499 | HLTWarning("can not find RCU trailer for data block %s 0x%08x: skipping data block", | |
500 | DataType2Text(iter->fDataType).c_str(), iter->fSpecification); | |
501 | continue; | |
092a1374 | 502 | } |
afa4418c | 503 | } |
436467f5 | 504 | altroEncoder->SetRCUTrailer(RCUTrailer, RCUTrailerSize); |
505 | ||
5cccaefd | 506 | for(unsigned int channel=0; channel<fHwAddressList.size(); channel++){ |
507 | int row=mapping.GetRow(fHwAddressList[channel]); | |
508 | int pad=mapping.GetPad(fHwAddressList[channel]); | |
509 | if (true) { | |
436467f5 | 510 | AliHLTTPCPad * zeroSuppressedPad= fRowPadVector[row][pad]; |
511 | Int_t currentTime=0; | |
512 | Int_t bunchSize=0; | |
513 | if(zeroSuppressedPad->GetNAddedSignals()>0){ | |
514 | while(zeroSuppressedPad->GetNextGoodSignal(currentTime, bunchSize)){ | |
515 | for(Int_t i=0;i<bunchSize;i++){ | |
5cccaefd | 516 | if (altroEncoder->AddSignal((AliHLTUInt16_t)(zeroSuppressedPad->GetDataSignal(currentTime+i)),(AliHLTUInt16_t)(currentTime+i))<0) { |
517 | // Matthias 01.10.2008: there is a problem with certain real data which produces the same | |
518 | // bunch multiple times, needs investigation. I found an examplary case in run 53465 | |
519 | // (08000053465011.450.root) equipment 981. | |
520 | // needs to be followed up. | |
521 | // addon 02.10.2008 I just corrected a bug concerning the loop over the active channels. | |
522 | // A double loop over all rows and pads also considered pads which had not even been | |
523 | // filled, and thus not properly cleaned. Maybe the bug above is related to that. | |
524 | HLTWarning("can not add channel: slice %d, partition %d, hw address %d, row %d, pad %d, time %d, bunch size %d", | |
525 | slice, patch, fHwAddressList[channel], row, pad, currentTime+i, bunchSize); | |
526 | break; | |
527 | } | |
436467f5 | 528 | } |
529 | } | |
5cccaefd | 530 | altroEncoder->SetChannel(fHwAddressList[channel]); |
436467f5 | 531 | } |
532 | } | |
533 | } | |
092a1374 | 534 | |
436467f5 | 535 | int sizeOfData=altroEncoder->SetLength(); |
092a1374 | 536 | |
436467f5 | 537 | if (sizeOfData<0) { |
538 | HLTError("data encoding failed"); | |
5cccaefd | 539 | iResult=sizeOfData; |
540 | break; | |
436467f5 | 541 | } |
5cccaefd | 542 | if(sizeOfData>(int)capacity){ |
543 | HLTWarning("Buffer too small too add the altrodata: %d of %d byte(s) already used", sizeOfData, capacity); | |
544 | iResult=-ENOSPC; | |
545 | break; | |
436467f5 | 546 | } |
3789100d | 547 | |
436467f5 | 548 | //Push back the zerosuppressed altro data to the output |
5cccaefd | 549 | if(true/* condition was deprecated but keep for the sake of formatting*/){ |
436467f5 | 550 | AliHLTComponentBlockData bd; |
551 | FillBlockData( bd ); | |
552 | bd.fOffset = 0; | |
553 | bd.fSize = sizeOfData; | |
554 | bd.fDataType = kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC; | |
555 | bd.fSpecification = iter->fSpecification; | |
436467f5 | 556 | outputBlocks.push_back( bd ); |
3789100d | 557 | |
436467f5 | 558 | //Push back the list of hardware addresses to the output |
559 | dataOffsetBeforeHW=sizeOfData; | |
560 | } | |
5cccaefd | 561 | } |
092a1374 | 562 | |
5cccaefd | 563 | AliHLTUInt32_t sizeOfHWArray = 0; |
564 | if(fSendHWList == kTRUE){ | |
3789100d | 565 | |
5cccaefd | 566 | if(true/* condition was deprecated but keep for the sake of formatting*/){ |
436467f5 | 567 | sizeOfHWArray = fHwAddressList.size()*sizeof(AliHLTUInt16_t); |
3789100d | 568 | |
5cccaefd | 569 | if(dataOffsetBeforeHW+sizeOfHWArray>capacity){ |
570 | HLTWarning("Buffer too small too add the active channels: %d of %d byte(s) already used", dataOffsetBeforeHW + sizeOfHWArray, capacity); | |
571 | iResult=-ENOSPC; | |
572 | break; | |
436467f5 | 573 | } |
3789100d | 574 | |
436467f5 | 575 | AliHLTUInt16_t*outputHWPtr=(AliHLTUInt16_t*)(outputPtr+dataOffsetBeforeHW); |
576 | memcpy(outputHWPtr,&fHwAddressList[0],sizeOfHWArray); | |
577 | AliHLTComponentBlockData bdHW; | |
578 | FillBlockData( bdHW ); | |
579 | bdHW.fOffset = dataOffsetBeforeHW; | |
580 | bdHW.fSize = sizeOfHWArray; | |
5cccaefd | 581 | bdHW.fDataType = kAliHLTDataTypeHwAddr16|kAliHLTDataOriginTPC; |
436467f5 | 582 | bdHW.fSpecification = iter->fSpecification; |
436467f5 | 583 | outputBlocks.push_back( bdHW ); |
584 | } | |
436467f5 | 585 | } |
5cccaefd | 586 | size = dataOffsetBeforeHW+sizeOfHWArray; |
436467f5 | 587 | fDigitReader->Reset(); |
3789100d | 588 | } |
092a1374 | 589 | |
5cccaefd | 590 | if (iResult<0) { |
591 | fDigitReader->Reset(); | |
592 | size=0; | |
593 | } | |
594 | ||
595 | return iResult; | |
afa4418c | 596 | } |