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 "AliHLTPHOSFourier.h"
22 //#include "AliHLTPHOSRcuFFTDataStruct.h"
24 AliHLTPHOSFourier::AliHLTPHOSFourier() : fFFT_own(0),
27 fIsFirstChannel(true),
37 AliHLTPHOSFourier::AliHLTPHOSFourier(const AliHLTPHOSFourier&) : fFFT_own(0),
40 fIsFirstChannel(true),
50 AliHLTPHOSFourier::~AliHLTPHOSFourier()
57 AliHLTPHOSRcuFFTDataStruct
58 AliHLTPHOSFourier::GetPSD()
60 return fFFTOupuStruct;
66 AliHLTPHOSFourier::ProcessFourier(const Int_t *data, const int length, const int /*z*/, const int /*x*/, const int gain, const int event)
71 if( (event > 0 ) && (event != fCurrentEvent ))
73 fCurrentEvent = event;
77 if(fIsFirstChannel == true)
79 fCurrentEvent = event;
80 fIsFirstChannel = false;
81 fFixedDataSize = length;
82 Int_t n_size = fFixedDataSize +1;
83 fFFT_own = TVirtualFFT::FFT(1, &n_size, "R2C ES K");
87 if( CheckSignal(data, length) == true)
89 Int2Double(data, fFFTInputArray, fFixedDataSize );
90 fFFT_own->SetPoints( fFFTInputArray );
91 fFFT_own->Transform();
93 for(int j=0; j < length; j++)
95 fFFT_own->GetPointComplex(j, re, im);
96 fFFTOupuStruct.fGlobalAccumulatedPSD[gain][j] += EvaluateMagnitude(re, im);
97 fFFTOupuStruct.fGlobalLastPSD[gain][j] += EvaluateMagnitude(re, im);
101 // printf("AliHLTPHOSFourier::ProcessFourier; (z, x, gain) = (%d, %d, %d), length = %d", z, x, gain, length);
105 AliHLTPHOSFourier::ResetEventPSD(const int gain)
107 cout << " AliHLTPHOSFourier::ResetEventPS, resetting event PSD "<< endl;
108 for(int i = 0; i < fFixedDataSize; i++ )
110 fFFTOupuStruct.fGlobalLastPSD[gain][i] = 0;
116 //AliHLTPHOSFourier::CheckSignal(const UInt_t *data, const int length)
117 AliHLTPHOSFourier::CheckSignal(const Int_t *data, const int length)
119 // UInt_t tmpMax = Max( const_cast< UInt_t *>(data), length);
120 // UInt_t tmpMin = Min( const_cast< UInt_t *>(data), length);
123 Int_t tmpMax = Max( const_cast< Int_t *>(data), length);
124 Int_t tmpMin = Min( const_cast< Int_t *>(data), length);
127 // if( (tmpMax -tmpMin) > 200)
128 if( (tmpMax -tmpMin) > 100)
130 cout << "FourierAna::CheckSignal min = "<< tmpMin << " max = " << tmpMax << endl;
133 if( (tmpMax >= MAXBINVALUE) || tmpMin < 1 )
135 cout << "ERROR, FourierAna::CheckSignal failed, signal out of range, min= "<< tmpMin << "max = " << tmpMax << endl;
148 AliHLTPHOSFourier::Init()
150 fFFTInputArray = new double[fFixedDataSize];
151 fFFTOutputArray = new double[fFixedDataSize];
153 for(int gain = 0; gain < NGAINS; gain ++)
155 fFFTOupuStruct.fDataLength = fFixedDataSize;
157 for(int k= 0; k <fFixedDataSize; k++ )
159 fFFTInputArray[k] = 0;
160 fFFTOutputArray[k] = 0;
163 for(int i=0; i < ALTROMAXSAMPLES ; i++)
165 fFFTOupuStruct.fGlobalAccumulatedPSD[gain][i] = 0;
166 fFFTOupuStruct.fGlobalLastPSD[gain][i] = 0;
173 AliHLTPHOSFourier::EvaluateMagnitude(const double re, const double im)
175 return re*re + im*im;
180 AliHLTPHOSFourier::Int2Double(const Int_t *inputarray, double *outputarray, const int size)
182 for(int i=0; i< size; i++)
184 outputarray[i] = (double)inputarray[i];