1 // $Id: AliHLTPHOSFourier.cxx 34951 2009-09-23 14:35:38Z phille $
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 "AliHLTCaloFourier.h"
22 //#include "AliHLTCaloRcuFFTDataStruct.h"
24 #include "AliHLTCaloConstants.h"
26 ClassImp(AliHLTCaloFourier);
30 AliHLTCaloFourier::AliHLTCaloFourier() : fFFT_own(0),
33 fIsFirstChannel(true),
45 AliHLTCaloFourier::AliHLTCaloFourier(const AliHLTCaloFourier&) : fFFT_own(0),
48 fIsFirstChannel(true),
59 AliHLTCaloFourier::~AliHLTCaloFourier()
66 AliHLTCaloRcuFFTDataStruct
67 AliHLTCaloFourier::GetPSD()
69 return fFFTOupuStruct;
75 AliHLTCaloFourier::ProcessFourier(const Int_t *data, const int length, const int /*z*/, const int /*x*/, const int gain, const int event)
80 if( (event > 0 ) && (event != fCurrentEvent ))
82 fCurrentEvent = event;
86 if(fIsFirstChannel == true)
88 fCurrentEvent = event;
89 fIsFirstChannel = false;
90 fFixedDataSize = length;
91 Int_t n_size = fFixedDataSize +1;
92 fFFT_own = TVirtualFFT::FFT(1, &n_size, "R2C ES K");
96 if( CheckSignal(data, length) == true)
98 Int2Double(data, fFFTInputArray, fFixedDataSize );
99 fFFT_own->SetPoints( fFFTInputArray );
100 fFFT_own->Transform();
102 for(int j=0; j < length; j++)
104 fFFT_own->GetPointComplex(j, re, im);
105 fFFTOupuStruct.fGlobalAccumulatedPSD[gain][j] += EvaluateMagnitude(re, im);
106 fFFTOupuStruct.fGlobalLastPSD[gain][j] += EvaluateMagnitude(re, im);
110 // printf("AliHLTCaloFourier::ProcessFourier; (z, x, gain) = (%d, %d, %d), length = %d", z, x, gain, length);
114 AliHLTCaloFourier::ResetEventPSD(const int gain)
116 cout << " AliHLTCaloFourier::ResetEventPS, resetting event PSD "<< endl;
117 for(int i = 0; i < fFixedDataSize; i++ )
119 fFFTOupuStruct.fGlobalLastPSD[gain][i] = 0;
125 //AliHLTCaloFourier::CheckSignal(const UInt_t *data, const int length)
126 AliHLTCaloFourier::CheckSignal(const Int_t *data, const int length)
128 // UInt_t tmpMax = Max( const_cast< UInt_t *>(data), length);
129 // UInt_t tmpMin = Min( const_cast< UInt_t *>(data), length);
132 Int_t tmpMax = Max( const_cast< Int_t *>(data), length);
133 Int_t tmpMin = Min( const_cast< Int_t *>(data), length);
136 // if( (tmpMax -tmpMin) > 200)
137 if( (tmpMax -tmpMin) > 100)
139 cout << "FourierAna::CheckSignal min = "<< tmpMin << " max = " << tmpMax << endl;
142 if( (tmpMax >= AliHLTCaloConstants::GetMAXBINVALUE() ) || tmpMin < 1 )
144 cout << "ERROR, FourierAna::CheckSignal failed, signal out of range, min= "<< tmpMin << "max = " << tmpMax << endl;
157 AliHLTCaloFourier::Init()
159 fFFTInputArray = new double[fFixedDataSize];
160 fFFTOutputArray = new double[fFixedDataSize];
162 for(int gain = 0; gain < AliHLTCaloConstants::GetNGAINS(); gain ++)
164 fFFTOupuStruct.fDataLength = fFixedDataSize;
166 for(int k= 0; k <fFixedDataSize; k++ )
168 fFFTInputArray[k] = 0;
169 fFFTOutputArray[k] = 0;
172 for(int i=0; i < AliHLTCaloConstants::GetALTROMAXSAMPLES() ; i++)
174 fFFTOupuStruct.fGlobalAccumulatedPSD[gain][i] = 0;
175 fFFTOupuStruct.fGlobalLastPSD[gain][i] = 0;
182 AliHLTCaloFourier::EvaluateMagnitude(const double re, const double im)
184 return re*re + im*im;
189 AliHLTCaloFourier::Int2Double(const Int_t *inputarray, double *outputarray, const int size)
191 for(int i=0; i< size; i++)
193 outputarray[i] = (double)inputarray[i];