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 "AliHLTPHOSRcuCellEnergyData.h"
26 const AliHLTComponentDataType AliHLTPHOSRawAnalyzerComponent::inputDataTypes[]={kAliHLTVoidDataType,{0,"",""}}; //'zero' terminated array
29 AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent():AliHLTProcessor(), fEventCount(0), 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(), fEventCount(0), 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 )
117 Int_t processedChannels = 0;
121 AliHLTPHOSRcuCellEnergyData* outPtr;
122 AliHLTUInt8_t* outBPtr;
124 const AliHLTComponentBlockData* iter = NULL;
129 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
136 if ( iter->fDataType != AliHLTPHOSDefinitions::gkDDLPackedRawDataType )
138 cout << "Warning: data type = is nOT gkDDLPackedRawDataType " << endl;
142 fRawMemoryReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
143 analyzerPtr->SetData(fTmpChannelData);
145 outPtr = (AliHLTPHOSRcuCellEnergyData*)outBPtr;
146 mysize += sizeof(AliHLTPHOSRcuCellEnergyData);
148 outPtr->fRcuX = fRcuX;
149 outPtr->fRcuZ = fRcuZ;
150 outPtr->fModuleID = fModuleID;
152 while(fPHOSRawStream->Next())
154 if (fPHOSRawStream->IsNewHWAddress())
156 if(processedChannels > 0)
158 analyzerPtr->SetData(fTmpChannelData);
159 analyzerPtr->Evaluate(0, 1008);
160 fMaxValues[tmpMod][tmpRow][tmpCol][tmpGain] = analyzerPtr->GetEnergy();
161 outPtr->fCellEnergies[tmpRow - fRcuRowOffeset][tmpCol - fRcuColOffeset][tmpGain] = fMaxValues[tmpMod][tmpRow][tmpCol][tmpGain];
165 tmpMod = fPHOSRawStream->GetModule();
166 tmpRow = fPHOSRawStream->GetRow();
167 tmpCol = fPHOSRawStream->GetColumn();
168 tmpGain = fPHOSRawStream->IsLowGain();
169 processedChannels ++;
173 fTmpChannelData[fPHOSRawStream->GetTime()] = fPHOSRawStream->GetSignal();
177 AliHLTComponentBlockData bd;
181 bd.fDataType = AliHLTPHOSDefinitions::gkCellEnergyDataType;
182 bd.fSpecification = 0xFFFFFFFF;
183 outputBlocks.push_back( bd );
189 Logging( kHLTLogFatal, "HLT::AliHLTPHOSRawAnalyzerComponent::DoEvent", "Too much data",
190 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
205 AliHLTPHOSRawAnalyzerComponent::DoInit( int argc, const char** argv )
207 int equippmentID = atoi(argv[6]);
209 fRawMemoryReader = new AliRawReaderMemory();
210 fPHOSRawStream = new AliCaloRawStream(fRawMemoryReader,"PHOS");
211 fRawMemoryReader->SetEquipmentID(equippmentID);
212 SetEquippmentID(equippmentID);
213 SetCoordinates(equippmentID);
214 if (argc==0 && argv==NULL) {
215 // this is currently just to get rid of the warning "unused parameter"
221 AliHLTPHOSRawAnalyzerComponent::DumpData()
223 for(int mod = 0; mod <5; mod ++)
225 printf("\n *********** MODULE %d ************\n", mod);
226 for(int row = 0; row < 64; row ++)
228 for(int col = 0; col < 56; col ++)
230 if( fMaxValues[mod][row][col][0] != 0)
232 cout << fMaxValues[mod][row][col][0] << "\t";
241 AliHLTPHOSRawAnalyzerComponent::Reset()
243 for(int mod = 0; mod <5; mod ++)
245 for(int row = 0; row < 64; row ++)
247 for(int col = 0; col < 56; col ++)
249 for(int gain = 0; gain <2; gain ++ )
251 fMaxValues[mod][row][col][gain] = 0;
257 for(int i = 0 ; i< 1008; i++)
259 fTmpChannelData[i] = 0;
264 AliHLTPHOSRawAnalyzerComponent::ResetDataPtr()
266 for(int i = 0 ; i< 1008; i++)
268 fTmpChannelData[i] = 0;
274 AliHLTPHOSRawAnalyzerComponent::SetEquippmentID(AliHLTUInt32_t id)
280 AliHLTPHOSRawAnalyzerComponent::GetEquippmentID()
282 return fEquippmentID;
286 AliHLTPHOSRawAnalyzerComponent::SetCoordinates(AliHLTUInt32_t equippmentID)
288 int rcuIndex = (fEquippmentID - 1792)%4;
289 fModuleID = (fEquippmentID -1792 -rcuIndex)/5;
316 fRcuRowOffeset = 32*fRcuX;
317 fRcuColOffeset = 28*fRcuZ;