]>
Commit | Line | Data |
---|---|---|
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 | 20 | using std::cout; |
21 | using std::endl; | |
22 | ||
cd906859 | 23 | ClassImp(AliHLTPHOSPulseGenerator) |
24 | ||
005850ed | 25 | |
26 | ||
d504c864 | 27 | AliHLTPHOSPulseGenerator::AliHLTPHOSPulseGenerator(): fAmplitude(0), fNSamples(0),fTau(0), fSampleFreq(0), fTZero(0), fDataPtr(0), fDT(0) |
228cb536 | 28 | { |
005850ed | 29 | //Never to be called |
228cb536 | 30 | cout << "You cannot invoke the Pulsgenerator without parameters" << endl; |
31 | } | |
32 | ||
d504c864 | 33 | |
d504c864 | 34 | AliHLTPHOSPulseGenerator::AliHLTPHOSPulseGenerator(const AliHLTPHOSPulseGenerator &): fAmplitude(0), fNSamples(0),fTau(0), fSampleFreq(0), fTZero(0), fDataPtr(0), fDT(0) |
cd906859 | 35 | { |
36 | ||
37 | } | |
38 | ||
39 | ||
40 | AliHLTPHOSPulseGenerator::~AliHLTPHOSPulseGenerator() | |
228cb536 | 41 | { |
005850ed | 42 | //Destructor |
228cb536 | 43 | delete fDataPtr; |
44 | fDataPtr=0; | |
45 | } | |
46 | ||
005850ed | 47 | |
d504c864 | 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) |
228cb536 | 49 | { |
005850ed | 50 | //See header file for documentation |
cd906859 | 51 | fDataPtr = new double[100]; |
228cb536 | 52 | SetAmplitude(a); |
53 | SetDT(fs); | |
54 | SetTZero(t0); | |
55 | fNSamples=N; | |
d504c864 | 56 | fTau=tau; |
228cb536 | 57 | fSampleFreq=fs; |
228cb536 | 58 | } |
59 | ||
d504c864 | 60 | |
228cb536 | 61 | void |
cd906859 | 62 | AliHLTPHOSPulseGenerator::AddBaseline(double baselineLevel, double *samples) |
228cb536 | 63 | { |
005850ed | 64 | //See header file for documentation |
cd906859 | 65 | double *tmpSamples; |
66 | tmpSamples = samples; | |
67 | printf("\nbaselineLevel = %f\n", baselineLevel); | |
228cb536 | 68 | cout << "AddBaseline not implemented yet" << endl; |
69 | } | |
70 | ||
005850ed | 71 | |
228cb536 | 72 | void |
cd906859 | 73 | AliHLTPHOSPulseGenerator::AddNoise(double *dataPtr, double *sigma) |
228cb536 | 74 | { |
005850ed | 75 | //See header file for documentation |
cd906859 | 76 | printf("\ndataPtr = %f, sigma = %f\n", *dataPtr, *sigma); |
228cb536 | 77 | cout << "AddNoise is not implemented yet" << endl; |
78 | } | |
79 | ||
cd906859 | 80 | |
228cb536 | 81 | void |
cd906859 | 82 | AliHLTPHOSPulseGenerator::AddNoise(double *dataPtr, double *sigma, double cutoff) |
228cb536 | 83 | { |
005850ed | 84 | //See header file for documentation |
cd906859 | 85 | printf("\ndataPtr = %f, sigma = %f, cutoff = %f\n", *dataPtr, *sigma, cutoff); |
228cb536 | 86 | cout << "AddNoise is not implemeted yet" << endl; |
87 | } | |
88 | ||
d504c864 | 89 | |
228cb536 | 90 | double * |
cd906859 | 91 | AliHLTPHOSPulseGenerator::AddPretriggerSamples(double baselineLevel, double *samples) |
228cb536 | 92 | { |
005850ed | 93 | //See header file for documentation |
cd906859 | 94 | printf("\nbaslinelevel = %f, samples = %f\n", baselineLevel, *samples); |
228cb536 | 95 | cout << "AddPretriggerSamples not implemented yet" << endl; |
cd906859 | 96 | return 0; |
228cb536 | 97 | } |
98 | ||
99 | ||
228cb536 | 100 | double * |
cd906859 | 101 | AliHLTPHOSPulseGenerator::GetPulse(double a, double t0) |
228cb536 | 102 | { |
005850ed | 103 | //See header file for documentation |
228cb536 | 104 | return fDataPtr; |
105 | } | |
106 | ||
005850ed | 107 | |
228cb536 | 108 | void |
005850ed | 109 | AliHLTPHOSPulseGenerator::Quantisize(double *dataPtr) const |
228cb536 | 110 | { |
005850ed | 111 | //See header file for documentation |
cd906859 | 112 | double *dtaPtr; |
113 | dtaPtr = new double[100]; | |
114 | dtaPtr = dataPtr; | |
228cb536 | 115 | } |
116 | ||
d504c864 | 117 | |
228cb536 | 118 | void |
cd906859 | 119 | AliHLTPHOSPulseGenerator::SetAmplitude(double a) |
228cb536 | 120 | { |
005850ed | 121 | //See header file for documentation |
228cb536 | 122 | fAmplitude=a; |
123 | } | |
124 | ||
d504c864 | 125 | |
228cb536 | 126 | void |
cd906859 | 127 | AliHLTPHOSPulseGenerator::SetDT(double fs) |
228cb536 | 128 | { |
005850ed | 129 | //See header file for documentation |
228cb536 | 130 | fDT=1/fs; |
131 | } | |
132 | ||
005850ed | 133 | |
228cb536 | 134 | void |
cd906859 | 135 | AliHLTPHOSPulseGenerator::SetTZero(double t0) |
228cb536 | 136 | { |
005850ed | 137 | //See header file for documentation |
228cb536 | 138 | fTZero = -t0/1000; // Since time is in nanoseconds and the samplingfrequency is in MHz -> divide by 1000 |
139 | } | |
140 | ||
cd906859 | 141 | |
005850ed | 142 | void |
143 | AliHLTPHOSPulseGenerator::SetSampleFreq(int fs) | |
144 | { | |
145 | //See header file for documentation | |
146 | fSampleFreq = fs; | |
147 | SetDT(fs); | |
148 | } | |
149 | ||
150 | ||
228cb536 | 151 | void |
cd906859 | 152 | AliHLTPHOSPulseGenerator::MakePulse(double *dtaPtr) |
228cb536 | 153 | { |
005850ed | 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 | } | |
228cb536 | 159 | } |
005850ed | 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 |