- Timestamp:
- 10/12/04 14:43:18 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Simulation/Detector/include-MFadc/MFadc.cxx
r5099 r5248 20 20 using namespace std; 21 21 22 MFadc::MFadc(Int_t pix, Int_t shape, Float_t integral, Float_t fwhm, Int_t shapeout, Float_t integralout, Float_t fwhmout, Float_t trigger_delay) { 22 MFadc::MFadc(Int_t pix, Int_t shape, Float_t integral, Float_t fwhm, 23 Int_t shapeout, Float_t integralout, Float_t fwhmout, 24 Float_t trigger_delay, Float_t fadc_slices_per_ns, 25 Int_t fadc_slices_written) { 23 26 // 24 27 // Constructor overloaded II … … 45 48 fwhm_resp_outer = fwhmout; 46 49 integ_resp_outer = integralout; 47 shape_resp=shape; 48 shape_resp_outer=shapeout; 49 50 cout<< "[MFadc] Setting up the MFadc with this values "<< endl ; 51 cout<< "[MFadc] - Inner pixels : "<< endl ; 50 shape_resp = shape; 51 shape_resp_outer = shapeout; 52 fFadcSlicesPerNanosec = fadc_slices_per_ns; 53 fFadcSlices = fadc_slices_written; 54 55 fSlices_mFadc = (Int_t)(TOTAL_TRIGGER_TIME*fFadcSlicesPerNanosec); 56 57 for (Int_t i = 0; i < CAMERA_PIXELS; i++) 58 sig[i] = new Float_t[fSlices_mFadc]; 59 60 noise = new Float_t[fSlices_mFadc*1001]; 61 noise_outer = new Float_t[fSlices_mFadc*1001]; 62 digital_noise = new Float_t[fSlices_mFadc*1001]; 63 64 for (Int_t i = 0; i < CAMERA_PIXELS; i++) 65 { 66 output[i] = new Float_t[fFadcSlices]; 67 output_lowgain[i] = new Float_t[fFadcSlices]; 68 } 69 70 cout<< "[MFadc] Setting up the MFadc with this values "<< endl ; 71 cout<< "[MFadc] FADC sampling frequency: " << fFadcSlicesPerNanosec << " GHz" << endl ; 72 cout<< "[MFadc] - Inner pixels : "<< endl ; 73 52 74 switch(shape_resp){ 53 75 case 0: … … 82 104 // set up the response shape 83 105 // 106 107 // 108 // First select number of bins for the histogram which will contain the single 109 // photoelectron response of the FADC. The width of these bins is smaller than that 110 // of the real FADC slices by a factor SUBBINS (see MFadcDefine.h): 111 // 112 if (shape_resp == 1) 113 fResponseSlicesFadc = (Int_t)(50.*fFadcSlicesPerNanosec*SUBBINS); 114 // 50 ns range 115 116 else 117 fResponseSlicesFadc = (Int_t)(7*fwhm_resp/2.35*fFadcSlicesPerNanosec*SUBBINS); 118 // 7 sigma range 119 120 sing_resp = new Float_t[fResponseSlicesFadc]; 121 sing_resp_outer = new Float_t[fResponseSlicesFadc]; 122 84 123 Int_t i ; 85 124 … … 92 131 response_sum_outer = 0.; 93 132 94 dX = WIDTH_FADC_TIMESLICE/ SUBBINS ; // Units: ns133 dX = 1. / fFadcSlicesPerNanosec / SUBBINS ; // Units: ns 95 134 dX2 = dX/2. ; 96 135 … … 102 141 fadc_time_offset = trigger_delay-x0; // ns 103 142 104 for (i =0; i< RESPONSE_SLICES_MFADC ; i++ ) {105 106 143 for (i = 0; i < fResponseSlicesFadc ; i++ ) 144 { 145 x = i * dX + dX2 ; 107 146 108 sing_resp[i] = expf(-0.5 * (x-x0)*(x-x0) / (sigma*sigma) );109 110 111 }147 sing_resp[i] = (Float_t)(expf(-0.5*(x-x0)*(x-x0)/(sigma*sigma))); 148 149 response_sum_inner += sing_resp[i]; 150 } 112 151 113 152 break; … … 121 160 p1 = 2.066; 122 161 p2 = 1.568; 123 p3 = 3; // This sets the peak of the pulse at x ~ 3 ADC slices162 p3 = 3; // This will set the peak of the pulse at x ~ 3*3.3 = 10 ns 124 163 // It is just a safe value so that the pulse is well contained. 125 164 p4 = 0.00282; … … 127 166 p6 = 0.2411; 128 167 p7 = -0.009442; 129 // Define the time before trigger to read FADC signal when it 130 // has to be written 131 fadc_time_offset = trigger_delay-p3*WIDTH_FADC_TIMESLICE; // ns 132 133 for (i=0; i< RESPONSE_SLICES_MFADC ; i++ ) { 134 x = i * dX + dX2; 135 136 // x has to be converted from ns to units FADC slices: 137 zed_slices=x/WIDTH_FADC_TIMESLICE-p3; 138 d=(zed_slices>0)?0.5:-0.5; 139 140 sing_resp[i] = (p1*exp(-p2*(exp(-p2*zed_slices)+zed_slices))+p4+ 141 p5*exp(-p2*(exp(-p2*zed_slices)+p6*zed_slices))+p7*d); 142 143 response_sum_inner += sing_resp[i]; 144 } 168 169 // Now define the time before trigger to read FADC signal when it 170 // has to be written. Here FADC_SLICES_PER_NSEC (=0.3) is the value 171 // for the 300 MHz MAGIC FADCs and must NOT be changed, even if you 172 // use a faster sampling in the simulation (through the input card 173 // command "fadc_GHz"), because this is just a conversion of units. The 174 // parameters of the "pulpo" pulse shape were obtained with the 300 MHz 175 // FADC and so we convert the time parameter to units of 3.3 ns slices 176 // just to use the provided parametrization, and no matter what sampling 177 // frequency we are simulating! 178 179 fadc_time_offset = trigger_delay - p3 / FADC_SLICES_PER_NSEC; // ns 180 181 for (i=0; i< fResponseSlicesFadc ; i++ ) 182 { 183 x = i * dX + dX2; 184 185 // x has to be converted from ns to units FADC slices of the default 186 // FADC of 300 MHz (these are just units, and must be these even if you 187 // are using another sampling frequency!): 188 // 189 zed_slices = x * FADC_SLICES_PER_NSEC - p3; 190 d=(zed_slices>0)?0.5:-0.5; 191 192 sing_resp[i] = (Float_t) (p1*exp(-p2*(exp(-p2*zed_slices)+zed_slices))+ 193 p4+p5*exp(-p2*(exp(-p2*zed_slices)+ 194 p6*zed_slices))+p7*d); 195 196 response_sum_inner += sing_resp[i]; 197 } 145 198 146 199 break; … … 162 215 fadc_time_offset = trigger_delay-x0; // ns 163 216 164 for (i=0; i< RESPONSE_SLICES_MFADC ; i++ ) { 217 for (i = 0; i < fResponseSlicesFadc ; i++ ) 218 { 219 x = i * dX + dX2 ; 165 220 166 x = i * dX + dX2 ; 167 168 // 169 // the value 1/sqrt(2*Pi*sigma^2) was introduced to normalize 170 // the area at the input value After this, the integral 171 // of the response will be integ_resp. 172 // 173 sing_resp_outer[i] = expf(-0.5 * (x-x0)*(x-x0) / (sigma*sigma) ) ; 174 response_sum_outer += sing_resp_outer[i]; 175 } 221 // 222 // the value 1/sqrt(2*Pi*sigma^2) was introduced to normalize 223 // the area at the input value After this, the integral 224 // of the response will be integ_resp. 225 // 226 sing_resp_outer[i] = (Float_t) (expf(-0.5 * (x-x0)*(x-x0) / 227 (sigma*sigma)) ) ; 228 response_sum_outer += sing_resp_outer[i]; 229 } 176 230 break; 177 231 case 1: … … 184 238 p1 = 2.066; 185 239 p2 = 1.568; 186 p3 = 3; // This sets the peak of the pulse at x ~ 3 ADC slices187 240 p3 = 3; // This sets the peak of the pulse at x ~ 3*3.3 = 10 nanosec 241 // It is just a safe value so that the pulse is well contained. 188 242 p4 = 0.00282; 189 243 p5 = 0.04093; 190 244 p6 = 0.2411; 191 245 p7 = -0.009442; 192 // Define the time before trigger to read FADC signal when it 193 // has to be written 194 fadc_time_offset = trigger_delay-p3*WIDTH_FADC_TIMESLICE; // ns 195 196 for (i=0; i< RESPONSE_SLICES_MFADC ; i++ ) { 197 x = i * dX + dX2; 198 199 zed_slices=x/WIDTH_FADC_TIMESLICE-p3; 200 d=(zed_slices>0)?0.5:-0.5; 201 202 sing_resp_outer[i] = (p1*exp(-p2*(exp(-p2*zed_slices)+zed_slices))+p4+ 203 p5*exp(-p2*(exp(-p2*zed_slices)+p6*zed_slices))+p7*d); 204 response_sum_outer += sing_resp_outer[i]; 246 247 // Now define the time before trigger to read FADC signal when it 248 // has to be written. Here FADC_SLICES_PER_NSEC (=0.3) is the value 249 // for the 300 MHz MAGIC FADCs and must NOT be changed, even if you 250 // use a faster sampling in the simulation (through the input card 251 // command "fadc_GHz"), because this is just a conversion of units. The 252 // parameters of the "pulpo" pulse shape were obtained with the 300 MHz 253 // FADC and so we convert the time parameter to units of 3.3 ns slices 254 // just to use the provided parametrization, and no matter what sampling 255 // frequency we are simulating! 256 257 fadc_time_offset = trigger_delay - p3 / FADC_SLICES_PER_NSEC; // ns 258 259 for (i=0; i< fResponseSlicesFadc ; i++ ) 260 { 261 x = i * dX + dX2; 262 263 // x has to be converted from ns to units FADC slices of the default 264 // FADC of 300 MHz (these are just units, and must be these even if you 265 // are using another sampling frequency!): 266 // 267 zed_slices = x * FADC_SLICES_PER_NSEC - p3; 268 d=(zed_slices>0)?0.5:-0.5; 269 270 sing_resp_outer[i] = (Float_t) (p1*exp(-p2*(exp(-p2*zed_slices)+ 271 zed_slices))+p4+ 272 p5*exp(-p2*(exp(-p2*zed_slices)+ 273 p6*zed_slices))+p7*d); 274 response_sum_outer += sing_resp_outer[i]; 205 275 } 206 276 break; … … 220 290 // 221 291 222 for (i=0; i< RESPONSE_SLICES_MFADC ; i++ ) { 292 for (i=0; i< fResponseSlicesFadc ; i++ ) 293 { 223 294 sing_resp[i] *= integ_resp / response_sum_inner * SUBBINS; 224 295 sing_resp_outer[i] *= integ_resp_outer / response_sum_outer * SUBBINS; 225 }296 } 226 297 227 298 // … … 250 321 // 251 322 memset(used, 0, CAMERA_PIXELS*sizeof(Bool_t)); 252 memset(output, 0, CAMERA_PIXELS*FADC_SLICES*sizeof(Float_t)); 253 memset(output_lowgain, 0, CAMERA_PIXELS*FADC_SLICES*sizeof(Float_t)); 323 324 for (Int_t i = 0; i < CAMERA_PIXELS; i++) 325 { 326 memset(output[i], 0, fFadcSlices*sizeof(Float_t)); 327 memset(output_lowgain[i], 0, fFadcSlices*sizeof(Float_t)); 328 } 329 254 330 // 255 331 // Added 15 01 2004, AM: 256 332 // 257 memset(sig, 0, (Int_t)(CAMERA_PIXELS*SLICES_MFADC*sizeof(Float_t))); 333 for (Int_t i = 0; i < CAMERA_PIXELS; i++) 334 memset(sig[i], 0, (Int_t)(fSlices_mFadc*sizeof(Float_t))); 258 335 } 259 336 void MFadc::Fill( Int_t iPix, Float_t time, … … 277 354 // fills the information about one single Phe in the Trigger class 278 355 // 279 // parameter is the number of the pixel and the time-difference to the 280 // first particle 281 // 282 // 356 // Parameters are the number of the pixel and the time-difference to the 357 // first photon. 358 // 359 // 360 // AM, Jan 2004: Replaced former FADC simulation (integration of signal) 361 // with a more realistic one (measuring signal height at discrete points). 362 // 363 283 364 284 365 Int_t i, ichan, ichanfadc ; … … 286 367 // 287 368 // first we have to check if the pixel iPix is used or not until now 288 // if this is the first use, reset all signal for that pixel s369 // if this is the first use, reset all signal for that pixel 289 370 // 290 if ( iPix > numpix ) { 291 cout << " WARNING: MFadc::Fill() : iPix greater than Pixels in Camera = " 292 << numpix 293 << endl ; 294 exit(987) ; 295 } 296 297 if ( used[iPix] == FALSE ) { 298 used [iPix] = TRUE ; 371 if ( iPix > numpix ) 372 { 373 cout << " WARNING: MFadc::Fill() : iPix greater than Pixels in Camera = " 374 << numpix 375 << endl; 376 exit(987); 377 } 378 379 if ( used[iPix] == FALSE ) 380 { 381 used [iPix] = TRUE; 299 382 300 for (i=0; i < (Int_t) SLICES_MFADC; i++ ) { 301 sig[iPix][i] = 0. ; 302 } 303 } 304 305 // 306 // then select the time slice to use (ican) 383 for (i=0; i < (Int_t) fSlices_mFadc; i++ ) 384 sig[iPix][i] = 0.; 385 } 386 387 // 388 // then select the time slice to use (ichan) 307 389 // 308 390 309 391 if ( time < TOTAL_TRIGGER_TIME+fadc_time_offset ) { 310 392 // 311 // determine the slices number assuming the WIDTH_RESPONSE_MFADC 312 // ichan marks the start of the pulse, in number of bins of width 313 // WIDTH_RESPONSE_MFADC (2/3 of a ns), measured from the start of the 314 // FADC. 315 // 316 317 ichan = (Int_t) ( time / ((Float_t) WIDTH_RESPONSE_MFADC )); 393 // Convert time into units of the width of the analog 394 // signal histogram, sing_resp: 395 // 396 ichan = (Int_t) ( time * fFadcSlicesPerNanosec * SUBBINS); 318 397 319 398 // 320 399 // putting the response slices in the right sig slices. 321 // Be carefull, because both slices have different widths. 322 // 323 324 // 325 // AM, Jan 2004: Replaced former FADC simulation (integration of signal) 326 // with a more realistic one (measuring signal height at discrete points). 327 // 400 // Be careful, because both slices have different widths. 401 // 402 403 // We want to put the single phe response given by sing_resp into the 404 // array sig[][], but only one of each SUBBINS bins, since the binning 405 // of sing_resp is finer than that of sig[][]. We want that the start of 406 // sing_resp coincides with the time "time" with respect to the begining 407 // of sig[][] 328 408 329 409 // We take the pulse height in the middle of FADC slices, we start in the … … 332 412 333 413 Int_t first_i = Int_t(SUBBINS/2) - ichan%(Int_t)SUBBINS; 334 first_i = first_i < 0 ? (Int_t)SUBBINS+first_i : first_i; 335 336 337 for ( i = first_i ; i < (Int_t)RESPONSE_SLICES; i += (Int_t)SUBBINS) { 338 ichanfadc = (Int_t) ((ichan+i)/SUBBINS) ; 339 if ( ichanfadc < 0 ) 414 first_i = first_i < 0 ? (Int_t)SUBBINS+first_i : first_i; // 415 // 416 // first_i is the first bin of sing_resp which matches the center of one 417 // bin of sig[][] 418 // 419 420 for ( i = first_i ; i < (Int_t)fResponseSlicesFadc; i += (Int_t)SUBBINS) 421 { 422 ichanfadc = (Int_t) ((ichan+i)/SUBBINS) ; 423 if ( ichanfadc < 0 ) 340 424 continue; 341 425 342 // 343 // SLICES_MFADC is by default 48. sig[][] is not the true FADC, which 344 // is filled from sig[][] in MFadc::TriggeredFadc() 345 // 346 if ( (ichanfadc) < (Int_t)SLICES_MFADC ) { 347 sig[iPix][ichanfadc] += (amplitude * sing_resp[i] ) ; 348 } 349 } 350 351 } 352 else { 426 // 427 // fSlices_mFadc is by default 48. sig[][] is not the true FADC, which 428 // is filled (from sig[][]) in MFadc::TriggeredFadc() 429 // 430 if ( (ichanfadc) < (Int_t) fSlices_mFadc ) 431 sig[iPix][ichanfadc] += (amplitude * sing_resp[i] ); 432 } 433 434 } 435 else 353 436 cout << " WARNING! Fadc::Fill " << time << " out of TriggerTimeRange " 354 437 << TOTAL_TRIGGER_TIME+fadc_time_offset << endl ; 355 }356 438 357 439 } … … 363 445 // for an outer pixel 364 446 // 365 // parameter is the number of the pixel and the time-difference to the 366 // first particle 367 // 447 // See explanations of the code in function Fill() above 368 448 // 369 449 370 450 Int_t i, ichan, ichanfadc ; 371 451 372 // 373 // first we have to check if the pixel iPix is used or not until now 374 // if this is the first use, reset all signal for that pixels 375 // 376 if ( iPix > numpix ) { 377 cout << " WARNING: MFadc::FillOuter() : iPix greater than CAMERA_PIXELS" 378 << endl ; 379 exit(987) ; 380 } 381 382 if ( used[iPix] == FALSE ) { 383 used [iPix] = TRUE ; 452 if ( iPix > numpix ) 453 { 454 cout << " WARNING: MFadc::FillOuter() : iPix greater than CAMERA_PIXELS" 455 << endl ; 456 exit(987) ; 457 } 458 459 if ( used[iPix] == FALSE ) 460 { 461 used [iPix] = TRUE ; 384 462 385 for (i=0; i < (Int_t) SLICES_MFADC; i++ ) { 386 sig[iPix][i] = 0. ; 387 } 388 } 389 390 // 391 // then select the time slice to use (ican) 392 // 463 for (i=0; i < (Int_t) fSlices_mFadc; i++) 464 sig[iPix][i] = 0.; 465 } 393 466 394 467 395 468 if ( time < TOTAL_TRIGGER_TIME+fadc_time_offset ) { 396 // 397 // determine the slices number assuming the WIDTH_RESPONSE_MFADC 398 // 399 ichan = (Int_t) ( time / ((Float_t) WIDTH_RESPONSE_MFADC )); 400 401 // 402 // putting the response slices in the right sig slices. 403 // Be carefull, because both slices have different widths. 404 // 405 406 // 407 // AM, Jan 2004: Replaced former FADC simulation (integration of signal) 408 // with a more realistic one (measuring signal height at discrete points). 409 // 410 411 // We take the pulse height in the middle of FADC slices, we start in the 412 // first such point after the time "time" (=ichan in response bins). Each 413 // FADC slice corresponds to SUBBINS response bins (SUBBINS=5 by default). 469 470 ichan = (Int_t) ( time * fFadcSlicesPerNanosec * SUBBINS); 414 471 415 472 Int_t first_i = Int_t(SUBBINS/2) - ichan%(Int_t)SUBBINS; 416 473 first_i = first_i < 0 ? (Int_t)SUBBINS+first_i : first_i; 417 474 418 for ( i = first_i ; i < (Int_t)RESPONSE_SLICES; i += (Int_t)SUBBINS) { 419 ichanfadc = (Int_t) ((ichan+i)/SUBBINS) ; 420 421 if ( ichanfadc < 0 ) 475 for ( i = first_i ; i < (Int_t)fResponseSlicesFadc; i += (Int_t)SUBBINS) 476 { 477 ichanfadc = (Int_t) ((ichan+i)/SUBBINS); 478 479 if ( ichanfadc < 0 ) 422 480 continue; 423 481 424 if ( (ichanfadc) < (Int_t)SLICES_MFADC ) { 425 sig[iPix][ichanfadc] += (amplitude * sing_resp_outer[i] ) ; 426 } 427 } 428 482 if ( (ichanfadc) < (Int_t)fSlices_mFadc ) 483 sig[iPix][ichanfadc] += (amplitude * sing_resp_outer[i] ); 484 } 485 429 486 } 430 487 else { … … 432 489 << TOTAL_TRIGGER_TIME+fadc_time_offset << endl ; 433 490 } 434 435 } 436 437 void MFadc::Set( Int_t iPix, Float_t resp[(Int_t) SLICES_MFADC]) {491 492 } 493 494 void MFadc::Set( Int_t iPix, Float_t *resp) { 438 495 439 496 // … … 459 516 used [iPix] = TRUE ; 460 517 461 for (i=0; i < (Int_t) SLICES_MFADC; i++ ) {518 for (i=0; i < (Int_t)fSlices_mFadc; i++ ) { 462 519 sig[iPix][i] = 0. ; 463 520 } 464 521 } 465 for ( i = 0 ; i<(Int_t) SLICES_MFADC; i++ ) {522 for ( i = 0 ; i<(Int_t)fSlices_mFadc; i++ ) { 466 523 sig[iPix][i] = resp[i] ; 467 524 } … … 469 526 } 470 527 471 void MFadc::AddSignal( Int_t iPix, Float_t resp[(Int_t) SLICES_MFADC]) {528 void MFadc::AddSignal( Int_t iPix, Float_t *resp) { 472 529 473 530 // … … 493 550 used [iPix] = TRUE ; 494 551 495 for (i=0; i < (Int_t) SLICES_MFADC; i++ ) {552 for (i=0; i < (Int_t)fSlices_mFadc; i++ ) { 496 553 sig[iPix][i] = 0. ; 497 554 } 498 555 } 499 for ( i = 0 ; i<(Int_t) SLICES_MFADC; i++ ) {556 for ( i = 0 ; i<(Int_t)fSlices_mFadc; i++ ) { 500 557 sig[iPix][i] += resp[i] ; 501 558 } … … 534 591 for(j=0;j<numpix;j++){ 535 592 baseline=0.0; 536 for(i=0;i<(Int_t) SLICES_MFADC;i++){593 for(i=0;i<(Int_t) fSlices_mFadc;i++){ 537 594 baseline+=sig[j][i]; 538 595 } 539 baseline=baseline/ SLICES_MFADC;540 for(i=0;i<(Int_t) SLICES_MFADC;i++){596 baseline=baseline/fSlices_mFadc; 597 for(i=0;i<(Int_t) fSlices_mFadc;i++){ 541 598 sig[j][i]=-baseline; 542 599 } … … 554 611 555 612 for(i=0;i<numpix;i++) 556 for(j=0;j<(Int_t) SLICES_MFADC;j++)613 for(j=0;j<(Int_t)fSlices_mFadc;j++) 557 614 sig[i][j]+=pedestal[i]; 558 615 // … … 562 619 // to do it for all pixels. 563 620 // 564 565 566 621 } 567 622 … … 585 640 if (used[i]){ 586 641 fdum=(10*GenOff->Rndm()); 587 for(j=0;j<(Int_t) SLICES_MFADC;j++)642 for(j=0;j<(Int_t) fSlices_mFadc;j++) 588 643 sig[i][j]+=fdum; 589 644 } … … 594 649 if (used[pixel]){ 595 650 fdum=(10*GenOff->Rndm()); 596 for(j=0;j<(Int_t) SLICES_MFADC;j++)651 for(j=0;j<(Int_t) fSlices_mFadc;j++) 597 652 sig[pixel][j]+=fdum; 598 653 } … … 607 662 for(i=0;i<numpix;i++){ 608 663 if (used[i]){ 609 for(j=0;j<(Int_t) SLICES_MFADC;j++)664 for(j=0;j<(Int_t) fSlices_mFadc;j++) 610 665 sig[i][j]+=offset; 611 666 } … … 615 670 616 671 if (used[pixel]){ 617 for(j=0;j<(Int_t) SLICES_MFADC;j++)672 for(j=0;j<(Int_t) fSlices_mFadc;j++) 618 673 sig[pixel][j]+=offset; 619 674 } … … 632 687 <<endl; 633 688 634 for (i=0;i<(UInt_t ( SLICES_MFADC))*1001;i++){689 for (i=0;i<(UInt_t (fSlices_mFadc))*1001;i++){ 635 690 noise[i]=GenElec->Gaus(0., value1 ); 636 691 noise_outer[i]=GenElec->Gaus(0., value2 ); … … 656 711 // 657 712 658 startslice=GenElec->Integer(((Int_t) SLICES_MFADC)*1000);713 startslice=GenElec->Integer(((Int_t)fSlices_mFadc)*1000); 659 714 660 715 if ( used[i] == FALSE ) … … 664 719 memcpy( (Float_t*)&sig[i][0], 665 720 (Float_t*)&noise[startslice], 666 ((Int_t) SLICES_MFADC)*sizeof(Float_t));721 ((Int_t) fSlices_mFadc)*sizeof(Float_t)); 667 722 else 668 723 memcpy( (Float_t*)&sig[i][0], 669 724 (Float_t*)&noise_outer[startslice], 670 ((Int_t) SLICES_MFADC)*sizeof(Float_t));725 ((Int_t) fSlices_mFadc)*sizeof(Float_t)); 671 726 } 672 727 … … 677 732 { 678 733 if (i < fInnerPixelsNum) 679 for ( Int_t is=0 ; is< (Int_t) SLICES_MFADC; is++ )734 for ( Int_t is=0 ; is< (Int_t)fSlices_mFadc ; is++ ) 680 735 sig[i][is] += noise[startslice+is]; 681 736 else 682 for ( Int_t is=0 ; is< (Int_t) SLICES_MFADC; is++ )737 for ( Int_t is=0 ; is< (Int_t)fSlices_mFadc ; is++ ) 683 738 sig[i][is] += noise_outer[startslice+is]; 684 739 } … … 694 749 <<endl; 695 750 696 for (i=0;i<UInt_t( SLICES_MFADC*1001);i++){751 for (i=0;i<UInt_t(fSlices_mFadc*1001);i++){ 697 752 xrdm=GenElec->Gaus(0., value); 698 753 digital_noise[i]=(xrdm>0?Int_t(xrdm+0.5):Int_t(xrdm-0.5)); … … 717 772 continue; 718 773 719 startslice=GenElec->Integer((Int_t) SLICES_MFADC*999);774 startslice=GenElec->Integer((Int_t) fSlices_mFadc*999); 720 775 // 721 776 // Then the noise is introduced for each time slice 722 777 // 723 for ( Int_t is =0 ; is< FADC_SLICES; is++ )778 for ( Int_t is = 0 ; is < fFadcSlices; is++ ) 724 779 { 725 780 output[i][is] += digital_noise[startslice+is]; 726 output_lowgain[i][is] += digital_noise[startslice+ FADC_SLICES+is];781 output_lowgain[i][is] += digital_noise[startslice+fFadcSlices+is]; 727 782 } 728 783 } … … 738 793 printf ("Pid %3d", ip ) ; 739 794 740 for ( Int_t is=0 ; is < (Int_t) SLICES_MFADC; is++ ) {795 for ( Int_t is=0 ; is < (Int_t)fSlices_mFadc; is++ ) { 741 796 742 797 if ( sig[ip][is] > 0. ) { … … 776 831 Int_t iFirstSlice ; 777 832 778 iFirstSlice = (Int_t) ( t / WIDTH_FADC_TIMESLICE) ;833 iFirstSlice = (Int_t) ( t * fFadcSlicesPerNanosec ) ; 779 834 780 835 for ( Int_t ip=0; ip<numpix; ip++ ) { … … 799 854 // puts the standard response function into the array resp 800 855 801 for ( Int_t i=0; i< RESPONSE_SLICES; i++ ) { 802 803 resp[i] = sing_resp[i] ; 804 } 856 for ( Int_t i=0; i< fResponseSlicesFadc; i++ ) 857 resp[i] = sing_resp[i]; 858 805 859 } 806 860 … … 841 895 // Get at random a point in the FADC presimulated digital noise: 842 896 // 843 startslice=GenElec->Integer((Int_t) SLICES_MFADC*999);897 startslice=GenElec->Integer((Int_t) fSlices_mFadc*999); 844 898 845 899 for ( Int_t is=0; is < n_slices ; is++ ) … … 875 929 // We had 0.5 for the correct rounding: 876 930 // 877 iFirstSlice = (Int_t) ( 0.5 + time / WIDTH_FADC_TIMESLICE ) ; 878 879 880 for ( Int_t ip=0; ip<numpix; ip++ ) 931 iFirstSlice = (Int_t) ( 0.5 + time * fFadcSlicesPerNanosec ) ; 932 933 for ( Int_t ip = 0; ip < numpix; ip++ ) 881 934 { 882 935 … … 887 940 // it anyway! 888 941 { 889 for ( Int_t i=0 ; i < FADC_SLICES; i++ )942 for ( Int_t i=0 ; i < fFadcSlices ; i++ ) 890 943 { 891 944 output[ip][i]= pedestal[ip]; … … 896 949 897 950 i=0; 898 for ( Int_t is =iFirstSlice ; is < (iFirstSlice+FADC_SLICES); is++ )951 for ( Int_t is = iFirstSlice; is < (iFirstSlice+fFadcSlices); is++ ) 899 952 { 900 if (is < (Int_t) SLICES_MFADC)953 if (is < (Int_t)fSlices_mFadc) 901 954 { 902 955 output[ip][i] = sig[ip][is]; … … 948 1001 sprintf (name, "fadc signal %d", i ) ; 949 1002 950 hist = new TH1F(dumm, name, (Int_t) SLICES_MFADC, fadc_time_offset, TOTAL_TRIGGER_TIME+fadc_time_offset);1003 hist = new TH1F(dumm, name, (Int_t)fSlices_mFadc, fadc_time_offset, TOTAL_TRIGGER_TIME+fadc_time_offset); 951 1004 // 952 1005 // fill the histogram 953 1006 // 954 1007 955 for (Int_t ibin =1; ibin <=(Int_t)SLICES_MFADC; ibin++) {956 hist->SetBinContent (ibin, sig[i][ibin-1]) 957 } 1008 for (Int_t ibin = 1; ibin <= (Int_t)fSlices_mFadc; ibin++) 1009 hist->SetBinContent (ibin, sig[i][ibin-1]); 1010 958 1011 959 1012 // hist->SetMaximum( 5.);
Note:
See TracChangeset
for help on using the changeset viewer.