1 /**************************************************************************
2 * Copyright(c) 2006, ALICE Experiment at CERN, All rights reserved. *
4 * Author: Per Thomas Hille for the ALICE HLT Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 #include "AliHLTPHOSPulseGenerator.h"
23 ClassImp(AliHLTPHOSPulseGenerator)
25 //______________________________________________________________________________________________________
26 AliHLTPHOSPulseGenerator::AliHLTPHOSPulseGenerator(): fAmplitude(0), fNSamples(0),fTau(0), fSampleFreq(0), fTZero(0), fDataPtr(0), fDT(0)
28 cout << "You cannot invoke the Pulsgenerator without parameters" << endl;
32 //______________________________________________________________________________________________________
33 AliHLTPHOSPulseGenerator::AliHLTPHOSPulseGenerator(const AliHLTPHOSPulseGenerator &): fAmplitude(0), fNSamples(0),fTau(0), fSampleFreq(0), fTZero(0), fDataPtr(0), fDT(0)
39 //______________________________________________________________________________________________________
40 AliHLTPHOSPulseGenerator::~AliHLTPHOSPulseGenerator()
47 * Contruct a pulsegenrator object an initializes all necessary parameters
48 * @param a Amplitude in ADC levels (0 -1023)
49 * @param t0 Timedelay in nanoseconds of signal relative the first sample. This value should be between 0 and Ts
50 * @param N the number of samples
51 * @param tau Rise time of the semi Gaussian signal
52 * @param fs samling rate
54 AliHLTPHOSPulseGenerator::AliHLTPHOSPulseGenerator(double a, double t0, int N, double tau, double fs): fAmplitude(a), fNSamples(N),fTau(0), fSampleFreq(fs), fTZero(0), fDataPtr(0), fDT(0)
56 fDataPtr = new double[100];
63 // MakePulse(fDataPtr,a);
69 * Adds a baseline offset to the signal
70 * @param baselineLevel The basline level to add
71 * @param *samples The sample array for which to add te basline offset
74 AliHLTPHOSPulseGenerator::AddBaseline(double baselineLevel, double *samples)
78 printf("\nbaselineLevel = %f\n", baselineLevel);
79 cout << "AddBaseline not implemented yet" << endl;
83 * Adds Gaussian white noise to the sample array given by *dataPtr.
84 * @param dataPtr array of samples
85 * @param sigma the noise amplitude in entities of ADC levels
88 AliHLTPHOSPulseGenerator::AddNoise(double *dataPtr, double *sigma)
90 printf("\ndataPtr = %f, sigma = %f\n", *dataPtr, *sigma);
91 cout << "AddNoise is not implemented yet" << endl;
96 * Adds correlated Gaussian noise with cutof frequency "cutoff"
97 * @param dataPtr array of values
98 * @param sigma noise amplitude in entities of ADC levels
99 * @param cutoff -30DB cutoff frequency of the noise in entities of sampling frequency
102 AliHLTPHOSPulseGenerator::AddNoise(double *dataPtr, double *sigma, double cutoff)
104 printf("\ndataPtr = %f, sigma = %f, cutoff = %f\n", *dataPtr, *sigma, cutoff);
105 cout << "AddNoise is not implemeted yet" << endl;
111 * Adds pretrigger samples to the sample array and returns
112 * a new array containing the pretrigger samples concatenatet
113 * in front of the samples given by "samples"
114 * @param baselineLevel The baseline value of the pretrigger samples
115 * @param samples The sample array for which to add the pretrigger samples
118 AliHLTPHOSPulseGenerator::AddPretriggerSamples(double baselineLevel, double *samples)
120 printf("\nbaslinelevel = %f, samples = %f\n", baselineLevel, *samples);
121 cout << "AddPretriggerSamples not implemented yet" << endl;
127 * Returns a Pulse with new amplidude and t0
128 * @param a new amplidude, overriding the one given in the constructor
129 * @param t0 start time of the pulse relative to the sampling clock.
132 AliHLTPHOSPulseGenerator::GetPulse(double a, double t0)
138 * Emulates the ADC. Rounds down to nearest Integerevalue all entries given by
142 AliHLTPHOSPulseGenerator::Quantisize(double *dataPtr)
145 dtaPtr = new double[100];
147 // cout << "Quantisize is not implemented yet" << endl;
151 //______________________________________________________________________________________________________
153 AliHLTPHOSPulseGenerator::SetAmplitude(double a)
159 //______________________________________________________________________________________________________
161 AliHLTPHOSPulseGenerator::SetDT(double fs)
166 //______________________________________________________________________________________________________
168 AliHLTPHOSPulseGenerator::SetTZero(double t0)
170 fTZero = -t0/1000; // Since time is in nanoseconds and the samplingfrequency is in MHz -> divide by 1000
174 //______________________________________________________________________________________________________
176 AliHLTPHOSPulseGenerator::MakePulse(double *dtaPtr)
178 for(int i=0; i<fNSamples; i++)
180 dtaPtr[i]=fAmplitude*exp((Double_t)2)*pow((i*fDT-fTZero)/fTau, 2)*exp(-2*(i*fDT-fTZero)/fTau);