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"
22 #include "AliRawReaderMemory.h"
23 #include "AliCaloRawStream.h"
25 #include "AliHLTPHOSRcuCellEnergyDataStruct.h"
27 const AliHLTComponentDataType AliHLTPHOSRawAnalyzerComponent::inputDataTypes[]={kAliHLTVoidDataType,{0,"",""}}; //'zero' terminated array
28 int AliHLTPHOSRawAnalyzerComponent::fEventCount = 0;
32 * @class AliHLTPHOSRawAnalyzerComponent
33 * Base class of PHOS HLT online raw analysis component.
34 * The class provides a common interface for the implementation of PHOS
36 * processors components. The class is intended for processing of
37 * arrays of raw data samples to evaluate energy and timing.
38 * The Energy will be given in entities of ADC leves ranging from 0 to
39 * 1023. Timing will be given in entities of samples periods.
40 * Drived clases must implement the fucntions
41 * - @ref GetComponentID
44 AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent():AliHLTProcessor(), analyzerPtr(0), fEquippmentID(0), fRcuX(0),
45 fRcuZ(0),fRcuZOffset(0), fRcuXOffset(0), fModuleID(0), fPHOSRawStream(0), fRawMemoryReader(0), fOutPtr(0)
50 AliHLTPHOSRawAnalyzerComponent::~AliHLTPHOSRawAnalyzerComponent()
52 if(fRawMemoryReader != 0)
54 delete fRawMemoryReader;
56 if(fPHOSRawStream != 0)
58 delete fPHOSRawStream;
65 AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent(const AliHLTPHOSRawAnalyzerComponent & ) : AliHLTProcessor(), analyzerPtr(0),
66 fEquippmentID(0), fRcuX(0), fRcuZ(0),fRcuZOffset(0), fRcuXOffset(0), fModuleID(0), fPHOSRawStream(0), fRawMemoryReader(0), fOutPtr(0)
72 *Deinit function called by the HLT framwork at end of run
73 *@return 0 if the denitialzation was sucessfull.
76 AliHLTPHOSRawAnalyzerComponent::Deinit()
78 cout << "Deinit" << endl;
84 *Deinit function called by the HLT framwork at end of run
85 *@return 0 if the denitialzation was sucessfull.
88 AliHLTPHOSRawAnalyzerComponent::DoDeinit()
90 cout << "DoDeinit" << endl;
91 Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSRawAnalyzerComponen DoDeinit");
93 if(fRawMemoryReader !=0)
95 delete fRawMemoryReader;
98 if(fPHOSRawStream != 0)
100 delete fPHOSRawStream;
107 *Function called by the HLT framework during initialization
108 *@return the ID of the component
111 AliHLTPHOSRawAnalyzerComponent::GetComponentID()
113 return "AliPhosTestRaw";
118 AliHLTPHOSRawAnalyzerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
120 const AliHLTComponentDataType* pType=inputDataTypes;
121 while (pType->fID!=0) {
122 list.push_back(*pType);
127 AliHLTComponentDataType
128 AliHLTPHOSRawAnalyzerComponent::GetOutputDataType()
130 return AliHLTPHOSDefinitions::gkCellEnergyDataType;
134 AliHLTPHOSRawAnalyzerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
138 inputMultiplier = 0.1;
142 int AliHLTPHOSRawAnalyzerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
143 AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
144 AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
146 AliHLTUInt8_t tmpMod = 0;
147 AliHLTUInt8_t tmpZ = 0;
148 AliHLTUInt8_t tmpX = 0;
149 AliHLTUInt8_t tmpGain = 0;
151 Int_t processedChannels = 0;
155 Int_t tmpChannelCnt = 0;
156 Int_t tmpStartIndex = 0;
157 AliHLTUInt8_t* outBPtr;
159 const AliHLTComponentBlockData* iter = NULL;
162 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
168 if ( iter->fDataType != AliHLTPHOSDefinitions::gkDDLPackedRawDataType )
173 fRawMemoryReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
174 analyzerPtr->SetData(fTmpChannelData);
175 fOutPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)outBPtr;
176 mysize += sizeof(AliHLTPHOSRcuCellEnergyDataStruct);
177 fOutPtr->fRcuX = fRcuX;
178 fOutPtr->fRcuZ = fRcuZ;
179 fOutPtr->fModuleID = fModuleID;
182 while(fPHOSRawStream->Next())
184 if (fPHOSRawStream->IsNewHWAddress())
186 if(processedChannels > 0)
188 analyzerPtr->SetData(fTmpChannelData);
189 analyzerPtr->Evaluate(0, sampleCnt);
191 fOutPtr->fValidData[tmpChannelCnt].fGain = tmpGain;
192 fOutPtr->fValidData[tmpChannelCnt].fZ = tmpZ;
193 fOutPtr->fValidData[tmpChannelCnt].fX = tmpX;
194 fOutPtr->fValidData[tmpChannelCnt].fEnergy = analyzerPtr->GetEnergy();
195 fOutPtr->fValidData[tmpChannelCnt].fTime = analyzerPtr->GetTiming();
197 ResetDataPtr(tmpStartIndex, sampleCnt);
201 tmpMod = (AliHLTUInt8_t)fPHOSRawStream->GetModule() ;
202 tmpX =(AliHLTUInt8_t)fPHOSRawStream->GetRow() - fRcuXOffset;
203 tmpZ =(AliHLTUInt8_t)fPHOSRawStream->GetColumn() - fRcuZOffset;
204 tmpGain = fPHOSRawStream->IsLowGain();
205 processedChannels ++;
211 tmpStartIndex = fPHOSRawStream->GetTime();
214 fTmpChannelData[fPHOSRawStream->GetTime()] = fPHOSRawStream->GetSignal();
220 analyzerPtr->SetData(fTmpChannelData);
221 analyzerPtr->Evaluate(0, sampleCnt);
223 fOutPtr->fValidData[tmpChannelCnt].fGain = tmpGain;
224 fOutPtr->fValidData[tmpChannelCnt].fZ = tmpZ;
225 fOutPtr->fValidData[tmpChannelCnt].fX = tmpX;
226 fOutPtr->fValidData[tmpChannelCnt].fEnergy = analyzerPtr->GetEnergy();
227 fOutPtr->fValidData[tmpChannelCnt].fTime = analyzerPtr->GetTiming();
230 ResetDataPtr(tmpStartIndex, sampleCnt);
235 fOutPtr->fCnt = tmpChannelCnt;
236 AliHLTComponentBlockData bd;
240 bd.fDataType = AliHLTPHOSDefinitions::gkCellEnergyDataType;
241 bd.fSpecification = 0xFFFFFFFF;
242 outputBlocks.push_back( bd );
248 Logging( kHLTLogFatal, "HLT::AliHLTPHOSRawAnalyzerComponent::DoEvent", "Too much data",
249 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
262 AliHLTPHOSRawAnalyzerComponent::DoInit( int argc, const char** argv )
264 int equippmentID = atoi(argv[6]);
266 fRawMemoryReader = new AliRawReaderMemory();
267 fPHOSRawStream = new AliCaloRawStream(fRawMemoryReader,"PHOS");
268 fPHOSRawStream->SetOldRCUFormat(kFALSE);
269 fRawMemoryReader->SetEquipmentID(equippmentID);
270 SetEquippmentID(equippmentID);
271 SetCoordinates(equippmentID);
272 if (argc==0 && argv==NULL) {
273 // this is currently just to get rid of the warning "unused parameter"
280 AliHLTPHOSRawAnalyzerComponent::DumpData(int gain)
282 for(int mod = 0; mod < N_MODULES; mod ++)
284 printf("\n *********** MODULE %d ************\n", mod);
285 for(int row = 0; row < N_ROWS_MOD; row ++)
287 for(int col = 0; col < N_COLUMNS_MOD; col ++)
289 if( fMaxValues[mod][row][col][0] != 0)
291 cout << fMaxValues[mod][row][col][gain] << "\t";
300 AliHLTPHOSRawAnalyzerComponent::DumpData()
306 AliHLTPHOSRawAnalyzerComponent::DumpChannelData(Double_t *data)
310 for(int i=0; i< ALTRO_MAX_SAMPLES; i++)
319 for(int i=0; i< ALTRO_MAX_SAMPLES; i++)
323 cout <<data[i] <<"\t";
332 AliHLTPHOSRawAnalyzerComponent::Reset()
334 for(int mod = 0; mod < N_MODULES; mod ++)
336 for(int row = 0; row < N_ROWS_MOD; row ++)
338 for(int col = 0; col < N_COLUMNS_MOD; col ++)
340 for(int gain = 0; gain < N_GAINS; gain ++ )
342 fMaxValues[mod][row][col][gain] = 0;
354 AliHLTPHOSRawAnalyzerComponent::ResetDataPtr()
356 for(int i = 0 ; i< ALTRO_MAX_SAMPLES; i++)
358 fTmpChannelData[i] = 0;
363 AliHLTPHOSRawAnalyzerComponent::ResetDataPtr(int sampleCnt)
365 for(int i = 0 ; i< sampleCnt; i++)
367 fTmpChannelData[i] = 0;
372 AliHLTPHOSRawAnalyzerComponent::ResetDataPtr(int startindex, int sampleCnt)
374 for(int i = startindex ; i< sampleCnt; i++)
376 fTmpChannelData[i] = 0;
381 AliHLTPHOSRawAnalyzerComponent::SetEquippmentID(AliHLTUInt16_t id)
388 AliHLTPHOSRawAnalyzerComponent::GetEquippmentID()
390 return fEquippmentID;
395 AliHLTPHOSRawAnalyzerComponent::SetCoordinates(AliHLTUInt16_t equippmentID)
397 int rcuIndex = (fEquippmentID - 1792)%N_RCUS_PER_MODULE;
398 fModuleID = (fEquippmentID -1792 -rcuIndex)/N_RCUS_PER_MODULE;
426 fRcuZOffset = N_ZROWS_RCU*fRcuZ;
427 fRcuXOffset = N_XCOLUMNS_RCU*fRcuX;
429 cout <<"********InitInfo************"<< endl;
430 cout <<"AliHLTPHOSRawAnalyzerComponent::SetCoordinate"<< endl;
431 cout <<"Equpippment ID =\t"<< fEquippmentID <<endl;
432 cout <<"Module ID =\t"<< (int)fModuleID<<endl;
433 cout <<"RCUX =\t\t" << (int)fRcuX << endl;
434 cout <<"RCUZ =\t\t" << (int)fRcuZ << endl;
435 cout <<"RcuZOffset = \t" << (int)fRcuZOffset << endl;
436 cout <<"RcuXOffset = \t" << (int)fRcuXOffset << endl << endl;