]>
Commit | Line | Data |
---|---|---|
090026bf | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line 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 | /* $Id$ */ | |
17 | ||
18 | #include <TF1.h> | |
19 | #include <TMath.h> | |
20 | ||
ec143d80 | 21 | #include "AliSignalProcesor.h" |
bb7e41dd | 22 | #include "AliMathBase.h" |
ec143d80 | 23 | |
24 | ||
25 | ClassImp(AliSignalProcesor) | |
26 | ||
27 | ||
28 | Double_t asymgauss(Double_t* x, Double_t* par) | |
29 | { | |
30 | // par[0] = normalization | |
31 | // par[1] = mean | |
32 | // par[2] = sigma | |
33 | // norm0 = 1 | |
34 | // par[3] = lambda0 | |
35 | // par[4] = norm1 | |
36 | // par[5] = lambda1 | |
37 | // | |
38 | ||
39 | Double_t par1save = par[1]; | |
40 | Double_t par2save = par[2]; | |
41 | Double_t par3save = par[3]; | |
42 | Double_t par5save = par[5]; | |
43 | Double_t dx = x[0]-par1save; | |
44 | // | |
45 | // | |
46 | Double_t sigma2 = par2save*par2save; | |
47 | Double_t sqrt2 = TMath::Sqrt(2.); | |
48 | if (-par3save*(dx-0.5*par3save*sigma2)>100) return 0; // avoid overflow | |
49 | if (-par5save*(dx-0.5*par5save*sigma2)>100) return 0; // avoid overflow | |
50 | if (TMath::Abs(par[4])>1) return 0; | |
51 | Double_t exp1 = par3save*TMath::Exp(-par3save*(dx-0.5*par3save*sigma2)) | |
bb7e41dd | 52 | *(1-AliMathBase::ErfFast((par3save*sigma2-dx)/(sqrt2*par2save))); |
ec143d80 | 53 | |
54 | Double_t exp2 = par5save*TMath::Exp(-par5save*(dx-0.5*par5save*sigma2)) | |
bb7e41dd | 55 | *(1-AliMathBase::ErfFast((par5save*sigma2-dx)/(sqrt2*par2save))); |
ec143d80 | 56 | |
57 | ||
58 | return par[0]*(exp1+par[4]*exp2); | |
59 | } | |
60 | ||
61 | Double_t asymgaussN(Double_t* x, Double_t* par) | |
62 | { | |
63 | // par[0] = normalization | |
64 | // par[1] = mean | |
65 | // par[2] = sigma | |
66 | // norm0 = 1 | |
67 | // par[3] = lambda0 | |
68 | // par[4] = norm1 | |
69 | // par[5] = lambda1 | |
70 | // | |
71 | ||
72 | Double_t par1save = par[1]; | |
73 | Double_t par2save = par[2]; | |
74 | Double_t par3save = par[3]; | |
75 | Double_t par5save = par[5]; | |
76 | Double_t dx = x[0]-par1save; | |
77 | // | |
78 | // | |
79 | Double_t sigma2 = par2save*par2save; | |
80 | Double_t sqrt2 = TMath::Sqrt(2.); | |
81 | if (-par3save*(dx-0.5*par3save*sigma2)>100) return 0; // avoid overflow | |
82 | if (-par5save*(dx-0.5*par5save*sigma2)>100) return 0; // avoid overflow | |
83 | if (TMath::Abs(par[4])>=1) return 0; | |
84 | ||
85 | Double_t exp1 = par3save*TMath::Exp(-par3save*(dx-0.5*par3save*sigma2)) | |
bb7e41dd | 86 | *0.5*(1-AliMathBase::ErfFast((par3save*sigma2-dx)/(sqrt2*par2save))); |
ec143d80 | 87 | |
88 | Double_t exp2 = par5save*TMath::Exp(-par5save*(dx-0.5*par5save*sigma2)) | |
bb7e41dd | 89 | *0.5*(1-AliMathBase::ErfFast((par5save*sigma2-dx)/(sqrt2*par2save))); |
ec143d80 | 90 | |
91 | ||
92 | return par[0]*(1.*exp1+par[4]*exp2)/(1.+par[4]); | |
93 | } | |
94 | ||
95 | ||
96 | TF1 * AliSignalProcesor::GetAsymGauss() | |
97 | { | |
98 | TF1 * f1 = new TF1("asymg",asymgaussN,-10,40,6); | |
99 | return f1; | |
100 | } | |
101 | ||
102 | ||
103 | ||
104 | void AliSignalProcesor::SplineSmoother(Double_t *ampin, Double_t *ampout, Int_t n) | |
105 | { | |
106 | // | |
107 | // | |
108 | Float_t in[10000]; | |
109 | Float_t out[10000]; | |
110 | in[0] = ampin[0]; | |
111 | in[1] = (ampin[0]+ampin[1])*0.5; | |
112 | in[2*(n-1)] = ampin[n-1]; | |
113 | in[2*(n-1)+1] = ampin[n-1]; | |
114 | // | |
115 | // add charge to the end | |
116 | for (Int_t i=0;i<10;i++){ | |
117 | in[2*(n-1)+i]=ampin[n-1]; | |
118 | } | |
119 | ||
120 | // | |
121 | for (Int_t i=1;i<n-1;i++){ | |
122 | in[2*i] = ampin[i]; | |
123 | in[2*i+1] = (9.*(ampin[i]+ampin[i+1])-(ampin[i-1]+ampin[i+2]))/16.; | |
124 | } | |
125 | // | |
126 | out[0] = in[0]; | |
127 | for (Int_t i=1;i<=2*n;i++){ | |
128 | out[i] = (9.*(in[i]+in[i+1])-(in[i-1]+in[i+2]))/16.; | |
129 | } | |
130 | // | |
131 | // | |
132 | for (int i=0;i<n;i++){ | |
133 | ampout[i] = out[2*i+1]; | |
134 | } | |
135 | } | |
136 | ||
137 | ||
138 | ||
139 | ||
140 | void AliSignalProcesor::TailCancelationALTRO(Double_t *ampin, Double_t *ampout, Float_t K, Float_t L, | |
141 | Int_t n) | |
142 | { | |
143 | // | |
144 | // ALTRO | |
145 | Float_t temp; | |
146 | ampout[0] = ampin[0]; | |
147 | temp = ampin[0]; | |
148 | for (int i=1;i<n;i++){ | |
149 | ampout[i] = ampin[i] + (K-L)*temp; | |
150 | temp = ampin[i] + K*temp; | |
151 | } | |
152 | } | |
153 | ||
154 | // | |
155 | // | |
156 | void AliSignalProcesor::TailCancelationTRD(Double_t *ampin, Double_t *ampout, Float_t r, Float_t c, | |
157 | Int_t n) | |
158 | { | |
159 | //TRD | |
160 | // | |
161 | Double_t reminder=0; | |
162 | // | |
163 | for (Int_t i=0; i<n; i++){ | |
164 | ampout[i] = ampin[i]-reminder; | |
165 | // | |
166 | reminder = r*(reminder+c*ampout[i]); | |
167 | } | |
168 | ||
169 | } | |
170 | ||
171 | void AliSignalProcesor::TailMaker(Double_t *ampin, Double_t *ampout, Float_t lambda, | |
172 | Int_t n) | |
173 | { | |
174 | ||
175 | Double_t l = TMath::Exp(-lambda); | |
176 | // | |
177 | Float_t temp=0; | |
178 | for (Int_t i=n-1; i>0; i--){ | |
179 | ampout[i] = ampin[i]+temp; | |
180 | // | |
181 | temp = l*(temp+ampin[i]); | |
182 | } | |
183 | } | |
184 | ||
185 | void AliSignalProcesor::TailCancelationALTRO1(Double_t *ampin, Double_t *ampout, Float_t norm, | |
186 | Float_t lambda, Int_t n) | |
187 | { | |
188 | ||
189 | Double_t l = TMath::Exp(-lambda); | |
190 | Double_t k = l*(1.-norm*lambda); | |
191 | ||
192 | return TailCancelationALTRO(ampin,ampout,k,l,n); | |
193 | } | |
194 | ||
195 | ||
196 | void AliSignalProcesor::TailCancelationTRD1(Double_t *ampin, Double_t *ampout, Float_t norm, | |
197 | Float_t lambda, Int_t n) | |
198 | { | |
199 | // | |
200 | // | |
201 | Double_t r = TMath::Exp(-lambda); | |
202 | Double_t c = norm*lambda; | |
203 | return TailCancelationTRD(ampin,ampout,r,c,n); | |
204 | } | |
205 | ||
206 | ||
207 | ||
208 | ||
209 | void AliSignalProcesor::TailCancelationMI(Double_t *ampin, Double_t *ampout, Float_t norm, | |
210 | Float_t lambda, Int_t n) | |
211 | { | |
212 | ||
213 | Double_t L = TMath::Exp(-lambda*0.5); | |
214 | Double_t K = L*(1.-norm*lambda*0.5); | |
215 | // | |
216 | // | |
217 | Float_t in[10000]; | |
218 | Float_t out[10000]; | |
219 | for (Int_t i=0;i<n*2+20;i++){ | |
220 | in[i] = 0; | |
221 | out[i]= 0; | |
222 | } | |
223 | in[0] = ampin[0]; | |
224 | in[1] = (ampin[0]+ampin[1])*0.5; | |
225 | in[2*(n-1)] = ampin[n-1]; | |
226 | in[2*(n-1)+1] = ampin[n-1]; | |
227 | // | |
228 | for (Int_t i=1;i<n-2;i++){ | |
229 | in[2*i] = ampin[i]; | |
230 | in[2*i+1] = (9.*(ampin[i]+ampin[i+1])-(ampin[i-1]+ampin[i+2]))/16; | |
231 | } | |
232 | // | |
233 | Float_t temp; | |
234 | out[0] = in[0]; | |
235 | temp = in[0]; | |
236 | for (int i=1;i<=2*n;i++){ | |
237 | out[i] = in[i] + (K-L)*temp; | |
238 | temp = in[i] + K*temp; | |
239 | } | |
240 | // | |
241 | // | |
242 | for (int i=0;i<n;i++){ | |
243 | ampout[i] = out[2*i+1]; | |
244 | } | |
245 | } | |
246 | ||
247 | ||
248 | ||
249 | ||
250 | ||
251 | void AliSignalProcesor::TailMakerSpline(Double_t *ampin, Double_t *ampout, Float_t lambda, | |
252 | Int_t n) | |
253 | { | |
254 | ||
255 | Double_t l = TMath::Exp(-lambda*0.5); | |
256 | // | |
257 | // | |
258 | Float_t in[10000]; | |
259 | Float_t out[10000]; | |
260 | for (Int_t i=0;i<n*2+20;i++){ | |
261 | in[i] = 0; | |
262 | out[i]= 0; | |
263 | } | |
264 | in[0] = ampin[0]; | |
265 | in[1] = (ampin[0]+ampin[1])*0.5; | |
266 | in[2*(n-1)] = ampin[n-1]; | |
267 | in[2*(n-1)+1] = ampin[n-1]; | |
268 | // | |
269 | // add charge to the end | |
270 | for (Int_t i=0;i<10;i++){ | |
271 | in[2*(n-1)+i]=ampin[n-1]; | |
272 | } | |
273 | ||
274 | // | |
275 | for (Int_t i=1;i<n-2;i++){ | |
276 | in[2*i] = ampin[i]; | |
277 | in[2*i+1] = (9.*(ampin[i]+ampin[i+1])-(ampin[i-1]+ampin[i+2]))/16; | |
278 | } | |
279 | // | |
280 | // | |
281 | Float_t temp; | |
282 | out[2*n] = in[2*n]; | |
283 | temp = 0; | |
284 | for (int i=2*n;i>=0;i--){ | |
285 | out[i] = in[i] + temp; | |
286 | temp = l*(temp+in[i]); | |
287 | } | |
288 | // | |
289 | // | |
290 | for (int i=0;i<n;i++){ | |
291 | ampout[i] = out[2*i+1]; | |
292 | } | |
293 | } |