]>
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$ | |
0a29d0f1 | 18 | Revision 1.34 2002/03/25 20:00:44 cblume |
19 | Introduce parameter class and regions of interest for merging | |
20 | ||
4487dad0 | 21 | Revision 1.33 2002/02/12 17:32:03 cblume |
22 | Rearrange the deleting of the list of sdigitsmanager | |
23 | ||
b1113c6b | 24 | Revision 1.32 2002/02/12 16:07:21 cblume |
25 | Add new constructor | |
26 | ||
bfc40adc | 27 | Revision 1.31 2002/02/11 14:27:11 cblume |
28 | New pad plane design, new TRF+PRF, tail cancelation, cross talk | |
29 | ||
e23fbb27 | 30 | Revision 1.30 2001/11/19 08:44:08 cblume |
31 | Fix bugs reported by Rene | |
32 | ||
a1c3aded | 33 | Revision 1.29 2001/11/14 19:44:25 hristov |
34 | Numeric const casted (Alpha) | |
35 | ||
20c69486 | 36 | Revision 1.28 2001/11/14 16:35:58 cblume |
37 | Inherits now from AliDetector | |
38 | ||
85cbec76 | 39 | Revision 1.27 2001/11/14 10:50:45 cblume |
40 | Changes in digits IO. Add merging of summable digits | |
41 | ||
abaf1f1d | 42 | Revision 1.26 2001/11/06 17:19:41 cblume |
43 | Add detailed geometry and simple simulator | |
44 | ||
16bf9884 | 45 | Revision 1.25 2001/06/27 09:54:44 cblume |
46 | Moved fField initialization to InitDetector() | |
47 | ||
88fd7ccb | 48 | Revision 1.24 2001/05/21 16:45:47 hristov |
49 | Last minute changes (C.Blume) | |
50 | ||
db30bf0f | 51 | Revision 1.23 2001/05/07 08:04:48 cblume |
52 | New TRF and PRF. Speedup of the code. Digits from amplification region included | |
53 | ||
872a7aba | 54 | Revision 1.22 2001/03/30 14:40:14 cblume |
55 | Update of the digitization parameter | |
56 | ||
a3c76cdc | 57 | Revision 1.21 2001/03/13 09:30:35 cblume |
58 | Update of digitization. Moved digit branch definition to AliTRD | |
59 | ||
6244debe | 60 | Revision 1.20 2001/02/25 20:19:00 hristov |
61 | Minor correction: loop variable declared only once for HP, Sun | |
62 | ||
c3a4830f | 63 | Revision 1.19 2001/02/14 18:22:26 cblume |
64 | Change in the geometry of the padplane | |
65 | ||
71d9fa7b | 66 | Revision 1.18 2001/01/26 19:56:57 hristov |
67 | Major upgrade of AliRoot code | |
68 | ||
2ab0c725 | 69 | Revision 1.17 2000/12/08 12:53:27 cblume |
70 | Change in Copy() function for HP-compiler | |
71 | ||
1948ba0c | 72 | Revision 1.16 2000/12/07 12:20:46 cblume |
73 | Go back to array compression. Use sampled PRF to speed up digitization | |
74 | ||
e153aaf6 | 75 | Revision 1.15 2000/11/23 14:34:08 cblume |
76 | Fixed bug in expansion routine of arrays (initialize buffers properly) | |
77 | ||
259b9e4b | 78 | Revision 1.14 2000/11/20 08:54:44 cblume |
79 | Switch off compression as default | |
80 | ||
c1e4b257 | 81 | Revision 1.13 2000/11/10 14:57:52 cblume |
82 | Changes in the geometry constants for the DEC compiler | |
83 | ||
dd56b762 | 84 | Revision 1.12 2000/11/01 14:53:20 cblume |
85 | Merge with TRD-develop | |
86 | ||
793ff80c | 87 | Revision 1.1.4.9 2000/10/26 17:00:22 cblume |
88 | Fixed bug in CheckDetector() | |
89 | ||
90 | Revision 1.1.4.8 2000/10/23 13:41:35 cblume | |
91 | Added protection against Log(0) in the gas gain calulation | |
92 | ||
93 | Revision 1.1.4.7 2000/10/17 02:27:34 cblume | |
94 | Get rid of global constants | |
95 | ||
96 | Revision 1.1.4.6 2000/10/16 01:16:53 cblume | |
97 | Changed timebin 0 to be the one closest to the readout | |
98 | ||
99 | Revision 1.1.4.5 2000/10/15 23:34:29 cblume | |
100 | Faster version of the digitizer | |
101 | ||
102 | Revision 1.1.4.4 2000/10/06 16:49:46 cblume | |
103 | Made Getters const | |
104 | ||
105 | Revision 1.1.4.3 2000/10/04 16:34:58 cblume | |
106 | Replace include files by forward declarations | |
107 | ||
108 | Revision 1.1.4.2 2000/09/22 14:41:10 cblume | |
109 | Bug fix in PRF. Included time response. New structure | |
110 | ||
eda4336d | 111 | Revision 1.10 2000/10/05 07:27:53 cblume |
112 | Changes in the header-files by FCA | |
113 | ||
6798b56e | 114 | Revision 1.9 2000/10/02 21:28:19 fca |
115 | Removal of useless dependecies via forward declarations | |
116 | ||
94de3818 | 117 | Revision 1.8 2000/06/09 11:10:07 cblume |
118 | Compiler warnings and coding conventions, next round | |
119 | ||
dd9a6ee3 | 120 | Revision 1.7 2000/06/08 18:32:58 cblume |
121 | Make code compliant to coding conventions | |
122 | ||
8230f242 | 123 | Revision 1.6 2000/06/07 16:27:32 cblume |
124 | Try to remove compiler warnings on Sun and HP | |
125 | ||
9d0b222b | 126 | Revision 1.5 2000/05/09 16:38:57 cblume |
127 | Removed PadResponse(). Merge problem | |
128 | ||
f0a7bf65 | 129 | Revision 1.4 2000/05/08 15:53:45 cblume |
130 | Resolved merge conflict | |
131 | ||
da581aea | 132 | Revision 1.3 2000/04/28 14:49:27 cblume |
133 | Only one declaration of iDict in MakeDigits() | |
134 | ||
135 | Revision 1.1.4.1 2000/05/08 14:42:04 cblume | |
136 | Introduced AliTRDdigitsManager | |
28329a48 | 137 | |
1befd3b2 | 138 | Revision 1.1 2000/02/28 19:00:13 cblume |
139 | Add new TRD classes | |
140 | ||
f7336fa3 | 141 | */ |
142 | ||
143 | /////////////////////////////////////////////////////////////////////////////// | |
144 | // // | |
145 | // Creates and handles digits from TRD hits // | |
abaf1f1d | 146 | // Author: C. Blume (C.Blume@gsi.de) // |
f7336fa3 | 147 | // // |
148 | // The following effects are included: // | |
149 | // - Diffusion // | |
150 | // - ExB effects // | |
151 | // - Gas gain including fluctuations // | |
152 | // - Pad-response (simple Gaussian approximation) // | |
abaf1f1d | 153 | // - Time-response // |
f7336fa3 | 154 | // - Electronics noise // |
155 | // - Electronics gain // | |
156 | // - Digitization // | |
157 | // - ADC threshold // | |
158 | // The corresponding parameter can be adjusted via the various // | |
159 | // Set-functions. If these parameters are not explicitly set, default // | |
160 | // values are used (see Init-function). // | |
abaf1f1d | 161 | // As an example on how to use this class to produce digits from hits // |
162 | // have a look at the macro hits2digits.C // | |
163 | // The production of summable digits is demonstrated in hits2sdigits.C // | |
164 | // and the subsequent conversion of the s-digits into normal digits is // | |
165 | // explained in sdigits2digits.C. // | |
f7336fa3 | 166 | // // |
167 | /////////////////////////////////////////////////////////////////////////////// | |
168 | ||
6798b56e | 169 | #include <stdlib.h> |
170 | ||
f7336fa3 | 171 | #include <TMath.h> |
172 | #include <TVector.h> | |
173 | #include <TRandom.h> | |
94de3818 | 174 | #include <TROOT.h> |
175 | #include <TTree.h> | |
793ff80c | 176 | #include <TFile.h> |
177 | #include <TF1.h> | |
abaf1f1d | 178 | #include <TList.h> |
85cbec76 | 179 | #include <TTask.h> |
793ff80c | 180 | |
181 | #include "AliRun.h" | |
db30bf0f | 182 | #include "AliMagF.h" |
85cbec76 | 183 | #include "AliRunDigitizer.h" |
f7336fa3 | 184 | |
185 | #include "AliTRD.h" | |
793ff80c | 186 | #include "AliTRDhit.h" |
f7336fa3 | 187 | #include "AliTRDdigitizer.h" |
da581aea | 188 | #include "AliTRDdataArrayI.h" |
189 | #include "AliTRDdataArrayF.h" | |
793ff80c | 190 | #include "AliTRDsegmentArray.h" |
da581aea | 191 | #include "AliTRDdigitsManager.h" |
793ff80c | 192 | #include "AliTRDgeometry.h" |
4487dad0 | 193 | #include "AliTRDparameter.h" |
f7336fa3 | 194 | |
195 | ClassImp(AliTRDdigitizer) | |
196 | ||
197 | //_____________________________________________________________________________ | |
85cbec76 | 198 | AliTRDdigitizer::AliTRDdigitizer() |
f7336fa3 | 199 | { |
200 | // | |
201 | // AliTRDdigitizer default constructor | |
202 | // | |
203 | ||
4487dad0 | 204 | fInputFile = 0; |
205 | fDigitsManager = 0; | |
206 | fSDigitsManagerList = 0; | |
207 | fSDigitsManager = 0; | |
208 | fTRD = 0; | |
209 | fGeo = 0; | |
210 | fPar = 0; | |
e23fbb27 | 211 | fMasks = 0; |
abaf1f1d | 212 | fEvent = 0; |
abaf1f1d | 213 | fCompress = kTRUE; |
e23fbb27 | 214 | fDebug = 0; |
abaf1f1d | 215 | fSDigits = kFALSE; |
216 | fSDigitsScale = 0.0; | |
4487dad0 | 217 | fMergeSignalOnly = kFALSE; |
f7336fa3 | 218 | |
219 | } | |
220 | ||
221 | //_____________________________________________________________________________ | |
222 | AliTRDdigitizer::AliTRDdigitizer(const Text_t *name, const Text_t *title) | |
85cbec76 | 223 | :AliDigitizer(name,title) |
f7336fa3 | 224 | { |
225 | // | |
85cbec76 | 226 | // AliTRDdigitizer constructor |
227 | // | |
228 | ||
4487dad0 | 229 | fInputFile = 0; |
230 | fDigitsManager = 0; | |
231 | fSDigitsManagerList = 0; | |
232 | fSDigitsManager = 0; | |
233 | fTRD = 0; | |
234 | fGeo = 0; | |
235 | fPar = 0; | |
e23fbb27 | 236 | fMasks = 0; |
85cbec76 | 237 | fEvent = 0; |
85cbec76 | 238 | fCompress = kTRUE; |
e23fbb27 | 239 | fDebug = 0; |
85cbec76 | 240 | fSDigits = kFALSE; |
4487dad0 | 241 | fMergeSignalOnly = kFALSE; |
85cbec76 | 242 | |
4487dad0 | 243 | // For the summable digits |
244 | fSDigitsScale = 100.; | |
85cbec76 | 245 | |
246 | } | |
247 | ||
248 | //_____________________________________________________________________________ | |
249 | AliTRDdigitizer::AliTRDdigitizer(AliRunDigitizer *manager | |
250 | , const Text_t *name, const Text_t *title) | |
251 | :AliDigitizer(manager,name,title) | |
252 | { | |
253 | // | |
254 | // AliTRDdigitizer constructor | |
f7336fa3 | 255 | // |
256 | ||
4487dad0 | 257 | fInputFile = 0; |
258 | fDigitsManager = 0; | |
259 | fSDigitsManagerList = 0; | |
260 | fSDigitsManager = 0; | |
261 | fTRD = 0; | |
262 | fGeo = 0; | |
263 | fPar = 0; | |
bfc40adc | 264 | fMasks = 0; |
bfc40adc | 265 | fEvent = 0; |
bfc40adc | 266 | fCompress = kTRUE; |
267 | fDebug = 0; | |
268 | fSDigits = kFALSE; | |
4487dad0 | 269 | fMergeSignalOnly = kFALSE; |
bfc40adc | 270 | |
4487dad0 | 271 | // For the summable digits |
272 | fSDigitsScale = 100.; | |
bfc40adc | 273 | |
274 | } | |
275 | ||
276 | //_____________________________________________________________________________ | |
277 | AliTRDdigitizer::AliTRDdigitizer(AliRunDigitizer *manager) | |
278 | :AliDigitizer(manager,"AliTRDdigitizer","TRD digitizer") | |
279 | { | |
280 | // | |
281 | // AliTRDdigitizer constructor | |
282 | // | |
283 | ||
4487dad0 | 284 | fInputFile = 0; |
285 | fDigitsManager = 0; | |
286 | fSDigitsManagerList = 0; | |
287 | fSDigitsManager = 0; | |
288 | fTRD = 0; | |
289 | fGeo = 0; | |
290 | fPar = 0; | |
e23fbb27 | 291 | fMasks = 0; |
abaf1f1d | 292 | fEvent = 0; |
abaf1f1d | 293 | fCompress = kTRUE; |
e23fbb27 | 294 | fDebug = 0; |
abaf1f1d | 295 | fSDigits = kFALSE; |
4487dad0 | 296 | fMergeSignalOnly = kFALSE; |
793ff80c | 297 | |
4487dad0 | 298 | // For the summable digits |
299 | fSDigitsScale = 100.; | |
f7336fa3 | 300 | |
301 | } | |
302 | ||
8230f242 | 303 | //_____________________________________________________________________________ |
dd9a6ee3 | 304 | AliTRDdigitizer::AliTRDdigitizer(const AliTRDdigitizer &d) |
8230f242 | 305 | { |
306 | // | |
307 | // AliTRDdigitizer copy constructor | |
308 | // | |
309 | ||
dd9a6ee3 | 310 | ((AliTRDdigitizer &) d).Copy(*this); |
8230f242 | 311 | |
312 | } | |
313 | ||
f7336fa3 | 314 | //_____________________________________________________________________________ |
315 | AliTRDdigitizer::~AliTRDdigitizer() | |
316 | { | |
8230f242 | 317 | // |
318 | // AliTRDdigitizer destructor | |
319 | // | |
f7336fa3 | 320 | |
321 | if (fInputFile) { | |
322 | fInputFile->Close(); | |
323 | delete fInputFile; | |
4487dad0 | 324 | fInputFile = 0; |
abaf1f1d | 325 | } |
326 | ||
327 | if (fDigitsManager) { | |
328 | delete fDigitsManager; | |
4487dad0 | 329 | fDigitsManager = 0; |
f7336fa3 | 330 | } |
331 | ||
abaf1f1d | 332 | if (fSDigitsManager) { |
333 | delete fSDigitsManager; | |
4487dad0 | 334 | fSDigitsManager = 0; |
f7336fa3 | 335 | } |
336 | ||
abaf1f1d | 337 | if (fSDigitsManagerList) { |
abaf1f1d | 338 | delete fSDigitsManagerList; |
4487dad0 | 339 | fSDigitsManagerList = 0; |
e23fbb27 | 340 | } |
341 | ||
342 | if (fMasks) { | |
343 | delete [] fMasks; | |
344 | fMasks = 0; | |
345 | } | |
346 | ||
f7336fa3 | 347 | } |
348 | ||
8230f242 | 349 | //_____________________________________________________________________________ |
dd9a6ee3 | 350 | AliTRDdigitizer &AliTRDdigitizer::operator=(const AliTRDdigitizer &d) |
351 | { | |
352 | // | |
353 | // Assignment operator | |
354 | // | |
355 | ||
356 | if (this != &d) ((AliTRDdigitizer &) d).Copy(*this); | |
357 | return *this; | |
358 | ||
359 | } | |
360 | ||
361 | //_____________________________________________________________________________ | |
362 | void AliTRDdigitizer::Copy(TObject &d) | |
8230f242 | 363 | { |
364 | // | |
365 | // Copy function | |
366 | // | |
367 | ||
4487dad0 | 368 | ((AliTRDdigitizer &) d).fInputFile = 0; |
369 | ((AliTRDdigitizer &) d).fSDigitsManagerList = 0; | |
370 | ((AliTRDdigitizer &) d).fSDigitsManager = 0; | |
371 | ((AliTRDdigitizer &) d).fDigitsManager = 0; | |
372 | ((AliTRDdigitizer &) d).fTRD = 0; | |
373 | ((AliTRDdigitizer &) d).fGeo = 0; | |
e23fbb27 | 374 | ((AliTRDdigitizer &) d).fMasks = 0; |
abaf1f1d | 375 | ((AliTRDdigitizer &) d).fEvent = 0; |
4487dad0 | 376 | ((AliTRDdigitizer &) d).fPar = 0; |
abaf1f1d | 377 | ((AliTRDdigitizer &) d).fCompress = fCompress; |
e23fbb27 | 378 | ((AliTRDdigitizer &) d).fDebug = fDebug ; |
abaf1f1d | 379 | ((AliTRDdigitizer &) d).fSDigits = fSDigits; |
380 | ((AliTRDdigitizer &) d).fSDigitsScale = fSDigitsScale; | |
4487dad0 | 381 | ((AliTRDdigitizer &) d).fMergeSignalOnly = fMergeSignalOnly; |
e23fbb27 | 382 | |
383 | } | |
384 | ||
e23fbb27 | 385 | //_____________________________________________________________________________ |
386 | void AliTRDdigitizer::Exec(Option_t* option) | |
387 | { | |
388 | // | |
389 | // Executes the merging | |
390 | // | |
391 | ||
392 | Int_t iInput; | |
393 | ||
394 | AliTRDdigitsManager *sdigitsManager; | |
395 | ||
396 | TString optionString = option; | |
397 | if (optionString.Contains("deb")) { | |
398 | fDebug = 1; | |
399 | if (optionString.Contains("2")) { | |
400 | fDebug = 2; | |
401 | } | |
402 | printf("<AliTRDdigitizer::Exec> "); | |
403 | printf("Called with debug option %d\n",fDebug); | |
404 | } | |
405 | ||
4487dad0 | 406 | // Connect the AliRoot file containing Geometry, Kine, and Hits |
407 | fInputFile = (TFile *) fManager->GetInputTreeTRDS(0)->GetCurrentFile(); | |
408 | if (!fInputFile) { | |
409 | if (fDebug > 0) { | |
410 | printf("<AliTRDdigitizer::Exec> "); | |
411 | printf("Cannot open the input file %s.\n",fInputFile->GetName()); | |
412 | } | |
413 | } | |
414 | ||
415 | if (gAlice) { | |
416 | delete gAlice; | |
417 | gAlice = 0; | |
418 | } | |
419 | gAlice = (AliRun *) fInputFile->Get("gAlice"); | |
420 | if (gAlice) { | |
421 | if (fDebug > 0) { | |
422 | printf("<AliTRDdigitizer::Exec> "); | |
423 | printf("AliRun object found on file.\n"); | |
424 | } | |
425 | } | |
426 | else { | |
427 | printf("<AliTRDdigitizer::Exec> "); | |
428 | printf("Could not find AliRun object.\n"); | |
429 | } | |
430 | ||
e23fbb27 | 431 | Int_t nInput = fManager->GetNinputs(); |
432 | fMasks = new Int_t[nInput]; | |
433 | for (iInput = 0; iInput < nInput; iInput++) { | |
434 | fMasks[iInput] = fManager->GetMask(iInput); | |
435 | } | |
e23fbb27 | 436 | |
437 | // Initialization | |
438 | InitDetector(); | |
439 | ||
440 | for (iInput = 0; iInput < nInput; iInput++) { | |
441 | ||
442 | if (fDebug > 0) { | |
443 | printf("<AliTRDdigitizer::Exec> "); | |
444 | printf("Add input stream %d\n",iInput); | |
445 | } | |
446 | ||
447 | // Read the s-digits via digits manager | |
448 | sdigitsManager = new AliTRDdigitsManager(); | |
449 | sdigitsManager->SetDebug(fDebug); | |
450 | sdigitsManager->SetSDigits(kTRUE); | |
451 | sdigitsManager->ReadDigits(fManager->GetInputTreeTRDS(iInput)); | |
452 | ||
453 | // Add the s-digits to the input list | |
454 | AddSDigitsManager(sdigitsManager); | |
455 | ||
456 | } | |
457 | ||
458 | // Convert the s-digits to normal digits | |
459 | if (fDebug > 0) { | |
460 | printf("<AliTRDdigitizer::Exec> "); | |
461 | printf("Do the conversion\n"); | |
462 | } | |
463 | SDigits2Digits(); | |
464 | ||
465 | // Store the digits | |
466 | if (fDebug > 0) { | |
467 | printf("<AliTRDdigitizer::Exec> "); | |
468 | printf("Write the digits\n"); | |
469 | } | |
470 | fDigitsManager->MakeBranch(fManager->GetTreeDTRD()); | |
471 | fDigitsManager->WriteDigits(); | |
472 | if (fDebug > 0) { | |
473 | printf("<AliTRDdigitizer::Exec> "); | |
474 | printf("Done\n"); | |
475 | } | |
476 | ||
b1113c6b | 477 | DeleteSDigitsManager(); |
478 | ||
e23fbb27 | 479 | } |
480 | ||
f7336fa3 | 481 | //_____________________________________________________________________________ |
e23fbb27 | 482 | Bool_t AliTRDdigitizer::Open(const Char_t *file, Int_t nEvent) |
f7336fa3 | 483 | { |
484 | // | |
485 | // Opens a ROOT-file with TRD-hits and reads in the hit-tree | |
486 | // | |
487 | ||
488 | // Connect the AliRoot file containing Geometry, Kine, and Hits | |
4487dad0 | 489 | fInputFile = (TFile *) gROOT->GetListOfFiles()->FindObject(file); |
f7336fa3 | 490 | if (!fInputFile) { |
e23fbb27 | 491 | if (fDebug > 0) { |
492 | printf("<AliTRDdigitizer::Open> "); | |
493 | printf("Open the AliROOT-file %s.\n",file); | |
abaf1f1d | 494 | } |
e23fbb27 | 495 | fInputFile = new TFile(file,"UPDATE"); |
f7336fa3 | 496 | } |
497 | else { | |
e23fbb27 | 498 | if (fDebug > 0) { |
499 | printf("<AliTRDdigitizer::Open> "); | |
500 | printf("%s is already open.\n",file); | |
abaf1f1d | 501 | } |
f7336fa3 | 502 | } |
503 | ||
4487dad0 | 504 | gAlice = (AliRun *) fInputFile->Get("gAlice"); |
da581aea | 505 | if (gAlice) { |
e23fbb27 | 506 | if (fDebug > 0) { |
507 | printf("<AliTRDdigitizer::Open> "); | |
abaf1f1d | 508 | printf("AliRun object found on file.\n"); |
509 | } | |
da581aea | 510 | } |
511 | else { | |
e23fbb27 | 512 | printf("<AliTRDdigitizer::Open> "); |
da581aea | 513 | printf("Could not find AliRun object.\n"); |
514 | return kFALSE; | |
515 | } | |
f7336fa3 | 516 | |
517 | fEvent = nEvent; | |
518 | ||
519 | // Import the Trees for the event nEvent in the file | |
520 | Int_t nparticles = gAlice->GetEvent(fEvent); | |
521 | if (nparticles <= 0) { | |
e23fbb27 | 522 | printf("<AliTRDdigitizer::Open> "); |
f7336fa3 | 523 | printf("No entries in the trees for event %d.\n",fEvent); |
524 | return kFALSE; | |
525 | } | |
526 | ||
abaf1f1d | 527 | if (InitDetector()) { |
528 | return MakeBranch(); | |
529 | } | |
530 | else { | |
531 | return kFALSE; | |
532 | } | |
793ff80c | 533 | |
534 | } | |
535 | ||
536 | //_____________________________________________________________________________ | |
537 | Bool_t AliTRDdigitizer::InitDetector() | |
538 | { | |
539 | // | |
540 | // Sets the pointer to the TRD detector and the geometry | |
541 | // | |
542 | ||
dd9a6ee3 | 543 | // Get the pointer to the detector class and check for version 1 |
4487dad0 | 544 | fTRD = (AliTRD *) gAlice->GetDetector("TRD"); |
dd9a6ee3 | 545 | if (fTRD->IsVersion() != 1) { |
e23fbb27 | 546 | printf("<AliTRDdigitizer::InitDetector> "); |
dd9a6ee3 | 547 | printf("TRD must be version 1 (slow simulator).\n"); |
548 | exit(1); | |
549 | } | |
550 | ||
551 | // Get the geometry | |
552 | fGeo = fTRD->GetGeometry(); | |
e23fbb27 | 553 | if (fDebug > 0) { |
554 | printf("<AliTRDdigitizer::InitDetector> "); | |
abaf1f1d | 555 | printf("Geometry version %d\n",fGeo->IsVersion()); |
556 | } | |
dd9a6ee3 | 557 | |
abaf1f1d | 558 | // Create a digits manager |
559 | fDigitsManager = new AliTRDdigitsManager(); | |
560 | fDigitsManager->SetSDigits(fSDigits); | |
561 | fDigitsManager->CreateArrays(); | |
562 | fDigitsManager->SetEvent(fEvent); | |
e23fbb27 | 563 | fDigitsManager->SetDebug(fDebug); |
abaf1f1d | 564 | |
565 | // The list for the input s-digits manager to be merged | |
566 | fSDigitsManagerList = new TList(); | |
567 | ||
4487dad0 | 568 | return kTRUE; |
f7336fa3 | 569 | |
570 | } | |
571 | ||
6244debe | 572 | //_____________________________________________________________________________ |
0a29d0f1 | 573 | Bool_t AliTRDdigitizer::MakeBranch(const Char_t *file) const |
6244debe | 574 | { |
abaf1f1d | 575 | // |
576 | // Create the branches for the digits array | |
6244debe | 577 | // |
578 | ||
abaf1f1d | 579 | return fDigitsManager->MakeBranch(file); |
6244debe | 580 | |
581 | } | |
582 | ||
f7336fa3 | 583 | //_____________________________________________________________________________ |
584 | Bool_t AliTRDdigitizer::MakeDigits() | |
585 | { | |
586 | // | |
872a7aba | 587 | // Creates digits. |
f7336fa3 | 588 | // |
589 | ||
f7336fa3 | 590 | /////////////////////////////////////////////////////////////// |
591 | // Parameter | |
592 | /////////////////////////////////////////////////////////////// | |
593 | ||
594 | // Converts number of electrons to fC | |
872a7aba | 595 | const Double_t kEl2fC = 1.602E-19 * 1.0E15; |
f7336fa3 | 596 | |
597 | /////////////////////////////////////////////////////////////// | |
598 | ||
793ff80c | 599 | // Number of pads included in the pad response |
600 | const Int_t kNpad = 3; | |
601 | ||
602 | // Number of track dictionary arrays | |
dd56b762 | 603 | const Int_t kNDict = AliTRDdigitsManager::kNDict; |
793ff80c | 604 | |
872a7aba | 605 | // Half the width of the amplification region |
606 | const Float_t kAmWidth = AliTRDgeometry::AmThick() / 2.; | |
607 | ||
c3a4830f | 608 | Int_t iRow, iCol, iTime, iPad; |
71d9fa7b | 609 | Int_t iDict = 0; |
793ff80c | 610 | Int_t nBytes = 0; |
f7336fa3 | 611 | |
612 | Int_t totalSizeDigits = 0; | |
613 | Int_t totalSizeDict0 = 0; | |
614 | Int_t totalSizeDict1 = 0; | |
615 | Int_t totalSizeDict2 = 0; | |
616 | ||
872a7aba | 617 | Int_t timeTRDbeg = 0; |
618 | Int_t timeTRDend = 1; | |
619 | ||
620 | Float_t pos[3]; | |
621 | Float_t rot[3]; | |
622 | Float_t xyz[3]; | |
623 | Float_t padSignal[kNpad]; | |
624 | Float_t signalOld[kNpad]; | |
625 | ||
793ff80c | 626 | AliTRDdataArrayF *signals = 0; |
627 | AliTRDdataArrayI *digits = 0; | |
8230f242 | 628 | AliTRDdataArrayI *dictionary[kNDict]; |
da581aea | 629 | |
4487dad0 | 630 | // Create a default parameter class if none is defined |
631 | if (!fPar) { | |
632 | fPar = new AliTRDparameter("TRDparameter","Standard TRD parameter"); | |
633 | if (fDebug > 0) { | |
634 | printf("<AliTRDdigitizer::MakeDigits> "); | |
635 | printf("Create the default parameter object\n"); | |
636 | } | |
637 | } | |
638 | ||
793ff80c | 639 | // Create a container for the amplitudes |
640 | AliTRDsegmentArray *signalsArray | |
e23fbb27 | 641 | = new AliTRDsegmentArray("AliTRDdataArrayF" |
642 | ,AliTRDgeometry::Ndet()); | |
793ff80c | 643 | |
4487dad0 | 644 | if (fPar->TRFOn()) { |
645 | timeTRDbeg = ((Int_t) (-fPar->GetTRFlo() / fPar->GetTimeBinSize())) - 1; | |
646 | timeTRDend = ((Int_t) ( fPar->GetTRFhi() / fPar->GetTimeBinSize())) - 1; | |
e23fbb27 | 647 | if (fDebug > 0) { |
648 | printf("<AliTRDdigitizer::MakeDigits> "); | |
abaf1f1d | 649 | printf("Sample the TRF between -%d and %d\n",timeTRDbeg,timeTRDend); |
650 | } | |
da581aea | 651 | } |
652 | ||
4487dad0 | 653 | Float_t elAttachProp = fPar->GetElAttachProp() / 100.; |
793ff80c | 654 | |
872a7aba | 655 | if (!fGeo) { |
e23fbb27 | 656 | printf("<AliTRDdigitizer::MakeDigits> "); |
872a7aba | 657 | printf("No geometry defined\n"); |
658 | return kFALSE; | |
659 | } | |
660 | ||
e23fbb27 | 661 | if (fDebug > 0) { |
662 | printf("<AliTRDdigitizer::MakeDigits> "); | |
abaf1f1d | 663 | printf("Start creating digits.\n"); |
664 | } | |
872a7aba | 665 | |
793ff80c | 666 | // Get the pointer to the hit tree |
0a29d0f1 | 667 | TTree *hitTree = gAlice->TreeH(); |
793ff80c | 668 | |
669 | // Get the number of entries in the hit tree | |
670 | // (Number of primary particles creating a hit somewhere) | |
0a29d0f1 | 671 | Int_t nTrack = (Int_t) hitTree->GetEntries(); |
e23fbb27 | 672 | if (fDebug > 0) { |
673 | printf("<AliTRDdigitizer::MakeDigits> "); | |
793ff80c | 674 | printf("Found %d primary particles\n",nTrack); |
675 | } | |
676 | ||
677 | Int_t detectorOld = -1; | |
678 | Int_t countHits = 0; | |
679 | ||
680 | // Loop through all entries in the tree | |
681 | for (Int_t iTrack = 0; iTrack < nTrack; iTrack++) { | |
682 | ||
683 | gAlice->ResetHits(); | |
0a29d0f1 | 684 | nBytes += hitTree->GetEvent(iTrack); |
793ff80c | 685 | |
e23fbb27 | 686 | // Loop through the TRD hits |
687 | Int_t iHit = 0; | |
688 | AliTRDhit *hit = (AliTRDhit *) fTRD->FirstHit(-1); | |
689 | while (hit) { | |
690 | ||
793ff80c | 691 | countHits++; |
e23fbb27 | 692 | iHit++; |
693 | ||
694 | pos[0] = hit->X(); | |
695 | pos[1] = hit->Y(); | |
696 | pos[2] = hit->Z(); | |
697 | Float_t q = hit->GetCharge(); | |
698 | Int_t track = hit->Track(); | |
699 | Int_t detector = hit->GetDetector(); | |
700 | Int_t plane = fGeo->GetPlane(detector); | |
701 | Int_t sector = fGeo->GetSector(detector); | |
702 | Int_t chamber = fGeo->GetChamber(detector); | |
4487dad0 | 703 | Int_t nRowMax = fPar->GetRowMax(plane,chamber,sector); |
704 | Int_t nColMax = fPar->GetColMax(plane); | |
705 | Int_t nTimeMax = fPar->GetTimeMax(); | |
706 | Int_t nTimeBefore = fPar->GetTimeBefore(); | |
707 | Int_t nTimeAfter = fPar->GetTimeAfter(); | |
708 | Int_t nTimeTotal = fPar->GetTimeTotal(); | |
709 | Float_t row0 = fPar->GetRow0(plane,chamber,sector); | |
710 | Float_t col0 = fPar->GetCol0(plane); | |
711 | Float_t time0 = fPar->GetTime0(plane); | |
712 | Float_t rowPadSize = fPar->GetRowPadSize(plane,chamber,sector); | |
713 | Float_t colPadSize = fPar->GetColPadSize(plane); | |
714 | Float_t timeBinSize = fPar->GetTimeBinSize(); | |
872a7aba | 715 | Float_t divideRow = 1.0 / rowPadSize; |
716 | Float_t divideCol = 1.0 / colPadSize; | |
717 | Float_t divideTime = 1.0 / timeBinSize; | |
793ff80c | 718 | |
e23fbb27 | 719 | if (fDebug > 1) { |
793ff80c | 720 | printf("Analyze hit no. %d ",iHit); |
721 | printf("-----------------------------------------------------------\n"); | |
722 | hit->Dump(); | |
723 | printf("plane = %d, sector = %d, chamber = %d\n" | |
724 | ,plane,sector,chamber); | |
725 | printf("nRowMax = %d, nColMax = %d, nTimeMax = %d\n" | |
726 | ,nRowMax,nColMax,nTimeMax); | |
872a7aba | 727 | printf("nTimeBefore = %d, nTimeAfter = %d, nTimeTotal = %d\n" |
728 | ,nTimeBefore,nTimeAfter,nTimeTotal); | |
793ff80c | 729 | printf("row0 = %f, col0 = %f, time0 = %f\n" |
730 | ,row0,col0,time0); | |
c1e4b257 | 731 | printf("rowPadSize = %f, colPadSize = %f, timeBinSize = %f\n" |
732 | ,rowPadSize,colPadSize,timeBinSize); | |
793ff80c | 733 | } |
734 | ||
e23fbb27 | 735 | // Don't analyze test hits and switched off detectors |
736 | if ((CheckDetector(plane,chamber,sector)) && | |
737 | (((Int_t) q) != 0)) { | |
dd56b762 | 738 | |
e23fbb27 | 739 | if (detector != detectorOld) { |
e153aaf6 | 740 | |
e23fbb27 | 741 | if (fDebug > 1) { |
742 | printf("<AliTRDdigitizer::MakeDigits> "); | |
743 | printf("Get new container. New det = %d, Old det = %d\n" | |
744 | ,detector,detectorOld); | |
dd9a6ee3 | 745 | } |
e23fbb27 | 746 | // Compress the old one if enabled |
747 | if ((fCompress) && (detectorOld > -1)) { | |
748 | if (fDebug > 1) { | |
749 | printf("<AliTRDdigitizer::MakeDigits> "); | |
750 | printf("Compress the old container ..."); | |
751 | } | |
752 | signals->Compress(1,0); | |
753 | for (iDict = 0; iDict < kNDict; iDict++) { | |
754 | dictionary[iDict]->Compress(1,0); | |
c1e4b257 | 755 | } |
e23fbb27 | 756 | if (fDebug > 1) printf("done\n"); |
793ff80c | 757 | } |
e23fbb27 | 758 | // Get the new container |
759 | signals = (AliTRDdataArrayF *) signalsArray->At(detector); | |
760 | if (signals->GetNtime() == 0) { | |
761 | // Allocate a new one if not yet existing | |
762 | if (fDebug > 1) { | |
763 | printf("<AliTRDdigitizer::MakeDigits> "); | |
764 | printf("Allocate a new container ... "); | |
765 | } | |
766 | signals->Allocate(nRowMax,nColMax,nTimeTotal); | |
793ff80c | 767 | } |
768 | else { | |
e23fbb27 | 769 | // Expand an existing one |
770 | if (fCompress) { | |
771 | if (fDebug > 1) { | |
772 | printf("<AliTRDdigitizer::MakeDigits> "); | |
773 | printf("Expand an existing container ... "); | |
774 | } | |
775 | signals->Expand(); | |
776 | } | |
793ff80c | 777 | } |
e23fbb27 | 778 | // The same for the dictionary |
779 | for (iDict = 0; iDict < kNDict; iDict++) { | |
780 | dictionary[iDict] = fDigitsManager->GetDictionary(detector,iDict); | |
781 | if (dictionary[iDict]->GetNtime() == 0) { | |
782 | dictionary[iDict]->Allocate(nRowMax,nColMax,nTimeTotal); | |
783 | } | |
784 | else { | |
785 | if (fCompress) dictionary[iDict]->Expand(); | |
786 | } | |
787 | } | |
788 | if (fDebug > 1) printf("done\n"); | |
789 | detectorOld = detector; | |
793ff80c | 790 | } |
791 | ||
e23fbb27 | 792 | // Rotate the sectors on top of each other |
793 | fGeo->Rotate(detector,pos,rot); | |
794 | ||
795 | // The driftlength. It is negative if the hit is in the | |
796 | // amplification region. | |
797 | Float_t driftlength = time0 - rot[0]; | |
798 | ||
799 | // Take also the drift in the amplification region into account | |
800 | // The drift length is at the moment still the same, regardless of | |
801 | // the position relativ to the wire. This non-isochronity needs still | |
802 | // to be implemented. | |
803 | Float_t driftlengthL = TMath::Abs(driftlength + kAmWidth); | |
4487dad0 | 804 | if (fPar->ExBOn()) driftlengthL /= TMath::Sqrt(fPar->GetLorentzFactor()); |
e23fbb27 | 805 | |
806 | // Loop over all electrons of this hit | |
807 | // TR photons produce hits with negative charge | |
808 | Int_t nEl = ((Int_t) TMath::Abs(q)); | |
809 | for (Int_t iEl = 0; iEl < nEl; iEl++) { | |
810 | ||
811 | xyz[0] = rot[0]; | |
812 | xyz[1] = rot[1]; | |
813 | xyz[2] = rot[2]; | |
814 | ||
815 | // Electron attachment | |
4487dad0 | 816 | if (fPar->ElAttachOn()) { |
e23fbb27 | 817 | if (gRandom->Rndm() < (driftlengthL * elAttachProp)) |
818 | continue; | |
819 | } | |
820 | ||
821 | // Apply the diffusion smearing | |
4487dad0 | 822 | if (fPar->DiffusionOn()) { |
823 | if (!(fPar->Diffusion(driftlengthL,xyz))) continue; | |
e23fbb27 | 824 | } |
f7336fa3 | 825 | |
e23fbb27 | 826 | // Apply E x B effects (depends on drift direction) |
4487dad0 | 827 | if (fPar->ExBOn()) { |
828 | if (!(fPar->ExB(driftlength+kAmWidth,xyz))) continue; | |
e23fbb27 | 829 | } |
793ff80c | 830 | |
e23fbb27 | 831 | // The electron position after diffusion and ExB in pad coordinates |
832 | // The pad row (z-direction) | |
833 | Float_t rowDist = xyz[2] - row0; | |
834 | Int_t rowE = ((Int_t) (rowDist * divideRow)); | |
835 | if ((rowE < 0) || (rowE >= nRowMax)) continue; | |
836 | Float_t rowOffset = ((((Float_t) rowE) + 0.5) * rowPadSize) - rowDist; | |
837 | ||
838 | // The pad column (rphi-direction) | |
4487dad0 | 839 | Float_t col0tilt = fPar->Col0Tilted(col0,rowOffset,plane); |
e23fbb27 | 840 | Float_t colDist = xyz[1] - col0tilt; |
841 | Int_t colE = ((Int_t) (colDist * divideCol)); | |
842 | if ((colE < 0) || (colE >= nColMax)) continue; | |
843 | Float_t colOffset = ((((Float_t) colE) + 0.5) * colPadSize) - colDist; | |
844 | ||
845 | // The time bin (negative for hits in the amplification region) | |
846 | // In the amplification region the electrons drift from both sides | |
847 | // to the middle (anode wire plane) | |
848 | Float_t timeDist = time0 - xyz[0]; | |
849 | Float_t timeOffset = 0; | |
850 | Int_t timeE = 0; | |
851 | if (timeDist > 0) { | |
852 | // The time bin | |
853 | timeE = ((Int_t) (timeDist * divideTime)); | |
854 | // The distance of the position to the middle of the timebin | |
855 | timeOffset = ((((Float_t) timeE) + 0.5) * timeBinSize) - timeDist; | |
856 | } | |
857 | else { | |
858 | // Difference between half of the amplification gap width and | |
859 | // the distance to the anode wire | |
860 | Float_t anodeDist = kAmWidth - TMath::Abs(timeDist + kAmWidth); | |
861 | // The time bin | |
862 | timeE = -1 * (((Int_t ) (anodeDist * divideTime)) + 1); | |
863 | // The distance of the position to the middle of the timebin | |
864 | timeOffset = ((((Float_t) timeE) + 0.5) * timeBinSize) + anodeDist; | |
865 | } | |
872a7aba | 866 | |
e23fbb27 | 867 | // Apply the gas gain including fluctuations |
868 | Float_t ggRndm = 0.0; | |
869 | do { | |
870 | ggRndm = gRandom->Rndm(); | |
871 | } while (ggRndm <= 0); | |
4487dad0 | 872 | Int_t signal = (Int_t) (-fPar->GetGasGain() * TMath::Log(ggRndm)); |
e23fbb27 | 873 | |
874 | // Apply the pad response | |
4487dad0 | 875 | if (fPar->PRFOn()) { |
e23fbb27 | 876 | // The distance of the electron to the center of the pad |
877 | // in units of pad width | |
878 | Float_t dist = - colOffset * divideCol; | |
4487dad0 | 879 | if (!(fPar->PadResponse(signal,dist,plane,padSignal))) continue; |
793ff80c | 880 | } |
e23fbb27 | 881 | else { |
882 | padSignal[0] = 0.0; | |
883 | padSignal[1] = signal; | |
884 | padSignal[2] = 0.0; | |
885 | } | |
886 | ||
887 | // Sample the time response inside the drift region | |
888 | // + additional time bins before and after. | |
889 | // The sampling is done always in the middle of the time bin | |
890 | for (Int_t iTimeBin = TMath::Max(timeE-timeTRDbeg, -nTimeBefore) | |
891 | ;iTimeBin < TMath::Min(timeE+timeTRDend,nTimeMax+nTimeAfter ) | |
892 | ;iTimeBin++) { | |
893 | ||
894 | // Apply the time response | |
895 | Float_t timeResponse = 1.0; | |
896 | Float_t crossTalk = 0.0; | |
897 | Float_t time = (iTimeBin - timeE) * timeBinSize + timeOffset; | |
4487dad0 | 898 | if (fPar->TRFOn()) { |
899 | timeResponse = fPar->TimeResponse(time); | |
e23fbb27 | 900 | } |
4487dad0 | 901 | if (fPar->CTOn()) { |
902 | crossTalk = fPar->CrossTalk(time); | |
e23fbb27 | 903 | } |
904 | ||
905 | signalOld[0] = 0.0; | |
906 | signalOld[1] = 0.0; | |
907 | signalOld[2] = 0.0; | |
f7336fa3 | 908 | |
e23fbb27 | 909 | for (iPad = 0; iPad < kNpad; iPad++) { |
910 | ||
911 | Int_t colPos = colE + iPad - 1; | |
912 | if (colPos < 0) continue; | |
913 | if (colPos >= nColMax) break; | |
914 | ||
915 | // Add the signals | |
916 | // Note: The time bin number is shifted by nTimeBefore to avoid negative | |
917 | // time bins. This has to be subtracted later. | |
918 | Int_t iCurrentTimeBin = iTimeBin + nTimeBefore; | |
919 | signalOld[iPad] = signals->GetDataUnchecked(rowE,colPos,iCurrentTimeBin); | |
920 | if( colPos != colE ) { | |
921 | signalOld[iPad] += padSignal[iPad] * (timeResponse + crossTalk); | |
922 | } | |
923 | else { | |
924 | signalOld[iPad] += padSignal[iPad] * timeResponse; | |
925 | } | |
926 | signals->SetDataUnchecked(rowE,colPos,iCurrentTimeBin,signalOld[iPad]); | |
927 | ||
928 | // Store the track index in the dictionary | |
929 | // Note: We store index+1 in order to allow the array to be compressed | |
930 | if (signalOld[iPad] > 0) { | |
931 | for (iDict = 0; iDict < kNDict; iDict++) { | |
932 | Int_t oldTrack = dictionary[iDict]->GetDataUnchecked(rowE | |
933 | ,colPos | |
934 | ,iCurrentTimeBin); | |
935 | if (oldTrack == track+1) break; | |
936 | if (oldTrack == 0) { | |
937 | dictionary[iDict]->SetDataUnchecked(rowE,colPos,iCurrentTimeBin,track+1); | |
938 | break; | |
939 | } | |
71d9fa7b | 940 | } |
941 | } | |
872a7aba | 942 | |
e23fbb27 | 943 | } // Loop: pads |
f7336fa3 | 944 | |
e23fbb27 | 945 | } // Loop: time bins |
f7336fa3 | 946 | |
e23fbb27 | 947 | } // Loop: electrons of a single hit |
f7336fa3 | 948 | |
e23fbb27 | 949 | } // If: detector and test hit |
f7336fa3 | 950 | |
e23fbb27 | 951 | hit = (AliTRDhit *) fTRD->NextHit(); |
f7336fa3 | 952 | |
e23fbb27 | 953 | } // Loop: hits of one primary track |
954 | ||
955 | } // Loop: primary tracks | |
956 | ||
957 | if (fDebug > 0) { | |
958 | printf("<AliTRDdigitizer::MakeDigits> "); | |
abaf1f1d | 959 | printf("Finished analyzing %d hits\n",countHits); |
960 | } | |
793ff80c | 961 | |
6244debe | 962 | // The total conversion factor |
4487dad0 | 963 | Float_t convert = kEl2fC * fPar->GetPadCoupling() |
964 | * fPar->GetTimeCoupling() | |
965 | * fPar->GetChipGain(); | |
6244debe | 966 | |
793ff80c | 967 | // Loop through all chambers to finalize the digits |
968 | for (Int_t iDet = 0; iDet < AliTRDgeometry::Ndet(); iDet++) { | |
969 | ||
872a7aba | 970 | Int_t plane = fGeo->GetPlane(iDet); |
971 | Int_t sector = fGeo->GetSector(iDet); | |
972 | Int_t chamber = fGeo->GetChamber(iDet); | |
4487dad0 | 973 | Int_t nRowMax = fPar->GetRowMax(plane,chamber,sector); |
974 | Int_t nColMax = fPar->GetColMax(plane); | |
975 | Int_t nTimeMax = fPar->GetTimeMax(); | |
976 | Int_t nTimeTotal = fPar->GetTimeTotal(); | |
793ff80c | 977 | |
e23fbb27 | 978 | Double_t *inADC = new Double_t[nTimeTotal]; |
979 | Double_t *outADC = new Double_t[nTimeTotal]; | |
980 | ||
981 | if (fDebug > 0) { | |
982 | printf("<AliTRDdigitizer::MakeDigits> "); | |
793ff80c | 983 | printf("Digitization for chamber %d\n",iDet); |
984 | } | |
da581aea | 985 | |
793ff80c | 986 | // Add a container for the digits of this detector |
abaf1f1d | 987 | digits = fDigitsManager->GetDigits(iDet); |
793ff80c | 988 | // Allocate memory space for the digits buffer |
872a7aba | 989 | digits->Allocate(nRowMax,nColMax,nTimeTotal); |
da581aea | 990 | |
793ff80c | 991 | // Get the signal container |
992 | signals = (AliTRDdataArrayF *) signalsArray->At(iDet); | |
993 | if (signals->GetNtime() == 0) { | |
994 | // Create missing containers | |
872a7aba | 995 | signals->Allocate(nRowMax,nColMax,nTimeTotal); |
793ff80c | 996 | } |
997 | else { | |
998 | // Expand the container if neccessary | |
999 | if (fCompress) signals->Expand(); | |
1000 | } | |
1001 | // Create the missing dictionary containers | |
1002 | for (iDict = 0; iDict < kNDict; iDict++) { | |
abaf1f1d | 1003 | dictionary[iDict] = fDigitsManager->GetDictionary(iDet,iDict); |
793ff80c | 1004 | if (dictionary[iDict]->GetNtime() == 0) { |
872a7aba | 1005 | dictionary[iDict]->Allocate(nRowMax,nColMax,nTimeTotal); |
793ff80c | 1006 | } |
1007 | } | |
f7336fa3 | 1008 | |
793ff80c | 1009 | Int_t nDigits = 0; |
1010 | ||
6244debe | 1011 | // Don't create noise in detectors that are switched off |
1012 | if (CheckDetector(plane,chamber,sector)) { | |
1013 | ||
1014 | // Create the digits for this chamber | |
872a7aba | 1015 | for (iRow = 0; iRow < nRowMax; iRow++ ) { |
1016 | for (iCol = 0; iCol < nColMax; iCol++ ) { | |
6244debe | 1017 | |
e23fbb27 | 1018 | // Create summable digits |
1019 | if (fSDigits) { | |
6244debe | 1020 | |
e23fbb27 | 1021 | for (iTime = 0; iTime < nTimeTotal; iTime++) { |
872a7aba | 1022 | Float_t signalAmp = signals->GetDataUnchecked(iRow,iCol,iTime); |
abaf1f1d | 1023 | signalAmp *= fSDigitsScale; |
e23fbb27 | 1024 | signalAmp = TMath::Min(signalAmp,(Float_t) 1.0e9); |
abaf1f1d | 1025 | Int_t adc = (Int_t) signalAmp; |
4487dad0 | 1026 | if (adc > 0) nDigits++; |
872a7aba | 1027 | digits->SetDataUnchecked(iRow,iCol,iTime,adc); |
c1e4b257 | 1028 | } |
6244debe | 1029 | |
e23fbb27 | 1030 | } |
1031 | // Create normal digits | |
1032 | else { | |
6244debe | 1033 | |
e23fbb27 | 1034 | for (iTime = 0; iTime < nTimeTotal; iTime++) { |
1035 | Float_t signalAmp = signals->GetDataUnchecked(iRow,iCol,iTime); | |
6244debe | 1036 | // Add the noise |
4487dad0 | 1037 | signalAmp = TMath::Max((Double_t) gRandom->Gaus(signalAmp,fPar->GetNoise()),0.0); |
6244debe | 1038 | // Convert to mV |
1039 | signalAmp *= convert; | |
1040 | // Convert to ADC counts. Set the overflow-bit fADCoutRange if the | |
1041 | // signal is larger than fADCinRange | |
1042 | Int_t adc = 0; | |
4487dad0 | 1043 | if (signalAmp >= fPar->GetADCinRange()) { |
1044 | adc = ((Int_t) fPar->GetADCoutRange()); | |
6244debe | 1045 | } |
1046 | else { | |
4487dad0 | 1047 | adc = ((Int_t) (signalAmp * (fPar->GetADCoutRange() |
1048 | / fPar->GetADCinRange()))); | |
6244debe | 1049 | } |
e23fbb27 | 1050 | inADC[iTime] = adc; |
1051 | outADC[iTime] = adc; | |
1052 | } | |
6244debe | 1053 | |
e23fbb27 | 1054 | // Apply the tail cancelation via the digital filter |
4487dad0 | 1055 | if (fPar->TCOn()) { |
1056 | DeConvExp(inADC,outADC,nTimeTotal,fPar->GetTCnexp()); | |
e23fbb27 | 1057 | } |
1058 | ||
1059 | for (iTime = 0; iTime < nTimeTotal; iTime++) { | |
6244debe | 1060 | // Store the amplitude of the digit if above threshold |
4487dad0 | 1061 | if (outADC[iTime] > fPar->GetADCthreshold()) { |
e23fbb27 | 1062 | if (fDebug > 2) { |
1063 | printf(" iRow = %d, iCol = %d, iTime = %d, adc = %f\n" | |
1064 | ,iRow,iCol,iTime,outADC[iTime]); | |
6244debe | 1065 | } |
1066 | nDigits++; | |
e23fbb27 | 1067 | digits->SetDataUnchecked(iRow,iCol,iTime,outADC[iTime]); |
6244debe | 1068 | } |
6244debe | 1069 | } |
1070 | ||
1071 | } | |
e23fbb27 | 1072 | |
6244debe | 1073 | } |
793ff80c | 1074 | } |
6244debe | 1075 | |
793ff80c | 1076 | } |
1077 | ||
1078 | // Compress the arrays | |
1079 | digits->Compress(1,0); | |
1080 | for (iDict = 0; iDict < kNDict; iDict++) { | |
1081 | dictionary[iDict]->Compress(1,0); | |
1082 | } | |
f7336fa3 | 1083 | |
793ff80c | 1084 | totalSizeDigits += digits->GetSize(); |
1085 | totalSizeDict0 += dictionary[0]->GetSize(); | |
1086 | totalSizeDict1 += dictionary[1]->GetSize(); | |
1087 | totalSizeDict2 += dictionary[2]->GetSize(); | |
f7336fa3 | 1088 | |
c1e4b257 | 1089 | Float_t nPixel = nRowMax * nColMax * nTimeMax; |
e23fbb27 | 1090 | if (fDebug > 0) { |
1091 | printf("<AliTRDdigitizer::MakeDigits> "); | |
abaf1f1d | 1092 | printf("Found %d digits in detector %d (%3.0f).\n" |
1093 | ,nDigits,iDet | |
1094 | ,100.0 * ((Float_t) nDigits) / nPixel); | |
1095 | } | |
1096 | ||
793ff80c | 1097 | if (fCompress) signals->Compress(1,0); |
f7336fa3 | 1098 | |
e23fbb27 | 1099 | delete [] inADC; |
1100 | delete [] outADC; | |
1101 | ||
f7336fa3 | 1102 | } |
1103 | ||
e23fbb27 | 1104 | if (fDebug > 0) { |
1105 | printf("<AliTRDdigitizer::MakeDigits> "); | |
abaf1f1d | 1106 | printf("Total number of analyzed hits = %d\n",countHits); |
e23fbb27 | 1107 | printf("<AliTRDdigitizer::MakeDigits> "); |
abaf1f1d | 1108 | printf("Total digits data size = %d, %d, %d, %d\n",totalSizeDigits |
1109 | ,totalSizeDict0 | |
1110 | ,totalSizeDict1 | |
1111 | ,totalSizeDict2); | |
1112 | } | |
1113 | ||
1114 | return kTRUE; | |
1115 | ||
1116 | } | |
1117 | ||
1118 | //_____________________________________________________________________________ | |
1119 | void AliTRDdigitizer::AddSDigitsManager(AliTRDdigitsManager *man) | |
1120 | { | |
1121 | // | |
1122 | // Add a digits manager for s-digits to the input list. | |
1123 | // | |
1124 | ||
1125 | fSDigitsManagerList->Add(man); | |
1126 | ||
1127 | } | |
1128 | ||
b1113c6b | 1129 | //_____________________________________________________________________________ |
1130 | void AliTRDdigitizer::DeleteSDigitsManager() | |
1131 | { | |
1132 | // | |
1133 | // Removes digits manager from the input list. | |
1134 | // | |
1135 | ||
1136 | fSDigitsManagerList->Delete(); | |
1137 | ||
1138 | } | |
1139 | ||
abaf1f1d | 1140 | //_____________________________________________________________________________ |
1141 | Bool_t AliTRDdigitizer::ConvertSDigits() | |
1142 | { | |
1143 | // | |
1144 | // Converts s-digits to normal digits | |
1145 | // | |
1146 | ||
1147 | // Number of track dictionary arrays | |
1148 | const Int_t kNDict = AliTRDdigitsManager::kNDict; | |
1149 | ||
1150 | // Converts number of electrons to fC | |
1151 | const Double_t kEl2fC = 1.602E-19 * 1.0E15; | |
1152 | ||
1153 | Int_t iDict = 0; | |
e23fbb27 | 1154 | Int_t iRow; |
1155 | Int_t iCol; | |
1156 | Int_t iTime; | |
abaf1f1d | 1157 | |
4487dad0 | 1158 | if (!fPar) { |
1159 | fPar = new AliTRDparameter("TRDparameter","Standard parameter"); | |
1160 | if (fDebug > 0) { | |
1161 | printf("<AliTRDdigitizer::ConvertSDigits> "); | |
1162 | printf("Create the default parameter object\n"); | |
1163 | } | |
abaf1f1d | 1164 | } |
1165 | ||
1166 | Double_t sDigitsScale = 1.0 / GetSDigitsScale(); | |
4487dad0 | 1167 | Double_t noise = fPar->GetNoise(); |
1168 | Double_t padCoupling = fPar->GetPadCoupling(); | |
1169 | Double_t timeCoupling = fPar->GetTimeCoupling(); | |
1170 | Double_t chipGain = fPar->GetChipGain(); | |
abaf1f1d | 1171 | Double_t convert = kEl2fC * padCoupling * timeCoupling * chipGain;; |
4487dad0 | 1172 | Double_t adcInRange = fPar->GetADCinRange(); |
1173 | Double_t adcOutRange = fPar->GetADCoutRange(); | |
1174 | Int_t adcThreshold = fPar->GetADCthreshold(); | |
abaf1f1d | 1175 | |
1176 | AliTRDdataArrayI *digitsIn; | |
1177 | AliTRDdataArrayI *digitsOut; | |
1178 | AliTRDdataArrayI *dictionaryIn[kNDict]; | |
1179 | AliTRDdataArrayI *dictionaryOut[kNDict]; | |
1180 | ||
1181 | // Loop through the detectors | |
1182 | for (Int_t iDet = 0; iDet < AliTRDgeometry::Ndet(); iDet++) { | |
da581aea | 1183 | |
e23fbb27 | 1184 | if (fDebug > 0) { |
1185 | printf("<AliTRDdigitizer::ConvertSDigits> "); | |
abaf1f1d | 1186 | printf("Convert detector %d to digits.\n",iDet); |
1187 | } | |
1188 | ||
1189 | Int_t plane = fGeo->GetPlane(iDet); | |
1190 | Int_t sector = fGeo->GetSector(iDet); | |
1191 | Int_t chamber = fGeo->GetChamber(iDet); | |
4487dad0 | 1192 | Int_t nRowMax = fPar->GetRowMax(plane,chamber,sector); |
1193 | Int_t nColMax = fPar->GetColMax(plane); | |
1194 | Int_t nTimeTotal = fPar->GetTimeTotal(); | |
abaf1f1d | 1195 | |
e23fbb27 | 1196 | Double_t *inADC = new Double_t[nTimeTotal]; |
1197 | Double_t *outADC = new Double_t[nTimeTotal]; | |
1198 | ||
abaf1f1d | 1199 | digitsIn = fSDigitsManager->GetDigits(iDet); |
1200 | digitsIn->Expand(); | |
1201 | digitsOut = fDigitsManager->GetDigits(iDet); | |
1202 | digitsOut->Allocate(nRowMax,nColMax,nTimeTotal); | |
1203 | for (iDict = 0; iDict < kNDict; iDict++) { | |
1204 | dictionaryIn[iDict] = fSDigitsManager->GetDictionary(iDet,iDict); | |
1205 | dictionaryIn[iDict]->Expand(); | |
1206 | dictionaryOut[iDict] = fDigitsManager->GetDictionary(iDet,iDict); | |
1207 | dictionaryOut[iDict]->Allocate(nRowMax,nColMax,nTimeTotal); | |
1208 | } | |
1209 | ||
e23fbb27 | 1210 | for (iRow = 0; iRow < nRowMax; iRow++ ) { |
1211 | for (iCol = 0; iCol < nColMax; iCol++ ) { | |
abaf1f1d | 1212 | |
e23fbb27 | 1213 | for (iTime = 0; iTime < nTimeTotal; iTime++) { |
abaf1f1d | 1214 | Double_t signal = (Double_t) digitsIn->GetDataUnchecked(iRow,iCol,iTime); |
1215 | signal *= sDigitsScale; | |
1216 | // Add the noise | |
1217 | signal = TMath::Max((Double_t) gRandom->Gaus(signal,noise),0.0); | |
1218 | // Convert to mV | |
1219 | signal *= convert; | |
1220 | // Convert to ADC counts. Set the overflow-bit adcOutRange if the | |
1221 | // signal is larger than adcInRange | |
1222 | Int_t adc = 0; | |
1223 | if (signal >= adcInRange) { | |
1224 | adc = ((Int_t) adcOutRange); | |
1225 | } | |
1226 | else { | |
1227 | adc = ((Int_t) (signal * (adcOutRange / adcInRange))); | |
1228 | } | |
e23fbb27 | 1229 | inADC[iTime] = adc; |
1230 | outADC[iTime] = adc; | |
1231 | } | |
1232 | ||
1233 | // Apply the tail cancelation via the digital filter | |
4487dad0 | 1234 | if (fPar->TCOn()) { |
1235 | DeConvExp(inADC,outADC,nTimeTotal,fPar->GetTCnexp()); | |
e23fbb27 | 1236 | } |
1237 | ||
1238 | for (iTime = 0; iTime < nTimeTotal; iTime++) { | |
abaf1f1d | 1239 | // Store the amplitude of the digit if above threshold |
e23fbb27 | 1240 | if (outADC[iTime] > adcThreshold) { |
1241 | digitsOut->SetDataUnchecked(iRow,iCol,iTime,outADC[iTime]); | |
1242 | // Copy the dictionary | |
1243 | for (iDict = 0; iDict < kNDict; iDict++) { | |
1244 | Int_t track = dictionaryIn[iDict]->GetDataUnchecked(iRow,iCol,iTime); | |
1245 | dictionaryOut[iDict]->SetDataUnchecked(iRow,iCol,iTime,track); | |
1246 | } | |
abaf1f1d | 1247 | } |
abaf1f1d | 1248 | } |
e23fbb27 | 1249 | |
abaf1f1d | 1250 | } |
1251 | } | |
1252 | ||
1253 | if (fCompress) { | |
1254 | digitsIn->Compress(1,0); | |
1255 | digitsOut->Compress(1,0); | |
1256 | for (iDict = 0; iDict < kNDict; iDict++) { | |
1257 | dictionaryIn[iDict]->Compress(1,0); | |
1258 | dictionaryOut[iDict]->Compress(1,0); | |
1259 | } | |
1260 | } | |
1261 | ||
e23fbb27 | 1262 | delete [] inADC; |
1263 | delete [] outADC; | |
1264 | ||
abaf1f1d | 1265 | } |
f7336fa3 | 1266 | |
1267 | return kTRUE; | |
1268 | ||
1269 | } | |
1270 | ||
16bf9884 | 1271 | //_____________________________________________________________________________ |
abaf1f1d | 1272 | Bool_t AliTRDdigitizer::MergeSDigits() |
16bf9884 | 1273 | { |
1274 | // | |
abaf1f1d | 1275 | // Merges the input s-digits: |
1276 | // - The amplitude of the different inputs are summed up. | |
1277 | // - Of the track IDs from the input dictionaries only one is | |
1278 | // kept for each input. This works for maximal 3 different merged inputs. | |
16bf9884 | 1279 | // |
1280 | ||
abaf1f1d | 1281 | // Number of track dictionary arrays |
1282 | const Int_t kNDict = AliTRDdigitsManager::kNDict; | |
1283 | ||
4487dad0 | 1284 | if (!fPar) { |
1285 | fPar = new AliTRDparameter("TRDparameter","Standard parameter"); | |
1286 | if (fDebug > 0) { | |
1287 | printf("<AliTRDdigitizer::MergeSDigits> "); | |
1288 | printf("Create the default parameter object\n"); | |
1289 | } | |
1290 | } | |
1291 | ||
abaf1f1d | 1292 | Int_t iDict = 0; |
e23fbb27 | 1293 | Int_t jDict = 0; |
abaf1f1d | 1294 | |
1295 | AliTRDdataArrayI *digitsA; | |
1296 | AliTRDdataArrayI *digitsB; | |
1297 | AliTRDdataArrayI *dictionaryA[kNDict]; | |
1298 | AliTRDdataArrayI *dictionaryB[kNDict]; | |
1299 | ||
1300 | // Get the first s-digits | |
1301 | fSDigitsManager = (AliTRDdigitsManager *) fSDigitsManagerList->First(); | |
1302 | if (!fSDigitsManager) return kFALSE; | |
1303 | ||
1304 | // Loop through the other sets of s-digits | |
1305 | AliTRDdigitsManager *mergeSDigitsManager; | |
1306 | mergeSDigitsManager = (AliTRDdigitsManager *) | |
1307 | fSDigitsManagerList->After(fSDigitsManager); | |
1308 | ||
e23fbb27 | 1309 | if (fDebug > 0) { |
abaf1f1d | 1310 | if (mergeSDigitsManager) { |
e23fbb27 | 1311 | printf("<AliTRDdigitizer::MergeSDigits> "); |
1312 | printf("Merge %d input files.\n",fSDigitsManagerList->GetSize()); | |
abaf1f1d | 1313 | } |
1314 | else { | |
e23fbb27 | 1315 | printf("<AliTRDdigitizer::MergeSDigits> "); |
abaf1f1d | 1316 | printf("Only one input file.\n"); |
1317 | } | |
1318 | } | |
1319 | ||
1320 | Int_t iMerge = 0; | |
1321 | while (mergeSDigitsManager) { | |
1322 | ||
1323 | iMerge++; | |
1324 | ||
1325 | // Loop through the detectors | |
1326 | for (Int_t iDet = 0; iDet < AliTRDgeometry::Ndet(); iDet++) { | |
1327 | ||
1328 | Int_t plane = fGeo->GetPlane(iDet); | |
1329 | Int_t sector = fGeo->GetSector(iDet); | |
1330 | Int_t chamber = fGeo->GetChamber(iDet); | |
4487dad0 | 1331 | Int_t nRowMax = fPar->GetRowMax(plane,chamber,sector); |
1332 | Int_t nColMax = fPar->GetColMax(plane); | |
1333 | Int_t nTimeTotal = fPar->GetTimeTotal(); | |
abaf1f1d | 1334 | |
1335 | // Loop through the pixels of one detector and add the signals | |
1336 | digitsA = fSDigitsManager->GetDigits(iDet); | |
1337 | digitsB = mergeSDigitsManager->GetDigits(iDet); | |
1338 | digitsA->Expand(); | |
1339 | digitsB->Expand(); | |
1340 | for (iDict = 0; iDict < kNDict; iDict++) { | |
1341 | dictionaryA[iDict] = fSDigitsManager->GetDictionary(iDet,iDict); | |
1342 | dictionaryB[iDict] = mergeSDigitsManager->GetDictionary(iDet,iDict); | |
1343 | dictionaryA[iDict]->Expand(); | |
1344 | dictionaryB[iDict]->Expand(); | |
1345 | } | |
1346 | ||
4487dad0 | 1347 | // Merge only detectors that contain a signal |
1348 | Bool_t doMerge = kTRUE; | |
1349 | if (fMergeSignalOnly) { | |
1350 | if (digitsA->GetOverThreshold(0) == 0) { | |
1351 | doMerge = kFALSE; | |
1352 | } | |
abaf1f1d | 1353 | } |
1354 | ||
4487dad0 | 1355 | if (doMerge) { |
abaf1f1d | 1356 | |
4487dad0 | 1357 | if (fDebug > 0) { |
1358 | printf("<AliTRDdigitizer::MergeSDigits> "); | |
1359 | printf("Merge detector %d of input no.%d\n",iDet,iMerge+1); | |
1360 | } | |
abaf1f1d | 1361 | |
4487dad0 | 1362 | for (Int_t iRow = 0; iRow < nRowMax; iRow++ ) { |
1363 | for (Int_t iCol = 0; iCol < nColMax; iCol++ ) { | |
1364 | for (Int_t iTime = 0; iTime < nTimeTotal; iTime++) { | |
1365 | ||
1366 | // Add the amplitudes of the summable digits | |
1367 | Int_t ampA = digitsA->GetDataUnchecked(iRow,iCol,iTime); | |
1368 | Int_t ampB = digitsB->GetDataUnchecked(iRow,iCol,iTime); | |
1369 | ampA += ampB; | |
1370 | digitsA->SetDataUnchecked(iRow,iCol,iTime,ampA); | |
1371 | ||
1372 | // Add the mask to the track id if defined. | |
1373 | for (iDict = 0; iDict < kNDict; iDict++) { | |
1374 | Int_t trackB = dictionaryB[iDict]->GetDataUnchecked(iRow,iCol,iTime); | |
1375 | if ((fMasks) && (trackB > 0)) { | |
1376 | for (jDict = 0; jDict < kNDict; jDict++) { | |
1377 | Int_t trackA = dictionaryA[iDict]->GetDataUnchecked(iRow,iCol,iTime); | |
1378 | if (trackA == 0) { | |
1379 | trackA = trackB + fMasks[iMerge]; | |
1380 | dictionaryA[iDict]->SetDataUnchecked(iRow,iCol,iTime,trackA); | |
1381 | } | |
1382 | } | |
1383 | } | |
e23fbb27 | 1384 | } |
abaf1f1d | 1385 | |
4487dad0 | 1386 | } |
abaf1f1d | 1387 | } |
4487dad0 | 1388 | } |
1389 | ||
abaf1f1d | 1390 | } |
1391 | ||
1392 | if (fCompress) { | |
1393 | digitsA->Compress(1,0); | |
1394 | digitsB->Compress(1,0); | |
1395 | for (iDict = 0; iDict < kNDict; iDict++) { | |
1396 | dictionaryA[iDict]->Compress(1,0); | |
1397 | dictionaryB[iDict]->Compress(1,0); | |
1398 | } | |
1399 | } | |
1400 | ||
1401 | } | |
1402 | ||
1403 | // The next set of s-digits | |
1404 | mergeSDigitsManager = (AliTRDdigitsManager *) | |
1405 | fSDigitsManagerList->After(mergeSDigitsManager); | |
1406 | ||
1407 | } | |
1408 | ||
16bf9884 | 1409 | return kTRUE; |
1410 | ||
1411 | } | |
1412 | ||
abaf1f1d | 1413 | //_____________________________________________________________________________ |
1414 | Bool_t AliTRDdigitizer::SDigits2Digits() | |
1415 | { | |
1416 | // | |
1417 | // Merges the input s-digits and converts them to normal digits | |
1418 | // | |
1419 | ||
1420 | if (!MergeSDigits()) return kFALSE; | |
1421 | ||
1422 | return ConvertSDigits(); | |
1423 | ||
1424 | } | |
1425 | ||
793ff80c | 1426 | //_____________________________________________________________________________ |
1427 | Bool_t AliTRDdigitizer::CheckDetector(Int_t plane, Int_t chamber, Int_t sector) | |
1428 | { | |
1429 | // | |
1430 | // Checks whether a detector is enabled | |
1431 | // | |
1432 | ||
1433 | if ((fTRD->GetSensChamber() >= 0) && | |
1434 | (fTRD->GetSensChamber() != chamber)) return kFALSE; | |
1435 | if ((fTRD->GetSensPlane() >= 0) && | |
c1e4b257 | 1436 | (fTRD->GetSensPlane() != plane)) return kFALSE; |
793ff80c | 1437 | if ( fTRD->GetSensSector() >= 0) { |
1438 | Int_t sens1 = fTRD->GetSensSector(); | |
1439 | Int_t sens2 = sens1 + fTRD->GetSensSectorRange(); | |
1440 | sens2 -= ((Int_t) (sens2 / AliTRDgeometry::Nsect())) | |
1441 | * AliTRDgeometry::Nsect(); | |
1442 | if (sens1 < sens2) { | |
1443 | if ((sector < sens1) || (sector >= sens2)) return kFALSE; | |
1444 | } | |
1445 | else { | |
1446 | if ((sector < sens1) && (sector >= sens2)) return kFALSE; | |
1447 | } | |
1448 | } | |
1449 | ||
1450 | return kTRUE; | |
1451 | ||
1452 | } | |
1453 | ||
f7336fa3 | 1454 | //_____________________________________________________________________________ |
0a29d0f1 | 1455 | Bool_t AliTRDdigitizer::WriteDigits() const |
f7336fa3 | 1456 | { |
1457 | // | |
1458 | // Writes out the TRD-digits and the dictionaries | |
1459 | // | |
1460 | ||
da581aea | 1461 | // Store the digits and the dictionary in the tree |
abaf1f1d | 1462 | return fDigitsManager->WriteDigits(); |
f7336fa3 | 1463 | |
1464 | } | |
793ff80c | 1465 | |
e23fbb27 | 1466 | //_____________________________________________________________________________ |
1467 | void AliTRDdigitizer::DeConvExp(Double_t *source, Double_t *target | |
1468 | , Int_t n, Int_t nexp) | |
1469 | { | |
1470 | // | |
1471 | // Does the deconvolution by the digital filter. | |
1472 | // | |
1473 | // Author: Marcus Gutfleisch, KIP Heidelberg | |
1474 | // Optimized for: New TRF from Venelin Angelov, simulated with CADENCE | |
1475 | // Pad-ground capacitance = 25 pF | |
1476 | // Pad-pad cross talk capacitance = 6 pF | |
1477 | // For 10 MHz digitization, corresponding to 20 time bins | |
1478 | // in the drift region | |
1479 | // | |
1480 | ||
1481 | Double_t rates[2]; | |
1482 | Double_t coefficients[2]; | |
1483 | ||
1484 | /* initialize (coefficient = alpha, rates = lambda) */ | |
1485 | ||
1486 | if( nexp == 1 ) { | |
1487 | rates[0] = 0.466998; | |
1488 | /* no rescaling */ | |
1489 | coefficients[0] = 1.0; | |
1490 | } | |
1491 | if( nexp == 2 ) { | |
1492 | rates[0] = 0.8988162; | |
1493 | coefficients[0] = 0.11392069; | |
1494 | rates[1] = 0.3745688; | |
1495 | coefficients[1] = 0.8860793; | |
1496 | /* no rescaling */ | |
1497 | Float_t sumc = coefficients[0]+coefficients[1]; | |
1498 | coefficients[0] /= sumc; | |
1499 | coefficients[1] /= sumc; | |
1500 | } | |
1501 | ||
1502 | Int_t i, k; | |
1503 | Double_t reminder[2]; | |
1504 | Double_t correction, result; | |
1505 | ||
1506 | /* attention: computation order is important */ | |
1507 | correction=0.0; | |
1508 | for ( k = 0; k < nexp; k++ ) reminder[k]=0.0; | |
1509 | ||
1510 | for ( i = 0; i < n; i++ ) { | |
1511 | result = ( source[i] - correction ); /* no rescaling */ | |
1512 | target[i] = result; | |
1513 | ||
1514 | for ( k = 0; k < nexp; k++ ) reminder[k] = rates[k] | |
1515 | * ( reminder[k] + coefficients[k] * result); | |
1516 | ||
1517 | correction=0.0; | |
1518 | for ( k = 0; k < nexp; k++ ) correction += reminder[k]; | |
1519 | } | |
1520 | ||
1521 | } | |
1522 |