]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/PHOS/AliHLTPHOSPulseGenerator.cxx
Coding conventions & doccumentation
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSPulseGenerator.cxx
CommitLineData
228cb536 1/**************************************************************************
cd906859 2 * Copyright(c) 2006, ALICE Experiment at CERN, All rights reserved. *
228cb536 3 * *
cd906859 4 * Author: Per Thomas Hille for the ALICE HLT Project. *
228cb536 5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
cd906859 16#include "AliHLTPHOSPulseGenerator.h"
228cb536 17#include <cmath>
18#include <iostream>
19
228cb536 20using std::cout;
21using std::endl;
22
cd906859 23ClassImp(AliHLTPHOSPulseGenerator)
24
d504c864 25//______________________________________________________________________________________________________
26AliHLTPHOSPulseGenerator::AliHLTPHOSPulseGenerator(): fAmplitude(0), fNSamples(0),fTau(0), fSampleFreq(0), fTZero(0), fDataPtr(0), fDT(0)
228cb536 27{
28 cout << "You cannot invoke the Pulsgenerator without parameters" << endl;
29}
30
d504c864 31
32//______________________________________________________________________________________________________
33AliHLTPHOSPulseGenerator::AliHLTPHOSPulseGenerator(const AliHLTPHOSPulseGenerator &): fAmplitude(0), fNSamples(0),fTau(0), fSampleFreq(0), fTZero(0), fDataPtr(0), fDT(0)
cd906859 34{
35
36}
37
38
d504c864 39//______________________________________________________________________________________________________
cd906859 40AliHLTPHOSPulseGenerator::~AliHLTPHOSPulseGenerator()
228cb536 41{
42 delete fDataPtr;
43 fDataPtr=0;
44}
45
cd906859 46/**
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
d504c864 50 * @param N the number of samples
51 * @param tau Rise time of the semi Gaussian signal
52 * @param fs samling rate
cd906859 53 **/
d504c864 54AliHLTPHOSPulseGenerator::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)
228cb536 55{
cd906859 56 fDataPtr = new double[100];
228cb536 57 SetAmplitude(a);
58 SetDT(fs);
59 SetTZero(t0);
60 fNSamples=N;
d504c864 61 fTau=tau;
228cb536 62 fSampleFreq=fs;
d504c864 63 // MakePulse(fDataPtr,a);
228cb536 64 MakePulse(fDataPtr);
65}
66
d504c864 67
cd906859 68/**
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
72 **/
228cb536 73void
cd906859 74AliHLTPHOSPulseGenerator::AddBaseline(double baselineLevel, double *samples)
228cb536 75{
cd906859 76 double *tmpSamples;
77 tmpSamples = samples;
78 printf("\nbaselineLevel = %f\n", baselineLevel);
228cb536 79 cout << "AddBaseline not implemented yet" << endl;
80}
81
cd906859 82/**
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
86 **/
228cb536 87void
cd906859 88AliHLTPHOSPulseGenerator::AddNoise(double *dataPtr, double *sigma)
228cb536 89{
cd906859 90 printf("\ndataPtr = %f, sigma = %f\n", *dataPtr, *sigma);
228cb536 91 cout << "AddNoise is not implemented yet" << endl;
92}
93
cd906859 94
95/**
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
d504c864 99 * @param cutoff -30DB cutoff frequency of the noise in entities of sampling frequency
cd906859 100 **/
228cb536 101void
cd906859 102AliHLTPHOSPulseGenerator::AddNoise(double *dataPtr, double *sigma, double cutoff)
228cb536 103{
cd906859 104 printf("\ndataPtr = %f, sigma = %f, cutoff = %f\n", *dataPtr, *sigma, cutoff);
228cb536 105 cout << "AddNoise is not implemeted yet" << endl;
106}
107
d504c864 108
109
cd906859 110/**
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"
d504c864 114 * @param baselineLevel The baseline value of the pretrigger samples
115 * @param samples The sample array for which to add the pretrigger samples
cd906859 116 **/
228cb536 117double *
cd906859 118AliHLTPHOSPulseGenerator::AddPretriggerSamples(double baselineLevel, double *samples)
228cb536 119{
cd906859 120 printf("\nbaslinelevel = %f, samples = %f\n", baselineLevel, *samples);
228cb536 121 cout << "AddPretriggerSamples not implemented yet" << endl;
cd906859 122 return 0;
228cb536 123}
124
125
cd906859 126/**
127 * Returns a Pulse with new amplidude and t0
128 * @param a new amplidude, overriding the one given in the constructor
d504c864 129 * @param t0 start time of the pulse relative to the sampling clock.
cd906859 130 **/
228cb536 131double *
cd906859 132AliHLTPHOSPulseGenerator::GetPulse(double a, double t0)
228cb536 133{
134 return fDataPtr;
135}
136
cd906859 137/**
138 * Emulates the ADC. Rounds down to nearest Integerevalue all entries given by
139 * dataPtr
140 **/
228cb536 141void
cd906859 142AliHLTPHOSPulseGenerator::Quantisize(double *dataPtr)
228cb536 143{
cd906859 144 double *dtaPtr;
145 dtaPtr = new double[100];
146 dtaPtr = dataPtr;
228cb536 147 // cout << "Quantisize is not implemented yet" << endl;
148}
149
d504c864 150
151//______________________________________________________________________________________________________
228cb536 152void
cd906859 153AliHLTPHOSPulseGenerator::SetAmplitude(double a)
228cb536 154{
155 fAmplitude=a;
156}
157
d504c864 158
159//______________________________________________________________________________________________________
228cb536 160void
cd906859 161AliHLTPHOSPulseGenerator::SetDT(double fs)
228cb536 162{
163 fDT=1/fs;
164}
165
d504c864 166//______________________________________________________________________________________________________
228cb536 167void
cd906859 168AliHLTPHOSPulseGenerator::SetTZero(double t0)
228cb536 169{
170 fTZero = -t0/1000; // Since time is in nanoseconds and the samplingfrequency is in MHz -> divide by 1000
171}
172
cd906859 173
d504c864 174//______________________________________________________________________________________________________
228cb536 175void
cd906859 176AliHLTPHOSPulseGenerator::MakePulse(double *dtaPtr)
228cb536 177{
178for(int i=0; i<fNSamples; i++)
179 {
a63d31b2 180 dtaPtr[i]=fAmplitude*exp((Double_t)2)*pow((i*fDT-fTZero)/fTau, 2)*exp(-2*(i*fDT-fTZero)/fTau);
228cb536 181 }
182}