]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSPulseGenerator.cxx
New production macros (Yves)
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSPulseGenerator.cxx
1 // $Id$
2
3 /**************************************************************************
4  * Copyright(c) 2006, ALICE Experiment at CERN, All rights reserved.      *
5  *                                                                        *
6  * Author: Per Thomas Hille for the ALICE HLT Project.                    *
7  * Contributors are mentioned in the code where appropriate.              *
8  *                                                                        *
9  * Permission to use, copy, modify and distribute this software and its   *
10  * documentation strictly for non-commercial purposes is hereby granted   *
11  * without fee, provided that the above copyright notice appears in all   *
12  * copies and that both the copyright notice and this permission notice   *
13  * appear in the supporting documentation. The authors make no claims     *
14  * about the suitability of this software for any purpose. It is          *
15  * provided "as is" without express or implied warranty.                  *
16  **************************************************************************/
17
18 #include "AliHLTPHOSPulseGenerator.h"
19 #include <cmath>
20 #include <iostream>
21
22 using std::cout;
23 using std::endl; 
24
25 ClassImp(AliHLTPHOSPulseGenerator) 
26
27
28
29 AliHLTPHOSPulseGenerator::AliHLTPHOSPulseGenerator(): fAmplitude(0), fNSamples(0),fTau(0), fSampleFreq(0), fTZero(0), fDataPtr(0), fDT(0)
30 {
31   //Never to be called   
32   cout << "You cannot invoke the Pulsgenerator without parameters" << endl;
33 }
34
35
36 AliHLTPHOSPulseGenerator::AliHLTPHOSPulseGenerator(const AliHLTPHOSPulseGenerator &): fAmplitude(0), fNSamples(0),fTau(0), fSampleFreq(0), fTZero(0), fDataPtr(0), fDT(0)
37 {
38   
39 }
40
41
42 AliHLTPHOSPulseGenerator::~AliHLTPHOSPulseGenerator()
43 {
44   //Destructor  
45   delete fDataPtr;
46   fDataPtr=0;
47 }
48
49
50 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)
51 {
52   //See header file for documentation  
53   fDataPtr = new double[100];
54   SetAmplitude(a);
55   SetDT(fs);
56   SetTZero(t0);
57   fNSamples=N;
58   fTau=tau;
59   fSampleFreq=fs;
60 }
61
62
63 void 
64 AliHLTPHOSPulseGenerator::AddBaseline(double baselineLevel, double *samples)
65 {
66   //See header file for documentation
67   double *tmpSamples;
68   tmpSamples = samples;
69   printf("\nbaselineLevel = %f\n", baselineLevel);
70   cout << "AddBaseline not implemented yet" << endl;
71 }
72
73
74 void 
75 AliHLTPHOSPulseGenerator::AddNoise(double *dataPtr, double *sigma)
76 {
77   //See header file for documentation 
78   printf("\ndataPtr = %f, sigma = %f\n", *dataPtr, *sigma);
79   cout << "AddNoise is not implemented yet" << endl;
80 }
81
82
83 void 
84 AliHLTPHOSPulseGenerator::AddNoise(double *dataPtr, double *sigma, double cutoff)
85 {
86   //See header file for documentation 
87   printf("\ndataPtr = %f, sigma = %f, cutoff = %f\n", *dataPtr, *sigma, cutoff);
88   cout << "AddNoise is not implemeted yet" << endl;
89 }
90
91
92 double *
93 AliHLTPHOSPulseGenerator::AddPretriggerSamples(double baselineLevel, double *samples)
94 {
95     //See header file for documentation
96   printf("\nbaslinelevel = %f, samples = %f\n", baselineLevel, *samples);
97   cout << "AddPretriggerSamples not implemented yet" << endl;
98   return 0;
99 }
100
101
102 double *
103 AliHLTPHOSPulseGenerator::GetPulse(double /*a*/, double /*t0*/)
104 {
105   //See header file for documentation
106   return fDataPtr;
107 }
108
109
110 void 
111 AliHLTPHOSPulseGenerator::Quantisize(double *dataPtr) const
112 {
113   //See header file for documentation
114   double *dtaPtr;
115   dtaPtr = new double[100];
116   dtaPtr = dataPtr;
117 }
118
119
120 void
121 AliHLTPHOSPulseGenerator::SetAmplitude(double a)
122 {
123   //See header file for documentation
124   fAmplitude=a;
125 }
126
127
128 void 
129 AliHLTPHOSPulseGenerator::SetDT(double fs)
130 {
131   //See header file for documentation
132   fDT=1/fs;  
133 }
134
135
136 void
137 AliHLTPHOSPulseGenerator::SetTZero(double t0)
138 {
139   //See header file for documentation
140   fTZero = -t0/1000; // Since time is in nanoseconds and the samplingfrequency is in MHz -> divide by 1000
141 }
142
143
144 void 
145 AliHLTPHOSPulseGenerator::SetSampleFreq(int fs)
146 {
147   //See header file for documentation
148   fSampleFreq = fs;
149   SetDT(fs);
150 }
151
152
153 void
154 AliHLTPHOSPulseGenerator::MakePulse(double *dtaPtr)
155 {
156   //See header file for documentation
157   for(int i=0; i<fNSamples; i++)
158     {
159       dtaPtr[i]=fAmplitude*exp((Double_t)2)*pow((i*fDT-fTZero)/fTau, 2)*exp(-2*(i*fDT-fTZero)/fTau);
160     }  
161 }
162
163
164 void
165 AliHLTPHOSPulseGenerator::MakePulse(double *dtaPtr, int N)
166 {
167   //See header file for documentation
168   for(int i=0; i<N; i++)
169     {
170       dtaPtr[i]=fAmplitude*exp((Double_t)2)*pow((i*fDT-fTZero)/fTau, 2)*exp(-2*(i*fDT-fTZero)/fTau);
171     }  
172 }
173