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 **************************************************************************/
18 #include "AliHLTPHOSFourierComponent.h"
19 #include "AliHLTPHOSFourier.h"
20 #include "AliHLTPHOSValidCellDataStruct.h"
21 #include "AliHLTPHOSRcuCellEnergyDataStruct.h"
22 #include "AliHLTPHOSSharedMemoryInterface.h"
24 #include "AliHLTPHOSRcuFFTDataStruct.h"
26 AliHLTPHOSFourierComponent gAliHLTPHOSFourierComponent;
28 AliHLTPHOSFourierComponent::AliHLTPHOSFourierComponent(): AliHLTPHOSRcuProcessor(),fFourierPtr(0), fShmPtr(0),fOutPtr(0)
30 fFourierPtr = new AliHLTPHOSFourier();
31 fShmPtr = new AliHLTPHOSSharedMemoryInterface();
35 AliHLTPHOSFourierComponent::~AliHLTPHOSFourierComponent()
42 AliHLTPHOSFourierComponent::Deinit()
44 Logging(kHLTLogInfo, "HLT", "PHOS", ",Deinitializing AliHLTPHOSFourierComponent");
50 AliHLTPHOSFourierComponent::GetComponentID()
58 AliHLTPHOSFourierComponent::Spawn()
61 return new AliHLTPHOSFourierComponent;
66 AliHLTPHOSFourierComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
69 list.push_back(AliHLTPHOSDefinitions::fgkCellEnergyDataType);
72 const AliHLTComponentDataType* pType=fgkInputDataTypes;
76 list.push_back(*pType);
83 AliHLTComponentDataType
84 AliHLTPHOSFourierComponent::GetOutputDataType()
86 return AliHLTPHOSDefinitions::fgkFourierTransform;
87 // return AliHLTPHOSDefinitions::fgkCellEnergyDataType;
88 // return kAliHLTMultipleDataType;
94 AliHLTPHOSFourierComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList)
97 tgtList.push_back(AliHLTPHOSDefinitions::fgkFourierTransform);
98 // tgtList.push_back(kAliHLTDataTypeHwAddr16);
99 return tgtList.size();
106 AliHLTPHOSFourierComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
109 // inputMultiplier = 1;
111 // inputMultiplier = 1.2;
112 inputMultiplier = 0.1;
116 AliHLTPHOSFourierComponent::DoInit(int /*argc*/, const char** /*argv*/)
118 cout << "AliHLTPHOSFourierComponent::DoInit !!!!!!!!!! " << endl;
124 AliHLTPHOSFourierComponent::DoDeinit()
131 AliHLTPHOSFourierComponent::DoEvent(const AliHLTComponentEventData& evtData,
132 const AliHLTComponentBlockData* blocks,
133 AliHLTComponentTriggerData& /*trigData*/,
134 AliHLTUInt8_t* outputPtr,
135 AliHLTUInt32_t& size,
136 AliHLTComponentBlockDataList& outputBlocks )
139 AliHLTPHOSValidCellDataStruct *currentChannel =0;
143 const AliHLTComponentBlockData* iter = NULL;
145 UInt_t specification = 0;
147 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
151 if(iter->fDataType != AliHLTPHOSDefinitions::fgkCellEnergyDataType)
157 specification = specification|iter->fSpecification;
158 AliHLTPHOSRcuCellEnergyDataStruct *cellDataPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)( iter->fPtr);
159 AliHLTPHOSRcuFFTDataStruct *fourierOutPtr = (AliHLTPHOSRcuFFTDataStruct*)outputPtr;
160 fShmPtr->SetMemory(cellDataPtr);
161 currentChannel = fShmPtr->NextChannel();
163 while(currentChannel != 0)
167 data= fShmPtr->GetRawData(nsamples);
168 fFourierPtr->ProcessFourier(data, nsamples, currentChannel->fZ, currentChannel->fX, currentChannel->fGain );
169 currentChannel = fShmPtr->NextChannel();
172 *fourierOutPtr = fFourierPtr->GetPSD();
174 for(int i=0; i < 500; i++)
181 cout << fourierOutPtr->fGlobalAccumulatedPSD[1][i] << "\t";
184 mysize += sizeof(AliHLTPHOSRcuFFTDataStruct);
185 AliHLTComponentBlockData bd;
188 bd.fDataType = AliHLTPHOSDefinitions::fgkFourierTransform;
189 // bd.fSpecification = 0xFFFFFFFF;
190 // bd.fSpecification = specification;
191 bd.fSpecification = 1;
192 outputBlocks.push_back( bd );
197 cout <<"size left is "<< size <<" FourierComponenet: offset ="<< offset << "mysize =" << mysize << "specification =" << specification <<endl;
204 cout <<"HLT::AliHLTFourierComponent::DoEvent Too much data Data written over allowed buffer. Amount written:"<< tSize<<"allowed amount"<< size << endl;
205 Logging( kHLTLogFatal, "HLT::AliHLTFourierComponent::DoEvent", "Too much data",
206 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu." , tSize, size );