]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCALDigitizer.cxx
Default arguments set only in the header file
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALDigitizer.cxx
CommitLineData
61e0abb5 1/**************************************************************************
692088ae 2
556fa06b 3
61e0abb5 4 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
692088ae 5
556fa06b 6
61e0abb5 7 * *
692088ae 8
556fa06b 9
61e0abb5 10 * Author: The ALICE Off-line Project. *
692088ae 11
556fa06b 12
61e0abb5 13 * Contributors are mentioned in the code where appropriate. *
692088ae 14
556fa06b 15
61e0abb5 16 * *
692088ae 17
556fa06b 18
61e0abb5 19 * Permission to use, copy, modify and distribute this software and its *
692088ae 20
556fa06b 21
61e0abb5 22 * documentation strictly for non-commercial purposes is hereby granted *
692088ae 23
556fa06b 24
61e0abb5 25 * without fee, provided that the above copyright notice appears in all *
692088ae 26
556fa06b 27
61e0abb5 28 * copies and that both the copyright notice and this permission notice *
692088ae 29
556fa06b 30
61e0abb5 31 * appear in the supporting documentation. The authors make no claims *
692088ae 32
556fa06b 33
61e0abb5 34 * about the suitability of this software for any purpose. It is *
692088ae 35
556fa06b 36
61e0abb5 37 * provided "as is" without express or implied warranty. *
692088ae 38
556fa06b 39
61e0abb5 40 **************************************************************************/
41
692088ae 42
43
556fa06b 44
45
61e0abb5 46/* $Id$ */
47
692088ae 48
49
556fa06b 50
51
61e0abb5 52//_________________________________________________________________________
692088ae 53
556fa06b 54
ffa6d63b 55//
692088ae 56
556fa06b 57
61e0abb5 58//////////////////////////////////////////////////////////////////////////////
692088ae 59
556fa06b 60
ffa6d63b 61// Class performs digitization of Summable digits
692088ae 62
556fa06b 63
ffa6d63b 64//
692088ae 65
556fa06b 66
61e0abb5 67// In addition it performs mixing of summable digits from different events.
692088ae 68
556fa06b 69
61e0abb5 70//
692088ae 71
556fa06b 72
61e0abb5 73// For each event two branches are created in TreeD:
692088ae 74
556fa06b 75
61e0abb5 76// "EMCAL" - list of digits
692088ae 77
556fa06b 78
61e0abb5 79// "AliEMCALDigitizer" - AliEMCALDigitizer with all parameters used in digitization
692088ae 80
556fa06b 81
61e0abb5 82//
692088ae 83
556fa06b 84
61e0abb5 85// Note, that one cset title for new digits branch, and repeat digitization with
692088ae 86
556fa06b 87
61e0abb5 88// another set of parameters.
692088ae 89
556fa06b 90
61e0abb5 91//
692088ae 92
556fa06b 93
61e0abb5 94// Examples of use:
692088ae 95
556fa06b 96
61e0abb5 97// root[0] AliEMCALDigitizer * d = new AliEMCALDigitizer() ;
692088ae 98
556fa06b 99
61e0abb5 100// root[1] d->ExecuteTask()
692088ae 101
556fa06b 102
61e0abb5 103// Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated
692088ae 104
556fa06b 105
61e0abb5 106// //Digitizes SDigitis in all events found in file galice.root
692088ae 107
556fa06b 108
61e0abb5 109//
692088ae 110
556fa06b 111
61e0abb5 112// root[2] AliEMCALDigitizer * d1 = new AliEMCALDigitizer("galice1.root") ;
692088ae 113
556fa06b 114
61e0abb5 115// // Will read sdigits from galice1.root
692088ae 116
556fa06b 117
61e0abb5 118// root[3] d1->MixWith("galice2.root")
692088ae 119
556fa06b 120
61e0abb5 121// Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated
692088ae 122
556fa06b 123
61e0abb5 124// // Reads another portion of sdigits from galice2.root
692088ae 125
556fa06b 126
61e0abb5 127// root[3] d1->MixWith("galice3.root")
692088ae 128
556fa06b 129
61e0abb5 130// // Reads another portion of sdigits from galice3.root
692088ae 131
556fa06b 132
61e0abb5 133// root[4] d->ExecuteTask("deb timing")
692088ae 134
556fa06b 135
61e0abb5 136// // Reads SDigits from files galice1.root, galice2.root ....
692088ae 137
556fa06b 138
61e0abb5 139// // mixes them and stores produced Digits in file galice1.root
692088ae 140
556fa06b 141
61e0abb5 142// // deb - prints number of produced digits
692088ae 143
556fa06b 144
61e0abb5 145// // deb all - prints list of produced digits
692088ae 146
556fa06b 147
61e0abb5 148// // timing - prints time used for digitization
692088ae 149
556fa06b 150
ffa6d63b 151////////////////////////////////////////////////////////////////////////////////////
692088ae 152
556fa06b 153
61e0abb5 154//
692088ae 155
556fa06b 156
ffa6d63b 157//*-- Author: Sahal Yacoob (LBL)
692088ae 158
556fa06b 159
814ad4bf 160// based on : AliEMCALDigitizer
692088ae 161
556fa06b 162
ffa6d63b 163//_________________________________________________________________________________
61e0abb5 164
692088ae 165
166
556fa06b 167
168
61e0abb5 169// --- ROOT system ---
692088ae 170
556fa06b 171
61e0abb5 172#include "TFile.h"
692088ae 173
556fa06b 174
61e0abb5 175#include "TTree.h"
692088ae 176
556fa06b 177
61e0abb5 178#include "TSystem.h"
692088ae 179
556fa06b 180
61e0abb5 181#include "TROOT.h"
692088ae 182
556fa06b 183
61e0abb5 184#include "TFolder.h"
692088ae 185
556fa06b 186
61e0abb5 187#include "TObjString.h"
692088ae 188
556fa06b 189
61e0abb5 190#include "TBenchmark.h"
692088ae 191
556fa06b 192
61e0abb5 193// --- Standard library ---
692088ae 194
556fa06b 195
61e0abb5 196#include <iomanip.h>
197
692088ae 198
199
556fa06b 200
201
61e0abb5 202// --- AliRoot header files ---
203
692088ae 204
205
556fa06b 206
207
61e0abb5 208#include "AliRun.h"
692088ae 209
556fa06b 210
61e0abb5 211#include "AliEMCALDigit.h"
692088ae 212
556fa06b 213
61e0abb5 214#include "AliEMCALHit.h"
692088ae 215
556fa06b 216
814ad4bf 217#include "AliEMCALTick.h"
692088ae 218
556fa06b 219
61e0abb5 220#include "AliEMCALv1.h"
692088ae 221
556fa06b 222
61e0abb5 223#include "AliEMCALDigitizer.h"
692088ae 224
556fa06b 225
61e0abb5 226#include "AliEMCALSDigitizer.h"
692088ae 227
556fa06b 228
61e0abb5 229#include "AliEMCALGeometry.h"
692088ae 230
556fa06b 231
814ad4bf 232#include "AliEMCALGetter.h"
692088ae 233
556fa06b 234
814ad4bf 235#include "AliRunDigitizer.h"
692088ae 236
556fa06b 237
61e0abb5 238ClassImp(AliEMCALDigitizer)
239
240
692088ae 241
242
243
556fa06b 244
245
246
61e0abb5 247//____________________________________________________________________________
692088ae 248
556fa06b 249
814ad4bf 250 AliEMCALDigitizer::AliEMCALDigitizer()
692088ae 251
556fa06b 252
61e0abb5 253{
692088ae 254
556fa06b 255
61e0abb5 256 // ctor
257
692088ae 258
259
556fa06b 260
261
61e0abb5 262 fSDigitizer = 0 ;
61e0abb5 263
692088ae 264
556fa06b 265 fNinputs = 0 ;
692088ae 266
692088ae 267
556fa06b 268 fPinNoise = 0.0 ;
692088ae 269
692088ae 270
556fa06b 271 fTowerDigitThreshold = 0.0 ;
692088ae 272
692088ae 273
556fa06b 274 fTimeResolution = 0. ;
b66c1acf 275
692088ae 276
556fa06b 277 fTimeSignalLength = 0. ;
692088ae 278
692088ae 279
556fa06b 280 fPreShowerDigitThreshold = 0. ;
692088ae 281
692088ae 282
556fa06b 283 fADCchannelTower = 0.0; // width of one ADC channel in GeV
284
285
286 fADCpedestalTower = 0. ; // pedestal of ADC
287
288
289 fNADCTower = 0; // number of channels in Tower ADC
290
291
292
293
294
295 fADCchannelPreSho = 0.0; // width of one ADC channel in Pre Shower
296
297
298 fADCpedestalPreSho = 0.0 ; // pedestal of ADC
299
300
301 fNADCPreSho = 0; // number of channels in Pre Shower ADC
302
303
304 fTimeThreshold = 0.0; //Means 1 MeV in terms of SDigits amplitude
b66c1acf 305
692088ae 306
814ad4bf 307 fManager = 0 ;
61e0abb5 308
61e0abb5 309
61e0abb5 310
692088ae 311
312
313
314
556fa06b 315
316
317
318
61e0abb5 319}
692088ae 320
556fa06b 321
61e0abb5 322//____________________________________________________________________________
692088ae 323
556fa06b 324
814ad4bf 325Bool_t AliEMCALDigitizer::Init()
692088ae 326
556fa06b 327
61e0abb5 328{
692088ae 329
556fa06b 330
814ad4bf 331 // Makes all memory allocations
332
692088ae 333
334
556fa06b 335
336
814ad4bf 337 fSDigitizer = 0 ;
692088ae 338
556fa06b 339
814ad4bf 340 fNinputs = 1 ;
692088ae 341
556fa06b 342
d968cee0 343 fPinNoise = 0.00001 ;
692088ae 344
556fa06b 345
d968cee0 346 fTowerDigitThreshold = 0.001 ;
692088ae 347
556fa06b 348
814ad4bf 349 fTimeResolution = 0.5e-9 ;
692088ae 350
556fa06b 351
814ad4bf 352 fTimeSignalLength = 1.0e-9 ;
692088ae 353
556fa06b 354
d968cee0 355 fPreShowerDigitThreshold = fTowerDigitThreshold/25. ;
692088ae 356
556fa06b 357
814ad4bf 358 fInitialized = kFALSE ;
692088ae 359
556fa06b 360
b66c1acf 361 fADCchannelTower = 0.000220; // width of one ADC channel in GeV
692088ae 362
556fa06b 363
d968cee0 364 fADCpedestalTower = 0.005 ; // GeV
692088ae 365
556fa06b 366
814ad4bf 367 fNADCTower = (Int_t) TMath::Power(2,16) ; // number of channels in Tower ADC
368
692088ae 369
370
556fa06b 371
372
373 fADCchannelPreSho = 0.0000300; // width of one ADC channel in Pre Shower
374
692088ae 375
814ad4bf 376 fADCpedestalPreSho = 0.005 ; //
692088ae 377
556fa06b 378
d968cee0 379 fNADCPreSho = (Int_t) TMath::Power(2,12); // number of channels in Pre ShowerADC
814ad4bf 380
692088ae 381
382
556fa06b 383
384
814ad4bf 385 fTimeThreshold = 0.001*10000000 ; //Means 1 MeV in terms of SDigits amplitude
692088ae 386
556fa06b 387
814ad4bf 388
389
390
692088ae 391
392
393
556fa06b 394
395
396
814ad4bf 397if(fManager)
692088ae 398
556fa06b 399
814ad4bf 400 SetTitle("aliroot") ;
692088ae 401
556fa06b 402
814ad4bf 403 else if (strcmp(GetTitle(),"")==0)
692088ae 404
556fa06b 405
814ad4bf 406 SetTitle("galice.root") ;
407
692088ae 408
409
556fa06b 410
411
814ad4bf 412 if( strcmp(GetName(), "") == 0 )
692088ae 413
556fa06b 414
814ad4bf 415 SetName("Default") ;
692088ae 416
556fa06b 417
61e0abb5 418
692088ae 419
556fa06b 420
814ad4bf 421 AliEMCALGetter * gime = AliEMCALGetter::GetInstance(GetTitle(), GetName(), "update") ;
692088ae 422
556fa06b 423
814ad4bf 424 if ( gime == 0 ) {
692088ae 425
556fa06b 426
814ad4bf 427 cerr << "ERROR: AliEMCALDigitizer::Init -> Could not obtain the Getter object !" << endl ;
692088ae 428
556fa06b 429
814ad4bf 430 return kFALSE;
692088ae 431
556fa06b 432
814ad4bf 433 }
692088ae 434
556fa06b 435
61e0abb5 436
692088ae 437
556fa06b 438
814ad4bf 439 //const AliEMCALGeometry * geom = gime->EMCALGeometry() ;
692088ae 440
556fa06b 441
814ad4bf 442 //fEmcCrystals = geom->GetNModules() * geom->GetNCristalsInModule() ;
692088ae 443
556fa06b 444
61e0abb5 445
692088ae 446
556fa06b 447
814ad4bf 448 // Post Digits to the white board
692088ae 449
556fa06b 450
814ad4bf 451 gime->PostDigits(GetName() ) ;
692088ae 452
556fa06b 453
61e0abb5 454
692088ae 455
556fa06b 456
814ad4bf 457 // Post Digitizer to the white board
692088ae 458
556fa06b 459
814ad4bf 460 gime->PostDigitizer(this) ;
692088ae 461
556fa06b 462
61e0abb5 463
692088ae 464
556fa06b 465
814ad4bf 466 //Mark that we will use current header file
692088ae 467
556fa06b 468
814ad4bf 469 if(!fManager){
692088ae 470
556fa06b 471
814ad4bf 472 gime->PostSDigits(GetName(),GetTitle()) ;
692088ae 473
556fa06b 474
814ad4bf 475 gime->PostSDigitizer(GetName(),GetTitle()) ;
692088ae 476
556fa06b 477
814ad4bf 478 }
692088ae 479
556fa06b 480
814ad4bf 481 return kTRUE ;
692088ae 482
556fa06b 483
61e0abb5 484
692088ae 485
556fa06b 486
814ad4bf 487
692088ae 488
556fa06b 489
61e0abb5 490
692088ae 491
556fa06b 492
814ad4bf 493}
494
692088ae 495
496
556fa06b 497
498
814ad4bf 499//____________________________________________________________________________
692088ae 500
556fa06b 501
814ad4bf 502AliEMCALDigitizer::AliEMCALDigitizer(const char *headerFile,const char *name)
692088ae 503
556fa06b 504
814ad4bf 505{
692088ae 506
556fa06b 507
814ad4bf 508 SetName(name) ;
692088ae 509
556fa06b 510
814ad4bf 511 SetTitle(headerFile) ;
692088ae 512
556fa06b 513
814ad4bf 514 fManager = 0 ; // We work in the standalong mode
692088ae 515
556fa06b 516
814ad4bf 517 Init() ;
692088ae 518
556fa06b 519
61e0abb5 520
814ad4bf 521
692088ae 522
523
556fa06b 524
525
61e0abb5 526
692088ae 527
556fa06b 528
814ad4bf 529}
692088ae 530
556fa06b 531
814ad4bf 532//____________________________________________________________________________
692088ae 533
556fa06b 534
814ad4bf 535AliEMCALDigitizer::AliEMCALDigitizer(AliRunDigitizer * ard):AliDigitizer(ard)
692088ae 536
556fa06b 537
814ad4bf 538{
692088ae 539
556fa06b 540
814ad4bf 541 // ctor
692088ae 542
556fa06b 543
814ad4bf 544 SetName(""); //Will call init in the digitizing
692088ae 545
556fa06b 546
814ad4bf 547 SetTitle("aliroot") ;
692088ae 548
556fa06b 549
61e0abb5 550}
551
692088ae 552
553
556fa06b 554
555
61e0abb5 556//____________________________________________________________________________
692088ae 557
556fa06b 558
61e0abb5 559 AliEMCALDigitizer::~AliEMCALDigitizer()
692088ae 560
556fa06b 561
61e0abb5 562{
692088ae 563
556fa06b 564
61e0abb5 565 // dtor
566
692088ae 567
568
556fa06b 569
570
61e0abb5 571}
692088ae 572
556fa06b 573
61e0abb5 574//____________________________________________________________________________
692088ae 575
556fa06b 576
61e0abb5 577void AliEMCALDigitizer::Reset() {
692088ae 578
556fa06b 579
61e0abb5 580 //sets current event number to the first simulated event
692088ae 581
556fa06b 582
814ad4bf 583if( strcmp(GetName(), "") == 0 )
692088ae 584
556fa06b 585
814ad4bf 586 Init() ;
61e0abb5 587
692088ae 588
589
556fa06b 590
591
814ad4bf 592 // Int_t inputs ;
692088ae 593
556fa06b 594
814ad4bf 595 // for(inputs = 0; inputs < fNinputs ;inputs++)
692088ae 596
556fa06b 597
814ad4bf 598 // fIevent->AddAt(-1, inputs ) ;
692088ae 599
556fa06b 600
61e0abb5 601
692088ae 602
556fa06b 603
61e0abb5 604}
605
692088ae 606
607
556fa06b 608
609
61e0abb5 610//____________________________________________________________________________
692088ae 611
556fa06b 612
814ad4bf 613void AliEMCALDigitizer::Digitize(const Int_t event) {
61e0abb5 614
692088ae 615
616
556fa06b 617
618
61e0abb5 619 // Makes the digitization of the collected summable digits
692088ae 620
556fa06b 621
61e0abb5 622 // for this it first creates the array of all EMCAL modules
692088ae 623
556fa06b 624
61e0abb5 625 // filled with noise (different for EMC, CPV and PPSD) and
692088ae 626
556fa06b 627
61e0abb5 628 // after that adds contributions from SDigits. This design
692088ae 629
556fa06b 630
61e0abb5 631 // helps to avoid scanning over the list of digits to add
692088ae 632
556fa06b 633
61e0abb5 634 // contribution of any new SDigit.
635
692088ae 636
637
556fa06b 638
639
814ad4bf 640 AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ;
692088ae 641
556fa06b 642
814ad4bf 643 TClonesArray * digits = gime->Digits(GetName()) ;
692088ae 644
556fa06b 645
814ad4bf 646
692088ae 647
556fa06b 648
814ad4bf 649 digits->Clear() ;
61e0abb5 650
692088ae 651
652
556fa06b 653
654
814ad4bf 655 const AliEMCALGeometry *geom = gime->EMCALGeometry() ;
61e0abb5 656
61e0abb5 657
692088ae 658
659
660
556fa06b 661
662
663
61e0abb5 664 //Making digits with noise, first EMC
692088ae 665
556fa06b 666
ffa6d63b 667 Int_t nEMC = 2*geom->GetNPhi()*geom->GetNZ();
692088ae 668
556fa06b 669
61e0abb5 670 Int_t absID ;
692088ae 671
556fa06b 672
61e0abb5 673 TString name = geom->GetName() ;
61e0abb5 674
692088ae 675
676
556fa06b 677
678
814ad4bf 679 // get first the sdigitizer from the tasks list (must have same name as the digitizer)
692088ae 680
556fa06b 681
814ad4bf 682 const AliEMCALSDigitizer * sDigitizer = gime->SDigitizer(GetName());
692088ae 683
556fa06b 684
814ad4bf 685 if ( !sDigitizer) {
692088ae 686
556fa06b 687
814ad4bf 688 cerr << "ERROR: AliEMCALDigitizer::Digitize -> SDigitizer with name " << GetName() << " not found " << endl ;
692088ae 689
556fa06b 690
814ad4bf 691 abort() ;
692088ae 692
556fa06b 693
61e0abb5 694 }
695
692088ae 696
697
556fa06b 698
699
814ad4bf 700// loop through the sdigits posted to the White Board and add them to the noise
692088ae 701
556fa06b 702
814ad4bf 703 TCollection * folderslist = gime->SDigitsFolder()->GetListOfFolders() ;
692088ae 704
556fa06b 705
814ad4bf 706 TIter next(folderslist) ;
692088ae 707
556fa06b 708
814ad4bf 709 TFolder * folder = 0 ;
692088ae 710
556fa06b 711
814ad4bf 712 TClonesArray * sdigits = 0 ;
692088ae 713
556fa06b 714
814ad4bf 715 Int_t input = 0 ;
692088ae 716
556fa06b 717
814ad4bf 718 TObjArray * sdigArray = new TObjArray(2) ;
692088ae 719
556fa06b 720
814ad4bf 721 while ( (folder = (TFolder*)next()) )
692088ae 722
556fa06b 723
814ad4bf 724 if ( (sdigits = (TClonesArray*)folder->FindObject(GetName()) ) ) {
692088ae 725
556fa06b 726
814ad4bf 727 cout << "INFO: AliEMCALDigitizer::Digitize -> Adding SDigits "
692088ae 728
556fa06b 729
814ad4bf 730 << GetName() << " from " << folder->GetName() << endl ;
692088ae 731
556fa06b 732
814ad4bf 733 sdigArray->AddAt(sdigits, input) ;
692088ae 734
556fa06b 735
814ad4bf 736 input++ ;
692088ae 737
556fa06b 738
814ad4bf 739 }
61e0abb5 740
692088ae 741
742
556fa06b 743
744
d968cee0 745 //Find the first tower with signal
692088ae 746
556fa06b 747
814ad4bf 748 Int_t nextSig = 200000 ;
692088ae 749
556fa06b 750
814ad4bf 751 Int_t i;
692088ae 752
556fa06b 753
814ad4bf 754 for(i=0; i<input; i++){
692088ae 755
556fa06b 756
814ad4bf 757 sdigits = (TClonesArray *)sdigArray->At(i) ;
692088ae 758
556fa06b 759
814ad4bf 760 if ( !sdigits->GetEntriesFast() )
692088ae 761
556fa06b 762
814ad4bf 763 continue ;
692088ae 764
556fa06b 765
814ad4bf 766 Int_t curNext = ((AliEMCALDigit *)sdigits->At(0))->GetId() ;
692088ae 767
556fa06b 768
814ad4bf 769 if(curNext < nextSig)
692088ae 770
556fa06b 771
814ad4bf 772 nextSig = curNext ;
692088ae 773
556fa06b 774
814ad4bf 775 }
61e0abb5 776
692088ae 777
778
556fa06b 779
780
814ad4bf 781 TArrayI index(input) ;
692088ae 782
556fa06b 783
814ad4bf 784 index.Reset() ; //Set all indexes to zero
61e0abb5 785
692088ae 786
787
556fa06b 788
789
814ad4bf 790 AliEMCALDigit * digit = 0 ;
692088ae 791
556fa06b 792
814ad4bf 793 AliEMCALDigit * curSDigit = 0 ;
ffa6d63b 794
692088ae 795
796
556fa06b 797
798
814ad4bf 799 TClonesArray * ticks = new TClonesArray("AliEMCALTick",1000) ;
ffa6d63b 800
692088ae 801
802
556fa06b 803
804
814ad4bf 805 //Put Noise contribution
692088ae 806
556fa06b 807
814ad4bf 808 for(absID = 1; absID <= nEMC; absID++){
692088ae 809
556fa06b 810
d968cee0 811 Float_t noise = gRandom->Gaus(0., fPinNoise);
692088ae 812
556fa06b 813
814ad4bf 814 new((*digits)[absID-1]) AliEMCALDigit( -1, -1, absID,sDigitizer->Digitize(noise), TimeOfNoise() ) ;
692088ae 815
556fa06b 816
814ad4bf 817 //look if we have to add signal?
692088ae 818
556fa06b 819
814ad4bf 820 if(absID==nextSig){
692088ae 821
556fa06b 822
814ad4bf 823 //Add SDigits from all inputs
692088ae 824
556fa06b 825
814ad4bf 826 digit = (AliEMCALDigit *) digits->At(absID-1) ;
692088ae 827
556fa06b 828
814ad4bf 829
692088ae 830
556fa06b 831
814ad4bf 832 ticks->Clear() ;
692088ae 833
556fa06b 834
814ad4bf 835 Int_t contrib = 0 ;
692088ae 836
556fa06b 837
814ad4bf 838 Float_t a = digit->GetAmp() ;
692088ae 839
556fa06b 840
814ad4bf 841 Float_t b = TMath::Abs( a /fTimeSignalLength) ;
692088ae 842
556fa06b 843
814ad4bf 844 //Mark the beginnign of the signal
692088ae 845
556fa06b 846
814ad4bf 847 new((*ticks)[contrib++]) AliEMCALTick(digit->GetTime(),0, b);
692088ae 848
556fa06b 849
814ad4bf 850 //Mark the end of the ignal
692088ae 851
556fa06b 852
814ad4bf 853 new((*ticks)[contrib++]) AliEMCALTick(digit->GetTime()+fTimeSignalLength, -a, -b);
692088ae 854
556fa06b 855
814ad4bf 856
692088ae 857
556fa06b 858
814ad4bf 859 // loop over input
692088ae 860
556fa06b 861
814ad4bf 862
692088ae 863
556fa06b 864
814ad4bf 865 for(i = 0; i< input ; i++){ //loop over (possible) merge sources
692088ae 866
556fa06b 867
814ad4bf 868 if(((TClonesArray *)sdigArray->At(i))->GetEntriesFast() > index[i] )
692088ae 869
556fa06b 870
814ad4bf 871 curSDigit = (AliEMCALDigit*)((TClonesArray *)sdigArray->At(i))->At(index[i]) ;
692088ae 872
556fa06b 873
814ad4bf 874 else
692088ae 875
556fa06b 876
814ad4bf 877 curSDigit = 0 ;
692088ae 878
556fa06b 879
814ad4bf 880 //May be several digits will contribute from the same input
692088ae 881
556fa06b 882
814ad4bf 883 while(curSDigit && curSDigit->GetId() == absID){
692088ae 884
556fa06b 885
814ad4bf 886 //Shift primary to separate primaries belonging different inputs
692088ae 887
556fa06b 888
814ad4bf 889 Int_t primaryoffset ;
692088ae 890
556fa06b 891
814ad4bf 892 if(fManager)
692088ae 893
556fa06b 894
814ad4bf 895 primaryoffset = fManager->GetMask(i) ;
692088ae 896
556fa06b 897
814ad4bf 898 else
692088ae 899
556fa06b 900
814ad4bf 901 primaryoffset = i ;
692088ae 902
556fa06b 903
814ad4bf 904 curSDigit->ShiftPrimary(primaryoffset) ;
692088ae 905
556fa06b 906
814ad4bf 907
692088ae 908
556fa06b 909
814ad4bf 910 a = curSDigit->GetAmp() ;
692088ae 911
556fa06b 912
814ad4bf 913 b = a /fTimeSignalLength ;
692088ae 914
556fa06b 915
814ad4bf 916 new((*ticks)[contrib++]) AliEMCALTick(curSDigit->GetTime(),0, b);
692088ae 917
556fa06b 918
814ad4bf 919 new((*ticks)[contrib++]) AliEMCALTick(curSDigit->GetTime()+fTimeSignalLength, -a, -b);
920
692088ae 921
922
556fa06b 923
924
814ad4bf 925 *digit = *digit + *curSDigit ; //add energies
926
692088ae 927
928
556fa06b 929
930
814ad4bf 931 index[i]++ ;
692088ae 932
556fa06b 933
814ad4bf 934 if(((TClonesArray *)sdigArray->At(i))->GetEntriesFast() > index[i] )
692088ae 935
556fa06b 936
814ad4bf 937 curSDigit = (AliEMCALDigit*)((TClonesArray *)sdigArray->At(i))->At(index[i]) ;
692088ae 938
556fa06b 939
814ad4bf 940 else
692088ae 941
556fa06b 942
814ad4bf 943 curSDigit = 0 ;
692088ae 944
556fa06b 945
814ad4bf 946 }
692088ae 947
556fa06b 948
814ad4bf 949 }
ffa6d63b 950
692088ae 951
952
556fa06b 953
954
814ad4bf 955//calculate and set time
692088ae 956
556fa06b 957
814ad4bf 958 Float_t time = FrontEdgeTime(ticks) ;
692088ae 959
556fa06b 960
814ad4bf 961 digit->SetTime(time) ;
962
692088ae 963
964
556fa06b 965
966
814ad4bf 967 //Find next signal module
692088ae 968
556fa06b 969
814ad4bf 970 nextSig = 200000 ;
692088ae 971
556fa06b 972
814ad4bf 973 for(i=0; i<input; i++){
692088ae 974
556fa06b 975
814ad4bf 976 sdigits = ((TClonesArray *)sdigArray->At(i)) ;
692088ae 977
556fa06b 978
814ad4bf 979 Int_t curNext = nextSig ;
692088ae 980
556fa06b 981
814ad4bf 982 if(sdigits->GetEntriesFast() > index[i] ){
692088ae 983
556fa06b 984
814ad4bf 985 curNext = ((AliEMCALDigit *) sdigits->At(index[i]))->GetId() ;
692088ae 986
556fa06b 987
814ad4bf 988
692088ae 989
556fa06b 990
814ad4bf 991 }
692088ae 992
556fa06b 993
814ad4bf 994 if(curNext < nextSig) nextSig = curNext ;
692088ae 995
556fa06b 996
814ad4bf 997 }
692088ae 998
556fa06b 999
814ad4bf 1000 }
692088ae 1001
556fa06b 1002
814ad4bf 1003 }
692088ae 1004
556fa06b 1005
814ad4bf 1006
692088ae 1007
556fa06b 1008
814ad4bf 1009 ticks->Delete() ;
692088ae 1010
556fa06b 1011
814ad4bf 1012 delete ticks ;
61e0abb5 1013
61e0abb5 1014
61e0abb5 1015
61e0abb5 1016
692088ae 1017
1018
1019
1020
1021
556fa06b 1022
1023
1024
1025
1026
814ad4bf 1027 //remove digits below thresholds
692088ae 1028
556fa06b 1029
814ad4bf 1030 for(absID = 0; absID < nEMC/2 ; absID++){
692088ae 1031
556fa06b 1032
d968cee0 1033 if(sDigitizer->Calibrate(((AliEMCALDigit*)digits->At(absID))->GetAmp()) < fTowerDigitThreshold)
692088ae 1034
556fa06b 1035
814ad4bf 1036 digits->RemoveAt(absID) ;
692088ae 1037
556fa06b 1038
814ad4bf 1039 else
692088ae 1040
556fa06b 1041
814ad4bf 1042 digit->SetTime(gRandom->Gaus(digit->GetTime(),fTimeResolution) ) ;
692088ae 1043
556fa06b 1044
814ad4bf 1045 }
692088ae 1046
556fa06b 1047
61e0abb5 1048
692088ae 1049
556fa06b 1050
814ad4bf 1051 for(absID = nEMC/2; absID < nEMC ; absID++){
692088ae 1052
556fa06b 1053
814ad4bf 1054 if(sDigitizer->Calibrate(((AliEMCALDigit*)digits->At(absID))->GetAmp()) < fPreShowerDigitThreshold)
692088ae 1055
556fa06b 1056
814ad4bf 1057 digits->RemoveAt(absID) ;
692088ae 1058
556fa06b 1059
814ad4bf 1060 else
692088ae 1061
556fa06b 1062
814ad4bf 1063 digit->SetTime(gRandom->Gaus(digit->GetTime(),fTimeResolution) ) ;
692088ae 1064
556fa06b 1065
61e0abb5 1066 }
692088ae 1067
556fa06b 1068
61e0abb5 1069
692088ae 1070
556fa06b 1071
814ad4bf 1072 digits->Compress() ;
692088ae 1073
556fa06b 1074
61e0abb5 1075
692088ae 1076
556fa06b 1077
814ad4bf 1078 Int_t ndigits = digits->GetEntriesFast() ;
692088ae 1079
556fa06b 1080
61e0abb5 1081
692088ae 1082
556fa06b 1083
814ad4bf 1084 digits->Expand(ndigits) ;
692088ae 1085
556fa06b 1086
61e0abb5 1087
692088ae 1088
556fa06b 1089
61e0abb5 1090
692088ae 1091
556fa06b 1092
814ad4bf 1093 //Set indexes in list of digits
692088ae 1094
556fa06b 1095
814ad4bf 1096 //Int_t i ;
692088ae 1097
556fa06b 1098
ec803232 1099 for (i = 0 ; i < ndigits ; i++) {
692088ae 1100
556fa06b 1101
814ad4bf 1102 AliEMCALDigit * digit = (AliEMCALDigit *) digits->At(i) ;
692088ae 1103
556fa06b 1104
814ad4bf 1105 digit->SetIndexInList(i) ;
692088ae 1106
556fa06b 1107
814ad4bf 1108 Float_t energy = sDigitizer->Calibrate(digit->GetAmp()) ;
692088ae 1109
556fa06b 1110
814ad4bf 1111 digit->SetAmp(DigitizeEnergy(energy,digit->GetId()) ) ;
692088ae 1112
556fa06b 1113
61e0abb5 1114 }
692088ae 1115
556fa06b 1116
814ad4bf 1117}
61e0abb5 1118
692088ae 1119
1120
556fa06b 1121
1122
814ad4bf 1123//____________________________________________________________________________
61e0abb5 1124
692088ae 1125
1126
556fa06b 1127
1128
814ad4bf 1129Int_t AliEMCALDigitizer::DigitizeEnergy(Float_t energy, Int_t absId)
692088ae 1130
556fa06b 1131
814ad4bf 1132{
692088ae 1133
556fa06b 1134
814ad4bf 1135 Int_t channel = -999;
692088ae 1136
556fa06b 1137
814ad4bf 1138 Int_t nphi = AliEMCALGetter::GetInstance()->EMCALGeometry()->GetNPhi() ;
692088ae 1139
556fa06b 1140
814ad4bf 1141 Int_t nz = AliEMCALGetter::GetInstance()->EMCALGeometry()->GetNZ() ;
692088ae 1142
556fa06b 1143
814ad4bf 1144
692088ae 1145
556fa06b 1146
ec803232 1147 if(absId <= nphi*nz){ //digitize as tower
692088ae 1148
556fa06b 1149
ec803232 1150 channel = static_cast<Int_t> (TMath::Ceil( (energy + fADCpedestalTower)/fADCchannelTower )) ;
692088ae 1151
556fa06b 1152
ec803232 1153 if(channel > fNADCTower )
692088ae 1154
556fa06b 1155
ec803232 1156 channel = fNADCTower ;
692088ae 1157
556fa06b 1158
ec803232 1159 } else {
692088ae 1160
556fa06b 1161
ec803232 1162 channel = static_cast<Int_t>(TMath::Ceil( (energy + fADCpedestalPreSho)/fADCchannelPreSho )) ;
692088ae 1163
556fa06b 1164
ec803232 1165 if(channel > fNADCPreSho )
692088ae 1166
556fa06b 1167
ec803232 1168 channel = fNADCPreSho ;
692088ae 1169
556fa06b 1170
ec803232 1171 }
692088ae 1172
556fa06b 1173
814ad4bf 1174
692088ae 1175
556fa06b 1176
814ad4bf 1177 return channel ;
692088ae 1178
556fa06b 1179
61e0abb5 1180}
1181
692088ae 1182
1183
556fa06b 1184
1185
61e0abb5 1186//____________________________________________________________________________
692088ae 1187
556fa06b 1188
61e0abb5 1189void AliEMCALDigitizer::Exec(Option_t *option) {
692088ae 1190
556fa06b 1191
61e0abb5 1192 // Managing method
692088ae 1193
556fa06b 1194
814ad4bf 1195if(strcmp(GetName(), "") == 0 )
692088ae 1196
556fa06b 1197
814ad4bf 1198 Init() ;
692088ae 1199
556fa06b 1200
814ad4bf 1201
692088ae 1202
556fa06b 1203
814ad4bf 1204 if (strstr(option,"print")) {
692088ae 1205
556fa06b 1206
814ad4bf 1207 Print("");
692088ae 1208
556fa06b 1209
814ad4bf 1210 return ;
692088ae 1211
556fa06b 1212
814ad4bf 1213 }
692088ae 1214
556fa06b 1215
814ad4bf 1216
692088ae 1217
556fa06b 1218
61e0abb5 1219 if(strstr(option,"tim"))
692088ae 1220
556fa06b 1221
61e0abb5 1222 gBenchmark->Start("EMCALDigitizer");
1223
692088ae 1224
1225
556fa06b 1226
1227
814ad4bf 1228 AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ;
692088ae 1229
556fa06b 1230
814ad4bf 1231
692088ae 1232
556fa06b 1233
814ad4bf 1234 Int_t nevents ;
692088ae 1235
556fa06b 1236
814ad4bf 1237
692088ae 1238
556fa06b 1239
814ad4bf 1240 TTree * treeD ;
692088ae 1241
556fa06b 1242
814ad4bf 1243
692088ae 1244
556fa06b 1245
814ad4bf 1246 if(fManager){
692088ae 1247
556fa06b 1248
814ad4bf 1249 treeD = fManager->GetTreeD() ;
692088ae 1250
556fa06b 1251
814ad4bf 1252 nevents = 1 ; // Will process only one event
692088ae 1253
556fa06b 1254
814ad4bf 1255 }
692088ae 1256
556fa06b 1257
814ad4bf 1258 else {
692088ae 1259
556fa06b 1260
814ad4bf 1261 gAlice->GetEvent(0) ;
692088ae 1262
556fa06b 1263
814ad4bf 1264 nevents = (Int_t) gAlice->TreeE()->GetEntries() ;
692088ae 1265
556fa06b 1266
814ad4bf 1267 treeD=gAlice->TreeD() ;
692088ae 1268
556fa06b 1269
814ad4bf 1270 }
692088ae 1271
556fa06b 1272
814ad4bf 1273 if(treeD == 0 ){
692088ae 1274
556fa06b 1275
814ad4bf 1276 cerr << " AliEMCALDigitizer :: Can not find TreeD " << endl ;
692088ae 1277
556fa06b 1278
814ad4bf 1279 return ;
692088ae 1280
556fa06b 1281
814ad4bf 1282 }
1283
692088ae 1284
1285
556fa06b 1286
1287
814ad4bf 1288 //Check, if this branch already exits
692088ae 1289
556fa06b 1290
814ad4bf 1291 TObjArray * lob = (TObjArray*)treeD->GetListOfBranches() ;
692088ae 1292
556fa06b 1293
814ad4bf 1294 TIter next(lob) ;
692088ae 1295
556fa06b 1296
814ad4bf 1297 TBranch * branch = 0 ;
692088ae 1298
556fa06b 1299
814ad4bf 1300 Bool_t emcalfound = kFALSE, digitizerfound = kFALSE ;
692088ae 1301
556fa06b 1302
61e0abb5 1303
692088ae 1304
556fa06b 1305
814ad4bf 1306 while ( (branch = (TBranch*)next()) && (!emcalfound || !digitizerfound) ) {
692088ae 1307
556fa06b 1308
814ad4bf 1309 if ( (strcmp(branch->GetName(), "EMCAL")==0) &&
692088ae 1310
556fa06b 1311
814ad4bf 1312 (strcmp(branch->GetTitle(), GetName())==0) )
692088ae 1313
556fa06b 1314
814ad4bf 1315 emcalfound = kTRUE ;
692088ae 1316
556fa06b 1317
814ad4bf 1318
692088ae 1319
556fa06b 1320
814ad4bf 1321 else if ( (strcmp(branch->GetName(), "AliEMCALDigitizer")==0) &&
692088ae 1322
556fa06b 1323
814ad4bf 1324 (strcmp(branch->GetTitle(), GetName())==0) )
692088ae 1325
556fa06b 1326
814ad4bf 1327 digitizerfound = kTRUE ;
692088ae 1328
556fa06b 1329
814ad4bf 1330 }
1331
692088ae 1332
1333
556fa06b 1334
1335
814ad4bf 1336 if ( emcalfound ) {
692088ae 1337
556fa06b 1338
814ad4bf 1339 cerr << "WARNING: AliEMCALDigitizer -> Digits branch with name " << GetName()
692088ae 1340
556fa06b 1341
814ad4bf 1342 << " already exits" << endl ;
692088ae 1343
556fa06b 1344
814ad4bf 1345 return ;
692088ae 1346
556fa06b 1347
814ad4bf 1348 }
692088ae 1349
556fa06b 1350
814ad4bf 1351 if ( digitizerfound ) {
692088ae 1352
556fa06b 1353
814ad4bf 1354 cerr << "WARNING: AliEMCALDigitizer -> Digitizer branch with name " << GetName()
692088ae 1355
556fa06b 1356
814ad4bf 1357 << " already exits" << endl ;
692088ae 1358
556fa06b 1359
814ad4bf 1360 return ;
692088ae 1361
556fa06b 1362
814ad4bf 1363 }
1364
692088ae 1365
1366
556fa06b 1367
1368
814ad4bf 1369 Int_t ievent ;
1370
692088ae 1371
1372
556fa06b 1373
1374
814ad4bf 1375 for(ievent = 0; ievent < nevents; ievent++){
692088ae 1376
556fa06b 1377
814ad4bf 1378
692088ae 1379
556fa06b 1380
814ad4bf 1381 if(fManager){
692088ae 1382
556fa06b 1383
814ad4bf 1384 Int_t input ;
692088ae 1385
556fa06b 1386
814ad4bf 1387 for(input = 0 ; input < fManager->GetNinputs(); input ++){
692088ae 1388
556fa06b 1389
814ad4bf 1390 TTree * treeS = fManager->GetInputTreeS(input) ;
692088ae 1391
556fa06b 1392
814ad4bf 1393 if(!treeS){
692088ae 1394
556fa06b 1395
814ad4bf 1396 cerr << "AliEMCALDigitizer -> No Input " << endl ;
692088ae 1397
556fa06b 1398
814ad4bf 1399 return ;
692088ae 1400
556fa06b 1401
814ad4bf 1402 }
692088ae 1403
556fa06b 1404
814ad4bf 1405 gime->ReadTreeS(treeS,input) ;
692088ae 1406
556fa06b 1407
814ad4bf 1408 }
692088ae 1409
556fa06b 1410
814ad4bf 1411 }
692088ae 1412
556fa06b 1413
814ad4bf 1414 else
692088ae 1415
556fa06b 1416
814ad4bf 1417 gime->Event(ievent,"S") ;
692088ae 1418
556fa06b 1419
61e0abb5 1420
692088ae 1421
556fa06b 1422
814ad4bf 1423 Digitize(ievent) ; //Add prepared SDigits to digits and add the noise
692088ae 1424
556fa06b 1425
61e0abb5 1426
692088ae 1427
556fa06b 1428
814ad4bf 1429 WriteDigits(ievent) ;
692088ae 1430
556fa06b 1431
61e0abb5 1432
692088ae 1433
556fa06b 1434
61e0abb5 1435 if(strstr(option,"deb"))
692088ae 1436
556fa06b 1437
61e0abb5 1438 PrintDigits(option);
692088ae 1439
556fa06b 1440
814ad4bf 1441
692088ae 1442
556fa06b 1443
814ad4bf 1444 //increment the total number of Digits per run
692088ae 1445
556fa06b 1446
814ad4bf 1447 fDigitsInRun += gime->Digits()->GetEntriesFast() ;
692088ae 1448
556fa06b 1449
61e0abb5 1450 }
692088ae 1451
556fa06b 1452
814ad4bf 1453
692088ae 1454
556fa06b 1455
61e0abb5 1456 if(strstr(option,"tim")){
692088ae 1457
556fa06b 1458
61e0abb5 1459 gBenchmark->Stop("EMCALDigitizer");
692088ae 1460
556fa06b 1461
61e0abb5 1462 cout << "AliEMCALDigitizer:" << endl ;
692088ae 1463
556fa06b 1464
814ad4bf 1465 cout << " took " << gBenchmark->GetCpuTime("EMCALDigitizer") << " seconds for Digitizing "
692088ae 1466
556fa06b 1467
814ad4bf 1468 << gBenchmark->GetCpuTime("EMCALDigitizer")/nevents << " seconds per event " << endl ;
692088ae 1469
556fa06b 1470
61e0abb5 1471 cout << endl ;
692088ae 1472
556fa06b 1473
61e0abb5 1474 }
692088ae 1475
556fa06b 1476
61e0abb5 1477
692088ae 1478
556fa06b 1479
61e0abb5 1480}
1481
61e0abb5 1482
61e0abb5 1483
692088ae 1484
1485
1486
1487
556fa06b 1488
1489
1490
1491
61e0abb5 1492//__________________________________________________________________
692088ae 1493
556fa06b 1494
814ad4bf 1495void AliEMCALDigitizer::MixWith(char* headerFile){
692088ae 1496
556fa06b 1497
61e0abb5 1498 // Alows produce digits by superimposing background and signal event.
692088ae 1499
556fa06b 1500
61e0abb5 1501 // It is assumed, that headers file with SIGNAL events is opened in
692088ae 1502
556fa06b 1503
61e0abb5 1504 // constructor, and now we set the BACKGROUND event, with which we
692088ae 1505
556fa06b 1506
61e0abb5 1507 // will mix. Thus we avoid writing (changing) huge and expencive
692088ae 1508
556fa06b 1509
61e0abb5 1510 // backgound files: all output will be writen into SIGNAL, i.e.
692088ae 1511
556fa06b 1512
61e0abb5 1513 // opened in constructor file.
692088ae 1514
556fa06b 1515
61e0abb5 1516 //
692088ae 1517
556fa06b 1518
61e0abb5 1519 // One can open as many files to mix with as one wants.
1520
692088ae 1521
1522
556fa06b 1523
1524
814ad4bf 1525if( strcmp(GetName(), "") == 0 )
692088ae 1526
556fa06b 1527
61e0abb5 1528 Init() ;
692088ae 1529
556fa06b 1530
814ad4bf 1531
692088ae 1532
556fa06b 1533
814ad4bf 1534 if(fManager){
692088ae 1535
556fa06b 1536
814ad4bf 1537 cout << "Can not use this method under AliRunDigitizer " << endl ;
692088ae 1538
556fa06b 1539
61e0abb5 1540 return ;
692088ae 1541
556fa06b 1542
814ad4bf 1543 } // check if the specified SDigits do not already exist on the White Board:
692088ae 1544
556fa06b 1545
814ad4bf 1546 // //Folders/RunMC/Event/Data/EMCAL/SDigits/headerFile/sdigitsname
1547
692088ae 1548
1549
556fa06b 1550
1551
814ad4bf 1552 TString path = "Folders/RunMC/Event/Data/EMCAL/SDigits" ;
692088ae 1553
556fa06b 1554
814ad4bf 1555 path += headerFile ;
692088ae 1556
556fa06b 1557
814ad4bf 1558 path += "/" ;
692088ae 1559
556fa06b 1560
814ad4bf 1561 path += GetName() ;
692088ae 1562
556fa06b 1563
814ad4bf 1564 if ( gROOT->FindObjectAny(path.Data()) ) {
692088ae 1565
556fa06b 1566
814ad4bf 1567 cerr << "WARNING: AliEMCALDigitizer::MixWith -> Entry already exists, do not add" << endl ;
692088ae 1568
556fa06b 1569
814ad4bf 1570 return;
692088ae 1571
556fa06b 1572
61e0abb5 1573 }
814ad4bf 1574
692088ae 1575
1576
556fa06b 1577
1578
814ad4bf 1579 AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ;
692088ae 1580
556fa06b 1581
814ad4bf 1582 gime->PostSDigits(GetName(),headerFile) ;
692088ae 1583
556fa06b 1584
61e0abb5 1585
692088ae 1586
556fa06b 1587
814ad4bf 1588 // check if the requested file is already open or exist and if SDigits Branch exist
692088ae 1589
556fa06b 1590
814ad4bf 1591 TFile * file = (TFile*)gROOT->FindObject(headerFile);
692088ae 1592
556fa06b 1593
814ad4bf 1594 if ( !file ) {
692088ae 1595
556fa06b 1596
814ad4bf 1597 file = new TFile(headerFile, "READ") ;
692088ae 1598
556fa06b 1599
814ad4bf 1600 if (!file) {
692088ae 1601
556fa06b 1602
814ad4bf 1603 cerr << "ERROR: AliEMCALDigitizer::MixWith -> File " << headerFile << " does not exist!" << endl ;
692088ae 1604
556fa06b 1605
814ad4bf 1606 return ;
692088ae 1607
556fa06b 1608
814ad4bf 1609 }
692088ae 1610
556fa06b 1611
814ad4bf 1612 }
692088ae 1613
556fa06b 1614
61e0abb5 1615
692088ae 1616
556fa06b 1617
61e0abb5 1618}
692088ae 1619
556fa06b 1620
814ad4bf 1621
692088ae 1622
556fa06b 1623
61e0abb5 1624//__________________________________________________________________
692088ae 1625
556fa06b 1626
61e0abb5 1627void AliEMCALDigitizer::Print(Option_t* option)const {
692088ae 1628
556fa06b 1629
814ad4bf 1630 if( strcmp(GetName(), "") != 0) {
692088ae 1631
556fa06b 1632
61e0abb5 1633
692088ae 1634
556fa06b 1635
61e0abb5 1636 cout << "------------------- "<< GetName() << " -------------" << endl ;
692088ae 1637
556fa06b 1638
61e0abb5 1639 cout << "Digitizing sDigits from file(s): " <<endl ;
692088ae 1640
556fa06b 1641
61e0abb5 1642
692088ae 1643
556fa06b 1644
814ad4bf 1645 TCollection * folderslist = ((TFolder*)gROOT->FindObjectAny("Folders/RunMC/Event/Data/EMCAL/SDigits"))->GetListOfFolders() ;
692088ae 1646
556fa06b 1647
814ad4bf 1648 TIter next(folderslist) ;
692088ae 1649
556fa06b 1650
814ad4bf 1651 TFolder * folder = 0 ;
692088ae 1652
556fa06b 1653
814ad4bf 1654 while ( (folder = (TFolder*)next()) )
692088ae 1655
556fa06b 1656
814ad4bf 1657 if ( folder->FindObject(GetName()) )
692088ae 1658
556fa06b 1659
814ad4bf 1660 {
692088ae 1661
556fa06b 1662
814ad4bf 1663 cout << "Adding SDigits " << GetName() << " from " << folder->GetName() << endl ;
692088ae 1664
556fa06b 1665
814ad4bf 1666 cout << endl ;
692088ae 1667
556fa06b 1668
814ad4bf 1669 cout << "Writing digits to " << GetTitle() << endl ;
692088ae 1670
556fa06b 1671
814ad4bf 1672
692088ae 1673
556fa06b 1674
814ad4bf 1675 cout << endl ;
692088ae 1676
556fa06b 1677
814ad4bf 1678 cout << "With following parameters: " << endl ;
692088ae 1679
556fa06b 1680
814ad4bf 1681 cout << " Electronics noise in EMC (fPinNoise) = " << fPinNoise << endl ;
692088ae 1682
556fa06b 1683
d968cee0 1684 cout << " Threshold in EMC (fTowerDigitThreshold) = " << fTowerDigitThreshold << endl;
692088ae 1685
556fa06b 1686
814ad4bf 1687 cout << " Threshold in PreShower (fPreShowerDigitThreshold) = " << fPreShowerDigitThreshold << endl ; ;
692088ae 1688
556fa06b 1689
814ad4bf 1690 cout << "---------------------------------------------------" << endl ;
692088ae 1691
556fa06b 1692
814ad4bf 1693 }
692088ae 1694
556fa06b 1695
814ad4bf 1696 else
692088ae 1697
556fa06b 1698
814ad4bf 1699 cout << "AliEMCALDigitizer not initialized " << endl ;
692088ae 1700
556fa06b 1701
814ad4bf 1702 }
692088ae 1703
556fa06b 1704
61e0abb5 1705}
814ad4bf 1706
692088ae 1707
1708
556fa06b 1709
1710
61e0abb5 1711//__________________________________________________________________
692088ae 1712
556fa06b 1713
61e0abb5 1714void AliEMCALDigitizer::PrintDigits(Option_t * option){
692088ae 1715
556fa06b 1716
61e0abb5 1717
692088ae 1718
556fa06b 1719
814ad4bf 1720 AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ;
692088ae 1721
556fa06b 1722
814ad4bf 1723 TClonesArray * fDigits = gime->Digits() ;
1724
692088ae 1725
1726
556fa06b 1727
1728
61e0abb5 1729 cout << "AliEMCALDigitiser:"<< endl ;
692088ae 1730
556fa06b 1731
61e0abb5 1732 cout << " Number of entries in Digits list " << fDigits->GetEntriesFast() << endl ;
692088ae 1733
556fa06b 1734
61e0abb5 1735 cout << endl ;
692088ae 1736
556fa06b 1737
61e0abb5 1738 if(strstr(option,"all")){
692088ae 1739
556fa06b 1740
61e0abb5 1741
692088ae 1742
556fa06b 1743
61e0abb5 1744 //loop over digits
692088ae 1745
556fa06b 1746
61e0abb5 1747 AliEMCALDigit * digit;
692088ae 1748
556fa06b 1749
61e0abb5 1750 cout << "Digit Id " << " Amplitude " << " Index " << " Nprim " << " Primaries list " << endl;
692088ae 1751
556fa06b 1752
61e0abb5 1753 Int_t index ;
692088ae 1754
556fa06b 1755
61e0abb5 1756 for (index = 0 ; index < fDigits->GetEntries() ; index++) {
692088ae 1757
556fa06b 1758
61e0abb5 1759 digit = (AliEMCALDigit * ) fDigits->At(index) ;
692088ae 1760
556fa06b 1761
61e0abb5 1762 cout << setw(8) << digit->GetId() << " " << setw(3) << digit->GetAmp() << " "
692088ae 1763
556fa06b 1764
61e0abb5 1765 << setw(6) << digit->GetIndexInList() << " "
692088ae 1766
556fa06b 1767
61e0abb5 1768 << setw(5) << digit->GetNprimary() <<" ";
692088ae 1769
556fa06b 1770
61e0abb5 1771
692088ae 1772
556fa06b 1773
61e0abb5 1774 Int_t iprimary;
692088ae 1775
556fa06b 1776
61e0abb5 1777 for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++)
692088ae 1778
556fa06b 1779
61e0abb5 1780 cout << setw(5) << digit->GetPrimary(iprimary+1) << " ";
692088ae 1781
556fa06b 1782
61e0abb5 1783 cout << endl;
692088ae 1784
556fa06b 1785
61e0abb5 1786 }
692088ae 1787
556fa06b 1788
61e0abb5 1789
692088ae 1790
556fa06b 1791
61e0abb5 1792 }
692088ae 1793
556fa06b 1794
61e0abb5 1795}
692088ae 1796
556fa06b 1797
814ad4bf 1798//_________________________________________________________________________________________
692088ae 1799
556fa06b 1800
814ad4bf 1801void AliEMCALDigitizer::WriteDigits(Int_t event)
692088ae 1802
556fa06b 1803
814ad4bf 1804{
61e0abb5 1805
692088ae 1806
1807
556fa06b 1808
1809
814ad4bf 1810 // Makes TreeD in the output file.
692088ae 1811
556fa06b 1812
814ad4bf 1813 // Check if branch already exists:
692088ae 1814
556fa06b 1815
814ad4bf 1816 // if yes, exit without writing: ROOT TTree does not support overwriting/updating of
692088ae 1817
556fa06b 1818
814ad4bf 1819 // already existing branches.
692088ae 1820
556fa06b 1821
814ad4bf 1822 // else creates branch with Digits, named "EMCAL", title "...",
692088ae 1823
556fa06b 1824
814ad4bf 1825 // and branch "AliEMCALDigitizer", with the same title to keep all the parameters
692088ae 1826
556fa06b 1827
814ad4bf 1828 // and names of files, from which digits are made.
61e0abb5 1829
692088ae 1830
1831
556fa06b 1832
1833
814ad4bf 1834 AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ;
692088ae 1835
556fa06b 1836
814ad4bf 1837 const TClonesArray * digits = gime->Digits(GetName()) ;
692088ae 1838
556fa06b 1839
814ad4bf 1840 TTree * treeD ;
1841
692088ae 1842
1843
556fa06b 1844
1845
814ad4bf 1846 if(fManager)
692088ae 1847
556fa06b 1848
814ad4bf 1849 treeD = fManager->GetTreeD() ;
692088ae 1850
556fa06b 1851
814ad4bf 1852 else
692088ae 1853
556fa06b 1854
814ad4bf 1855 treeD = gAlice->TreeD();
692088ae 1856
556fa06b 1857
61e0abb5 1858
692088ae 1859
556fa06b 1860
814ad4bf 1861 // create new branches
692088ae 1862
556fa06b 1863
814ad4bf 1864 // -- generate file name if necessary
692088ae 1865
556fa06b 1866
814ad4bf 1867 char * file =0;
692088ae 1868
556fa06b 1869
814ad4bf 1870 if(gSystem->Getenv("CONFIG_SPLIT_FILE")){ //generating file name
692088ae 1871
556fa06b 1872
814ad4bf 1873 file = new char[strlen(gAlice->GetBaseFile())+20] ;
692088ae 1874
556fa06b 1875
814ad4bf 1876 sprintf(file,"%s/EMCAL.Digits.root",gAlice->GetBaseFile()) ;
692088ae 1877
556fa06b 1878
814ad4bf 1879 }
1880
692088ae 1881
1882
556fa06b 1883
1884
814ad4bf 1885 TDirectory *cwd = gDirectory;
692088ae 1886
556fa06b 1887
814ad4bf 1888 // -- create Digits branch
692088ae 1889
556fa06b 1890
814ad4bf 1891 Int_t bufferSize = 32000 ;
692088ae 1892
556fa06b 1893
814ad4bf 1894 TBranch * digitsBranch = treeD->Branch("EMCAL",&digits,bufferSize);
692088ae 1895
556fa06b 1896
814ad4bf 1897 digitsBranch->SetTitle(GetName());
692088ae 1898
556fa06b 1899
814ad4bf 1900 if (file) {
692088ae 1901
556fa06b 1902
814ad4bf 1903 digitsBranch->SetFile(file);
692088ae 1904
556fa06b 1905
814ad4bf 1906 TIter next( digitsBranch->GetListOfBranches());
692088ae 1907
556fa06b 1908
814ad4bf 1909 TBranch * sbr ;
692088ae 1910
556fa06b 1911
814ad4bf 1912 while ((sbr=(TBranch*)next())) {
692088ae 1913
556fa06b 1914
814ad4bf 1915 sbr->SetFile(file);
692088ae 1916
556fa06b 1917
814ad4bf 1918 }
692088ae 1919
556fa06b 1920
814ad4bf 1921 cwd->cd();
692088ae 1922
556fa06b 1923
814ad4bf 1924 }
692088ae 1925
556fa06b 1926
814ad4bf 1927
692088ae 1928
556fa06b 1929
814ad4bf 1930 // -- Create Digitizer branch
692088ae 1931
556fa06b 1932
814ad4bf 1933 Int_t splitlevel = 0 ;
692088ae 1934
556fa06b 1935
814ad4bf 1936 AliEMCALDigitizer * d = gime->Digitizer(GetName()) ;
692088ae 1937
556fa06b 1938
814ad4bf 1939 TBranch * digitizerBranch = treeD->Branch("AliEMCALDigitizer", "AliEMCALDigitizer", &d,bufferSize,splitlevel);
692088ae 1940
556fa06b 1941
814ad4bf 1942 digitizerBranch->SetTitle(GetName());
692088ae 1943
556fa06b 1944
814ad4bf 1945 if (file) {
692088ae 1946
556fa06b 1947
814ad4bf 1948 digitizerBranch->SetFile(file);
692088ae 1949
556fa06b 1950
814ad4bf 1951 TIter next( digitizerBranch->GetListOfBranches());
692088ae 1952
556fa06b 1953
814ad4bf 1954 TBranch * sbr;
692088ae 1955
556fa06b 1956
814ad4bf 1957 while ((sbr=(TBranch*)next())) {
692088ae 1958
556fa06b 1959
814ad4bf 1960 sbr->SetFile(file);
692088ae 1961
556fa06b 1962
814ad4bf 1963 }
692088ae 1964
556fa06b 1965
814ad4bf 1966 cwd->cd();
692088ae 1967
556fa06b 1968
814ad4bf 1969 }
692088ae 1970
556fa06b 1971
814ad4bf 1972
692088ae 1973
556fa06b 1974
814ad4bf 1975 digitsBranch->Fill() ;
692088ae 1976
556fa06b 1977
814ad4bf 1978 digitizerBranch->Fill() ;
1979
692088ae 1980
1981
556fa06b 1982
1983
814ad4bf 1984 treeD->Write(0,kOverwrite) ;
692088ae 1985
556fa06b 1986
814ad4bf 1987
692088ae 1988
556fa06b 1989
814ad4bf 1990}
692088ae 1991
556fa06b 1992
814ad4bf 1993//____________________________________________________________________________
692088ae 1994
556fa06b 1995
814ad4bf 1996Float_t AliEMCALDigitizer::FrontEdgeTime(TClonesArray * ticks)
692088ae 1997
556fa06b 1998
814ad4bf 1999{ //
692088ae 2000
556fa06b 2001
814ad4bf 2002 ticks->Sort() ; //Sort in accordance with times of ticks
692088ae 2003
556fa06b 2004
814ad4bf 2005 TIter it(ticks) ;
692088ae 2006
556fa06b 2007
814ad4bf 2008 AliEMCALTick * ctick = (AliEMCALTick *) it.Next() ;
692088ae 2009
556fa06b 2010
814ad4bf 2011 Float_t time = ctick->CrossingTime(fTimeThreshold) ;
692088ae 2012
556fa06b 2013
814ad4bf 2014
692088ae 2015
556fa06b 2016
814ad4bf 2017 AliEMCALTick * t ;
692088ae 2018
556fa06b 2019
814ad4bf 2020 while((t=(AliEMCALTick*) it.Next())){
692088ae 2021
556fa06b 2022
814ad4bf 2023 if(t->GetTime() < time) //This tick starts before crossing
692088ae 2024
556fa06b 2025
814ad4bf 2026 *ctick+=*t ;
692088ae 2027
556fa06b 2028
814ad4bf 2029 else
692088ae 2030
556fa06b 2031
814ad4bf 2032 return time ;
692088ae 2033
556fa06b 2034
814ad4bf 2035
692088ae 2036
556fa06b 2037
814ad4bf 2038 time = ctick->CrossingTime(fTimeThreshold) ;
692088ae 2039
556fa06b 2040
814ad4bf 2041 }
692088ae 2042
556fa06b 2043
814ad4bf 2044 return time ;
692088ae 2045
556fa06b 2046
814ad4bf 2047}
692088ae 2048
556fa06b 2049
814ad4bf 2050//____________________________________________________________________________
692088ae 2051
556fa06b 2052
814ad4bf 2053Float_t AliEMCALDigitizer::TimeOfNoise(void)
692088ae 2054
556fa06b 2055
814ad4bf 2056{ // Calculates the time signal generated by noise
692088ae 2057
556fa06b 2058
814ad4bf 2059 //to be rewritten, now returns just big number
692088ae 2060
556fa06b 2061
814ad4bf 2062 return 1. ;
2063
692088ae 2064
2065
556fa06b 2066
2067
814ad4bf 2068}
692088ae 2069
556fa06b 2070
814ad4bf 2071//____________________________________________________________________________
692088ae 2072
556fa06b 2073
814ad4bf 2074void AliEMCALDigitizer::SetSDigitsBranch(const char* title)
692088ae 2075
556fa06b 2076
814ad4bf 2077{
692088ae 2078
556fa06b 2079
814ad4bf 2080 // we set title (comment) of the SDigits branch in the first! header file
692088ae 2081
556fa06b 2082
814ad4bf 2083 if( strcmp(GetName(), "") == 0 )
692088ae 2084
556fa06b 2085
814ad4bf 2086 Init() ;
61e0abb5 2087
692088ae 2088
2089
556fa06b 2090
2091
814ad4bf 2092 AliEMCALGetter::GetInstance()->SDigits()->SetName(title) ;
692088ae 2093
556fa06b 2094
61e0abb5 2095}
692088ae 2096
556fa06b 2097