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 **************************************************************************/
17 #include "AliHLTPHOSPulseGenerator.h"
28 ClassImp(AliHLTPHOSPulseGenerator)
31 * Default constructor, not to be called without argumets
33 AliHLTPHOSPulseGenerator::AliHLTPHOSPulseGenerator(): fAmplitude(0), fNSamples(0),fTau(0), fSampleFreq(0), fTZero(0), fDataPtr(0), fDT(0), fEvent(0)
35 cout << "You cannot invoke the Pulsgenerator without parameters" << endl;
38 AliHLTPHOSPulseGenerator::AliHLTPHOSPulseGenerator(const AliHLTPHOSPulseGenerator &): fAmplitude(0), fNSamples(0),fTau(0), fSampleFreq(0), fTZero(0), fDataPtr(0), fDT(0), fEvent(0)
44 AliHLTPHOSPulseGenerator::~AliHLTPHOSPulseGenerator()
51 * Contruct a pulsegenrator object an initializes all necessary parameters
52 * @param a Amplitude in ADC levels (0 -1023)
53 * @param t0 Timedelay in nanoseconds of signal relative the first sample. This value should be between 0 and Ts
54 * where Ts is the sample interval
56 AliHLTPHOSPulseGenerator::AliHLTPHOSPulseGenerator(double a, double t0, int N, double t, double fs): fAmplitude(a), fNSamples(N),fTau(0), fSampleFreq(fs), fTZero(0), fDataPtr(0), fDT(0), fEvent(0)
59 fDataPtr = new double[100];
69 // dT=tau/fs; //Function values are calculated at intervals dT
70 // fDT=1/fs; //Function values are calculated at intervals dT
75 * Adds a baseline offset to the signal
76 * @param baselineLevel The basline level to add
77 * @param *samples The sample array for which to add te basline offset
80 AliHLTPHOSPulseGenerator::AddBaseline(double baselineLevel, double *samples)
84 printf("\nbaselineLevel = %f\n", baselineLevel);
85 cout << "AddBaseline not implemented yet" << endl;
89 * Adds Gaussian white noise to the sample array given by *dataPtr.
90 * @param dataPtr array of samples
91 * @param sigma the noise amplitude in entities of ADC levels
94 AliHLTPHOSPulseGenerator::AddNoise(double *dataPtr, double *sigma)
96 printf("\ndataPtr = %f, sigma = %f\n", *dataPtr, *sigma);
97 cout << "AddNoise is not implemented yet" << endl;
102 * Adds correlated Gaussian noise with cutof frequency "cutoff"
103 * @param dataPtr array of values
104 * @param sigma noise amplitude in entities of ADC levels
105 * @param -30DB cutoff frequency of the noise in entities of sampling frequency
108 AliHLTPHOSPulseGenerator::AddNoise(double *dataPtr, double *sigma, double cutoff)
110 printf("\ndataPtr = %f, sigma = %f, cutoff = %f\n", *dataPtr, *sigma, cutoff);
111 cout << "AddNoise is not implemeted yet" << endl;
115 * Adds pretrigger samples to the sample array and returns
116 * a new array containing the pretrigger samples concatenatet
117 * in front of the samples given by "samples"
118 * @param The baseline value of the pretrigger samples
119 * @param The sample array for which to add the pretrigger samples
122 AliHLTPHOSPulseGenerator::AddPretriggerSamples(double baselineLevel, double *samples)
124 printf("\nbaslinelevel = %f, samples = %f\n", baselineLevel, *samples);
125 cout << "AddPretriggerSamples not implemented yet" << endl;
131 * Returns the generated pulse with the parameters given in the constructor
134 AliHLTPHOSPulseGenerator::GetPulse()
141 * Returns a Pulse with new amplidude and t0
142 * @param a new amplidude, overriding the one given in the constructor
145 AliHLTPHOSPulseGenerator::GetPulse(double a, double t0)
151 * Emulates the ADC. Rounds down to nearest Integerevalue all entries given by
155 AliHLTPHOSPulseGenerator::Quantisize(double *dataPtr)
158 dtaPtr = new double[100];
160 // cout << "Quantisize is not implemented yet" << endl;
164 AliHLTPHOSPulseGenerator::SetAmplitude(double a)
170 AliHLTPHOSPulseGenerator::SetDT(double fs)
176 AliHLTPHOSPulseGenerator::SetTZero(double t0)
178 fTZero = -t0/1000; // Since time is in nanoseconds and the samplingfrequency is in MHz -> divide by 1000
183 AliHLTPHOSPulseGenerator::MakePulse(double *dtaPtr)
185 for(int i=0; i<fNSamples; i++)
187 dtaPtr[i]=fAmplitude*exp((Double_t)2)*pow((i*fDT-fTZero)/fTau, 2)*exp(-2*(i*fDT-fTZero)/fTau);