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
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 )
118 Int_t processedChannels = 0;
123 // AliHLTPHOSRcuCellEnergyDataStruct
124 AliHLTPHOSRcuCellEnergyDataStruct* outPtr;
125 AliHLTUInt8_t* outBPtr;
127 const AliHLTComponentBlockData* iter = NULL;
132 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
139 if ( iter->fDataType != AliHLTPHOSDefinitions::gkDDLPackedRawDataType )
141 cout << "Warning: data type = is nOT gkDDLPackedRawDataType " << endl;
145 fRawMemoryReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
146 analyzerPtr->SetData(fTmpChannelData);
147 outPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)outBPtr;
148 mysize += sizeof(AliHLTPHOSRcuCellEnergyDataStruct);
149 outPtr->fRcuX = fRcuX;
150 outPtr->fRcuZ = fRcuZ;
151 outPtr->fModuleID = fModuleID;
154 while(fPHOSRawStream->Next())
156 if (fPHOSRawStream->IsNewHWAddress())
158 if(processedChannels > 0)
160 analyzerPtr->SetData(fTmpChannelData);
161 // cout << "sampleCnt = " << sampleCnt << endl;
162 analyzerPtr->Evaluate(0, sampleCnt);
163 fMaxValues[tmpMod][tmpRow][tmpCol][tmpGain] = analyzerPtr->GetEnergy();
165 // outPtr->fValidData[fCnt] = ;
168 outPtr->fCellEnergies[tmpRow - fRcuRowOffeset][tmpCol - fRcuColOffeset][tmpGain] = fMaxValues[tmpMod][tmpRow][tmpCol][tmpGain];
174 tmpMod = fPHOSRawStream->GetModule();
175 tmpRow = fPHOSRawStream->GetRow();
176 tmpCol = fPHOSRawStream->GetColumn();
177 tmpGain = fPHOSRawStream->IsLowGain();
179 processedChannels ++;
181 fTmpChannelData[fPHOSRawStream->GetTime()] = fPHOSRawStream->GetSignal();
186 AliHLTComponentBlockData bd;
190 bd.fDataType = AliHLTPHOSDefinitions::gkCellEnergyDataType;
191 bd.fSpecification = 0xFFFFFFFF;
192 outputBlocks.push_back( bd );
198 Logging( kHLTLogFatal, "HLT::AliHLTPHOSRawAnalyzerComponent::DoEvent", "Too much data",
199 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
214 AliHLTPHOSRawAnalyzerComponent::DoInit( int argc, const char** argv )
216 int equippmentID = atoi(argv[6]);
218 fRawMemoryReader = new AliRawReaderMemory();
219 fPHOSRawStream = new AliCaloRawStream(fRawMemoryReader,"PHOS");
220 fRawMemoryReader->SetEquipmentID(equippmentID);
221 SetEquippmentID(equippmentID);
222 SetCoordinates(equippmentID);
223 if (argc==0 && argv==NULL) {
224 // this is currently just to get rid of the warning "unused parameter"
230 AliHLTPHOSRawAnalyzerComponent::DumpData()
232 for(int mod = 0; mod <5; mod ++)
234 printf("\n *********** MODULE %d ************\n", mod);
235 for(int row = 0; row < 64; row ++)
237 for(int col = 0; col < 56; col ++)
239 if( fMaxValues[mod][row][col][0] != 0)
241 cout << fMaxValues[mod][row][col][0] << "\t";
250 AliHLTPHOSRawAnalyzerComponent::Reset()
252 for(int mod = 0; mod <5; mod ++)
254 for(int row = 0; row < 64; row ++)
256 for(int col = 0; col < 56; col ++)
258 for(int gain = 0; gain <2; gain ++ )
260 fMaxValues[mod][row][col][gain] = 0;
266 for(int i = 0 ; i< 1008; i++)
268 fTmpChannelData[i] = 0;
273 AliHLTPHOSRawAnalyzerComponent::ResetDataPtr()
275 for(int i = 0 ; i< 1008; i++)
277 fTmpChannelData[i] = 0;
283 AliHLTPHOSRawAnalyzerComponent::SetEquippmentID(AliHLTUInt32_t id)
289 AliHLTPHOSRawAnalyzerComponent::GetEquippmentID()
291 return fEquippmentID;
295 AliHLTPHOSRawAnalyzerComponent::SetCoordinates(AliHLTUInt32_t equippmentID)
297 int rcuIndex = (fEquippmentID - 1792)%4;
298 fModuleID = (fEquippmentID -1792 -rcuIndex)/5;
325 fRcuRowOffeset = 32*fRcuX;
326 fRcuColOffeset = 28*fRcuZ;