]>
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$ | |
e23fbb27 | 18 | Revision 1.30 2001/11/19 08:44:08 cblume |
19 | Fix bugs reported by Rene | |
20 | ||
a1c3aded | 21 | Revision 1.29 2001/11/14 19:44:25 hristov |
22 | Numeric const casted (Alpha) | |
23 | ||
20c69486 | 24 | Revision 1.28 2001/11/14 16:35:58 cblume |
25 | Inherits now from AliDetector | |
26 | ||
85cbec76 | 27 | Revision 1.27 2001/11/14 10:50:45 cblume |
28 | Changes in digits IO. Add merging of summable digits | |
29 | ||
abaf1f1d | 30 | Revision 1.26 2001/11/06 17:19:41 cblume |
31 | Add detailed geometry and simple simulator | |
32 | ||
16bf9884 | 33 | Revision 1.25 2001/06/27 09:54:44 cblume |
34 | Moved fField initialization to InitDetector() | |
35 | ||
88fd7ccb | 36 | Revision 1.24 2001/05/21 16:45:47 hristov |
37 | Last minute changes (C.Blume) | |
38 | ||
db30bf0f | 39 | Revision 1.23 2001/05/07 08:04:48 cblume |
40 | New TRF and PRF. Speedup of the code. Digits from amplification region included | |
41 | ||
872a7aba | 42 | Revision 1.22 2001/03/30 14:40:14 cblume |
43 | Update of the digitization parameter | |
44 | ||
a3c76cdc | 45 | Revision 1.21 2001/03/13 09:30:35 cblume |
46 | Update of digitization. Moved digit branch definition to AliTRD | |
47 | ||
6244debe | 48 | Revision 1.20 2001/02/25 20:19:00 hristov |
49 | Minor correction: loop variable declared only once for HP, Sun | |
50 | ||
c3a4830f | 51 | Revision 1.19 2001/02/14 18:22:26 cblume |
52 | Change in the geometry of the padplane | |
53 | ||
71d9fa7b | 54 | Revision 1.18 2001/01/26 19:56:57 hristov |
55 | Major upgrade of AliRoot code | |
56 | ||
2ab0c725 | 57 | Revision 1.17 2000/12/08 12:53:27 cblume |
58 | Change in Copy() function for HP-compiler | |
59 | ||
1948ba0c | 60 | Revision 1.16 2000/12/07 12:20:46 cblume |
61 | Go back to array compression. Use sampled PRF to speed up digitization | |
62 | ||
e153aaf6 | 63 | Revision 1.15 2000/11/23 14:34:08 cblume |
64 | Fixed bug in expansion routine of arrays (initialize buffers properly) | |
65 | ||
259b9e4b | 66 | Revision 1.14 2000/11/20 08:54:44 cblume |
67 | Switch off compression as default | |
68 | ||
c1e4b257 | 69 | Revision 1.13 2000/11/10 14:57:52 cblume |
70 | Changes in the geometry constants for the DEC compiler | |
71 | ||
dd56b762 | 72 | Revision 1.12 2000/11/01 14:53:20 cblume |
73 | Merge with TRD-develop | |
74 | ||
793ff80c | 75 | Revision 1.1.4.9 2000/10/26 17:00:22 cblume |
76 | Fixed bug in CheckDetector() | |
77 | ||
78 | Revision 1.1.4.8 2000/10/23 13:41:35 cblume | |
79 | Added protection against Log(0) in the gas gain calulation | |
80 | ||
81 | Revision 1.1.4.7 2000/10/17 02:27:34 cblume | |
82 | Get rid of global constants | |
83 | ||
84 | Revision 1.1.4.6 2000/10/16 01:16:53 cblume | |
85 | Changed timebin 0 to be the one closest to the readout | |
86 | ||
87 | Revision 1.1.4.5 2000/10/15 23:34:29 cblume | |
88 | Faster version of the digitizer | |
89 | ||
90 | Revision 1.1.4.4 2000/10/06 16:49:46 cblume | |
91 | Made Getters const | |
92 | ||
93 | Revision 1.1.4.3 2000/10/04 16:34:58 cblume | |
94 | Replace include files by forward declarations | |
95 | ||
96 | Revision 1.1.4.2 2000/09/22 14:41:10 cblume | |
97 | Bug fix in PRF. Included time response. New structure | |
98 | ||
eda4336d | 99 | Revision 1.10 2000/10/05 07:27:53 cblume |
100 | Changes in the header-files by FCA | |
101 | ||
6798b56e | 102 | Revision 1.9 2000/10/02 21:28:19 fca |
103 | Removal of useless dependecies via forward declarations | |
104 | ||
94de3818 | 105 | Revision 1.8 2000/06/09 11:10:07 cblume |
106 | Compiler warnings and coding conventions, next round | |
107 | ||
dd9a6ee3 | 108 | Revision 1.7 2000/06/08 18:32:58 cblume |
109 | Make code compliant to coding conventions | |
110 | ||
8230f242 | 111 | Revision 1.6 2000/06/07 16:27:32 cblume |
112 | Try to remove compiler warnings on Sun and HP | |
113 | ||
9d0b222b | 114 | Revision 1.5 2000/05/09 16:38:57 cblume |
115 | Removed PadResponse(). Merge problem | |
116 | ||
f0a7bf65 | 117 | Revision 1.4 2000/05/08 15:53:45 cblume |
118 | Resolved merge conflict | |
119 | ||
da581aea | 120 | Revision 1.3 2000/04/28 14:49:27 cblume |
121 | Only one declaration of iDict in MakeDigits() | |
122 | ||
123 | Revision 1.1.4.1 2000/05/08 14:42:04 cblume | |
124 | Introduced AliTRDdigitsManager | |
28329a48 | 125 | |
1befd3b2 | 126 | Revision 1.1 2000/02/28 19:00:13 cblume |
127 | Add new TRD classes | |
128 | ||
f7336fa3 | 129 | */ |
130 | ||
131 | /////////////////////////////////////////////////////////////////////////////// | |
132 | // // | |
133 | // Creates and handles digits from TRD hits // | |
abaf1f1d | 134 | // Author: C. Blume (C.Blume@gsi.de) // |
f7336fa3 | 135 | // // |
136 | // The following effects are included: // | |
137 | // - Diffusion // | |
138 | // - ExB effects // | |
139 | // - Gas gain including fluctuations // | |
140 | // - Pad-response (simple Gaussian approximation) // | |
abaf1f1d | 141 | // - Time-response // |
f7336fa3 | 142 | // - Electronics noise // |
143 | // - Electronics gain // | |
144 | // - Digitization // | |
145 | // - ADC threshold // | |
146 | // The corresponding parameter can be adjusted via the various // | |
147 | // Set-functions. If these parameters are not explicitly set, default // | |
148 | // values are used (see Init-function). // | |
abaf1f1d | 149 | // As an example on how to use this class to produce digits from hits // |
150 | // have a look at the macro hits2digits.C // | |
151 | // The production of summable digits is demonstrated in hits2sdigits.C // | |
152 | // and the subsequent conversion of the s-digits into normal digits is // | |
153 | // explained in sdigits2digits.C. // | |
f7336fa3 | 154 | // // |
155 | /////////////////////////////////////////////////////////////////////////////// | |
156 | ||
6798b56e | 157 | #include <stdlib.h> |
158 | ||
f7336fa3 | 159 | #include <TMath.h> |
160 | #include <TVector.h> | |
161 | #include <TRandom.h> | |
94de3818 | 162 | #include <TROOT.h> |
163 | #include <TTree.h> | |
793ff80c | 164 | #include <TFile.h> |
165 | #include <TF1.h> | |
abaf1f1d | 166 | #include <TList.h> |
85cbec76 | 167 | #include <TTask.h> |
793ff80c | 168 | |
169 | #include "AliRun.h" | |
db30bf0f | 170 | #include "AliMagF.h" |
85cbec76 | 171 | #include "AliRunDigitizer.h" |
f7336fa3 | 172 | |
173 | #include "AliTRD.h" | |
793ff80c | 174 | #include "AliTRDhit.h" |
f7336fa3 | 175 | #include "AliTRDdigitizer.h" |
da581aea | 176 | #include "AliTRDdataArrayI.h" |
177 | #include "AliTRDdataArrayF.h" | |
793ff80c | 178 | #include "AliTRDsegmentArray.h" |
da581aea | 179 | #include "AliTRDdigitsManager.h" |
793ff80c | 180 | #include "AliTRDgeometry.h" |
f7336fa3 | 181 | |
182 | ClassImp(AliTRDdigitizer) | |
183 | ||
184 | //_____________________________________________________________________________ | |
85cbec76 | 185 | AliTRDdigitizer::AliTRDdigitizer() |
f7336fa3 | 186 | { |
187 | // | |
188 | // AliTRDdigitizer default constructor | |
189 | // | |
190 | ||
abaf1f1d | 191 | fInputFile = NULL; |
192 | fDigitsManager = NULL; | |
193 | fSDigitsManagerList = NULL; | |
194 | fSDigitsManager = NULL; | |
195 | fTRD = NULL; | |
196 | fGeo = NULL; | |
197 | fPRFsmp = NULL; | |
198 | fTRFsmp = NULL; | |
e23fbb27 | 199 | fCTsmp = NULL; |
200 | ||
201 | fMasks = 0; | |
abaf1f1d | 202 | |
203 | fEvent = 0; | |
204 | fGasGain = 0.0; | |
205 | fNoise = 0.0; | |
206 | fChipGain = 0.0; | |
207 | fADCoutRange = 0.0; | |
208 | fADCinRange = 0.0; | |
209 | fADCthreshold = 0; | |
210 | fDiffusionOn = 0; | |
211 | fDiffusionT = 0.0; | |
212 | fDiffusionL = 0.0; | |
213 | fElAttachOn = 0; | |
214 | fElAttachProp = 0.0; | |
215 | fExBOn = 0; | |
216 | fOmegaTau = 0.0; | |
217 | fPRFOn = 0; | |
218 | fTRFOn = 0; | |
e23fbb27 | 219 | fCTOn = 0; |
220 | fTCOn = 0; | |
abaf1f1d | 221 | fDriftVelocity = 0.0; |
222 | fPadCoupling = 0.0; | |
223 | fTimeCoupling = 0.0; | |
224 | fTimeBinWidth = 0.0; | |
225 | fField = 0.0; | |
e23fbb27 | 226 | fTiltingAngle = 0.0; |
abaf1f1d | 227 | |
228 | fPRFbin = 0; | |
229 | fPRFlo = 0.0; | |
230 | fPRFhi = 0.0; | |
231 | fPRFwid = 0.0; | |
232 | fPRFpad = 0; | |
233 | fTRFbin = 0; | |
234 | fTRFlo = 0.0; | |
235 | fTRFhi = 0.0; | |
236 | fTRFwid = 0.0; | |
e23fbb27 | 237 | fTCnexp = 0; |
abaf1f1d | 238 | |
239 | fCompress = kTRUE; | |
e23fbb27 | 240 | fDebug = 0; |
abaf1f1d | 241 | fSDigits = kFALSE; |
242 | fSDigitsScale = 0.0; | |
f7336fa3 | 243 | |
244 | } | |
245 | ||
246 | //_____________________________________________________________________________ | |
247 | AliTRDdigitizer::AliTRDdigitizer(const Text_t *name, const Text_t *title) | |
85cbec76 | 248 | :AliDigitizer(name,title) |
f7336fa3 | 249 | { |
250 | // | |
85cbec76 | 251 | // AliTRDdigitizer constructor |
252 | // | |
253 | ||
254 | fInputFile = NULL; | |
255 | ||
256 | fDigitsManager = NULL; | |
257 | fSDigitsManager = NULL; | |
258 | fSDigitsManagerList = NULL; | |
259 | ||
260 | fTRD = NULL; | |
261 | fGeo = NULL; | |
262 | fPRFsmp = NULL; | |
263 | fTRFsmp = NULL; | |
e23fbb27 | 264 | fCTsmp = NULL; |
265 | ||
266 | fMasks = 0; | |
85cbec76 | 267 | |
268 | fEvent = 0; | |
269 | ||
270 | fCompress = kTRUE; | |
e23fbb27 | 271 | fDebug = 0; |
85cbec76 | 272 | fSDigits = kFALSE; |
273 | ||
274 | Init(); | |
275 | ||
276 | } | |
277 | ||
278 | //_____________________________________________________________________________ | |
279 | AliTRDdigitizer::AliTRDdigitizer(AliRunDigitizer *manager | |
280 | , const Text_t *name, const Text_t *title) | |
281 | :AliDigitizer(manager,name,title) | |
282 | { | |
283 | // | |
284 | // AliTRDdigitizer constructor | |
f7336fa3 | 285 | // |
286 | ||
abaf1f1d | 287 | fInputFile = NULL; |
288 | ||
289 | fDigitsManager = NULL; | |
290 | fSDigitsManager = NULL; | |
291 | fSDigitsManagerList = NULL; | |
f7336fa3 | 292 | |
abaf1f1d | 293 | fTRD = NULL; |
294 | fGeo = NULL; | |
295 | fPRFsmp = NULL; | |
296 | fTRFsmp = NULL; | |
e23fbb27 | 297 | fCTsmp = NULL; |
298 | ||
299 | fMasks = 0; | |
f7336fa3 | 300 | |
abaf1f1d | 301 | fEvent = 0; |
302 | ||
303 | fCompress = kTRUE; | |
e23fbb27 | 304 | fDebug = 0; |
abaf1f1d | 305 | fSDigits = kFALSE; |
793ff80c | 306 | |
f7336fa3 | 307 | Init(); |
308 | ||
309 | } | |
310 | ||
8230f242 | 311 | //_____________________________________________________________________________ |
dd9a6ee3 | 312 | AliTRDdigitizer::AliTRDdigitizer(const AliTRDdigitizer &d) |
8230f242 | 313 | { |
314 | // | |
315 | // AliTRDdigitizer copy constructor | |
316 | // | |
317 | ||
dd9a6ee3 | 318 | ((AliTRDdigitizer &) d).Copy(*this); |
8230f242 | 319 | |
320 | } | |
321 | ||
f7336fa3 | 322 | //_____________________________________________________________________________ |
323 | AliTRDdigitizer::~AliTRDdigitizer() | |
324 | { | |
8230f242 | 325 | // |
326 | // AliTRDdigitizer destructor | |
327 | // | |
f7336fa3 | 328 | |
329 | if (fInputFile) { | |
330 | fInputFile->Close(); | |
331 | delete fInputFile; | |
abaf1f1d | 332 | fInputFile = NULL; |
333 | } | |
334 | ||
335 | if (fDigitsManager) { | |
336 | delete fDigitsManager; | |
337 | fDigitsManager = NULL; | |
f7336fa3 | 338 | } |
339 | ||
abaf1f1d | 340 | if (fSDigitsManager) { |
341 | delete fSDigitsManager; | |
342 | fSDigitsManager = NULL; | |
f7336fa3 | 343 | } |
344 | ||
abaf1f1d | 345 | if (fSDigitsManagerList) { |
346 | fSDigitsManagerList->Delete(); | |
347 | delete fSDigitsManagerList; | |
348 | fSDigitsManagerList = NULL; | |
349 | } | |
a1c3aded | 350 | |
351 | if (fTRFsmp) { | |
e23fbb27 | 352 | delete [] fTRFsmp; |
a1c3aded | 353 | fTRFsmp = NULL; |
354 | } | |
355 | ||
356 | if (fPRFsmp) { | |
e23fbb27 | 357 | delete [] fPRFsmp; |
a1c3aded | 358 | fPRFsmp = NULL; |
359 | } | |
360 | ||
e23fbb27 | 361 | if (fCTsmp) { |
362 | delete [] fCTsmp; | |
363 | fCTsmp = NULL; | |
364 | } | |
365 | ||
366 | if (fMasks) { | |
367 | delete [] fMasks; | |
368 | fMasks = 0; | |
369 | } | |
370 | ||
f7336fa3 | 371 | } |
372 | ||
8230f242 | 373 | //_____________________________________________________________________________ |
dd9a6ee3 | 374 | AliTRDdigitizer &AliTRDdigitizer::operator=(const AliTRDdigitizer &d) |
375 | { | |
376 | // | |
377 | // Assignment operator | |
378 | // | |
379 | ||
380 | if (this != &d) ((AliTRDdigitizer &) d).Copy(*this); | |
381 | return *this; | |
382 | ||
383 | } | |
384 | ||
385 | //_____________________________________________________________________________ | |
386 | void AliTRDdigitizer::Copy(TObject &d) | |
8230f242 | 387 | { |
388 | // | |
389 | // Copy function | |
390 | // | |
391 | ||
1948ba0c | 392 | Int_t iBin; |
393 | ||
abaf1f1d | 394 | ((AliTRDdigitizer &) d).fInputFile = NULL; |
395 | ((AliTRDdigitizer &) d).fSDigitsManagerList = NULL; | |
396 | ((AliTRDdigitizer &) d).fSDigitsManager = NULL; | |
397 | ((AliTRDdigitizer &) d).fDigitsManager = NULL; | |
398 | ((AliTRDdigitizer &) d).fTRD = NULL; | |
399 | ((AliTRDdigitizer &) d).fGeo = NULL; | |
400 | ||
e23fbb27 | 401 | ((AliTRDdigitizer &) d).fMasks = 0; |
402 | ||
abaf1f1d | 403 | ((AliTRDdigitizer &) d).fEvent = 0; |
404 | ||
405 | ((AliTRDdigitizer &) d).fGasGain = fGasGain; | |
406 | ((AliTRDdigitizer &) d).fNoise = fNoise; | |
407 | ((AliTRDdigitizer &) d).fChipGain = fChipGain; | |
408 | ((AliTRDdigitizer &) d).fADCoutRange = fADCoutRange; | |
409 | ((AliTRDdigitizer &) d).fADCinRange = fADCinRange; | |
410 | ((AliTRDdigitizer &) d).fADCthreshold = fADCthreshold; | |
411 | ((AliTRDdigitizer &) d).fDiffusionOn = fDiffusionOn; | |
412 | ((AliTRDdigitizer &) d).fDiffusionT = fDiffusionT; | |
413 | ((AliTRDdigitizer &) d).fDiffusionL = fDiffusionL; | |
414 | ((AliTRDdigitizer &) d).fElAttachOn = fElAttachOn; | |
415 | ((AliTRDdigitizer &) d).fElAttachProp = fElAttachProp; | |
416 | ((AliTRDdigitizer &) d).fExBOn = fExBOn; | |
417 | ((AliTRDdigitizer &) d).fOmegaTau = fOmegaTau; | |
418 | ((AliTRDdigitizer &) d).fLorentzFactor = fLorentzFactor; | |
419 | ((AliTRDdigitizer &) d).fDriftVelocity = fDriftVelocity; | |
420 | ((AliTRDdigitizer &) d).fPadCoupling = fPadCoupling; | |
421 | ((AliTRDdigitizer &) d).fTimeCoupling = fTimeCoupling; | |
422 | ((AliTRDdigitizer &) d).fTimeBinWidth = fTimeBinWidth; | |
423 | ((AliTRDdigitizer &) d).fField = fField; | |
424 | ((AliTRDdigitizer &) d).fPRFOn = fPRFOn; | |
425 | ((AliTRDdigitizer &) d).fTRFOn = fTRFOn; | |
e23fbb27 | 426 | ((AliTRDdigitizer &) d).fCTOn = fCTOn; |
427 | ((AliTRDdigitizer &) d).fTCOn = fTCOn; | |
428 | ((AliTRDdigitizer &) d).fTiltingAngle = fTiltingAngle; | |
abaf1f1d | 429 | |
430 | ((AliTRDdigitizer &) d).fCompress = fCompress; | |
e23fbb27 | 431 | ((AliTRDdigitizer &) d).fDebug = fDebug ; |
abaf1f1d | 432 | ((AliTRDdigitizer &) d).fSDigits = fSDigits; |
433 | ((AliTRDdigitizer &) d).fSDigitsScale = fSDigitsScale; | |
434 | ||
435 | ((AliTRDdigitizer &) d).fPRFbin = fPRFbin; | |
436 | ((AliTRDdigitizer &) d).fPRFlo = fPRFlo; | |
437 | ((AliTRDdigitizer &) d).fPRFhi = fPRFhi; | |
438 | ((AliTRDdigitizer &) d).fPRFwid = fPRFwid; | |
439 | ((AliTRDdigitizer &) d).fPRFpad = fPRFpad; | |
e23fbb27 | 440 | if (((AliTRDdigitizer &) d).fPRFsmp) delete [] ((AliTRDdigitizer &) d).fPRFsmp; |
e153aaf6 | 441 | ((AliTRDdigitizer &) d).fPRFsmp = new Float_t[fPRFbin]; |
1948ba0c | 442 | for (iBin = 0; iBin < fPRFbin; iBin++) { |
e153aaf6 | 443 | ((AliTRDdigitizer &) d).fPRFsmp[iBin] = fPRFsmp[iBin]; |
444 | } | |
abaf1f1d | 445 | ((AliTRDdigitizer &) d).fTRFbin = fTRFbin; |
446 | ((AliTRDdigitizer &) d).fTRFlo = fTRFlo; | |
447 | ((AliTRDdigitizer &) d).fTRFhi = fTRFhi; | |
448 | ((AliTRDdigitizer &) d).fTRFwid = fTRFwid; | |
e23fbb27 | 449 | if (((AliTRDdigitizer &) d).fTRFsmp) delete [] ((AliTRDdigitizer &) d).fTRFsmp; |
872a7aba | 450 | ((AliTRDdigitizer &) d).fTRFsmp = new Float_t[fTRFbin]; |
1948ba0c | 451 | for (iBin = 0; iBin < fTRFbin; iBin++) { |
872a7aba | 452 | ((AliTRDdigitizer &) d).fTRFsmp[iBin] = fTRFsmp[iBin]; |
6244debe | 453 | } |
e23fbb27 | 454 | |
455 | if (((AliTRDdigitizer &) d).fCTsmp) delete [] ((AliTRDdigitizer &) d).fCTsmp; | |
456 | ((AliTRDdigitizer &) d).fCTsmp = new Float_t[fTRFbin]; | |
457 | for (iBin = 0; iBin < fTRFbin; iBin++) { | |
458 | ((AliTRDdigitizer &) d).fCTsmp[iBin] = fCTsmp[iBin]; | |
459 | } | |
460 | ||
461 | ((AliTRDdigitizer &) d).fTCnexp = fTCnexp; | |
462 | ||
463 | } | |
464 | ||
465 | //_____________________________________________________________________________ | |
466 | Float_t AliTRDdigitizer::CrossTalk(Float_t time) | |
467 | { | |
468 | // | |
469 | // Applies the pad-pad capacitive cross talk | |
470 | // | |
471 | ||
472 | Int_t iBin = ((Int_t) ((time - fTRFlo) / fTRFwid)); | |
473 | if ((iBin >= 0) && (iBin < fTRFbin)) { | |
474 | return fCTsmp[iBin]; | |
475 | } | |
476 | else { | |
477 | return 0.0; | |
478 | } | |
479 | ||
8230f242 | 480 | } |
481 | ||
f7336fa3 | 482 | //_____________________________________________________________________________ |
483 | Int_t AliTRDdigitizer::Diffusion(Float_t driftlength, Float_t *xyz) | |
484 | { | |
485 | // | |
486 | // Applies the diffusion smearing to the position of a single electron | |
487 | // | |
488 | ||
489 | Float_t driftSqrt = TMath::Sqrt(driftlength); | |
490 | Float_t sigmaT = driftSqrt * fDiffusionT; | |
491 | Float_t sigmaL = driftSqrt * fDiffusionL; | |
492 | xyz[0] = gRandom->Gaus(xyz[0], sigmaL * fLorentzFactor); | |
493 | xyz[1] = gRandom->Gaus(xyz[1], sigmaT * fLorentzFactor); | |
494 | xyz[2] = gRandom->Gaus(xyz[2], sigmaT); | |
793ff80c | 495 | |
f7336fa3 | 496 | return 1; |
497 | ||
498 | } | |
499 | ||
500 | //_____________________________________________________________________________ | |
501 | Int_t AliTRDdigitizer::ExB(Float_t driftlength, Float_t *xyz) | |
502 | { | |
503 | // | |
504 | // Applies E x B effects to the position of a single electron | |
505 | // | |
506 | ||
507 | xyz[0] = xyz[0]; | |
793ff80c | 508 | xyz[1] = xyz[1] + fOmegaTau * driftlength; |
f7336fa3 | 509 | xyz[2] = xyz[2]; |
510 | ||
511 | return 1; | |
512 | ||
513 | } | |
514 | ||
793ff80c | 515 | //_____________________________________________________________________________ |
e23fbb27 | 516 | Int_t AliTRDdigitizer::PadResponse(Float_t signal, Float_t dist |
517 | , Int_t plane, Float_t *pad) | |
793ff80c | 518 | { |
519 | // | |
520 | // Applies the pad response | |
521 | // | |
522 | ||
e23fbb27 | 523 | const Int_t kNplan = AliTRDgeometry::kNplan; |
524 | ||
525 | Int_t iBin = ((Int_t) (( - dist - fPRFlo) / fPRFwid)); | |
526 | Int_t iOff = plane * fPRFbin; | |
e153aaf6 | 527 | |
e23fbb27 | 528 | Int_t iBin0 = iBin - fPRFpad + iOff; |
529 | Int_t iBin1 = iBin + iOff; | |
530 | Int_t iBin2 = iBin + fPRFpad + iOff; | |
e153aaf6 | 531 | |
e23fbb27 | 532 | if ((iBin0 >= 0) && (iBin2 < (fPRFbin*kNplan))) { |
e153aaf6 | 533 | |
534 | pad[0] = signal * fPRFsmp[iBin0]; | |
535 | pad[1] = signal * fPRFsmp[iBin1]; | |
536 | pad[2] = signal * fPRFsmp[iBin2]; | |
537 | ||
793ff80c | 538 | return 1; |
e153aaf6 | 539 | |
793ff80c | 540 | } |
541 | else { | |
e153aaf6 | 542 | |
793ff80c | 543 | return 0; |
e153aaf6 | 544 | |
793ff80c | 545 | } |
546 | ||
547 | } | |
548 | ||
549 | //_____________________________________________________________________________ | |
550 | Float_t AliTRDdigitizer::TimeResponse(Float_t time) | |
551 | { | |
552 | // | |
553 | // Applies the preamp shaper time response | |
554 | // | |
555 | ||
556 | Int_t iBin = ((Int_t) ((time - fTRFlo) / fTRFwid)); | |
557 | if ((iBin >= 0) && (iBin < fTRFbin)) { | |
872a7aba | 558 | return fTRFsmp[iBin]; |
793ff80c | 559 | } |
560 | else { | |
561 | return 0.0; | |
562 | } | |
563 | ||
564 | } | |
565 | ||
e23fbb27 | 566 | //_____________________________________________________________________________ |
567 | Float_t AliTRDdigitizer::Col0Tilted(Float_t col0, Float_t rowOffset | |
568 | , Int_t plane) | |
569 | { | |
570 | // | |
571 | // Calculates col0 for tilted pads | |
572 | // | |
573 | ||
574 | Float_t diff = fTiltingAngle * rowOffset; | |
575 | return (col0 + TMath::Power(-1.0,plane) * diff); | |
576 | ||
577 | } | |
578 | ||
579 | //_____________________________________________________________________________ | |
580 | void AliTRDdigitizer::Exec(Option_t* option) | |
581 | { | |
582 | // | |
583 | // Executes the merging | |
584 | // | |
585 | ||
586 | Int_t iInput; | |
587 | ||
588 | AliTRDdigitsManager *sdigitsManager; | |
589 | ||
590 | TString optionString = option; | |
591 | if (optionString.Contains("deb")) { | |
592 | fDebug = 1; | |
593 | if (optionString.Contains("2")) { | |
594 | fDebug = 2; | |
595 | } | |
596 | printf("<AliTRDdigitizer::Exec> "); | |
597 | printf("Called with debug option %d\n",fDebug); | |
598 | } | |
599 | ||
600 | Int_t nInput = fManager->GetNinputs(); | |
601 | fMasks = new Int_t[nInput]; | |
602 | for (iInput = 0; iInput < nInput; iInput++) { | |
603 | fMasks[iInput] = fManager->GetMask(iInput); | |
604 | } | |
605 | ||
606 | // Set the event number | |
607 | fEvent = gAlice->GetEvNumber(); | |
608 | ||
609 | // Initialization | |
610 | InitDetector(); | |
611 | ||
612 | for (iInput = 0; iInput < nInput; iInput++) { | |
613 | ||
614 | if (fDebug > 0) { | |
615 | printf("<AliTRDdigitizer::Exec> "); | |
616 | printf("Add input stream %d\n",iInput); | |
617 | } | |
618 | ||
619 | // Read the s-digits via digits manager | |
620 | sdigitsManager = new AliTRDdigitsManager(); | |
621 | sdigitsManager->SetDebug(fDebug); | |
622 | sdigitsManager->SetSDigits(kTRUE); | |
623 | sdigitsManager->ReadDigits(fManager->GetInputTreeTRDS(iInput)); | |
624 | ||
625 | // Add the s-digits to the input list | |
626 | AddSDigitsManager(sdigitsManager); | |
627 | ||
628 | } | |
629 | ||
630 | // Convert the s-digits to normal digits | |
631 | if (fDebug > 0) { | |
632 | printf("<AliTRDdigitizer::Exec> "); | |
633 | printf("Do the conversion\n"); | |
634 | } | |
635 | SDigits2Digits(); | |
636 | ||
637 | // Store the digits | |
638 | if (fDebug > 0) { | |
639 | printf("<AliTRDdigitizer::Exec> "); | |
640 | printf("Write the digits\n"); | |
641 | } | |
642 | fDigitsManager->MakeBranch(fManager->GetTreeDTRD()); | |
643 | fDigitsManager->WriteDigits(); | |
644 | if (fDebug > 0) { | |
645 | printf("<AliTRDdigitizer::Exec> "); | |
646 | printf("Done\n"); | |
647 | } | |
648 | ||
649 | } | |
650 | ||
f7336fa3 | 651 | //_____________________________________________________________________________ |
85cbec76 | 652 | Bool_t AliTRDdigitizer::Init() |
f7336fa3 | 653 | { |
654 | // | |
655 | // Initializes the digitization procedure with standard values | |
656 | // | |
657 | ||
658 | // The default parameter for the digitization | |
db30bf0f | 659 | fGasGain = 2800.; |
660 | fChipGain = 6.1; | |
6244debe | 661 | fNoise = 1000.; |
662 | fADCoutRange = 1023.; // 10-bit ADC | |
a3c76cdc | 663 | fADCinRange = 1000.; // 1V input range |
6244debe | 664 | fADCthreshold = 1; |
665 | ||
666 | // For the summable digits | |
abaf1f1d | 667 | fSDigitsScale = 100.; |
f7336fa3 | 668 | |
db30bf0f | 669 | // The drift velocity (cm / mus) |
670 | fDriftVelocity = 1.5; | |
671 | ||
db30bf0f | 672 | // Diffusion on |
6244debe | 673 | fDiffusionOn = 1; |
db30bf0f | 674 | |
675 | // E x B effects | |
676 | fExBOn = 0; | |
f7336fa3 | 677 | |
678 | // Propability for electron attachment | |
6244debe | 679 | fElAttachOn = 0; |
680 | fElAttachProp = 0.0; | |
f7336fa3 | 681 | |
da581aea | 682 | // The pad response function |
e23fbb27 | 683 | fPRFOn = 1; |
872a7aba | 684 | |
685 | // The time response function | |
e23fbb27 | 686 | fTRFOn = 1; |
687 | ||
688 | // The cross talk | |
689 | fCTOn = 0; | |
690 | ||
691 | // The tail cancelation | |
692 | fTCOn = 1; | |
693 | ||
694 | // The number of exponentials | |
695 | fTCnexp = 2; | |
da581aea | 696 | |
6244debe | 697 | // The pad coupling factor (same number as for the TPC) |
698 | fPadCoupling = 0.5; | |
699 | ||
700 | // The time coupling factor (same number as for the TPC) | |
701 | fTimeCoupling = 0.4; | |
702 | ||
e23fbb27 | 703 | // The tilting angle for the readout pads |
704 | SetTiltingAngle(5.0); | |
705 | ||
85cbec76 | 706 | return kTRUE; |
707 | ||
6244debe | 708 | } |
709 | ||
710 | //_____________________________________________________________________________ | |
85cbec76 | 711 | Bool_t AliTRDdigitizer::ReInit() |
6244debe | 712 | { |
713 | // | |
872a7aba | 714 | // Reinitializes the digitization procedure after a change in the parameter |
6244debe | 715 | // |
716 | ||
872a7aba | 717 | if (!fGeo) { |
718 | printf("AliTRDdigitizer::ReInit -- "); | |
719 | printf("No geometry defined. Run InitDetector() first\n"); | |
85cbec76 | 720 | return kFALSE; |
872a7aba | 721 | } |
722 | ||
6244debe | 723 | // Calculate the time bin width in ns |
724 | fTimeBinWidth = fGeo->GetTimeBinSize() / fDriftVelocity * 1000.0; | |
725 | ||
872a7aba | 726 | // The range and the binwidth for the sampled TRF |
727 | fTRFbin = 100; | |
db30bf0f | 728 | // Start 0.2 mus before the signal |
729 | fTRFlo = -0.2 * fDriftVelocity; | |
872a7aba | 730 | // End the maximum driftlength after the signal |
731 | fTRFhi = AliTRDgeometry::DrThick() | |
732 | + fGeo->GetTimeAfter() * fGeo->GetTimeBinSize(); | |
733 | fTRFwid = (fTRFhi - fTRFlo) / ((Float_t) fTRFbin); | |
6244debe | 734 | |
db30bf0f | 735 | // Transverse and longitudinal diffusion coefficients (Xe/CO2) |
736 | fDiffusionT = GetDiffusionT(fDriftVelocity,fField); | |
737 | fDiffusionL = GetDiffusionL(fDriftVelocity,fField); | |
738 | ||
739 | // omega * tau.= tan(Lorentz-angle) | |
740 | fOmegaTau = GetOmegaTau(fDriftVelocity,fField); | |
741 | ||
6244debe | 742 | // The Lorentz factor |
743 | if (fExBOn) { | |
744 | fLorentzFactor = 1.0 / (1.0 + fOmegaTau*fOmegaTau); | |
745 | } | |
746 | else { | |
747 | fLorentzFactor = 1.0; | |
748 | } | |
793ff80c | 749 | |
85cbec76 | 750 | return kTRUE; |
751 | ||
793ff80c | 752 | } |
753 | ||
754 | //_____________________________________________________________________________ | |
6244debe | 755 | void AliTRDdigitizer::SampleTRF() |
793ff80c | 756 | { |
757 | // | |
6244debe | 758 | // Samples the time response function |
e23fbb27 | 759 | // |
760 | // New TRF from Venelin Angelov, simulated with CADENCE | |
761 | // Pad-ground capacitance = 25 pF | |
762 | // Pad-pad cross talk capacitance = 6 pF | |
793ff80c | 763 | // |
764 | ||
872a7aba | 765 | Int_t ipos1; |
766 | Int_t ipos2; | |
767 | Float_t diff; | |
768 | ||
e23fbb27 | 769 | const Int_t kNpasa = 252; |
770 | ||
771 | Float_t time[kNpasa] = { -0.220000, -0.210000, -0.200000, -0.190000 | |
772 | , -0.180000, -0.170000, -0.160000, -0.150000 | |
773 | , -0.140000, -0.130000, -0.120000, -0.110000 | |
774 | , -0.100000, -0.090000, -0.080000, -0.070000 | |
775 | , -0.060000, -0.050000, -0.040000, -0.030000 | |
776 | , -0.020000, -0.010000, -0.000000, 0.010000 | |
777 | , 0.020000, 0.030000, 0.040000, 0.050000 | |
778 | , 0.060000, 0.070000, 0.080000, 0.090000 | |
779 | , 0.100000, 0.110000, 0.120000, 0.130000 | |
780 | , 0.140000, 0.150000, 0.160000, 0.170000 | |
781 | , 0.180000, 0.190000, 0.200000, 0.210000 | |
782 | , 0.220000, 0.230000, 0.240000, 0.250000 | |
783 | , 0.260000, 0.270000, 0.280000, 0.290000 | |
784 | , 0.300000, 0.310000, 0.320000, 0.330000 | |
785 | , 0.340000, 0.350000, 0.360000, 0.370000 | |
786 | , 0.380000, 0.390000, 0.400000, 0.410000 | |
787 | , 0.420000, 0.430000, 0.440000, 0.450000 | |
788 | , 0.460000, 0.470000, 0.480000, 0.490000 | |
789 | , 0.500000, 0.510000, 0.520000, 0.530000 | |
790 | , 0.540000, 0.550000, 0.560000, 0.570000 | |
791 | , 0.580000, 0.590000, 0.600000, 0.610000 | |
792 | , 0.620000, 0.630000, 0.640000, 0.650000 | |
793 | , 0.660000, 0.670000, 0.680000, 0.690000 | |
794 | , 0.700000, 0.710000, 0.720000, 0.730000 | |
795 | , 0.740000, 0.750000, 0.760000, 0.770000 | |
796 | , 0.780000, 0.790000, 0.800000, 0.810000 | |
797 | , 0.820000, 0.830000, 0.840000, 0.850000 | |
798 | , 0.860000, 0.870000, 0.880000, 0.890000 | |
799 | , 0.900000, 0.910000, 0.920000, 0.930000 | |
800 | , 0.940000, 0.950000, 0.960000, 0.970000 | |
801 | , 0.980000, 0.990000, 1.000000, 1.010000 | |
802 | , 1.020000, 1.030000, 1.040000, 1.050000 | |
803 | , 1.060000, 1.070000, 1.080000, 1.090000 | |
804 | , 1.100000, 1.110000, 1.120000, 1.130000 | |
805 | , 1.140000, 1.150000, 1.160000, 1.170000 | |
806 | , 1.180000, 1.190000, 1.200000, 1.210000 | |
807 | , 1.220000, 1.230000, 1.240000, 1.250000 | |
808 | , 1.260000, 1.270000, 1.280000, 1.290000 | |
809 | , 1.300000, 1.310000, 1.320000, 1.330000 | |
810 | , 1.340000, 1.350000, 1.360000, 1.370000 | |
811 | , 1.380000, 1.390000, 1.400000, 1.410000 | |
812 | , 1.420000, 1.430000, 1.440000, 1.450000 | |
813 | , 1.460000, 1.470000, 1.480000, 1.490000 | |
814 | , 1.500000, 1.510000, 1.520000, 1.530000 | |
815 | , 1.540000, 1.550000, 1.560000, 1.570000 | |
816 | , 1.580000, 1.590000, 1.600000, 1.610000 | |
817 | , 1.620000, 1.630000, 1.640000, 1.650000 | |
818 | , 1.660000, 1.670000, 1.680000, 1.690000 | |
819 | , 1.700000, 1.710000, 1.720000, 1.730000 | |
820 | , 1.740000, 1.750000, 1.760000, 1.770000 | |
821 | , 1.780000, 1.790000, 1.800000, 1.810000 | |
822 | , 1.820000, 1.830000, 1.840000, 1.850000 | |
823 | , 1.860000, 1.870000, 1.880000, 1.890000 | |
824 | , 1.900000, 1.910000, 1.920000, 1.930000 | |
825 | , 1.940000, 1.950000, 1.960000, 1.970000 | |
826 | , 1.980000, 1.990000, 2.000000, 2.010000 | |
827 | , 2.020000, 2.030000, 2.040000, 2.050000 | |
828 | , 2.060000, 2.070000, 2.080000, 2.090000 | |
829 | , 2.100000, 2.110000, 2.120000, 2.130000 | |
830 | , 2.140000, 2.150000, 2.160000, 2.170000 | |
831 | , 2.180000, 2.190000, 2.200000, 2.210000 | |
832 | , 2.220000, 2.230000, 2.240000, 2.250000 | |
833 | , 2.260000, 2.270000, 2.280000, 2.290000 }; | |
834 | ||
835 | Float_t signal[kNpasa] = { 0.000000, 0.000000, 0.000000, 0.000000 | |
836 | , 0.000000, 0.000000, 0.000000, 0.000396 | |
837 | , 0.005096, 0.022877, 0.061891, 0.126614 | |
838 | , 0.215798, 0.324406, 0.444507, 0.566817 | |
839 | , 0.683465, 0.787089, 0.873159, 0.937146 | |
840 | , 0.979049, 0.999434, 1.000000, 0.983579 | |
841 | , 0.954134, 0.913364, 0.866365, 0.813703 | |
842 | , 0.759910, 0.706116, 0.653454, 0.603624 | |
843 | , 0.556625, 0.514156, 0.475085, 0.439977 | |
844 | , 0.408834, 0.380578, 0.355549, 0.333352 | |
845 | , 0.313647, 0.296093, 0.280351, 0.266195 | |
846 | , 0.253397, 0.241789, 0.231257, 0.221574 | |
847 | , 0.212627, 0.204417, 0.196772, 0.189581 | |
848 | , 0.182956, 0.176784, 0.171008, 0.165515 | |
849 | , 0.160419, 0.155606, 0.151076, 0.146716 | |
850 | , 0.142639, 0.138845, 0.135221, 0.131767 | |
851 | , 0.128482, 0.125368, 0.122424, 0.119592 | |
852 | , 0.116931, 0.114326, 0.111891, 0.109513 | |
853 | , 0.107248, 0.105096, 0.103058, 0.101019 | |
854 | , 0.099151, 0.097282, 0.095527, 0.093715 | |
855 | , 0.092129, 0.090544, 0.088958, 0.087429 | |
856 | , 0.086014, 0.084598, 0.083239, 0.081880 | |
857 | , 0.080634, 0.079388, 0.078143, 0.077010 | |
858 | , 0.075878, 0.074745, 0.073669, 0.072593 | |
859 | , 0.071574, 0.070612, 0.069649, 0.068686 | |
860 | , 0.067780, 0.066874, 0.066025, 0.065176 | |
861 | , 0.064326, 0.063533, 0.062684, 0.061948 | |
862 | , 0.061212, 0.060419, 0.059740, 0.059003 | |
863 | , 0.058324, 0.057644, 0.057022, 0.056342 | |
864 | , 0.055663, 0.055096, 0.054473, 0.053851 | |
865 | , 0.053284, 0.052718, 0.052152, 0.051585 | |
866 | , 0.051019, 0.050566, 0.050000, 0.049490 | |
867 | , 0.048981, 0.048528, 0.048018, 0.047508 | |
868 | , 0.047055, 0.046602, 0.046149, 0.045696 | |
869 | , 0.045300, 0.044904, 0.044451, 0.044054 | |
870 | , 0.043658, 0.043205, 0.042865, 0.042469 | |
871 | , 0.042072, 0.041733, 0.041336, 0.040997 | |
872 | , 0.040657, 0.040260, 0.039921, 0.039581 | |
873 | , 0.039241, 0.038958, 0.038618, 0.038335 | |
874 | , 0.037995, 0.037656, 0.037373, 0.037089 | |
875 | , 0.036806, 0.036467, 0.036183, 0.035900 | |
876 | , 0.035617, 0.035334, 0.035108, 0.034824 | |
877 | , 0.034541, 0.034315, 0.034032, 0.033805 | |
878 | , 0.033522, 0.033296, 0.033069, 0.032786 | |
879 | , 0.032559, 0.032333, 0.032106, 0.031880 | |
880 | , 0.031653, 0.031427, 0.031200, 0.030974 | |
881 | , 0.030804, 0.030578, 0.030351, 0.030125 | |
882 | , 0.029955, 0.029785, 0.029558, 0.029332 | |
883 | , 0.029162, 0.028992, 0.028766, 0.028596 | |
884 | , 0.028426, 0.028199, 0.028086, 0.027860 | |
885 | , 0.027746, 0.027633, 0.027463, 0.027293 | |
886 | , 0.027180, 0.027067, 0.026954, 0.026954 | |
887 | , 0.026840, 0.026727, 0.026727, 0.026614 | |
888 | , 0.026614, 0.026614, 0.026557, 0.026501 | |
889 | , 0.026501, 0.026501, 0.026501, 0.026501 | |
890 | , 0.026501, 0.026501, 0.026501, 0.026387 | |
891 | , 0.026387, 0.026387, 0.026387, 0.026387 | |
892 | , 0.026387, 0.026387, 0.026387, 0.026387 | |
893 | , 0.026387, 0.026387, 0.026387, 0.026387 | |
894 | , 0.026387, 0.026274, 0.026274, 0.026274 | |
895 | , 0.026274, 0.026274, 0.026274, 0.026274 | |
896 | , 0.026274, 0.026274, 0.026274, 0.026274 | |
897 | , 0.026274, 0.026274, 0.026274, 0.026161 }; | |
898 | ||
899 | Float_t xtalk[kNpasa] = { 0.000000, 0.000000, 0.000000, 0.000000 | |
900 | , 0.000000, 0.000000, 0.000000, 0.000113 | |
901 | , 0.000793, 0.003058, 0.007305, 0.013194 | |
902 | , 0.019706, 0.025821, 0.030634, 0.033465 | |
903 | , 0.034145, 0.032729, 0.029615, 0.025198 | |
904 | , 0.019989, 0.014496, 0.009003, 0.003964 | |
905 | , -0.000510, -0.004190, -0.007191, -0.009400 | |
906 | , -0.010872, -0.011835, -0.012288, -0.012288 | |
907 | , -0.012005, -0.011495, -0.010872, -0.010136 | |
908 | , -0.009343, -0.008607, -0.007871, -0.007191 | |
909 | , -0.006512, -0.005946, -0.005379, -0.004926 | |
910 | , -0.004473, -0.004077, -0.003737, -0.003398 | |
911 | , -0.003114, -0.002831, -0.002605, -0.002378 | |
912 | , -0.002208, -0.002039, -0.001869, -0.001699 | |
913 | , -0.001585, -0.001472, -0.001359, -0.001246 | |
914 | , -0.001132, -0.001019, -0.001019, -0.000906 | |
915 | , -0.000906, -0.000793, -0.000793, -0.000680 | |
916 | , -0.000680, -0.000680, -0.000566, -0.000566 | |
917 | , -0.000566, -0.000566, -0.000453, -0.000453 | |
918 | , -0.000453, -0.000453, -0.000453, -0.000453 | |
919 | , -0.000340, -0.000340, -0.000340, -0.000340 | |
920 | , -0.000340, -0.000340, -0.000340, -0.000340 | |
921 | , -0.000340, -0.000340, -0.000340, -0.000340 | |
922 | , -0.000340, -0.000227, -0.000227, -0.000227 | |
923 | , -0.000227, -0.000227, -0.000227, -0.000227 | |
924 | , -0.000227, -0.000227, -0.000227, -0.000227 | |
925 | , -0.000227, -0.000227, -0.000227, -0.000227 | |
926 | , -0.000227, -0.000227, -0.000227, -0.000227 | |
927 | , -0.000227, -0.000227, -0.000227, -0.000227 | |
928 | , -0.000227, -0.000227, -0.000227, -0.000227 | |
929 | , -0.000227, -0.000227, -0.000227, -0.000227 | |
930 | , -0.000227, -0.000227, -0.000227, -0.000227 | |
931 | , -0.000227, -0.000227, -0.000227, -0.000113 | |
932 | , -0.000113, -0.000113, -0.000113, -0.000113 | |
933 | , -0.000113, -0.000113, -0.000113, -0.000113 | |
934 | , -0.000113, -0.000113, -0.000113, -0.000113 | |
935 | , -0.000113, -0.000113, -0.000113, -0.000113 | |
936 | , -0.000113, -0.000113, -0.000113, -0.000113 | |
937 | , -0.000113, -0.000113, -0.000113, -0.000113 | |
938 | , -0.000113, -0.000113, -0.000113, -0.000113 | |
939 | , -0.000113, -0.000113, -0.000113, -0.000113 | |
940 | , -0.000113, -0.000113, -0.000113, -0.000113 | |
941 | , -0.000113, -0.000113, -0.000113, -0.000113 | |
942 | , -0.000113, -0.000113, -0.000113, -0.000113 | |
943 | , -0.000113, -0.000113, -0.000113, -0.000113 | |
944 | , -0.000113, -0.000113, -0.000113, -0.000113 | |
945 | , -0.000113, -0.000113, -0.000113, -0.000113 | |
946 | , -0.000113, -0.000113, -0.000113, -0.000113 | |
947 | , -0.000113, -0.000113, -0.000113, -0.000113 | |
948 | , -0.000113, -0.000113, -0.000113, -0.000113 | |
949 | , -0.000113, -0.000113, -0.000113, -0.000113 | |
950 | , -0.000113, -0.000113, -0.000113, -0.000113 | |
951 | , -0.000113, -0.000113, -0.000113, 0.000000 | |
952 | , 0.000000, 0.000000, 0.000000, 0.000000 | |
953 | , 0.000000, 0.000000, 0.000000, 0.000000 | |
954 | , 0.000000, 0.000000, 0.000000, 0.000000 | |
955 | , 0.000000, 0.000000, 0.000000, 0.000000 | |
956 | , 0.000000, 0.000000, 0.000000, 0.000000 | |
957 | , 0.000000, 0.000000, 0.000000, 0.000000 | |
958 | , 0.000000, 0.000000, 0.000000, 0.000000 | |
959 | , 0.000000, 0.000000, 0.000000, 0.000000 | |
960 | , 0.000000, 0.000000, 0.000000, 0.000000 | |
961 | , 0.000000, 0.000000, 0.000000, 0.000000 }; | |
962 | ||
963 | // increase CrossTalk to measurements | |
964 | for (Int_t ipasa = 0; ipasa < kNpasa; ipasa++) { | |
965 | xtalk[ipasa] *= 1.75; | |
966 | } | |
967 | ||
968 | if (fTRFsmp) delete [] fTRFsmp; | |
872a7aba | 969 | fTRFsmp = new Float_t[fTRFbin]; |
e23fbb27 | 970 | if (fCTsmp) delete [] fCTsmp; |
971 | fCTsmp = new Float_t[fTRFbin]; | |
872a7aba | 972 | |
973 | Float_t loTRF = TMath::Max(fTRFlo / fDriftVelocity,time[0]); | |
974 | Float_t hiTRF = TMath::Min(fTRFhi / fDriftVelocity,time[kNpasa-1]); | |
793ff80c | 975 | Float_t binWidth = (hiTRF - loTRF) / ((Float_t) fTRFbin); |
872a7aba | 976 | |
977 | // Take the linear interpolation | |
793ff80c | 978 | for (Int_t iBin = 0; iBin < fTRFbin; iBin++) { |
872a7aba | 979 | |
6244debe | 980 | Float_t bin = (((Float_t) iBin) + 0.5) * binWidth + loTRF; |
872a7aba | 981 | ipos1 = ipos2 = 0; |
982 | diff = 0; | |
983 | do { | |
984 | diff = bin - time[ipos2++]; | |
985 | } while (diff > 0); | |
986 | ipos2--; | |
e23fbb27 | 987 | if (ipos2 >= kNpasa) ipos2 = kNpasa - 1; |
872a7aba | 988 | ipos1 = ipos2 - 1; |
989 | ||
990 | fTRFsmp[iBin] = signal[ipos2] | |
991 | + diff * (signal[ipos2] - signal[ipos1]) | |
992 | / ( time[ipos2] - time[ipos1]); | |
993 | ||
e23fbb27 | 994 | fCTsmp[iBin] = xtalk[ipos2] |
995 | + diff * (xtalk[ipos2] - xtalk[ipos1]) | |
996 | / ( time[ipos2] - time[ipos1]); | |
997 | ||
793ff80c | 998 | } |
999 | ||
f7336fa3 | 1000 | } |
1001 | ||
e153aaf6 | 1002 | //_____________________________________________________________________________ |
1003 | void AliTRDdigitizer::SamplePRF() | |
1004 | { | |
1005 | // | |
1006 | // Samples the pad response function | |
1007 | // | |
1008 | ||
e23fbb27 | 1009 | const Int_t kNplan = AliTRDgeometry::kNplan; |
db30bf0f | 1010 | const Int_t kPRFbin = 61; |
e23fbb27 | 1011 | |
1012 | Float_t prf[kNplan][kPRFbin] = { { 0.018570, 0.022270, 0.026710, 0.032010 | |
1013 | , 0.038350, 0.045920, 0.054930, 0.065650 | |
1014 | , 0.078370, 0.093420, 0.111150, 0.131940 | |
1015 | , 0.156160, 0.184160, 0.216220, 0.252470 | |
1016 | , 0.292860, 0.337030, 0.384330, 0.433750 | |
1017 | , 0.484010, 0.533630, 0.581150, 0.625200 | |
1018 | , 0.664710, 0.698860, 0.727130, 0.749230 | |
1019 | , 0.765050, 0.774540, 0.777700, 0.774540 | |
1020 | , 0.765050, 0.749230, 0.727130, 0.698860 | |
1021 | , 0.664710, 0.625200, 0.581150, 0.533630 | |
1022 | , 0.484010, 0.433750, 0.384330, 0.337030 | |
1023 | , 0.292860, 0.252470, 0.216220, 0.184160 | |
1024 | , 0.156160, 0.131940, 0.111150, 0.093420 | |
1025 | , 0.078370, 0.065650, 0.054930, 0.045920 | |
1026 | , 0.038350, 0.032010, 0.026710, 0.022270 | |
1027 | , 0.018570 } | |
1028 | , { 0.015730, 0.019040, 0.023030, 0.027840 | |
1029 | , 0.033650, 0.040650, 0.049060, 0.059160 | |
1030 | , 0.071260, 0.085710, 0.102910, 0.123270 | |
1031 | , 0.147240, 0.175220, 0.207590, 0.244540 | |
1032 | , 0.286090, 0.331920, 0.381350, 0.433290 | |
1033 | , 0.486290, 0.538710, 0.588870, 0.635280 | |
1034 | , 0.676760, 0.712460, 0.741890, 0.764810 | |
1035 | , 0.781150, 0.790930, 0.794180, 0.790930 | |
1036 | , 0.781150, 0.764810, 0.741890, 0.712460 | |
1037 | , 0.676760, 0.635280, 0.588870, 0.538710 | |
1038 | , 0.486290, 0.433290, 0.381350, 0.331920 | |
1039 | , 0.286090, 0.244540, 0.207590, 0.175220 | |
1040 | , 0.147240, 0.123270, 0.102910, 0.085710 | |
1041 | , 0.071260, 0.059160, 0.049060, 0.040650 | |
1042 | , 0.033650, 0.027840, 0.023030, 0.019040 | |
1043 | , 0.015730 } | |
1044 | , { 0.013330, 0.016270, 0.019850, 0.024210 | |
1045 | , 0.029510, 0.035960, 0.043790, 0.053280 | |
1046 | , 0.064740, 0.078580, 0.095190, 0.115070 | |
1047 | , 0.138700, 0.166570, 0.199120, 0.236660 | |
1048 | , 0.279260, 0.326660, 0.378140, 0.432540 | |
1049 | , 0.488260, 0.543440, 0.596200, 0.644900 | |
1050 | , 0.688240, 0.725380, 0.755840, 0.779470 | |
1051 | , 0.796260, 0.806280, 0.809610, 0.806280 | |
1052 | , 0.796260, 0.779470, 0.755840, 0.725380 | |
1053 | , 0.688240, 0.644900, 0.596200, 0.543440 | |
1054 | , 0.488260, 0.432540, 0.378140, 0.326660 | |
1055 | , 0.279260, 0.236660, 0.199120, 0.166570 | |
1056 | , 0.138700, 0.115070, 0.095190, 0.078580 | |
1057 | , 0.064740, 0.053280, 0.043790, 0.035960 | |
1058 | , 0.029510, 0.024210, 0.019850, 0.016270 | |
1059 | , 0.013330 } | |
1060 | , { 0.011280, 0.013890, 0.017090, 0.021030 | |
1061 | , 0.025870, 0.031800, 0.039060, 0.047940 | |
1062 | , 0.058790, 0.071980, 0.087990, 0.107330 | |
1063 | , 0.130550, 0.158220, 0.190850, 0.228870 | |
1064 | , 0.272410, 0.321270, 0.374740, 0.431560 | |
1065 | , 0.489960, 0.547870, 0.603180, 0.654080 | |
1066 | , 0.699190, 0.737640, 0.769030, 0.793260 | |
1067 | , 0.810410, 0.820620, 0.824010, 0.820620 | |
1068 | , 0.810410, 0.793260, 0.769030, 0.737640 | |
1069 | , 0.699190, 0.654080, 0.603180, 0.547870 | |
1070 | , 0.489960, 0.431560, 0.374740, 0.321270 | |
1071 | , 0.272410, 0.228870, 0.190850, 0.158220 | |
1072 | , 0.130550, 0.107330, 0.087990, 0.071980 | |
1073 | , 0.058790, 0.047940, 0.039060, 0.031800 | |
1074 | , 0.025870, 0.021030, 0.017090, 0.013890 | |
1075 | , 0.011280 } | |
1076 | , { 0.009550, 0.011860, 0.014720, 0.018270 | |
1077 | , 0.022660, 0.028100, 0.034820, 0.043120 | |
1078 | , 0.053340, 0.065900, 0.081280, 0.100040 | |
1079 | , 0.122800, 0.150180, 0.182800, 0.221170 | |
1080 | , 0.265550, 0.315790, 0.371180, 0.430370 | |
1081 | , 0.491430, 0.552030, 0.609840, 0.662860 | |
1082 | , 0.709630, 0.749290, 0.781490, 0.806220 | |
1083 | , 0.823650, 0.834000, 0.837430, 0.834000 | |
1084 | , 0.823650, 0.806220, 0.781490, 0.749290 | |
1085 | , 0.709630, 0.662860, 0.609840, 0.552030 | |
1086 | , 0.491430, 0.430370, 0.371180, 0.315790 | |
1087 | , 0.265550, 0.221170, 0.182800, 0.150180 | |
1088 | , 0.122800, 0.100040, 0.081280, 0.065900 | |
1089 | , 0.053340, 0.043120, 0.034820, 0.028100 | |
1090 | , 0.022660, 0.018270, 0.014720, 0.011860 | |
1091 | , 0.009550 } | |
1092 | , { 0.008080, 0.010120, 0.012670, 0.015860 | |
1093 | , 0.019840, 0.024820, 0.031030, 0.038760 | |
1094 | , 0.048370, 0.060300, 0.075040, 0.093200 | |
1095 | , 0.115430, 0.142450, 0.174980, 0.213610 | |
1096 | , 0.258720, 0.310250, 0.367480, 0.429010 | |
1097 | , 0.492690, 0.555950, 0.616210, 0.671280 | |
1098 | , 0.719600, 0.760350, 0.793250, 0.818380 | |
1099 | , 0.836020, 0.846460, 0.849920, 0.846460 | |
1100 | , 0.836020, 0.818380, 0.793250, 0.760350 | |
1101 | , 0.719600, 0.671280, 0.616210, 0.555950 | |
1102 | , 0.492690, 0.429010, 0.367480, 0.310250 | |
1103 | , 0.258720, 0.213610, 0.174980, 0.142450 | |
1104 | , 0.115430, 0.093200, 0.075040, 0.060300 | |
1105 | , 0.048370, 0.038760, 0.031030, 0.024820 | |
1106 | , 0.019840, 0.015860, 0.012670, 0.010120 | |
1107 | , 0.008080 } }; | |
db30bf0f | 1108 | |
1109 | fPRFlo = -1.5; | |
1110 | fPRFhi = 1.5; | |
1111 | fPRFbin = kPRFbin; | |
1112 | fPRFwid = (fPRFhi - fPRFlo) / ((Float_t) fPRFbin); | |
1113 | fPRFpad = ((Int_t) (1.0 / fPRFwid)); | |
1114 | ||
e23fbb27 | 1115 | if (fPRFsmp) delete [] fPRFsmp; |
1116 | fPRFsmp = new Float_t[kNplan*fPRFbin]; | |
1117 | for (Int_t iPla = 0; iPla < kNplan; iPla++) { | |
1118 | for (Int_t iBin = 0; iBin < fPRFbin; iBin++) { | |
1119 | fPRFsmp[iPla*kPRFbin+iBin] = prf[iPla][iBin]; | |
1120 | } | |
1121 | } | |
e153aaf6 | 1122 | |
1123 | } | |
1124 | ||
f7336fa3 | 1125 | //_____________________________________________________________________________ |
e23fbb27 | 1126 | Bool_t AliTRDdigitizer::Open(const Char_t *file, Int_t nEvent) |
f7336fa3 | 1127 | { |
1128 | // | |
1129 | // Opens a ROOT-file with TRD-hits and reads in the hit-tree | |
1130 | // | |
1131 | ||
1132 | // Connect the AliRoot file containing Geometry, Kine, and Hits | |
e23fbb27 | 1133 | fInputFile = (TFile*) gROOT->GetListOfFiles()->FindObject(file); |
f7336fa3 | 1134 | if (!fInputFile) { |
e23fbb27 | 1135 | if (fDebug > 0) { |
1136 | printf("<AliTRDdigitizer::Open> "); | |
1137 | printf("Open the AliROOT-file %s.\n",file); | |
abaf1f1d | 1138 | } |
e23fbb27 | 1139 | fInputFile = new TFile(file,"UPDATE"); |
f7336fa3 | 1140 | } |
1141 | else { | |
e23fbb27 | 1142 | if (fDebug > 0) { |
1143 | printf("<AliTRDdigitizer::Open> "); | |
1144 | printf("%s is already open.\n",file); | |
abaf1f1d | 1145 | } |
f7336fa3 | 1146 | } |
1147 | ||
da581aea | 1148 | gAlice = (AliRun*) fInputFile->Get("gAlice"); |
1149 | if (gAlice) { | |
e23fbb27 | 1150 | if (fDebug > 0) { |
1151 | printf("<AliTRDdigitizer::Open> "); | |
abaf1f1d | 1152 | printf("AliRun object found on file.\n"); |
1153 | } | |
da581aea | 1154 | } |
1155 | else { | |
e23fbb27 | 1156 | printf("<AliTRDdigitizer::Open> "); |
da581aea | 1157 | printf("Could not find AliRun object.\n"); |
1158 | return kFALSE; | |
1159 | } | |
f7336fa3 | 1160 | |
1161 | fEvent = nEvent; | |
1162 | ||
1163 | // Import the Trees for the event nEvent in the file | |
1164 | Int_t nparticles = gAlice->GetEvent(fEvent); | |
1165 | if (nparticles <= 0) { | |
e23fbb27 | 1166 | printf("<AliTRDdigitizer::Open> "); |
f7336fa3 | 1167 | printf("No entries in the trees for event %d.\n",fEvent); |
1168 | return kFALSE; | |
1169 | } | |
1170 | ||
abaf1f1d | 1171 | if (InitDetector()) { |
1172 | return MakeBranch(); | |
1173 | } | |
1174 | else { | |
1175 | return kFALSE; | |
1176 | } | |
793ff80c | 1177 | |
1178 | } | |
1179 | ||
1180 | //_____________________________________________________________________________ | |
1181 | Bool_t AliTRDdigitizer::InitDetector() | |
1182 | { | |
1183 | // | |
1184 | // Sets the pointer to the TRD detector and the geometry | |
1185 | // | |
1186 | ||
dd9a6ee3 | 1187 | // Get the pointer to the detector class and check for version 1 |
1188 | fTRD = (AliTRD*) gAlice->GetDetector("TRD"); | |
1189 | if (fTRD->IsVersion() != 1) { | |
e23fbb27 | 1190 | printf("<AliTRDdigitizer::InitDetector> "); |
dd9a6ee3 | 1191 | printf("TRD must be version 1 (slow simulator).\n"); |
1192 | exit(1); | |
1193 | } | |
1194 | ||
1195 | // Get the geometry | |
1196 | fGeo = fTRD->GetGeometry(); | |
e23fbb27 | 1197 | if (fDebug > 0) { |
1198 | printf("<AliTRDdigitizer::InitDetector> "); | |
abaf1f1d | 1199 | printf("Geometry version %d\n",fGeo->IsVersion()); |
1200 | } | |
dd9a6ee3 | 1201 | |
88fd7ccb | 1202 | // The magnetic field strength in Tesla |
1203 | fField = 0.2 * gAlice->Field()->Factor(); | |
1204 | ||
abaf1f1d | 1205 | // Create a digits manager |
1206 | fDigitsManager = new AliTRDdigitsManager(); | |
1207 | fDigitsManager->SetSDigits(fSDigits); | |
1208 | fDigitsManager->CreateArrays(); | |
1209 | fDigitsManager->SetEvent(fEvent); | |
e23fbb27 | 1210 | fDigitsManager->SetDebug(fDebug); |
abaf1f1d | 1211 | |
1212 | // The list for the input s-digits manager to be merged | |
1213 | fSDigitsManagerList = new TList(); | |
1214 | ||
85cbec76 | 1215 | return ReInit(); |
f7336fa3 | 1216 | |
1217 | } | |
1218 | ||
6244debe | 1219 | //_____________________________________________________________________________ |
abaf1f1d | 1220 | Bool_t AliTRDdigitizer::MakeBranch(const Char_t *file) |
6244debe | 1221 | { |
abaf1f1d | 1222 | // |
1223 | // Create the branches for the digits array | |
6244debe | 1224 | // |
1225 | ||
abaf1f1d | 1226 | return fDigitsManager->MakeBranch(file); |
6244debe | 1227 | |
1228 | } | |
1229 | ||
f7336fa3 | 1230 | //_____________________________________________________________________________ |
1231 | Bool_t AliTRDdigitizer::MakeDigits() | |
1232 | { | |
1233 | // | |
872a7aba | 1234 | // Creates digits. |
f7336fa3 | 1235 | // |
1236 | ||
f7336fa3 | 1237 | /////////////////////////////////////////////////////////////// |
1238 | // Parameter | |
1239 | /////////////////////////////////////////////////////////////// | |
1240 | ||
1241 | // Converts number of electrons to fC | |
872a7aba | 1242 | const Double_t kEl2fC = 1.602E-19 * 1.0E15; |
f7336fa3 | 1243 | |
1244 | /////////////////////////////////////////////////////////////// | |
1245 | ||
793ff80c | 1246 | // Number of pads included in the pad response |
1247 | const Int_t kNpad = 3; | |
1248 | ||
1249 | // Number of track dictionary arrays | |
dd56b762 | 1250 | const Int_t kNDict = AliTRDdigitsManager::kNDict; |
793ff80c | 1251 | |
872a7aba | 1252 | // Half the width of the amplification region |
1253 | const Float_t kAmWidth = AliTRDgeometry::AmThick() / 2.; | |
1254 | ||
c3a4830f | 1255 | Int_t iRow, iCol, iTime, iPad; |
71d9fa7b | 1256 | Int_t iDict = 0; |
793ff80c | 1257 | Int_t nBytes = 0; |
f7336fa3 | 1258 | |
1259 | Int_t totalSizeDigits = 0; | |
1260 | Int_t totalSizeDict0 = 0; | |
1261 | Int_t totalSizeDict1 = 0; | |
1262 | Int_t totalSizeDict2 = 0; | |
1263 | ||
872a7aba | 1264 | Int_t timeTRDbeg = 0; |
1265 | Int_t timeTRDend = 1; | |
1266 | ||
1267 | Float_t pos[3]; | |
1268 | Float_t rot[3]; | |
1269 | Float_t xyz[3]; | |
1270 | Float_t padSignal[kNpad]; | |
1271 | Float_t signalOld[kNpad]; | |
1272 | ||
793ff80c | 1273 | AliTRDdataArrayF *signals = 0; |
1274 | AliTRDdataArrayI *digits = 0; | |
8230f242 | 1275 | AliTRDdataArrayI *dictionary[kNDict]; |
da581aea | 1276 | |
793ff80c | 1277 | // Create a container for the amplitudes |
1278 | AliTRDsegmentArray *signalsArray | |
e23fbb27 | 1279 | = new AliTRDsegmentArray("AliTRDdataArrayF" |
1280 | ,AliTRDgeometry::Ndet()); | |
793ff80c | 1281 | |
872a7aba | 1282 | if (fTRFOn) { |
1283 | timeTRDbeg = ((Int_t) (-fTRFlo / fGeo->GetTimeBinSize())) - 1; | |
1284 | timeTRDend = ((Int_t) ( fTRFhi / fGeo->GetTimeBinSize())) - 1; | |
e23fbb27 | 1285 | if (fDebug > 0) { |
1286 | printf("<AliTRDdigitizer::MakeDigits> "); | |
abaf1f1d | 1287 | printf("Sample the TRF between -%d and %d\n",timeTRDbeg,timeTRDend); |
1288 | } | |
da581aea | 1289 | } |
1290 | ||
872a7aba | 1291 | Float_t elAttachProp = fElAttachProp / 100.; |
f7336fa3 | 1292 | |
e153aaf6 | 1293 | // Create the sampled PRF |
1294 | SamplePRF(); | |
1295 | ||
6244debe | 1296 | // Create the sampled TRF |
1297 | SampleTRF(); | |
793ff80c | 1298 | |
872a7aba | 1299 | if (!fGeo) { |
e23fbb27 | 1300 | printf("<AliTRDdigitizer::MakeDigits> "); |
872a7aba | 1301 | printf("No geometry defined\n"); |
1302 | return kFALSE; | |
1303 | } | |
1304 | ||
e23fbb27 | 1305 | if (fDebug > 0) { |
1306 | printf("<AliTRDdigitizer::MakeDigits> "); | |
abaf1f1d | 1307 | printf("Start creating digits.\n"); |
1308 | } | |
872a7aba | 1309 | |
793ff80c | 1310 | // Get the pointer to the hit tree |
1311 | TTree *HitTree = gAlice->TreeH(); | |
1312 | ||
1313 | // Get the number of entries in the hit tree | |
1314 | // (Number of primary particles creating a hit somewhere) | |
1315 | Int_t nTrack = (Int_t) HitTree->GetEntries(); | |
e23fbb27 | 1316 | if (fDebug > 0) { |
1317 | printf("<AliTRDdigitizer::MakeDigits> "); | |
793ff80c | 1318 | printf("Found %d primary particles\n",nTrack); |
1319 | } | |
1320 | ||
1321 | Int_t detectorOld = -1; | |
1322 | Int_t countHits = 0; | |
1323 | ||
1324 | // Loop through all entries in the tree | |
1325 | for (Int_t iTrack = 0; iTrack < nTrack; iTrack++) { | |
1326 | ||
1327 | gAlice->ResetHits(); | |
1328 | nBytes += HitTree->GetEvent(iTrack); | |
1329 | ||
e23fbb27 | 1330 | // Loop through the TRD hits |
1331 | Int_t iHit = 0; | |
1332 | AliTRDhit *hit = (AliTRDhit *) fTRD->FirstHit(-1); | |
1333 | while (hit) { | |
1334 | ||
793ff80c | 1335 | countHits++; |
e23fbb27 | 1336 | iHit++; |
1337 | ||
1338 | pos[0] = hit->X(); | |
1339 | pos[1] = hit->Y(); | |
1340 | pos[2] = hit->Z(); | |
1341 | Float_t q = hit->GetCharge(); | |
1342 | Int_t track = hit->Track(); | |
1343 | Int_t detector = hit->GetDetector(); | |
1344 | Int_t plane = fGeo->GetPlane(detector); | |
1345 | Int_t sector = fGeo->GetSector(detector); | |
1346 | Int_t chamber = fGeo->GetChamber(detector); | |
793ff80c | 1347 | Int_t nRowMax = fGeo->GetRowMax(plane,chamber,sector); |
1348 | Int_t nColMax = fGeo->GetColMax(plane); | |
1349 | Int_t nTimeMax = fGeo->GetTimeMax(); | |
872a7aba | 1350 | Int_t nTimeBefore = fGeo->GetTimeBefore(); |
1351 | Int_t nTimeAfter = fGeo->GetTimeAfter(); | |
1352 | Int_t nTimeTotal = fGeo->GetTimeTotal(); | |
793ff80c | 1353 | Float_t row0 = fGeo->GetRow0(plane,chamber,sector); |
1354 | Float_t col0 = fGeo->GetCol0(plane); | |
1355 | Float_t time0 = fGeo->GetTime0(plane); | |
71d9fa7b | 1356 | Float_t rowPadSize = fGeo->GetRowPadSize(plane,chamber,sector); |
1357 | Float_t colPadSize = fGeo->GetColPadSize(plane); | |
793ff80c | 1358 | Float_t timeBinSize = fGeo->GetTimeBinSize(); |
872a7aba | 1359 | Float_t divideRow = 1.0 / rowPadSize; |
1360 | Float_t divideCol = 1.0 / colPadSize; | |
1361 | Float_t divideTime = 1.0 / timeBinSize; | |
793ff80c | 1362 | |
e23fbb27 | 1363 | if (fDebug > 1) { |
793ff80c | 1364 | printf("Analyze hit no. %d ",iHit); |
1365 | printf("-----------------------------------------------------------\n"); | |
1366 | hit->Dump(); | |
1367 | printf("plane = %d, sector = %d, chamber = %d\n" | |
1368 | ,plane,sector,chamber); | |
1369 | printf("nRowMax = %d, nColMax = %d, nTimeMax = %d\n" | |
1370 | ,nRowMax,nColMax,nTimeMax); | |
872a7aba | 1371 | printf("nTimeBefore = %d, nTimeAfter = %d, nTimeTotal = %d\n" |
1372 | ,nTimeBefore,nTimeAfter,nTimeTotal); | |
793ff80c | 1373 | printf("row0 = %f, col0 = %f, time0 = %f\n" |
1374 | ,row0,col0,time0); | |
c1e4b257 | 1375 | printf("rowPadSize = %f, colPadSize = %f, timeBinSize = %f\n" |
1376 | ,rowPadSize,colPadSize,timeBinSize); | |
793ff80c | 1377 | } |
1378 | ||
e23fbb27 | 1379 | // Don't analyze test hits and switched off detectors |
1380 | if ((CheckDetector(plane,chamber,sector)) && | |
1381 | (((Int_t) q) != 0)) { | |
dd56b762 | 1382 | |
e23fbb27 | 1383 | if (detector != detectorOld) { |
e153aaf6 | 1384 | |
e23fbb27 | 1385 | if (fDebug > 1) { |
1386 | printf("<AliTRDdigitizer::MakeDigits> "); | |
1387 | printf("Get new container. New det = %d, Old det = %d\n" | |
1388 | ,detector,detectorOld); | |
dd9a6ee3 | 1389 | } |
e23fbb27 | 1390 | // Compress the old one if enabled |
1391 | if ((fCompress) && (detectorOld > -1)) { | |
1392 | if (fDebug > 1) { | |
1393 | printf("<AliTRDdigitizer::MakeDigits> "); | |
1394 | printf("Compress the old container ..."); | |
1395 | } | |
1396 | signals->Compress(1,0); | |
1397 | for (iDict = 0; iDict < kNDict; iDict++) { | |
1398 | dictionary[iDict]->Compress(1,0); | |
c1e4b257 | 1399 | } |
e23fbb27 | 1400 | if (fDebug > 1) printf("done\n"); |
793ff80c | 1401 | } |
e23fbb27 | 1402 | // Get the new container |
1403 | signals = (AliTRDdataArrayF *) signalsArray->At(detector); | |
1404 | if (signals->GetNtime() == 0) { | |
1405 | // Allocate a new one if not yet existing | |
1406 | if (fDebug > 1) { | |
1407 | printf("<AliTRDdigitizer::MakeDigits> "); | |
1408 | printf("Allocate a new container ... "); | |
1409 | } | |
1410 | signals->Allocate(nRowMax,nColMax,nTimeTotal); | |
793ff80c | 1411 | } |
1412 | else { | |
e23fbb27 | 1413 | // Expand an existing one |
1414 | if (fCompress) { | |
1415 | if (fDebug > 1) { | |
1416 | printf("<AliTRDdigitizer::MakeDigits> "); | |
1417 | printf("Expand an existing container ... "); | |
1418 | } | |
1419 | signals->Expand(); | |
1420 | } | |
793ff80c | 1421 | } |
e23fbb27 | 1422 | // The same for the dictionary |
1423 | for (iDict = 0; iDict < kNDict; iDict++) { | |
1424 | dictionary[iDict] = fDigitsManager->GetDictionary(detector,iDict); | |
1425 | if (dictionary[iDict]->GetNtime() == 0) { | |
1426 | dictionary[iDict]->Allocate(nRowMax,nColMax,nTimeTotal); | |
1427 | } | |
1428 | else { | |
1429 | if (fCompress) dictionary[iDict]->Expand(); | |
1430 | } | |
1431 | } | |
1432 | if (fDebug > 1) printf("done\n"); | |
1433 | detectorOld = detector; | |
793ff80c | 1434 | } |
1435 | ||
e23fbb27 | 1436 | // Rotate the sectors on top of each other |
1437 | fGeo->Rotate(detector,pos,rot); | |
1438 | ||
1439 | // The driftlength. It is negative if the hit is in the | |
1440 | // amplification region. | |
1441 | Float_t driftlength = time0 - rot[0]; | |
1442 | ||
1443 | // Take also the drift in the amplification region into account | |
1444 | // The drift length is at the moment still the same, regardless of | |
1445 | // the position relativ to the wire. This non-isochronity needs still | |
1446 | // to be implemented. | |
1447 | Float_t driftlengthL = TMath::Abs(driftlength + kAmWidth); | |
1448 | if (fExBOn) driftlengthL /= TMath::Sqrt(fLorentzFactor); | |
1449 | ||
1450 | // Loop over all electrons of this hit | |
1451 | // TR photons produce hits with negative charge | |
1452 | Int_t nEl = ((Int_t) TMath::Abs(q)); | |
1453 | for (Int_t iEl = 0; iEl < nEl; iEl++) { | |
1454 | ||
1455 | xyz[0] = rot[0]; | |
1456 | xyz[1] = rot[1]; | |
1457 | xyz[2] = rot[2]; | |
1458 | ||
1459 | // Electron attachment | |
1460 | if (fElAttachOn) { | |
1461 | if (gRandom->Rndm() < (driftlengthL * elAttachProp)) | |
1462 | continue; | |
1463 | } | |
1464 | ||
1465 | // Apply the diffusion smearing | |
1466 | if (fDiffusionOn) { | |
1467 | if (!(Diffusion(driftlengthL,xyz))) continue; | |
1468 | } | |
f7336fa3 | 1469 | |
e23fbb27 | 1470 | // Apply E x B effects (depends on drift direction) |
1471 | if (fExBOn) { | |
1472 | if (!(ExB(driftlength+kAmWidth,xyz))) continue; | |
1473 | } | |
793ff80c | 1474 | |
e23fbb27 | 1475 | // The electron position after diffusion and ExB in pad coordinates |
1476 | // The pad row (z-direction) | |
1477 | Float_t rowDist = xyz[2] - row0; | |
1478 | Int_t rowE = ((Int_t) (rowDist * divideRow)); | |
1479 | if ((rowE < 0) || (rowE >= nRowMax)) continue; | |
1480 | Float_t rowOffset = ((((Float_t) rowE) + 0.5) * rowPadSize) - rowDist; | |
1481 | ||
1482 | // The pad column (rphi-direction) | |
1483 | Float_t col0tilt = Col0Tilted(col0,rowOffset,plane); | |
1484 | Float_t colDist = xyz[1] - col0tilt; | |
1485 | Int_t colE = ((Int_t) (colDist * divideCol)); | |
1486 | if ((colE < 0) || (colE >= nColMax)) continue; | |
1487 | Float_t colOffset = ((((Float_t) colE) + 0.5) * colPadSize) - colDist; | |
1488 | ||
1489 | // The time bin (negative for hits in the amplification region) | |
1490 | // In the amplification region the electrons drift from both sides | |
1491 | // to the middle (anode wire plane) | |
1492 | Float_t timeDist = time0 - xyz[0]; | |
1493 | Float_t timeOffset = 0; | |
1494 | Int_t timeE = 0; | |
1495 | if (timeDist > 0) { | |
1496 | // The time bin | |
1497 | timeE = ((Int_t) (timeDist * divideTime)); | |
1498 | // The distance of the position to the middle of the timebin | |
1499 | timeOffset = ((((Float_t) timeE) + 0.5) * timeBinSize) - timeDist; | |
1500 | } | |
1501 | else { | |
1502 | // Difference between half of the amplification gap width and | |
1503 | // the distance to the anode wire | |
1504 | Float_t anodeDist = kAmWidth - TMath::Abs(timeDist + kAmWidth); | |
1505 | // The time bin | |
1506 | timeE = -1 * (((Int_t ) (anodeDist * divideTime)) + 1); | |
1507 | // The distance of the position to the middle of the timebin | |
1508 | timeOffset = ((((Float_t) timeE) + 0.5) * timeBinSize) + anodeDist; | |
1509 | } | |
872a7aba | 1510 | |
e23fbb27 | 1511 | // Apply the gas gain including fluctuations |
1512 | Float_t ggRndm = 0.0; | |
1513 | do { | |
1514 | ggRndm = gRandom->Rndm(); | |
1515 | } while (ggRndm <= 0); | |
1516 | Int_t signal = (Int_t) (-fGasGain * TMath::Log(ggRndm)); | |
1517 | ||
1518 | // Apply the pad response | |
1519 | if (fPRFOn) { | |
1520 | // The distance of the electron to the center of the pad | |
1521 | // in units of pad width | |
1522 | Float_t dist = - colOffset * divideCol; | |
1523 | if (!(PadResponse(signal,dist,plane,padSignal))) continue; | |
793ff80c | 1524 | } |
e23fbb27 | 1525 | else { |
1526 | padSignal[0] = 0.0; | |
1527 | padSignal[1] = signal; | |
1528 | padSignal[2] = 0.0; | |
1529 | } | |
1530 | ||
1531 | // Sample the time response inside the drift region | |
1532 | // + additional time bins before and after. | |
1533 | // The sampling is done always in the middle of the time bin | |
1534 | for (Int_t iTimeBin = TMath::Max(timeE-timeTRDbeg, -nTimeBefore) | |
1535 | ;iTimeBin < TMath::Min(timeE+timeTRDend,nTimeMax+nTimeAfter ) | |
1536 | ;iTimeBin++) { | |
1537 | ||
1538 | // Apply the time response | |
1539 | Float_t timeResponse = 1.0; | |
1540 | Float_t crossTalk = 0.0; | |
1541 | Float_t time = (iTimeBin - timeE) * timeBinSize + timeOffset; | |
1542 | if (fTRFOn) { | |
1543 | timeResponse = TimeResponse(time); | |
1544 | } | |
1545 | if (fCTOn) { | |
1546 | crossTalk = CrossTalk(time); | |
1547 | } | |
1548 | ||
1549 | signalOld[0] = 0.0; | |
1550 | signalOld[1] = 0.0; | |
1551 | signalOld[2] = 0.0; | |
f7336fa3 | 1552 | |
e23fbb27 | 1553 | for (iPad = 0; iPad < kNpad; iPad++) { |
1554 | ||
1555 | Int_t colPos = colE + iPad - 1; | |
1556 | if (colPos < 0) continue; | |
1557 | if (colPos >= nColMax) break; | |
1558 | ||
1559 | // Add the signals | |
1560 | // Note: The time bin number is shifted by nTimeBefore to avoid negative | |
1561 | // time bins. This has to be subtracted later. | |
1562 | Int_t iCurrentTimeBin = iTimeBin + nTimeBefore; | |
1563 | signalOld[iPad] = signals->GetDataUnchecked(rowE,colPos,iCurrentTimeBin); | |
1564 | if( colPos != colE ) { | |
1565 | signalOld[iPad] += padSignal[iPad] * (timeResponse + crossTalk); | |
1566 | } | |
1567 | else { | |
1568 | signalOld[iPad] += padSignal[iPad] * timeResponse; | |
1569 | } | |
1570 | signals->SetDataUnchecked(rowE,colPos,iCurrentTimeBin,signalOld[iPad]); | |
1571 | ||
1572 | // Store the track index in the dictionary | |
1573 | // Note: We store index+1 in order to allow the array to be compressed | |
1574 | if (signalOld[iPad] > 0) { | |
1575 | for (iDict = 0; iDict < kNDict; iDict++) { | |
1576 | Int_t oldTrack = dictionary[iDict]->GetDataUnchecked(rowE | |
1577 | ,colPos | |
1578 | ,iCurrentTimeBin); | |
1579 | if (oldTrack == track+1) break; | |
1580 | if (oldTrack == 0) { | |
1581 | dictionary[iDict]->SetDataUnchecked(rowE,colPos,iCurrentTimeBin,track+1); | |
1582 | break; | |
1583 | } | |
71d9fa7b | 1584 | } |
1585 | } | |
872a7aba | 1586 | |
e23fbb27 | 1587 | } // Loop: pads |
f7336fa3 | 1588 | |
e23fbb27 | 1589 | } // Loop: time bins |
f7336fa3 | 1590 | |
e23fbb27 | 1591 | } // Loop: electrons of a single hit |
f7336fa3 | 1592 | |
e23fbb27 | 1593 | } // If: detector and test hit |
f7336fa3 | 1594 | |
e23fbb27 | 1595 | hit = (AliTRDhit *) fTRD->NextHit(); |
f7336fa3 | 1596 | |
e23fbb27 | 1597 | } // Loop: hits of one primary track |
1598 | ||
1599 | } // Loop: primary tracks | |
1600 | ||
1601 | if (fDebug > 0) { | |
1602 | printf("<AliTRDdigitizer::MakeDigits> "); | |
abaf1f1d | 1603 | printf("Finished analyzing %d hits\n",countHits); |
1604 | } | |
793ff80c | 1605 | |
6244debe | 1606 | // The total conversion factor |
1607 | Float_t convert = kEl2fC * fPadCoupling * fTimeCoupling * fChipGain; | |
1608 | ||
793ff80c | 1609 | // Loop through all chambers to finalize the digits |
1610 | for (Int_t iDet = 0; iDet < AliTRDgeometry::Ndet(); iDet++) { | |
1611 | ||
872a7aba | 1612 | Int_t plane = fGeo->GetPlane(iDet); |
1613 | Int_t sector = fGeo->GetSector(iDet); | |
1614 | Int_t chamber = fGeo->GetChamber(iDet); | |
1615 | Int_t nRowMax = fGeo->GetRowMax(plane,chamber,sector); | |
1616 | Int_t nColMax = fGeo->GetColMax(plane); | |
1617 | Int_t nTimeMax = fGeo->GetTimeMax(); | |
1618 | Int_t nTimeTotal = fGeo->GetTimeTotal(); | |
793ff80c | 1619 | |
e23fbb27 | 1620 | Double_t *inADC = new Double_t[nTimeTotal]; |
1621 | Double_t *outADC = new Double_t[nTimeTotal]; | |
1622 | ||
1623 | if (fDebug > 0) { | |
1624 | printf("<AliTRDdigitizer::MakeDigits> "); | |
793ff80c | 1625 | printf("Digitization for chamber %d\n",iDet); |
1626 | } | |
da581aea | 1627 | |
793ff80c | 1628 | // Add a container for the digits of this detector |
abaf1f1d | 1629 | digits = fDigitsManager->GetDigits(iDet); |
793ff80c | 1630 | // Allocate memory space for the digits buffer |
872a7aba | 1631 | digits->Allocate(nRowMax,nColMax,nTimeTotal); |
da581aea | 1632 | |
793ff80c | 1633 | // Get the signal container |
1634 | signals = (AliTRDdataArrayF *) signalsArray->At(iDet); | |
1635 | if (signals->GetNtime() == 0) { | |
1636 | // Create missing containers | |
872a7aba | 1637 | signals->Allocate(nRowMax,nColMax,nTimeTotal); |
793ff80c | 1638 | } |
1639 | else { | |
1640 | // Expand the container if neccessary | |
1641 | if (fCompress) signals->Expand(); | |
1642 | } | |
1643 | // Create the missing dictionary containers | |
1644 | for (iDict = 0; iDict < kNDict; iDict++) { | |
abaf1f1d | 1645 | dictionary[iDict] = fDigitsManager->GetDictionary(iDet,iDict); |
793ff80c | 1646 | if (dictionary[iDict]->GetNtime() == 0) { |
872a7aba | 1647 | dictionary[iDict]->Allocate(nRowMax,nColMax,nTimeTotal); |
793ff80c | 1648 | } |
1649 | } | |
f7336fa3 | 1650 | |
793ff80c | 1651 | Int_t nDigits = 0; |
1652 | ||
6244debe | 1653 | // Don't create noise in detectors that are switched off |
1654 | if (CheckDetector(plane,chamber,sector)) { | |
1655 | ||
1656 | // Create the digits for this chamber | |
872a7aba | 1657 | for (iRow = 0; iRow < nRowMax; iRow++ ) { |
1658 | for (iCol = 0; iCol < nColMax; iCol++ ) { | |
6244debe | 1659 | |
e23fbb27 | 1660 | // Create summable digits |
1661 | if (fSDigits) { | |
6244debe | 1662 | |
e23fbb27 | 1663 | for (iTime = 0; iTime < nTimeTotal; iTime++) { |
872a7aba | 1664 | Float_t signalAmp = signals->GetDataUnchecked(iRow,iCol,iTime); |
abaf1f1d | 1665 | signalAmp *= fSDigitsScale; |
e23fbb27 | 1666 | signalAmp = TMath::Min(signalAmp,(Float_t) 1.0e9); |
abaf1f1d | 1667 | Int_t adc = (Int_t) signalAmp; |
6244debe | 1668 | nDigits++; |
872a7aba | 1669 | digits->SetDataUnchecked(iRow,iCol,iTime,adc); |
c1e4b257 | 1670 | } |
6244debe | 1671 | |
e23fbb27 | 1672 | } |
1673 | // Create normal digits | |
1674 | else { | |
6244debe | 1675 | |
e23fbb27 | 1676 | for (iTime = 0; iTime < nTimeTotal; iTime++) { |
1677 | Float_t signalAmp = signals->GetDataUnchecked(iRow,iCol,iTime); | |
6244debe | 1678 | // Add the noise |
1679 | signalAmp = TMath::Max((Double_t) gRandom->Gaus(signalAmp,fNoise),0.0); | |
1680 | // Convert to mV | |
1681 | signalAmp *= convert; | |
1682 | // Convert to ADC counts. Set the overflow-bit fADCoutRange if the | |
1683 | // signal is larger than fADCinRange | |
1684 | Int_t adc = 0; | |
1685 | if (signalAmp >= fADCinRange) { | |
1686 | adc = ((Int_t) fADCoutRange); | |
1687 | } | |
1688 | else { | |
1689 | adc = ((Int_t) (signalAmp * (fADCoutRange / fADCinRange))); | |
1690 | } | |
e23fbb27 | 1691 | inADC[iTime] = adc; |
1692 | outADC[iTime] = adc; | |
1693 | } | |
6244debe | 1694 | |
e23fbb27 | 1695 | // Apply the tail cancelation via the digital filter |
1696 | if (fTCOn) { | |
1697 | DeConvExp(inADC,outADC,nTimeTotal,fTCnexp); | |
1698 | } | |
1699 | ||
1700 | for (iTime = 0; iTime < nTimeTotal; iTime++) { | |
6244debe | 1701 | // Store the amplitude of the digit if above threshold |
e23fbb27 | 1702 | if (outADC[iTime] > fADCthreshold) { |
1703 | if (fDebug > 2) { | |
1704 | printf(" iRow = %d, iCol = %d, iTime = %d, adc = %f\n" | |
1705 | ,iRow,iCol,iTime,outADC[iTime]); | |
6244debe | 1706 | } |
1707 | nDigits++; | |
e23fbb27 | 1708 | digits->SetDataUnchecked(iRow,iCol,iTime,outADC[iTime]); |
6244debe | 1709 | } |
6244debe | 1710 | } |
1711 | ||
1712 | } | |
e23fbb27 | 1713 | |
6244debe | 1714 | } |
793ff80c | 1715 | } |
6244debe | 1716 | |
793ff80c | 1717 | } |
1718 | ||
1719 | // Compress the arrays | |
1720 | digits->Compress(1,0); | |
1721 | for (iDict = 0; iDict < kNDict; iDict++) { | |
1722 | dictionary[iDict]->Compress(1,0); | |
1723 | } | |
f7336fa3 | 1724 | |
793ff80c | 1725 | totalSizeDigits += digits->GetSize(); |
1726 | totalSizeDict0 += dictionary[0]->GetSize(); | |
1727 | totalSizeDict1 += dictionary[1]->GetSize(); | |
1728 | totalSizeDict2 += dictionary[2]->GetSize(); | |
f7336fa3 | 1729 | |
c1e4b257 | 1730 | Float_t nPixel = nRowMax * nColMax * nTimeMax; |
e23fbb27 | 1731 | if (fDebug > 0) { |
1732 | printf("<AliTRDdigitizer::MakeDigits> "); | |
abaf1f1d | 1733 | printf("Found %d digits in detector %d (%3.0f).\n" |
1734 | ,nDigits,iDet | |
1735 | ,100.0 * ((Float_t) nDigits) / nPixel); | |
1736 | } | |
1737 | ||
793ff80c | 1738 | if (fCompress) signals->Compress(1,0); |
f7336fa3 | 1739 | |
e23fbb27 | 1740 | delete [] inADC; |
1741 | delete [] outADC; | |
1742 | ||
f7336fa3 | 1743 | } |
1744 | ||
e23fbb27 | 1745 | if (fDebug > 0) { |
1746 | printf("<AliTRDdigitizer::MakeDigits> "); | |
abaf1f1d | 1747 | printf("Total number of analyzed hits = %d\n",countHits); |
e23fbb27 | 1748 | printf("<AliTRDdigitizer::MakeDigits> "); |
abaf1f1d | 1749 | printf("Total digits data size = %d, %d, %d, %d\n",totalSizeDigits |
1750 | ,totalSizeDict0 | |
1751 | ,totalSizeDict1 | |
1752 | ,totalSizeDict2); | |
1753 | } | |
1754 | ||
1755 | return kTRUE; | |
1756 | ||
1757 | } | |
1758 | ||
1759 | //_____________________________________________________________________________ | |
1760 | void AliTRDdigitizer::AddSDigitsManager(AliTRDdigitsManager *man) | |
1761 | { | |
1762 | // | |
1763 | // Add a digits manager for s-digits to the input list. | |
1764 | // | |
1765 | ||
1766 | fSDigitsManagerList->Add(man); | |
1767 | ||
1768 | } | |
1769 | ||
1770 | //_____________________________________________________________________________ | |
1771 | Bool_t AliTRDdigitizer::ConvertSDigits() | |
1772 | { | |
1773 | // | |
1774 | // Converts s-digits to normal digits | |
1775 | // | |
1776 | ||
1777 | // Number of track dictionary arrays | |
1778 | const Int_t kNDict = AliTRDdigitsManager::kNDict; | |
1779 | ||
1780 | // Converts number of electrons to fC | |
1781 | const Double_t kEl2fC = 1.602E-19 * 1.0E15; | |
1782 | ||
1783 | Int_t iDict = 0; | |
e23fbb27 | 1784 | Int_t iRow; |
1785 | Int_t iCol; | |
1786 | Int_t iTime; | |
abaf1f1d | 1787 | |
e23fbb27 | 1788 | if (fDebug > 0) { |
abaf1f1d | 1789 | this->Dump(); |
1790 | } | |
1791 | ||
1792 | Double_t sDigitsScale = 1.0 / GetSDigitsScale(); | |
1793 | Double_t noise = GetNoise(); | |
1794 | Double_t padCoupling = GetPadCoupling(); | |
1795 | Double_t timeCoupling = GetTimeCoupling(); | |
1796 | Double_t chipGain = GetChipGain(); | |
1797 | Double_t convert = kEl2fC * padCoupling * timeCoupling * chipGain;; | |
1798 | Double_t adcInRange = GetADCinRange(); | |
1799 | Double_t adcOutRange = GetADCoutRange(); | |
1800 | Int_t adcThreshold = GetADCthreshold(); | |
1801 | ||
1802 | AliTRDdataArrayI *digitsIn; | |
1803 | AliTRDdataArrayI *digitsOut; | |
1804 | AliTRDdataArrayI *dictionaryIn[kNDict]; | |
1805 | AliTRDdataArrayI *dictionaryOut[kNDict]; | |
1806 | ||
1807 | // Loop through the detectors | |
1808 | for (Int_t iDet = 0; iDet < AliTRDgeometry::Ndet(); iDet++) { | |
da581aea | 1809 | |
e23fbb27 | 1810 | if (fDebug > 0) { |
1811 | printf("<AliTRDdigitizer::ConvertSDigits> "); | |
abaf1f1d | 1812 | printf("Convert detector %d to digits.\n",iDet); |
1813 | } | |
1814 | ||
1815 | Int_t plane = fGeo->GetPlane(iDet); | |
1816 | Int_t sector = fGeo->GetSector(iDet); | |
1817 | Int_t chamber = fGeo->GetChamber(iDet); | |
1818 | Int_t nRowMax = fGeo->GetRowMax(plane,chamber,sector); | |
1819 | Int_t nColMax = fGeo->GetColMax(plane); | |
1820 | Int_t nTimeTotal = fGeo->GetTimeTotal(); | |
1821 | ||
e23fbb27 | 1822 | Double_t *inADC = new Double_t[nTimeTotal]; |
1823 | Double_t *outADC = new Double_t[nTimeTotal]; | |
1824 | ||
abaf1f1d | 1825 | digitsIn = fSDigitsManager->GetDigits(iDet); |
1826 | digitsIn->Expand(); | |
1827 | digitsOut = fDigitsManager->GetDigits(iDet); | |
1828 | digitsOut->Allocate(nRowMax,nColMax,nTimeTotal); | |
1829 | for (iDict = 0; iDict < kNDict; iDict++) { | |
1830 | dictionaryIn[iDict] = fSDigitsManager->GetDictionary(iDet,iDict); | |
1831 | dictionaryIn[iDict]->Expand(); | |
1832 | dictionaryOut[iDict] = fDigitsManager->GetDictionary(iDet,iDict); | |
1833 | dictionaryOut[iDict]->Allocate(nRowMax,nColMax,nTimeTotal); | |
1834 | } | |
1835 | ||
e23fbb27 | 1836 | for (iRow = 0; iRow < nRowMax; iRow++ ) { |
1837 | for (iCol = 0; iCol < nColMax; iCol++ ) { | |
abaf1f1d | 1838 | |
e23fbb27 | 1839 | for (iTime = 0; iTime < nTimeTotal; iTime++) { |
abaf1f1d | 1840 | Double_t signal = (Double_t) digitsIn->GetDataUnchecked(iRow,iCol,iTime); |
1841 | signal *= sDigitsScale; | |
1842 | // Add the noise | |
1843 | signal = TMath::Max((Double_t) gRandom->Gaus(signal,noise),0.0); | |
1844 | // Convert to mV | |
1845 | signal *= convert; | |
1846 | // Convert to ADC counts. Set the overflow-bit adcOutRange if the | |
1847 | // signal is larger than adcInRange | |
1848 | Int_t adc = 0; | |
1849 | if (signal >= adcInRange) { | |
1850 | adc = ((Int_t) adcOutRange); | |
1851 | } | |
1852 | else { | |
1853 | adc = ((Int_t) (signal * (adcOutRange / adcInRange))); | |
1854 | } | |
e23fbb27 | 1855 | inADC[iTime] = adc; |
1856 | outADC[iTime] = adc; | |
1857 | } | |
1858 | ||
1859 | // Apply the tail cancelation via the digital filter | |
1860 | if (fTCOn) { | |
1861 | DeConvExp(inADC,outADC,nTimeTotal,fTCnexp); | |
1862 | } | |
1863 | ||
1864 | for (iTime = 0; iTime < nTimeTotal; iTime++) { | |
abaf1f1d | 1865 | // Store the amplitude of the digit if above threshold |
e23fbb27 | 1866 | if (outADC[iTime] > adcThreshold) { |
1867 | digitsOut->SetDataUnchecked(iRow,iCol,iTime,outADC[iTime]); | |
1868 | // Copy the dictionary | |
1869 | for (iDict = 0; iDict < kNDict; iDict++) { | |
1870 | Int_t track = dictionaryIn[iDict]->GetDataUnchecked(iRow,iCol,iTime); | |
1871 | dictionaryOut[iDict]->SetDataUnchecked(iRow,iCol,iTime,track); | |
1872 | } | |
abaf1f1d | 1873 | } |
abaf1f1d | 1874 | } |
e23fbb27 | 1875 | |
abaf1f1d | 1876 | } |
1877 | } | |
1878 | ||
1879 | if (fCompress) { | |
1880 | digitsIn->Compress(1,0); | |
1881 | digitsOut->Compress(1,0); | |
1882 | for (iDict = 0; iDict < kNDict; iDict++) { | |
1883 | dictionaryIn[iDict]->Compress(1,0); | |
1884 | dictionaryOut[iDict]->Compress(1,0); | |
1885 | } | |
1886 | } | |
1887 | ||
e23fbb27 | 1888 | delete [] inADC; |
1889 | delete [] outADC; | |
1890 | ||
abaf1f1d | 1891 | } |
f7336fa3 | 1892 | |
1893 | return kTRUE; | |
1894 | ||
1895 | } | |
1896 | ||
16bf9884 | 1897 | //_____________________________________________________________________________ |
abaf1f1d | 1898 | Bool_t AliTRDdigitizer::MergeSDigits() |
16bf9884 | 1899 | { |
1900 | // | |
abaf1f1d | 1901 | // Merges the input s-digits: |
1902 | // - The amplitude of the different inputs are summed up. | |
1903 | // - Of the track IDs from the input dictionaries only one is | |
1904 | // kept for each input. This works for maximal 3 different merged inputs. | |
16bf9884 | 1905 | // |
1906 | ||
abaf1f1d | 1907 | // Number of track dictionary arrays |
1908 | const Int_t kNDict = AliTRDdigitsManager::kNDict; | |
1909 | ||
1910 | Int_t iDict = 0; | |
e23fbb27 | 1911 | Int_t jDict = 0; |
abaf1f1d | 1912 | |
1913 | AliTRDdataArrayI *digitsA; | |
1914 | AliTRDdataArrayI *digitsB; | |
1915 | AliTRDdataArrayI *dictionaryA[kNDict]; | |
1916 | AliTRDdataArrayI *dictionaryB[kNDict]; | |
1917 | ||
1918 | // Get the first s-digits | |
1919 | fSDigitsManager = (AliTRDdigitsManager *) fSDigitsManagerList->First(); | |
1920 | if (!fSDigitsManager) return kFALSE; | |
1921 | ||
1922 | // Loop through the other sets of s-digits | |
1923 | AliTRDdigitsManager *mergeSDigitsManager; | |
1924 | mergeSDigitsManager = (AliTRDdigitsManager *) | |
1925 | fSDigitsManagerList->After(fSDigitsManager); | |
1926 | ||
e23fbb27 | 1927 | if (fDebug > 0) { |
abaf1f1d | 1928 | if (mergeSDigitsManager) { |
e23fbb27 | 1929 | printf("<AliTRDdigitizer::MergeSDigits> "); |
1930 | printf("Merge %d input files.\n",fSDigitsManagerList->GetSize()); | |
abaf1f1d | 1931 | } |
1932 | else { | |
e23fbb27 | 1933 | printf("<AliTRDdigitizer::MergeSDigits> "); |
abaf1f1d | 1934 | printf("Only one input file.\n"); |
1935 | } | |
1936 | } | |
1937 | ||
1938 | Int_t iMerge = 0; | |
1939 | while (mergeSDigitsManager) { | |
1940 | ||
1941 | iMerge++; | |
1942 | ||
1943 | // Loop through the detectors | |
1944 | for (Int_t iDet = 0; iDet < AliTRDgeometry::Ndet(); iDet++) { | |
1945 | ||
1946 | Int_t plane = fGeo->GetPlane(iDet); | |
1947 | Int_t sector = fGeo->GetSector(iDet); | |
1948 | Int_t chamber = fGeo->GetChamber(iDet); | |
1949 | Int_t nRowMax = fGeo->GetRowMax(plane,chamber,sector); | |
1950 | Int_t nColMax = fGeo->GetColMax(plane); | |
1951 | Int_t nTimeTotal = fGeo->GetTimeTotal(); | |
1952 | ||
1953 | // Loop through the pixels of one detector and add the signals | |
1954 | digitsA = fSDigitsManager->GetDigits(iDet); | |
1955 | digitsB = mergeSDigitsManager->GetDigits(iDet); | |
1956 | digitsA->Expand(); | |
1957 | digitsB->Expand(); | |
1958 | for (iDict = 0; iDict < kNDict; iDict++) { | |
1959 | dictionaryA[iDict] = fSDigitsManager->GetDictionary(iDet,iDict); | |
1960 | dictionaryB[iDict] = mergeSDigitsManager->GetDictionary(iDet,iDict); | |
1961 | dictionaryA[iDict]->Expand(); | |
1962 | dictionaryB[iDict]->Expand(); | |
1963 | } | |
1964 | ||
e23fbb27 | 1965 | if (fDebug > 0) { |
1966 | printf("<AliTRDdigitizer::MergeSDigits> "); | |
1967 | printf("Merge detector %d of input no.%d\n",iDet,iMerge+1); | |
abaf1f1d | 1968 | } |
1969 | ||
1970 | for (Int_t iRow = 0; iRow < nRowMax; iRow++ ) { | |
1971 | for (Int_t iCol = 0; iCol < nColMax; iCol++ ) { | |
1972 | for (Int_t iTime = 0; iTime < nTimeTotal; iTime++) { | |
1973 | ||
1974 | // Add the amplitudes of the summable digits | |
1975 | Int_t ampA = digitsA->GetDataUnchecked(iRow,iCol,iTime); | |
1976 | Int_t ampB = digitsB->GetDataUnchecked(iRow,iCol,iTime); | |
1977 | ampA += ampB; | |
1978 | digitsA->SetDataUnchecked(iRow,iCol,iTime,ampA); | |
1979 | ||
e23fbb27 | 1980 | // Add the mask to the track id if defined. |
1981 | for (iDict = 0; iDict < kNDict; iDict++) { | |
1982 | Int_t trackB = dictionaryB[iDict]->GetDataUnchecked(iRow,iCol,iTime); | |
1983 | if ((fMasks) && (trackB > 0)) { | |
1984 | for (jDict = 0; jDict < kNDict; jDict++) { | |
1985 | Int_t trackA = dictionaryA[iDict]->GetDataUnchecked(iRow,iCol,iTime); | |
1986 | if (trackA == 0) { | |
1987 | trackA = trackB + fMasks[iMerge]; | |
1988 | dictionaryA[iDict]->SetDataUnchecked(iRow,iCol,iTime,trackA); | |
1989 | } | |
1990 | } | |
1991 | } | |
abaf1f1d | 1992 | } |
1993 | ||
1994 | } | |
1995 | } | |
1996 | } | |
1997 | ||
1998 | if (fCompress) { | |
1999 | digitsA->Compress(1,0); | |
2000 | digitsB->Compress(1,0); | |
2001 | for (iDict = 0; iDict < kNDict; iDict++) { | |
2002 | dictionaryA[iDict]->Compress(1,0); | |
2003 | dictionaryB[iDict]->Compress(1,0); | |
2004 | } | |
2005 | } | |
2006 | ||
2007 | } | |
2008 | ||
2009 | // The next set of s-digits | |
2010 | mergeSDigitsManager = (AliTRDdigitsManager *) | |
2011 | fSDigitsManagerList->After(mergeSDigitsManager); | |
2012 | ||
2013 | } | |
2014 | ||
16bf9884 | 2015 | return kTRUE; |
2016 | ||
2017 | } | |
2018 | ||
abaf1f1d | 2019 | //_____________________________________________________________________________ |
2020 | Bool_t AliTRDdigitizer::SDigits2Digits() | |
2021 | { | |
2022 | // | |
2023 | // Merges the input s-digits and converts them to normal digits | |
2024 | // | |
2025 | ||
2026 | if (!MergeSDigits()) return kFALSE; | |
2027 | ||
2028 | return ConvertSDigits(); | |
2029 | ||
2030 | } | |
2031 | ||
793ff80c | 2032 | //_____________________________________________________________________________ |
2033 | Bool_t AliTRDdigitizer::CheckDetector(Int_t plane, Int_t chamber, Int_t sector) | |
2034 | { | |
2035 | // | |
2036 | // Checks whether a detector is enabled | |
2037 | // | |
2038 | ||
2039 | if ((fTRD->GetSensChamber() >= 0) && | |
2040 | (fTRD->GetSensChamber() != chamber)) return kFALSE; | |
2041 | if ((fTRD->GetSensPlane() >= 0) && | |
c1e4b257 | 2042 | (fTRD->GetSensPlane() != plane)) return kFALSE; |
793ff80c | 2043 | if ( fTRD->GetSensSector() >= 0) { |
2044 | Int_t sens1 = fTRD->GetSensSector(); | |
2045 | Int_t sens2 = sens1 + fTRD->GetSensSectorRange(); | |
2046 | sens2 -= ((Int_t) (sens2 / AliTRDgeometry::Nsect())) | |
2047 | * AliTRDgeometry::Nsect(); | |
2048 | if (sens1 < sens2) { | |
2049 | if ((sector < sens1) || (sector >= sens2)) return kFALSE; | |
2050 | } | |
2051 | else { | |
2052 | if ((sector < sens1) && (sector >= sens2)) return kFALSE; | |
2053 | } | |
2054 | } | |
2055 | ||
2056 | return kTRUE; | |
2057 | ||
2058 | } | |
2059 | ||
f7336fa3 | 2060 | //_____________________________________________________________________________ |
2061 | Bool_t AliTRDdigitizer::WriteDigits() | |
2062 | { | |
2063 | // | |
2064 | // Writes out the TRD-digits and the dictionaries | |
2065 | // | |
2066 | ||
da581aea | 2067 | // Store the digits and the dictionary in the tree |
abaf1f1d | 2068 | return fDigitsManager->WriteDigits(); |
f7336fa3 | 2069 | |
2070 | } | |
793ff80c | 2071 | |
e23fbb27 | 2072 | //_____________________________________________________________________________ |
2073 | void AliTRDdigitizer::SetTiltingAngle(Float_t v) | |
2074 | { | |
2075 | // | |
2076 | // Set the tilting angle for the readout pads | |
2077 | // | |
2078 | ||
2079 | fTiltingAngle = TMath::Tan(TMath::Pi()/180.0 * v); | |
2080 | ||
2081 | } | |
2082 | ||
2083 | //_____________________________________________________________________________ | |
2084 | Float_t AliTRDdigitizer::GetTiltingAngle() const | |
2085 | { | |
2086 | // | |
2087 | // Get the tilting angle for the readout pads | |
2088 | // | |
2089 | ||
2090 | return TMath::ATan(180.0/TMath::Pi() * fTiltingAngle); | |
2091 | ||
2092 | } | |
2093 | ||
793ff80c | 2094 | //_____________________________________________________________________________ |
db30bf0f | 2095 | Float_t AliTRDdigitizer::GetDiffusionL(Float_t vd, Float_t b) |
793ff80c | 2096 | { |
2097 | // | |
db30bf0f | 2098 | // Returns the longitudinal diffusion coefficient for a given drift |
2099 | // velocity <vd> and a B-field <b> for Xe/CO2 (15%). | |
2100 | // The values are according to a GARFIELD simulation. | |
793ff80c | 2101 | // |
2102 | ||
db30bf0f | 2103 | const Int_t kNb = 5; |
2104 | Float_t p0[kNb] = { 0.007440, 0.007493, 0.007513, 0.007672, 0.007831 }; | |
2105 | Float_t p1[kNb] = { 0.019252, 0.018912, 0.018636, 0.018012, 0.017343 }; | |
2106 | Float_t p2[kNb] = { -0.005042, -0.004926, -0.004867, -0.004650, -0.004424 }; | |
2107 | Float_t p3[kNb] = { 0.000195, 0.000189, 0.000195, 0.000182, 0.000169 }; | |
2108 | ||
2109 | Int_t ib = ((Int_t) (10 * (b - 0.15))); | |
2110 | ib = TMath::Max( 0,ib); | |
2111 | ib = TMath::Min(kNb,ib); | |
2112 | ||
2113 | Float_t diff = p0[ib] | |
2114 | + p1[ib] * vd | |
2115 | + p2[ib] * vd*vd | |
2116 | + p3[ib] * vd*vd*vd; | |
2117 | ||
2118 | return diff; | |
2119 | ||
2120 | } | |
2121 | ||
2122 | //_____________________________________________________________________________ | |
2123 | Float_t AliTRDdigitizer::GetDiffusionT(Float_t vd, Float_t b) | |
2124 | { | |
2125 | // | |
2126 | // Returns the transverse diffusion coefficient for a given drift | |
2127 | // velocity <vd> and a B-field <b> for Xe/CO2 (15%). | |
2128 | // The values are according to a GARFIELD simulation. | |
2129 | // | |
2130 | ||
2131 | const Int_t kNb = 5; | |
2132 | Float_t p0[kNb] = { 0.009550, 0.009599, 0.009674, 0.009757, 0.009850 }; | |
2133 | Float_t p1[kNb] = { 0.006667, 0.006539, 0.006359, 0.006153, 0.005925 }; | |
2134 | Float_t p2[kNb] = { -0.000853, -0.000798, -0.000721, -0.000635, -0.000541 }; | |
2135 | Float_t p3[kNb] = { 0.000131, 0.000122, 0.000111, 0.000098, 0.000085 }; | |
2136 | ||
2137 | Int_t ib = ((Int_t) (10 * (b - 0.15))); | |
2138 | ib = TMath::Max( 0,ib); | |
2139 | ib = TMath::Min(kNb,ib); | |
2140 | ||
2141 | Float_t diff = p0[ib] | |
2142 | + p1[ib] * vd | |
2143 | + p2[ib] * vd*vd | |
2144 | + p3[ib] * vd*vd*vd; | |
2145 | ||
2146 | return diff; | |
2147 | ||
2148 | } | |
2149 | ||
2150 | //_____________________________________________________________________________ | |
2151 | Float_t AliTRDdigitizer::GetOmegaTau(Float_t vd, Float_t b) | |
2152 | { | |
2153 | // | |
2154 | // Returns omega*tau (tan(Lorentz-angle)) for a given drift velocity <vd> | |
2155 | // and a B-field <b> for Xe/CO2 (15%). | |
2156 | // The values are according to a GARFIELD simulation. | |
2157 | // | |
2158 | ||
2159 | const Int_t kNb = 5; | |
2160 | Float_t p0[kNb] = { 0.004810, 0.007412, 0.010252, 0.013409, 0.016888 }; | |
2161 | Float_t p1[kNb] = { 0.054875, 0.081534, 0.107333, 0.131983, 0.155455 }; | |
2162 | Float_t p2[kNb] = { -0.008682, -0.012896, -0.016987, -0.020880, -0.024623 }; | |
2163 | Float_t p3[kNb] = { 0.000155, 0.000238, 0.000330, 0.000428, 0.000541 }; | |
2164 | ||
2165 | Int_t ib = ((Int_t) (10 * (b - 0.15))); | |
2166 | ib = TMath::Max( 0,ib); | |
2167 | ib = TMath::Min(kNb,ib); | |
2168 | ||
2169 | Float_t alphaL = p0[ib] | |
2170 | + p1[ib] * vd | |
2171 | + p2[ib] * vd*vd | |
2172 | + p3[ib] * vd*vd*vd; | |
2173 | ||
2174 | return TMath::Tan(alphaL); | |
793ff80c | 2175 | |
2176 | } | |
2177 | ||
e23fbb27 | 2178 | //_____________________________________________________________________________ |
2179 | void AliTRDdigitizer::DeConvExp(Double_t *source, Double_t *target | |
2180 | , Int_t n, Int_t nexp) | |
2181 | { | |
2182 | // | |
2183 | // Does the deconvolution by the digital filter. | |
2184 | // | |
2185 | // Author: Marcus Gutfleisch, KIP Heidelberg | |
2186 | // Optimized for: New TRF from Venelin Angelov, simulated with CADENCE | |
2187 | // Pad-ground capacitance = 25 pF | |
2188 | // Pad-pad cross talk capacitance = 6 pF | |
2189 | // For 10 MHz digitization, corresponding to 20 time bins | |
2190 | // in the drift region | |
2191 | // | |
2192 | ||
2193 | Double_t rates[2]; | |
2194 | Double_t coefficients[2]; | |
2195 | ||
2196 | /* initialize (coefficient = alpha, rates = lambda) */ | |
2197 | ||
2198 | if( nexp == 1 ) { | |
2199 | rates[0] = 0.466998; | |
2200 | /* no rescaling */ | |
2201 | coefficients[0] = 1.0; | |
2202 | } | |
2203 | if( nexp == 2 ) { | |
2204 | rates[0] = 0.8988162; | |
2205 | coefficients[0] = 0.11392069; | |
2206 | rates[1] = 0.3745688; | |
2207 | coefficients[1] = 0.8860793; | |
2208 | /* no rescaling */ | |
2209 | Float_t sumc = coefficients[0]+coefficients[1]; | |
2210 | coefficients[0] /= sumc; | |
2211 | coefficients[1] /= sumc; | |
2212 | } | |
2213 | ||
2214 | Int_t i, k; | |
2215 | Double_t reminder[2]; | |
2216 | Double_t correction, result; | |
2217 | ||
2218 | /* attention: computation order is important */ | |
2219 | correction=0.0; | |
2220 | for ( k = 0; k < nexp; k++ ) reminder[k]=0.0; | |
2221 | ||
2222 | for ( i = 0; i < n; i++ ) { | |
2223 | result = ( source[i] - correction ); /* no rescaling */ | |
2224 | target[i] = result; | |
2225 | ||
2226 | for ( k = 0; k < nexp; k++ ) reminder[k] = rates[k] | |
2227 | * ( reminder[k] + coefficients[k] * result); | |
2228 | ||
2229 | correction=0.0; | |
2230 | for ( k = 0; k < nexp; k++ ) correction += reminder[k]; | |
2231 | } | |
2232 | ||
2233 | } | |
2234 |