- Timestamp:
- 10/17/03 20:56:53 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Simulation/Detector/include-MFadc/MFadc.cxx
r2339 r2393 138 138 // 139 139 if ( iPix > numpix ) { 140 cout << " WARNING: MFadc::Fill() : iPix greater than CAMERA_PIXELS" 140 cout << " WARNING: MFadc::Fill() : iPix greater than Pixels in Camera = " 141 << numpix 141 142 << endl ; 142 143 exit(987) ; … … 371 372 for(j=0;j<(Int_t)SLICES_MFADC;j++) 372 373 sig[i][j]+=pedestal[i]; 374 373 375 } 374 376 … … 437 439 <<endl; 438 440 439 for (i=0;i< UInt_t(SLICES_MFADC*1001);i++){441 for (i=0;i<(UInt_t (SLICES_MFADC))*1001;i++){ 440 442 noise[i]=GenElec->Gaus(0., value ); 441 443 } … … 459 461 // 460 462 461 startslice=GenElec->Integer(( Int_t) SLICES_MFADC*1000);463 startslice=GenElec->Integer(((Int_t)SLICES_MFADC)*1000); 462 464 463 465 if ( used[i] == FALSE ) { … … 466 468 memcpy( (Float_t*)&sig[i][0], 467 469 (Float_t*)&noise[startslice], 468 ( Int_t) SLICES_MFADC*sizeof(Float_t));470 ((Int_t) SLICES_MFADC)*sizeof(Float_t)); 469 471 472 for ( Int_t is=0 ; is< (Int_t)SLICES_MFADC ; is++ ) { 473 474 } 470 475 } 471 476 // … … 481 486 } 482 487 488 void MFadc::SetDigitalNoise(Float_t value){ 489 490 UInt_t i; 491 Float_t xrdm; 492 493 cout<<"MFadc::SetDigitalNoise ... generating database for electronic noise." 494 <<endl; 495 496 for (i=0;i<UInt_t(SLICES_MFADC*1001);i++){ 497 xrdm=GenElec->Gaus(0., value); 498 digital_noise[i]=(xrdm>0?Int_t(xrdm+0.5):Int_t(xrdm-0.5)); 499 } 500 501 cout<<"MFadc::SetDigitalNoise ... done"<<endl; 502 503 } 504 505 void MFadc::DigitalNoise() { 506 // ============================================================ 507 // 508 // adds the noise due to optronic and electronic 509 // to the signal 510 // 511 UInt_t startslice; 512 513 for ( Int_t i = 0 ; i < numpix; i++) { 514 515 if ( used[i] == TRUE ) { 516 startslice=GenElec->Integer((Int_t) SLICES_MFADC*999); 517 // 518 // Then the noise is introduced for each time slice 519 // 520 for ( Int_t is=0 ; is< FADC_SLICES; is++ ) { 521 522 if(digital_noise[startslice+is]+Int_t(output[i][is])<0) 523 output[i][is] = 0; 524 else 525 output[i][is] = 526 (digital_noise[startslice+is]+Int_t(output[i][is])>255 ? 527 255 : 528 UChar_t(digital_noise[startslice+is]+Int_t(output[i][is]))); 529 if(digital_noise[startslice+FADC_SLICES+is]+Int_t(output_lowgain[i][is])<0) 530 output_lowgain[i][is] = 0; 531 else 532 output_lowgain[i][is] = 533 (digital_noise[startslice+FADC_SLICES+is] 534 +Int_t(output_lowgain[i][is])>255? 535 255: 536 UChar_t(digital_noise[startslice+FADC_SLICES+is] 537 +Int_t(output_lowgain[i][is]))); 538 } 539 } 540 } 541 } 483 542 484 543 … … 570 629 } 571 630 631 Float_t MFadc::GetPedestalNoise( Int_t pix, Int_t ishigh) { 632 // ============================================================ 633 // 634 // computes the pedestal sigma for channel pix 635 636 Float_t rms=0; 637 UChar_t value=0; 638 639 Float_t factor; 640 UInt_t startslice; 641 642 factor=(ishigh?1.0:high2low_gain); 643 644 startslice=GenElec->Integer((Int_t) SLICES_MFADC*999); 645 646 for ( Int_t is=0; is < (Int_t)SLICES_MFADC ; is++ ) { 647 if (pedestal[pix]+(sig[pix][is]-pedestal[pix])/factor>0.0){ 648 value=(pedestal[pix]+(sig[pix][is]-pedestal[pix])/factor > 255. 649 ? 255 650 :UChar_t(pedestal[pix]+(sig[pix][is]-pedestal[pix])/factor+0.5)); 651 if(Int_t(value)+digital_noise[startslice+is]<0.0) 652 value=0; 653 else 654 value=(Int_t(value)+digital_noise[startslice+is]>255 655 ?255 656 :UChar_t(Int_t(value)+digital_noise[startslice+is])); 657 } 658 else { 659 value= 0; 660 if(Int_t(value)+digital_noise[startslice+is]<0.0) 661 value=0; 662 else 663 value=(Int_t(value)+digital_noise[startslice+is]>255 664 ?255 665 :UChar_t(Int_t(value)+digital_noise[startslice+is])); 666 } 667 rms+=((Float_t)value-pedestal[pix])*((Float_t)value-pedestal[pix]); 668 } 669 670 rms=sqrt(rms/(SLICES_MFADC-1)); 671 672 return rms; 673 } 674 572 675 void MFadc::TriggeredFadc(Float_t time) { 573 676 … … 601 704 if (is< (Int_t)SLICES_MFADC && sig[ip][is]>0.0) 602 705 { 706 603 707 output[ip][i]=(sig[ip][is] > 255. ? 255 :(UChar_t) (sig[ip][is]+0.5)); 604 708 output_lowgain[ip][i]= 605 (Int_t)(pedestal[ip]+(sig[ip][is]-pedestal[ip])/ HIGH2LOWGAIN) > 255. ? 255 :606 (UChar_t)(pedestal[ip]+(sig[ip][is]-pedestal[ip])/ HIGH2LOWGAIN);709 (Int_t)(pedestal[ip]+(sig[ip][is]-pedestal[ip])/high2low_gain+0.5) > 255. ? 255 : 710 (UChar_t)(pedestal[ip]+(sig[ip][is]-pedestal[ip])/high2low_gain+0.5); 607 711 i++; 712 608 713 } 609 else if(sig[ip][is]> 0.0)714 else if(sig[ip][is]>=0.0) 610 715 { 611 716 output[ip][i]= (UChar_t)(pedestal[ip]+0.5); … … 616 721 { 617 722 output[ip][i]= 0; 618 output_lowgain[ip][i]= 0; 723 if((pedestal[ip]+(sig[ip][is]-pedestal[ip])/high2low_gain)<0) 724 output_lowgain[ip][i]= 0; 725 else 726 output_lowgain[ip][i]=(UChar_t)(pedestal[ip]+(sig[ip][is]-pedestal[ip])/high2low_gain+0.5); 619 727 i++; 620 728 } … … 714 822 return (output_lowgain[pixel][slice]); 715 823 } 824 825 826
Note:
See TracChangeset
for help on using the changeset viewer.