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;
33 AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent():AliHLTProcessor(), fEquippmentID(0), fRcuX(0),
34 fRcuZ(0),fRcuRowOffeset(0), fRcuColOffeset(0), fModuleID(0), fPHOSRawStream(), fRawMemoryReader(0), fOutPtr(0)
39 AliHLTPHOSRawAnalyzerComponent::~AliHLTPHOSRawAnalyzerComponent()
41 if(fRawMemoryReader != 0)
43 delete fRawMemoryReader;
45 if(fPHOSRawStream != 0)
47 delete fPHOSRawStream;
54 AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent(const AliHLTPHOSRawAnalyzerComponent & ) : AliHLTProcessor(),
55 fEquippmentID(0), fRcuX(0), fRcuZ(0),fRcuRowOffeset(0), fRcuColOffeset(0), fModuleID(0), fPHOSRawStream(), fRawMemoryReader(0), fOutPtr(0)
61 AliHLTPHOSRawAnalyzerComponent::Deinit()
67 AliHLTPHOSRawAnalyzerComponent::DoDeinit()
69 Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSRawAnalyzerComponen DoDeinit");
71 if(fRawMemoryReader !=0)
73 delete fRawMemoryReader;
76 if(fPHOSRawStream != 0)
78 delete fPHOSRawStream;
85 AliHLTPHOSRawAnalyzerComponent::GetComponentID()
87 return "AliPhosTestRaw";
91 AliHLTPHOSRawAnalyzerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
93 const AliHLTComponentDataType* pType=inputDataTypes;
94 while (pType->fID!=0) {
95 list.push_back(*pType);
100 AliHLTComponentDataType
101 AliHLTPHOSRawAnalyzerComponent::GetOutputDataType()
103 return AliHLTPHOSDefinitions::gkCellEnergyDataType;
107 AliHLTPHOSRawAnalyzerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
111 inputMultiplier = 0.1;
115 int AliHLTPHOSRawAnalyzerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
116 AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
117 AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
124 Int_t processedChannels = 0;
128 Int_t tmpChannelCnt = 0;
129 AliHLTUInt8_t* outBPtr;
131 const AliHLTComponentBlockData* iter = NULL;
134 if((fEventCount % 100) == 0)
136 cout << "analyzing event: " << fEventCount << endl;
139 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
145 if ( iter->fDataType != AliHLTPHOSDefinitions::gkDDLPackedRawDataType )
147 cout << "Warning: data type = is nOT gkDDLPackedRawDataType " << endl;
151 fRawMemoryReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
152 analyzerPtr->SetData(fTmpChannelData);
153 fOutPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)outBPtr;
154 mysize += sizeof(AliHLTPHOSRcuCellEnergyDataStruct);
155 fOutPtr->fRcuX = fRcuX;
156 fOutPtr->fRcuZ = fRcuZ;
157 fOutPtr->fModuleID = fModuleID;
160 if(fEventCount%100 ==0)
162 cout <<"Analyzing event: " << fEventCount << endl;
165 while(fPHOSRawStream->Next())
167 if (fPHOSRawStream->IsNewHWAddress())
169 if(processedChannels > 0)
171 analyzerPtr->SetData(fTmpChannelData);
172 analyzerPtr->Evaluate(0, sampleCnt);
173 fOutPtr->fCellEnergies[tmpRow][tmpCol][tmpGain] = analyzerPtr->GetEnergy();
175 fOutPtr->fValidData[tmpChannelCnt].fGain = tmpGain;
176 fOutPtr->fValidData[tmpChannelCnt].fRow = tmpRow;
177 fOutPtr->fValidData[tmpChannelCnt].fCol = tmpCol;
184 tmpMod = fPHOSRawStream->GetModule() ;
185 tmpRow = fPHOSRawStream->GetRow() - fRcuRowOffeset;
186 tmpCol = fPHOSRawStream->GetColumn() - fRcuColOffeset;
187 tmpGain = fPHOSRawStream->IsLowGain();
188 processedChannels ++;
190 fTmpChannelData[fPHOSRawStream->GetTime()] = fPHOSRawStream->GetSignal();
195 fOutPtr->fCnt = tmpChannelCnt;
196 AliHLTComponentBlockData bd;
200 bd.fDataType = AliHLTPHOSDefinitions::gkCellEnergyDataType;
201 bd.fSpecification = 0xFFFFFFFF;
202 outputBlocks.push_back( bd );
208 Logging( kHLTLogFatal, "HLT::AliHLTPHOSRawAnalyzerComponent::DoEvent", "Too much data",
209 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
223 AliHLTPHOSRawAnalyzerComponent::DoInit( int argc, const char** argv )
225 int equippmentID = atoi(argv[6]);
227 fRawMemoryReader = new AliRawReaderMemory();
228 fPHOSRawStream = new AliCaloRawStream(fRawMemoryReader,"PHOS");
229 fRawMemoryReader->SetEquipmentID(equippmentID);
230 SetEquippmentID(equippmentID);
231 SetCoordinates(equippmentID);
232 if (argc==0 && argv==NULL) {
233 // this is currently just to get rid of the warning "unused parameter"
239 AliHLTPHOSRawAnalyzerComponent::DumpData()
241 for(int mod = 0; mod <5; mod ++)
243 printf("\n *********** MODULE %d ************\n", mod);
244 for(int row = 0; row < 64; row ++)
246 for(int col = 0; col < 56; col ++)
248 if( fMaxValues[mod][row][col][0] != 0)
250 cout << fMaxValues[mod][row][col][0] << "\t";
258 AliHLTPHOSRawAnalyzerComponent::DumpChannelData(Double_t *data)
262 for(int i=0; i< 1008; i++)
271 for(int i=0; i< 1008; i++)
275 cout <<data[i] <<"\t";
285 AliHLTPHOSRawAnalyzerComponent::Reset()
287 for(int mod = 0; mod <5; mod ++)
289 for(int row = 0; row < 64; row ++)
291 for(int col = 0; col < 56; col ++)
293 for(int gain = 0; gain <2; gain ++ )
295 fMaxValues[mod][row][col][gain] = 0;
301 for(int i = 0 ; i< 1008; i++)
303 fTmpChannelData[i] = 0;
308 AliHLTPHOSRawAnalyzerComponent::ResetDataPtr()
310 for(int i = 0 ; i< 1008; i++)
312 fTmpChannelData[i] = 0;
318 AliHLTPHOSRawAnalyzerComponent::SetEquippmentID(AliHLTUInt32_t id)
324 AliHLTPHOSRawAnalyzerComponent::GetEquippmentID()
326 return fEquippmentID;
330 AliHLTPHOSRawAnalyzerComponent::SetCoordinates(AliHLTUInt32_t equippmentID)
332 int rcuIndex = (fEquippmentID - 1792)%4;
333 fModuleID = (fEquippmentID -1792 -rcuIndex)/5;
360 fRcuRowOffeset = 32*fRcuX;
361 fRcuColOffeset = 28*fRcuZ;