250 G4double cvelScint=c_light/m_refIndex/1.07;
252 G4ThreeVector pos=hit->
GetPos();
258 G4double timeFlight=hit->
GetTime()-m_beamTime;
267 G4double nx=pDirection.x();
268 G4double ny=pDirection.y();
269 G4double nz=pDirection.z();
281 G4double thetaProb=1-
cos( asin(1.43/m_refIndex));
285 G4double nMean, nPhoton;
292 G4double resolutionScale=1.;
293 G4double sigma=resolutionScale*sqrt(nMean);
294 nPhoton=G4int(G4RandGauss::shoot(nMean,sigma)+0.5);
297 nPhoton=G4int(G4Poisson(nMean));
302 NphStep=G4int(nPhoton*thetaProb*m_rAngle*m_QE*m_CE*m_peCorFac);
318 for (G4int i=0;i<NphStep;i++)
321 ddS=stepL*G4UniformRand();
322 ddT=deltaT*G4UniformRand();
323 G4ThreeVector emtPos;
324 emtPos.setX(pos.x() + nx*ddS);
325 emtPos.setY(pos.y() + ny*ddS);
326 emtPos.setZ(pos.z() + nz*ddS);
332 DirectPh(partId, emtPos, pathL, forb);
337 G4double ran = G4UniformRand();
341 attenL = 10.*attenL/0.75;
343 if (pathL>0 &&
exp(-pathL/attenL) > ran)
346 G4double scinSwim=pathL/cvelScint;
354 G4double endTime= timeFlight + ddT + scinSwim + scinTime + transitTime;
372 if (m_t1st[forb]>endTime) m_t1st[forb] = endTime;
373 if (m_tLast[forb]<endTime) m_tLast[forb]= endTime;
412 G4double I1,I2,I3,rp1,rs1,rp2,rs2,Rp1,Rs1,Rp2,Rs2,Rp,Rs;
425 I3=asin(
sin(I1)*(
n1/n3));
430 Rp=(Rp1+Rp2-2*Rp1*Rp2)/(1-Rp1*Rp2);
431 Rs=(Rs1+Rs2-2*Rs1*Rs2)/(1-Rs1*Rs2);
460 const static G4double silicon_oil_index = 1.43;
461 const static G4double glass_index = 1.532;
464 G4double cos_span=1-
cos( asin(silicon_oil_index/m_refIndex) );
469 dcos=cos_span*(ran*2.0-1.0);
471 G4double r2=sqrt(emtPos.x()*emtPos.x()+emtPos.y()*emtPos.y());
473 G4double costheta,sintheta;
474 G4double theta,thetaR;
475 costheta=dcos>0?(1-dcos):(1+dcos);
476 theta=acos(costheta);
478 thetaR=asin(1/m_refIndex);
481 G4double ratio1Mean=(CLHEP::pi)*25.5*25.5/(57.1+60.7)/25.0;
482 G4double ratio2Mean=(19.5/25.5)*(19.5/25.5);
483 G4double ratio1=G4RandGauss::shoot(ratio1Mean,0.015);
484 G4double ratio2=G4RandGauss::shoot(ratio2Mean,0.015);
485 G4double ratio3Mean=0.945*ratio1Mean*ratio2Mean;
486 G4double ratio3=G4RandGauss::shoot(ratio3Mean,0.015);
488 G4double R2=1-
Reflectivity(m_refIndex,silicon_oil_index, glass_index, theta);
489 if (dcos > 0 && dcos != 1)
493 if (G4UniformRand()<ratio1)
495 if (G4UniformRand()<R2)
497 if (G4UniformRand()<ratio2)
500 pathL=(m_scinLength/2-emtPos.z())/costheta;
505 if (G4UniformRand()<ratio3)
508 pathL=(1.5*m_scinLength-emtPos.z())/costheta;
514 if (G4UniformRand()<R1)
516 G4double tempran=G4UniformRand();
520 pathL=(1.5*m_scinLength-emtPos.z())/costheta;
522 else if (tempran>ratio1&&G4UniformRand()<R1&&G4UniformRand()<ratio3)
525 pathL=(2.5*m_scinLength-emtPos.z())/costheta;
532 if (G4UniformRand()<ratio1)
534 if (G4UniformRand()<R2)
536 if (G4UniformRand()<ratio2)
539 pathL=(m_scinLength/2-emtPos.z())/costheta;
544 if (G4UniformRand()<ratio3)
547 pathL=(1.5*m_scinLength-emtPos.z())/costheta;
553 G4double tempran=G4UniformRand();
557 pathL=(1.5*m_scinLength-emtPos.z())/costheta;
559 else if (tempran>ratio1 && G4UniformRand()<ratio3)
562 pathL=(2.5*m_scinLength-emtPos.z())/costheta;
567 else if (dcos < 0 && dcos != -1)
571 if (G4UniformRand()<ratio1)
573 if (G4UniformRand()<R2)
575 if (G4UniformRand()<ratio2)
578 pathL=(m_scinLength/2+emtPos.z())/costheta;
583 if (G4UniformRand()<ratio3)
586 pathL=(1.5*m_scinLength+emtPos.z())/costheta;
592 if (G4UniformRand()<R1)
594 G4double tempran=G4UniformRand();
598 pathL=(1.5*m_scinLength+emtPos.z())/costheta;
600 else if (tempran>ratio1&&G4UniformRand()<R1&&G4UniformRand()<ratio3)
603 pathL=(2.5*m_scinLength+emtPos.z())/costheta;
610 if (G4UniformRand()<ratio1)
612 if (G4UniformRand()<R2)
614 if (G4UniformRand()<ratio2)
617 pathL=(m_scinLength/2+emtPos.z())/costheta;
622 if (G4UniformRand()<ratio3)
625 pathL=(1.5*m_scinLength+emtPos.z())/costheta;
631 G4double tempran=G4UniformRand();
635 pathL=(1.5*m_scinLength+emtPos.z())/costheta;
637 else if (tempran>ratio1 && G4UniformRand()<ratio3)
640 pathL=(2.5*m_scinLength+emtPos.z())/costheta;
646 G4double convFactor=180./3.1415926;
647 if (theta>asin(1)-thetaR)
649 G4double
alpha = G4UniformRand()*asin(1.);
650 G4int nRef1 = pathL*sintheta*
cos(
alpha)/50.0+0.5;
651 G4int nRef2 = pathL*sintheta*
sin(
alpha)/58.9+0.5;
652 G4double beta1=acos(sintheta*
cos(
alpha));
653 G4double beta2=acos(sintheta*
sin(
alpha));
654 beta2 -= 3.75/convFactor;
658 for (G4int i=0;i<nRef1;i++)
660 if (G4UniformRand()<(1-R21) && G4UniformRand()<0.15)
663 for (G4int i=0;i<nRef2;i++)
665 if (G4UniformRand()<(1-R22) && G4UniformRand()<0.15)
695 G4double tmp_tauRatio,tmp_tau1,tmp_tau2,tmp_tau3;
696 tmp_tauRatio = m_tauRatio;
700 G4double UniformR = tmp_tauRatio/(1+tmp_tauRatio);
701 G4double EmissionTime;
702 if (G4UniformRand()>UniformR) {
704 EmissionTime = -tmp_tau2*log( G4UniformRand() );
705 if (G4UniformRand()-
exp(EmissionTime/tmp_tau2-EmissionTime/tmp_tau1)>1.E-8)
709 else EmissionTime = -tmp_tau3*log( G4UniformRand() );
768 G4double norma_const;
769 G4double echarge=1.6e-7;
782 norma_const = sqrt(CLHEP::pi)*tau*tau*tau/4.0;
783 t = (i+1)*m_timeBinSize;
784 snpe[i][0] = m_Ce*
t*
t*
exp(- (
t/tau) * (
t/tau) )/norma_const;
790 norma_const = sqrt(CLHEP::pi)*tau*tau*tau/4.0;
791 t = (i+1)*m_timeBinSize;
792 snpe[i][1] = m_Ce*
t*
t*
exp(- (
t/tau) * (
t/tau) )/norma_const;
797 G4double pmtGain0,pmtGain,relativeGain,smearPMTgain;
798 G4double smearADC[2] = {0.,0.};
799 G4int runId = m_RealizationSvc->
getRunId();
815 G4double timeSmear = G4RandGauss::shoot(0,0.020);
816 if (runId>=-22913 && runId<=-20448) {
817 timeSmear = G4RandGauss::shoot(0,0.040);
820 for (G4int j=0; j<fb; j++)
822 if (m_totalPhot[j] > 0)
824 n1=G4int(m_t1st[j]/m_timeBinSize);
825 n2=G4int(m_tLast[j]/m_timeBinSize);
833 for (G4int i=
n1;i<
n2;i++)
839 Npoisson = G4Poisson(10.0);
840 if(Npoisson>0.)
break;
846 pmtGain = pmtGain0*relativeGain;
847 smearPMTgain = G4RandGauss::shoot(pmtGain,pmtGain/sqrt(Npoisson));
849 if(smearPMTgain>0)
break;
851 smearADC[j] += phtn*smearPMTgain;
857 profPmt[ii][j] += smearPMTgain*phtn*snpe[ihst][j];
868 profPmt[i][j] = m_preGain*profPmt[i][j]+G4RandGauss::shoot(0,m_noiseSigma);
875 if (profPmt[i][j]>max)
884 G4double tmp_HLthresh, tmp_LLthresh, adcFactor;
887 if(runId>=-80000 && runId<=-9484)
891 tmp_HLthresh = m_HLthresh;
892 tmp_LLthresh = m_LLthresh;
916 if (max>=tmp_HLthresh)
920 if ( profPmt[i][j] >= tmp_LLthresh )
922 m_TDC[j] = i*m_timeBinSize + timeSmear +G4RandGauss::shoot(0,0.025);
927 double x = m_preGain*smearADC[j]*echarge*ratio;
938 m_ADC[j] = m_preGain*smearADC[j]*echarge*adcFactor;