]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSPulseGenerator.cxx
Do not set default CDB storage, if not defined, but return Fatal.
[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 #include "AliHLTPHOSPulseGenerator.h"
17 #include <cmath>
18 #include <iostream>
19
20 using std::cout;
21 using std::endl; 
22
23 ClassImp(AliHLTPHOSPulseGenerator) 
24
25
26
27 AliHLTPHOSPulseGenerator::AliHLTPHOSPulseGenerator(): fAmplitude(0), fNSamples(0),fTau(0), fSampleFreq(0), fTZero(0), fDataPtr(0), fDT(0)
28 {
29   //Never to be called   
30   cout << "You cannot invoke the Pulsgenerator without parameters" << endl;
31 }
32
33
34 AliHLTPHOSPulseGenerator::AliHLTPHOSPulseGenerator(const AliHLTPHOSPulseGenerator &): fAmplitude(0), fNSamples(0),fTau(0), fSampleFreq(0), fTZero(0), fDataPtr(0), fDT(0)
35 {
36   
37 }
38
39
40 AliHLTPHOSPulseGenerator::~AliHLTPHOSPulseGenerator()
41 {
42   //Destructor  
43   delete fDataPtr;
44   fDataPtr=0;
45 }
46
47
48 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)
49 {
50   //See header file for documentation  
51   fDataPtr = new double[100];
52   SetAmplitude(a);
53   SetDT(fs);
54   SetTZero(t0);
55   fNSamples=N;
56   fTau=tau;
57   fSampleFreq=fs;
58 }
59
60
61 void 
62 AliHLTPHOSPulseGenerator::AddBaseline(double baselineLevel, double *samples)
63 {
64   //See header file for documentation
65   double *tmpSamples;
66   tmpSamples = samples;
67   printf("\nbaselineLevel = %f\n", baselineLevel);
68   cout << "AddBaseline not implemented yet" << endl;
69 }
70
71
72 void 
73 AliHLTPHOSPulseGenerator::AddNoise(double *dataPtr, double *sigma)
74 {
75   //See header file for documentation 
76   printf("\ndataPtr = %f, sigma = %f\n", *dataPtr, *sigma);
77   cout << "AddNoise is not implemented yet" << endl;
78 }
79
80
81 void 
82 AliHLTPHOSPulseGenerator::AddNoise(double *dataPtr, double *sigma, double cutoff)
83 {
84   //See header file for documentation 
85   printf("\ndataPtr = %f, sigma = %f, cutoff = %f\n", *dataPtr, *sigma, cutoff);
86   cout << "AddNoise is not implemeted yet" << endl;
87 }
88
89
90 double *
91 AliHLTPHOSPulseGenerator::AddPretriggerSamples(double baselineLevel, double *samples)
92 {
93     //See header file for documentation
94   printf("\nbaslinelevel = %f, samples = %f\n", baselineLevel, *samples);
95   cout << "AddPretriggerSamples not implemented yet" << endl;
96   return 0;
97 }
98
99
100 double *
101 AliHLTPHOSPulseGenerator::GetPulse(double /*a*/, double /*t0*/)
102 {
103   //See header file for documentation
104   return fDataPtr;
105 }
106
107
108 void 
109 AliHLTPHOSPulseGenerator::Quantisize(double *dataPtr) const
110 {
111   //See header file for documentation
112   double *dtaPtr;
113   dtaPtr = new double[100];
114   dtaPtr = dataPtr;
115 }
116
117
118 void
119 AliHLTPHOSPulseGenerator::SetAmplitude(double a)
120 {
121   //See header file for documentation
122   fAmplitude=a;
123 }
124
125
126 void 
127 AliHLTPHOSPulseGenerator::SetDT(double fs)
128 {
129   //See header file for documentation
130   fDT=1/fs;  
131 }
132
133
134 void
135 AliHLTPHOSPulseGenerator::SetTZero(double t0)
136 {
137   //See header file for documentation
138   fTZero = -t0/1000; // Since time is in nanoseconds and the samplingfrequency is in MHz -> divide by 1000
139 }
140
141
142 void 
143 AliHLTPHOSPulseGenerator::SetSampleFreq(int fs)
144 {
145   //See header file for documentation
146   fSampleFreq = fs;
147   SetDT(fs);
148 }
149
150
151 void
152 AliHLTPHOSPulseGenerator::MakePulse(double *dtaPtr)
153 {
154   //See header file for documentation
155   for(int i=0; i<fNSamples; i++)
156     {
157       dtaPtr[i]=fAmplitude*exp((Double_t)2)*pow((i*fDT-fTZero)/fTau, 2)*exp(-2*(i*fDT-fTZero)/fTau);
158     }  
159 }
160
161
162 void
163 AliHLTPHOSPulseGenerator::MakePulse(double *dtaPtr, int N)
164 {
165   //See header file for documentation
166   for(int i=0; i<N; i++)
167     {
168       dtaPtr[i]=fAmplitude*exp((Double_t)2)*pow((i*fDT-fTZero)/fTau, 2)*exp(-2*(i*fDT-fTZero)/fTau);
169     }  
170 }
171