]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/PHOS/AliHLTPHOSRawAnalyzerComponent.cxx
Chnages was necessary in this class beacause the format
[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;
53740333 131 AliHLTUInt8_t* outBPtr;
53740333 132 outBPtr = outputPtr;
0a211711 133 const AliHLTComponentBlockData* iter = NULL;
134 unsigned long ndx;
cf434398 135
68d9caee 136 if((fEventCount % 100) == 0)
137 {
138 cout << "analyzing event: " << fEventCount << endl;
139 }
2947a32c 140
0a211711 141 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
142 {
0a211711 143 iter = blocks+ndx;
53740333 144 mysize = 0;
145 offset = tSize;
146
0a211711 147 if ( iter->fDataType != AliHLTPHOSDefinitions::gkDDLPackedRawDataType )
148 {
149 cout << "Warning: data type = is nOT gkDDLPackedRawDataType " << endl;
150 continue;
151 }
ef408bb3 152
bde48b84 153 fRawMemoryReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
154 analyzerPtr->SetData(fTmpChannelData);
a00e1689 155 fOutPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)outBPtr;
bde48b84 156 mysize += sizeof(AliHLTPHOSRcuCellEnergyDataStruct);
a00e1689 157 fOutPtr->fRcuX = fRcuX;
158 fOutPtr->fRcuZ = fRcuZ;
159 fOutPtr->fModuleID = fModuleID;
2bcb5a06 160 tmpChannelCnt = 0;
2bcb5a06 161
a00e1689 162 if(fEventCount%100 ==0)
163 {
164 cout <<"Analyzing event: " << fEventCount << endl;
165 }
166
2947a32c 167 while(fPHOSRawStream->Next())
168 {
169 if (fPHOSRawStream->IsNewHWAddress())
170 {
171 if(processedChannels > 0)
172 {
173 analyzerPtr->SetData(fTmpChannelData);
68d9caee 174 analyzerPtr->Evaluate(0, sampleCnt);
a00e1689 175 fOutPtr->fCellEnergies[tmpRow][tmpCol][tmpGain] = analyzerPtr->GetEnergy();
68d9caee 176 sampleCnt = 0;
a00e1689 177 fOutPtr->fValidData[tmpChannelCnt].fGain = tmpGain;
178 fOutPtr->fValidData[tmpChannelCnt].fRow = tmpRow;
179 fOutPtr->fValidData[tmpChannelCnt].fCol = tmpCol;
2bcb5a06 180 tmpChannelCnt ++;
68d9caee 181 ResetDataPtr();
182 sampleCnt = 0;
bde48b84 183
2947a32c 184 }
185
2bcb5a06 186 tmpMod = fPHOSRawStream->GetModule() ;
187 tmpRow = fPHOSRawStream->GetRow() - fRcuRowOffeset;
188 tmpCol = fPHOSRawStream->GetColumn() - fRcuColOffeset;
2947a32c 189 tmpGain = fPHOSRawStream->IsLowGain();
190 processedChannels ++;
191 }
2947a32c 192 fTmpChannelData[fPHOSRawStream->GetTime()] = fPHOSRawStream->GetSignal();
bde48b84 193 sampleCnt ++;
68d9caee 194
2947a32c 195 }
a00e1689 196
197 fOutPtr->fCnt = tmpChannelCnt;
53740333 198 AliHLTComponentBlockData bd;
199 FillBlockData( bd );
53740333 200 bd.fOffset = offset;
201 bd.fSize = mysize;
53740333 202 bd.fDataType = AliHLTPHOSDefinitions::gkCellEnergyDataType;
9ce19a20 203 bd.fSpecification = 0xFFFFFFFF;
53740333 204 outputBlocks.push_back( bd );
53740333 205 tSize += mysize;
206 outBPtr += mysize;
207
cf434398 208 if( tSize > size )
53740333 209 {
210 Logging( kHLTLogFatal, "HLT::AliHLTPHOSRawAnalyzerComponent::DoEvent", "Too much data",
211 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
212 , tSize, size );
213 return EMSGSIZE;
214 }
2947a32c 215 }
53740333 216
2947a32c 217 fEventCount++;
53740333 218 size = tSize;
2947a32c 219 return 0;
220}//end DoEvent
0a211711 221
222
223
224int
225AliHLTPHOSRawAnalyzerComponent::DoInit( int argc, const char** argv )
226{
53740333 227 int equippmentID = atoi(argv[6]);
2947a32c 228 Reset();
0a211711 229 fRawMemoryReader = new AliRawReaderMemory();
230 fPHOSRawStream = new AliCaloRawStream(fRawMemoryReader,"PHOS");
53740333 231 fRawMemoryReader->SetEquipmentID(equippmentID);
53740333 232 SetEquippmentID(equippmentID);
233 SetCoordinates(equippmentID);
0a211711 234 if (argc==0 && argv==NULL) {
235 // this is currently just to get rid of the warning "unused parameter"
236 }
237 return 0;
238}
9dfd64cf 239
2947a32c 240void
241AliHLTPHOSRawAnalyzerComponent::DumpData()
0a211711 242{
2947a32c 243 for(int mod = 0; mod <5; mod ++)
244 {
245 printf("\n *********** MODULE %d ************\n", mod);
246 for(int row = 0; row < 64; row ++)
247 {
248 for(int col = 0; col < 56; col ++)
249 {
250 if( fMaxValues[mod][row][col][0] != 0)
251 {
252 cout << fMaxValues[mod][row][col][0] << "\t";
253 }
254 }
255 }
256 }
257}
9dfd64cf 258
68d9caee 259void
260AliHLTPHOSRawAnalyzerComponent::DumpChannelData(Double_t *data)
261{
262 cout << endl;
263
264 for(int i=0; i< 1008; i++)
265 {
266 if (data[i] != 0)
267 {
268 cout <<i <<"\t";
269 }
270 }
271 cout << endl;
272
273 for(int i=0; i< 1008; i++)
274 {
275 if (data[i] != 0)
276 {
277 cout <<data[i] <<"\t";
278 }
279 }
280
281 cout << endl;
282}
283
284
0a211711 285
2947a32c 286void
287AliHLTPHOSRawAnalyzerComponent::Reset()
288{
289 for(int mod = 0; mod <5; mod ++)
9dfd64cf 290 {
2947a32c 291 for(int row = 0; row < 64; row ++)
292 {
293 for(int col = 0; col < 56; col ++)
294 {
295 for(int gain = 0; gain <2; gain ++ )
296 {
297 fMaxValues[mod][row][col][gain] = 0;
298 }
299 }
300 }
301 }
9dfd64cf 302
2947a32c 303 for(int i = 0 ; i< 1008; i++)
304 {
305 fTmpChannelData[i] = 0;
0a211711 306 }
2947a32c 307} // end Reset
9dfd64cf 308
2947a32c 309void
310AliHLTPHOSRawAnalyzerComponent::ResetDataPtr()
311{
312 for(int i = 0 ; i< 1008; i++)
313 {
314 fTmpChannelData[i] = 0;
315 }
cbab66dd 316}
ef408bb3 317
318
319void
53740333 320AliHLTPHOSRawAnalyzerComponent::SetEquippmentID(AliHLTUInt32_t id)
ef408bb3 321{
53740333 322 fEquippmentID = id;
ef408bb3 323}
324
325int
53740333 326AliHLTPHOSRawAnalyzerComponent::GetEquippmentID()
327{
328 return fEquippmentID;
329}
330
53740333 331void
332AliHLTPHOSRawAnalyzerComponent::SetCoordinates(AliHLTUInt32_t equippmentID)
ef408bb3 333{
53740333 334 int rcuIndex = (fEquippmentID - 1792)%4;
cf434398 335 fModuleID = (fEquippmentID -1792 -rcuIndex)/5;
53740333 336
337 if(rcuIndex == 0)
338 {
339 fRcuX = 0;
cf434398 340 fRcuZ = 0;
53740333 341 }
342
343 if(rcuIndex == 1)
344 {
cf434398 345 fRcuX = 0;
346 fRcuZ = 1;
53740333 347 }
348
349 if(rcuIndex == 2)
350 {
cf434398 351 fRcuX = 1;
352 fRcuZ = 0;
53740333 353 }
354
355
cf434398 356 if(rcuIndex == 3)
53740333 357 {
358 fRcuX = 1;
cf434398 359 fRcuZ = 1;
53740333 360 }
361
cf434398 362 fRcuRowOffeset = 32*fRcuX;
363 fRcuColOffeset = 28*fRcuZ;
364
ef408bb3 365}