1 /**************************************************************************
2 * This file is property of and copyright by the Experimental Nuclear *
3 * Physics Group, Dep. of Physics *
4 * University of Oslo, Norway, 2007 *
6 * Author: Per Thomas Hille <perthi@fys.uio.no> for the ALICE HLT Project.*
7 * Contributors are mentioned in the code where appropriate. *
8 * Please report bugs to perthi@fys.uio.no *
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 **************************************************************************/
19 #include "AliHLTPHOSRawAnalyzerComponent.h"
23 #include "AliRawReaderMemory.h"
24 #include "AliCaloRawStream.h"
26 #include "AliHLTPHOSRcuCellEnergyDataStruct.h"
27 //#include "AliHLTPHOSDataHeaderStruct.h"
30 const AliHLTComponentDataType AliHLTPHOSRawAnalyzerComponent::inputDataTypes[]={kAliHLTVoidDataType,{0,"",""}}; //'zero' terminated array
31 int AliHLTPHOSRawAnalyzerComponent::fEventCount = 0;
34 AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent():AliHLTProcessor(),fEquippmentID(0), fRcuX(0),
35 fRcuZ(0),fRcuRowOffeset(0), fRcuColOffeset(0), fModuleID(0), fPHOSRawStream(0), fRawMemoryReader(0), fOutPtr(0)
36 //AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent():AliHLTProcessor()
41 AliHLTPHOSRawAnalyzerComponent::~AliHLTPHOSRawAnalyzerComponent()
43 if(fRawMemoryReader != 0)
45 delete fRawMemoryReader;
47 if(fPHOSRawStream != 0)
49 delete fPHOSRawStream;
56 AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent(const AliHLTPHOSRawAnalyzerComponent & ) : AliHLTProcessor(),
57 fEquippmentID(0), fRcuX(0), fRcuZ(0),fRcuRowOffeset(0), fRcuColOffeset(0), fModuleID(0), fPHOSRawStream(0), fRawMemoryReader(0), fOutPtr(0)
63 AliHLTPHOSRawAnalyzerComponent::Deinit()
69 AliHLTPHOSRawAnalyzerComponent::DoDeinit()
71 Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSRawAnalyzerComponen DoDeinit");
73 if(fRawMemoryReader !=0)
75 delete fRawMemoryReader;
78 if(fPHOSRawStream != 0)
80 delete fPHOSRawStream;
87 AliHLTPHOSRawAnalyzerComponent::GetComponentID()
89 return "AliPhosTestRaw";
93 AliHLTPHOSRawAnalyzerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
95 const AliHLTComponentDataType* pType=inputDataTypes;
96 while (pType->fID!=0) {
97 list.push_back(*pType);
102 AliHLTComponentDataType
103 AliHLTPHOSRawAnalyzerComponent::GetOutputDataType()
105 return AliHLTPHOSDefinitions::gkCellEnergyDataType;
109 AliHLTPHOSRawAnalyzerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
113 inputMultiplier = 0.1;
117 int AliHLTPHOSRawAnalyzerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
118 AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
119 AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
126 Int_t processedChannels = 0;
130 Int_t tmpChannelCnt = 0;
131 AliHLTUInt8_t* outBPtr;
133 const AliHLTComponentBlockData* iter = NULL;
136 if((fEventCount % 100) == 0)
138 cout << "analyzing event: " << fEventCount << endl;
141 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
147 if ( iter->fDataType != AliHLTPHOSDefinitions::gkDDLPackedRawDataType )
149 cout << "Warning: data type = is nOT gkDDLPackedRawDataType " << endl;
153 fRawMemoryReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
154 analyzerPtr->SetData(fTmpChannelData);
155 fOutPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)outBPtr;
156 mysize += sizeof(AliHLTPHOSRcuCellEnergyDataStruct);
157 fOutPtr->fRcuX = fRcuX;
158 fOutPtr->fRcuZ = fRcuZ;
159 fOutPtr->fModuleID = fModuleID;
162 if(fEventCount%100 ==0)
164 cout <<"Analyzing event: " << fEventCount << endl;
167 while(fPHOSRawStream->Next())
169 if (fPHOSRawStream->IsNewHWAddress())
171 if(processedChannels > 0)
173 analyzerPtr->SetData(fTmpChannelData);
174 analyzerPtr->Evaluate(0, sampleCnt);
175 fOutPtr->fCellEnergies[tmpRow][tmpCol][tmpGain] = analyzerPtr->GetEnergy();
177 fOutPtr->fValidData[tmpChannelCnt].fGain = tmpGain;
178 fOutPtr->fValidData[tmpChannelCnt].fRow = tmpRow;
179 fOutPtr->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();
197 fOutPtr->fCnt = tmpChannelCnt;
198 AliHLTComponentBlockData bd;
202 bd.fDataType = AliHLTPHOSDefinitions::gkCellEnergyDataType;
203 bd.fSpecification = 0xFFFFFFFF;
204 outputBlocks.push_back( bd );
210 Logging( kHLTLogFatal, "HLT::AliHLTPHOSRawAnalyzerComponent::DoEvent", "Too much data",
211 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
225 AliHLTPHOSRawAnalyzerComponent::DoInit( int argc, const char** argv )
227 int equippmentID = atoi(argv[6]);
229 fRawMemoryReader = new AliRawReaderMemory();
230 fPHOSRawStream = new AliCaloRawStream(fRawMemoryReader,"PHOS");
231 fRawMemoryReader->SetEquipmentID(equippmentID);
232 SetEquippmentID(equippmentID);
233 SetCoordinates(equippmentID);
234 if (argc==0 && argv==NULL) {
235 // this is currently just to get rid of the warning "unused parameter"
241 AliHLTPHOSRawAnalyzerComponent::DumpData()
243 for(int mod = 0; mod <5; mod ++)
245 printf("\n *********** MODULE %d ************\n", mod);
246 for(int row = 0; row < 64; row ++)
248 for(int col = 0; col < 56; col ++)
250 if( fMaxValues[mod][row][col][0] != 0)
252 cout << fMaxValues[mod][row][col][0] << "\t";
260 AliHLTPHOSRawAnalyzerComponent::DumpChannelData(Double_t *data)
264 for(int i=0; i< 1008; i++)
273 for(int i=0; i< 1008; i++)
277 cout <<data[i] <<"\t";
287 AliHLTPHOSRawAnalyzerComponent::Reset()
289 for(int mod = 0; mod <5; mod ++)
291 for(int row = 0; row < 64; row ++)
293 for(int col = 0; col < 56; col ++)
295 for(int gain = 0; gain <2; gain ++ )
297 fMaxValues[mod][row][col][gain] = 0;
303 for(int i = 0 ; i< 1008; i++)
305 fTmpChannelData[i] = 0;
310 AliHLTPHOSRawAnalyzerComponent::ResetDataPtr()
312 for(int i = 0 ; i< 1008; i++)
314 fTmpChannelData[i] = 0;
320 AliHLTPHOSRawAnalyzerComponent::SetEquippmentID(AliHLTUInt32_t id)
326 AliHLTPHOSRawAnalyzerComponent::GetEquippmentID()
328 return fEquippmentID;
332 AliHLTPHOSRawAnalyzerComponent::SetCoordinates(AliHLTUInt32_t equippmentID)
334 int rcuIndex = (fEquippmentID - 1792)%4;
335 fModuleID = (fEquippmentID -1792 -rcuIndex)/5;
362 fRcuRowOffeset = 32*fRcuX;
363 fRcuColOffeset = 28*fRcuZ;