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), fRcuX(0), fRcuZ(0),fRcuRowOffeset(0), fRcuColOffeset(0), fModuleID(0), fPHOSRawStream(), fRawMemoryReader(0), outPtr(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), fRcuX(0), fRcuZ(0),fRcuRowOffeset(0), fRcuColOffeset(0), fModuleID(0), fPHOSRawStream(), fRawMemoryReader(0), outPtr(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;
126 AliHLTUInt8_t* outBPtr;
128 const AliHLTComponentBlockData* iter = NULL;
131 if((fEventCount % 100) == 0)
133 cout << "analyzing event: " << fEventCount << endl;
137 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
143 if ( iter->fDataType != AliHLTPHOSDefinitions::gkDDLPackedRawDataType )
145 cout << "Warning: data type = is nOT gkDDLPackedRawDataType " << endl;
149 fRawMemoryReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
150 analyzerPtr->SetData(fTmpChannelData);
151 outPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)outBPtr;
152 mysize += sizeof(AliHLTPHOSRcuCellEnergyDataStruct);
153 outPtr->fRcuX = fRcuX;
154 outPtr->fRcuZ = fRcuZ;
155 outPtr->fModuleID = fModuleID;
158 while(fPHOSRawStream->Next())
160 if (fPHOSRawStream->IsNewHWAddress())
162 // cout << "samplCount =" << sampleCnt <<endl;
166 if(processedChannels > 0)
168 analyzerPtr->SetData(fTmpChannelData);
170 // DumpChannelData(fTmpChannelData);
172 analyzerPtr->Evaluate(0, sampleCnt);
173 outPtr->fCellEnergies[tmpRow][tmpCol][tmpGain] = analyzerPtr->GetEnergy();
177 outPtr->fValidData[tmpChannelCnt].fGain = tmpGain;
178 outPtr->fValidData[tmpChannelCnt].fRow = tmpRow;
179 outPtr->fValidData[tmpChannelCnt].fCol = tmpCol;
186 tmpMod = fPHOSRawStream->GetModule() ;
187 tmpRow = fPHOSRawStream->GetRow() - fRcuRowOffeset;
188 tmpCol = fPHOSRawStream->GetColumn() - fRcuColOffeset;
189 tmpGain = fPHOSRawStream->IsLowGain();
190 processedChannels ++;
192 fTmpChannelData[fPHOSRawStream->GetTime()] = fPHOSRawStream->GetSignal();
199 outPtr->fCnt = tmpChannelCnt;
200 AliHLTComponentBlockData bd;
204 bd.fDataType = AliHLTPHOSDefinitions::gkCellEnergyDataType;
205 bd.fSpecification = 0xFFFFFFFF;
206 outputBlocks.push_back( bd );
212 Logging( kHLTLogFatal, "HLT::AliHLTPHOSRawAnalyzerComponent::DoEvent", "Too much data",
213 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
231 AliHLTPHOSRawAnalyzerComponent::DoInit( int argc, const char** argv )
233 int equippmentID = atoi(argv[6]);
235 fRawMemoryReader = new AliRawReaderMemory();
236 fPHOSRawStream = new AliCaloRawStream(fRawMemoryReader,"PHOS");
237 fRawMemoryReader->SetEquipmentID(equippmentID);
238 SetEquippmentID(equippmentID);
239 SetCoordinates(equippmentID);
240 if (argc==0 && argv==NULL) {
241 // this is currently just to get rid of the warning "unused parameter"
247 AliHLTPHOSRawAnalyzerComponent::DumpData()
249 for(int mod = 0; mod <5; mod ++)
251 printf("\n *********** MODULE %d ************\n", mod);
252 for(int row = 0; row < 64; row ++)
254 for(int col = 0; col < 56; col ++)
256 if( fMaxValues[mod][row][col][0] != 0)
258 cout << fMaxValues[mod][row][col][0] << "\t";
266 AliHLTPHOSRawAnalyzerComponent::DumpChannelData(Double_t *data)
270 for(int i=0; i< 1008; i++)
279 for(int i=0; i< 1008; i++)
283 cout <<data[i] <<"\t";
293 AliHLTPHOSRawAnalyzerComponent::Reset()
295 for(int mod = 0; mod <5; mod ++)
297 for(int row = 0; row < 64; row ++)
299 for(int col = 0; col < 56; col ++)
301 for(int gain = 0; gain <2; gain ++ )
303 fMaxValues[mod][row][col][gain] = 0;
309 for(int i = 0 ; i< 1008; i++)
311 fTmpChannelData[i] = 0;
316 AliHLTPHOSRawAnalyzerComponent::ResetDataPtr()
318 for(int i = 0 ; i< 1008; i++)
320 fTmpChannelData[i] = 0;
326 AliHLTPHOSRawAnalyzerComponent::SetEquippmentID(AliHLTUInt32_t id)
332 AliHLTPHOSRawAnalyzerComponent::GetEquippmentID()
334 return fEquippmentID;
338 AliHLTPHOSRawAnalyzerComponent::SetCoordinates(AliHLTUInt32_t equippmentID)
340 int rcuIndex = (fEquippmentID - 1792)%4;
341 fModuleID = (fEquippmentID -1792 -rcuIndex)/5;
368 fRcuRowOffeset = 32*fRcuX;
369 fRcuColOffeset = 28*fRcuZ;