Line data Source code
1 : // $Id: AliHLTPHOSFourier.cxx 34951 2009-09-23 14:35:38Z phille $
2 :
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 *
7 : * *
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 *
11 : * *
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 "AliHLTCaloFourier.h"
21 :
22 : //#include "AliHLTCaloRcuFFTDataStruct.h"
23 :
24 : #include "AliHLTCaloConstants.h"
25 :
26 6 : ClassImp(AliHLTCaloFourier);
27 :
28 :
29 :
30 0 : AliHLTCaloFourier::AliHLTCaloFourier() : fFFT_own(0),
31 0 : fFFTInputArray(0),
32 0 : fFFTOutputArray(0),
33 0 : fIsFirstChannel(true),
34 0 : fFixedDataSize(0),
35 0 : fFFTOupuStruct(),
36 0 : fCurrentEvent(0)
37 0 : {
38 :
39 :
40 0 : }
41 :
42 :
43 :
44 :
45 0 : AliHLTCaloFourier::AliHLTCaloFourier(const AliHLTCaloFourier&) : fFFT_own(0),
46 0 : fFFTInputArray(0),
47 0 : fFFTOutputArray(0),
48 0 : fIsFirstChannel(true),
49 0 : fFixedDataSize(0),
50 0 : fFFTOupuStruct(),
51 0 : fCurrentEvent(0)
52 :
53 0 : {
54 :
55 0 : }
56 :
57 :
58 :
59 : AliHLTCaloFourier::~AliHLTCaloFourier()
60 0 : {
61 :
62 0 : }
63 :
64 :
65 :
66 : AliHLTCaloRcuFFTDataStruct
67 : AliHLTCaloFourier::GetPSD()
68 : {
69 0 : return fFFTOupuStruct;
70 : }
71 :
72 :
73 :
74 : void
75 : AliHLTCaloFourier::ProcessFourier(const Int_t *data, const int length, const int /*z*/, const int /*x*/, const int gain, const int event)
76 : {
77 0 : Double_t re = 0;
78 0 : Double_t im = 0;
79 :
80 0 : if( (event > 0 ) && (event != fCurrentEvent ))
81 : {
82 0 : fCurrentEvent = event;
83 0 : ResetEventPSD(gain);
84 0 : }
85 :
86 0 : if(fIsFirstChannel == true)
87 : {
88 0 : fCurrentEvent = event;
89 0 : fIsFirstChannel = false;
90 0 : fFixedDataSize = length;
91 0 : Int_t n_size = fFixedDataSize +1;
92 0 : fFFT_own = TVirtualFFT::FFT(1, &n_size, "R2C ES K");
93 0 : Init();
94 0 : }
95 :
96 0 : if( CheckSignal(data, length) == true)
97 : {
98 0 : Int2Double(data, fFFTInputArray, fFixedDataSize );
99 0 : fFFT_own->SetPoints( fFFTInputArray );
100 0 : fFFT_own->Transform();
101 :
102 0 : for(int j=0; j < length; j++)
103 : {
104 0 : fFFT_own->GetPointComplex(j, re, im);
105 0 : fFFTOupuStruct.fGlobalAccumulatedPSD[gain][j] += EvaluateMagnitude(re, im);
106 0 : fFFTOupuStruct.fGlobalLastPSD[gain][j] += EvaluateMagnitude(re, im);
107 :
108 : }
109 0 : }
110 : // printf("AliHLTCaloFourier::ProcessFourier; (z, x, gain) = (%d, %d, %d), length = %d", z, x, gain, length);
111 0 : }
112 :
113 : void
114 : AliHLTCaloFourier::ResetEventPSD(const int gain)
115 : {
116 0 : cout << " AliHLTCaloFourier::ResetEventPS, resetting event PSD "<< endl;
117 0 : for(int i = 0; i < fFixedDataSize; i++ )
118 : {
119 0 : fFFTOupuStruct.fGlobalLastPSD[gain][i] = 0;
120 : }
121 0 : }
122 :
123 :
124 : bool
125 : //AliHLTCaloFourier::CheckSignal(const UInt_t *data, const int length)
126 : AliHLTCaloFourier::CheckSignal(const Int_t *data, const int length)
127 : {
128 : // UInt_t tmpMax = Max( const_cast< UInt_t *>(data), length);
129 : // UInt_t tmpMin = Min( const_cast< UInt_t *>(data), length);
130 :
131 :
132 0 : Int_t tmpMax = Max( const_cast< Int_t *>(data), length);
133 0 : Int_t tmpMin = Min( const_cast< Int_t *>(data), length);
134 :
135 :
136 : // if( (tmpMax -tmpMin) > 200)
137 0 : if( (tmpMax -tmpMin) > 100)
138 : {
139 0 : cout << "FourierAna::CheckSignal min = "<< tmpMin << " max = " << tmpMax << endl;
140 0 : }
141 :
142 0 : if( (tmpMax >= AliHLTCaloConstants::GetMAXBINVALUE() ) || tmpMin < 1 )
143 : {
144 0 : cout << "ERROR, FourierAna::CheckSignal failed, signal out of range, min= "<< tmpMin << "max = " << tmpMax << endl;
145 0 : return false;
146 : }
147 : else
148 : {
149 0 : return true;
150 : }
151 :
152 : //return true;
153 0 : }
154 :
155 :
156 : void
157 : AliHLTCaloFourier::Init()
158 : {
159 0 : fFFTInputArray = new double[fFixedDataSize];
160 0 : fFFTOutputArray = new double[fFixedDataSize];
161 :
162 0 : for(int gain = 0; gain < AliHLTCaloConstants::GetNGAINS(); gain ++)
163 : {
164 0 : fFFTOupuStruct.fDataLength = fFixedDataSize;
165 :
166 0 : for(int k= 0; k <fFixedDataSize; k++ )
167 : {
168 0 : fFFTInputArray[k] = 0;
169 0 : fFFTOutputArray[k] = 0;
170 :
171 : }
172 0 : for(int i=0; i < AliHLTCaloConstants::GetALTROMAXSAMPLES() ; i++)
173 : {
174 0 : fFFTOupuStruct.fGlobalAccumulatedPSD[gain][i] = 0;
175 0 : fFFTOupuStruct.fGlobalLastPSD[gain][i] = 0;
176 : }
177 : }
178 0 : }
179 :
180 :
181 : double
182 : AliHLTCaloFourier::EvaluateMagnitude(const double re, const double im)
183 : {
184 0 : return re*re + im*im;
185 : }
186 :
187 :
188 : void
189 : AliHLTCaloFourier::Int2Double(const Int_t *inputarray, double *outputarray, const int size)
190 : {
191 0 : for(int i=0; i< size; i++)
192 : {
193 0 : outputarray[i] = (double)inputarray[i];
194 : }
195 0 : }
|