]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDdigitizer.cxx
Coding rules
[u/mrichter/AliRoot.git] / TRD / AliTRDdigitizer.cxx
CommitLineData
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
88cb7938 16/* $Id$ */
f7336fa3 17
625f5260 18////////////////////////////////////////////////////////////////////////////
19// //
20// Creates and handles digits from TRD hits //
21// //
22// Authors: C. Blume (blume@ikf.uni-frankfurt.de) //
23// C. Lippmann //
24// B. Vulpescu //
25// //
26// The following effects are included: //
27// - Diffusion //
28// - ExB effects //
29// - Gas gain including fluctuations //
30// - Pad-response (simple Gaussian approximation) //
31// - Time-response //
32// - Electronics noise //
33// - Electronics gain //
34// - Digitization //
b65e5048 35// - Zero suppression //
625f5260 36// //
37////////////////////////////////////////////////////////////////////////////
6798b56e 38
f7a1cc68 39#include <TGeoManager.h>
abaf1f1d 40#include <TList.h>
f7a1cc68 41#include <TMath.h>
f7a1cc68 42#include <TRandom.h>
f7a1cc68 43#include <TTree.h>
26d3c914 44
793ff80c 45#include "AliRun.h"
3e2e3ece 46#include "AliMC.h"
88cb7938 47#include "AliRunLoader.h"
48#include "AliLoader.h"
49#include "AliConfig.h"
85cbec76 50#include "AliRunDigitizer.h"
88cb7938 51#include "AliRunLoader.h"
52#include "AliLoader.h"
ad2cc20b 53#include "AliLog.h"
621310dd 54
f7336fa3 55#include "AliTRD.h"
793ff80c 56#include "AliTRDhit.h"
f7336fa3 57#include "AliTRDdigitizer.h"
b65e5048 58#include "AliTRDarrayDictionary.h"
59#include "AliTRDarrayADC.h"
60#include "AliTRDarraySignal.h"
da581aea 61#include "AliTRDdigitsManager.h"
793ff80c 62#include "AliTRDgeometry.h"
a5cadd36 63#include "AliTRDpadPlane.h"
3551db50 64#include "AliTRDcalibDB.h"
65#include "AliTRDSimParam.h"
66#include "AliTRDCommonParam.h"
ecf39416 67#include "AliTRDfeeParam.h"
b65e5048 68#include "AliTRDmcmSim.h"
4329977a 69#include "Cal/AliTRDCalROC.h"
70#include "Cal/AliTRDCalDet.h"
71
f7336fa3 72ClassImp(AliTRDdigitizer)
73
74//_____________________________________________________________________________
85cbec76 75AliTRDdigitizer::AliTRDdigitizer()
4d18a639 76 :AliDigitizer()
77 ,fRunLoader(0)
78 ,fDigitsManager(0)
79 ,fSDigitsManager(0)
80 ,fSDigitsManagerList(0)
81 ,fTRD(0)
82 ,fGeo(0)
83 ,fEvent(0)
84 ,fMasks(0)
85 ,fCompress(kTRUE)
86 ,fSDigits(kFALSE)
4d18a639 87 ,fMergeSignalOnly(kFALSE)
f7336fa3 88{
89 //
90 // AliTRDdigitizer default constructor
91 //
3551db50 92
93 Init();
3becff3c 94
f7336fa3 95}
96
97//_____________________________________________________________________________
4d18a639 98AliTRDdigitizer::AliTRDdigitizer(const Text_t *name, const Text_t *title)
99 :AliDigitizer(name,title)
100 ,fRunLoader(0)
101 ,fDigitsManager(0)
102 ,fSDigitsManager(0)
103 ,fSDigitsManagerList(0)
104 ,fTRD(0)
105 ,fGeo(0)
106 ,fEvent(0)
107 ,fMasks(0)
108 ,fCompress(kTRUE)
109 ,fSDigits(kFALSE)
4d18a639 110 ,fMergeSignalOnly(kFALSE)
f7336fa3 111{
112 //
85cbec76 113 // AliTRDdigitizer constructor
114 //
115
3551db50 116 Init();
3becff3c 117
85cbec76 118}
119
120//_____________________________________________________________________________
121AliTRDdigitizer::AliTRDdigitizer(AliRunDigitizer *manager
4d18a639 122 , const Text_t *name, const Text_t *title)
123 :AliDigitizer(manager,name,title)
124 ,fRunLoader(0)
125 ,fDigitsManager(0)
126 ,fSDigitsManager(0)
127 ,fSDigitsManagerList(0)
128 ,fTRD(0)
129 ,fGeo(0)
130 ,fEvent(0)
131 ,fMasks(0)
132 ,fCompress(kTRUE)
133 ,fSDigits(kFALSE)
4d18a639 134 ,fMergeSignalOnly(kFALSE)
85cbec76 135{
136 //
137 // AliTRDdigitizer constructor
f7336fa3 138 //
139
3551db50 140 Init();
3becff3c 141
bfc40adc 142}
143
144//_____________________________________________________________________________
145AliTRDdigitizer::AliTRDdigitizer(AliRunDigitizer *manager)
4d18a639 146 :AliDigitizer(manager,"AliTRDdigitizer","TRD digitizer")
147 ,fRunLoader(0)
148 ,fDigitsManager(0)
149 ,fSDigitsManager(0)
150 ,fSDigitsManagerList(0)
151 ,fTRD(0)
152 ,fGeo(0)
153 ,fEvent(0)
154 ,fMasks(0)
155 ,fCompress(kTRUE)
156 ,fSDigits(kFALSE)
4d18a639 157 ,fMergeSignalOnly(kFALSE)
bfc40adc 158{
159 //
160 // AliTRDdigitizer constructor
161 //
162
3551db50 163 Init();
3becff3c 164
3551db50 165}
88cb7938 166
3551db50 167//_____________________________________________________________________________
168Bool_t AliTRDdigitizer::Init()
169{
3becff3c 170 //
171 // Initialize the digitizer with default values
172 //
173
85a5290f 174 fRunLoader = 0;
4487dad0 175 fDigitsManager = 0;
4487dad0 176 fSDigitsManager = 0;
85a5290f 177 fSDigitsManagerList = 0;
4487dad0 178 fTRD = 0;
179 fGeo = 0;
3becff3c 180
abaf1f1d 181 fEvent = 0;
85a5290f 182 fMasks = 0;
abaf1f1d 183 fCompress = kTRUE;
abaf1f1d 184 fSDigits = kFALSE;
4487dad0 185 fMergeSignalOnly = kFALSE;
3551db50 186
3551db50 187 return AliDigitizer::Init();
3becff3c 188
f7336fa3 189}
190
8230f242 191//_____________________________________________________________________________
4d18a639 192AliTRDdigitizer::AliTRDdigitizer(const AliTRDdigitizer &d)
193 :AliDigitizer(d)
194 ,fRunLoader(0)
195 ,fDigitsManager(0)
196 ,fSDigitsManager(0)
197 ,fSDigitsManagerList(0)
198 ,fTRD(0)
199 ,fGeo(0)
200 ,fEvent(0)
201 ,fMasks(0)
202 ,fCompress(d.fCompress)
203 ,fSDigits(d.fSDigits)
4d18a639 204 ,fMergeSignalOnly(d.fMergeSignalOnly)
8230f242 205{
206 //
207 // AliTRDdigitizer copy constructor
208 //
209
8230f242 210}
211
f7336fa3 212//_____________________________________________________________________________
213AliTRDdigitizer::~AliTRDdigitizer()
214{
8230f242 215 //
216 // AliTRDdigitizer destructor
217 //
f7336fa3 218
abaf1f1d 219 if (fDigitsManager) {
220 delete fDigitsManager;
4d18a639 221 fDigitsManager = 0;
f7336fa3 222 }
223
b65e5048 224 if (fDigitsManager) { //typo? fSDigitsManager?
4d18a639 225 delete fSDigitsManager;
226 fSDigitsManager = 0;
227 }
f7336fa3 228
abaf1f1d 229 if (fSDigitsManagerList) {
47b5729a 230 fSDigitsManagerList->Delete();
abaf1f1d 231 delete fSDigitsManagerList;
4487dad0 232 fSDigitsManagerList = 0;
e23fbb27 233 }
234
235 if (fMasks) {
236 delete [] fMasks;
4329977a 237 fMasks = 0;
e23fbb27 238 }
239
f162af62 240 if (fGeo) {
241 delete fGeo;
242 fGeo = 0;
243 }
244
f7336fa3 245}
246
8230f242 247//_____________________________________________________________________________
dd9a6ee3 248AliTRDdigitizer &AliTRDdigitizer::operator=(const AliTRDdigitizer &d)
249{
250 //
251 // Assignment operator
252 //
253
625f5260 254 if (this != &d) {
255 ((AliTRDdigitizer &) d).Copy(*this);
256 }
4d18a639 257
dd9a6ee3 258 return *this;
259
260}
261
262//_____________________________________________________________________________
e0d47c25 263void AliTRDdigitizer::Copy(TObject &d) const
8230f242 264{
265 //
266 // Copy function
267 //
268
85a5290f 269 ((AliTRDdigitizer &) d).fRunLoader = 0;
4487dad0 270 ((AliTRDdigitizer &) d).fDigitsManager = 0;
85a5290f 271 ((AliTRDdigitizer &) d).fSDigitsManager = 0;
272 ((AliTRDdigitizer &) d).fSDigitsManagerList = 0;
4487dad0 273 ((AliTRDdigitizer &) d).fTRD = 0;
274 ((AliTRDdigitizer &) d).fGeo = 0;
85a5290f 275 ((AliTRDdigitizer &) d).fEvent = 0;
276 ((AliTRDdigitizer &) d).fMasks = 0;
abaf1f1d 277 ((AliTRDdigitizer &) d).fCompress = fCompress;
abaf1f1d 278 ((AliTRDdigitizer &) d).fSDigits = fSDigits;
4487dad0 279 ((AliTRDdigitizer &) d).fMergeSignalOnly = fMergeSignalOnly;
3becff3c 280
e23fbb27 281}
282
e23fbb27 283//_____________________________________________________________________________
621310dd 284void AliTRDdigitizer::Exec(const Option_t * const option)
e23fbb27 285{
286 //
287 // Executes the merging
288 //
289
290 Int_t iInput;
291
292 AliTRDdigitsManager *sdigitsManager;
293
294 TString optionString = option;
295 if (optionString.Contains("deb")) {
9afbd7de 296 AliLog::SetClassDebugLevel("AliTRDdigitizer",1);
7925de54 297 AliInfo("Called with debug option");
e23fbb27 298 }
299
cec4059b 300 // The AliRoot file is already connected by the manager
625f5260 301 AliRunLoader *inrl = 0x0;
88cb7938 302
9afbd7de 303 if (gAlice) {
7925de54 304 AliDebug(1,"AliRun object found on file.");
9afbd7de 305 }
4487dad0 306 else {
88cb7938 307 inrl = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(0));
308 inrl->LoadgAlice();
309 gAlice = inrl->GetAliRun();
9afbd7de 310 if (!gAlice) {
7925de54 311 AliError("Could not find AliRun object.")
9afbd7de 312 return;
313 }
4487dad0 314 }
cec4059b 315
e23fbb27 316 Int_t nInput = fManager->GetNinputs();
4d18a639 317 fMasks = new Int_t[nInput];
e23fbb27 318 for (iInput = 0; iInput < nInput; iInput++) {
319 fMasks[iInput] = fManager->GetMask(iInput);
320 }
e23fbb27 321
9afbd7de 322 //
e23fbb27 323 // Initialization
9afbd7de 324 //
e23fbb27 325
95867fd1 326 AliRunLoader *orl = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
327
67c67368 328 if (InitDetector()) {
9afbd7de 329
95867fd1 330 AliLoader *ogime = orl->GetLoader("TRDLoader");
67c67368 331
95867fd1 332 TTree *tree = 0;
9afbd7de 333 if (fSDigits) {
334 // If we produce SDigits
335 tree = ogime->TreeS();
336 if (!tree) {
337 ogime->MakeTree("S");
67c67368 338 tree = ogime->TreeS();
67c67368 339 }
9afbd7de 340 }
341 else {
342 // If we produce Digits
343 tree = ogime->TreeD();
344 if (!tree) {
345 ogime->MakeTree("D");
346 tree = ogime->TreeD();
67c67368 347 }
9afbd7de 348 }
349
67c67368 350 MakeBranch(tree);
9afbd7de 351
67c67368 352 }
353
e23fbb27 354 for (iInput = 0; iInput < nInput; iInput++) {
355
7925de54 356 AliDebug(1,Form("Add input stream %d",iInput));
e23fbb27 357
9afbd7de 358 // Check if the input tree exists
88cb7938 359 inrl = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(iInput));
4d18a639 360 AliLoader *gime = inrl->GetLoader("TRDLoader");
88cb7938 361
4d18a639 362 TTree *treees = gime->TreeS();
9afbd7de 363 if (treees == 0x0) {
364 if (gime->LoadSDigits()) {
365 AliError(Form("Error Occured while loading S. Digits for input %d.",iInput));
366 return;
367 }
4d18a639 368 treees = gime->TreeS();
9afbd7de 369 }
88cb7938 370
371 if (treees == 0x0) {
7925de54 372 AliError(Form("Input stream %d does not exist",iInput));
c57e2264 373 return;
374 }
375
e23fbb27 376 // Read the s-digits via digits manager
377 sdigitsManager = new AliTRDdigitsManager();
e23fbb27 378 sdigitsManager->SetSDigits(kTRUE);
88cb7938 379
4d18a639 380 AliRunLoader *rl = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(iInput));
381 AliLoader *gimme = rl->GetLoader("TRDLoader");
b65e5048 382 if (!gimme->TreeS())
383 {
384 gimme->LoadSDigits();
385 }
e23fbb27 386
b65e5048 387 sdigitsManager->ReadDigits(gimme->TreeS());
388
e23fbb27 389 // Add the s-digits to the input list
390 AddSDigitsManager(sdigitsManager);
391
392 }
393
394 // Convert the s-digits to normal digits
7925de54 395 AliDebug(1,"Do the conversion");
e23fbb27 396 SDigits2Digits();
397
398 // Store the digits
7925de54 399 AliDebug(1,"Write the digits");
e23fbb27 400 fDigitsManager->WriteDigits();
88cb7938 401
9afbd7de 402 // Write parameters
67c67368 403 orl->CdGAFile();
67c67368 404
26d3c914 405 // Clean up
b1113c6b 406 DeleteSDigitsManager();
407
26d3c914 408 AliDebug(1,"Done");
409
e23fbb27 410}
411
f7336fa3 412//_____________________________________________________________________________
e23fbb27 413Bool_t AliTRDdigitizer::Open(const Char_t *file, Int_t nEvent)
f7336fa3 414{
415 //
416 // Opens a ROOT-file with TRD-hits and reads in the hit-tree
417 //
f7336fa3 418 // Connect the AliRoot file containing Geometry, Kine, and Hits
3becff3c 419 //
f540341d 420
e191bb57 421 TString evfoldname = AliConfig::GetDefaultEventFolderName();
9afbd7de 422
f540341d 423 fRunLoader = AliRunLoader::GetRunLoader(evfoldname);
9afbd7de 424 if (!fRunLoader) {
425 fRunLoader = AliRunLoader::Open(file,evfoldname,"UPDATE");
426 }
9afbd7de 427 if (!fRunLoader) {
95867fd1 428 AliError(Form("Can not open session for file %s.",file));
429 return kFALSE;
430 }
431
432 if (!fRunLoader->GetAliRun()) {
433 fRunLoader->LoadgAlice();
434 }
435 gAlice = fRunLoader->GetAliRun();
436
437 if (gAlice) {
7925de54 438 AliDebug(1,"AliRun object found on file.");
95867fd1 439 }
440 else {
7925de54 441 AliError("Could not find AliRun object.");
95867fd1 442 return kFALSE;
443 }
444
445 fEvent = nEvent;
446
447 AliLoader *loader = fRunLoader->GetLoader("TRDLoader");
448 if (!loader) {
449 AliError("Can not get TRD loader from Run Loader");
450 return kFALSE;
451 }
452
453 if (InitDetector()) {
454 TTree *tree = 0;
455 if (fSDigits) {
456 // If we produce SDigits
457 tree = loader->TreeS();
458 if (!tree) {
459 loader->MakeTree("S");
460 tree = loader->TreeS();
461 }
462 }
463 else {
464 // If we produce Digits
465 tree = loader->TreeD();
466 if (!tree) {
467 loader->MakeTree("D");
468 tree = loader->TreeD();
469 }
470 }
471 return MakeBranch(tree);
472 }
473 else {
474 return kFALSE;
475 }
476
477}
478
479//_____________________________________________________________________________
621310dd 480Bool_t AliTRDdigitizer::Open(AliRunLoader * const runLoader, Int_t nEvent)
95867fd1 481{
482 //
483 // Opens a ROOT-file with TRD-hits and reads in the hit-tree
484 //
485 // Connect the AliRoot file containing Geometry, Kine, and Hits
486 //
487
488 fRunLoader = runLoader;
489 if (!fRunLoader) {
490 AliError("RunLoader does not exist");
491 return kFALSE;
4d18a639 492 }
88cb7938 493
9afbd7de 494 if (!fRunLoader->GetAliRun()) {
495 fRunLoader->LoadgAlice();
496 }
88cb7938 497 gAlice = fRunLoader->GetAliRun();
498
da581aea 499 if (gAlice) {
7925de54 500 AliDebug(1,"AliRun object found on file.");
da581aea 501 }
502 else {
7925de54 503 AliError("Could not find AliRun object.");
da581aea 504 return kFALSE;
505 }
f7336fa3 506
507 fEvent = nEvent;
508
4d18a639 509 AliLoader *loader = fRunLoader->GetLoader("TRDLoader");
9afbd7de 510 if (!loader) {
511 AliError("Can not get TRD loader from Run Loader");
512 return kFALSE;
513 }
88cb7938 514
abaf1f1d 515 if (InitDetector()) {
4d18a639 516 TTree *tree = 0;
9afbd7de 517 if (fSDigits) {
518 // If we produce SDigits
519 tree = loader->TreeS();
520 if (!tree) {
521 loader->MakeTree("S");
522 tree = loader->TreeS();
4d18a639 523 }
9afbd7de 524 }
525 else {
526 // If we produce Digits
95867fd1 527 tree = loader->TreeD();
9afbd7de 528 if (!tree) {
529 loader->MakeTree("D");
530 tree = loader->TreeD();
4d18a639 531 }
9afbd7de 532 }
88cb7938 533 return MakeBranch(tree);
abaf1f1d 534 }
535 else {
536 return kFALSE;
537 }
793ff80c 538
539}
540
541//_____________________________________________________________________________
542Bool_t AliTRDdigitizer::InitDetector()
543{
544 //
545 // Sets the pointer to the TRD detector and the geometry
546 //
547
dd9a6ee3 548 // Get the pointer to the detector class and check for version 1
4487dad0 549 fTRD = (AliTRD *) gAlice->GetDetector("TRD");
cec4059b 550 if (!fTRD) {
7925de54 551 AliFatal("No TRD module found");
cec4059b 552 exit(1);
553 }
dd9a6ee3 554 if (fTRD->IsVersion() != 1) {
7925de54 555 AliFatal("TRD must be version 1 (slow simulator)");
dd9a6ee3 556 exit(1);
557 }
558
559 // Get the geometry
f162af62 560 fGeo = new AliTRDgeometry();
dd9a6ee3 561
abaf1f1d 562 // Create a digits manager
625f5260 563 if (fDigitsManager) {
564 delete fDigitsManager;
565 }
abaf1f1d 566 fDigitsManager = new AliTRDdigitsManager();
567 fDigitsManager->SetSDigits(fSDigits);
568 fDigitsManager->CreateArrays();
569 fDigitsManager->SetEvent(fEvent);
abaf1f1d 570
571 // The list for the input s-digits manager to be merged
47b5729a 572 if (fSDigitsManagerList) {
573 fSDigitsManagerList->Delete();
3becff3c 574 }
575 else {
47b5729a 576 fSDigitsManagerList = new TList();
577 }
abaf1f1d 578
4487dad0 579 return kTRUE;
f7336fa3 580
581}
6244debe 582//_____________________________________________________________________________
95867fd1 583Bool_t AliTRDdigitizer::MakeBranch(TTree *tree) const
6244debe 584{
abaf1f1d 585 //
586 // Create the branches for the digits array
6244debe 587 //
588
88cb7938 589 return fDigitsManager->MakeBranch(tree);
6244debe 590
591}
592
625f5260 593//_____________________________________________________________________________
594void AliTRDdigitizer::AddSDigitsManager(AliTRDdigitsManager *man)
595{
596 //
597 // Add a digits manager for s-digits to the input list.
598 //
599
600 fSDigitsManagerList->Add(man);
601
602}
603
604//_____________________________________________________________________________
605void AliTRDdigitizer::DeleteSDigitsManager()
606{
607 //
608 // Removes digits manager from the input list.
609 //
610
611 fSDigitsManagerList->Delete();
612
613}
614
f7336fa3 615//_____________________________________________________________________________
616Bool_t AliTRDdigitizer::MakeDigits()
617{
618 //
872a7aba 619 // Creates digits.
f7336fa3 620 //
621
625f5260 622 AliDebug(1,"Start creating digits");
623
624 if (!fGeo) {
625 AliError("No geometry defined");
626 return kFALSE;
627 }
f7336fa3 628
625f5260 629 AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
630 if (!calibration) {
631 AliFatal("Could not get calibration object");
632 return kFALSE;
633 }
634
635 const Int_t kNdet = AliTRDgeometry::Ndet();
636
637 Float_t **hits = new Float_t*[kNdet];
638 Int_t *nhit = new Int_t[kNdet];
639
b65e5048 640 AliTRDarraySignal *signals = 0x0;
625f5260 641
642 // Sort all hits according to detector number
643 if (!SortHits(hits,nhit)) {
644 AliError("Sorting hits failed");
645 return kFALSE;
646 }
647
648 // Loop through all detectors
649 for (Int_t det = 0; det < kNdet; det++) {
650
651 // Detectors that are switched off, not installed, etc.
652 if (( calibration->IsChamberInstalled(det)) &&
b65e5048 653 (!calibration->IsChamberMasked(det)) &&
625f5260 654 ( fGeo->ChamberInGeometry(det)) &&
655 (nhit[det] > 0)) {
656
b65e5048 657 signals = new AliTRDarraySignal();
658
625f5260 659 // Convert the hits of the current detector to detector signals
660 if (!ConvertHits(det,hits[det],nhit[det],signals)) {
b65e5048 661 AliError(Form("Conversion of hits failed for detector=%d",det));
625f5260 662 return kFALSE;
663 }
664 // Convert the detector signals to digits or s-digits
665 if (!ConvertSignals(det,signals)) {
b65e5048 666 AliError(Form("Conversion of signals failed for detector=%d",det));
667 return kFALSE;
625f5260 668 }
669
670 // Delete the signals array
671 delete signals;
672 signals = 0x0;
673
674 } // if: detector status
675
27cea06a 676 delete [] hits[det];
677
625f5260 678 } // for: detector
679
680 delete [] hits;
681 delete [] nhit;
682
683 return kTRUE;
684
685}
686
687//_____________________________________________________________________________
688Bool_t AliTRDdigitizer::SortHits(Float_t **hits, Int_t *nhit)
689{
690 //
691 // Read all the hits and sorts them according to detector number
692 // in the output array <hits>.
693 //
694
695 AliDebug(1,"Start sorting hits");
696
697 const Int_t kNdet = AliTRDgeometry::Ndet();
698 // Size of the hit vector
699 const Int_t kNhit = 6;
700
701 Float_t *xyz = 0;
702 Int_t nhitTrk = 0;
703
704 Int_t *lhit = new Int_t[kNdet];
705
706 for (Int_t det = 0; det < kNdet; det++) {
707 lhit[det] = 0;
708 nhit[det] = 0;
709 hits[det] = 0;
710 }
711
712 AliLoader *gimme = fRunLoader->GetLoader("TRDLoader");
713 if (!gimme->TreeH()) {
714 gimme->LoadHits();
715 }
716 TTree *hitTree = gimme->TreeH();
717 if (hitTree == 0x0) {
718 AliError("Can not get TreeH");
719 return kFALSE;
720 }
721 fTRD->SetTreeAddress();
722
723 // Get the number of entries in the hit tree
724 // (Number of primary particles creating a hit somewhere)
725 Int_t nTrk = (Int_t) hitTree->GetEntries();
726 AliDebug(1,Form("Found %d tracks",nTrk));
727
728 // Loop through all the tracks in the tree
729 for (Int_t iTrk = 0; iTrk < nTrk; iTrk++) {
730
3e2e3ece 731 gAlice->GetMCApp()->ResetHits();
625f5260 732 hitTree->GetEvent(iTrk);
733
734 if (!fTRD->Hits()) {
735 AliError(Form("No hits array for track = %d",iTrk));
736 continue;
737 }
738
739 // Number of hits for this track
740 nhitTrk = fTRD->Hits()->GetEntriesFast();
741
742 Int_t hitCnt = 0;
743 // Loop through the TRD hits
744 AliTRDhit *hit = (AliTRDhit *) fTRD->FirstHit(-1);
745 while (hit) {
746
747 hitCnt++;
748
749 // Don't analyze test hits
750 if (((Int_t) hit->GetCharge()) != 0) {
751
752 Int_t trk = hit->Track();
753 Int_t det = hit->GetDetector();
754 Int_t q = hit->GetCharge();
755 Float_t x = hit->X();
756 Float_t y = hit->Y();
757 Float_t z = hit->Z();
758 Float_t time = hit->GetTime();
759
760 if (nhit[det] == lhit[det]) {
761 // Inititialization of new detector
762 xyz = new Float_t[kNhit*(nhitTrk+lhit[det])];
763 if (hits[det]) {
764 memcpy(xyz,hits[det],sizeof(Float_t)*kNhit*lhit[det]);
765 delete [] hits[det];
766 }
767 lhit[det] += nhitTrk;
768 hits[det] = xyz;
769 }
770 else {
771 xyz = hits[det];
772 }
773 xyz[nhit[det]*kNhit+0] = x;
774 xyz[nhit[det]*kNhit+1] = y;
775 xyz[nhit[det]*kNhit+2] = z;
776 xyz[nhit[det]*kNhit+3] = q;
777 xyz[nhit[det]*kNhit+4] = trk;
778 xyz[nhit[det]*kNhit+5] = time;
779 nhit[det]++;
780
781 } // if: charge != 0
782
783 hit = (AliTRDhit *) fTRD->NextHit();
784
785 } // for: hits of one track
786
787 } // for: tracks
788
789 delete [] lhit;
790
791 return kTRUE;
792
793}
f7336fa3 794
625f5260 795//_____________________________________________________________________________
621310dd 796Bool_t AliTRDdigitizer::ConvertHits(Int_t det
797 , const Float_t * const hits
798 , Int_t nhit
b65e5048 799 , AliTRDarraySignal *signals)
625f5260 800{
801 //
802 // Converts the detectorwise sorted hits to detector signals
803 //
804
805 AliDebug(1,Form("Start converting hits for detector=%d (nhits=%d)",det,nhit));
f7336fa3 806
793ff80c 807 // Number of pads included in the pad response
a5cadd36 808 const Int_t kNpad = 3;
793ff80c 809 // Number of track dictionary arrays
625f5260 810 const Int_t kNdict = AliTRDdigitsManager::kNDict;
811 // Size of the hit vector
812 const Int_t kNhit = 6;
793ff80c 813
4329977a 814 // Width of the amplification region
815 const Float_t kAmWidth = AliTRDgeometry::AmThick();
3becff3c 816 // Width of the drift region
ccb4315c 817 const Float_t kDrWidth = AliTRDgeometry::DrThick();
4329977a 818 // Drift + amplification region
819 const Float_t kDrMin = - 0.5 * kAmWidth;
820 const Float_t kDrMax = kDrWidth + 0.5 * kAmWidth;
3551db50 821
625f5260 822 Int_t iPad = 0;
823 Int_t dict = 0;
824 Int_t timeBinTRFend = 1;
872a7aba 825
a5cadd36 826 Double_t pos[3];
4329977a 827 Double_t loc[3];
a5cadd36 828 Double_t padSignal[kNpad];
829 Double_t signalOld[kNpad];
872a7aba 830
b65e5048 831 AliTRDarrayDictionary *dictionary[kNdict];
4329977a 832
9afbd7de 833 AliTRDSimParam *simParam = AliTRDSimParam::Instance();
9afbd7de 834 AliTRDCommonParam *commonParam = AliTRDCommonParam::Instance();
625f5260 835 AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
836
3becff3c 837 if (!commonParam) {
4329977a 838 AliFatal("Could not get common parameterss");
3551db50 839 return kFALSE;
840 }
625f5260 841 if (!simParam) {
842 AliFatal("Could not get simulation parameters");
843 return kFALSE;
844 }
3becff3c 845 if (!calibration) {
4329977a 846 AliFatal("Could not get calibration object");
3551db50 847 return kFALSE;
848 }
849
625f5260 850 // Get the detector wise calibration objects
851 AliTRDCalROC *calVdriftROC = 0;
852 Float_t calVdriftDetValue = 0.0;
853 const AliTRDCalDet *calVdriftDet = calibration->GetVdriftDet();
854 AliTRDCalROC *calT0ROC = 0;
855 Float_t calT0DetValue = 0.0;
856 const AliTRDCalDet *calT0Det = calibration->GetT0Det();
4329977a 857
4329977a 858 if (simParam->TRFOn()) {
859 timeBinTRFend = ((Int_t) (simParam->GetTRFhi()
860 * commonParam->GetSamplingFrequency())) - 1;
4329977a 861 }
862
3becff3c 863 Int_t nTimeTotal = calibration->GetNumberOfTimeBins();
b43a3e17 864 Float_t samplingRate = commonParam->GetSamplingFrequency();
4329977a 865 Float_t elAttachProp = simParam->GetElAttachProp() / 100.0;
a328fff9 866
625f5260 867 AliTRDpadPlane *padPlane = fGeo->GetPadPlane(det);
b65e5048 868 Int_t layer = fGeo->GetLayer(det); //update
625f5260 869 Float_t row0 = padPlane->GetRow0ROC();
870 Int_t nRowMax = padPlane->GetNrows();
871 Int_t nColMax = padPlane->GetNcols();
872
873 // Create a new array for the signals
874 signals->Allocate(nRowMax,nColMax,nTimeTotal);
875
876 // Create a new array for the dictionary
877 for (dict = 0; dict < kNdict; dict++) {
b65e5048 878 dictionary[dict] = (AliTRDarrayDictionary *) fDigitsManager->GetDictionary(det,dict);
625f5260 879 dictionary[dict]->Allocate(nRowMax,nColMax,nTimeTotal);
880 }
881
882 // Loop through the hits in this detector
883 for (Int_t hit = 0; hit < nhit; hit++) {
884
885 pos[0] = hits[hit*kNhit+0];
886 pos[1] = hits[hit*kNhit+1];
887 pos[2] = hits[hit*kNhit+2];
888 Float_t q = hits[hit*kNhit+3];
889 Float_t hittime = hits[hit*kNhit+5];
890 Int_t track = ((Int_t) hits[hit*kNhit+4]);
891
892 Int_t inDrift = 1;
893
894 // Find the current volume with the geo manager
895 gGeoManager->SetCurrentPoint(pos);
896 gGeoManager->FindNode();
897 if (strstr(gGeoManager->GetPath(),"/UK")) {
898 inDrift = 0;
899 }
793ff80c 900
625f5260 901 // Get the calibration objects
902 calVdriftROC = calibration->GetVdriftROC(det);
903 calVdriftDetValue = calVdriftDet->GetValue(det);
904 calT0ROC = calibration->GetT0ROC(det);
905 calT0DetValue = calT0Det->GetValue(det);
906
907 // Go to the local coordinate system:
908 // loc[0] - col direction in amplification or driftvolume
909 // loc[1] - row direction in amplification or driftvolume
910 // loc[2] - time direction in amplification or driftvolume
911 gGeoManager->MasterToLocal(pos,loc);
912 if (inDrift) {
913 // Relative to middle of amplification region
914 loc[2] = loc[2] - kDrWidth/2.0 - kAmWidth/2.0;
915 }
793ff80c 916
625f5260 917 // The driftlength [cm] (w/o diffusion yet !).
918 // It is negative if the hit is between pad plane and anode wires.
919 Double_t driftlength = -1.0 * loc[2];
e23fbb27 920
625f5260 921 // Stupid patch to take care of TR photons that are absorbed
922 // outside the chamber volume. A real fix would actually need
923 // a more clever implementation of the TR hit generation
924 if (q < 0.0) {
925 if ((loc[1] < padPlane->GetRowEndROC()) ||
926 (loc[1] > padPlane->GetRow0ROC())) {
f881dc35 927 continue;
928 }
625f5260 929 if ((driftlength < kDrMin) ||
930 (driftlength > kDrMax)) {
931 continue;
4329977a 932 }
625f5260 933 }
f881dc35 934
625f5260 935 // Get row and col of unsmeared electron to retrieve drift velocity
936 // The pad row (z-direction)
937 Int_t rowE = padPlane->GetPadRowNumberROC(loc[1]);
938 if (rowE < 0) {
939 continue;
940 }
941 Double_t rowOffset = padPlane->GetPadRowOffsetROC(rowE,loc[1]);
942 // The pad column (rphi-direction)
943 Double_t offsetTilt = padPlane->GetTiltOffset(rowOffset);
944 Int_t colE = padPlane->GetPadColNumber(loc[0]+offsetTilt);
945 if (colE < 0) {
946 continue;
947 }
0a17cc30 948 Double_t colOffset = 0.0;
f881dc35 949
625f5260 950 // Normalized drift length
951 Float_t driftvelocity = calVdriftDetValue * calVdriftROC->GetValue(colE,rowE);
952 Double_t absdriftlength = TMath::Abs(driftlength);
953 if (commonParam->ExBOn()) {
954 absdriftlength /= TMath::Sqrt(GetLorentzFactor(driftvelocity));
955 }
956
957 // Loop over all electrons of this hit
958 // TR photons produce hits with negative charge
959 Int_t nEl = ((Int_t) TMath::Abs(q));
960 for (Int_t iEl = 0; iEl < nEl; iEl++) {
961
962 // Now the real local coordinate system of the ROC
963 // column direction: locC
964 // row direction: locR
965 // time direction: locT
966 // locR and locC are identical to the coordinates of the corresponding
967 // volumina of the drift or amplification region.
968 // locT is defined relative to the wire plane (i.e. middle of amplification
26d3c914 969 // region), meaning locT = 0, and is negative for hits coming from the
625f5260 970 // drift region.
971 Double_t locC = loc[0];
972 Double_t locR = loc[1];
973 Double_t locT = loc[2];
974
975 // Electron attachment
976 if (simParam->ElAttachOn()) {
977 if (gRandom->Rndm() < (absdriftlength * elAttachProp)) {
978 continue;
f881dc35 979 }
625f5260 980 }
981
982 // Apply the diffusion smearing
983 if (simParam->DiffusionOn()) {
984 if (!(Diffusion(driftvelocity,absdriftlength,locR,locC,locT))) {
985 continue;
f881dc35 986 }
f881dc35 987 }
793ff80c 988
625f5260 989 // Apply E x B effects (depends on drift direction)
990 if (commonParam->ExBOn()) {
991 if (!(ExB(driftvelocity,driftlength,locC))) {
4329977a 992 continue;
993 }
729161c5 994 }
995
625f5260 996 // The electron position after diffusion and ExB in pad coordinates.
4329977a 997 // The pad row (z-direction)
625f5260 998 rowE = padPlane->GetPadRowNumberROC(locR);
999 if (rowE < 0) continue;
1000 rowOffset = padPlane->GetPadRowOffsetROC(rowE,locR);
4329977a 1001
1002 // The pad column (rphi-direction)
625f5260 1003 offsetTilt = padPlane->GetTiltOffset(rowOffset);
1004 colE = padPlane->GetPadColNumber(locC+offsetTilt);
1005 if (colE < 0) continue;
1006 colOffset = padPlane->GetPadColOffset(colE,locC+offsetTilt);
b65e5048 1007
625f5260 1008 // Also re-retrieve drift velocity because col and row may have changed
1009 driftvelocity = calVdriftDetValue * calVdriftROC->GetValue(colE,rowE);
1010 Float_t t0 = calT0DetValue + calT0ROC->GetValue(colE,rowE);
1011
1012 // Convert the position to drift time [mus], using either constant drift velocity or
1013 // time structure of drift cells (non-isochronity, GARFIELD calculation).
1014 // Also add absolute time of hits to take pile-up events into account properly
1015 Double_t drifttime;
1016 if (simParam->TimeStructOn()) {
1017 // Get z-position with respect to anode wire
58897a75 1018 Double_t zz = row0 - locR + padPlane->GetAnodeWireOffset();
625f5260 1019 zz -= ((Int_t)(2 * zz)) / 2.0;
1020 if (zz > 0.25) {
1021 zz = 0.5 - zz;
1022 }
1023 // Use drift time map (GARFIELD)
a076fc2f 1024 drifttime = commonParam->TimeStruct(driftvelocity,0.5*kAmWidth-1.0*locT,zz)
625f5260 1025 + hittime;
1026 }
1027 else {
1028 // Use constant drift velocity
26d3c914 1029 drifttime = TMath::Abs(locT) / driftvelocity
625f5260 1030 + hittime;
4329977a 1031 }
625f5260 1032
1033 // Apply the gas gain including fluctuations
1034 Double_t ggRndm = 0.0;
1035 do {
1036 ggRndm = gRandom->Rndm();
1037 } while (ggRndm <= 0);
eb52b657 1038 Double_t signal = -(simParam->GetGasGain()) * TMath::Log(ggRndm);
625f5260 1039
1040 // Apply the pad response
1041 if (simParam->PRFOn()) {
1042 // The distance of the electron to the center of the pad
1043 // in units of pad width
1044 Double_t dist = (colOffset - 0.5*padPlane->GetColSize(colE))
1045 / padPlane->GetColSize(colE);
1046 // This is a fixed parametrization, i.e. not dependent on
1047 // calibration values !
053767a4 1048 if (!(calibration->PadResponse(signal,dist,layer,padSignal))) continue;
625f5260 1049 }
1050 else {
1051 padSignal[0] = 0.0;
1052 padSignal[1] = signal;
1053 padSignal[2] = 0.0;
4329977a 1054 }
f881dc35 1055
625f5260 1056 // The time bin (always positive), with t0 distortion
1057 Double_t timeBinIdeal = drifttime * samplingRate + t0;
1058 // Protection
1059 if (TMath::Abs(timeBinIdeal) > 2*nTimeTotal) {
1060 timeBinIdeal = 2 * nTimeTotal;
1061 }
1062 Int_t timeBinTruncated = ((Int_t) timeBinIdeal);
1063 // The distance of the position to the middle of the timebin
1064 Double_t timeOffset = ((Float_t) timeBinTruncated
1065 + 0.5 - timeBinIdeal) / samplingRate;
3551db50 1066
625f5260 1067 // Sample the time response inside the drift region
1068 // + additional time bins before and after.
1069 // The sampling is done always in the middle of the time bin
1070 for (Int_t iTimeBin = TMath::Max(timeBinTruncated,0)
1071 ;iTimeBin < TMath::Min(timeBinTruncated+timeBinTRFend,nTimeTotal)
1072 ;iTimeBin++) {
1073
1074 // Apply the time response
1075 Double_t timeResponse = 1.0;
1076 Double_t crossTalk = 0.0;
1077 Double_t time = (iTimeBin - timeBinTruncated) / samplingRate + timeOffset;
58897a75 1078
625f5260 1079 if (simParam->TRFOn()) {
1080 timeResponse = simParam->TimeResponse(time);
f881dc35 1081 }
625f5260 1082 if (simParam->CTOn()) {
1083 crossTalk = simParam->CrossTalk(time);
f881dc35 1084 }
e23fbb27 1085
625f5260 1086 signalOld[0] = 0.0;
1087 signalOld[1] = 0.0;
1088 signalOld[2] = 0.0;
e23fbb27 1089
625f5260 1090 for (iPad = 0; iPad < kNpad; iPad++) {
f7336fa3 1091
625f5260 1092 Int_t colPos = colE + iPad - 1;
1093 if (colPos < 0) continue;
1094 if (colPos >= nColMax) break;
e23fbb27 1095
625f5260 1096 // Add the signals
b65e5048 1097 signalOld[iPad] = signals->GetData(rowE,colPos,iTimeBin);
e23fbb27 1098
625f5260 1099 if (colPos != colE) {
1100 // Cross talk added to non-central pads
1101 signalOld[iPad] += padSignal[iPad]
1102 * (timeResponse + crossTalk);
1103 }
1104 else {
1105 // W/o cross talk at central pad
1106 signalOld[iPad] += padSignal[iPad]
1107 * timeResponse;
1108 }
f881dc35 1109
b65e5048 1110 signals->SetData(rowE,colPos,iTimeBin,signalOld[iPad]);
625f5260 1111
1112 // Store the track index in the dictionary
1113 // Note: We store index+1 in order to allow the array to be compressed
b65e5048 1114 // Note2: Taking out the +1 in track
625f5260 1115 if (signalOld[iPad] > 0.0) {
1116 for (dict = 0; dict < kNdict; dict++) {
b65e5048 1117 Int_t oldTrack = dictionary[dict]->GetData(rowE,colPos,iTimeBin);
1118 if (oldTrack == track) break;
1119 if (oldTrack == -1 ) {
1120 dictionary[dict]->SetData(rowE,colPos,iTimeBin,track);
1121 break;
1122 }
f881dc35 1123 }
625f5260 1124 }
872a7aba 1125
625f5260 1126 } // Loop: pads
f7336fa3 1127
625f5260 1128 } // Loop: time bins
f7336fa3 1129
625f5260 1130 } // Loop: electrons of a single hit
f7336fa3 1131
625f5260 1132 } // Loop: hits
f7336fa3 1133
625f5260 1134 AliDebug(2,Form("Finished analyzing %d hits",nhit));
e23fbb27 1135
625f5260 1136 return kTRUE;
e23fbb27 1137
625f5260 1138}
793ff80c 1139
625f5260 1140//_____________________________________________________________________________
b65e5048 1141Bool_t AliTRDdigitizer::ConvertSignals(Int_t det, AliTRDarraySignal *signals)
625f5260 1142{
4329977a 1143 //
625f5260 1144 // Convert signals to digits
4329977a 1145 //
1146
625f5260 1147 AliDebug(1,Form("Start converting the signals for detector %d",det));
1148
1149 if (fSDigits) {
1150 // Convert the signal array to s-digits
1151 if (!Signal2SDigits(det,signals)) {
1152 return kFALSE;
793ff80c 1153 }
625f5260 1154 }
1155 else {
1156 // Convert the signal array to digits
1157 if (!Signal2ADC(det,signals)) {
1158 return kFALSE;
793ff80c 1159 }
d295185b 1160 // Run digital processing for digits
1161 RunDigitalProcessing(det);
625f5260 1162 }
f7336fa3 1163
625f5260 1164 // Compress the arrays
b65e5048 1165 CompressOutputArrays(det);
6244debe 1166
625f5260 1167 return kTRUE;
6244debe 1168
625f5260 1169}
4329977a 1170
625f5260 1171//_____________________________________________________________________________
b65e5048 1172Bool_t AliTRDdigitizer::Signal2ADC(Int_t det, AliTRDarraySignal *signals)
625f5260 1173{
1174 //
1175 // Converts the sampled electron signals to ADC values for a given chamber
1176 //
6244debe 1177
625f5260 1178 AliDebug(1,Form("Start converting signals to ADC values for detector=%d",det));
e23fbb27 1179
625f5260 1180 AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
1181 if (!calibration) {
1182 AliFatal("Could not get calibration object");
1183 return kFALSE;
1184 }
793ff80c 1185
625f5260 1186 AliTRDSimParam *simParam = AliTRDSimParam::Instance();
1187 if (!simParam) {
1188 AliFatal("Could not get simulation parameters");
1189 return kFALSE;
1190 }
f7336fa3 1191
625f5260 1192 // Converts number of electrons to fC
1193 const Double_t kEl2fC = 1.602e-19 * 1.0e15;
0c24ba98 1194
625f5260 1195 // Coupling factor
1196 Double_t coupling = simParam->GetPadCoupling()
1197 * simParam->GetTimeCoupling();
1198 // Electronics conversion factor
1199 Double_t convert = kEl2fC
1200 * simParam->GetChipGain();
1201 // ADC conversion factor
1202 Double_t adcConvert = simParam->GetADCoutRange()
1203 / simParam->GetADCinRange();
1204 // The electronics baseline in mV
1205 Double_t baseline = simParam->GetADCbaseline()
1206 / adcConvert;
1207 // The electronics baseline in electrons
1208 Double_t baselineEl = baseline
1209 / convert;
1210
1211 Int_t row = 0;
1212 Int_t col = 0;
1213 Int_t time = 0;
1214
1215 Int_t nRowMax = fGeo->GetPadPlane(det)->GetNrows();
1216 Int_t nColMax = fGeo->GetPadPlane(det)->GetNcols();
1217 Int_t nTimeTotal = calibration->GetNumberOfTimeBins();
abaf1f1d 1218
625f5260 1219 // The gainfactor calibration objects
1220 const AliTRDCalDet *calGainFactorDet = calibration->GetGainFactorDet();
1221 AliTRDCalROC *calGainFactorROC = 0;
1222 Float_t calGainFactorDetValue = 0.0;
f7336fa3 1223
b65e5048 1224 AliTRDarrayADC *digits = 0x0;
e23fbb27 1225
625f5260 1226 if (!signals) {
1227 AliError(Form("Signals array for detector %d does not exist\n",det));
1228 return kFALSE;
1229 }
1230 if (signals->HasData()) {
1231 // Expand the container if neccessary
b65e5048 1232 signals->Expand();
625f5260 1233 }
1234 else {
1235 // Create missing containers
1236 signals->Allocate(nRowMax,nColMax,nTimeTotal);
f7336fa3 1237 }
1238
625f5260 1239 // Get the container for the digits of this detector
1240 if (fDigitsManager->HasSDigits()) {
1241 AliError("Digits manager has s-digits");
1242 return kFALSE;
1243 }
b65e5048 1244
1245 digits = (AliTRDarrayADC *) fDigitsManager->GetDigits(det);
625f5260 1246 // Allocate memory space for the digits buffer
1247 if (!digits->HasData()) {
1248 digits->Allocate(nRowMax,nColMax,nTimeTotal);
0c24ba98 1249 }
1250
625f5260 1251 // Get the calibration objects
1252 calGainFactorROC = calibration->GetGainFactorROC(det);
1253 calGainFactorDetValue = calGainFactorDet->GetValue(det);
abaf1f1d 1254
625f5260 1255 // Create the digits for this chamber
1256 for (row = 0; row < nRowMax; row++ ) {
1257 for (col = 0; col < nColMax; col++ ) {
abaf1f1d 1258
625f5260 1259 // Check whether pad is masked
1260 // Bridged pads are not considered yet!!!
1261 if (calibration->IsPadMasked(det,col,row)) {
1262 continue;
1263 }
abaf1f1d 1264
625f5260 1265 // The gain factors
1266 Float_t padgain = calGainFactorDetValue
1267 * calGainFactorROC->GetValue(col,row);
1268 if (padgain <= 0) {
1269 AliError(Form("Not a valid gain %f, %d %d %d",padgain,det,col,row));
1270 }
abaf1f1d 1271
625f5260 1272 for (time = 0; time < nTimeTotal; time++) {
1273
1274 // Get the signal amplitude
b65e5048 1275 Float_t signalAmp = signals->GetData(row,col,time);
625f5260 1276 // Pad and time coupling
1277 signalAmp *= coupling;
1278 // Gain factors
1279 signalAmp *= padgain;
1280
1281 // Add the noise, starting from minus ADC baseline in electrons
1282 signalAmp = TMath::Max((Double_t) gRandom->Gaus(signalAmp,simParam->GetNoise())
1283 ,-baselineEl);
1284
1285 // Convert to mV
1286 signalAmp *= convert;
1287 // Add ADC baseline in mV
1288 signalAmp += baseline;
1289
1290 // Convert to ADC counts. Set the overflow-bit fADCoutRange if the
1291 // signal is larger than fADCinRange
1292 Short_t adc = 0;
1293 if (signalAmp >= simParam->GetADCinRange()) {
1294 adc = ((Short_t) simParam->GetADCoutRange());
1295 }
1296 else {
1297 adc = TMath::Nint(signalAmp * adcConvert);
1298 }
abaf1f1d 1299
b65e5048 1300 // Saving all digits
1301 digits->SetData(row,col,time,adc);
abaf1f1d 1302
625f5260 1303 } // for: time
b65e5048 1304
625f5260 1305 } // for: col
1306 } // for: row
b1113c6b 1307
625f5260 1308 return kTRUE;
b1113c6b 1309
1310}
1311
abaf1f1d 1312//_____________________________________________________________________________
b65e5048 1313Bool_t AliTRDdigitizer::Signal2SDigits(Int_t det, AliTRDarraySignal *signals)
abaf1f1d 1314{
1315 //
625f5260 1316 // Converts the sampled electron signals to s-digits
abaf1f1d 1317 //
1318
625f5260 1319 AliDebug(1,Form("Start converting signals to s-digits for detector=%d",det));
abaf1f1d 1320
4329977a 1321 AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
9afbd7de 1322 if (!calibration) {
4329977a 1323 AliFatal("Could not get calibration object");
3551db50 1324 return kFALSE;
1325 }
6bf5f0ce 1326
625f5260 1327 Int_t row = 0;
1328 Int_t col = 0;
1329 Int_t time = 0;
9afbd7de 1330
625f5260 1331 Int_t nRowMax = fGeo->GetPadPlane(det)->GetNrows();
1332 Int_t nColMax = fGeo->GetPadPlane(det)->GetNcols();
1333 Int_t nTimeTotal = calibration->GetNumberOfTimeBins();
e23fbb27 1334
625f5260 1335 // Get the container for the digits of this detector
b65e5048 1336
625f5260 1337 if (!fDigitsManager->HasSDigits()) {
1338 AliError("Digits manager has no s-digits");
1339 return kFALSE;
1340 }
b65e5048 1341
1342 AliTRDarraySignal *digits = (AliTRDarraySignal *) fDigitsManager->GetSDigits(det);
625f5260 1343 // Allocate memory space for the digits buffer
1344 if (!digits->HasData()) {
1345 digits->Allocate(nRowMax,nColMax,nTimeTotal);
1346 }
e23fbb27 1347
625f5260 1348 // Create the sdigits for this chamber
1349 for (row = 0; row < nRowMax; row++ ) {
1350 for (col = 0; col < nColMax; col++ ) {
1351 for (time = 0; time < nTimeTotal; time++) {
b65e5048 1352 digits->SetData(row,col,time,signals->GetData(row,col,time));
625f5260 1353 } // for: time
1354 } // for: col
1355 } // for: row
b65e5048 1356
625f5260 1357 return kTRUE;
abaf1f1d 1358
625f5260 1359}
abaf1f1d 1360
e7539003 1361//_____________________________________________________________________________
621310dd 1362Bool_t AliTRDdigitizer::Digits2SDigits(AliTRDdigitsManager * const manDig
1363 , AliTRDdigitsManager * const manSDig)
e7539003 1364{
1365 //
1366 // Converts digits into s-digits. Needed for embedding into real data.
1367 //
1368
1369 AliDebug(1,"Start converting digits to s-digits");
1370
6b4a4228 1371 if (!fGeo) {
1372 fGeo = new AliTRDgeometry();
1373 }
1374
e7539003 1375 AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
1376 if (!calibration) {
1377 AliFatal("Could not get calibration object");
1378 return kFALSE;
1379 }
1380
1381 AliTRDSimParam *simParam = AliTRDSimParam::Instance();
1382 if (!simParam) {
1383 AliFatal("Could not get simulation parameters");
1384 return kFALSE;
1385 }
1386
1387 // Converts number of electrons to fC
1388 const Double_t kEl2fC = 1.602e-19 * 1.0e15;
1389
1390 // Coupling factor
1391 Double_t coupling = simParam->GetPadCoupling()
1392 * simParam->GetTimeCoupling();
1393 // Electronics conversion factor
1394 Double_t convert = kEl2fC
1395 * simParam->GetChipGain();
1396 // ADC conversion factor
1397 Double_t adcConvert = simParam->GetADCoutRange()
1398 / simParam->GetADCinRange();
1399 // The electronics baseline in mV
1400 Double_t baseline = simParam->GetADCbaseline()
1401 / adcConvert;
1402 // The electronics baseline in electrons
6b4a4228 1403 //Double_t baselineEl = baseline
1404 // / convert;
e7539003 1405
1406 // The gainfactor calibration objects
1407 //const AliTRDCalDet *calGainFactorDet = calibration->GetGainFactorDet();
1408 //AliTRDCalROC *calGainFactorROC = 0;
1409 //Float_t calGainFactorDetValue = 0.0;
1410
1411 Int_t row = 0;
1412 Int_t col = 0;
1413 Int_t time = 0;
1414
1415 for (Int_t det = 0; det < AliTRDgeometry::Ndet(); det++) {
1416
1417 Int_t nRowMax = fGeo->GetPadPlane(det)->GetNrows();
1418 Int_t nColMax = fGeo->GetPadPlane(det)->GetNcols();
1419 Int_t nTimeTotal = calibration->GetNumberOfTimeBins();
1420
1421 // Get the calibration objects
1422 //calGainFactorROC = calibration->GetGainFactorROC(det);
1423 //calGainFactorDetValue = calGainFactorDet->GetValue(det);
1424
1425 // Get the digits
1426 AliTRDarrayADC *digits = (AliTRDarrayADC *) manDig->GetDigits(det);
1427
1428 if (!manSDig->HasSDigits()) {
1429 AliError("SDigits manager has no s-digits");
1430 return kFALSE;
1431 }
1432 // Get the s-digits
1433 AliTRDarraySignal *sdigits = (AliTRDarraySignal *) manSDig->GetSDigits(det);
1434 AliTRDarrayDictionary *tracks0 = (AliTRDarrayDictionary *) manSDig->GetDictionary(det,0);
1435 AliTRDarrayDictionary *tracks1 = (AliTRDarrayDictionary *) manSDig->GetDictionary(det,1);
1436 AliTRDarrayDictionary *tracks2 = (AliTRDarrayDictionary *) manSDig->GetDictionary(det,2);
1437 // Allocate memory space for the digits buffer
1438 sdigits->Allocate(nRowMax,nColMax,nTimeTotal);
1439 tracks0->Allocate(nRowMax,nColMax,nTimeTotal);
1440 tracks1->Allocate(nRowMax,nColMax,nTimeTotal);
1441 tracks2->Allocate(nRowMax,nColMax,nTimeTotal);
1442
1443 // Create the sdigits for this chamber
1444 for (row = 0; row < nRowMax; row++ ) {
1445 for (col = 0; col < nColMax; col++ ) {
1446
1447 // The gain factors
1448 //Float_t padgain = calGainFactorDetValue
1449 // * calGainFactorROC->GetValue(col,row);
1450
1451 for (time = 0; time < nTimeTotal; time++) {
1452
1453 Double_t signal = (Double_t) digits->GetData(row,col,time);
1454
1455 // ADC -> signal in mV
1456 signal /= adcConvert;
1457
1458 // Subtract baseline in mV
1459 signal -= baseline;
1460
1461 // Signal in mV -> signal in #electrons
1462 signal /= convert;
1463
1464 // Gain factor
1465 //signal /= padgain; // Not needed for real data
1466
1467 // Pad and time coupling
1468 signal /= coupling;
1469
1470 sdigits->SetData(row,col,time,signal);
1471 tracks0->SetData(row,col,time,0);
1472 tracks1->SetData(row,col,time,0);
1473 tracks2->SetData(row,col,time,0);
1474
1475 } // for: time
1476
1477 } // for: col
1478 } // for: row
1479
1480 sdigits->Compress(0);
1481 tracks0->Compress();
1482 tracks1->Compress();
1483 tracks2->Compress();
1484
1485 } // for: det
1486
1487 return kTRUE;
1488
1489}
1490
625f5260 1491//_____________________________________________________________________________
1492Bool_t AliTRDdigitizer::SDigits2Digits()
1493{
1494 //
1495 // Merges the input s-digits and converts them to normal digits
1496 //
e23fbb27 1497
625f5260 1498 if (!MergeSDigits()) {
1499 return kFALSE;
1500 }
f7336fa3 1501
625f5260 1502 return ConvertSDigits();
f7336fa3 1503
1504}
1505
16bf9884 1506//_____________________________________________________________________________
abaf1f1d 1507Bool_t AliTRDdigitizer::MergeSDigits()
16bf9884 1508{
1509 //
abaf1f1d 1510 // Merges the input s-digits:
1511 // - The amplitude of the different inputs are summed up.
1512 // - Of the track IDs from the input dictionaries only one is
1513 // kept for each input. This works for maximal 3 different merged inputs.
16bf9884 1514 //
1515
abaf1f1d 1516 // Number of track dictionary arrays
1517 const Int_t kNDict = AliTRDdigitsManager::kNDict;
1518
4d18a639 1519 AliTRDSimParam *simParam = AliTRDSimParam::Instance();
9afbd7de 1520 if (!simParam) {
4329977a 1521 AliFatal("Could not get simulation parameters");
3551db50 1522 return kFALSE;
1523 }
1524
4d18a639 1525 AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
9afbd7de 1526 if (!calibration) {
4329977a 1527 AliFatal("Could not get calibration object");
3551db50 1528 return kFALSE;
1529 }
1530
abaf1f1d 1531 Int_t iDict = 0;
e23fbb27 1532 Int_t jDict = 0;
abaf1f1d 1533
b65e5048 1534 AliTRDarraySignal *digitsA;
1535 AliTRDarraySignal *digitsB;
1536 AliTRDarrayDictionary *dictionaryA[kNDict];
1537 AliTRDarrayDictionary *dictionaryB[kNDict];
abaf1f1d 1538
b65e5048 1539 AliTRDdigitsManager *mergeSDigitsManager = 0x0;
abaf1f1d 1540 // Get the first s-digits
1541 fSDigitsManager = (AliTRDdigitsManager *) fSDigitsManagerList->First();
9afbd7de 1542 if (!fSDigitsManager) {
7925de54 1543 AliError("No SDigits manager");
9afbd7de 1544 return kFALSE;
1545 }
abaf1f1d 1546
1547 // Loop through the other sets of s-digits
b65e5048 1548 mergeSDigitsManager = (AliTRDdigitsManager *) fSDigitsManagerList->After(fSDigitsManager);
abaf1f1d 1549
9afbd7de 1550 if (mergeSDigitsManager) {
7925de54 1551 AliDebug(1,Form("Merge %d input files.",fSDigitsManagerList->GetSize()));
9afbd7de 1552 }
1553 else {
7925de54 1554 AliDebug(1,"Only one input file.");
abaf1f1d 1555 }
3551db50 1556
b65e5048 1557 Int_t nTimeTotal = calibration->GetNumberOfTimeBins();
abaf1f1d 1558 Int_t iMerge = 0;
b65e5048 1559
abaf1f1d 1560 while (mergeSDigitsManager) {
1561
1562 iMerge++;
b65e5048 1563
abaf1f1d 1564 // Loop through the detectors
1565 for (Int_t iDet = 0; iDet < AliTRDgeometry::Ndet(); iDet++) {
1566
625f5260 1567 Int_t nRowMax = fGeo->GetPadPlane(iDet)->GetNrows();
1568 Int_t nColMax = fGeo->GetPadPlane(iDet)->GetNcols();
b65e5048 1569
abaf1f1d 1570 // Loop through the pixels of one detector and add the signals
b65e5048 1571 digitsA = (AliTRDarraySignal *) fSDigitsManager->GetSDigits(iDet);
1572 digitsB = (AliTRDarraySignal *) mergeSDigitsManager->GetSDigits(iDet);
1573 digitsA->Expand();
1574 if (!digitsA->HasData()) continue;
1575 digitsB->Expand();
1576 if (!digitsB->HasData()) continue;
1577
abaf1f1d 1578 for (iDict = 0; iDict < kNDict; iDict++) {
b65e5048 1579 dictionaryA[iDict] = (AliTRDarrayDictionary *) fSDigitsManager->GetDictionary(iDet,iDict);
1580 dictionaryB[iDict] = (AliTRDarrayDictionary *) mergeSDigitsManager->GetDictionary(iDet,iDict);
1581 dictionaryA[iDict]->Expand();
abaf1f1d 1582 dictionaryB[iDict]->Expand();
1583 }
1584
4487dad0 1585 // Merge only detectors that contain a signal
1586 Bool_t doMerge = kTRUE;
1587 if (fMergeSignalOnly) {
b65e5048 1588 if (digitsA->GetOverThreshold(0) == 0) {
1589 doMerge = kFALSE;
4487dad0 1590 }
abaf1f1d 1591 }
b65e5048 1592
4487dad0 1593 if (doMerge) {
b65e5048 1594
1595 AliDebug(1,Form("Merge detector %d of input no.%d",iDet,iMerge+1));
1596
1597 for (Int_t iRow = 0; iRow < nRowMax; iRow++ ) {
1598 for (Int_t iCol = 0; iCol < nColMax; iCol++ ) {
1599 for (Int_t iTime = 0; iTime < nTimeTotal; iTime++) {
1600
4487dad0 1601 // Add the amplitudes of the summable digits
b65e5048 1602 Float_t ampA = digitsA->GetData(iRow,iCol,iTime);
1603 Float_t ampB = digitsB->GetData(iRow,iCol,iTime);
1604 ampA += ampB;
1605 digitsA->SetData(iRow,iCol,iTime,ampA);
1606
1607 // Add the mask to the track id if defined.
1608 for (iDict = 0; iDict < kNDict; iDict++) {
1609 Int_t trackB = dictionaryB[iDict]->GetData(iRow,iCol,iTime);
1610 if ((fMasks) && (trackB > 0)) {
1611 for (jDict = 0; jDict < kNDict; jDict++) {
1612 Int_t trackA = dictionaryA[iDict]->GetData(iRow,iCol,iTime);
1613 if (trackA == 0) {
1614 trackA = trackB + fMasks[iMerge];
1615 dictionaryA[iDict]->SetData(iRow,iCol,iTime,trackA);
625f5260 1616 } // if: track A == 0
b65e5048 1617 } // for: jDict
1618 } // if: fMasks and trackB > 0
625f5260 1619 } // for: iDict
abaf1f1d 1620
625f5260 1621 } // for: iTime
1622 } // for: iCol
1623 } // for: iRow
4487dad0 1624
625f5260 1625 } // if: doMerge
1626
1627 mergeSDigitsManager->RemoveDigits(iDet);
1628 mergeSDigitsManager->RemoveDictionaries(iDet);
b65e5048 1629
abaf1f1d 1630 if (fCompress) {
b65e5048 1631 digitsA->Compress(0);
1632 for (iDict = 0; iDict < kNDict; iDict++) {
1633 dictionaryA[iDict]->Compress();
abaf1f1d 1634 }
1635 }
b65e5048 1636
625f5260 1637 } // for: detectors
b65e5048 1638
abaf1f1d 1639 // The next set of s-digits
b65e5048 1640 mergeSDigitsManager = (AliTRDdigitsManager *) fSDigitsManagerList->After(mergeSDigitsManager);
1641
625f5260 1642 } // while: mergeDigitsManagers
b65e5048 1643
625f5260 1644 return kTRUE;
1645
1646}
1647
1648//_____________________________________________________________________________
1649Bool_t AliTRDdigitizer::ConvertSDigits()
1650{
1651 //
1652 // Converts s-digits to normal digits
1653 //
1654
b65e5048 1655 AliTRDarraySignal *digitsIn = 0x0;
625f5260 1656
1657 if (!fSDigitsManager->HasSDigits()) {
1658 AliError("No s-digits in digits manager");
1659 return kFALSE;
abaf1f1d 1660 }
1661
625f5260 1662 // Loop through the detectors
1663 for (Int_t det = 0; det < AliTRDgeometry::Ndet(); det++) {
1664
1665 // Get the merged s-digits (signals)
b65e5048 1666 digitsIn = (AliTRDarraySignal *) fSDigitsManager->GetSDigits(det);
625f5260 1667 if (!digitsIn->HasData()) {
1668 AliDebug(2,Form("No digits for det=%d",det));
1669 continue;
1670 }
b0a41e80 1671
625f5260 1672 // Convert the merged sdigits to digits
1673 if (!Signal2ADC(det,digitsIn)) {
1674 continue;
1675 }
1676
1677 // Copy the dictionary information to the output array
1678 if (!CopyDictionary(det)) {
1679 continue;
1680 }
1681
1682 // Delete
1683 fSDigitsManager->RemoveDigits(det);
1684 fSDigitsManager->RemoveDictionaries(det);
1685
d295185b 1686 // Run digital processing
1687 RunDigitalProcessing(det);
1688
625f5260 1689 // Compress the arrays
1690 CompressOutputArrays(det);
1691
1692 } // for: detector numbers
1693
b0a41e80 1694
16bf9884 1695 return kTRUE;
1696
1697}
1698
abaf1f1d 1699//_____________________________________________________________________________
625f5260 1700Bool_t AliTRDdigitizer::CopyDictionary(Int_t det)
abaf1f1d 1701{
1702 //
625f5260 1703 // Copies the dictionary information from the s-digits arrays
1704 // to the output arrays
abaf1f1d 1705 //
1706
625f5260 1707 AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
1708 if (!calibration) {
1709 AliFatal("Could not get calibration object");
4d18a639 1710 return kFALSE;
1711 }
abaf1f1d 1712
625f5260 1713 AliDebug(1,Form("Start copying dictionaries for detector=%d",det));
1714
1715 const Int_t kNDict = AliTRDdigitsManager::kNDict;
b65e5048 1716 AliTRDarrayDictionary *dictionaryIn[kNDict];
1717 AliTRDarrayDictionary *dictionaryOut[kNDict];
625f5260 1718
1719 Int_t nRowMax = fGeo->GetPadPlane(det)->GetNrows();
1720 Int_t nColMax = fGeo->GetPadPlane(det)->GetNcols();
1721 Int_t nTimeTotal = calibration->GetNumberOfTimeBins();
1722
1723 Int_t row = 0;
1724 Int_t col = 0;
1725 Int_t time = 0;
1726 Int_t dict = 0;
1727
1728 for (dict = 0; dict < kNDict; dict++) {
1729
b65e5048 1730 dictionaryIn[dict] = (AliTRDarrayDictionary *) fSDigitsManager->GetDictionary(det,dict);
625f5260 1731 dictionaryIn[dict]->Expand();
b65e5048 1732 dictionaryOut[dict] = (AliTRDarrayDictionary *) fDigitsManager->GetDictionary(det,dict);
625f5260 1733 dictionaryOut[dict]->Allocate(nRowMax,nColMax,nTimeTotal);
1734
1735 for (row = 0; row < nRowMax; row++) {
1736 for (col = 0; col < nColMax; col++) {
1737 for (time = 0; time < nTimeTotal; time++) {
b65e5048 1738 Int_t track = dictionaryIn[dict]->GetData(row,col,time);
1739 dictionaryOut[dict]->SetData(row,col,time,track);
625f5260 1740 } // for: time
1741 } // for: col
1742 } // for: row
b65e5048 1743
625f5260 1744 } // for: dictionaries
b65e5048 1745
625f5260 1746 return kTRUE;
1747
1748}
1749
1750//_____________________________________________________________________________
1751void AliTRDdigitizer::CompressOutputArrays(Int_t det)
1752{
1753 //
1754 // Compress the output arrays
1755 //
1756
1757 const Int_t kNDict = AliTRDdigitsManager::kNDict;
b65e5048 1758 AliTRDarrayDictionary *dictionary = 0x0;
625f5260 1759
1760 if (fCompress) {
1761
b65e5048 1762 if (!fSDigits) {
1763 AliTRDarrayADC *digits = 0x0;
1764 digits = (AliTRDarrayADC *) fDigitsManager->GetDigits(det);
1765 digits->Compress();
1766 }
1767
1768 if (fSDigits) {
1769 AliTRDarraySignal *digits = 0x0;
1770 digits = (AliTRDarraySignal *) fDigitsManager->GetSDigits(det);
1771 digits->Compress(0);
1772 }
1773
625f5260 1774 for (Int_t dict = 0; dict < kNDict; dict++) {
b65e5048 1775 dictionary = (AliTRDarrayDictionary *) fDigitsManager->GetDictionary(det,dict);
1776 dictionary->Compress();
625f5260 1777 }
1778
1779 }
abaf1f1d 1780
1781}
1782
f7336fa3 1783//_____________________________________________________________________________
0a29d0f1 1784Bool_t AliTRDdigitizer::WriteDigits() const
f7336fa3 1785{
1786 //
1787 // Writes out the TRD-digits and the dictionaries
1788 //
1789
4d18a639 1790 // Write parameters
bdbb05bb 1791 fRunLoader->CdGAFile();
bdbb05bb 1792
da581aea 1793 // Store the digits and the dictionary in the tree
abaf1f1d 1794 return fDigitsManager->WriteDigits();
f7336fa3 1795
1796}
793ff80c 1797
8e64dd77 1798//_____________________________________________________________________________
88cb7938 1799void AliTRDdigitizer::InitOutput(Int_t iEvent)
8e64dd77 1800{
1801 //
1802 // Initializes the output branches
1803 //
1804
1805 fEvent = iEvent;
88cb7938 1806
9afbd7de 1807 if (!fRunLoader) {
1808 AliError("Run Loader is NULL");
1809 return;
1810 }
1811
4329977a 1812 AliLoader *loader = fRunLoader->GetLoader("TRDLoader");
9afbd7de 1813 if (!loader) {
1814 AliError("Can not get TRD loader from Run Loader");
1815 return;
1816 }
88cb7938 1817
4d18a639 1818 TTree *tree = 0;
88cb7938 1819
9afbd7de 1820 if (fSDigits) {
1821 // If we produce SDigits
88cb7938 1822 tree = loader->TreeS();
9afbd7de 1823 if (!tree) {
88cb7938 1824 loader->MakeTree("S");
1825 tree = loader->TreeS();
9afbd7de 1826 }
1827 }
1828 else {
1829 // If we produce Digits
1830 tree = loader->TreeD();
1831 if (!tree) {
1832 loader->MakeTree("D");
1833 tree = loader->TreeD();
1834 }
1835 }
88cb7938 1836 fDigitsManager->SetEvent(iEvent);
1837 fDigitsManager->MakeBranch(tree);
8e64dd77 1838
1839}
3551db50 1840
3551db50 1841//_____________________________________________________________________________
a076fc2f 1842Int_t AliTRDdigitizer::Diffusion(Float_t vdrift, Double_t absdriftlength
1843 , Double_t &lRow, Double_t &lCol, Double_t &lTime)
3551db50 1844{
1845 //
a076fc2f 1846 // Applies the diffusion smearing to the position of a single electron.
1847 // Depends on absolute drift length.
3551db50 1848 //
1849
a076fc2f 1850 Float_t diffL = 0.0;
1851 Float_t diffT = 0.0;
4d18a639 1852
a076fc2f 1853 if (AliTRDCommonParam::Instance()->GetDiffCoeff(diffL,diffT,vdrift)) {
3551db50 1854
a076fc2f 1855 Float_t driftSqrt = TMath::Sqrt(absdriftlength);
1856 Float_t sigmaT = driftSqrt * diffT;
1857 Float_t sigmaL = driftSqrt * diffL;
1858 lRow = gRandom->Gaus(lRow ,sigmaT);
1859 lCol = gRandom->Gaus(lCol ,sigmaT * GetLorentzFactor(vdrift));
1860 lTime = gRandom->Gaus(lTime,sigmaL * GetLorentzFactor(vdrift));
4d18a639 1861
a076fc2f 1862 return 1;
7754cd1f 1863
3551db50 1864 }
a076fc2f 1865 else {
3551db50 1866
a076fc2f 1867 return 0;
1b95a37b 1868
3551db50 1869 }
9afbd7de 1870
3551db50 1871}
3551db50 1872
1873//_____________________________________________________________________________
1874Float_t AliTRDdigitizer::GetLorentzFactor(Float_t vd)
1875{
9afbd7de 1876 //
a076fc2f 1877 // Returns the Lorentz factor
9afbd7de 1878 //
1879
a076fc2f 1880 Double_t omegaTau = AliTRDCommonParam::Instance()->GetOmegaTau(vd);
1881 Double_t lorentzFactor = 1.0;
1882 if (AliTRDCommonParam::Instance()->ExBOn()) {
1883 lorentzFactor = 1.0 / (1.0 + omegaTau*omegaTau);
1884 }
4d18a639 1885
a076fc2f 1886 return lorentzFactor;
9afbd7de 1887
3551db50 1888}
1889
1890//_____________________________________________________________________________
4329977a 1891Int_t AliTRDdigitizer::ExB(Float_t vdrift, Double_t driftlength, Double_t &lCol)
3551db50 1892{
1893 //
4329977a 1894 // Applies E x B effects to the position of a single electron.
1895 // Depends on signed drift length.
3551db50 1896 //
4329977a 1897
a076fc2f 1898 lCol = lCol
1899 + AliTRDCommonParam::Instance()->GetOmegaTau(vdrift)
1900 * driftlength;
3551db50 1901
1902 return 1;
9afbd7de 1903
3551db50 1904}
b65e5048 1905
1906//_____________________________________________________________________________
d295185b 1907void AliTRDdigitizer::RunDigitalProcessing(Int_t det)
b65e5048 1908{
1909 //
b0a41e80 1910 // Run the digital processing in the TRAP
b65e5048 1911 //
1912
b0a41e80 1913 AliTRDfeeParam *feeParam = AliTRDfeeParam::Instance();
b65e5048 1914
1915 //Create and initialize the mcm object
b0a41e80 1916 AliTRDmcmSim* mcmfast = new AliTRDmcmSim();
b65e5048 1917
d295185b 1918 AliTRDarrayADC *digits = fDigitsManager->GetDigits(det);
1919 if (!digits)
1920 return;
1921
b65e5048 1922 //Call the methods in the mcm class using the temporary array as input
64e3d742 1923 for(Int_t rob = 0; rob < digits->GetNrow() / 2; rob++)
b0a41e80 1924 {
1925 for(Int_t mcm = 0; mcm < 16; mcm++)
b65e5048 1926 {
b0a41e80 1927 mcmfast->Init(det, rob, mcm);
40bd6ee4 1928 mcmfast->SetData(digits, fDigitsManager);
b65e5048 1929 mcmfast->Filter();
c8b1590d 1930 if (feeParam->GetTracklet()) {
b0a41e80 1931 mcmfast->Tracklet();
c8b1590d 1932 mcmfast->StoreTracklets();
1933 }
b65e5048 1934 mcmfast->ZSMapping();
b0a41e80 1935 mcmfast->WriteData(digits);
b65e5048 1936 }
b0a41e80 1937 }
b65e5048 1938
b65e5048 1939 delete mcmfast;
d295185b 1940
b65e5048 1941}