]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSPulseGenerator.cxx
HLT component to write data to files. The directory where to write the files
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSPulseGenerator.cxx
1 /**************************************************************************
2  * Copyright(c) 2006, ALICE Experiment at CERN, All rights reserved.      *
3  *                                                                        *
4  * Author: Per Thomas Hille for the ALICE HLT Project.                    *
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
16
17 #include "AliHLTPHOSPulseGenerator.h"
18 //#include <stdio.h>
19 #include <cmath>
20 #include <iostream>
21
22
23
24 using std::cout;
25 using std::endl; 
26
27
28 ClassImp(AliHLTPHOSPulseGenerator) 
29
30 /**
31  * Default constructor, not to be called without argumets
32  **/
33 AliHLTPHOSPulseGenerator::AliHLTPHOSPulseGenerator(): fAmplitude(0), fNSamples(0),fTau(0), fSampleFreq(0), fTZero(0), fDataPtr(0), fDT(0), fEvent(0)
34 {
35   cout << "You cannot invoke the Pulsgenerator without parameters" << endl;
36 }
37
38 AliHLTPHOSPulseGenerator::AliHLTPHOSPulseGenerator(const AliHLTPHOSPulseGenerator &): fAmplitude(0), fNSamples(0),fTau(0), fSampleFreq(0), fTZero(0), fDataPtr(0), fDT(0), fEvent(0)
39 {
40   
41 }
42
43
44 AliHLTPHOSPulseGenerator::~AliHLTPHOSPulseGenerator()
45 {
46   delete fDataPtr;
47   fDataPtr=0;
48 }
49
50 /**
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
55  **/
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)
57 {
58
59   fDataPtr = new double[100];
60
61
62
63   SetAmplitude(a);
64   SetDT(fs);
65   SetTZero(t0);
66   fNSamples=N;
67   fTau=t;
68   fSampleFreq=fs;
69   //  dT=tau/fs;   //Function values are calculated at intervals dT
70   //  fDT=1/fs;   //Function values are calculated at intervals dT
71   MakePulse(fDataPtr);
72 }
73
74 /**
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
78  **/
79 void 
80 AliHLTPHOSPulseGenerator::AddBaseline(double baselineLevel, double *samples)
81 {
82   double *tmpSamples;
83   tmpSamples = samples;
84   printf("\nbaselineLevel = %f\n", baselineLevel);
85   cout << "AddBaseline not implemented yet" << endl;
86 }
87
88 /**
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  
92  **/
93 void 
94 AliHLTPHOSPulseGenerator::AddNoise(double *dataPtr, double *sigma)
95 {
96   printf("\ndataPtr = %f, sigma = %f\n", *dataPtr, *sigma);
97   cout << "AddNoise is not implemented yet" << endl;
98 }
99
100
101 /**
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
106  **/
107 void 
108 AliHLTPHOSPulseGenerator::AddNoise(double *dataPtr, double *sigma, double cutoff)
109 {
110   printf("\ndataPtr = %f, sigma = %f, cutoff = %f\n", *dataPtr, *sigma, cutoff);
111   cout << "AddNoise is not implemeted yet" << endl;
112 }
113
114 /**
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
120  **/
121 double *
122 AliHLTPHOSPulseGenerator::AddPretriggerSamples(double baselineLevel, double *samples)
123 {
124   printf("\nbaslinelevel = %f, samples = %f\n", baselineLevel, *samples);
125   cout << "AddPretriggerSamples not implemented yet" << endl;
126   return 0;
127 }
128
129
130 /**
131  * Returns the generated pulse with the parameters given in the constructor
132  **/
133 double *
134 AliHLTPHOSPulseGenerator::GetPulse()
135 {
136   return fDataPtr;
137 }
138
139
140 /**
141  * Returns a Pulse with new amplidude and t0
142  * @param a new amplidude, overriding the one given in the constructor
143  **/
144 double *
145 AliHLTPHOSPulseGenerator::GetPulse(double a, double t0)
146 {
147   return fDataPtr;
148 }
149
150 /**
151  * Emulates the ADC. Rounds down to nearest Integerevalue all entries given by
152  * dataPtr
153  **/
154 void 
155 AliHLTPHOSPulseGenerator::Quantisize(double *dataPtr)
156 {
157   double *dtaPtr;
158   dtaPtr = new double[100];
159   dtaPtr = dataPtr;
160   //  cout << "Quantisize is not implemented yet" << endl;
161 }
162
163 void
164 AliHLTPHOSPulseGenerator::SetAmplitude(double a)
165 {
166   fAmplitude=a;
167 }
168
169 void 
170 AliHLTPHOSPulseGenerator::SetDT(double fs)
171 {
172   fDT=1/fs;  
173 }
174
175 void
176 AliHLTPHOSPulseGenerator::SetTZero(double t0)
177 {
178   fTZero = -t0/1000; // Since time is in nanoseconds and the samplingfrequency is in MHz -> divide by 1000
179 }
180
181
182 void
183 AliHLTPHOSPulseGenerator::MakePulse(double *dtaPtr)
184 {
185 for(int i=0; i<fNSamples; i++)
186   {
187     dtaPtr[i]=fAmplitude*exp((Double_t)2)*pow((i*fDT-fTZero)/fTau, 2)*exp(-2*(i*fDT-fTZero)/fTau);
188   }  
189 }