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()
83 *Deinit function called by the HLT framwork at end of run
84 *@return 0 if the denitialzation was sucessfull.
87 AliHLTPHOSRawAnalyzerComponent::DoDeinit()
89 Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSRawAnalyzerComponen DoDeinit");
91 if(fRawMemoryReader !=0)
93 delete fRawMemoryReader;
96 if(fPHOSRawStream != 0)
98 delete fPHOSRawStream;
105 *Function called by the HLT framework during initialization
106 *@return the ID of the component
109 AliHLTPHOSRawAnalyzerComponent::GetComponentID()
111 return "AliPhosTestRaw";
116 AliHLTPHOSRawAnalyzerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
118 const AliHLTComponentDataType* pType=inputDataTypes;
119 while (pType->fID!=0) {
120 list.push_back(*pType);
125 AliHLTComponentDataType
126 AliHLTPHOSRawAnalyzerComponent::GetOutputDataType()
128 return AliHLTPHOSDefinitions::gkCellEnergyDataType;
132 AliHLTPHOSRawAnalyzerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
136 inputMultiplier = 0.1;
140 int AliHLTPHOSRawAnalyzerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
141 AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
142 AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
144 AliHLTUInt8_t tmpMod = 0;
145 AliHLTUInt8_t tmpZ = 0;
146 AliHLTUInt8_t tmpX = 0;
147 AliHLTUInt8_t tmpGain = 0;
149 Int_t processedChannels = 0;
153 Int_t tmpChannelCnt = 0;
154 Int_t tmpStartIndex = 0;
155 AliHLTUInt8_t* outBPtr;
157 const AliHLTComponentBlockData* iter = NULL;
160 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
166 if ( iter->fDataType != AliHLTPHOSDefinitions::gkDDLPackedRawDataType )
171 fRawMemoryReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
172 analyzerPtr->SetData(fTmpChannelData);
173 fOutPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)outBPtr;
174 mysize += sizeof(AliHLTPHOSRcuCellEnergyDataStruct);
175 fOutPtr->fRcuX = fRcuX;
176 fOutPtr->fRcuZ = fRcuZ;
177 fOutPtr->fModuleID = fModuleID;
180 while(fPHOSRawStream->Next())
182 if (fPHOSRawStream->IsNewHWAddress())
184 if(processedChannels > 0)
186 analyzerPtr->SetData(fTmpChannelData);
187 analyzerPtr->Evaluate(0, sampleCnt);
189 fOutPtr->fValidData[tmpChannelCnt].fGain = tmpGain;
190 fOutPtr->fValidData[tmpChannelCnt].fZ = tmpZ;
191 fOutPtr->fValidData[tmpChannelCnt].fX = tmpX;
192 fOutPtr->fValidData[tmpChannelCnt].fEnergy = analyzerPtr->GetEnergy();
193 fOutPtr->fValidData[tmpChannelCnt].fTime = analyzerPtr->GetTiming();
195 ResetDataPtr(tmpStartIndex, sampleCnt);
199 tmpMod = (AliHLTUInt8_t)fPHOSRawStream->GetModule() ;
200 tmpX =(AliHLTUInt8_t)fPHOSRawStream->GetRow() - fRcuXOffset;
201 tmpZ =(AliHLTUInt8_t)fPHOSRawStream->GetColumn() - fRcuZOffset;
202 tmpGain = fPHOSRawStream->IsLowGain();
203 processedChannels ++;
208 tmpStartIndex = fPHOSRawStream->GetTime();
211 fTmpChannelData[fPHOSRawStream->GetTime()] = fPHOSRawStream->GetSignal();
216 fOutPtr->fCnt = tmpChannelCnt;
217 AliHLTComponentBlockData bd;
221 bd.fDataType = AliHLTPHOSDefinitions::gkCellEnergyDataType;
222 bd.fSpecification = 0xFFFFFFFF;
223 outputBlocks.push_back( bd );
229 Logging( kHLTLogFatal, "HLT::AliHLTPHOSRawAnalyzerComponent::DoEvent", "Too much data",
230 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
243 AliHLTPHOSRawAnalyzerComponent::DoInit( int argc, const char** argv )
245 int equippmentID = atoi(argv[6]);
247 fRawMemoryReader = new AliRawReaderMemory();
248 fPHOSRawStream = new AliCaloRawStream(fRawMemoryReader,"PHOS");
249 fPHOSRawStream->SetOldRCUFormat(kFALSE);
250 fRawMemoryReader->SetEquipmentID(equippmentID);
251 SetEquippmentID(equippmentID);
252 SetCoordinates(equippmentID);
253 if (argc==0 && argv==NULL) {
254 // this is currently just to get rid of the warning "unused parameter"
261 AliHLTPHOSRawAnalyzerComponent::DumpData(int gain)
263 for(int mod = 0; mod < N_MODULES; mod ++)
265 printf("\n *********** MODULE %d ************\n", mod);
266 for(int row = 0; row < N_ROWS_MOD; row ++)
268 for(int col = 0; col < N_COLUMNS_MOD; col ++)
270 if( fMaxValues[mod][row][col][0] != 0)
272 cout << fMaxValues[mod][row][col][gain] << "\t";
281 AliHLTPHOSRawAnalyzerComponent::DumpData()
287 AliHLTPHOSRawAnalyzerComponent::DumpChannelData(Double_t *data)
291 for(int i=0; i< ALTRO_MAX_SAMPLES; i++)
300 for(int i=0; i< ALTRO_MAX_SAMPLES; i++)
304 cout <<data[i] <<"\t";
313 AliHLTPHOSRawAnalyzerComponent::Reset()
315 for(int mod = 0; mod < N_MODULES; mod ++)
317 for(int row = 0; row < N_ROWS_MOD; row ++)
319 for(int col = 0; col < N_COLUMNS_MOD; col ++)
321 for(int gain = 0; gain < N_GAINS; gain ++ )
323 fMaxValues[mod][row][col][gain] = 0;
335 AliHLTPHOSRawAnalyzerComponent::ResetDataPtr()
337 for(int i = 0 ; i< ALTRO_MAX_SAMPLES; i++)
339 fTmpChannelData[i] = 0;
344 AliHLTPHOSRawAnalyzerComponent::ResetDataPtr(int sampleCnt)
346 for(int i = 0 ; i< sampleCnt; i++)
348 fTmpChannelData[i] = 0;
353 AliHLTPHOSRawAnalyzerComponent::ResetDataPtr(int startindex, int sampleCnt)
355 for(int i = startindex ; i< sampleCnt; i++)
357 fTmpChannelData[i] = 0;
362 AliHLTPHOSRawAnalyzerComponent::SetEquippmentID(AliHLTUInt16_t id)
369 AliHLTPHOSRawAnalyzerComponent::GetEquippmentID()
371 return fEquippmentID;
376 AliHLTPHOSRawAnalyzerComponent::SetCoordinates(AliHLTUInt16_t equippmentID)
378 int rcuIndex = (fEquippmentID - 1792)%N_RCUS_PER_MODULE;
379 fModuleID = (fEquippmentID -1792 -rcuIndex)/N_RCUS_PER_MODULE;
405 fRcuZOffset = N_ZROWS_RCU*fRcuZ;
406 fRcuXOffset = N_XCOLUMNS_RCU*fRcuX;
408 cout <<"********InitInfo************"<< endl;
409 cout <<"AliHLTPHOSRawAnalyzerComponent::SetCoordinate"<< endl;
410 cout <<"Equpippment ID =\t"<< fEquippmentID <<endl;
411 cout <<"Module ID =\t"<< fModuleID<<endl;
412 cout <<"RCUX =\t\t" << fRcuX << endl;
413 cout <<"RCUZ =\t\t" << fRcuZ << endl;
414 cout <<"RcuZOffset = \t" << fRcuZOffset << endl;
415 cout <<"RcuXOffset = \t" << fRcuXOffset << endl << endl;