]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/PHOS/AliHLTPHOSRawAnalyzerComponent.cxx
New documenation:wq
[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
19#include "AliHLTPHOSRawAnalyzerComponent.h"
20#include <iostream>
9dfd64cf 21#include "stdio.h"
0a211711 22
9dfd64cf 23#include "AliRawReaderMemory.h"
0a211711 24#include "AliCaloRawStream.h"
2947a32c 25#include <cstdlib>
bde48b84 26#include "AliHLTPHOSRcuCellEnergyDataStruct.h"
a00e1689 27//#include "AliHLTPHOSDataHeaderStruct.h"
0a211711 28
cbab66dd 29
ee7849e6 30const AliHLTComponentDataType AliHLTPHOSRawAnalyzerComponent::inputDataTypes[]={kAliHLTVoidDataType,{0,"",""}}; //'zero' terminated array
2bcb5a06 31int AliHLTPHOSRawAnalyzerComponent::fEventCount = 0;
ee7849e6 32
4df5dd10 33
34AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent():AliHLTProcessor(),fEquippmentID(0), fRcuX(0),
35fRcuZ(0),fRcuRowOffeset(0), fRcuColOffeset(0), fModuleID(0), fPHOSRawStream(0), fRawMemoryReader(0), fOutPtr(0)
36//AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent():AliHLTProcessor()
cbab66dd 37{
cf434398 38
cbab66dd 39}
40
41AliHLTPHOSRawAnalyzerComponent::~AliHLTPHOSRawAnalyzerComponent()
42{
0a211711 43 if(fRawMemoryReader != 0)
44 {
45 delete fRawMemoryReader;
46 }
47 if(fPHOSRawStream != 0)
48 {
49 delete fPHOSRawStream;
50 }
51
cbab66dd 52}
53
54
0a211711 55
a00e1689 56AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent(const AliHLTPHOSRawAnalyzerComponent & ) : AliHLTProcessor(),
4df5dd10 57fEquippmentID(0), fRcuX(0), fRcuZ(0),fRcuRowOffeset(0), fRcuColOffeset(0), fModuleID(0), fPHOSRawStream(0), fRawMemoryReader(0), fOutPtr(0)
cbab66dd 58{
cbab66dd 59}
60
9dfd64cf 61
cbab66dd 62int
63AliHLTPHOSRawAnalyzerComponent::Deinit()
64{
65 return 0;
66}
67
68int
69AliHLTPHOSRawAnalyzerComponent::DoDeinit()
70{
9dfd64cf 71 Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSRawAnalyzerComponen DoDeinit");
72
0a211711 73 if(fRawMemoryReader !=0)
74 {
75 delete fRawMemoryReader;
76 }
77
78 if(fPHOSRawStream != 0)
79 {
80 delete fPHOSRawStream;
81 }
cbab66dd 82 return 0;
cbab66dd 83
cbab66dd 84}
85
9dfd64cf 86const char*
87AliHLTPHOSRawAnalyzerComponent::GetComponentID()
88{
89 return "AliPhosTestRaw";
90}
ee7849e6 91
cbab66dd 92void
ee7849e6 93AliHLTPHOSRawAnalyzerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
cbab66dd 94{
ee7849e6 95 const AliHLTComponentDataType* pType=inputDataTypes;
96 while (pType->fID!=0) {
97 list.push_back(*pType);
98 pType++;
99 }
cbab66dd 100}
101
102AliHLTComponentDataType
103AliHLTPHOSRawAnalyzerComponent::GetOutputDataType()
104{
53740333 105 return AliHLTPHOSDefinitions::gkCellEnergyDataType;
cbab66dd 106}
107
108void
9dfd64cf 109AliHLTPHOSRawAnalyzerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
110
cbab66dd 111{
ef408bb3 112 constBase = 30;
113 inputMultiplier = 0.1;
cbab66dd 114}
115
0a211711 116
117int AliHLTPHOSRawAnalyzerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
118 AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
119 AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
cbab66dd 120{
bde48b84 121 Int_t tmpMod = 0;
122 Int_t tmpRow = 0;
123 Int_t tmpCol = 0;
124 Int_t tmpGain = 0;
125 Int_t sampleCnt = 0;
2947a32c 126 Int_t processedChannels = 0;
bde48b84 127 UInt_t offset = 0;
128 UInt_t mysize = 0;
129 UInt_t tSize = 0;
2bcb5a06 130 Int_t tmpChannelCnt = 0;
432edd34 131 Int_t tmpStartIndex = 0;
53740333 132 AliHLTUInt8_t* outBPtr;
53740333 133 outBPtr = outputPtr;
0a211711 134 const AliHLTComponentBlockData* iter = NULL;
135 unsigned long ndx;
cf434398 136
68d9caee 137 if((fEventCount % 100) == 0)
138 {
d4ef0417 139 // cout << "analyzing event: " << fEventCount << endl;
68d9caee 140 }
2947a32c 141
0a211711 142 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
143 {
0a211711 144 iter = blocks+ndx;
53740333 145 mysize = 0;
146 offset = tSize;
147
0a211711 148 if ( iter->fDataType != AliHLTPHOSDefinitions::gkDDLPackedRawDataType )
149 {
d4ef0417 150 // cout << "Warning: data type = is nOT gkDDLPackedRawDataType " << endl;
0a211711 151 continue;
152 }
ef408bb3 153
bde48b84 154 fRawMemoryReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
155 analyzerPtr->SetData(fTmpChannelData);
a00e1689 156 fOutPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)outBPtr;
bde48b84 157 mysize += sizeof(AliHLTPHOSRcuCellEnergyDataStruct);
a00e1689 158 fOutPtr->fRcuX = fRcuX;
159 fOutPtr->fRcuZ = fRcuZ;
160 fOutPtr->fModuleID = fModuleID;
2bcb5a06 161 tmpChannelCnt = 0;
2bcb5a06 162
a00e1689 163 if(fEventCount%100 ==0)
164 {
d4ef0417 165 // cout <<"Analyzing event: " << fEventCount << endl;
a00e1689 166 }
167
2947a32c 168 while(fPHOSRawStream->Next())
169 {
170 if (fPHOSRawStream->IsNewHWAddress())
171 {
172 if(processedChannels > 0)
173 {
174 analyzerPtr->SetData(fTmpChannelData);
68d9caee 175 analyzerPtr->Evaluate(0, sampleCnt);
68d9caee 176 sampleCnt = 0;
a00e1689 177 fOutPtr->fValidData[tmpChannelCnt].fGain = tmpGain;
178 fOutPtr->fValidData[tmpChannelCnt].fRow = tmpRow;
179 fOutPtr->fValidData[tmpChannelCnt].fCol = tmpCol;
432edd34 180 fOutPtr->fValidData[tmpChannelCnt].fEnergy = analyzerPtr->GetEnergy();
181 fOutPtr->fValidData[tmpChannelCnt].fTime = analyzerPtr->GetTiming();
2bcb5a06 182 tmpChannelCnt ++;
432edd34 183 ResetDataPtr(tmpStartIndex, sampleCnt);
68d9caee 184 sampleCnt = 0;
2947a32c 185 }
186
2bcb5a06 187 tmpMod = fPHOSRawStream->GetModule() ;
188 tmpRow = fPHOSRawStream->GetRow() - fRcuRowOffeset;
189 tmpCol = fPHOSRawStream->GetColumn() - fRcuColOffeset;
2947a32c 190 tmpGain = fPHOSRawStream->IsLowGain();
191 processedChannels ++;
192 }
432edd34 193
194 if(sampleCnt == 0)
195 {
196 tmpStartIndex = fPHOSRawStream->GetTime();
197 }
198
2947a32c 199 fTmpChannelData[fPHOSRawStream->GetTime()] = fPHOSRawStream->GetSignal();
bde48b84 200 sampleCnt ++;
68d9caee 201
2947a32c 202 }
a00e1689 203
204 fOutPtr->fCnt = tmpChannelCnt;
53740333 205 AliHLTComponentBlockData bd;
206 FillBlockData( bd );
53740333 207 bd.fOffset = offset;
208 bd.fSize = mysize;
53740333 209 bd.fDataType = AliHLTPHOSDefinitions::gkCellEnergyDataType;
9ce19a20 210 bd.fSpecification = 0xFFFFFFFF;
53740333 211 outputBlocks.push_back( bd );
53740333 212 tSize += mysize;
213 outBPtr += mysize;
214
cf434398 215 if( tSize > size )
53740333 216 {
217 Logging( kHLTLogFatal, "HLT::AliHLTPHOSRawAnalyzerComponent::DoEvent", "Too much data",
218 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
219 , tSize, size );
220 return EMSGSIZE;
221 }
2947a32c 222 }
53740333 223
2947a32c 224 fEventCount++;
53740333 225 size = tSize;
2947a32c 226 return 0;
227}//end DoEvent
0a211711 228
229
230
231int
232AliHLTPHOSRawAnalyzerComponent::DoInit( int argc, const char** argv )
233{
53740333 234 int equippmentID = atoi(argv[6]);
2947a32c 235 Reset();
0a211711 236 fRawMemoryReader = new AliRawReaderMemory();
237 fPHOSRawStream = new AliCaloRawStream(fRawMemoryReader,"PHOS");
53740333 238 fRawMemoryReader->SetEquipmentID(equippmentID);
53740333 239 SetEquippmentID(equippmentID);
240 SetCoordinates(equippmentID);
0a211711 241 if (argc==0 && argv==NULL) {
242 // this is currently just to get rid of the warning "unused parameter"
243 }
244 return 0;
245}
9dfd64cf 246
2947a32c 247void
432edd34 248AliHLTPHOSRawAnalyzerComponent::DumpData(int gain)
0a211711 249{
432edd34 250 for(int mod = 0; mod < N_MODULES; mod ++)
2947a32c 251 {
252 printf("\n *********** MODULE %d ************\n", mod);
432edd34 253 for(int row = 0; row < N_ROWS_MOD; row ++)
2947a32c 254 {
432edd34 255 for(int col = 0; col < N_COLUMNS_MOD; col ++)
2947a32c 256 {
257 if( fMaxValues[mod][row][col][0] != 0)
258 {
432edd34 259 cout << fMaxValues[mod][row][col][gain] << "\t";
2947a32c 260 }
261 }
262 }
263 }
264}
9dfd64cf 265
432edd34 266
267void
268AliHLTPHOSRawAnalyzerComponent::DumpData()
269{
270 DumpData(0);
271}
272
68d9caee 273void
274AliHLTPHOSRawAnalyzerComponent::DumpChannelData(Double_t *data)
275{
276 cout << endl;
277
432edd34 278 for(int i=0; i< ALTRO_MAX_SAMPLES; i++)
68d9caee 279 {
280 if (data[i] != 0)
281 {
282 cout <<i <<"\t";
283 }
284 }
285 cout << endl;
286
432edd34 287 for(int i=0; i< ALTRO_MAX_SAMPLES; i++)
68d9caee 288 {
289 if (data[i] != 0)
290 {
291 cout <<data[i] <<"\t";
292 }
293 }
294
295 cout << endl;
296}
297
298
0a211711 299
2947a32c 300void
301AliHLTPHOSRawAnalyzerComponent::Reset()
302{
432edd34 303 for(int mod = 0; mod < N_MODULES; mod ++)
9dfd64cf 304 {
432edd34 305 for(int row = 0; row < N_ROWS_MOD; row ++)
2947a32c 306 {
432edd34 307 for(int col = 0; col < N_COLUMNS_MOD; col ++)
2947a32c 308 {
432edd34 309 for(int gain = 0; gain < N_GAINS; gain ++ )
2947a32c 310 {
311 fMaxValues[mod][row][col][gain] = 0;
312 }
313 }
314 }
315 }
9dfd64cf 316
432edd34 317 ResetDataPtr();
318
319} // end Reset
320
321
322
323void
324AliHLTPHOSRawAnalyzerComponent::ResetDataPtr()
325{
326 for(int i = 0 ; i< ALTRO_MAX_SAMPLES; i++)
327 {
328 fTmpChannelData[i] = 0;
329 }
330}
331
332void
333AliHLTPHOSRawAnalyzerComponent::ResetDataPtr(int sampleCnt)
334{
335 for(int i = 0 ; i< sampleCnt; i++)
2947a32c 336 {
337 fTmpChannelData[i] = 0;
0a211711 338 }
432edd34 339}
9dfd64cf 340
2947a32c 341void
432edd34 342AliHLTPHOSRawAnalyzerComponent::ResetDataPtr(int startindex, int sampleCnt)
2947a32c 343{
432edd34 344 for(int i = startindex ; i< sampleCnt; i++)
2947a32c 345 {
346 fTmpChannelData[i] = 0;
347 }
cbab66dd 348}
ef408bb3 349
350
351void
53740333 352AliHLTPHOSRawAnalyzerComponent::SetEquippmentID(AliHLTUInt32_t id)
ef408bb3 353{
53740333 354 fEquippmentID = id;
ef408bb3 355}
356
357int
53740333 358AliHLTPHOSRawAnalyzerComponent::GetEquippmentID()
359{
360 return fEquippmentID;
361}
362
53740333 363void
364AliHLTPHOSRawAnalyzerComponent::SetCoordinates(AliHLTUInt32_t equippmentID)
ef408bb3 365{
53740333 366 int rcuIndex = (fEquippmentID - 1792)%4;
cf434398 367 fModuleID = (fEquippmentID -1792 -rcuIndex)/5;
53740333 368
369 if(rcuIndex == 0)
370 {
371 fRcuX = 0;
cf434398 372 fRcuZ = 0;
53740333 373 }
374
375 if(rcuIndex == 1)
376 {
cf434398 377 fRcuX = 0;
378 fRcuZ = 1;
53740333 379 }
380
381 if(rcuIndex == 2)
382 {
cf434398 383 fRcuX = 1;
384 fRcuZ = 0;
53740333 385 }
386
387
cf434398 388 if(rcuIndex == 3)
53740333 389 {
390 fRcuX = 1;
cf434398 391 fRcuZ = 1;
53740333 392 }
393
cf434398 394 fRcuRowOffeset = 32*fRcuX;
395 fRcuColOffeset = 28*fRcuZ;
396
ef408bb3 397}