]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSFourierComponent.cxx
Eff C++ warning removal (Marian)
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSFourierComponent.cxx
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   list.clear();
69   list.push_back(AliHLTPHOSDefinitions::fgkCellEnergyDataType);
70
71   /*
72   const AliHLTComponentDataType* pType=fgkInputDataTypes;
73
74   while (pType->fID!=0) 
75     {
76       list.push_back(*pType);
77       pType++;
78     }
79   */
80 }
81
82
83 AliHLTComponentDataType 
84 AliHLTPHOSFourierComponent::GetOutputDataType()
85 {
86   return AliHLTPHOSDefinitions::fgkFourierTransform;
87   // return AliHLTPHOSDefinitions::fgkCellEnergyDataType;
88   // return kAliHLTMultipleDataType;
89 }
90
91
92 /*
93 int 
94 AliHLTPHOSFourierComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList)
95 {
96   tgtList.clear();
97   tgtList.push_back(AliHLTPHOSDefinitions::fgkFourierTransform);
98   //  tgtList.push_back(kAliHLTDataTypeHwAddr16);
99   return tgtList.size();
100 }
101 */
102
103
104
105 void 
106 AliHLTPHOSFourierComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
107 {
108  //  constBase =1;
109 //   inputMultiplier = 1;
110   // constBase = 30;
111   // inputMultiplier = 1.2;
112   inputMultiplier = 0.1;
113 }
114  
115 int 
116 AliHLTPHOSFourierComponent::DoInit(int /*argc*/, const char** /*argv*/)
117 {
118   cout << "AliHLTPHOSFourierComponent::DoInit !!!!!!!!!! " << endl;
119   return 0;
120 }
121
122 /*
123 int 
124 AliHLTPHOSFourierComponent::DoDeinit()
125 {
126
127 }
128 */
129
130 int 
131 AliHLTPHOSFourierComponent::DoEvent(const AliHLTComponentEventData& evtData,
132                                     const AliHLTComponentBlockData* blocks, 
133                                     AliHLTComponentTriggerData& /*trigData*/,
134                                     AliHLTUInt8_t* outputPtr, 
135                                     AliHLTUInt32_t& size,
136                                     AliHLTComponentBlockDataList& outputBlocks )
137 {
138   fPhosEventCount ++;
139   AliHLTPHOSValidCellDataStruct *currentChannel =0;
140   UInt_t offset            = 0; 
141   UInt_t mysize            = 0;
142   UInt_t tSize             = 0;
143   const AliHLTComponentBlockData* iter = NULL; 
144   unsigned long ndx;
145   UInt_t specification = 0;
146  
147   for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
148     {
149       iter = blocks+ndx;
150   
151       if(iter->fDataType != AliHLTPHOSDefinitions::fgkCellEnergyDataType)
152         {
153           
154           continue;
155         }
156       
157       specification = specification|iter->fSpecification;        
158       AliHLTPHOSRcuCellEnergyDataStruct *cellDataPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)( iter->fPtr);
159       AliHLTPHOSRcuFFTDataStruct *fourierOutPtr =  (AliHLTPHOSRcuFFTDataStruct*)outputPtr;
160       fShmPtr->SetMemory(cellDataPtr);
161       currentChannel = fShmPtr->NextChannel();
162       
163       while(currentChannel != 0)
164         {
165           Int_t *data;
166           Int_t nsamples = 0;
167           data= fShmPtr->GetRawData(nsamples);
168           fFourierPtr->ProcessFourier(data, nsamples, currentChannel->fZ, currentChannel->fX, currentChannel->fGain  ); 
169           currentChannel = fShmPtr->NextChannel();
170         }
171           
172       *fourierOutPtr =  fFourierPtr->GetPSD();
173   
174       for(int i=0; i < 500; i++)
175         {
176           if(i%16 == 0)
177             {
178               printf("\n");
179             }
180
181           cout << fourierOutPtr->fGlobalAccumulatedPSD[1][i] <<  "\t";
182         }
183       
184       mysize += sizeof(AliHLTPHOSRcuFFTDataStruct);
185       AliHLTComponentBlockData bd;
186       bd.fOffset = offset;
187       bd.fSize = mysize;
188       bd.fDataType = AliHLTPHOSDefinitions::fgkFourierTransform;
189       // bd.fSpecification = 0xFFFFFFFF;
190       //     bd.fSpecification = specification;
191       bd.fSpecification = 1;
192       outputBlocks.push_back( bd );
193       
194
195
196
197       cout <<"size left is "<<  size  <<"  FourierComponenet: offset ="<< offset << "mysize =" << mysize << "specification =" << specification <<endl;
198       tSize += mysize;
199    
200       outputPtr += mysize;
201
202       if( tSize > size )
203         {
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 );
207
208           return EMSGSIZE;
209         }
210     
211     }
212
213   return 0;
214
215 }