84   CLHEP::RandGauss GaussGen(
fEngine);
 
   85   CLHEP::RandFlat  UniformGen(
fEngine);
 
   99   bool   fTrackSecondariesFirst = 
false;
 
  100   bool   fExcitedNucleus        = 
false;
 
  101   bool   fVeryHighEnergy        = 
false;
 
  103   bool   fMultipleScattering    = 
false;
 
  106   if( aTrack.GetParentID() == 0 && aTrack.GetCurrentStepNumber() == 1 ) {
 
  107     fExcitedNucleus = 
false; 
 
  108     fVeryHighEnergy = 
false; 
 
  110     fMultipleScattering = 
false;
 
  113   const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
 
  114   G4ParticleDefinition *pDef = aParticle->GetDefinition();
 
  115   G4String particleName = pDef->GetParticleName();
 
  116   const G4Material* aMaterial = aStep.GetPreStepPoint()->GetMaterial();
 
  117   const G4Material* bMaterial = aStep.GetPostStepPoint()->GetMaterial();
 
  119   if((particleName == 
"neutron" || particleName == 
"antineutron") &&
 
  120      aStep.GetTotalEnergyDeposit() <= 0)
 
  128   G4Element *ElementA = NULL, *ElementB = NULL;
 
  130     const G4ElementVector* theElementVector1 =
 
  131       aMaterial->GetElementVector();
 
  132     ElementA = (*theElementVector1)[0];
 
  135     const G4ElementVector* theElementVector2 =
 
  136       bMaterial->GetElementVector();
 
  137     ElementB = (*theElementVector2)[0];
 
  139   G4int z1,z2,j=1; G4bool NobleNow=
false,NobleLater=
false;
 
  140   if (ElementA) z1 = (G4int)(ElementA->GetZ()); 
else z1 = -1;
 
  141   if (ElementB) z2 = (G4int)(ElementB->GetZ()); 
else z2 = -1;
 
  142   if ( z1==2 || z1==10 || z1==18 || z1==36 || z1==54 ) {
 
  152   if ( z2==2 || z2==10 || z2==18 || z2==36 || z2==54 ) {
 
  163   if ( !NobleNow && !NobleLater )
 
  168   G4StepPoint* pPreStepPoint  = aStep.GetPreStepPoint();
 
  169   G4StepPoint* pPostStepPoint = aStep.GetPostStepPoint();
 
  170   G4ThreeVector x1 = pPostStepPoint->GetPosition();
 
  171   G4ThreeVector x0 = pPreStepPoint->GetPosition();
 
  172   G4double evtStrt = pPreStepPoint->GetGlobalTime();
 
  173   G4double      
t0 = pPreStepPoint->GetLocalTime();
 
  174   G4double      t1 = pPostStepPoint->GetLocalTime();
 
  180   G4bool outside = 
false, inside = 
false, InsAndOuts = 
false;
 
  181   G4MaterialPropertiesTable* aMaterialPropertiesTable =
 
  182     aMaterial->GetMaterialPropertiesTable();
 
  183   if ( NobleNow && !NobleLater ) outside = 
true;
 
  184   if ( !NobleNow && NobleLater ) {
 
  185     aMaterial = bMaterial; inside = 
true; z1 = z2;
 
  186     aMaterialPropertiesTable = bMaterial->GetMaterialPropertiesTable();
 
  188   if ( NobleNow && NobleLater &&
 
  189        aMaterial->GetDensity() != bMaterial->GetDensity() )
 
  193   G4double Density = aMaterial->GetDensity()/(
CLHEP::g/CLHEP::cm3);
 
  194   G4double nDensity = Density*
AVO; 
 
  195   G4int Phase = aMaterial->GetState(); 
 
  196   G4double ElectricField(0.), FieldSign(0.); 
 
  197   G4bool GlobalFields = 
false;
 
  200     ElectricField = aMaterialPropertiesTable->GetConstProperty(
"ELECTRICFIELD");
 
  204     if ( x1[2] < 
WIN && x1[2] > 
TOP && Phase == kStateGas )
 
  205       ElectricField = aMaterialPropertiesTable->GetConstProperty(
"ELECTRICFIELDWINDOW");
 
  206     else if ( x1[2] < 
TOP && x1[2] > 
ANE && Phase == kStateGas )
 
  207       ElectricField = aMaterialPropertiesTable->GetConstProperty(
"ELECTRICFIELDTOP");
 
  208     else if ( x1[2] < 
ANE && x1[2] > 
SRF && Phase == kStateGas )
 
  209       ElectricField = aMaterialPropertiesTable->
 
  210         GetConstProperty(
"ELECTRICFIELDANODE");
 
  211     else if ( x1[2] < 
SRF && x1[2] > 
GAT && Phase == kStateLiquid )
 
  212       ElectricField = aMaterialPropertiesTable->
 
  213         GetConstProperty(
"ELECTRICFIELDSURFACE");
 
  214     else if ( x1[2] < 
GAT && x1[2] > 
CTH && Phase == kStateLiquid )
 
  215       ElectricField = aMaterialPropertiesTable->
 
  216         GetConstProperty(
"ELECTRICFIELDGATE");
 
  217     else if ( x1[2] < 
CTH && x1[2] > 
BOT && Phase == kStateLiquid )
 
  218       ElectricField = aMaterialPropertiesTable->
 
  219         GetConstProperty(
"ELECTRICFIELDCATHODE");
 
  220     else if ( x1[2] < 
BOT && x1[2] > 
PMT && Phase == kStateLiquid )
 
  221       ElectricField = aMaterialPropertiesTable->
 
  222         GetConstProperty(
"ELECTRICFIELDBOTTOM");
 
  224       ElectricField = aMaterialPropertiesTable->
 
  225         GetConstProperty(
"ELECTRICFIELD");
 
  227   if ( ElectricField >= 0 ) FieldSign = 1; 
else FieldSign = -1;
 
  229   G4double Temperature = aMaterial->GetTemperature();
 
  230   G4double ScintillationYield, ResolutionScale, R0 = 1.0*CLHEP::um,
 
  231     DokeBirks[3], ThomasImel = 0.00, delta = 1*CLHEP::mm;
 
  232   DokeBirks[0] = 0.00; DokeBirks[2] = 1.00;
 
  233   G4double PhotMean = 7*CLHEP::eV, PhotWidth = 1.0*CLHEP::eV; 
 
  234   G4double SingTripRatioR, SingTripRatioX, tau1, tau3, tauR = 0*CLHEP::ns;
 
  237     ScintillationYield = 1 / (41.3*CLHEP::eV); 
 
  239     ResolutionScale = 0.2; 
 
  240     PhotMean = 15.9*CLHEP::eV;
 
  241     tau1 = GaussGen.fire(10.0*CLHEP::ns,0.0*CLHEP::ns);
 
  242     tau3 = 1.6e3*CLHEP::ns;
 
  246     ScintillationYield = 1 / (29.2*CLHEP::eV);
 
  248     ResolutionScale = 0.13; 
 
  249     PhotMean = 15.5*CLHEP::eV; PhotWidth = 0.26*CLHEP::eV;
 
  250     tau1 = GaussGen.fire(10.0*CLHEP::ns,10.*CLHEP::ns);
 
  251     tau3 = GaussGen.fire(15.4e3*CLHEP::ns,200*CLHEP::ns); 
 
  254     ScintillationYield = 1 / (19.5*CLHEP::eV);
 
  256     ResolutionScale = 0.107; 
 
  257     R0 = 1.568*CLHEP::um; 
 
  259       ThomasImel = 0.156977*pow(ElectricField,-0.1);
 
  260       DokeBirks[0] = 0.07*pow((ElectricField/1.0e3),-0.85);
 
  265       DokeBirks[0] = 0.0003;
 
  267     } nDensity /= 39.948; 
 
  268     PhotMean = 9.69*CLHEP::eV; PhotWidth = 0.22*CLHEP::eV;
 
  269     tau1 = GaussGen.fire(6.5*CLHEP::ns,0.8*CLHEP::ns); 
 
  270     tau3 = GaussGen.fire(1300*CLHEP::ns,50*CLHEP::ns); 
 
  271     tauR = GaussGen.fire(0.8*CLHEP::ns,0.2*CLHEP::ns); 
 
  274     if ( Phase == kStateGas ) ScintillationYield = 1 / (30.0*CLHEP::eV);
 
  275     else ScintillationYield = 1 / (15.0*CLHEP::eV);
 
  277     ResolutionScale = 0.05; 
 
  278     PhotMean = 8.43*CLHEP::eV;
 
  279     tau1 = GaussGen.fire(2.8*CLHEP::ns,.04*CLHEP::ns);
 
  280     tau3 = GaussGen.fire(93.*CLHEP::ns,1.1*CLHEP::ns);
 
  281     tauR = GaussGen.fire(12.*CLHEP::ns,.76*CLHEP::ns);
 
  284   default: nDensity /= 131.293;
 
  285     ScintillationYield = 48.814+0.80877*Density+2.6721*pow(Density,2.);
 
  286     ScintillationYield /= CLHEP::keV; 
 
  290     ResolutionScale = 1.00 * 
 
  291       (0.12724-0.032152*Density-0.0013492*pow(Density,2.));
 
  293     if ( Phase == kStateLiquid ) {
 
  294       ResolutionScale *= 1.5; 
 
  298         R0 = 69.492*pow(ElectricField,-0.50422)*CLHEP::um;
 
  300         DokeBirks[0]= 19.171*pow(ElectricField+25.552,-0.83057)+0.026772;
 
  310       delta = 0.4*CLHEP::mm; 
 
  311       PhotMean = 6.97*CLHEP::eV; PhotWidth = 0.23*CLHEP::eV;
 
  316       tau1 = GaussGen.fire(3.1*CLHEP::ns,.7*CLHEP::ns); 
 
  317       tau3 = GaussGen.fire(24.*CLHEP::ns,1.*CLHEP::ns); 
 
  319     else if ( Phase == kStateGas ) {
 
  322         ScintillationYield = 1 / (12.98*CLHEP::eV); } 
 
  324       G4double Townsend = (ElectricField/nDensity)*1e17;
 
  325       DokeBirks[0] = 0.0000; 
 
  326       DokeBirks[2] = 0.1933*pow(Density,2.6199)+0.29754 -
 
  327         (0.045439*pow(Density,2.4689)+0.066034)*log10(ElectricField);
 
  328       if ( ElectricField>6990 ) DokeBirks[2]=0.0;
 
  329       if ( ElectricField<1000 ) DokeBirks[2]=0.2;
 
  330       if ( ElectricField<100. ) { DokeBirks[0]=0.18; DokeBirks[2]=0.58; }
 
  331       if( Density < 0.061 ) ThomasImel = 0.041973*pow(Density,1.8105);
 
  332       else if( Density >= 0.061 && Density <= 0.167 )
 
  333         ThomasImel=5.9583e-5+0.0048523*Density-0.023109*pow(Density,2.);
 
  334       else ThomasImel = 6.2552e-6*pow(Density,-1.9963);
 
  335       if(ElectricField)ThomasImel=1.2733e-5*pow(Townsend/Density,-0.68426);
 
  337       PhotMean = 7.1*CLHEP::eV; PhotWidth = 0.2*CLHEP::eV;
 
  338       tau1 = GaussGen.fire(5.18*CLHEP::ns,1.55*CLHEP::ns);
 
  339       tau3 = GaussGen.fire(100.1*CLHEP::ns,7.9*CLHEP::ns);
 
  342       tau1 = 3.5*CLHEP::ns; tau3 = 20.*CLHEP::ns; tauR = 40.*CLHEP::ns;
 
  347   G4double anExcitationEnergy = ((
const G4Ions*)(pDef))->
 
  348     GetExcitationEnergy(); 
 
  349   G4double TotalEnergyDeposit = 
 
  350     aMaterialPropertiesTable->GetConstProperty( 
"ENERGY_DEPOSIT_TOT" );
 
  351   G4bool 
convert = 
false, annihil = 
false;
 
  353   if(pPreStepPoint->GetKineticEnergy()>=(2*CLHEP::electron_mass_c2) &&
 
  354      !pPostStepPoint->GetKineticEnergy() &&
 
  355      !aStep.GetTotalEnergyDeposit() && aParticle->GetPDGcode()==22) {
 
  356     convert = 
true; TotalEnergyDeposit = CLHEP::electron_mass_c2;
 
  358   if(pPreStepPoint->GetKineticEnergy() &&
 
  359      !pPostStepPoint->GetKineticEnergy() &&
 
  360      aParticle->GetPDGcode()==-11) {
 
  361     annihil = 
true; TotalEnergyDeposit += aStep.GetTotalEnergyDeposit();
 
  363   G4bool either = 
false;
 
  364   if(inside || outside || convert || annihil || InsAndOuts) either=
true;
 
  366   if( anExcitationEnergy<100*CLHEP::eV && aStep.GetTotalEnergyDeposit()<1*CLHEP::eV &&
 
  367       !either && !fExcitedNucleus )
 
  370   if ( !annihil ) TotalEnergyDeposit += aStep.GetTotalEnergyDeposit();
 
  371   if ( !convert ) aMaterialPropertiesTable->
 
  372                     AddConstProperty( 
"ENERGY_DEPOSIT_TOT", TotalEnergyDeposit );
 
  374   TotalEnergyDeposit = aStep.GetTotalEnergyDeposit();
 
  379   G4double InitialKinetEnergy = aMaterialPropertiesTable->
 
  380     GetConstProperty( 
"ENERGY_DEPOSIT_GOL" );
 
  382   if ( InitialKinetEnergy == 0 ) {
 
  383     G4double tE = pPreStepPoint->GetKineticEnergy()+anExcitationEnergy;
 
  384     if ( (fabs(tE-1.8*CLHEP::keV) < CLHEP::eV || fabs(tE-9.4*CLHEP::keV) < CLHEP::eV) &&
 
  385          Phase == kStateLiquid && z1 == 54 ) tE = 9.4*CLHEP::keV;
 
  386     if ( fKr83m && ElectricField != 0 )
 
  388     aMaterialPropertiesTable->
 
  389       AddConstProperty ( 
"ENERGY_DEPOSIT_GOL", tE );
 
  393     if ( anExcitationEnergy ) fExcitedNucleus = 
true;
 
  397   if(outside){ aMaterialPropertiesTable->
 
  398       AddConstProperty(
"ENERGY_DEPOSIT_GOL",
 
  399                        InitialKinetEnergy-pPostStepPoint->GetKineticEnergy());
 
  400     if(aMaterialPropertiesTable->
 
  401        GetConstProperty(
"ENERGY_DEPOSIT_GOL")<0)
 
  402       aMaterialPropertiesTable->AddConstProperty(
"ENERGY_DEPOSIT_GOL",0);
 
  406   if(inside) { aMaterialPropertiesTable->
 
  407       AddConstProperty(
"ENERGY_DEPOSIT_GOL",
 
  408                        InitialKinetEnergy+pPreStepPoint->GetKineticEnergy());
 
  409     if ( TotalEnergyDeposit > 0 && InitialKinetEnergy == 0 ) {
 
  410       aMaterialPropertiesTable->AddConstProperty(
"ENERGY_DEPOSIT_GOL",0);
 
  411       TotalEnergyDeposit = .000000;
 
  417     aMaterialPropertiesTable->
 
  418       AddConstProperty(
"ENERGY_DEPOSIT_GOL",(-0.1*CLHEP::keV)+
 
  419                        InitialKinetEnergy-pPostStepPoint->GetKineticEnergy());
 
  420     InitialKinetEnergy = bMaterial->GetMaterialPropertiesTable()->
 
  421       GetConstProperty(
"ENERGY_DEPOSIT_GOL");
 
  422     bMaterial->GetMaterialPropertiesTable()->
 
  423       AddConstProperty(
"ENERGY_DEPOSIT_GOL",(-0.1*CLHEP::keV)+
 
  424                        InitialKinetEnergy+pPreStepPoint->GetKineticEnergy());
 
  425     if(aMaterialPropertiesTable->
 
  426        GetConstProperty(
"ENERGY_DEPOSIT_GOL")<0)
 
  427       aMaterialPropertiesTable->AddConstProperty(
"ENERGY_DEPOSIT_GOL",0);
 
  428     if ( bMaterial->GetMaterialPropertiesTable()->
 
  429          GetConstProperty(
"ENERGY_DEPOSIT_GOL") < 0 )
 
  430       bMaterial->GetMaterialPropertiesTable()->
 
  431         AddConstProperty ( 
"ENERGY_DEPOSIT_GOL", 0 );
 
  433   InitialKinetEnergy = aMaterialPropertiesTable->
 
  434     GetConstProperty(
"ENERGY_DEPOSIT_GOL"); 
 
  436     InitialKinetEnergy += 2*CLHEP::electron_mass_c2;
 
  440     InitialKinetEnergy -= 2*CLHEP::electron_mass_c2;
 
  442   aMaterialPropertiesTable->
 
  443     AddConstProperty(
"ENERGY_DEPOSIT_GOL",InitialKinetEnergy);
 
  444   if (anExcitationEnergy < 1
e-100 && aStep.GetTotalEnergyDeposit()==0 &&
 
  445       aMaterialPropertiesTable->GetConstProperty(
"ENERGY_DEPOSIT_GOL")==0 &&
 
  446       aMaterialPropertiesTable->GetConstProperty(
"ENERGY_DEPOSIT_TOT")==0)
 
  450   if ( aTrack.GetCreatorProcess() )
 
  451     procName = aTrack.GetCreatorProcess()->GetProcessName();
 
  455     fMultipleScattering = 
true;
 
  458   if ( fAlpha ) delta = 1000.*CLHEP::km;
 
  459   G4int i, 
k, 
counter = 0; G4double pos[3];
 
  462       fMultipleScattering = 
true;
 
  466   char xCoord[80]; 
char yCoord[80]; 
char zCoord[80];
 
  470     sprintf(xCoord,
"POS_X_%d",i); sprintf(yCoord,
"POS_Y_%d",i);
 
  471     sprintf(zCoord,
"POS_Z_%d",i);
 
  472     pos[0] = aMaterialPropertiesTable->GetConstProperty(xCoord);
 
  473     pos[1] = aMaterialPropertiesTable->GetConstProperty(yCoord);
 
  474     pos[2] = aMaterialPropertiesTable->GetConstProperty(zCoord);
 
  475     if ( sqrt(pow(x1[0]-pos[0],2.)+pow(x1[1]-pos[1],2.)+
 
  476               pow(x1[2]-pos[2],2.)) < delta ) {
 
  477       exists = 
true; 
break; 
 
  480   if(!exists && TotalEnergyDeposit) { 
 
  482     sprintf(xCoord,
"POS_X_%i",j); sprintf(yCoord,
"POS_Y_%i",j);
 
  483     sprintf(zCoord,
"POS_Z_%i",j);
 
  485     aMaterialPropertiesTable->AddConstProperty( xCoord, x1[0] );
 
  486     aMaterialPropertiesTable->AddConstProperty( yCoord, x1[1] );
 
  487     aMaterialPropertiesTable->AddConstProperty( zCoord, x1[2] );
 
  489     aMaterialPropertiesTable-> 
 
  490       AddConstProperty( 
"TOTALNUM_INT_SITES", j );
 
  498   G4double 
a1 = ElementA->GetA();
 
  499   z2 = pDef->GetAtomicNumber();
 
  500   G4double 
a2 = (G4double)(pDef->GetAtomicMass());
 
  501   if ( particleName == 
"alpha" || (z2 == 2 && a2 == 4) )
 
  503   if ( fAlpha || 
abs(aParticle->GetPDGcode()) == 2112 )
 
  505   G4double epsilon = 11.5*(TotalEnergyDeposit/CLHEP::keV)*pow(z1,(-7./3.));
 
  506   G4double gamma = 3.*pow(epsilon,0.15)+0.7*pow(epsilon,0.6)+epsilon;
 
  507   G4double kappa = 0.133*pow(z1,(2./3.))*pow(a2,(-1./2.))*(2./3.);
 
  509   if ( (z1 == z2 && pDef->GetParticleType() == 
"nucleus") ||
 
  510        particleName == 
"neutron" || particleName == 
"antineutron" ) {
 
  512     if ( z1 == 18 && Phase == kStateLiquid )
 
  517     if ( ElectricField == 0 && Phase == kStateLiquid ) {
 
  518       if ( z1 == 54 ) ThomasImel = 0.19;
 
  519       if ( z1 == 18 ) ThomasImel = 0.25;
 
  522       0.3065*
exp(-0.008806*pow(ElectricField,0.76313));
 
  527   G4double MeanNumberOfQuanta = 
 
  528     ScintillationYield*TotalEnergyDeposit;
 
  531   G4double sigma = sqrt(ResolutionScale*MeanNumberOfQuanta); 
 
  533     G4int(floor(GaussGen.fire(MeanNumberOfQuanta,sigma)+0.5));
 
  535   if (LeffVar > 1) { LeffVar = 1.00000; }
 
  536   if (LeffVar < 0) { LeffVar = 0; }
 
  540   if(TotalEnergyDeposit < 1/ScintillationYield || NumQuanta < 0)
 
  546   G4int NumIons = NumQuanta - NumExcitons;
 
  552   G4double dE, dx=0, LET=0, recombProb;
 
  554   if ( particleName != 
"e-" && particleName != 
"e+" && z1 != z2 &&
 
  555        particleName != 
"mu-" && particleName != 
"mu+" ) {
 
  561     if(LET) dx = dE/(Density*LET); 
 
  562     if(
abs(aParticle->GetPDGcode())==2112) dx=0;
 
  565     dx = aStep.GetStepLength()/CLHEP::cm;
 
  566     if(dx) LET = (dE/dx)*(1/Density); 
 
  567     if ( LET > 0 && dE > 0 && dx > 0 ) {
 
  570            particleName == 
"e-" ) {
 
  571         dx /= ratio; LET *= ratio; }}
 
  573   DokeBirks[1] = DokeBirks[0]/(1-DokeBirks[2]); 
 
  575   recombProb = (DokeBirks[0]*LET)/(1+DokeBirks[1]*LET)+DokeBirks[2];
 
  576   if ( Phase == kStateLiquid ) {
 
  577     if ( z1 == 54 ) recombProb *= (Density/
Density_LXe);
 
  578     if ( z1 == 18 ) recombProb *= (Density/
Density_LAr);
 
  581   if(recombProb<0) recombProb=0;
 
  582   if(recombProb>1) recombProb=1;
 
  586   G4int NumPhotons = NumExcitons + 
BinomFluct(NumIons,recombProb);
 
  587   G4int NumElectrons = NumQuanta - NumPhotons;
 
  598   char numExc[80]; 
char numIon[80]; 
char numPho[80]; 
char numEle[80];
 
  599   sprintf(numExc,
"N_EXC_%i",counter); sprintf(numIon,
"N_ION_%i",counter);
 
  600   aMaterialPropertiesTable->AddConstProperty( numExc, NumExcitons );
 
  601   aMaterialPropertiesTable->AddConstProperty( numIon, NumIons     );
 
  602   sprintf(numPho,
"N_PHO_%i",counter); sprintf(numEle,
"N_ELE_%i",counter);
 
  603   aMaterialPropertiesTable->AddConstProperty( numPho, NumPhotons   );
 
  604   aMaterialPropertiesTable->AddConstProperty( numEle, NumElectrons );
 
  608   char trackL[80]; 
char time00[80]; 
char time01[80]; 
char energy[80];
 
  609   sprintf(trackL,
"TRACK_%i",counter); sprintf(energy,
"ENRGY_%i",counter);
 
  610   sprintf(time00,
"TIME0_%i",counter); sprintf(time01,
"TIME1_%i",counter);
 
  611   delta = aMaterialPropertiesTable->GetConstProperty( trackL );
 
  612   G4double energ = aMaterialPropertiesTable->GetConstProperty( energy );
 
  613   delta += dx*CLHEP::cm; energ += dE*
CLHEP::MeV;
 
  614   aMaterialPropertiesTable->AddConstProperty( trackL, delta );
 
  615   aMaterialPropertiesTable->AddConstProperty( energy, energ );
 
  616   if ( TotalEnergyDeposit > 0 ) {
 
  617     G4double deltaTime = aMaterialPropertiesTable->
 
  618       GetConstProperty( time00 );
 
  621     if (aParticle->GetCharge() != 0) {
 
  623         aMaterialPropertiesTable->AddConstProperty( time00, t0 );
 
  627         aMaterialPropertiesTable->AddConstProperty( time00, t1 );
 
  629     deltaTime = aMaterialPropertiesTable->GetConstProperty( time01 );
 
  632       aMaterialPropertiesTable->AddConstProperty( time01, t1 );
 
  636   TotalEnergyDeposit=aMaterialPropertiesTable->
 
  637     GetConstProperty(
"ENERGY_DEPOSIT_TOT"); 
 
  638   InitialKinetEnergy=aMaterialPropertiesTable->
 
  639     GetConstProperty(
"ENERGY_DEPOSIT_GOL"); 
 
  640   if(InitialKinetEnergy > 
HIENLIM &&
 
  641      abs(aParticle->GetPDGcode()) != 2112) fVeryHighEnergy=
true;
 
  643   if (fVeryHighEnergy && !fExcitedNucleus) safety = 0.2*CLHEP::keV;
 
  644   else safety = 2.*CLHEP::eV;
 
  647   if( !anExcitationEnergy && pDef->GetParticleType() == 
"nucleus" &&
 
  648       aTrack.GetTrackStatus() != fAlive && !fAlpha )
 
  649     InitialKinetEnergy = TotalEnergyDeposit;
 
  650   if ( particleName == 
"neutron" || particleName == 
"antineutron" )
 
  651     InitialKinetEnergy = TotalEnergyDeposit;
 
  656   if( 
std::abs(TotalEnergyDeposit-InitialKinetEnergy)<safety ||
 
  657       TotalEnergyDeposit>=InitialKinetEnergy ){
 
  661     NumPhotons = 0; NumElectrons = 0;
 
  663       sprintf(numPho,
"N_PHO_%d",i); sprintf(numEle,
"N_ELE_%d",i);
 
  664       sprintf(trackL,
"TRACK_%d",i); sprintf(energy,
"ENRGY_%d",i);
 
  666       dx += aMaterialPropertiesTable->GetConstProperty(trackL);
 
  667       dE += aMaterialPropertiesTable->GetConstProperty(energy);
 
  670     G4int buffer = 100; 
if ( fVeryHighEnergy ) buffer = 1;
 
  671     fParticleChange.SetNumberOfSecondaries(buffer*(NumPhotons+NumElectrons));
 
  673     if (fTrackSecondariesFirst) {
 
  674       if (aTrack.GetTrackStatus() == fAlive )
 
  683       sprintf(xCoord,
"POS_X_%d",i); sprintf(yCoord,
"POS_Y_%d",i);
 
  684       sprintf(zCoord,
"POS_Z_%d",i);
 
  685       sprintf(numExc,
"N_EXC_%d",i); sprintf(numIon,
"N_ION_%d",i);
 
  686       sprintf(numPho,
"N_PHO_%d",i); sprintf(numEle,
"N_ELE_%d",i);
 
  687       NumExcitons = (G4int)aMaterialPropertiesTable->
 
  688         GetConstProperty( numExc );
 
  689       NumIons     = (G4int)aMaterialPropertiesTable->
 
  690         GetConstProperty( numIon );
 
  691       sprintf(trackL,
"TRACK_%d",i); sprintf(energy,
"ENRGY_%d",i);
 
  692       sprintf(time00,
"TIME0_%d",i); sprintf(time01,
"TIME1_%d",i);
 
  693       delta = aMaterialPropertiesTable->GetConstProperty( trackL );
 
  694       energ = aMaterialPropertiesTable->GetConstProperty( energy );
 
  695       t0 = aMaterialPropertiesTable->GetConstProperty( time00 );
 
  696       t1 = aMaterialPropertiesTable->GetConstProperty( time01 );
 
  702       if ( (delta < R0 && !fVeryHighEnergy) || z2 == z1 || fAlpha ) {
 
  703         if( z1 == 54 && ElectricField && 
 
  704             Phase == kStateLiquid ) {
 
  705           if ( 
abs ( z1 - z2 ) && 
 
  706                abs ( aParticle->GetPDGcode() ) != 2112 ) {
 
  707             ThomasImel = 0.056776*pow(ElectricField,-0.11844);
 
  709               ThomasImel=0.057675*pow(ElectricField,-0.49362);
 
  715               -0.15169*pow((ElectricField+215.25),0.01811)+0.20952;
 
  718           if (ThomasImel > 0.19) ThomasImel = 0.19;
 
  719           if (ThomasImel < 0.00) ThomasImel = 0.00;
 
  721         if ( Phase == kStateLiquid ) {
 
  722           if ( z1 == 54 ) ThomasImel *= pow((Density/2.84),0.3);
 
  723           if ( z1 == 18 ) ThomasImel *= pow((Density/
Density_LAr),0.3);
 
  730           xi = (G4double(NumIons)/4.)*ThomasImel;
 
  731           if ( InitialKinetEnergy == 9.4*CLHEP::keV ) {
 
  732             G4double NumIonsEff = 1.066e7*pow(t0/CLHEP::ns,-1.303)*
 
  733               (0.17163+162.32/(ElectricField+191.39));
 
  734             if ( NumIonsEff > 1e6 ) NumIonsEff = 1e6;
 
  735             xi = (G4double(NumIonsEff)/4.)*ThomasImel;
 
  737           if ( fKr83m && ElectricField==0 )
 
  738             xi = (G4double(1.3*NumIons)/4.)*ThomasImel;
 
  739           recombProb = 1-log(1+xi)/xi;
 
  740           if(recombProb<0) recombProb=0;
 
  741           if(recombProb>1) recombProb=1;
 
  744         NumPhotons = NumExcitons + 
BinomFluct(NumIons,recombProb);
 
  745         NumElectrons = (NumExcitons + NumIons) - NumPhotons;
 
  747         aMaterialPropertiesTable->
 
  748           AddConstProperty( numPho, NumPhotons   );
 
  749         aMaterialPropertiesTable->
 
  750           AddConstProperty( numEle, NumElectrons );
 
  755       NumPhotons  = (G4int)aMaterialPropertiesTable->
 
  756         GetConstProperty( numPho );
 
  757       NumElectrons =(G4int)aMaterialPropertiesTable->
 
  758         GetConstProperty( numEle );
 
  760       G4double FanoFactor =0; 
 
  763           2575.9*pow((ElectricField+15.154),-0.64064)-1.4707;
 
  764         if ( fKr83m ) TotalEnergyDeposit = 4*CLHEP::keV;
 
  765         if ( (dE/CLHEP::keV) <= 100 && ElectricField >= 0 ) {
 
  766           G4double keVee = (TotalEnergyDeposit/(100.*CLHEP::keV));
 
  768             FanoFactor *= -0.00075+0.4625*keVee+34.375*pow(keVee,2.);
 
  770             FanoFactor *= 0.069554+1.7322*keVee-.80215*pow(keVee,2.);
 
  773       if ( Phase == kStateGas && Density>0.5 ) FanoFactor =
 
  774                                                  0.42857-4.7857*Density+7.8571*pow(Density,2.);
 
  775       if( FanoFactor <= 0 || fVeryHighEnergy ) FanoFactor = 0;
 
  776       NumQuanta = NumPhotons + NumElectrons;
 
  777       if(z1==54 && FanoFactor) NumElectrons = G4int(
 
  778                                                     floor(GaussGen.fire(NumElectrons,
 
  779                                                                              sqrt(FanoFactor*NumElectrons))+0.5));
 
  780       NumPhotons = NumQuanta - NumElectrons;
 
  781       if ( NumElectrons <= 0 ) NumElectrons = 0;
 
  782       if (   NumPhotons <= 0 )   NumPhotons = 0;
 
  787       } NumElectrons = G4int(floor(NumElectrons*
phe_per_e+0.5));
 
  793       if(fKr83m || InitialKinetEnergy==9.4*CLHEP::keV) fKr83m += dE/CLHEP::keV;
 
  794       if(fKr83m > 41) fKr83m = 0;
 
  800       aMaterialPropertiesTable->AddConstProperty( numExc, 0 );
 
  801       aMaterialPropertiesTable->AddConstProperty( numIon, 0 );
 
  802       aMaterialPropertiesTable->AddConstProperty( numPho, 0 );
 
  803       aMaterialPropertiesTable->AddConstProperty( numEle, 0 );
 
  806       if( InitialKinetEnergy < MAX_ENE && InitialKinetEnergy > 
MIN_ENE &&
 
  807           !fMultipleScattering )
 
  808         NumQuanta = NumPhotons + NumElectrons;
 
  810       for(k = 0; k < NumQuanta; k++) {
 
  811         G4double sampledEnergy;
 
  812         std::unique_ptr<G4DynamicParticle> aQuantum;
 
  815         G4double cost = 1. - 2.*UniformGen.fire();
 
  816         G4double sint = std::sqrt((1.-cost)*(1.+cost));
 
  817         G4double phi = CLHEP::twopi*UniformGen.fire();
 
  818         G4double sinp = std::sin(phi); G4double cosp = std::cos(phi);
 
  819         G4double 
px = sint*cosp; G4double 
py = sint*sinp;
 
  823         G4ParticleMomentum photonMomentum(px, py, pz);
 
  826         if (k < NumPhotons) {
 
  828           G4double sx = cost*cosp;
 
  829           G4double sy = cost*sinp;
 
  831           G4ThreeVector photonPolarization(sx, sy, sz);
 
  832           G4ThreeVector perp = photonMomentum.cross(photonPolarization);
 
  833           phi = CLHEP::twopi*UniformGen.fire();
 
  834           sinp = std::sin(phi);
 
  835           cosp = std::cos(phi);
 
  836           photonPolarization = cosp * photonPolarization + sinp * perp;
 
  837           photonPolarization = photonPolarization.unit();
 
  840           sampledEnergy = GaussGen.fire(PhotMean,PhotWidth);
 
  841           aQuantum = std::make_unique<G4DynamicParticle>(G4OpticalPhoton::OpticalPhoton(),
 
  843           aQuantum->SetPolarization(photonPolarization.x(),
 
  844                                     photonPolarization.y(),
 
  845                                     photonPolarization.z());
 
  851             G4ParticleMomentum electronMomentum(0, 0, -FieldSign);
 
  854             if ( Phase == kStateGas ) {
 
  865             sampledEnergy = 1.38e-23*(CLHEP::joule/CLHEP::kelvin)*Temperature;
 
  870         aQuantum->SetKineticEnergy(sampledEnergy);
 
  879         G4double aSecondaryTime = t0+UniformGen.fire()*(t1-
t0)+evtStrt;
 
  880         if (tau1<0) { tau1=0; }
 
  881         if (tau3<0) { tau3=0; }
 
  882         if (tauR<0) { tauR=0; }
 
  883         if ( aQuantum->GetDefinition()->
 
  884              GetParticleName()==
"opticalphoton" ) {
 
  885           if ( 
abs(z2-z1) && !fAlpha && 
 
  886                abs(aParticle->GetPDGcode()) != 2112 ) {
 
  887             LET = (energ/
CLHEP::MeV)/(delta/CLHEP::cm)*(1/Density); 
 
  893             if ( Phase == kStateLiquid && z1 == 54 )
 
  894               tauR = 3.5*((1+0.41*LET)/(0.18*LET))*CLHEP::ns
 
  895                 *
exp(-0.00900*ElectricField);
 
  902             SingTripRatioX = GaussGen.fire(0.17,0.05);
 
  903             SingTripRatioR = GaussGen.fire(0.8,0.2);
 
  905               SingTripRatioR = 0.2701+0.003379*LET-4.7338e-5*pow(LET,2.)
 
  906                 +8.1449e-6*pow(LET,3.); SingTripRatioX = SingTripRatioR;
 
  908                 SingTripRatioX = GaussGen.fire(0.36,0.06);
 
  909                 SingTripRatioR = GaussGen.fire(0.5,0.2); }
 
  913             SingTripRatioR = GaussGen.fire(2.3,0.51);
 
  916             if (z1==18) SingTripRatioR = (-0.065492+1.9996
 
  917                                           *
exp(-dE/CLHEP::MeV))/(1+0.082154/pow(dE/CLHEP::MeV,2.)) + 2.1811;
 
  918             SingTripRatioX = SingTripRatioR;
 
  923             SingTripRatioR = GaussGen.fire(7.8,1.5);
 
  924             if (z1==18) SingTripRatioR = 0.22218*pow(energ/CLHEP::keV,0.48211);
 
  925             SingTripRatioX = SingTripRatioR;
 
  930           if ( k > NumExcitons ) {
 
  933             aSecondaryTime += tauR*(1./UniformGen.fire()-1);
 
  934             if(UniformGen.fire()<SingTripRatioR/(1+SingTripRatioR))
 
  935               aSecondaryTime -= tau1*log(UniformGen.fire());
 
  936             else aSecondaryTime -= tau3*log(UniformGen.fire());
 
  939             if(UniformGen.fire()<SingTripRatioX/(1+SingTripRatioX))
 
  940               aSecondaryTime -= tau1*log(UniformGen.fire());
 
  941             else aSecondaryTime -= tau3*log(UniformGen.fire());
 
  945           G4double gainField = 12;
 
  946           G4double tauTrap = 884.83-62.069*gainField;
 
  947           if ( Phase == kStateLiquid )
 
  948             aSecondaryTime -= tauTrap*CLHEP::ns*log(UniformGen.fire());
 
  957         std::string sx(xCoord);
 
  958         std::string sy(yCoord);
 
  959         std::string sz(zCoord);
 
  960         x0[0] = aMaterialPropertiesTable->GetConstProperty( xCoord );
 
  961         x0[1] = aMaterialPropertiesTable->GetConstProperty( yCoord );
 
  962         x0[2] = aMaterialPropertiesTable->GetConstProperty( zCoord );
 
  963         G4double radius = sqrt(pow(x0[0],2.)+pow(x0[1],2.));
 
  966         if ( radius >= 
R_TOL ) {
 
  967           if (x0[0] == 0) { x0[0] = 1*CLHEP::nm; }
 
  968           if (x0[1] == 0) { x0[1] = 1*CLHEP::nm; }
 
  969           radius -= 
R_TOL; phi = atan ( x0[1] / x0[0] );
 
  970           x0[0] = fabs(radius*cos(phi))*((fabs(x0[0]))/(x0[0]));
 
  971           x0[1] = fabs(radius*sin(phi))*((fabs(x0[1]))/(x0[1]));
 
  974         G4ThreeVector aSecondaryPosition = x0;
 
  975         if ( k >= NumPhotons && 
diffusion && ElectricField > 0 ) {
 
  976           G4double D_T = 64*pow(1
e-3*ElectricField,-.17);
 
  978           G4double D_L = 13.859*pow(1
e-3*ElectricField,-0.58559);
 
  980           if ( Phase == kStateLiquid && z1 == 18 ) {
 
  981             D_T = 93.342*pow(ElectricField/nDensity,0.041322);
 
  983           if ( Phase == kStateGas && z1 == 54 ) {
 
  984             D_L=4.265+19097/ElectricField-1.7397e6/pow(ElectricField,2.)+
 
  985               1.2477e8/pow(ElectricField,3.); D_T *= 0.01;
 
  987           if (ElectricField<100 && Phase == kStateLiquid) D_L = 8*CLHEP::cm2/
CLHEP::s;
 
  988           G4double vDrift = sqrt((2*sampledEnergy)/(
EMASS));
 
  989           if ( 
BORDER == 0 ) x0[2] = 0;
 
  990           G4double sigmaDT = sqrt(2*D_T*fabs(
BORDER-x0[2])/vDrift);
 
  991           G4double sigmaDL = sqrt(2*D_L*fabs(
BORDER-x0[2])/vDrift);
 
  992           G4double dr = 
std::abs(GaussGen.fire(0.,sigmaDT));
 
  993           phi = CLHEP::twopi * UniformGen.fire();
 
  994           aSecondaryPosition[0] += cos(phi) * dr;
 
  995           aSecondaryPosition[1] += sin(phi) * dr;
 
  996           aSecondaryPosition[2] += GaussGen.fire(0.,sigmaDL);
 
  997           radius = std::sqrt(std::pow(aSecondaryPosition[0],2.)+
 
  998                              std::pow(aSecondaryPosition[1],2.));
 
  999           if(aSecondaryPosition[2] >= 
BORDER && Phase == kStateLiquid) {
 
 1001           if(aSecondaryPosition[2] <= 
PMT && !GlobalFields)
 
 1002             aSecondaryPosition[2] = 
PMT + 
R_TOL;
 
 1006         if ( aSecondaryTime < 0 ) aSecondaryTime = 0; 
 
 1017       aMaterialPropertiesTable->AddConstProperty( xCoord, 999*CLHEP::km );
 
 1018       aMaterialPropertiesTable->AddConstProperty( yCoord, 999*CLHEP::km );
 
 1019       aMaterialPropertiesTable->AddConstProperty( zCoord, 999*CLHEP::km );
 
 1020       aMaterialPropertiesTable->AddConstProperty( trackL, 0*CLHEP::um );
 
 1021       aMaterialPropertiesTable->AddConstProperty( energy, 0*CLHEP::eV );
 
 1022       aMaterialPropertiesTable->AddConstProperty( time00, DBL_MAX );
 
 1023       aMaterialPropertiesTable->AddConstProperty( time01, -1*CLHEP::ns );
 
 1028     aMaterialPropertiesTable->
 
 1029       AddConstProperty( 
"TOTALNUM_INT_SITES", 0 );
 
 1030     aMaterialPropertiesTable->
 
 1031       AddConstProperty( 
"ENERGY_DEPOSIT_TOT", 0*CLHEP::keV );
 
 1032     aMaterialPropertiesTable->
 
 1033       AddConstProperty( 
"ENERGY_DEPOSIT_GOL", 0*CLHEP::MeV );
 
 1034     fExcitedNucleus = 
false;
 
G4double GetLiquidElectronDriftSpeed(double T, double F, G4bool M, G4int Z)
double fYieldFactor
turns scint. on/off 
G4VParticleChange fParticleChange
pointer to G4VParticleChange 
util::quantities::megaelectronvolt MeV
int fNumIonElectrons
number of ionization electrons produced by step 
kilovolt_as<> kilovolt
Type of potential stored in kilovolt, in double precision. 
G4int BinomFluct(G4int N0, G4double prob)
bool exists(std::string path)
int fNumScintPhotons
number of photons produced by the step 
auto counter(T begin, T end)
Returns an object to iterate values from begin to end in a range-for loop. 
static G4ThermalElectron * ThermalElectron()
G4double GetGasElectronDriftSpeed(G4double efieldinput, G4double density)
CLHEP::HepRandomEngine & fEngine
random engine 
G4double CalculateElectronLET(G4double E, G4int Z)
void InitMatPropValues(G4MaterialPropertiesTable *nobleElementMat, int z)
process_name physics producers generator physics producers generator physics producers generator py
then echo File list $list not found else cat $list while read file do echo $file sed s
std::map< int, bool > fElementPropInit
TimeTrackTreeStorage::TriggerInputSpec_t convert(TimeTrackTreeStorage::Config::TriggerSpecConfig const &config)
double fEnergyDep
energy deposited by the step