Changeset 2393
- Timestamp:
- 10/17/03 20:56:53 (21 years ago)
- Location:
- trunk/MagicSoft/Simulation/Detector
- Files:
-
- 4 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 -
trunk/MagicSoft/Simulation/Detector/include-MFadc/MFadc.hxx
r2340 r2393 56 56 57 57 Float_t sig[CAMERA_PIXELS][(Int_t) SLICES_MFADC] ; // the analog signal for pixels 58 Float_t noise[(Int_t) SLICES_MFADC*1001]; 58 Float_t noise[((Int_t) SLICES_MFADC)*1001]; 59 Int_t digital_noise[((Int_t) SLICES_MFADC)*1001]; 59 60 60 61 UChar_t output[CAMERA_PIXELS][FADC_SLICES]; // the analog signal for pixels that is read after a trigger occurs (high gain). 61 62 62 63 UChar_t output_lowgain[CAMERA_PIXELS][FADC_SLICES]; // analog signal, low gain. 63 64 Float_t high2low_gain; 64 65 // 65 66 // first the data for the response function … … 90 91 Float_t fwhmout=MFADC_RESPONSE_FWHM) ; 91 92 93 void SetSeed(UInt_t seed) {GenElec->SetSeed(seed);} 94 92 95 void Reset() ; 93 96 … … 132 135 void ElecNoise(Float_t value=2.0) ; 133 136 137 void SetDigitalNoise(Float_t value=2.0); 138 139 void DigitalNoise() ; 140 134 141 void Scan() ; 135 142 … … 140 147 void GetPedestals( Float_t *offset); 141 148 149 Float_t GetPedestalNoise (Int_t pix, Int_t ishigh); 150 142 151 void TriggeredFadc(Float_t time); 143 152 … … 147 156 148 157 UChar_t GetFadcLowGainSignal(Int_t pixel, Int_t slice); 158 159 void SetHigh2LowGain(Float_t h2l) {high2low_gain=h2l;} 149 160 150 161 Float_t GetAmplitude() { … … 163 174 return fwhm_resp_outer ; 164 175 } 176 177 Bool_t IsPixelUsed(UInt_t p){ 178 return used[p]; 179 } 165 180 166 181 } ; -
trunk/MagicSoft/Simulation/Detector/include-MTrigger/MTrigger.cxx
r2373 r2393 262 262 GenElec = new TRandom() ; 263 263 264 GenElec->SetSeed(0); 265 264 266 // 265 267 // Read in the lookup table for NN trigger … … 885 887 <<endl; 886 888 887 for (i=0;i< (UInt_t)(TRIGGER_TIME_SLICES*1001);i++){889 for (i=0;i<TRIGGER_TIME_SLICES*1001;i++){ 888 890 noise[i]=GenElec->Gaus(0., rausch ); 889 891 } … … 1030 1032 fclose (unit) ; 1031 1033 1032 for (int i=0;i<CAMERA_PIXELS;i++) 1034 for (int i=0;i<CAMERA_PIXELS;i++){ 1033 1035 thres[i]=thres_aux[i]; 1034 } 1036 } 1037 } 1038 1035 1039 } 1036 1040 … … 1138 1142 for ( i=0 ; i < pixnum; i++ ) { 1139 1143 if ( used [i] == TRUE ) { 1140 1144 1141 1145 for ( ii=1 ; ii<TRIGGER_TIME_SLICES; ii++ ) { 1142 1146 // … … 1144 1148 // form low to big signals 1145 1149 // 1146 1147 1150 if ( a_sig[i][ii-1] < chan_thres[i] && 1148 1151 a_sig[i][ii] >= chan_thres[i] ) { … … 1315 1318 // 1316 1319 Int_t iReturn = 0 ; 1317 1320 1318 1321 for (Int_t iS=0; iS< TRIGGER_TIME_SLICES; iS++ ) { 1319 1322 … … 1326 1329 else SlicesZero[iS] = FALSE; 1327 1330 } 1328 1329 1331 return ( iReturn ) ; 1330 1332 } -
trunk/MagicSoft/Simulation/Detector/include-MTrigger/MTrigger.hxx
r2342 r2393 178 178 ~MTrigger() ; 179 179 180 void SetSeed(UInt_t seed) {GenElec->SetSeed(seed);} 181 180 182 void Reset() ; 181 183
Note:
See TracChangeset
for help on using the changeset viewer.