]>
Commit | Line | Data |
---|---|---|
9d05c97d | 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 * | |
5 | * * | |
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 * | |
9 | * * | |
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" | |
23 | ||
24 | #include "AliHLTPHOSRcuFFTDataStruct.h" | |
25 | ||
26 | AliHLTPHOSFourierComponent gAliHLTPHOSFourierComponent; | |
27 | ||
28 | AliHLTPHOSFourierComponent::AliHLTPHOSFourierComponent(): AliHLTPHOSRcuProcessor(),fFourierPtr(0), fShmPtr(0),fOutPtr(0) | |
29 | { | |
30 | fFourierPtr = new AliHLTPHOSFourier(); | |
31 | fShmPtr = new AliHLTPHOSSharedMemoryInterface(); | |
32 | } | |
33 | ||
34 | ||
35 | AliHLTPHOSFourierComponent::~AliHLTPHOSFourierComponent() | |
36 | { | |
37 | ||
38 | } | |
39 | ||
40 | ||
41 | int | |
42 | AliHLTPHOSFourierComponent::Deinit() | |
43 | { | |
44 | Logging(kHLTLogInfo, "HLT", "PHOS", ",Deinitializing AliHLTPHOSFourierComponent"); | |
45 | return 0; | |
46 | } | |
47 | ||
48 | ||
49 | const char* | |
50 | AliHLTPHOSFourierComponent::GetComponentID() | |
51 | { | |
52 | return "PhosFourier"; | |
53 | // "PhosFourier" | |
54 | } | |
55 | ||
56 | ||
57 | AliHLTComponent* | |
58 | AliHLTPHOSFourierComponent::Spawn() | |
59 | ||
60 | { | |
61 | return new AliHLTPHOSFourierComponent; | |
62 | } | |
63 | ||
64 | ||
65 | void | |
66 | AliHLTPHOSFourierComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) | |
67 | { | |
68 | const AliHLTComponentDataType* pType=fgkInputDataTypes; | |
69 | ||
70 | while (pType->fID!=0) | |
71 | { | |
72 | list.push_back(*pType); | |
73 | pType++; | |
74 | } | |
75 | } | |
76 | ||
77 | ||
78 | AliHLTComponentDataType | |
79 | AliHLTPHOSFourierComponent::GetOutputDataType() | |
80 | { | |
81 | return AliHLTPHOSDefinitions::fgkFourierTransform; | |
82 | // return AliHLTPHOSDefinitions::fgkCellEnergyDataType; | |
83 | // return kAliHLTMultipleDataType; | |
84 | } | |
85 | ||
86 | ||
87 | /* | |
88 | int | |
89 | AliHLTPHOSFourierComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList) | |
90 | { | |
91 | tgtList.clear(); | |
92 | tgtList.push_back(AliHLTPHOSDefinitions::fgkFourierTransform); | |
93 | // tgtList.push_back(kAliHLTDataTypeHwAddr16); | |
94 | return tgtList.size(); | |
95 | } | |
96 | */ | |
97 | ||
98 | ||
99 | ||
100 | void | |
101 | AliHLTPHOSFourierComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier) | |
102 | { | |
103 | // constBase =1; | |
104 | // inputMultiplier = 1; | |
105 | // constBase = 30; | |
106 | // inputMultiplier = 1.2; | |
107 | inputMultiplier = 0.1; | |
108 | } | |
109 | ||
110 | int | |
111 | AliHLTPHOSFourierComponent::DoInit(int /*argc*/, const char** /*argv*/) | |
112 | { | |
113 | cout << "AliHLTPHOSFourierComponent::DoInit !!!!!!!!!! " << endl; | |
114 | return 0; | |
115 | } | |
116 | ||
117 | /* | |
118 | int | |
119 | AliHLTPHOSFourierComponent::DoDeinit() | |
120 | { | |
121 | ||
122 | } | |
123 | */ | |
124 | ||
125 | int | |
126 | AliHLTPHOSFourierComponent::DoEvent(const AliHLTComponentEventData& evtData, | |
127 | const AliHLTComponentBlockData* blocks, | |
128 | AliHLTComponentTriggerData& /*trigData*/, | |
129 | AliHLTUInt8_t* outputPtr, | |
130 | AliHLTUInt32_t& size, | |
131 | AliHLTComponentBlockDataList& outputBlocks ) | |
132 | { | |
133 | fPhosEventCount ++; | |
134 | AliHLTPHOSValidCellDataStruct *currentChannel =0; | |
135 | UInt_t offset = 0; | |
136 | UInt_t mysize = 0; | |
137 | UInt_t tSize = 0; | |
138 | const AliHLTComponentBlockData* iter = NULL; | |
139 | unsigned long ndx; | |
140 | UInt_t specification = 0; | |
141 | ||
142 | for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) | |
143 | { | |
144 | iter = blocks+ndx; | |
145 | if(iter->fDataType != AliHLTPHOSDefinitions::fgkCellEnergyDataType) | |
146 | { | |
147 | ||
148 | continue; | |
149 | } | |
150 | ||
151 | specification = specification|iter->fSpecification; | |
152 | AliHLTPHOSRcuCellEnergyDataStruct *cellDataPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)( iter->fPtr); | |
153 | AliHLTPHOSRcuFFTDataStruct *fourierOutPtr = (AliHLTPHOSRcuFFTDataStruct*)outputPtr; | |
154 | fShmPtr->SetMemory(cellDataPtr); | |
155 | currentChannel = fShmPtr->NextChannel(); | |
156 | ||
157 | while(currentChannel != 0) | |
158 | { | |
159 | Int_t *data; | |
160 | Int_t nsamples = 0; | |
161 | data= fShmPtr->GetRawData(nsamples); | |
1283c2be | 162 | fFourierPtr->ProcessFourier(data, nsamples, currentChannel->fZ, currentChannel->fX, currentChannel->fGain ); |
9d05c97d | 163 | currentChannel = fShmPtr->NextChannel(); |
164 | } | |
165 | ||
166 | *fourierOutPtr = fFourierPtr->GetPSD(); | |
167 | ||
168 | for(int i=0; i < 500; i++) | |
169 | { | |
170 | if(i%16 == 0) | |
171 | { | |
172 | printf("\n"); | |
173 | } | |
174 | ||
175 | cout << fourierOutPtr->fGlobalAccumulatedPSD[1][i] << "\t"; | |
176 | } | |
177 | ||
178 | mysize += sizeof(AliHLTPHOSRcuFFTDataStruct); | |
179 | AliHLTComponentBlockData bd; | |
180 | bd.fOffset = offset; | |
181 | bd.fSize = mysize; | |
182 | bd.fDataType = AliHLTPHOSDefinitions::fgkFourierTransform; | |
183 | // bd.fSpecification = 0xFFFFFFFF; | |
184 | bd.fSpecification = specification; | |
185 | outputBlocks.push_back( bd ); | |
186 | ||
187 | cout <<"size left is "<< size <<" FourierComponenet: offset ="<< offset << "mysize =" << mysize << "specification =" << specification <<endl; | |
188 | ||
189 | tSize += mysize; | |
190 | ||
191 | outputPtr += mysize; | |
192 | ||
193 | if( tSize > size ) | |
194 | { | |
195 | cout <<"HLT::AliHLTFourierComponent::DoEvent Too much data Data written over allowed buffer. Amount written:"<< tSize<<"allowed amount"<< size << endl; | |
196 | Logging( kHLTLogFatal, "HLT::AliHLTFourierComponent::DoEvent", "Too much data", | |
197 | "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu." , tSize, size ); | |
198 | ||
199 | return EMSGSIZE; | |
200 | } | |
201 | ||
202 | } | |
203 | ||
204 | return 0; | |
205 | ||
206 | } |