]>
Commit | Line | Data |
---|---|---|
f7336fa3 | 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 | /* | |
17 | $Log$ | |
db30bf0f | 18 | Revision 1.23 2001/05/07 08:04:48 cblume |
19 | New TRF and PRF. Speedup of the code. Digits from amplification region included | |
20 | ||
872a7aba | 21 | Revision 1.22 2001/03/30 14:40:14 cblume |
22 | Update of the digitization parameter | |
23 | ||
a3c76cdc | 24 | Revision 1.21 2001/03/13 09:30:35 cblume |
25 | Update of digitization. Moved digit branch definition to AliTRD | |
26 | ||
6244debe | 27 | Revision 1.20 2001/02/25 20:19:00 hristov |
28 | Minor correction: loop variable declared only once for HP, Sun | |
29 | ||
c3a4830f | 30 | Revision 1.19 2001/02/14 18:22:26 cblume |
31 | Change in the geometry of the padplane | |
32 | ||
71d9fa7b | 33 | Revision 1.18 2001/01/26 19:56:57 hristov |
34 | Major upgrade of AliRoot code | |
35 | ||
2ab0c725 | 36 | Revision 1.17 2000/12/08 12:53:27 cblume |
37 | Change in Copy() function for HP-compiler | |
38 | ||
1948ba0c | 39 | Revision 1.16 2000/12/07 12:20:46 cblume |
40 | Go back to array compression. Use sampled PRF to speed up digitization | |
41 | ||
e153aaf6 | 42 | Revision 1.15 2000/11/23 14:34:08 cblume |
43 | Fixed bug in expansion routine of arrays (initialize buffers properly) | |
44 | ||
259b9e4b | 45 | Revision 1.14 2000/11/20 08:54:44 cblume |
46 | Switch off compression as default | |
47 | ||
c1e4b257 | 48 | Revision 1.13 2000/11/10 14:57:52 cblume |
49 | Changes in the geometry constants for the DEC compiler | |
50 | ||
dd56b762 | 51 | Revision 1.12 2000/11/01 14:53:20 cblume |
52 | Merge with TRD-develop | |
53 | ||
793ff80c | 54 | Revision 1.1.4.9 2000/10/26 17:00:22 cblume |
55 | Fixed bug in CheckDetector() | |
56 | ||
57 | Revision 1.1.4.8 2000/10/23 13:41:35 cblume | |
58 | Added protection against Log(0) in the gas gain calulation | |
59 | ||
60 | Revision 1.1.4.7 2000/10/17 02:27:34 cblume | |
61 | Get rid of global constants | |
62 | ||
63 | Revision 1.1.4.6 2000/10/16 01:16:53 cblume | |
64 | Changed timebin 0 to be the one closest to the readout | |
65 | ||
66 | Revision 1.1.4.5 2000/10/15 23:34:29 cblume | |
67 | Faster version of the digitizer | |
68 | ||
69 | Revision 1.1.4.4 2000/10/06 16:49:46 cblume | |
70 | Made Getters const | |
71 | ||
72 | Revision 1.1.4.3 2000/10/04 16:34:58 cblume | |
73 | Replace include files by forward declarations | |
74 | ||
75 | Revision 1.1.4.2 2000/09/22 14:41:10 cblume | |
76 | Bug fix in PRF. Included time response. New structure | |
77 | ||
eda4336d | 78 | Revision 1.10 2000/10/05 07:27:53 cblume |
79 | Changes in the header-files by FCA | |
80 | ||
6798b56e | 81 | Revision 1.9 2000/10/02 21:28:19 fca |
82 | Removal of useless dependecies via forward declarations | |
83 | ||
94de3818 | 84 | Revision 1.8 2000/06/09 11:10:07 cblume |
85 | Compiler warnings and coding conventions, next round | |
86 | ||
dd9a6ee3 | 87 | Revision 1.7 2000/06/08 18:32:58 cblume |
88 | Make code compliant to coding conventions | |
89 | ||
8230f242 | 90 | Revision 1.6 2000/06/07 16:27:32 cblume |
91 | Try to remove compiler warnings on Sun and HP | |
92 | ||
9d0b222b | 93 | Revision 1.5 2000/05/09 16:38:57 cblume |
94 | Removed PadResponse(). Merge problem | |
95 | ||
f0a7bf65 | 96 | Revision 1.4 2000/05/08 15:53:45 cblume |
97 | Resolved merge conflict | |
98 | ||
da581aea | 99 | Revision 1.3 2000/04/28 14:49:27 cblume |
100 | Only one declaration of iDict in MakeDigits() | |
101 | ||
102 | Revision 1.1.4.1 2000/05/08 14:42:04 cblume | |
103 | Introduced AliTRDdigitsManager | |
28329a48 | 104 | |
1befd3b2 | 105 | Revision 1.1 2000/02/28 19:00:13 cblume |
106 | Add new TRD classes | |
107 | ||
f7336fa3 | 108 | */ |
109 | ||
110 | /////////////////////////////////////////////////////////////////////////////// | |
111 | // // | |
112 | // Creates and handles digits from TRD hits // | |
113 | // // | |
114 | // The following effects are included: // | |
115 | // - Diffusion // | |
116 | // - ExB effects // | |
117 | // - Gas gain including fluctuations // | |
118 | // - Pad-response (simple Gaussian approximation) // | |
119 | // - Electronics noise // | |
120 | // - Electronics gain // | |
121 | // - Digitization // | |
122 | // - ADC threshold // | |
123 | // The corresponding parameter can be adjusted via the various // | |
124 | // Set-functions. If these parameters are not explicitly set, default // | |
125 | // values are used (see Init-function). // | |
126 | // To produce digits from a root-file with TRD-hits use the // | |
127 | // slowDigitsCreate.C macro. // | |
128 | // // | |
129 | /////////////////////////////////////////////////////////////////////////////// | |
130 | ||
6798b56e | 131 | #include <stdlib.h> |
132 | ||
f7336fa3 | 133 | #include <TMath.h> |
134 | #include <TVector.h> | |
135 | #include <TRandom.h> | |
94de3818 | 136 | #include <TROOT.h> |
137 | #include <TTree.h> | |
793ff80c | 138 | #include <TFile.h> |
139 | #include <TF1.h> | |
140 | ||
141 | #include "AliRun.h" | |
db30bf0f | 142 | #include "AliMagF.h" |
f7336fa3 | 143 | |
144 | #include "AliTRD.h" | |
793ff80c | 145 | #include "AliTRDhit.h" |
f7336fa3 | 146 | #include "AliTRDdigitizer.h" |
da581aea | 147 | #include "AliTRDdataArrayI.h" |
148 | #include "AliTRDdataArrayF.h" | |
793ff80c | 149 | #include "AliTRDsegmentArray.h" |
da581aea | 150 | #include "AliTRDdigitsManager.h" |
793ff80c | 151 | #include "AliTRDgeometry.h" |
f7336fa3 | 152 | |
153 | ClassImp(AliTRDdigitizer) | |
154 | ||
155 | //_____________________________________________________________________________ | |
156 | AliTRDdigitizer::AliTRDdigitizer():TNamed() | |
157 | { | |
158 | // | |
159 | // AliTRDdigitizer default constructor | |
160 | // | |
161 | ||
6244debe | 162 | fInputFile = NULL; |
163 | fDigits = NULL; | |
164 | fTRD = NULL; | |
165 | fGeo = NULL; | |
6244debe | 166 | fPRFsmp = NULL; |
872a7aba | 167 | fTRFsmp = NULL; |
6244debe | 168 | |
169 | fEvent = 0; | |
170 | fGasGain = 0.0; | |
171 | fNoise = 0.0; | |
172 | fChipGain = 0.0; | |
173 | fSinRange = 0.0; | |
174 | fSoutRange = 0.0; | |
175 | fADCoutRange = 0.0; | |
176 | fADCinRange = 0.0; | |
177 | fADCthreshold = 0; | |
178 | fDiffusionOn = 0; | |
179 | fDiffusionT = 0.0; | |
180 | fDiffusionL = 0.0; | |
181 | fElAttachOn = 0; | |
182 | fElAttachProp = 0.0; | |
183 | fExBOn = 0; | |
184 | fOmegaTau = 0.0; | |
185 | fPRFOn = 0; | |
186 | fTRFOn = 0; | |
187 | fDriftVelocity = 0.0; | |
188 | fPadCoupling = 0.0; | |
189 | fTimeCoupling = 0.0; | |
190 | fTimeBinWidth = 0.0; | |
db30bf0f | 191 | fField = 0.0; |
6244debe | 192 | |
193 | fPRFbin = 0; | |
194 | fPRFlo = 0.0; | |
195 | fPRFhi = 0.0; | |
196 | fPRFwid = 0.0; | |
197 | fPRFpad = 0; | |
198 | fTRFbin = 0; | |
199 | fTRFlo = 0.0; | |
200 | fTRFhi = 0.0; | |
201 | fTRFwid = 0.0; | |
202 | ||
203 | fCompress = kTRUE; | |
204 | fVerbose = 1; | |
205 | fSDigits = kFALSE; | |
f7336fa3 | 206 | |
207 | } | |
208 | ||
209 | //_____________________________________________________________________________ | |
210 | AliTRDdigitizer::AliTRDdigitizer(const Text_t *name, const Text_t *title) | |
211 | :TNamed(name,title) | |
212 | { | |
213 | // | |
214 | // AliTRDdigitizer default constructor | |
215 | // | |
216 | ||
da581aea | 217 | fInputFile = NULL; |
218 | fDigits = NULL; | |
219 | fTRD = NULL; | |
220 | fGeo = NULL; | |
e153aaf6 | 221 | fPRFsmp = NULL; |
872a7aba | 222 | fTRFsmp = NULL; |
f7336fa3 | 223 | |
da581aea | 224 | fEvent = 0; |
f7336fa3 | 225 | |
e153aaf6 | 226 | fCompress = kTRUE; |
793ff80c | 227 | fVerbose = 1; |
6244debe | 228 | fSDigits = kFALSE; |
793ff80c | 229 | |
f7336fa3 | 230 | Init(); |
231 | ||
232 | } | |
233 | ||
8230f242 | 234 | //_____________________________________________________________________________ |
dd9a6ee3 | 235 | AliTRDdigitizer::AliTRDdigitizer(const AliTRDdigitizer &d) |
8230f242 | 236 | { |
237 | // | |
238 | // AliTRDdigitizer copy constructor | |
239 | // | |
240 | ||
dd9a6ee3 | 241 | ((AliTRDdigitizer &) d).Copy(*this); |
8230f242 | 242 | |
243 | } | |
244 | ||
f7336fa3 | 245 | //_____________________________________________________________________________ |
246 | AliTRDdigitizer::~AliTRDdigitizer() | |
247 | { | |
8230f242 | 248 | // |
249 | // AliTRDdigitizer destructor | |
250 | // | |
f7336fa3 | 251 | |
252 | if (fInputFile) { | |
253 | fInputFile->Close(); | |
254 | delete fInputFile; | |
255 | } | |
256 | ||
da581aea | 257 | if (fDigits) { |
258 | delete fDigits; | |
f7336fa3 | 259 | } |
260 | ||
f7336fa3 | 261 | } |
262 | ||
8230f242 | 263 | //_____________________________________________________________________________ |
dd9a6ee3 | 264 | AliTRDdigitizer &AliTRDdigitizer::operator=(const AliTRDdigitizer &d) |
265 | { | |
266 | // | |
267 | // Assignment operator | |
268 | // | |
269 | ||
270 | if (this != &d) ((AliTRDdigitizer &) d).Copy(*this); | |
271 | return *this; | |
272 | ||
273 | } | |
274 | ||
275 | //_____________________________________________________________________________ | |
276 | void AliTRDdigitizer::Copy(TObject &d) | |
8230f242 | 277 | { |
278 | // | |
279 | // Copy function | |
280 | // | |
281 | ||
1948ba0c | 282 | Int_t iBin; |
283 | ||
6244debe | 284 | ((AliTRDdigitizer &) d).fInputFile = NULL; |
285 | ((AliTRDdigitizer &) d).fDigits = NULL; | |
286 | ((AliTRDdigitizer &) d).fTRD = NULL; | |
287 | ((AliTRDdigitizer &) d).fGeo = NULL; | |
288 | ||
289 | ((AliTRDdigitizer &) d).fEvent = 0; | |
290 | ||
291 | ((AliTRDdigitizer &) d).fGasGain = fGasGain; | |
292 | ((AliTRDdigitizer &) d).fNoise = fNoise; | |
293 | ((AliTRDdigitizer &) d).fChipGain = fChipGain; | |
294 | ((AliTRDdigitizer &) d).fSoutRange = fSoutRange; | |
295 | ((AliTRDdigitizer &) d).fSinRange = fSinRange; | |
296 | ((AliTRDdigitizer &) d).fADCoutRange = fADCoutRange; | |
297 | ((AliTRDdigitizer &) d).fADCinRange = fADCinRange; | |
298 | ((AliTRDdigitizer &) d).fADCthreshold = fADCthreshold; | |
299 | ((AliTRDdigitizer &) d).fDiffusionOn = fDiffusionOn; | |
300 | ((AliTRDdigitizer &) d).fDiffusionT = fDiffusionT; | |
301 | ((AliTRDdigitizer &) d).fDiffusionL = fDiffusionL; | |
302 | ((AliTRDdigitizer &) d).fElAttachOn = fElAttachOn; | |
303 | ((AliTRDdigitizer &) d).fElAttachProp = fElAttachProp; | |
304 | ((AliTRDdigitizer &) d).fExBOn = fExBOn; | |
305 | ((AliTRDdigitizer &) d).fOmegaTau = fOmegaTau; | |
306 | ((AliTRDdigitizer &) d).fLorentzFactor = fLorentzFactor; | |
307 | ((AliTRDdigitizer &) d).fDriftVelocity = fDriftVelocity; | |
308 | ((AliTRDdigitizer &) d).fPadCoupling = fPadCoupling; | |
309 | ((AliTRDdigitizer &) d).fTimeCoupling = fTimeCoupling; | |
310 | ((AliTRDdigitizer &) d).fTimeBinWidth = fTimeBinWidth; | |
db30bf0f | 311 | ((AliTRDdigitizer &) d).fField = fField; |
6244debe | 312 | ((AliTRDdigitizer &) d).fPRFOn = fPRFOn; |
313 | ((AliTRDdigitizer &) d).fTRFOn = fTRFOn; | |
314 | ||
315 | ((AliTRDdigitizer &) d).fCompress = fCompress; | |
316 | ((AliTRDdigitizer &) d).fVerbose = fVerbose; | |
317 | ((AliTRDdigitizer &) d).fSDigits = fSDigits; | |
dd9a6ee3 | 318 | |
6244debe | 319 | ((AliTRDdigitizer &) d).fPRFbin = fPRFbin; |
320 | ((AliTRDdigitizer &) d).fPRFlo = fPRFlo; | |
321 | ((AliTRDdigitizer &) d).fPRFhi = fPRFhi; | |
322 | ((AliTRDdigitizer &) d).fPRFwid = fPRFwid; | |
323 | ((AliTRDdigitizer &) d).fPRFpad = fPRFpad; | |
e153aaf6 | 324 | if (((AliTRDdigitizer &) d).fPRFsmp) delete ((AliTRDdigitizer &) d).fPRFsmp; |
325 | ((AliTRDdigitizer &) d).fPRFsmp = new Float_t[fPRFbin]; | |
1948ba0c | 326 | for (iBin = 0; iBin < fPRFbin; iBin++) { |
e153aaf6 | 327 | ((AliTRDdigitizer &) d).fPRFsmp[iBin] = fPRFsmp[iBin]; |
328 | } | |
6244debe | 329 | ((AliTRDdigitizer &) d).fTRFbin = fTRFbin; |
330 | ((AliTRDdigitizer &) d).fTRFlo = fTRFlo; | |
331 | ((AliTRDdigitizer &) d).fTRFhi = fTRFhi; | |
332 | ((AliTRDdigitizer &) d).fTRFwid = fTRFwid; | |
872a7aba | 333 | if (((AliTRDdigitizer &) d).fTRFsmp) delete ((AliTRDdigitizer &) d).fTRFsmp; |
334 | ((AliTRDdigitizer &) d).fTRFsmp = new Float_t[fTRFbin]; | |
1948ba0c | 335 | for (iBin = 0; iBin < fTRFbin; iBin++) { |
872a7aba | 336 | ((AliTRDdigitizer &) d).fTRFsmp[iBin] = fTRFsmp[iBin]; |
6244debe | 337 | } |
338 | ||
8230f242 | 339 | } |
340 | ||
f7336fa3 | 341 | //_____________________________________________________________________________ |
342 | Int_t AliTRDdigitizer::Diffusion(Float_t driftlength, Float_t *xyz) | |
343 | { | |
344 | // | |
345 | // Applies the diffusion smearing to the position of a single electron | |
346 | // | |
347 | ||
348 | Float_t driftSqrt = TMath::Sqrt(driftlength); | |
349 | Float_t sigmaT = driftSqrt * fDiffusionT; | |
350 | Float_t sigmaL = driftSqrt * fDiffusionL; | |
351 | xyz[0] = gRandom->Gaus(xyz[0], sigmaL * fLorentzFactor); | |
352 | xyz[1] = gRandom->Gaus(xyz[1], sigmaT * fLorentzFactor); | |
353 | xyz[2] = gRandom->Gaus(xyz[2], sigmaT); | |
793ff80c | 354 | |
f7336fa3 | 355 | return 1; |
356 | ||
357 | } | |
358 | ||
359 | //_____________________________________________________________________________ | |
360 | Int_t AliTRDdigitizer::ExB(Float_t driftlength, Float_t *xyz) | |
361 | { | |
362 | // | |
363 | // Applies E x B effects to the position of a single electron | |
364 | // | |
365 | ||
366 | xyz[0] = xyz[0]; | |
793ff80c | 367 | xyz[1] = xyz[1] + fOmegaTau * driftlength; |
f7336fa3 | 368 | xyz[2] = xyz[2]; |
369 | ||
370 | return 1; | |
371 | ||
372 | } | |
373 | ||
793ff80c | 374 | //_____________________________________________________________________________ |
375 | Int_t AliTRDdigitizer::PadResponse(Float_t signal, Float_t dist, Float_t *pad) | |
376 | { | |
377 | // | |
378 | // Applies the pad response | |
379 | // | |
380 | ||
e153aaf6 | 381 | Int_t iBin = ((Int_t) (( - dist - fPRFlo) / fPRFwid)); |
382 | ||
383 | Int_t iBin0 = iBin - fPRFpad; | |
384 | Int_t iBin1 = iBin; | |
385 | Int_t iBin2 = iBin + fPRFpad; | |
386 | ||
387 | if ((iBin0 >= 0) && (iBin2 < fPRFbin)) { | |
388 | ||
389 | pad[0] = signal * fPRFsmp[iBin0]; | |
390 | pad[1] = signal * fPRFsmp[iBin1]; | |
391 | pad[2] = signal * fPRFsmp[iBin2]; | |
392 | ||
793ff80c | 393 | return 1; |
e153aaf6 | 394 | |
793ff80c | 395 | } |
396 | else { | |
e153aaf6 | 397 | |
793ff80c | 398 | return 0; |
e153aaf6 | 399 | |
793ff80c | 400 | } |
401 | ||
402 | } | |
403 | ||
404 | //_____________________________________________________________________________ | |
405 | Float_t AliTRDdigitizer::TimeResponse(Float_t time) | |
406 | { | |
407 | // | |
408 | // Applies the preamp shaper time response | |
409 | // | |
410 | ||
411 | Int_t iBin = ((Int_t) ((time - fTRFlo) / fTRFwid)); | |
412 | if ((iBin >= 0) && (iBin < fTRFbin)) { | |
872a7aba | 413 | return fTRFsmp[iBin]; |
793ff80c | 414 | } |
415 | else { | |
416 | return 0.0; | |
417 | } | |
418 | ||
419 | } | |
420 | ||
f7336fa3 | 421 | //_____________________________________________________________________________ |
422 | void AliTRDdigitizer::Init() | |
423 | { | |
424 | // | |
425 | // Initializes the digitization procedure with standard values | |
426 | // | |
427 | ||
428 | // The default parameter for the digitization | |
db30bf0f | 429 | fGasGain = 2800.; |
430 | fChipGain = 6.1; | |
6244debe | 431 | fNoise = 1000.; |
432 | fADCoutRange = 1023.; // 10-bit ADC | |
a3c76cdc | 433 | fADCinRange = 1000.; // 1V input range |
6244debe | 434 | fADCthreshold = 1; |
435 | ||
436 | // For the summable digits | |
437 | fSinRange = 1000000.; | |
438 | fSoutRange = 1000000.; | |
f7336fa3 | 439 | |
db30bf0f | 440 | // The drift velocity (cm / mus) |
441 | fDriftVelocity = 1.5; | |
442 | ||
443 | // The magnetic field strength in Tesla | |
444 | fField = 0.2 * gAlice->Field()->Factor(); | |
445 | ||
446 | // Diffusion on | |
6244debe | 447 | fDiffusionOn = 1; |
db30bf0f | 448 | |
449 | // E x B effects | |
450 | fExBOn = 0; | |
f7336fa3 | 451 | |
452 | // Propability for electron attachment | |
6244debe | 453 | fElAttachOn = 0; |
454 | fElAttachProp = 0.0; | |
f7336fa3 | 455 | |
da581aea | 456 | // The pad response function |
6244debe | 457 | fPRFOn = 1; |
872a7aba | 458 | |
459 | // The time response function | |
460 | fTRFOn = 1; | |
da581aea | 461 | |
6244debe | 462 | // The pad coupling factor (same number as for the TPC) |
463 | fPadCoupling = 0.5; | |
464 | ||
465 | // The time coupling factor (same number as for the TPC) | |
466 | fTimeCoupling = 0.4; | |
467 | ||
6244debe | 468 | } |
469 | ||
470 | //_____________________________________________________________________________ | |
471 | void AliTRDdigitizer::ReInit() | |
472 | { | |
473 | // | |
872a7aba | 474 | // Reinitializes the digitization procedure after a change in the parameter |
6244debe | 475 | // |
476 | ||
872a7aba | 477 | if (!fGeo) { |
478 | printf("AliTRDdigitizer::ReInit -- "); | |
479 | printf("No geometry defined. Run InitDetector() first\n"); | |
480 | exit(1); | |
481 | } | |
482 | ||
6244debe | 483 | // Calculate the time bin width in ns |
484 | fTimeBinWidth = fGeo->GetTimeBinSize() / fDriftVelocity * 1000.0; | |
485 | ||
872a7aba | 486 | // The range and the binwidth for the sampled TRF |
487 | fTRFbin = 100; | |
db30bf0f | 488 | // Start 0.2 mus before the signal |
489 | fTRFlo = -0.2 * fDriftVelocity; | |
872a7aba | 490 | // End the maximum driftlength after the signal |
491 | fTRFhi = AliTRDgeometry::DrThick() | |
492 | + fGeo->GetTimeAfter() * fGeo->GetTimeBinSize(); | |
493 | fTRFwid = (fTRFhi - fTRFlo) / ((Float_t) fTRFbin); | |
6244debe | 494 | |
db30bf0f | 495 | // Transverse and longitudinal diffusion coefficients (Xe/CO2) |
496 | fDiffusionT = GetDiffusionT(fDriftVelocity,fField); | |
497 | fDiffusionL = GetDiffusionL(fDriftVelocity,fField); | |
498 | ||
499 | // omega * tau.= tan(Lorentz-angle) | |
500 | fOmegaTau = GetOmegaTau(fDriftVelocity,fField); | |
501 | ||
6244debe | 502 | // The Lorentz factor |
503 | if (fExBOn) { | |
504 | fLorentzFactor = 1.0 / (1.0 + fOmegaTau*fOmegaTau); | |
505 | } | |
506 | else { | |
507 | fLorentzFactor = 1.0; | |
508 | } | |
793ff80c | 509 | |
510 | } | |
511 | ||
512 | //_____________________________________________________________________________ | |
6244debe | 513 | void AliTRDdigitizer::SampleTRF() |
793ff80c | 514 | { |
515 | // | |
6244debe | 516 | // Samples the time response function |
872a7aba | 517 | // It is defined according to Vasiles simulation of the preamp shaper |
518 | // output and includes the effect of the ion tail (based on Tariqs | |
519 | // Garfield simulation) and a shaping time of 125 ns FWHM | |
793ff80c | 520 | // |
521 | ||
872a7aba | 522 | Int_t ipos1; |
523 | Int_t ipos2; | |
524 | Float_t diff; | |
525 | ||
db30bf0f | 526 | const Int_t kNpasa = 200; |
527 | Float_t time[kNpasa] = { -0.280000, -0.270000, -0.260000, -0.250000 | |
528 | , -0.240000, -0.230000, -0.220000, -0.210000 | |
529 | , -0.200000, -0.190000, -0.180000, -0.170000 | |
530 | , -0.160000, -0.150000, -0.140000, -0.130000 | |
531 | , -0.120000, -0.110000, -0.100000, -0.090000 | |
532 | , -0.080000, -0.070000, -0.060000, -0.050000 | |
533 | , -0.040000, -0.030000, -0.020000, -0.010000 | |
534 | , -0.000000, 0.010000, 0.020000, 0.030000 | |
535 | , 0.040000, 0.050000, 0.060000, 0.070000 | |
536 | , 0.080000, 0.090000, 0.100000, 0.110000 | |
537 | , 0.120000, 0.130000, 0.140000, 0.150000 | |
538 | , 0.160000, 0.170000, 0.180000, 0.190000 | |
539 | , 0.200000, 0.210000, 0.220000, 0.230000 | |
540 | , 0.240000, 0.250000, 0.260000, 0.270000 | |
541 | , 0.280000, 0.290000, 0.300000, 0.310000 | |
542 | , 0.320000, 0.330000, 0.340000, 0.350000 | |
543 | , 0.360000, 0.370000, 0.380000, 0.390000 | |
544 | , 0.400000, 0.410000, 0.420000, 0.430000 | |
545 | , 0.440000, 0.450000, 0.460000, 0.470000 | |
546 | , 0.480000, 0.490000, 0.500000, 0.510000 | |
547 | , 0.520000, 0.530000, 0.540000, 0.550000 | |
548 | , 0.560000, 0.570000, 0.580000, 0.590000 | |
549 | , 0.600000, 0.610000, 0.620000, 0.630000 | |
550 | , 0.640000, 0.650000, 0.660000, 0.670000 | |
551 | , 0.680000, 0.690000, 0.700000, 0.710000 | |
552 | , 0.720000, 0.730000, 0.740000, 0.750000 | |
553 | , 0.760000, 0.770000, 0.780000, 0.790000 | |
554 | , 0.800000, 0.810000, 0.820000, 0.830000 | |
555 | , 0.840000, 0.850000, 0.860000, 0.870000 | |
556 | , 0.880000, 0.890000, 0.900000, 0.910000 | |
557 | , 0.920000, 0.930000, 0.940000, 0.950000 | |
558 | , 0.960000, 0.970000, 0.980000, 0.990000 | |
559 | , 1.000000, 1.010000, 1.020000, 1.030000 | |
560 | , 1.040000, 1.050000, 1.060000, 1.070000 | |
561 | , 1.080000, 1.090000, 1.100000, 1.110000 | |
562 | , 1.120000, 1.130000, 1.140000, 1.150000 | |
563 | , 1.160000, 1.170000, 1.180000, 1.190000 | |
564 | , 1.200000, 1.210000, 1.220000, 1.230000 | |
565 | , 1.240000, 1.250000, 1.260000, 1.270000 | |
566 | , 1.280000, 1.290000, 1.300000, 1.310000 | |
567 | , 1.320000, 1.330000, 1.340000, 1.350000 | |
568 | , 1.360000, 1.370000, 1.380000, 1.390000 | |
569 | , 1.400000, 1.410000, 1.420000, 1.430000 | |
570 | , 1.440000, 1.450000, 1.460000, 1.470000 | |
571 | , 1.480000, 1.490000, 1.500000, 1.510000 | |
572 | , 1.520000, 1.530000, 1.540000, 1.550000 | |
573 | , 1.560000, 1.570000, 1.580000, 1.590000 | |
574 | , 1.600000, 1.610000, 1.620000, 1.630000 | |
575 | , 1.640000, 1.650000, 1.660000, 1.670000 | |
576 | , 1.680000, 1.690000, 1.700000, 1.710000 }; | |
577 | ||
578 | Float_t signal[kNpasa] = { 0.000000, 0.000000, 0.000000, 0.000000 | |
579 | , 0.000000, 0.000000, 0.000000, 0.000000 | |
580 | , 0.000000, 0.000000, 0.000000, 0.000000 | |
581 | , 0.000000, 0.000000, 0.000000, 0.000098 | |
582 | , 0.003071, 0.020056, 0.066053, 0.148346 | |
583 | , 0.263120, 0.398496, 0.540226, 0.674436 | |
584 | , 0.790977, 0.883083, 0.947744, 0.985714 | |
585 | , 0.999248, 0.992105, 0.967669, 0.930827 | |
586 | , 0.884586, 0.833083, 0.778571, 0.723684 | |
587 | , 0.669173, 0.617293, 0.567669, 0.521805 | |
588 | , 0.479699, 0.440977, 0.405639, 0.373985 | |
589 | , 0.345526, 0.320038, 0.297256, 0.276917 | |
590 | , 0.258797, 0.242632, 0.228195, 0.215301 | |
591 | , 0.203759, 0.193383, 0.184023, 0.175564 | |
592 | , 0.167895, 0.160940, 0.154549, 0.148722 | |
593 | , 0.143308, 0.138346, 0.133722, 0.129398 | |
594 | , 0.125376, 0.121617, 0.118045, 0.114699 | |
595 | , 0.111541, 0.108571, 0.105714, 0.103008 | |
596 | , 0.100414, 0.097970, 0.095602, 0.093346 | |
597 | , 0.091165, 0.089060, 0.087068, 0.085150 | |
598 | , 0.083308, 0.081541, 0.079812, 0.078158 | |
599 | , 0.076541, 0.075000, 0.073496, 0.072068 | |
600 | , 0.070677, 0.069286, 0.068008, 0.066729 | |
601 | , 0.065489, 0.064286, 0.063120, 0.061992 | |
602 | , 0.060902, 0.059850, 0.058797, 0.057820 | |
603 | , 0.056842, 0.055902, 0.054962, 0.054060 | |
604 | , 0.053158, 0.052293, 0.051466, 0.050639 | |
605 | , 0.049850, 0.049060, 0.048308, 0.047556 | |
606 | , 0.046842, 0.046128, 0.045451, 0.044774 | |
607 | , 0.044098, 0.043459, 0.042820, 0.042218 | |
608 | , 0.041617, 0.041015, 0.040451, 0.039887 | |
609 | , 0.039323, 0.038797, 0.038271, 0.037744 | |
610 | , 0.037237, 0.036744, 0.036259, 0.035786 | |
611 | , 0.035323, 0.034872, 0.034429, 0.033996 | |
612 | , 0.033575, 0.033162, 0.032756, 0.032361 | |
613 | , 0.031974, 0.031594, 0.031222, 0.030857 | |
614 | , 0.030496, 0.030143, 0.029793, 0.029451 | |
615 | , 0.029109, 0.028774, 0.028444, 0.028113 | |
616 | , 0.027793, 0.027477, 0.027165, 0.026861 | |
617 | , 0.026564, 0.026271, 0.025981, 0.025699 | |
618 | , 0.025421, 0.025147, 0.024880, 0.024613 | |
619 | , 0.024353, 0.024094, 0.023842, 0.023590 | |
620 | , 0.023346, 0.023102, 0.022865, 0.022628 | |
621 | , 0.022398, 0.022173, 0.021951, 0.021733 | |
622 | , 0.021519, 0.021308, 0.021098, 0.020891 | |
623 | , 0.020688, 0.020485, 0.020286, 0.020090 | |
624 | , 0.019895, 0.019707, 0.019519, 0.019335 | |
625 | , 0.019150, 0.018974, 0.018797, 0.018624 | |
626 | , 0.018451, 0.018282, 0.018113, 0.017947 | |
627 | , 0.017782, 0.017617, 0.017455, 0.017297 }; | |
628 | ||
629 | //for (Int_t ipasa = 0; ipasa < kNpasa; ipasa++) { | |
630 | // time[ipasa] += 0.13; | |
631 | //} | |
872a7aba | 632 | |
633 | if (fTRFsmp) delete fTRFsmp; | |
634 | fTRFsmp = new Float_t[fTRFbin]; | |
635 | ||
636 | Float_t loTRF = TMath::Max(fTRFlo / fDriftVelocity,time[0]); | |
637 | Float_t hiTRF = TMath::Min(fTRFhi / fDriftVelocity,time[kNpasa-1]); | |
793ff80c | 638 | Float_t binWidth = (hiTRF - loTRF) / ((Float_t) fTRFbin); |
872a7aba | 639 | |
640 | // Take the linear interpolation | |
793ff80c | 641 | for (Int_t iBin = 0; iBin < fTRFbin; iBin++) { |
872a7aba | 642 | |
6244debe | 643 | Float_t bin = (((Float_t) iBin) + 0.5) * binWidth + loTRF; |
872a7aba | 644 | ipos1 = ipos2 = 0; |
645 | diff = 0; | |
646 | do { | |
647 | diff = bin - time[ipos2++]; | |
648 | } while (diff > 0); | |
649 | ipos2--; | |
650 | if (ipos2 > kNpasa) ipos2 = kNpasa - 1; | |
651 | ipos1 = ipos2 - 1; | |
652 | ||
653 | fTRFsmp[iBin] = signal[ipos2] | |
654 | + diff * (signal[ipos2] - signal[ipos1]) | |
655 | / ( time[ipos2] - time[ipos1]); | |
656 | ||
793ff80c | 657 | } |
658 | ||
f7336fa3 | 659 | } |
660 | ||
e153aaf6 | 661 | //_____________________________________________________________________________ |
662 | void AliTRDdigitizer::SamplePRF() | |
663 | { | |
664 | // | |
665 | // Samples the pad response function | |
666 | // | |
667 | ||
db30bf0f | 668 | const Int_t kPRFbin = 61; |
669 | Float_t prf[kPRFbin] = { 0.002340, 0.003380, 0.004900, 0.007080, 0.010220 | |
670 | , 0.014740, 0.021160, 0.030230, 0.042800, 0.059830 | |
671 | , 0.082030, 0.109700, 0.142550, 0.179840, 0.220610 | |
672 | , 0.263980, 0.309180, 0.355610, 0.402790, 0.450350 | |
673 | , 0.497930, 0.545190, 0.591740, 0.637100, 0.680610 | |
674 | , 0.721430, 0.758400, 0.790090, 0.814720, 0.830480 | |
675 | , 0.835930, 0.830480, 0.814710, 0.790070, 0.758390 | |
676 | , 0.721410, 0.680590, 0.637080, 0.591730, 0.545180 | |
677 | , 0.497920, 0.450340, 0.402790, 0.355610, 0.309190 | |
678 | , 0.263990, 0.220630, 0.179850, 0.142570, 0.109720 | |
679 | , 0.082040, 0.059830, 0.042820, 0.030230, 0.021170 | |
680 | , 0.014740, 0.010230, 0.007080, 0.004900, 0.003380 | |
681 | , 0.002340 }; | |
682 | ||
683 | fPRFlo = -1.5; | |
684 | fPRFhi = 1.5; | |
685 | fPRFbin = kPRFbin; | |
686 | fPRFwid = (fPRFhi - fPRFlo) / ((Float_t) fPRFbin); | |
687 | fPRFpad = ((Int_t) (1.0 / fPRFwid)); | |
688 | ||
e153aaf6 | 689 | if (fPRFsmp) delete fPRFsmp; |
690 | fPRFsmp = new Float_t[fPRFbin]; | |
691 | for (Int_t iBin = 0; iBin < fPRFbin; iBin++) { | |
db30bf0f | 692 | fPRFsmp[iBin] = prf[iBin]; |
e153aaf6 | 693 | } |
694 | ||
695 | } | |
696 | ||
f7336fa3 | 697 | //_____________________________________________________________________________ |
698 | Bool_t AliTRDdigitizer::Open(const Char_t *name, Int_t nEvent) | |
699 | { | |
700 | // | |
701 | // Opens a ROOT-file with TRD-hits and reads in the hit-tree | |
702 | // | |
703 | ||
704 | // Connect the AliRoot file containing Geometry, Kine, and Hits | |
705 | fInputFile = (TFile*) gROOT->GetListOfFiles()->FindObject(name); | |
706 | if (!fInputFile) { | |
707 | printf("AliTRDdigitizer::Open -- "); | |
708 | printf("Open the ALIROOT-file %s.\n",name); | |
709 | fInputFile = new TFile(name,"UPDATE"); | |
710 | } | |
711 | else { | |
712 | printf("AliTRDdigitizer::Open -- "); | |
713 | printf("%s is already open.\n",name); | |
714 | } | |
715 | ||
da581aea | 716 | gAlice = (AliRun*) fInputFile->Get("gAlice"); |
717 | if (gAlice) { | |
718 | printf("AliTRDdigitizer::Open -- "); | |
719 | printf("AliRun object found on file.\n"); | |
720 | } | |
721 | else { | |
722 | printf("AliTRDdigitizer::Open -- "); | |
723 | printf("Could not find AliRun object.\n"); | |
724 | return kFALSE; | |
725 | } | |
f7336fa3 | 726 | |
727 | fEvent = nEvent; | |
728 | ||
729 | // Import the Trees for the event nEvent in the file | |
730 | Int_t nparticles = gAlice->GetEvent(fEvent); | |
731 | if (nparticles <= 0) { | |
732 | printf("AliTRDdigitizer::Open -- "); | |
733 | printf("No entries in the trees for event %d.\n",fEvent); | |
734 | return kFALSE; | |
735 | } | |
736 | ||
793ff80c | 737 | return InitDetector(); |
738 | ||
739 | } | |
740 | ||
741 | //_____________________________________________________________________________ | |
742 | Bool_t AliTRDdigitizer::InitDetector() | |
743 | { | |
744 | // | |
745 | // Sets the pointer to the TRD detector and the geometry | |
746 | // | |
747 | ||
dd9a6ee3 | 748 | // Get the pointer to the detector class and check for version 1 |
749 | fTRD = (AliTRD*) gAlice->GetDetector("TRD"); | |
750 | if (fTRD->IsVersion() != 1) { | |
6244debe | 751 | printf("AliTRDdigitizer::InitDetector -- "); |
dd9a6ee3 | 752 | printf("TRD must be version 1 (slow simulator).\n"); |
753 | exit(1); | |
754 | } | |
755 | ||
756 | // Get the geometry | |
757 | fGeo = fTRD->GetGeometry(); | |
6244debe | 758 | printf("AliTRDdigitizer::InitDetector -- "); |
dd9a6ee3 | 759 | printf("Geometry version %d\n",fGeo->IsVersion()); |
760 | ||
872a7aba | 761 | ReInit(); |
762 | ||
f7336fa3 | 763 | return kTRUE; |
764 | ||
765 | } | |
766 | ||
6244debe | 767 | //_____________________________________________________________________________ |
768 | Bool_t AliTRDdigitizer::SumSDigits() | |
769 | { | |
770 | // | |
771 | // Sums up the summable digits and creates final digits | |
772 | // Not yet implemented | |
773 | // | |
774 | ||
775 | return kFALSE; | |
776 | ||
777 | } | |
778 | ||
f7336fa3 | 779 | //_____________________________________________________________________________ |
780 | Bool_t AliTRDdigitizer::MakeDigits() | |
781 | { | |
782 | // | |
872a7aba | 783 | // Creates digits. |
f7336fa3 | 784 | // |
785 | ||
f7336fa3 | 786 | /////////////////////////////////////////////////////////////// |
787 | // Parameter | |
788 | /////////////////////////////////////////////////////////////// | |
789 | ||
790 | // Converts number of electrons to fC | |
872a7aba | 791 | const Double_t kEl2fC = 1.602E-19 * 1.0E15; |
f7336fa3 | 792 | |
793 | /////////////////////////////////////////////////////////////// | |
794 | ||
793ff80c | 795 | // Number of pads included in the pad response |
796 | const Int_t kNpad = 3; | |
797 | ||
798 | // Number of track dictionary arrays | |
dd56b762 | 799 | const Int_t kNDict = AliTRDdigitsManager::kNDict; |
793ff80c | 800 | |
872a7aba | 801 | // Half the width of the amplification region |
802 | const Float_t kAmWidth = AliTRDgeometry::AmThick() / 2.; | |
803 | ||
c3a4830f | 804 | Int_t iRow, iCol, iTime, iPad; |
71d9fa7b | 805 | Int_t iDict = 0; |
793ff80c | 806 | Int_t nBytes = 0; |
f7336fa3 | 807 | |
808 | Int_t totalSizeDigits = 0; | |
809 | Int_t totalSizeDict0 = 0; | |
810 | Int_t totalSizeDict1 = 0; | |
811 | Int_t totalSizeDict2 = 0; | |
812 | ||
872a7aba | 813 | Int_t timeTRDbeg = 0; |
814 | Int_t timeTRDend = 1; | |
815 | ||
816 | Float_t pos[3]; | |
817 | Float_t rot[3]; | |
818 | Float_t xyz[3]; | |
819 | Float_t padSignal[kNpad]; | |
820 | Float_t signalOld[kNpad]; | |
821 | ||
793ff80c | 822 | AliTRDdataArrayF *signals = 0; |
823 | AliTRDdataArrayI *digits = 0; | |
8230f242 | 824 | AliTRDdataArrayI *dictionary[kNDict]; |
da581aea | 825 | |
793ff80c | 826 | // Create a digits manager |
827 | fDigits = new AliTRDdigitsManager(); | |
828 | ||
829 | // Create a container for the amplitudes | |
830 | AliTRDsegmentArray *signalsArray | |
831 | = new AliTRDsegmentArray("AliTRDdataArrayF",AliTRDgeometry::Ndet()); | |
832 | ||
872a7aba | 833 | if (fTRFOn) { |
834 | timeTRDbeg = ((Int_t) (-fTRFlo / fGeo->GetTimeBinSize())) - 1; | |
835 | timeTRDend = ((Int_t) ( fTRFhi / fGeo->GetTimeBinSize())) - 1; | |
da581aea | 836 | printf("AliTRDdigitizer::MakeDigits -- "); |
872a7aba | 837 | printf("Sample the TRF between -%d and %d\n",timeTRDbeg,timeTRDend); |
da581aea | 838 | } |
839 | ||
872a7aba | 840 | Float_t elAttachProp = fElAttachProp / 100.; |
f7336fa3 | 841 | |
e153aaf6 | 842 | // Create the sampled PRF |
843 | SamplePRF(); | |
844 | ||
6244debe | 845 | // Create the sampled TRF |
846 | SampleTRF(); | |
793ff80c | 847 | |
872a7aba | 848 | if (!fGeo) { |
849 | printf("AliTRDdigitizer::MakeDigits -- "); | |
850 | printf("No geometry defined\n"); | |
851 | return kFALSE; | |
852 | } | |
853 | ||
854 | printf("AliTRDdigitizer::MakeDigits -- "); | |
855 | printf("Start creating digits.\n"); | |
856 | if (fVerbose > 0) this->Dump(); | |
857 | ||
793ff80c | 858 | // Get the pointer to the hit tree |
859 | TTree *HitTree = gAlice->TreeH(); | |
860 | ||
861 | // Get the number of entries in the hit tree | |
862 | // (Number of primary particles creating a hit somewhere) | |
863 | Int_t nTrack = (Int_t) HitTree->GetEntries(); | |
864 | if (fVerbose > 0) { | |
865 | printf("AliTRDdigitizer::MakeDigits -- "); | |
866 | printf("Found %d primary particles\n",nTrack); | |
867 | } | |
868 | ||
869 | Int_t detectorOld = -1; | |
870 | Int_t countHits = 0; | |
871 | ||
872 | // Loop through all entries in the tree | |
873 | for (Int_t iTrack = 0; iTrack < nTrack; iTrack++) { | |
874 | ||
875 | gAlice->ResetHits(); | |
876 | nBytes += HitTree->GetEvent(iTrack); | |
877 | ||
878 | // Get the number of hits in the TRD created by this particle | |
879 | Int_t nHit = fTRD->Hits()->GetEntriesFast(); | |
880 | if (fVerbose > 0) { | |
881 | printf("AliTRDdigitizer::MakeDigits -- "); | |
882 | printf("Found %d hits for primary particle %d\n",nHit,iTrack); | |
883 | } | |
884 | ||
885 | // Loop through the TRD hits | |
886 | for (Int_t iHit = 0; iHit < nHit; iHit++) { | |
887 | ||
888 | countHits++; | |
889 | ||
890 | AliTRDhit *hit = (AliTRDhit *) fTRD->Hits()->UncheckedAt(iHit); | |
793ff80c | 891 | pos[0] = hit->X(); |
892 | pos[1] = hit->Y(); | |
893 | pos[2] = hit->Z(); | |
894 | Float_t q = hit->GetCharge(); | |
895 | Int_t track = hit->Track(); | |
896 | Int_t detector = hit->GetDetector(); | |
897 | Int_t plane = fGeo->GetPlane(detector); | |
898 | Int_t sector = fGeo->GetSector(detector); | |
899 | Int_t chamber = fGeo->GetChamber(detector); | |
900 | ||
901 | if (!(CheckDetector(plane,chamber,sector))) continue; | |
902 | ||
903 | Int_t nRowMax = fGeo->GetRowMax(plane,chamber,sector); | |
904 | Int_t nColMax = fGeo->GetColMax(plane); | |
905 | Int_t nTimeMax = fGeo->GetTimeMax(); | |
872a7aba | 906 | Int_t nTimeBefore = fGeo->GetTimeBefore(); |
907 | Int_t nTimeAfter = fGeo->GetTimeAfter(); | |
908 | Int_t nTimeTotal = fGeo->GetTimeTotal(); | |
793ff80c | 909 | Float_t row0 = fGeo->GetRow0(plane,chamber,sector); |
910 | Float_t col0 = fGeo->GetCol0(plane); | |
911 | Float_t time0 = fGeo->GetTime0(plane); | |
71d9fa7b | 912 | Float_t rowPadSize = fGeo->GetRowPadSize(plane,chamber,sector); |
913 | Float_t colPadSize = fGeo->GetColPadSize(plane); | |
793ff80c | 914 | Float_t timeBinSize = fGeo->GetTimeBinSize(); |
872a7aba | 915 | Float_t divideRow = 1.0 / rowPadSize; |
916 | Float_t divideCol = 1.0 / colPadSize; | |
917 | Float_t divideTime = 1.0 / timeBinSize; | |
793ff80c | 918 | |
919 | if (fVerbose > 1) { | |
920 | printf("Analyze hit no. %d ",iHit); | |
921 | printf("-----------------------------------------------------------\n"); | |
922 | hit->Dump(); | |
923 | printf("plane = %d, sector = %d, chamber = %d\n" | |
924 | ,plane,sector,chamber); | |
925 | printf("nRowMax = %d, nColMax = %d, nTimeMax = %d\n" | |
926 | ,nRowMax,nColMax,nTimeMax); | |
872a7aba | 927 | printf("nTimeBefore = %d, nTimeAfter = %d, nTimeTotal = %d\n" |
928 | ,nTimeBefore,nTimeAfter,nTimeTotal); | |
793ff80c | 929 | printf("row0 = %f, col0 = %f, time0 = %f\n" |
930 | ,row0,col0,time0); | |
c1e4b257 | 931 | printf("rowPadSize = %f, colPadSize = %f, timeBinSize = %f\n" |
932 | ,rowPadSize,colPadSize,timeBinSize); | |
793ff80c | 933 | } |
934 | ||
872a7aba | 935 | // Don't analyze test hits |
936 | if (hit->FromTest()) continue; | |
dd56b762 | 937 | |
793ff80c | 938 | if (detector != detectorOld) { |
e153aaf6 | 939 | |
793ff80c | 940 | if (fVerbose > 1) { |
941 | printf("AliTRDdigitizer::MakeDigits -- "); | |
942 | printf("Get new container. New det = %d, Old det = %d\n" | |
943 | ,detector,detectorOld); | |
944 | } | |
945 | // Compress the old one if enabled | |
946 | if ((fCompress) && (detectorOld > -1)) { | |
947 | if (fVerbose > 1) { | |
948 | printf("AliTRDdigitizer::MakeDigits -- "); | |
e153aaf6 | 949 | printf("Compress the old container ..."); |
dd9a6ee3 | 950 | } |
793ff80c | 951 | signals->Compress(1,0); |
952 | for (iDict = 0; iDict < kNDict; iDict++) { | |
953 | dictionary[iDict]->Compress(1,0); | |
dd9a6ee3 | 954 | } |
793ff80c | 955 | if (fVerbose > 1) printf("done\n"); |
9d0b222b | 956 | } |
793ff80c | 957 | // Get the new container |
958 | signals = (AliTRDdataArrayF *) signalsArray->At(detector); | |
959 | if (signals->GetNtime() == 0) { | |
960 | // Allocate a new one if not yet existing | |
961 | if (fVerbose > 1) { | |
962 | printf("AliTRDdigitizer::MakeDigits -- "); | |
963 | printf("Allocate a new container ... "); | |
964 | } | |
872a7aba | 965 | signals->Allocate(nRowMax,nColMax,nTimeTotal); |
793ff80c | 966 | } |
967 | else { | |
968 | // Expand an existing one | |
c1e4b257 | 969 | if (fCompress) { |
970 | if (fVerbose > 1) { | |
971 | printf("AliTRDdigitizer::MakeDigits -- "); | |
972 | printf("Expand an existing container ... "); | |
973 | } | |
974 | signals->Expand(); | |
793ff80c | 975 | } |
793ff80c | 976 | } |
977 | // The same for the dictionary | |
978 | for (iDict = 0; iDict < kNDict; iDict++) { | |
979 | dictionary[iDict] = fDigits->GetDictionary(detector,iDict); | |
980 | if (dictionary[iDict]->GetNtime() == 0) { | |
872a7aba | 981 | dictionary[iDict]->Allocate(nRowMax,nColMax,nTimeTotal); |
793ff80c | 982 | } |
983 | else { | |
984 | if (fCompress) dictionary[iDict]->Expand(); | |
985 | } | |
986 | } | |
987 | if (fVerbose > 1) printf("done\n"); | |
988 | detectorOld = detector; | |
989 | } | |
9d0b222b | 990 | |
793ff80c | 991 | // Rotate the sectors on top of each other |
793ff80c | 992 | fGeo->Rotate(detector,pos,rot); |
993 | ||
872a7aba | 994 | // The driftlength. It is negative if the hit is in the |
995 | // amplification region. | |
793ff80c | 996 | Float_t driftlength = time0 - rot[0]; |
793ff80c | 997 | |
872a7aba | 998 | // Take also the drift in the amplification region into account |
999 | // The drift length is at the moment still the same, regardless of | |
1000 | // the position relativ to the wire. This non-isochronity needs still | |
1001 | // to be implemented. | |
1002 | Float_t driftlengthL = TMath::Abs(driftlength + kAmWidth); | |
1003 | if (fExBOn) driftlengthL /= TMath::Sqrt(fLorentzFactor); | |
793ff80c | 1004 | |
1005 | // Loop over all electrons of this hit | |
1006 | // TR photons produce hits with negative charge | |
1007 | Int_t nEl = ((Int_t) TMath::Abs(q)); | |
1008 | for (Int_t iEl = 0; iEl < nEl; iEl++) { | |
1009 | ||
793ff80c | 1010 | xyz[0] = rot[0]; |
1011 | xyz[1] = rot[1]; | |
1012 | xyz[2] = rot[2]; | |
1013 | ||
1014 | // Electron attachment | |
1015 | if (fElAttachOn) { | |
872a7aba | 1016 | if (gRandom->Rndm() < (driftlengthL * elAttachProp)) |
793ff80c | 1017 | continue; |
1018 | } | |
1019 | ||
1020 | // Apply the diffusion smearing | |
1021 | if (fDiffusionOn) { | |
1022 | if (!(Diffusion(driftlengthL,xyz))) continue; | |
da581aea | 1023 | } |
f7336fa3 | 1024 | |
872a7aba | 1025 | // Apply E x B effects (depends on drift direction) |
793ff80c | 1026 | if (fExBOn) { |
872a7aba | 1027 | if (!(ExB(driftlength+kAmWidth,xyz))) continue; |
793ff80c | 1028 | } |
f7336fa3 | 1029 | |
872a7aba | 1030 | // The electron position after diffusion and ExB in pad coordinates |
793ff80c | 1031 | // The pad row (z-direction) |
872a7aba | 1032 | Int_t rowE = ((Int_t) ((xyz[2] - row0) * divideRow)); |
1033 | if ((rowE < 0) || (rowE >= nRowMax)) continue; | |
793ff80c | 1034 | |
872a7aba | 1035 | // The pad column (rphi-direction) |
1036 | Int_t colE = ((Int_t) ((xyz[1] - col0) * divideCol)); | |
1037 | if ((colE < 0) || (colE >= nColMax)) continue; | |
1038 | ||
1039 | // The time bin (negative for hits in the amplification region) | |
1040 | // In the amplification region the electrons drift from both sides | |
1041 | // to the middle (anode wire plane) | |
1042 | Float_t timeDist = time0 - xyz[0]; | |
1043 | Float_t timeOffset = 0; | |
1044 | Int_t timeE = 0; | |
1045 | if (timeDist > 0) { | |
1046 | // The time bin | |
1047 | timeE = ((Int_t) (timeDist * divideTime)); | |
1048 | // The distance of the position to the middle of the timebin | |
1049 | timeOffset = ((((Float_t) timeE) + 0.5) * timeBinSize) - timeDist; | |
1050 | } | |
1051 | else { | |
1052 | // Difference between half of the amplification gap width and | |
1053 | // the distance to the anode wire | |
1054 | Float_t anodeDist = kAmWidth - TMath::Abs(timeDist + kAmWidth); | |
1055 | // The time bin | |
1056 | timeE = -1 * (((Int_t ) (anodeDist * divideTime)) + 1); | |
1057 | // The distance of the position to the middle of the timebin | |
1058 | timeOffset = ((((Float_t) timeE) + 0.5) * timeBinSize) + anodeDist; | |
1059 | } | |
1060 | ||
793ff80c | 1061 | // Apply the gas gain including fluctuations |
1062 | Float_t ggRndm = 0.0; | |
1063 | do { | |
1064 | ggRndm = gRandom->Rndm(); | |
1065 | } while (ggRndm <= 0); | |
1066 | Int_t signal = (Int_t) (-fGasGain * TMath::Log(ggRndm)); | |
1067 | ||
793ff80c | 1068 | // Apply the pad response |
793ff80c | 1069 | if (fPRFOn) { |
1070 | // The distance of the electron to the center of the pad | |
1071 | // in units of pad width | |
1072 | Float_t dist = (xyz[1] - col0 - (colE + 0.5) * colPadSize) | |
872a7aba | 1073 | * divideCol; |
793ff80c | 1074 | if (!(PadResponse(signal,dist,padSignal))) continue; |
1075 | } | |
1076 | else { | |
1077 | padSignal[0] = 0.0; | |
1078 | padSignal[1] = signal; | |
1079 | padSignal[2] = 0.0; | |
1080 | } | |
f7336fa3 | 1081 | |
872a7aba | 1082 | // Sample the time response inside the drift region |
1083 | // + additional time bins before and after. | |
1084 | // The sampling is done always in the middle of the time bin | |
1085 | for (Int_t iTimeBin = TMath::Max(timeE-timeTRDbeg, -nTimeBefore) | |
1086 | ;iTimeBin < TMath::Min(timeE+timeTRDend,nTimeMax+nTimeAfter ) | |
6244debe | 1087 | ;iTimeBin++) { |
793ff80c | 1088 | |
1089 | // Apply the time response | |
1090 | Float_t timeResponse = 1.0; | |
1091 | if (fTRFOn) { | |
1092 | Float_t time = (iTimeBin - timeE) * timeBinSize + timeOffset; | |
1093 | timeResponse = TimeResponse(time); | |
1094 | } | |
f7336fa3 | 1095 | |
872a7aba | 1096 | signalOld[0] = 0.0; |
1097 | signalOld[1] = 0.0; | |
1098 | signalOld[2] = 0.0; | |
1099 | ||
c3a4830f | 1100 | for (iPad = 0; iPad < kNpad; iPad++) { |
872a7aba | 1101 | |
793ff80c | 1102 | Int_t colPos = colE + iPad - 1; |
1103 | if (colPos < 0) continue; | |
1104 | if (colPos >= nColMax) break; | |
872a7aba | 1105 | |
1106 | // Add the signals | |
1107 | // Note: The time bin number is shifted by nTimeBefore to avoid negative | |
db30bf0f | 1108 | // time bins. This has to be subtracted later. |
872a7aba | 1109 | Int_t iCurrentTimeBin = iTimeBin + nTimeBefore; |
1110 | signalOld[iPad] = signals->GetDataUnchecked(rowE,colPos,iCurrentTimeBin); | |
793ff80c | 1111 | signalOld[iPad] += padSignal[iPad] * timeResponse; |
872a7aba | 1112 | signals->SetDataUnchecked(rowE,colPos,iCurrentTimeBin,signalOld[iPad]); |
f7336fa3 | 1113 | |
872a7aba | 1114 | // Store the track index in the dictionary |
1115 | // Note: We store index+1 in order to allow the array to be compressed | |
1116 | if (signalOld[iPad] > 0) { | |
71d9fa7b | 1117 | for (iDict = 0; iDict < kNDict; iDict++) { |
872a7aba | 1118 | Int_t oldTrack = dictionary[iDict]->GetDataUnchecked(rowE |
1119 | ,colPos | |
1120 | ,iCurrentTimeBin); | |
71d9fa7b | 1121 | if (oldTrack == track+1) break; |
71d9fa7b | 1122 | if (oldTrack == 0) { |
872a7aba | 1123 | dictionary[iDict]->SetDataUnchecked(rowE,colPos,iCurrentTimeBin,track+1); |
71d9fa7b | 1124 | break; |
1125 | } | |
1126 | } | |
793ff80c | 1127 | } |
872a7aba | 1128 | |
1129 | } | |
f7336fa3 | 1130 | |
f7336fa3 | 1131 | } |
1132 | ||
793ff80c | 1133 | } |
f7336fa3 | 1134 | |
793ff80c | 1135 | } |
f7336fa3 | 1136 | |
793ff80c | 1137 | } // All hits finished |
f7336fa3 | 1138 | |
793ff80c | 1139 | printf("AliTRDdigitizer::MakeDigits -- "); |
1140 | printf("Finished analyzing %d hits\n",countHits); | |
1141 | ||
6244debe | 1142 | // The total conversion factor |
1143 | Float_t convert = kEl2fC * fPadCoupling * fTimeCoupling * fChipGain; | |
1144 | ||
793ff80c | 1145 | // Loop through all chambers to finalize the digits |
1146 | for (Int_t iDet = 0; iDet < AliTRDgeometry::Ndet(); iDet++) { | |
1147 | ||
872a7aba | 1148 | Int_t plane = fGeo->GetPlane(iDet); |
1149 | Int_t sector = fGeo->GetSector(iDet); | |
1150 | Int_t chamber = fGeo->GetChamber(iDet); | |
1151 | Int_t nRowMax = fGeo->GetRowMax(plane,chamber,sector); | |
1152 | Int_t nColMax = fGeo->GetColMax(plane); | |
1153 | Int_t nTimeMax = fGeo->GetTimeMax(); | |
1154 | Int_t nTimeTotal = fGeo->GetTimeTotal(); | |
793ff80c | 1155 | |
793ff80c | 1156 | if (fVerbose > 0) { |
1157 | printf("AliTRDdigitizer::MakeDigits -- "); | |
1158 | printf("Digitization for chamber %d\n",iDet); | |
1159 | } | |
da581aea | 1160 | |
793ff80c | 1161 | // Add a container for the digits of this detector |
1162 | digits = fDigits->GetDigits(iDet); | |
1163 | // Allocate memory space for the digits buffer | |
872a7aba | 1164 | digits->Allocate(nRowMax,nColMax,nTimeTotal); |
da581aea | 1165 | |
793ff80c | 1166 | // Get the signal container |
1167 | signals = (AliTRDdataArrayF *) signalsArray->At(iDet); | |
1168 | if (signals->GetNtime() == 0) { | |
1169 | // Create missing containers | |
872a7aba | 1170 | signals->Allocate(nRowMax,nColMax,nTimeTotal); |
793ff80c | 1171 | } |
1172 | else { | |
1173 | // Expand the container if neccessary | |
1174 | if (fCompress) signals->Expand(); | |
1175 | } | |
1176 | // Create the missing dictionary containers | |
1177 | for (iDict = 0; iDict < kNDict; iDict++) { | |
1178 | dictionary[iDict] = fDigits->GetDictionary(iDet,iDict); | |
1179 | if (dictionary[iDict]->GetNtime() == 0) { | |
872a7aba | 1180 | dictionary[iDict]->Allocate(nRowMax,nColMax,nTimeTotal); |
793ff80c | 1181 | } |
1182 | } | |
f7336fa3 | 1183 | |
793ff80c | 1184 | Int_t nDigits = 0; |
1185 | ||
6244debe | 1186 | // Don't create noise in detectors that are switched off |
1187 | if (CheckDetector(plane,chamber,sector)) { | |
1188 | ||
1189 | // Create the digits for this chamber | |
872a7aba | 1190 | for (iRow = 0; iRow < nRowMax; iRow++ ) { |
1191 | for (iCol = 0; iCol < nColMax; iCol++ ) { | |
1192 | for (iTime = 0; iTime < nTimeTotal; iTime++) { | |
6244debe | 1193 | |
1194 | // Create summable digits | |
1195 | if (fSDigits) { | |
1196 | ||
872a7aba | 1197 | Float_t signalAmp = signals->GetDataUnchecked(iRow,iCol,iTime); |
6244debe | 1198 | Int_t adc = 0; |
1199 | if (signalAmp >= fSinRange) { | |
1200 | adc = ((Int_t) fSoutRange); | |
1201 | } | |
1202 | else { | |
1203 | adc = ((Int_t) (signalAmp * (fSoutRange / fSinRange))); | |
1204 | } | |
1205 | nDigits++; | |
872a7aba | 1206 | digits->SetDataUnchecked(iRow,iCol,iTime,adc); |
f7336fa3 | 1207 | |
c1e4b257 | 1208 | } |
6244debe | 1209 | // Create normal digits |
1210 | else { | |
1211 | ||
872a7aba | 1212 | Float_t signalAmp = signals->GetDataUnchecked(iRow,iCol,iTime); |
6244debe | 1213 | |
1214 | // Add the noise | |
1215 | signalAmp = TMath::Max((Double_t) gRandom->Gaus(signalAmp,fNoise),0.0); | |
1216 | // Convert to mV | |
1217 | signalAmp *= convert; | |
1218 | // Convert to ADC counts. Set the overflow-bit fADCoutRange if the | |
1219 | // signal is larger than fADCinRange | |
1220 | Int_t adc = 0; | |
1221 | if (signalAmp >= fADCinRange) { | |
1222 | adc = ((Int_t) fADCoutRange); | |
1223 | } | |
1224 | else { | |
1225 | adc = ((Int_t) (signalAmp * (fADCoutRange / fADCinRange))); | |
1226 | } | |
1227 | ||
1228 | // Store the amplitude of the digit if above threshold | |
1229 | if (adc > fADCthreshold) { | |
1230 | if (fVerbose > 2) { | |
1231 | printf(" iRow = %d, iCol = %d, iTime = %d\n" | |
1232 | ,iRow,iCol,iTime); | |
1233 | printf(" signal = %f, adc = %d\n",signalAmp,adc); | |
1234 | } | |
1235 | nDigits++; | |
872a7aba | 1236 | digits->SetDataUnchecked(iRow,iCol,iTime,adc); |
6244debe | 1237 | } |
f7336fa3 | 1238 | |
6244debe | 1239 | } |
1240 | ||
1241 | } | |
1242 | } | |
793ff80c | 1243 | } |
6244debe | 1244 | |
793ff80c | 1245 | } |
1246 | ||
1247 | // Compress the arrays | |
1248 | digits->Compress(1,0); | |
1249 | for (iDict = 0; iDict < kNDict; iDict++) { | |
1250 | dictionary[iDict]->Compress(1,0); | |
1251 | } | |
f7336fa3 | 1252 | |
793ff80c | 1253 | totalSizeDigits += digits->GetSize(); |
1254 | totalSizeDict0 += dictionary[0]->GetSize(); | |
1255 | totalSizeDict1 += dictionary[1]->GetSize(); | |
1256 | totalSizeDict2 += dictionary[2]->GetSize(); | |
f7336fa3 | 1257 | |
c1e4b257 | 1258 | Float_t nPixel = nRowMax * nColMax * nTimeMax; |
793ff80c | 1259 | printf("AliTRDdigitizer::MakeDigits -- "); |
c1e4b257 | 1260 | printf("Found %d digits in detector %d (%3.0f).\n" |
1261 | ,nDigits,iDet | |
1262 | ,100.0 * ((Float_t) nDigits) / nPixel); | |
da581aea | 1263 | |
793ff80c | 1264 | if (fCompress) signals->Compress(1,0); |
f7336fa3 | 1265 | |
f7336fa3 | 1266 | } |
1267 | ||
da581aea | 1268 | printf("AliTRDdigitizer::MakeDigits -- "); |
8230f242 | 1269 | printf("Total number of analyzed hits = %d\n",countHits); |
da581aea | 1270 | |
f7336fa3 | 1271 | printf("AliTRDdigitizer::MakeDigits -- "); |
1272 | printf("Total digits data size = %d, %d, %d, %d\n",totalSizeDigits | |
1273 | ,totalSizeDict0 | |
1274 | ,totalSizeDict1 | |
1275 | ,totalSizeDict2); | |
1276 | ||
1277 | return kTRUE; | |
1278 | ||
1279 | } | |
1280 | ||
793ff80c | 1281 | //_____________________________________________________________________________ |
1282 | Bool_t AliTRDdigitizer::CheckDetector(Int_t plane, Int_t chamber, Int_t sector) | |
1283 | { | |
1284 | // | |
1285 | // Checks whether a detector is enabled | |
1286 | // | |
1287 | ||
1288 | if ((fTRD->GetSensChamber() >= 0) && | |
1289 | (fTRD->GetSensChamber() != chamber)) return kFALSE; | |
1290 | if ((fTRD->GetSensPlane() >= 0) && | |
c1e4b257 | 1291 | (fTRD->GetSensPlane() != plane)) return kFALSE; |
793ff80c | 1292 | if ( fTRD->GetSensSector() >= 0) { |
1293 | Int_t sens1 = fTRD->GetSensSector(); | |
1294 | Int_t sens2 = sens1 + fTRD->GetSensSectorRange(); | |
1295 | sens2 -= ((Int_t) (sens2 / AliTRDgeometry::Nsect())) | |
1296 | * AliTRDgeometry::Nsect(); | |
1297 | if (sens1 < sens2) { | |
1298 | if ((sector < sens1) || (sector >= sens2)) return kFALSE; | |
1299 | } | |
1300 | else { | |
1301 | if ((sector < sens1) && (sector >= sens2)) return kFALSE; | |
1302 | } | |
1303 | } | |
1304 | ||
1305 | return kTRUE; | |
1306 | ||
1307 | } | |
1308 | ||
f7336fa3 | 1309 | //_____________________________________________________________________________ |
1310 | Bool_t AliTRDdigitizer::WriteDigits() | |
1311 | { | |
1312 | // | |
1313 | // Writes out the TRD-digits and the dictionaries | |
1314 | // | |
1315 | ||
1316 | // Create the branches | |
1317 | if (!(gAlice->TreeD()->GetBranch("TRDdigits"))) { | |
6244debe | 1318 | return kFALSE; |
f7336fa3 | 1319 | } |
1320 | ||
da581aea | 1321 | // Store the digits and the dictionary in the tree |
1322 | fDigits->WriteDigits(); | |
f7336fa3 | 1323 | |
1324 | // Write the new tree into the input file (use overwrite option) | |
71d9fa7b | 1325 | Char_t treeName[15]; |
f7336fa3 | 1326 | sprintf(treeName,"TreeD%d",fEvent); |
1327 | printf("AliTRDdigitizer::WriteDigits -- "); | |
1328 | printf("Write the digits tree %s for event %d.\n" | |
1329 | ,treeName,fEvent); | |
2ab0c725 | 1330 | gAlice->TreeD()->Write(treeName,TObject::kOverwrite); |
f7336fa3 | 1331 | |
1332 | return kTRUE; | |
1333 | ||
1334 | } | |
793ff80c | 1335 | |
1336 | //_____________________________________________________________________________ | |
db30bf0f | 1337 | Float_t AliTRDdigitizer::GetDiffusionL(Float_t vd, Float_t b) |
793ff80c | 1338 | { |
1339 | // | |
db30bf0f | 1340 | // Returns the longitudinal diffusion coefficient for a given drift |
1341 | // velocity <vd> and a B-field <b> for Xe/CO2 (15%). | |
1342 | // The values are according to a GARFIELD simulation. | |
793ff80c | 1343 | // |
1344 | ||
db30bf0f | 1345 | const Int_t kNb = 5; |
1346 | Float_t p0[kNb] = { 0.007440, 0.007493, 0.007513, 0.007672, 0.007831 }; | |
1347 | Float_t p1[kNb] = { 0.019252, 0.018912, 0.018636, 0.018012, 0.017343 }; | |
1348 | Float_t p2[kNb] = { -0.005042, -0.004926, -0.004867, -0.004650, -0.004424 }; | |
1349 | Float_t p3[kNb] = { 0.000195, 0.000189, 0.000195, 0.000182, 0.000169 }; | |
1350 | ||
1351 | Int_t ib = ((Int_t) (10 * (b - 0.15))); | |
1352 | ib = TMath::Max( 0,ib); | |
1353 | ib = TMath::Min(kNb,ib); | |
1354 | ||
1355 | Float_t diff = p0[ib] | |
1356 | + p1[ib] * vd | |
1357 | + p2[ib] * vd*vd | |
1358 | + p3[ib] * vd*vd*vd; | |
1359 | ||
1360 | return diff; | |
1361 | ||
1362 | } | |
1363 | ||
1364 | //_____________________________________________________________________________ | |
1365 | Float_t AliTRDdigitizer::GetDiffusionT(Float_t vd, Float_t b) | |
1366 | { | |
1367 | // | |
1368 | // Returns the transverse diffusion coefficient for a given drift | |
1369 | // velocity <vd> and a B-field <b> for Xe/CO2 (15%). | |
1370 | // The values are according to a GARFIELD simulation. | |
1371 | // | |
1372 | ||
1373 | const Int_t kNb = 5; | |
1374 | Float_t p0[kNb] = { 0.009550, 0.009599, 0.009674, 0.009757, 0.009850 }; | |
1375 | Float_t p1[kNb] = { 0.006667, 0.006539, 0.006359, 0.006153, 0.005925 }; | |
1376 | Float_t p2[kNb] = { -0.000853, -0.000798, -0.000721, -0.000635, -0.000541 }; | |
1377 | Float_t p3[kNb] = { 0.000131, 0.000122, 0.000111, 0.000098, 0.000085 }; | |
1378 | ||
1379 | Int_t ib = ((Int_t) (10 * (b - 0.15))); | |
1380 | ib = TMath::Max( 0,ib); | |
1381 | ib = TMath::Min(kNb,ib); | |
1382 | ||
1383 | Float_t diff = p0[ib] | |
1384 | + p1[ib] * vd | |
1385 | + p2[ib] * vd*vd | |
1386 | + p3[ib] * vd*vd*vd; | |
1387 | ||
1388 | return diff; | |
1389 | ||
1390 | } | |
1391 | ||
1392 | //_____________________________________________________________________________ | |
1393 | Float_t AliTRDdigitizer::GetOmegaTau(Float_t vd, Float_t b) | |
1394 | { | |
1395 | // | |
1396 | // Returns omega*tau (tan(Lorentz-angle)) for a given drift velocity <vd> | |
1397 | // and a B-field <b> for Xe/CO2 (15%). | |
1398 | // The values are according to a GARFIELD simulation. | |
1399 | // | |
1400 | ||
1401 | const Int_t kNb = 5; | |
1402 | Float_t p0[kNb] = { 0.004810, 0.007412, 0.010252, 0.013409, 0.016888 }; | |
1403 | Float_t p1[kNb] = { 0.054875, 0.081534, 0.107333, 0.131983, 0.155455 }; | |
1404 | Float_t p2[kNb] = { -0.008682, -0.012896, -0.016987, -0.020880, -0.024623 }; | |
1405 | Float_t p3[kNb] = { 0.000155, 0.000238, 0.000330, 0.000428, 0.000541 }; | |
1406 | ||
1407 | Int_t ib = ((Int_t) (10 * (b - 0.15))); | |
1408 | ib = TMath::Max( 0,ib); | |
1409 | ib = TMath::Min(kNb,ib); | |
1410 | ||
1411 | Float_t alphaL = p0[ib] | |
1412 | + p1[ib] * vd | |
1413 | + p2[ib] * vd*vd | |
1414 | + p3[ib] * vd*vd*vd; | |
1415 | ||
1416 | return TMath::Tan(alphaL); | |
793ff80c | 1417 | |
1418 | } | |
1419 |