3 /**************************************************************************
4 * This file is property of and copyright by the Experimental Nuclear *
5 * Physics Group, Dep. of Physics *
6 * University of Oslo, Norway, 2007 *
8 * Author: Per Thomas Hille <perthi@fys.uio.no> for the ALICE HLT Project.*
9 * Contributors are mentioned in the code where appropriate. *
10 * Please report bugs to perthi@fys.uio.no *
12 * Permission to use, copy, modify and distribute this software and its *
13 * documentation strictly for non-commercial purposes is hereby granted *
14 * without fee, provided that the above copyright notice appears in all *
15 * copies and that both the copyright notice and this permission notice *
16 * appear in the supporting documentation. The authors make no claims *
17 * about the suitability of this software for any purpose. It is *
18 * provided "as is" without express or implied warranty. *
19 **************************************************************************/
20 #include "AliHLTPHOSFourierComponent.h"
21 #include "AliHLTPHOSFourier.h"
22 #include "AliHLTPHOSValidCellDataStruct.h"
23 #include "AliHLTPHOSRcuCellEnergyDataStruct.h"
24 #include "AliHLTPHOSSharedMemoryInterface.h"
26 #include "AliHLTPHOSRcuFFTDataStruct.h"
28 AliHLTPHOSFourierComponent gAliHLTPHOSFourierComponent;
30 AliHLTPHOSFourierComponent::AliHLTPHOSFourierComponent(): AliHLTPHOSRcuProcessor(),fFourierPtr(0), fShmPtr(0),fOutPtr(0)
32 fFourierPtr = new AliHLTPHOSFourier();
33 fShmPtr = new AliHLTPHOSSharedMemoryInterface();
37 AliHLTPHOSFourierComponent::~AliHLTPHOSFourierComponent()
44 AliHLTPHOSFourierComponent::Deinit()
46 Logging(kHLTLogInfo, "HLT", "PHOS", ",Deinitializing AliHLTPHOSFourierComponent");
52 AliHLTPHOSFourierComponent::GetComponentID()
60 AliHLTPHOSFourierComponent::Spawn()
63 return new AliHLTPHOSFourierComponent;
68 AliHLTPHOSFourierComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
71 list.push_back(AliHLTPHOSDefinitions::fgkCellEnergyDataType);
74 const AliHLTComponentDataType* pType=fgkInputDataTypes;
78 list.push_back(*pType);
85 AliHLTComponentDataType
86 AliHLTPHOSFourierComponent::GetOutputDataType()
88 return AliHLTPHOSDefinitions::fgkFourierTransform;
89 // return AliHLTPHOSDefinitions::fgkCellEnergyDataType;
90 // return kAliHLTMultipleDataType;
96 AliHLTPHOSFourierComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList)
99 tgtList.push_back(AliHLTPHOSDefinitions::fgkFourierTransform);
100 // tgtList.push_back(kAliHLTDataTypeHwAddr16);
101 return tgtList.size();
108 AliHLTPHOSFourierComponent::GetOutputDataSize(unsigned long& /*constBase*/, double& inputMultiplier)
111 // inputMultiplier = 1;
113 // inputMultiplier = 1.2;
114 inputMultiplier = 0.1;
118 AliHLTPHOSFourierComponent::DoInit(int /*argc*/, const char** /*argv*/)
120 cout << "AliHLTPHOSFourierComponent::DoInit !!!!!!!!!! " << endl;
126 AliHLTPHOSFourierComponent::DoDeinit()
133 AliHLTPHOSFourierComponent::DoEvent(const AliHLTComponentEventData& evtData,
134 const AliHLTComponentBlockData* blocks,
135 AliHLTComponentTriggerData& /*trigData*/,
136 AliHLTUInt8_t* outputPtr,
137 AliHLTUInt32_t& size,
138 AliHLTComponentBlockDataList& outputBlocks )
141 AliHLTPHOSValidCellDataStruct *currentChannel =0;
145 const AliHLTComponentBlockData* iter = NULL;
147 UInt_t specification = 0;
149 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
153 if(iter->fDataType != AliHLTPHOSDefinitions::fgkCellEnergyDataType)
159 specification = specification|iter->fSpecification;
160 AliHLTPHOSRcuCellEnergyDataStruct *cellDataPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)( iter->fPtr);
161 AliHLTPHOSRcuFFTDataStruct *fourierOutPtr = (AliHLTPHOSRcuFFTDataStruct*)outputPtr;
162 fShmPtr->SetMemory(cellDataPtr);
163 currentChannel = fShmPtr->NextChannel();
165 while(currentChannel != 0)
169 data= fShmPtr->GetRawData(nsamples);
170 fFourierPtr->ProcessFourier(data, nsamples, currentChannel->fZ, currentChannel->fX, currentChannel->fGain );
171 currentChannel = fShmPtr->NextChannel();
174 *fourierOutPtr = fFourierPtr->GetPSD();
176 for(int i=0; i < 500; i++)
183 cout << fourierOutPtr->fGlobalAccumulatedPSD[1][i] << "\t";
186 mysize += sizeof(AliHLTPHOSRcuFFTDataStruct);
187 AliHLTComponentBlockData bd;
190 bd.fDataType = AliHLTPHOSDefinitions::fgkFourierTransform;
191 // bd.fSpecification = 0xFFFFFFFF;
192 // bd.fSpecification = specification;
193 bd.fSpecification = 1;
194 outputBlocks.push_back( bd );
199 cout <<"size left is "<< size <<" FourierComponenet: offset ="<< offset << "mysize =" << mysize << "specification =" << specification <<endl;
206 cout <<"HLT::AliHLTFourierComponent::DoEvent Too much data Data written over allowed buffer. Amount written:"<< tSize<<"allowed amount"<< size << endl;
207 Logging( kHLTLogFatal, "HLT::AliHLTFourierComponent::DoEvent", "Too much data",
208 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu." , tSize, size );