]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/PHOS/AliHLTPHOSRawAnalyzerComponent.cxx
Modified files to use constants declared in the
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSRawAnalyzerComponent.cxx
CommitLineData
cbab66dd 1/**************************************************************************
99388135 2 * This file is property of and copyright by the Experimental Nuclear *
3 * Physics Group, Dep. of Physics *
4 * University of Oslo, Norway, 2007 *
5 * *
6 * Author: Per Thomas Hille <perthi@fys.uio.no> for the ALICE HLT Project.*
cbab66dd 7 * Contributors are mentioned in the code where appropriate. *
99388135 8 * Please report bugs to perthi@fys.uio.no *
cbab66dd 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
2b7cf4fb 19
20/// @class AliHLTPHOSRawAnalyzerComponent
21/// Base class of PHOS HLT online raw analysis component.
22/// The class provides a common interface for the implementation of PHOS
23/// HLT raw data
24/// processors components. The class is intended for processing of
25/// arrays of raw data samples to evaluate energy and timing.
26/// The Energy will be given in entities of ADC leves ranging from 0 to
27/// 1023. Timing will be given in entities of samples periods.
28/// Drived clases must implement the fucntions
29/// - @ref GetComponentID
30/// - @ref Spawn
31
2b7cf4fb 32#include "AliHLTPHOSRawAnalyzer.h"
cbab66dd 33#include "AliHLTPHOSRawAnalyzerComponent.h"
9dfd64cf 34#include "AliRawReaderMemory.h"
0a211711 35#include "AliCaloRawStream.h"
bde48b84 36#include "AliHLTPHOSRcuCellEnergyDataStruct.h"
2b7cf4fb 37#include "AliHLTPHOSRcuChannelDataStruct.h"
e086ee30 38#include "AliHLTDDLDecoder.h"
39#include "AliHLTAltroData.h"
cbab66dd 40
e086ee30 41#include "AliHLTPHOSMapper.h"
ee7849e6 42
d2a0b488 43using namespace std;
4df5dd10 44
2b7cf4fb 45
d504c864 46//_________________________________________________________________________________________________
d2a0b488 47AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent():AliHLTPHOSProcessor(), fAnalyzerPtr(0),
48fSendChannelData(kFALSE),fPHOSRawStream(0), fRawMemoryReader(0), fOutPtr(0)
cbab66dd 49{
e086ee30 50 fMapperPtr = new AliHLTPHOSMapper();
d504c864 51}
2b7cf4fb 52
d504c864 53//_________________________________________________________________________________________________
cbab66dd 54AliHLTPHOSRawAnalyzerComponent::~AliHLTPHOSRawAnalyzerComponent()
55{
0a211711 56 if(fRawMemoryReader != 0)
57 {
58 delete fRawMemoryReader;
59 }
60 if(fPHOSRawStream != 0)
61 {
62 delete fPHOSRawStream;
63 }
cbab66dd 64}
65
d504c864 66//_________________________________________________________________________________________________
d2a0b488 67AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent(const AliHLTPHOSRawAnalyzerComponent & ) : AliHLTPHOSProcessor(), fAnalyzerPtr(0),
68fSendChannelData(kFALSE),fPHOSRawStream(0), fRawMemoryReader(0), fOutPtr(0)
cbab66dd 69{
cbab66dd 70
cbab66dd 71}
72
d504c864 73//_________________________________________________________________________________________________
cbab66dd 74int
d2a0b488 75AliHLTPHOSRawAnalyzerComponent::Deinit()
cbab66dd 76{
d2a0b488 77 Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSRawAnalyzerComponen Deinit");
9dfd64cf 78
0a211711 79 if(fRawMemoryReader !=0)
80 {
81 delete fRawMemoryReader;
82 }
83
84 if(fPHOSRawStream != 0)
85 {
86 delete fPHOSRawStream;
87 }
cbab66dd 88 return 0;
cbab66dd 89
d2a0b488 90 return 0;
cbab66dd 91}
92
d504c864 93//_________________________________________________________________________________________________
9dfd64cf 94const char*
95AliHLTPHOSRawAnalyzerComponent::GetComponentID()
96{
97 return "AliPhosTestRaw";
98}
ee7849e6 99
1c1b3412 100
d504c864 101//_________________________________________________________________________________________________
cbab66dd 102void
ee7849e6 103AliHLTPHOSRawAnalyzerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
cbab66dd 104{
146c463a 105 const AliHLTComponentDataType* pType=fgkInputDataTypes;
ee7849e6 106 while (pType->fID!=0) {
107 list.push_back(*pType);
108 pType++;
109 }
cbab66dd 110}
111
d504c864 112//_________________________________________________________________________________________________
cbab66dd 113AliHLTComponentDataType
114AliHLTPHOSRawAnalyzerComponent::GetOutputDataType()
115{
d504c864 116 return AliHLTPHOSDefinitions::fgkCellEnergyDataType;
cbab66dd 117}
118
d504c864 119
120//_________________________________________________________________________________________________
cbab66dd 121void
9dfd64cf 122AliHLTPHOSRawAnalyzerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
123
cbab66dd 124{
ef408bb3 125 constBase = 30;
2b7cf4fb 126 inputMultiplier = 1;
cbab66dd 127}
128
d504c864 129//_________________________________________________________________________________________________
130int
131AliHLTPHOSRawAnalyzerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
cbab66dd 132{
e086ee30 133 // cout << "AliHLTPHOSRawAnalyzerComponent::DoEven" << endl;
134 // cout << "AliHLTPHOSRawAnalyzerComponent::DoEven" << endl;
135 // cout << "evtData.fStructSize" << evtData.fStructSize << endl;
136 // cout << "evtData.fEventID" << evtData.fEventID << endl ;
137 cout << "AliHLTPHOSRawAnalyzerComponent::DoEvent: evtData.fBlockCnt = " << evtData.fBlockCnt << endl ;
138 // cout << "size =" << size << endl;
139 // cout << "blocks->fSize =" << blocks->fSize << endl;
140 // cout << "blocks->fOffset =" << blocks->fOffset << endl;
141
142 // AliHLTUInt8_t tmpMod = 0;
143 // AliHLTUInt8_t tmpZ = 0;
144 // AliHLTUInt8_t tmpX = 0;
145 // AliHLTUInt8_t tmpGain = 0;
bde48b84 146 Int_t sampleCnt = 0;
2947a32c 147 Int_t processedChannels = 0;
bde48b84 148 UInt_t offset = 0;
149 UInt_t mysize = 0;
150 UInt_t tSize = 0;
2bcb5a06 151 Int_t tmpChannelCnt = 0;
432edd34 152 Int_t tmpStartIndex = 0;
53740333 153 AliHLTUInt8_t* outBPtr;
2b7cf4fb 154 unsigned long first;
155 unsigned long last;
53740333 156 outBPtr = outputPtr;
0a211711 157 const AliHLTComponentBlockData* iter = NULL;
158 unsigned long ndx;
cf434398 159
e086ee30 160
0a211711 161 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
162 {
e086ee30 163 printf("\nNEW DDL BLOCK\n");
164
0a211711 165 iter = blocks+ndx;
53740333 166 mysize = 0;
167 offset = tSize;
168
d504c864 169 if ( iter->fDataType != AliHLTPHOSDefinitions::fgkDDLPackedRawDataType )
0a211711 170 {
e086ee30 171 cout <<"WARNING: notAliHLTPHOSDefinitions::fgkDDLPackedRawDataTyp " << endl;
172 // continue;
0a211711 173 }
ef408bb3 174
e086ee30 175
176 fDecoderPtr->SetMemory(reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize);
177
178 fDecoderPtr->Decode();
179
180
181 fOutPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)outBPtr;
182
183 int tmpCnt = 0;
184 printf("\n********** NEW EVENT ************\n");
185 printf("\n********************************");
186 printf("\n********************************");
187 printf("\n********************************\n");
188
189 while( fDecoderPtr->NextChannel(fAltroDataPtr) == true )
190 {
191
192 // fDecoderPtr->NextChannel(fAltroDataPtr);
193
194 fAnalyzerPtr->SetData(fAltroDataPtr->fData);
195 fAnalyzerPtr->Evaluate(0, fAltroDataPtr->fDataSize);
196 // fOutPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)outBPtr;
197
198
199
200 fOutPtr->fValidData[tmpChannelCnt].fGain = fMapperPtr->ALTRO_MAP[fAltroDataPtr->fHadd].gain;
201 fOutPtr->fValidData[tmpChannelCnt].fZ = fMapperPtr->ALTRO_MAP[fAltroDataPtr->fHadd].row;
202 fOutPtr->fValidData[tmpChannelCnt].fX = fMapperPtr->ALTRO_MAP[fAltroDataPtr->fHadd].col;
203 fOutPtr->fValidData[tmpChannelCnt].fEnergy = (float)fAnalyzerPtr->GetEnergy();
204 fOutPtr->fValidData[tmpChannelCnt].fTime = (float)fAnalyzerPtr->GetTiming();
205 tmpChannelCnt ++;
206
207
208 if(tmpCnt < 1)
209 {
210
211 printf("\n******New ALTRO BLOCK**********\n");
212 printf("tmpCnt = %d \n", tmpCnt);
213 printf("size = %d\n", fAltroDataPtr->fDataSize);
214 printf("harware adress = %d\n", fAltroDataPtr->fHadd);
215 // DumpData(fAltroDataPtr->fData, fAltroDataPtr->fDataSize, 4);
216 DumpData(fAltroDataPtr->fData, 128, 4);
217 // cout << "gain =" <<fMapperPtr->ALTRO_MAP[fAltroDataPtr->fHadd].gain << endl;
218 // cout << "row =" <<fMapperPtr->ALTRO_MAP[fAltroDataPtr->fHadd].row << endl;
219 // cout << "col =" <<fMapperPtr->ALTRO_MAP[fAltroDataPtr->fHadd].col << endl;
220 // cout << "Channel = " << fAltroDataPtr->GetChannel()<< endl;
221 // cout << "Chip = " << fAltroDataPtr->GetChip()<< endl;
222 // cout << "Card = " << fAltroDataPtr->GetCard()<< endl;
223 // cout << "Branch = " << fAltroDataPtr->GetBranch()<< endl;
224 // DumpData(fAltroDataPtr->fData, fAltroDataPtr->fDataSize , 4);
225 printf("\n****** END altroblock **********\n");
226 }
227
228 tmpCnt ++;
229
230 // printf("harware adress = %d\n", fAltroDataPtr->fHadd);
231 // printf("size = %d\n", fAltroDataPtr->fDataSize);
232 }
233
234
235 mysize += sizeof(AliHLTPHOSRcuCellEnergyDataStruct);
236 // cout <<"Pushing data block" << endl;
237
238 fOutPtr->fCnt = tmpChannelCnt;
239 AliHLTComponentBlockData bd;
240 FillBlockData( bd );
241 bd.fOffset = offset;
242 bd.fSize = mysize;
243
244 bd.fDataType = AliHLTPHOSDefinitions::fgkCellEnergyDataType;
245 bd.fSpecification = 0xFFFFFFFF;
246 outputBlocks.push_back( bd );
247
248 tSize += mysize;
249 outBPtr += mysize;
250
251 if( tSize > size )
252 {
253 cout <<"kHLTLogFatal, HLT::AliHLTPHOSRawAnalyzerComponent::DoEvent Too much data Data written over allowed buffer. Amount written:"
254 << tSize << " allowed" << size << endl;
255 Logging( kHLTLogFatal, "HLT::AliHLTPHOSRawAnalyzerComponent::DoEvent", "Too much data",
256 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
257 , tSize, size );
258 return EMSGSIZE;
259 }
260
261 printf("\nEND DDL BLOCK\n");
262
263
264 }
265
266 fPhosEventCount++;
267
268 if(fPrintInfo == kTRUE)
269 {
270 if(fPhosEventCount%fPrintInfoFrequncy == 0)
271 {
272 cout <<"Analyzing event " << fPhosEventCount << "for Equippment " << fkEquippmentID << endl;
273 }
274 }
275 size = tSize;
276
277 return 0;
278}//end DoEvent
279
280
281
282
283
284 // printf("\nRawAnalyzer: printing data\n");
285
286
287 /*
288 int cnt = 0;
289
290 for(int i=0; i< 100; i ++)
291 {
292 if(cnt%4 == 0) printf("\n");
293 printf(":%d\t",fAltroDataPtr->fData[i] );
294 cnt ++;
295 }
296 */
297 // }
298
299
300
301
302 // while( fDecoderPtr->NextChannel(fAltroDataPtr))
303 // {
304 // fAnalyzerPtr->SetData(fTmpChannelData);
305 // }
306
307 /*
308
a00e1689 309 fOutPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)outBPtr;
bde48b84 310 mysize += sizeof(AliHLTPHOSRcuCellEnergyDataStruct);
a00e1689 311 fOutPtr->fRcuX = fRcuX;
312 fOutPtr->fRcuZ = fRcuZ;
313 fOutPtr->fModuleID = fModuleID;
2bcb5a06 314 tmpChannelCnt = 0;
e086ee30 315
316
317 while(fPHOSRawStream->Next())
2947a32c 318 {
319 if (fPHOSRawStream->IsNewHWAddress())
320 {
321 if(processedChannels > 0)
322 {
e56d0892 323 // cout << "rawanalyzer fPHOSRawStream->IsNewHWAddress()" <<endl;
146c463a 324 fAnalyzerPtr->SetData(fTmpChannelData);
325 fAnalyzerPtr->Evaluate(0, sampleCnt);
a00e1689 326 fOutPtr->fValidData[tmpChannelCnt].fGain = tmpGain;
1c1b3412 327 fOutPtr->fValidData[tmpChannelCnt].fZ = tmpZ;
328 fOutPtr->fValidData[tmpChannelCnt].fX = tmpX;
2b7cf4fb 329 fOutPtr->fValidData[tmpChannelCnt].fEnergy = (float)fAnalyzerPtr->GetEnergy();
330 fOutPtr->fValidData[tmpChannelCnt].fTime = (float)fAnalyzerPtr->GetTiming();
432edd34 331 ResetDataPtr(tmpStartIndex, sampleCnt);
2b7cf4fb 332 tmpChannelCnt ++;
68d9caee 333 sampleCnt = 0;
2947a32c 334 }
335
1c1b3412 336 tmpMod = (AliHLTUInt8_t)fPHOSRawStream->GetModule() ;
1c1b3412 337 tmpX =(AliHLTUInt8_t)fPHOSRawStream->GetRow() - fRcuXOffset;
338 tmpZ =(AliHLTUInt8_t)fPHOSRawStream->GetColumn() - fRcuZOffset;
2947a32c 339 tmpGain = fPHOSRawStream->IsLowGain();
340 processedChannels ++;
341 }
432edd34 342
343 if(sampleCnt == 0)
344 {
345 tmpStartIndex = fPHOSRawStream->GetTime();
346 }
e086ee30 347
2947a32c 348 fTmpChannelData[fPHOSRawStream->GetTime()] = fPHOSRawStream->GetSignal();
bde48b84 349 sampleCnt ++;
e086ee30 350
2947a32c 351 }
2b7cf4fb 352
006ee9b2 353 tmpChannelCnt ++;
e086ee30 354
355 cout <<"tmpChannnelCnt =" << tmpChannelCnt << endl;
356 // DumpChannelData(fTmpChannelData);
146c463a 357 fAnalyzerPtr->SetData(fTmpChannelData);
358 fAnalyzerPtr->Evaluate(0, sampleCnt);
006ee9b2 359 fOutPtr->fValidData[tmpChannelCnt].fGain = tmpGain;
360 fOutPtr->fValidData[tmpChannelCnt].fZ = tmpZ;
361 fOutPtr->fValidData[tmpChannelCnt].fX = tmpX;
146c463a 362 fOutPtr->fValidData[tmpChannelCnt].fEnergy = fAnalyzerPtr->GetEnergy();
363 fOutPtr->fValidData[tmpChannelCnt].fTime = fAnalyzerPtr->GetTiming();
857f8ed5 364 ResetDataPtr(tmpStartIndex, sampleCnt);
006ee9b2 365
2b7cf4fb 366 sampleCnt = 0;
a00e1689 367 fOutPtr->fCnt = tmpChannelCnt;
53740333 368 AliHLTComponentBlockData bd;
369 FillBlockData( bd );
53740333 370 bd.fOffset = offset;
e086ee30 371
53740333 372 bd.fSize = mysize;
d504c864 373 bd.fDataType = AliHLTPHOSDefinitions::fgkCellEnergyDataType;
9ce19a20 374 bd.fSpecification = 0xFFFFFFFF;
53740333 375 outputBlocks.push_back( bd );
53740333 376 tSize += mysize;
377 outBPtr += mysize;
2b7cf4fb 378
cf434398 379 if( tSize > size )
2b7cf4fb 380 {
381 cout <<"kHLTLogFatal, HLT::AliHLTPHOSRawAnalyzerComponent::DoEvent Too much data Data written over allowed buffer. Amount written:" << tSize << " allowed" << size << endl;
382 Logging( kHLTLogFatal, "HLT::AliHLTPHOSRawAnalyzerComponent::DoEvent", "Too much data",
383 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
384 , tSize, size );
385 return EMSGSIZE;
386 }
e086ee30 387 */
53740333 388
e086ee30 389
390
391/*
d2a0b488 392 fPhosEventCount++;
2b7cf4fb 393
394 if(fPrintInfo == kTRUE)
395 {
d2a0b488 396 if(fPhosEventCount%fPrintInfoFrequncy == 0)
2b7cf4fb 397 {
d2a0b488 398 cout <<"Analyzing event " << fPhosEventCount << "for Equippment " << fkEquippmentID << endl;
2b7cf4fb 399 }
400 }
53740333 401 size = tSize;
e086ee30 402
2947a32c 403 return 0;
404}//end DoEvent
e086ee30 405*/
406
0a211711 407
408
d504c864 409//_________________________________________________________________________________________________
0a211711 410int
411AliHLTPHOSRawAnalyzerComponent::DoInit( int argc, const char** argv )
412{
e086ee30 413
414cout <<"AliHLTPHOSRawAnalyzerComponent::DoInit( int argc, const char** argv ) "<< endl;
415
416 fAltroDataPtr = new AliHLTAltroData();
417 fDecoderPtr = new AliHLTDDLDecoder();
2b7cf4fb 418 fSendChannelData = kFALSE;
419 fPrintInfo = kFALSE;
2947a32c 420 Reset();
0a211711 421 fRawMemoryReader = new AliRawReaderMemory();
422 fPHOSRawStream = new AliCaloRawStream(fRawMemoryReader,"PHOS");
e086ee30 423
424 // fPHOSRawStream->SetOldRCUFormat(kFALSE);
425
426 fPHOSRawStream->SetOldRCUFormat(kTRUE);
427
2b7cf4fb 428 int iResult=0;
429 TString argument="";
d2a0b488 430 iResult = ScanArguments(argc, argv);
2b7cf4fb 431
432
d2a0b488 433 if(fIsSetEquippmentID == kFALSE)
2b7cf4fb 434 {
e56d0892 435 cout << "The argument equippmentID is not set: set it with a component argumet like this: -equippmentID <number>" << endl;
2b7cf4fb 436 Logging( kHLTLogFatal, "HLT::AliHLTPHOSRcuHistogramProducerComponent::DoInt( int argc, const char** argv )", "Missing argument",
437 "The argument equippmentID is not set: set it with a component argumet like this: -equippmentID <number>");
e086ee30 438 iResult = -3;
2b7cf4fb 439 }
d2a0b488 440 else
441 {
442 fRawMemoryReader->SetEquipmentID(fkEquippmentID);
443 }
2b7cf4fb 444
d2a0b488 445 return iResult;
e086ee30 446
447
448return 0;
449
0a211711 450}
9dfd64cf 451
e086ee30 452/*
d504c864 453//_________________________________________________________________________________________________
2ca5f55f 454void
455AliHLTPHOSRawAnalyzerComponent::DumpData(int gain) const
0a211711 456{
432edd34 457 for(int mod = 0; mod < N_MODULES; mod ++)
2947a32c 458 {
459 printf("\n *********** MODULE %d ************\n", mod);
432edd34 460 for(int row = 0; row < N_ROWS_MOD; row ++)
2947a32c 461 {
432edd34 462 for(int col = 0; col < N_COLUMNS_MOD; col ++)
2947a32c 463 {
464 if( fMaxValues[mod][row][col][0] != 0)
465 {
432edd34 466 cout << fMaxValues[mod][row][col][gain] << "\t";
2947a32c 467 }
468 }
469 }
470 }
471}
e086ee30 472*/
9dfd64cf 473
432edd34 474
d504c864 475//_________________________________________________________________________________________________
2ca5f55f 476void
477AliHLTPHOSRawAnalyzerComponent::DumpChannelData(Double_t *data) const
68d9caee 478{
d2a0b488 479 cout << endl;
480 for(int i=0; i< ALTRO_MAX_SAMPLES; i++)
481 {
482 if (data[i] != 0)
68d9caee 483 {
d2a0b488 484 cout <<i <<"\t";
68d9caee 485 }
d2a0b488 486 }
487 cout << endl;
488
489 for(int i=0; i< ALTRO_MAX_SAMPLES; i++)
490 {
491 if (data[i] != 0)
68d9caee 492 {
d2a0b488 493 cout <<data[i] <<"\t";
68d9caee 494 }
d2a0b488 495 }
496
497 cout << endl;
68d9caee 498}
499
d504c864 500//_________________________________________________________________________________________________
2947a32c 501void
502AliHLTPHOSRawAnalyzerComponent::Reset()
503{
432edd34 504 for(int mod = 0; mod < N_MODULES; mod ++)
9dfd64cf 505 {
432edd34 506 for(int row = 0; row < N_ROWS_MOD; row ++)
2947a32c 507 {
432edd34 508 for(int col = 0; col < N_COLUMNS_MOD; col ++)
2947a32c 509 {
432edd34 510 for(int gain = 0; gain < N_GAINS; gain ++ )
2947a32c 511 {
512 fMaxValues[mod][row][col][gain] = 0;
513 }
514 }
515 }
516 }
9dfd64cf 517
2b7cf4fb 518 ResetDataPtr(0, ALTRO_MAX_SAMPLES);
432edd34 519
520} // end Reset
521
e086ee30 522
523
d504c864 524//_________________________________________________________________________________________________
2947a32c 525void
432edd34 526AliHLTPHOSRawAnalyzerComponent::ResetDataPtr(int startindex, int sampleCnt)
2947a32c 527{
432edd34 528 for(int i = startindex ; i< sampleCnt; i++)
2947a32c 529 {
530 fTmpChannelData[i] = 0;
531 }
cbab66dd 532}
ef408bb3 533