223 G4double cvelScint = c_light / m_refIndex / 1.07;
225 G4ThreeVector pos = hit->
GetPos();
228 G4double edep = hit->
GetEdep();
231 G4double timeFlight = hit->
GetTime() - m_beamTime;
240 G4double nx = pDirection.x();
241 G4double ny = pDirection.y();
242 G4double nz = pDirection.z();
254 G4double thetaProb = 1 -
cos( asin( 1.43 / m_refIndex ) );
258 G4double nMean, nPhoton;
260 nMean = m_phNConst *
BirksLaw( hit );
261 G4int runId = m_RealizationSvc->getRunId();
262 if ( ( runId >= -11396 && runId <= -8093 ) || ( runId > -1000000 && runId <= -23463 ) )
263 { nMean = 9000.0 *
BirksLaw( hit ); }
268 G4double resolutionScale = 1.;
269 G4double sigma = resolutionScale * sqrt( nMean );
270 nPhoton = G4int( G4RandGauss::shoot( nMean, sigma ) + 0.5 );
272 else nPhoton = G4int( G4Poisson( nMean ) );
277 NphStep = G4int( nPhoton * thetaProb * m_rAngle * m_QE * m_CE * m_peCorFac );
292 for ( G4int i = 0; i < NphStep; i++ )
295 ddS = stepL * G4UniformRand();
296 ddT = deltaT * G4UniformRand();
297 G4ThreeVector emtPos;
298 emtPos.setX( pos.x() + nx * ddS );
299 emtPos.setY( pos.y() + ny * ddS );
300 emtPos.setZ( pos.z() + nz * ddS );
306 DirectPh( partId, emtPos, pathL, forb );
310 G4double ran = G4UniformRand();
313 G4double attenL =
m_tofSimSvc->BarAttenLength( scinNb );
314 attenL = 10. * attenL / 0.75;
316 if ( pathL > 0 &&
exp( -pathL / attenL ) > ran )
319 G4double scinSwim = pathL / cvelScint;
327 G4double endTime = timeFlight + ddT + scinSwim + scinTime + transitTime;
330 if ( m_G4Svc->TofRootFlag() )
345 if ( m_t1st[forb] > endTime ) m_t1st[forb] = endTime;
346 if ( m_tLast[forb] < endTime ) m_tLast[forb] = endTime;
429 const static G4double silicon_oil_index = 1.43;
430 const static G4double glass_index = 1.532;
433 G4double cos_span = 1 -
cos( asin( silicon_oil_index / m_refIndex ) );
436 ran = G4UniformRand();
438 dcos = cos_span * ( ran * 2.0 - 1.0 );
440 G4double r2 = sqrt( emtPos.x() * emtPos.x() + emtPos.y() * emtPos.y() );
442 G4double costheta, sintheta;
443 G4double theta, thetaR;
444 costheta = dcos > 0 ? ( 1 - dcos ) : ( 1 + dcos );
445 theta = acos( costheta );
446 sintheta =
sin( theta );
447 thetaR = asin( 1 / m_refIndex );
450 G4double ratio1Mean = ( CLHEP::pi ) * 25.5 * 25.5 / ( 57.1 + 60.7 ) / 25.0;
451 G4double ratio2Mean = ( 19.5 / 25.5 ) * ( 19.5 / 25.5 );
452 G4double ratio1 = G4RandGauss::shoot( ratio1Mean, 0.015 );
453 G4double ratio2 = G4RandGauss::shoot( ratio2Mean, 0.015 );
454 G4double ratio3Mean = 0.945 * ratio1Mean * ratio2Mean;
455 G4double ratio3 = G4RandGauss::shoot( ratio3Mean, 0.015 );
457 G4double R2 = 1 -
Reflectivity( m_refIndex, silicon_oil_index, glass_index, theta );
458 if ( dcos > 0 && dcos != 1 )
460 if ( theta < thetaR )
462 if ( G4UniformRand() < ratio1 )
464 if ( G4UniformRand() < R2 )
466 if ( G4UniformRand() < ratio2 )
469 pathL = ( m_scinLength / 2 - emtPos.z() ) / costheta;
474 if ( G4UniformRand() < ratio3 )
477 pathL = ( 1.5 * m_scinLength - emtPos.z() ) / costheta;
483 if ( G4UniformRand() < R1 )
485 G4double tempran = G4UniformRand();
486 if ( tempran < ratio3 )
489 pathL = ( 1.5 * m_scinLength - emtPos.z() ) / costheta;
491 else if ( tempran > ratio1 && G4UniformRand() < R1 && G4UniformRand() < ratio3 )
494 pathL = ( 2.5 * m_scinLength - emtPos.z() ) / costheta;
501 if ( G4UniformRand() < ratio1 )
503 if ( G4UniformRand() < R2 )
505 if ( G4UniformRand() < ratio2 )
508 pathL = ( m_scinLength / 2 - emtPos.z() ) / costheta;
513 if ( G4UniformRand() < ratio3 )
516 pathL = ( 1.5 * m_scinLength - emtPos.z() ) / costheta;
522 G4double tempran = G4UniformRand();
523 if ( tempran < ratio3 )
526 pathL = ( 1.5 * m_scinLength - emtPos.z() ) / costheta;
528 else if ( tempran > ratio1 && G4UniformRand() < ratio3 )
531 pathL = ( 2.5 * m_scinLength - emtPos.z() ) / costheta;
536 else if ( dcos < 0 && dcos != -1 )
538 if ( theta < thetaR )
540 if ( G4UniformRand() < ratio1 )
542 if ( G4UniformRand() < R2 )
544 if ( G4UniformRand() < ratio2 )
547 pathL = ( m_scinLength / 2 + emtPos.z() ) / costheta;
552 if ( G4UniformRand() < ratio3 )
555 pathL = ( 1.5 * m_scinLength + emtPos.z() ) / costheta;
561 if ( G4UniformRand() < R1 )
563 G4double tempran = G4UniformRand();
564 if ( tempran < ratio3 )
567 pathL = ( 1.5 * m_scinLength + emtPos.z() ) / costheta;
569 else if ( tempran > ratio1 && G4UniformRand() < R1 && G4UniformRand() < ratio3 )
572 pathL = ( 2.5 * m_scinLength + emtPos.z() ) / costheta;
579 if ( G4UniformRand() < ratio1 )
581 if ( G4UniformRand() < R2 )
583 if ( G4UniformRand() < ratio2 )
586 pathL = ( m_scinLength / 2 + emtPos.z() ) / costheta;
591 if ( G4UniformRand() < ratio3 )
594 pathL = ( 1.5 * m_scinLength + emtPos.z() ) / costheta;
600 G4double tempran = G4UniformRand();
601 if ( tempran < ratio3 )
604 pathL = ( 1.5 * m_scinLength + emtPos.z() ) / costheta;
606 else if ( tempran > ratio1 && G4UniformRand() < ratio3 )
609 pathL = ( 2.5 * m_scinLength + emtPos.z() ) / costheta;
615 G4double convFactor = 180. / 3.1415926;
616 if ( theta > asin( 1 ) - thetaR )
618 G4double
alpha = G4UniformRand() * asin( 1. );
619 G4int nRef1 = pathL * sintheta *
cos(
alpha ) / 50.0 + 0.5;
620 G4int nRef2 = pathL * sintheta *
sin(
alpha ) / 58.9 + 0.5;
621 G4double beta1 = acos( sintheta *
cos(
alpha ) );
622 G4double beta2 = acos( sintheta *
sin(
alpha ) );
623 beta2 -= 3.75 / convFactor;
627 for ( G4int i = 0; i < nRef1; i++ )
629 if ( G4UniformRand() < ( 1 - R21 ) && G4UniformRand() < 0.15 ) pathL = -9;
631 for ( G4int i = 0; i < nRef2; i++ )
633 if ( G4UniformRand() < ( 1 - R22 ) && G4UniformRand() < 0.15 ) pathL = -9;
733 G4double norma_const;
734 G4double echarge = 1.6e-7;
747 norma_const = sqrt( CLHEP::pi ) * tau * tau * tau / 4.0;
748 t = ( i + 1 ) * m_timeBinSize;
749 snpe[i][0] = m_Ce *
t *
t *
exp( -(
t / tau ) * (
t / tau ) ) /
756 norma_const = sqrt( CLHEP::pi ) * tau * tau * tau / 4.0;
757 t = ( i + 1 ) * m_timeBinSize;
758 snpe[i][1] = m_Ce *
t *
t *
exp( -(
t / tau ) * (
t / tau ) ) / norma_const;
763 G4double pmtGain0, pmtGain, relativeGain, smearPMTgain;
764 G4double smearADC[2] = { 0., 0. };
765 G4int runId = m_RealizationSvc->getRunId();
781 G4double timeSmear = G4RandGauss::shoot( 0, 0.020 );
782 if ( runId >= -22913 && runId <= -20448 )
784 timeSmear = G4RandGauss::shoot( 0, 0.040 );
786 else if ( ( runId >= -11396 && runId <= -8093 ) || ( runId > -1000000 && runId <= -23463 ) )
787 { timeSmear = G4RandGauss::shoot( 0, 0.025 ); }
789 for ( G4int j = 0; j < fb; j++ )
791 if ( m_totalPhot[j] > 0 )
793 n1 = G4int( m_t1st[j] / m_timeBinSize );
794 n2 = G4int( m_tLast[j] / m_timeBinSize );
797 for ( G4int i = 0; i <
m_profBinN; i++ ) profPmt[i][j] = 0.0;
801 for ( G4int i =
n1; i <
n2; i++ )
803 phtn = m_nPhot[i][j];
808 Npoisson = G4Poisson( 10.0 );
809 if ( Npoisson > 0. )
break;
818 pmtGain = pmtGain0 * relativeGain;
819 smearPMTgain = G4RandGauss::shoot( pmtGain, pmtGain / sqrt( Npoisson ) );
821 if ( smearPMTgain > 0 )
break;
823 smearADC[j] += phtn * smearPMTgain;
825 for ( G4int ihst = 0; ihst <
m_snpeBinN; ihst++ )
828 if ( ii <
m_profBinN ) profPmt[ii][j] += smearPMTgain * phtn * snpe[ihst][j];
837 if ( profPmt[i][j] > 0 )
838 profPmt[i][j] = m_preGain * profPmt[i][j] + G4RandGauss::shoot( 0, m_noiseSigma );
845 if ( profPmt[i][j] >
max )
max = profPmt[i][j];
847 if ( m_G4Svc->TofRootFlag() )
853 G4double tmp_HLthresh, tmp_LLthresh, adcFactor;
856 if ( runId >= -80000 && runId <= -9484 )
860 tmp_HLthresh = m_HLthresh;
861 tmp_LLthresh = m_LLthresh;
885 if (
max >= tmp_HLthresh )
889 if ( profPmt[i][j] >= tmp_LLthresh )
892 i * m_timeBinSize + timeSmear +
893 G4RandGauss::shoot( 0, 0.025 );
895 if ( ( runId >= -11396 && runId <= -8093 ) ||
896 ( runId > -1000000 && runId <= -23463 ) )
899 {
m_TDC[j] = i * m_timeBinSize + timeSmear + G4RandGauss::shoot( 0, 0.055 ); }
901 {
m_TDC[j] = i * m_timeBinSize + timeSmear + G4RandGauss::shoot( 0, 0.062 ); }
904 if ( m_G4Svc->TofSaturationFlag() )
907 double x = m_preGain * smearADC[j] * echarge * ratio;
911 else m_ADC[j] = m_preGain * smearADC[j] * echarge * adcFactor;
913 if ( m_G4Svc->TofRootFlag() )