Changeset 2290 for trunk/MagicSoft/Simulation/Detector
- Timestamp:
- 07/17/03 19:07:24 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Simulation/Detector/include-MFadc/MFadc.cxx
r1200 r2290 18 18 #include "MGFadcSignal.hxx" 19 19 20 MFadc::MFadc(Float_t ampl, Float_t fwhm ) {20 MFadc::MFadc(Float_t ampl, Float_t fwhm, Float_t amplout, Float_t fwhmout) { 21 21 // 22 22 // Constructor overloaded II 23 23 // 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) 28 // 24 29 // The procedure is the following: 25 30 // 1. some parameters of the trigger are set to default. … … 27 32 // 3. Then the all signals are set to zero 28 33 29 fwhm_resp = fwhm ; 30 ampl_resp = ampl ; 34 fwhm_resp = fwhm; 35 ampl_resp = ampl; 36 fwhm_resp_outer = fwhmout; 37 ampl_resp_outer = amplout; 31 38 32 39 // … … 42 49 43 50 Float_t dX, dX2 ; 44 51 45 52 dX = WIDTH_FADC_TIMESLICE / SUBBINS ; 46 53 dX2 = dX/2. ; … … 51 58 52 59 // 53 // the value 0.125 was introduced to normalize the things 54 // 55 sing_resp[i] = 0.125 * 56 ampl_resp * expf(-0.5 * (x-x0)*(x-x0) / (sigma*sigma) ) ; 60 // the value 1/(2*Pi*sigma^2) was introduced to normalize 61 // the area at the input value 62 // 63 sing_resp[i] = ampl_resp / sqrt(2*3.1415926*sigma*sigma)* 64 expf(-0.5 * (x-x0)*(x-x0) / (sigma*sigma) ) ; 65 66 } 67 68 sigma = fwhm_resp_outer / 2.35 ; 69 x0 = 3*sigma ; 70 71 dX = WIDTH_FADC_TIMESLICE / SUBBINS ; 72 dX2 = dX/2. ; 73 74 for (i=0; i< RESPONSE_SLICES_MFADC ; i++ ) { 75 76 x = i * dX + dX2 ; 77 78 // 79 // the value 1/(2*Pi*sigma^2) was introduced to normalize 80 // the area at the input value 81 // 82 sing_resp_outer[i] = ampl_resp_outer / sqrt(2*3.1415926*sigma*sigma)* 83 expf(-0.5 * (x-x0)*(x-x0) / (sigma*sigma) ) ; 57 84 58 85 } … … 82 109 memset(used, 0, CAMERA_PIXELS*sizeof(Bool_t)); 83 110 memset(output, 0, CAMERA_PIXELS*FADC_SLICES*sizeof(UChar_t)); 84 } 85 111 memset(output_lowgain, 0, CAMERA_PIXELS*FADC_SLICES*sizeof(UChar_t)); 112 } 113 void MFadc::Fill( Int_t iPix, Float_t time, 114 Float_t amplitude, Int_t isinner ) { 115 116 if(isinner) 117 Fill(iPix, time, amplitude); 118 else 119 FillOuter(iPix, time, amplitude); 120 121 } 86 122 void MFadc::Fill( Int_t iPix, Float_t time, Float_t amplitude ) { 87 123 … … 143 179 else { 144 180 cout << " WARNING! Fadc::Fill " << time << " out of TriggerTimeRange " 181 << TOTAL_TRIGGER_TIME << endl ; 182 } 183 184 } 185 186 void MFadc::FillOuter( Int_t iPix, Float_t time, Float_t amplitude ) { 187 188 // 189 // fills the information about one single Phe in the Trigger class 190 // for an outer pixel 191 // 192 // parameter is the number of the pixel and the time-difference to the 193 // first particle 194 // 195 // 196 197 Int_t i, ichan, ichanfadc ; 198 199 // 200 // first we have to check if the pixel iPix is used or not until now 201 // if this is the first use, reset all signal for that pixels 202 // 203 if ( iPix > CAMERA_PIXELS ) { 204 cout << " WARNING: MFadc::FillOuter() : iPix greater than CAMERA_PIXELS" 205 << endl ; 206 exit(987) ; 207 } 208 209 if ( used[iPix] == FALSE ) { 210 used [iPix] = TRUE ; 211 212 for (i=0; i < (Int_t) SLICES_MFADC; i++ ) { 213 sig[iPix][i] = 0. ; 214 } 215 } 216 217 // 218 // then select the time slice to use (ican) 219 // 220 221 222 if ( time < 0. ) { 223 cout << " WARNING! Fadc::FillOuter " << time << " below ZERO!! Very strange!!" 224 << endl ; 225 } 226 else if ( time < TOTAL_TRIGGER_TIME ) { 227 // 228 // determine the slices number assuming the WIDTH_RESPONSE_MFADC 229 // 230 ichan = (Int_t) ( time / ((Float_t) WIDTH_RESPONSE_MFADC )); 231 232 // 233 // putting the response slices in the right sig slices. 234 // Be carefull, because both slices have different widths. 235 // 236 237 for ( i = 0 ; i<RESPONSE_SLICES; i++ ) { 238 ichanfadc = (Int_t) ((ichan+i)/SUBBINS) ; 239 if ( (ichanfadc) < (Int_t)SLICES_MFADC ) { 240 sig[iPix][ichanfadc] += (amplitude * sing_resp_outer[i] ) ; 241 } 242 } 243 } 244 else { 245 cout << " WARNING! Fadc::FillOuter " << time << " out of TriggerTimeRange " 145 246 << TOTAL_TRIGGER_TIME << endl ; 146 247 } … … 328 429 } 329 430 431 void MFadc::SetElecNoise(Float_t value){ 432 433 UInt_t i; 434 435 cout<<"MFadc::SetElecNoise ... generating database for electroni noise." 436 <<endl; 437 438 for (i=0;i<CAMERA_PIXELS*(Int_t) SLICES_MFADC*101;i++){ 439 noise[i]=GenElec->Gaus(0., value ); 440 } 441 442 cout<<"MFadc::SetElecNoise ... done"<<endl; 443 444 } 445 330 446 void MFadc::ElecNoise(Float_t value) { 331 447 // ============================================================ … … 334 450 // to the signal 335 451 // 452 UInt_t startslice; 453 454 startslice=GenElec->Integer(CAMERA_PIXELS*(Int_t) SLICES_MFADC*100); 336 455 337 456 for ( Int_t i = 0 ; i < CAMERA_PIXELS; i++) { … … 343 462 used [i] = TRUE ; 344 463 345 for (Int_t ii=0; ii < (Int_t)SLICES_MFADC; ii++ ) { 346 sig[i][ii] = 0. ; 347 } 464 memcpy( (Float_t*)&sig[0][0], 465 (Float_t*)&noise[startslice+i*(Int_t) SLICES_MFADC], 466 (Int_t) SLICES_MFADC*sizeof(Float_t)); 467 348 468 } 349 469 // 350 470 // Then the noise is introduced for each time slice 351 471 // 352 for ( Int_t is=0 ; is< (Int_t)SLICES_MFADC ; is++ ) { 472 else 473 for ( Int_t is=0 ; is< (Int_t)SLICES_MFADC ; is++ ) { 353 474 354 sig[i][is] += GenElec->Gaus(0., value);475 sig[i][is] += noise[startslice+i*(Int_t) SLICES_MFADC+is] ; 355 476 356 }477 } 357 478 358 479 } … … 478 599 for ( Int_t is=iFirstSlice ; is < (iFirstSlice+FADC_SLICES) ; is++ ) { 479 600 if (is< (Int_t)SLICES_MFADC && sig[ip][is]>0.0) 480 output[ip][i++]=(UChar_t) (sig[ip][is]+0.5); 601 { 602 output[ip][i++]=(sig[ip][is] > 255. ? 255 :(UChar_t) (sig[ip][is]+0.5)); 603 output_lowgain[ip][i++]= 604 (Int_t)(pedestal[ip]+(sig[ip][is]-pedestal[ip])/HIGH2LOWGAIN) > 255. ? 255 : 605 (UChar_t)(pedestal[ip]+(sig[ip][is]-pedestal[ip])/HIGH2LOWGAIN); 606 607 } 481 608 else 482 output[ip][i++]= 0; 609 { 610 output[ip][i]= 0; 611 output_lowgain[ip][i++]= 0; 612 } 483 613 } 484 614 … … 490 620 // ============================================================ 491 621 // 492 // This method is used to book the histogram mto show the signal in622 // This method is used to book the histogram to show the signal in 493 623 // a special gui frame (class MGTriggerSignal). After the look onto the 494 624 // signals for a better understanding of the things we will expect … … 568 698 } 569 699 570 700 701 UChar_t MFadc::GetFadcLowGainSignal(Int_t pixel, Int_t slice){ 702 703 // It returns the analog signal for a given pixel and a given FADC 704 // time slice which would be read. 705 706 return (output_lowgain[pixel][slice]); 707 } 708 709 710
Note:
See TracChangeset
for help on using the changeset viewer.