Changeset 2985
- Timestamp:
- 01/30/04 15:01:40 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Simulation/Detector/include-MFadc/MFadc.cxx
r2452 r2985 18 18 #include "MGFadcSignal.hxx" 19 19 20 MFadc::MFadc(Int_t pix, Float_t ampl, Float_t fwhm, Float_t amplout, Float_t fwhmout) {20 MFadc::MFadc(Int_t pix, Float_t integral, Float_t fwhm, Float_t integralout, Float_t fwhmout, Float_t trigger_delay) { 21 21 // 22 22 // Constructor overloaded II 23 23 // 24 24 // Input variables: 25 // 1. ampl(out) = integration of the single phe response (outer pixels) 26 // 2. fwhm(out) = width at half high of the single phe 27 // response(outer pixels) 25 // 1. integral(out) = integration of the single phe response for inner 26 // (outer) pixels. 27 // 2. fwhm(out) = width at half high of the single phe response for 28 // inner (outer) pixels. 29 // 30 // trigger_delay: shift of signals towards later times in FADC, in order 31 // to center the signals in a good range. It acts as a sort of delay of 32 // the signals (before being sent to the FADC) with respect to the trigger. 28 33 // 29 34 // The procedure is the following: … … 31 36 // this parameters of the trigger may be changed 32 37 // 3. Then the all signals are set to zero 38 33 39 numpix=pix; 34 40 35 41 fwhm_resp = fwhm; 36 ampl_resp = ampl;42 integ_resp = integral; 37 43 fwhm_resp_outer = fwhmout; 38 ampl_resp_outer = amplout;44 integ_resp_outer = integralout; 39 45 40 46 cout<< "[MFadc] Setting up the MFadc with this values "<< endl ; 41 47 cout<< "[MFadc] - Inner pixels : "<< endl ; 42 cout<< "[MFadc] Response Are : "<<ampl<<" adc counts"<< endl ;48 cout<< "[MFadc] Response Area : "<<integral<<" adc counts"<< endl ; 43 49 cout<< "[MFadc] Response FWHM : "<<fwhm<<" ns"<< endl ; 44 cout<< "[MFadc] - Outer pixels : "<< endl ;45 cout<< "[MFadc] Response Are : "<<amplout<<" adc counts"<< endl ;50 cout<< "[MFadc] - Inner pixels : "<< endl ; 51 cout<< "[MFadc] Response Area : "<<integralout<<" adc counts"<< endl ; 46 52 cout<< "[MFadc] Response FWHM : "<<fwhmout<<" ns"<< endl ; 47 53 … … 57 63 x0 = 3*sigma; 58 64 65 fadc_time_offset = trigger_delay-x0; // ns 66 67 59 68 Float_t dX, dX2 ; 60 69 … … 70 79 // 71 80 // the value 1/(2*Pi*sigma^2) was introduced to normalize 72 // the area at the input value 73 // 74 sing_resp[i] = ampl_resp / sqrt(2*3.1415926*sigma*sigma)* 81 // the area at the input value. After this, the integral 82 // of the response will be integ_resp. 83 // 84 sing_resp[i] = integ_resp / sqrt(2*3.1415926*sigma*sigma)* 75 85 expf(-0.5 * (x-x0)*(x-x0) / (sigma*sigma) ) ; 86 87 // 88 // The integral of the response above would be the sum of all 89 // sing_resp[i] values times the bin width WIDTH_RESPONSE_MFADC, 90 // and it would now equal "integ_resp". 91 // We want however that our actual measurement, the sum of FADC 92 // slices contents, is equal to integ_resp. Since in each FADC 93 // slice we will put the content of just one response bin, and 94 // there are a number SUBBINS of such response bins within 1 FADC 95 // slice, the needed factor is then: 96 // 97 sing_resp[i] *= (WIDTH_RESPONSE_MFADC*SUBBINS); 76 98 77 99 } … … 90 112 // 91 113 // the value 1/(2*Pi*sigma^2) was introduced to normalize 92 // the area at the input value 93 // 94 sing_resp_outer[i] = ampl_resp_outer / sqrt(2*3.1415926*sigma*sigma)* 114 // the area at the input value After this, the integral 115 // of the response will be integ_resp. 116 // 117 sing_resp_outer[i] = integ_resp_outer / sqrt(2*3.1415926*sigma*sigma)* 95 118 expf(-0.5 * (x-x0)*(x-x0) / (sigma*sigma) ) ; 96 119 120 // 121 // The integral of the response above would be the sum of all 122 // sing_resp[i] values times the bin width WIDTH_RESPONSE_MFADC, 123 // and it would now equal "integ_resp". 124 // We want however that our actual measurement, the sum of FADC 125 // slices contents, is equal to integ_resp. Since in each FADC 126 // slice we will put the content of just one response bin, and 127 // there are a number SUBBINS of such response bins within 1 FADC 128 // slice, the needed factor is then: 129 // 130 sing_resp_outer[i] *= (WIDTH_RESPONSE_MFADC*SUBBINS); 97 131 } 98 132 … … 119 153 // 120 154 // set all values of the signals to zero 121 // set th avalues of FADC slices that would be read after trigger to zero155 // set the values of FADC slices that would be read after trigger to zero 122 156 // 123 157 memset(used, 0, CAMERA_PIXELS*sizeof(Bool_t)); 124 158 memset(output, 0, CAMERA_PIXELS*FADC_SLICES*sizeof(UChar_t)); 125 159 memset(output_lowgain, 0, CAMERA_PIXELS*FADC_SLICES*sizeof(UChar_t)); 160 // 161 // Added 15 01 2004, AM: 162 // 163 memset(sig, 0, (Int_t)(CAMERA_PIXELS*SLICES_MFADC*sizeof(Float_t))); 126 164 } 127 165 void MFadc::Fill( Int_t iPix, Float_t time, 128 166 Float_t amplitude, Int_t isinner ) { 167 168 // AM, Jan 2004 : added delay to shift the signal peak to the desired 169 // range in the FADC window (indicated through the trigger_delay command 170 // in the camera input card. 171 172 time += fadc_time_offset; 129 173 130 174 if(isinner) … … 169 213 // 170 214 171 172 if ( time < 0. ) { 173 cout << " WARNING! Fadc::Fill " << time << " below ZERO!! Very strange!!" 174 << endl ; 175 } 176 else if ( time < TOTAL_TRIGGER_TIME ) { 215 if ( time < TOTAL_TRIGGER_TIME+trigger_delay ) { 177 216 // 178 217 // determine the slices number assuming the WIDTH_RESPONSE_MFADC 179 // 218 // ichan marks the start of the pulse, in number of bins of width 219 // WIDTH_RESPONSE_MFADC (2/3 of a ns), measured from the start of the 220 // FADC. 221 // 222 180 223 ichan = (Int_t) ( time / ((Float_t) WIDTH_RESPONSE_MFADC )); 181 224 … … 185 228 // 186 229 187 for ( i = 0 ; i<RESPONSE_SLICES; i++ ) { 230 // 231 // AM, Jan 2004: Replaced former FADC simulation (integration of signal) 232 // with a more realistic one (measuring signal height at discrete points). 233 // 234 235 // We take the pulse height in the middle of FADC slices, we start in the 236 // first such point after the time "time" (=ichan in response bins). Each 237 // FADC slice corresponds to SUBBINS response bins (SUBBINS=5 by default). 238 239 Int_t first_i = Int_t(SUBBINS/2) - ichan%(Int_t)SUBBINS; 240 first_i = first_i < 0 ? (Int_t)SUBBINS+first_i : first_i; 241 242 243 for ( i = first_i ; i < (Int_t)RESPONSE_SLICES; i += (Int_t)SUBBINS) { 188 244 ichanfadc = (Int_t) ((ichan+i)/SUBBINS) ; 245 if ( ichanfadc < 0 ) 246 continue; 247 248 // 249 // SLICES_MFADC is by default 48. sig[][] is not the true FADC, which 250 // is filled from sig[][] in MFadc::TriggeredFadc() 251 // 189 252 if ( (ichanfadc) < (Int_t)SLICES_MFADC ) { 190 253 sig[iPix][ichanfadc] += (amplitude * sing_resp[i] ) ; 191 254 } 192 255 } 256 193 257 } 194 258 else { 195 259 cout << " WARNING! Fadc::Fill " << time << " out of TriggerTimeRange " 196 << TOTAL_TRIGGER_TIME << endl ;260 << TOTAL_TRIGGER_TIME+trigger_delay << endl ; 197 261 } 198 262 … … 234 298 // 235 299 236 237 if ( time < 0. ) { 238 cout << " WARNING! Fadc::FillOuter " << time << " below ZERO!! Very strange!!" 239 << endl ; 240 } 241 else if ( time < TOTAL_TRIGGER_TIME ) { 300 301 if ( time < TOTAL_TRIGGER_TIME+trigger_delay ) { 242 302 // 243 303 // determine the slices number assuming the WIDTH_RESPONSE_MFADC … … 250 310 // 251 311 252 for ( i = 0 ; i<RESPONSE_SLICES; i++ ) { 312 // 313 // AM, Jan 2004: Replaced former FADC simulation (integration of signal) 314 // with a more realistic one (measuring signal height at discrete points). 315 // 316 317 // We take the pulse height in the middle of FADC slices, we start in the 318 // first such point after the time "time" (=ichan in response bins). Each 319 // FADC slice corresponds to SUBBINS response bins (SUBBINS=5 by default). 320 321 Int_t first_i = Int_t(SUBBINS/2) - ichan%(Int_t)SUBBINS; 322 first_i = first_i < 0 ? (Int_t)SUBBINS+first_i : first_i; 323 324 for ( i = first_i ; i < (Int_t)RESPONSE_SLICES; i += (Int_t)SUBBINS) { 253 325 ichanfadc = (Int_t) ((ichan+i)/SUBBINS) ; 326 327 if ( ichanfadc < 0 ) 328 continue; 329 254 330 if ( (ichanfadc) < (Int_t)SLICES_MFADC ) { 255 331 sig[iPix][ichanfadc] += (amplitude * sing_resp_outer[i] ) ; 256 332 } 257 333 } 334 258 335 } 259 336 else { 260 337 cout << " WARNING! Fadc::FillOuter " << time << " out of TriggerTimeRange " 261 << TOTAL_TRIGGER_TIME << endl ;338 << TOTAL_TRIGGER_TIME+trigger_delay << endl ; 262 339 } 263 340 … … 364 441 baseline=0.0; 365 442 for(i=0;i<(Int_t) SLICES_MFADC;i++){ 366 baseline =+sig[j][i];443 baseline+=sig[j][i]; 367 444 } 368 445 baseline=baseline/SLICES_MFADC; … … 383 460 384 461 for(i=0;i<numpix;i++) 385 for(j=0;j<(Int_t)SLICES_MFADC;j++){ 386 if(used[i]) 387 sig[i][j]+=pedestal[i]; 388 else 389 sig[i][j]=pedestal[i]; 390 } 462 for(j=0;j<(Int_t)SLICES_MFADC;j++) 463 sig[i][j]+=pedestal[i]; 464 // 465 // AM 15 01 2003: Formerly the above operation was performed only 466 // for pixels in which used[] was true. But to run camera with no noise 467 // and get the right baseline on the pixels with no C-photons, we have 468 // to do it for all pixels. 469 // 470 391 471 392 472 } … … 412 492 fdum=(10*GenOff->Rndm()); 413 493 for(j=0;j<(Int_t) SLICES_MFADC;j++) 414 sig[i][j] =+fdum;494 sig[i][j]+=fdum; 415 495 } 416 496 } … … 421 501 fdum=(10*GenOff->Rndm()); 422 502 for(j=0;j<(Int_t) SLICES_MFADC;j++) 423 sig[pixel][j] =+fdum;503 sig[pixel][j]+=fdum; 424 504 } 425 505 … … 434 514 if (used[i]){ 435 515 for(j=0;j<(Int_t) SLICES_MFADC;j++) 436 sig[i][j] =+offset;516 sig[i][j]+=offset; 437 517 } 438 518 } … … 442 522 if (used[pixel]){ 443 523 for(j=0;j<(Int_t) SLICES_MFADC;j++) 444 sig[pixel][j] =+offset;524 sig[pixel][j]+=offset; 445 525 } 446 526 } … … 593 673 Float_t t ; 594 674 595 (0 > time - TIME_BEFORE_TRIGGER)? t= 0: t=(time-TIME_BEFORE_TRIGGER) ; // to show also the start of the pulse before the trigger time675 (0 > time - TIME_BEFORE_TRIGGER)? t=trigger_delay: t=(time-TIME_BEFORE_TRIGGER+trigger_delay) ; // to show also the start of the pulse before the trigger time 596 676 597 677 if ( t < 0. ) { … … 666 746 ? 255 667 747 :UChar_t(pedestal[pix]+(sig[pix][is]-pedestal[pix])/factor+0.5)); 748 668 749 if(Int_t(value)+digital_noise[startslice+is]<0.0) 669 750 value=0; … … 683 764 } 684 765 sigma+=((Float_t)value-pedestal[pix])*((Float_t)value-pedestal[pix]); 685 } 686 766 767 } 687 768 688 769 sigma=sqrt(sigma/(SLICES_MFADC-1)); … … 694 775 695 776 // 696 // first of all we subtract from the time a offset (8 ns) 697 // 698 699 Float_t t ; 700 701 (0>time-TIME_BEFORE_TRIGGER)? t=0: t=(time-TIME_BEFORE_TRIGGER) ; // to show also the start of the pulse before the trigger time 702 703 if ( t < 0. ) { 704 cout << " WARNING!! FROM MFADC::SCAN(t) " << endl ; 705 exit (776) ; 706 } 707 708 // 709 // calculate the first slice to write out 777 // calculate the first slice to write out, according to trigger time: 710 778 // 711 779 … … 713 781 Int_t i; 714 782 715 iFirstSlice = (Int_t) ( t / WIDTH_FADC_TIMESLICE ) ; 783 // 784 // We had 0.5 for the correct rounding: 785 // 786 iFirstSlice = (Int_t) ( 0.5 + time / WIDTH_FADC_TIMESLICE ) ; 716 787 717 788 for ( Int_t ip=0; ip<numpix; ip++ ) { 718 789 719 if ( used[ip] == kTRUE ) { 720 i=0; 721 for ( Int_t is=iFirstSlice ; is < (iFirstSlice+FADC_SLICES) ; is++ ) { 722 if (is< (Int_t)SLICES_MFADC && sig[ip][is]>0.0) 790 if ( used[ip] == kTRUE ) { 791 i=0; 792 for ( Int_t is=iFirstSlice ; is < (iFirstSlice+FADC_SLICES) ; is++ ) 723 793 { 794 if (is< (Int_t)SLICES_MFADC && sig[ip][is]>0.0) 795 { 724 796 725 726 727 (Int_t)(pedestal[ip]+(sig[ip][is]-pedestal[ip])/high2low_gain+0.5) > 255. ? 255 :728 (UChar_t)(pedestal[ip]+(sig[ip][is]-pedestal[ip])/high2low_gain+0.5);729 797 output[ip][i]=(sig[ip][is] > 255. ? 255 :(UChar_t) (sig[ip][is]+0.5)); 798 output_lowgain[ip][i]= 799 (Int_t)(pedestal[ip]+(sig[ip][is]-pedestal[ip])/high2low_gain+0.5) > 255. ? 255 : 800 (UChar_t)(pedestal[ip]+(sig[ip][is]-pedestal[ip])/high2low_gain+0.5); 801 i++; 730 802 803 } 804 else if(sig[ip][is]>=0.0) 805 { 806 output[ip][i]= (UChar_t)(pedestal[ip]+0.5); 807 output_lowgain[ip][i]= (UChar_t)(pedestal[ip]+0.5); 808 i++; 809 } 810 else 811 { 812 output[ip][i]= 0; 813 if((pedestal[ip]+(sig[ip][is]-pedestal[ip])/high2low_gain)<0) 814 output_lowgain[ip][i]= 0; 815 else 816 output_lowgain[ip][i]=(UChar_t)(pedestal[ip]+(sig[ip][is]-pedestal[ip])/high2low_gain+0.5); 817 i++; 818 } 731 819 } 732 else if(sig[ip][is]>=0.0) 820 } 821 else 822 // Pixels with no C-photons in the case that camera is run with 823 // no noise (nor NSB neither electronic) 824 { 825 for ( Int_t i=0 ; i < FADC_SLICES ; i++ ) 733 826 { 734 output[ip][i]= (UChar_t)(pedestal[ip]+0.5); 735 output_lowgain[ip][i]= (UChar_t)(pedestal[ip]+0.5); 736 i++; 737 } 738 else 739 { 740 output[ip][i]= 0; 741 if((pedestal[ip]+(sig[ip][is]-pedestal[ip])/high2low_gain)<0) 742 output_lowgain[ip][i]= 0; 743 else 744 output_lowgain[ip][i]=(UChar_t)(pedestal[ip]+(sig[ip][is]-pedestal[ip])/high2low_gain+0.5); 745 i++; 746 } 827 output[ip][i]= (UChar_t)(pedestal[ip]+0.5); 828 output_lowgain[ip][i]= (UChar_t)(pedestal[ip]+0.5); 829 } 747 830 } 748 749 } 831 } 832 750 833 } 751 834 … … 782 865 sprintf (name, "fadc signal %d", i ) ; 783 866 784 hist = new TH1F(dumm, name, SLICES_MFADC, 0., TOTAL_TRIGGER_TIME);867 hist = new TH1F(dumm, name, SLICES_MFADC, trigger_delay, TOTAL_TRIGGER_TIME+trigger_delay); 785 868 // 786 869 // fill the histogram
Note:
See TracChangeset
for help on using the changeset viewer.