1 /**************************************************************************
2 * Copyright(c) 2006, ALICE Experiment at CERN, All rights reserved. *
4 * Author: Per Thomas Hille for the ALICE HLT Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 #include "AliHLTPHOSRawAnalyzerComponent.h"
20 #include "AliRawReaderMemory.h"
21 #include "AliCaloRawStream.h"
23 #include "AliHLTPHOSRcuCellEnergyDataStruct.h"
26 const AliHLTComponentDataType AliHLTPHOSRawAnalyzerComponent::inputDataTypes[]={kAliHLTVoidDataType,{0,"",""}}; //'zero' terminated array
27 int AliHLTPHOSRawAnalyzerComponent::fEventCount = 0;
29 AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent():AliHLTProcessor(), fEquippmentID(0), fPHOSRawStream(), fRawMemoryReader(0)
34 AliHLTPHOSRawAnalyzerComponent::~AliHLTPHOSRawAnalyzerComponent()
36 if(fRawMemoryReader != 0)
38 delete fRawMemoryReader;
40 if(fPHOSRawStream != 0)
42 delete fPHOSRawStream;
49 AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent(const AliHLTPHOSRawAnalyzerComponent & ) : AliHLTProcessor(), fEquippmentID(0), fPHOSRawStream(),fRawMemoryReader(0)
55 AliHLTPHOSRawAnalyzerComponent::Deinit()
61 AliHLTPHOSRawAnalyzerComponent::DoDeinit()
63 Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSRawAnalyzerComponen DoDeinit");
65 if(fRawMemoryReader !=0)
67 delete fRawMemoryReader;
70 if(fPHOSRawStream != 0)
72 delete fPHOSRawStream;
79 AliHLTPHOSRawAnalyzerComponent::GetComponentID()
81 return "AliPhosTestRaw";
85 AliHLTPHOSRawAnalyzerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
87 const AliHLTComponentDataType* pType=inputDataTypes;
88 while (pType->fID!=0) {
89 list.push_back(*pType);
94 AliHLTComponentDataType
95 AliHLTPHOSRawAnalyzerComponent::GetOutputDataType()
97 return AliHLTPHOSDefinitions::gkCellEnergyDataType;
101 AliHLTPHOSRawAnalyzerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
105 inputMultiplier = 0.1;
109 int AliHLTPHOSRawAnalyzerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
110 AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
111 AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
118 Int_t processedChannels = 0;
122 Int_t tmpChannelCnt = 0;
125 cout << "analyzing event: " << fEventCount << endl;
127 // AliHLTPHOSRcuCellEnergyDataStruct
128 // AliHLTPHOSRcuCellEnergyDataStruct* outPtr;
129 AliHLTUInt8_t* outBPtr;
131 const AliHLTComponentBlockData* iter = NULL;
136 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
144 if ( iter->fDataType != AliHLTPHOSDefinitions::gkDDLPackedRawDataType )
146 cout << "Warning: data type = is nOT gkDDLPackedRawDataType " << endl;
150 fRawMemoryReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
151 analyzerPtr->SetData(fTmpChannelData);
152 outPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)outBPtr;
153 mysize += sizeof(AliHLTPHOSRcuCellEnergyDataStruct);
154 outPtr->fRcuX = fRcuX;
155 outPtr->fRcuZ = fRcuZ;
156 outPtr->fModuleID = fModuleID;
158 // cout << "analyzing evnt: " << fEventCount << "Module:" << fModuleID << "Rcu(" << fRcuZ <<"," << fRcuX << ")" << endl;
162 // outPtr->fValidData.fRcuX = fRcuX;
163 // outPtr->fValidData.fRcuZ = fRcuZ;
166 while(fPHOSRawStream->Next())
168 if (fPHOSRawStream->IsNewHWAddress())
170 if(processedChannels > 0)
172 analyzerPtr->SetData(fTmpChannelData);
173 // cout << "sampleCnt = " << sampleCnt << endl;
174 analyzerPtr->Evaluate(0, sampleCnt);
175 // fMaxValues[tmpMod][tmpRow][tmpCol][tmpGain] = analyzerPtr->GetEnergy();
177 // outPtr->fValidData[fCnt] = ;
180 // outPtr->fCellEnergies[tmpRow - fRcuRowOffeset][tmpCol - fRcuColOffeset][tmpGain] = fMaxValues[tmpMod][tmpRow][tmpCol][tmpGain];
181 // outPtr->fCellEnergies[tmpRow][tmpCol][tmpGain] = fMaxValues[tmpMod][tmpRow][tmpCol][tmpGain];
182 outPtr->fCellEnergies[tmpRow][tmpCol][tmpGain] = analyzerPtr->GetEnergy();
185 outPtr->fValidData[tmpChannelCnt].fGain = tmpGain;
186 outPtr->fValidData[tmpChannelCnt].fRow = tmpRow;
187 outPtr->fValidData[tmpChannelCnt].fCol = tmpCol;
198 tmpMod = fPHOSRawStream->GetModule() ;
199 tmpRow = fPHOSRawStream->GetRow() - fRcuRowOffeset;
200 tmpCol = fPHOSRawStream->GetColumn() - fRcuColOffeset;
201 tmpGain = fPHOSRawStream->IsLowGain();
203 // outPtr->fValidData.fRow = tmpRow;
204 // outPtr->fValidData).fCol = tmpCol;
207 processedChannels ++;
209 fTmpChannelData[fPHOSRawStream->GetTime()] = fPHOSRawStream->GetSignal();
214 outPtr->fCnt = tmpChannelCnt;
215 // cout << "outPtr->fCnt = " << outPtr->fCnt << endl;
217 AliHLTComponentBlockData bd;
221 bd.fDataType = AliHLTPHOSDefinitions::gkCellEnergyDataType;
222 bd.fSpecification = 0xFFFFFFFF;
223 outputBlocks.push_back( bd );
229 Logging( kHLTLogFatal, "HLT::AliHLTPHOSRawAnalyzerComponent::DoEvent", "Too much data",
230 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
245 AliHLTPHOSRawAnalyzerComponent::DoInit( int argc, const char** argv )
247 int equippmentID = atoi(argv[6]);
249 fRawMemoryReader = new AliRawReaderMemory();
250 fPHOSRawStream = new AliCaloRawStream(fRawMemoryReader,"PHOS");
251 fRawMemoryReader->SetEquipmentID(equippmentID);
252 SetEquippmentID(equippmentID);
253 SetCoordinates(equippmentID);
254 if (argc==0 && argv==NULL) {
255 // this is currently just to get rid of the warning "unused parameter"
261 AliHLTPHOSRawAnalyzerComponent::DumpData()
263 for(int mod = 0; mod <5; mod ++)
265 printf("\n *********** MODULE %d ************\n", mod);
266 for(int row = 0; row < 64; row ++)
268 for(int col = 0; col < 56; col ++)
270 if( fMaxValues[mod][row][col][0] != 0)
272 cout << fMaxValues[mod][row][col][0] << "\t";
281 AliHLTPHOSRawAnalyzerComponent::Reset()
283 for(int mod = 0; mod <5; mod ++)
285 for(int row = 0; row < 64; row ++)
287 for(int col = 0; col < 56; col ++)
289 for(int gain = 0; gain <2; gain ++ )
291 fMaxValues[mod][row][col][gain] = 0;
297 for(int i = 0 ; i< 1008; i++)
299 fTmpChannelData[i] = 0;
304 AliHLTPHOSRawAnalyzerComponent::ResetDataPtr()
306 for(int i = 0 ; i< 1008; i++)
308 fTmpChannelData[i] = 0;
314 AliHLTPHOSRawAnalyzerComponent::SetEquippmentID(AliHLTUInt32_t id)
320 AliHLTPHOSRawAnalyzerComponent::GetEquippmentID()
322 return fEquippmentID;
326 AliHLTPHOSRawAnalyzerComponent::SetCoordinates(AliHLTUInt32_t equippmentID)
328 int rcuIndex = (fEquippmentID - 1792)%4;
329 fModuleID = (fEquippmentID -1792 -rcuIndex)/5;
356 fRcuRowOffeset = 32*fRcuX;
357 fRcuColOffeset = 28*fRcuZ;