48 #include "G4ParticleTypes.hh" 49 #include "G4EmProcessSubType.hh" 50 #include "G4Version.hh" 52 #include <G4SystemOfUnits.hh> 53 #include <G4PhysicalConstants.hh> 57 #define MIN_ENE -1*CLHEP::eV //lets you turn NEST off BELOW a certain energy 58 #define MAX_ENE 1.*CLHEP::TeV //lets you turn NEST off ABOVE a certain energy 59 #define HIENLIM 5*CLHEP::MeV //energy at which Doke model used exclusively 61 #define R_TOL 0.2*CLHEP::mm //tolerance (for edge events) 62 #define R_MAX 1*CLHEP::km //for corraling diffusing electrons 77 #define Density_LXe 2.9 //reference density for density-dep. effects 78 #define Density_LAr 1.393 79 #define Density_LNe 1.207 80 #define Density_LKr 2.413 84 : G4VRestDiscreteProcess(processName, type)
87 SetProcessSubType(fScintillation);
93 G4cout << GetProcessName() <<
" is created " << G4endl;
112 aParticleChange.Initialize(aTrack);
115 return G4VRestDiscreteProcess::PostStepDoIt(aTrack, aStep);
117 if( aTrack.GetParentID() == 0 && aTrack.GetCurrentStepNumber() == 1 ) {
124 const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
125 G4ParticleDefinition *pDef = aParticle->GetDefinition();
126 G4String particleName = pDef->GetParticleName();
127 const G4Material* aMaterial = aStep.GetPreStepPoint()->GetMaterial();
128 const G4Material* bMaterial = aStep.GetPostStepPoint()->GetMaterial();
130 if((particleName ==
"neutron" || particleName ==
"antineutron") &&
131 aStep.GetTotalEnergyDeposit() <= 0)
132 return G4VRestDiscreteProcess::PostStepDoIt(aTrack, aStep);
139 G4Element *ElementA = NULL, *ElementB = NULL;
140 if (aMaterial && aMaterial->GetMaterialPropertiesTable()) {
141 const G4ElementVector* theElementVector1 =
142 aMaterial->GetElementVector();
143 ElementA = (*theElementVector1)[0];
145 if (bMaterial && bMaterial->GetMaterialPropertiesTable()) {
146 const G4ElementVector* theElementVector2 =
147 bMaterial->GetElementVector();
148 ElementB = (*theElementVector2)[0];
150 G4int z1,z2,j=1; G4bool NobleNow=
false,NobleLater=
false;
151 if (ElementA) z1 = (G4int)(ElementA->GetZ());
else z1 = -1;
152 if (ElementB) z2 = (G4int)(ElementB->GetZ());
else z2 = -1;
153 if ( z1==2 || z1==10 || z1==18 || z1==36 || z1==54 ) {
155 j = (G4int)aMaterial->GetMaterialPropertiesTable()->
156 GetConstProperty(
"TOTALNUM_INT_SITES");
162 if ( z2==2 || z2==10 || z2==18 || z2==36 || z2==54 ) {
164 j = (G4int)bMaterial->GetMaterialPropertiesTable()->
165 GetConstProperty(
"TOTALNUM_INT_SITES");
172 if ( !NobleNow && !NobleLater )
173 return G4VRestDiscreteProcess::PostStepDoIt(aTrack, aStep);
177 G4StepPoint* pPreStepPoint = aStep.GetPreStepPoint();
178 G4StepPoint* pPostStepPoint = aStep.GetPostStepPoint();
179 G4ThreeVector
x1 = pPostStepPoint->GetPosition();
180 G4ThreeVector x0 = pPreStepPoint->GetPosition();
181 G4double evtStrt = pPreStepPoint->GetGlobalTime();
182 G4double
t0 = pPreStepPoint->GetLocalTime();
183 G4double
t1 = pPostStepPoint->GetLocalTime();
189 G4bool outside =
false, inside =
false, InsAndOuts =
false;
190 G4MaterialPropertiesTable* aMaterialPropertiesTable =
191 aMaterial->GetMaterialPropertiesTable();
192 if ( NobleNow && !NobleLater ) outside =
true;
193 if ( !NobleNow && NobleLater ) {
194 aMaterial = bMaterial; inside =
true; z1 = z2;
196 aMaterialPropertiesTable = bMaterial->GetMaterialPropertiesTable();
198 if ( NobleNow && NobleLater &&
199 aMaterial->GetDensity() != bMaterial->GetDensity() )
207 G4double nDensity = Density*
AVO;
208 G4int Phase = aMaterial->GetState();
209 G4double ElectricField, FieldSign;
210 G4bool GlobalFields =
false;
212 ElectricField = aMaterialPropertiesTable->
213 GetConstProperty(
"ELECTRICFIELD"); GlobalFields =
true; }
215 if ( x1[2] <
WIN && x1[2] >
TOP && Phase == kStateGas )
216 ElectricField = aMaterialPropertiesTable->
217 GetConstProperty(
"ELECTRICFIELDWINDOW");
218 else if ( x1[2] <
TOP && x1[2] >
ANE && Phase == kStateGas )
219 ElectricField = aMaterialPropertiesTable->
220 GetConstProperty(
"ELECTRICFIELDTOP");
221 else if ( x1[2] <
ANE && x1[2] >
SRF && Phase == kStateGas )
222 ElectricField = aMaterialPropertiesTable->
223 GetConstProperty(
"ELECTRICFIELDANODE");
224 else if ( x1[2] <
SRF && x1[2] >
GAT && Phase == kStateLiquid )
225 ElectricField = aMaterialPropertiesTable->
226 GetConstProperty(
"ELECTRICFIELDSURFACE");
227 else if ( x1[2] <
GAT && x1[2] >
CTH && Phase == kStateLiquid )
228 ElectricField = aMaterialPropertiesTable->
229 GetConstProperty(
"ELECTRICFIELDGATE");
230 else if ( x1[2] <
CTH && x1[2] >
BOT && Phase == kStateLiquid )
231 ElectricField = aMaterialPropertiesTable->
232 GetConstProperty(
"ELECTRICFIELDCATHODE");
233 else if ( x1[2] <
BOT && x1[2] >
PMT && Phase == kStateLiquid )
234 ElectricField = aMaterialPropertiesTable->
235 GetConstProperty(
"ELECTRICFIELDBOTTOM");
237 ElectricField = aMaterialPropertiesTable->
238 GetConstProperty(
"ELECTRICFIELD");
240 if ( ElectricField >= 0 ) FieldSign = 1;
else FieldSign = -1;
242 G4double Temperature = aMaterial->GetTemperature();
243 G4double ScintillationYield, ResolutionScale, R0 = 1.0*
CLHEP::um,
244 DokeBirks[3], ThomasImel = 0.00, delta = 1*
CLHEP::mm;
245 DokeBirks[0] = 0.00; DokeBirks[2] = 1.00;
250 ScintillationYield = 1 / (41.3*
CLHEP::eV);
252 ResolutionScale = 0.2;
259 ScintillationYield = 1 / (29.2*
CLHEP::eV);
261 ResolutionScale = 0.13;
264 tau3 = G4RandGauss::shoot(15.4e3*
CLHEP::ns,200*CLHEP::ns);
267 ScintillationYield = 1 / (19.5*
CLHEP::eV);
269 ResolutionScale = 0.107;
272 ThomasImel = 0.156977*
pow(ElectricField,-0.1);
273 DokeBirks[0] = 0.07*
pow((ElectricField/1.0e3),-0.85);
278 DokeBirks[0] = 0.0003;
280 } nDensity /= 39.948;
282 tau1 = G4RandGauss::shoot(6.5*CLHEP::ns,0.8*CLHEP::ns);
283 tau3 = G4RandGauss::shoot(1300*CLHEP::ns,50*CLHEP::ns);
284 tauR = G4RandGauss::shoot(0.8*CLHEP::ns,0.2*CLHEP::ns);
287 if ( Phase == kStateGas ) ScintillationYield = 1 / (30.0*
CLHEP::eV);
288 else ScintillationYield = 1 / (15.0*
CLHEP::eV);
290 ResolutionScale = 0.05;
292 tau1 = G4RandGauss::shoot(2.8*CLHEP::ns,.04*CLHEP::ns);
293 tau3 = G4RandGauss::shoot(93.*CLHEP::ns,1.1*CLHEP::ns);
294 tauR = G4RandGauss::shoot(12.*CLHEP::ns,.76*CLHEP::ns);
297 default: nDensity /= 131.293;
298 ScintillationYield = 48.814+0.80877*Density+2.6721*
pow(Density,2.);
303 ResolutionScale = 1.00 *
304 (0.12724-0.032152*Density-0.0013492*
pow(Density,2.));
306 if ( Phase == kStateLiquid ) {
307 ResolutionScale *= 1.5;
313 DokeBirks[0]= 19.171*
pow(ElectricField+25.552,-0.83057)+0.026772;
329 tau1 = G4RandGauss::shoot(3.1*CLHEP::ns,.7*CLHEP::ns);
330 tau3 = G4RandGauss::shoot(24.*CLHEP::ns,1.*CLHEP::ns);
332 else if ( Phase == kStateGas ) {
335 ScintillationYield = 1 / (12.98*
CLHEP::eV); }
337 G4double Townsend = (ElectricField/nDensity)*1e17;
338 DokeBirks[0] = 0.0000;
339 DokeBirks[2] = 0.1933*
pow(Density,2.6199)+0.29754 -
340 (0.045439*
pow(Density,2.4689)+0.066034)*log10(ElectricField);
341 if ( ElectricField>6990 ) DokeBirks[2]=0.0;
342 if ( ElectricField<1000 ) DokeBirks[2]=0.2;
343 if ( ElectricField<100. ) { DokeBirks[0]=0.18; DokeBirks[2]=0.58; }
344 if( Density < 0.061 ) ThomasImel = 0.041973*
pow(Density,1.8105);
345 else if( Density >= 0.061 && Density <= 0.167 )
346 ThomasImel=5.9583e-5+0.0048523*Density-0.023109*
pow(Density,2.);
347 else ThomasImel = 6.2552e-6*
pow(Density,-1.9963);
348 if(ElectricField)ThomasImel=1.2733e-5*
pow(Townsend/Density,-0.68426);
351 tau1 = G4RandGauss::shoot(5.18*CLHEP::ns,1.55*CLHEP::ns);
352 tau3 = G4RandGauss::shoot(100.1*CLHEP::ns,7.9*CLHEP::ns);
360 G4double anExcitationEnergy = ((
const G4Ions*)(pDef))->
361 GetExcitationEnergy();
362 G4double TotalEnergyDeposit =
363 aMaterialPropertiesTable->GetConstProperty(
"ENERGY_DEPOSIT_TOT" );
364 G4bool
convert =
false, annihil =
false;
366 if(pPreStepPoint->GetKineticEnergy()>=(2*CLHEP::electron_mass_c2) &&
367 !pPostStepPoint->GetKineticEnergy() &&
368 !aStep.GetTotalEnergyDeposit() && aParticle->GetPDGcode()==22) {
369 convert =
true; TotalEnergyDeposit = CLHEP::electron_mass_c2;
371 if(pPreStepPoint->GetKineticEnergy() &&
372 !pPostStepPoint->GetKineticEnergy() &&
373 aParticle->GetPDGcode()==-11) {
374 annihil =
true; TotalEnergyDeposit += aStep.GetTotalEnergyDeposit();
376 G4bool either =
false;
377 if(inside || outside || convert || annihil || InsAndOuts) either=
true;
381 return G4VRestDiscreteProcess::PostStepDoIt(aTrack, aStep);
383 if ( !annihil ) TotalEnergyDeposit += aStep.GetTotalEnergyDeposit();
384 if ( !convert ) aMaterialPropertiesTable->
385 AddConstProperty(
"ENERGY_DEPOSIT_TOT", TotalEnergyDeposit );
387 TotalEnergyDeposit = aStep.GetTotalEnergyDeposit();
392 G4double InitialKinetEnergy = aMaterialPropertiesTable->
393 GetConstProperty(
"ENERGY_DEPOSIT_GOL" );
395 if ( InitialKinetEnergy == 0 ) {
396 G4double tE = pPreStepPoint->GetKineticEnergy()+anExcitationEnergy;
399 Phase == kStateLiquid && z1 == 54 ) tE = 9.4*
CLHEP::keV;
400 if (
fKr83m && ElectricField != 0 )
402 aMaterialPropertiesTable->
403 AddConstProperty (
"ENERGY_DEPOSIT_GOL", tE );
411 if(outside){ aMaterialPropertiesTable->
412 AddConstProperty(
"ENERGY_DEPOSIT_GOL",
413 InitialKinetEnergy-pPostStepPoint->GetKineticEnergy());
414 if(aMaterialPropertiesTable->
415 GetConstProperty(
"ENERGY_DEPOSIT_GOL")<0)
416 aMaterialPropertiesTable->AddConstProperty(
"ENERGY_DEPOSIT_GOL",0);
420 if(inside) { aMaterialPropertiesTable->
421 AddConstProperty(
"ENERGY_DEPOSIT_GOL",
422 InitialKinetEnergy+pPreStepPoint->GetKineticEnergy());
423 if ( TotalEnergyDeposit > 0 && InitialKinetEnergy == 0 ) {
424 aMaterialPropertiesTable->AddConstProperty(
"ENERGY_DEPOSIT_GOL",0);
425 TotalEnergyDeposit = .000000;
431 aMaterialPropertiesTable->
432 AddConstProperty(
"ENERGY_DEPOSIT_GOL",(-0.1*
CLHEP::keV)+
433 InitialKinetEnergy-pPostStepPoint->GetKineticEnergy());
434 InitialKinetEnergy = bMaterial->GetMaterialPropertiesTable()->
435 GetConstProperty(
"ENERGY_DEPOSIT_GOL");
436 bMaterial->GetMaterialPropertiesTable()->
437 AddConstProperty(
"ENERGY_DEPOSIT_GOL",(-0.1*
CLHEP::keV)+
438 InitialKinetEnergy+pPreStepPoint->GetKineticEnergy());
439 if(aMaterialPropertiesTable->
440 GetConstProperty(
"ENERGY_DEPOSIT_GOL")<0)
441 aMaterialPropertiesTable->AddConstProperty(
"ENERGY_DEPOSIT_GOL",0);
442 if ( bMaterial->GetMaterialPropertiesTable()->
443 GetConstProperty(
"ENERGY_DEPOSIT_GOL") < 0 )
444 bMaterial->GetMaterialPropertiesTable()->
445 AddConstProperty (
"ENERGY_DEPOSIT_GOL", 0 );
447 InitialKinetEnergy = aMaterialPropertiesTable->
448 GetConstProperty(
"ENERGY_DEPOSIT_GOL");
450 InitialKinetEnergy += 2*CLHEP::electron_mass_c2;
455 InitialKinetEnergy -= 2*CLHEP::electron_mass_c2;
458 aMaterialPropertiesTable->
459 AddConstProperty(
"ENERGY_DEPOSIT_GOL",InitialKinetEnergy);
460 if (anExcitationEnergy < 1
e-100 && aStep.GetTotalEnergyDeposit()==0 &&
461 aMaterialPropertiesTable->GetConstProperty(
"ENERGY_DEPOSIT_GOL")==0 &&
462 aMaterialPropertiesTable->GetConstProperty(
"ENERGY_DEPOSIT_TOT")==0)
463 return G4VRestDiscreteProcess::PostStepDoIt(aTrack, aStep);
466 if ( aTrack.GetCreatorProcess() )
467 procName = aTrack.GetCreatorProcess()->GetProcessName();
482 char xCoord[80];
char yCoord[80];
char zCoord[80];
486 sprintf(xCoord,
"POS_X_%d",i); sprintf(yCoord,
"POS_Y_%d",i);
487 sprintf(zCoord,
"POS_Z_%d",i);
488 pos[0] = aMaterialPropertiesTable->GetConstProperty(xCoord);
489 pos[1] = aMaterialPropertiesTable->GetConstProperty(yCoord);
490 pos[2] = aMaterialPropertiesTable->GetConstProperty(zCoord);
491 if ( sqrt(
pow(x1[0]-pos[0],2.)+
pow(x1[1]-pos[1],2.)+
492 pow(x1[2]-pos[2],2.)) < delta ) {
493 exists =
true;
break;
496 if(!exists && TotalEnergyDeposit) {
498 sprintf(xCoord,
"POS_X_%i",j); sprintf(yCoord,
"POS_Y_%i",j);
499 sprintf(zCoord,
"POS_Z_%i",j);
501 aMaterialPropertiesTable->AddConstProperty( xCoord, x1[0] );
502 aMaterialPropertiesTable->AddConstProperty( yCoord, x1[1] );
503 aMaterialPropertiesTable->AddConstProperty( zCoord, x1[2] );
505 aMaterialPropertiesTable->
506 AddConstProperty(
"TOTALNUM_INT_SITES", j );
514 G4double
a1 = ElementA->GetA();
515 z2 = pDef->GetAtomicNumber();
516 G4double
a2 = (G4double)(pDef->GetAtomicMass());
517 if ( particleName ==
"alpha" || (z2 == 2 && a2 == 4) )
519 if (
fAlpha ||
abs(aParticle->GetPDGcode()) == 2112 )
521 G4double epsilon = 11.5*(TotalEnergyDeposit/
CLHEP::keV)*
pow(z1,(-7./3.));
522 G4double
gamma = 3.*
pow(epsilon,0.15)+0.7*
pow(epsilon,0.6)+epsilon;
523 G4double kappa = 0.133*
pow(z1,(2./3.))*
pow(a2,(-1./2.))*(2./3.);
525 if ( (z1 == z2 && pDef->GetParticleType() ==
"nucleus") ||
526 particleName ==
"neutron" || particleName ==
"antineutron" ) {
528 if ( z1 == 18 && Phase == kStateLiquid )
533 if ( ElectricField == 0 && Phase == kStateLiquid ) {
534 if ( z1 == 54 ) ThomasImel = 0.19;
535 if ( z1 == 18 ) ThomasImel = 0.25;
538 0.3065*exp(-0.008806*
pow(ElectricField,0.76313));
543 G4double MeanNumberOfQuanta =
544 ScintillationYield*TotalEnergyDeposit;
547 G4double sigma = sqrt(ResolutionScale*MeanNumberOfQuanta);
549 G4int(floor(G4RandGauss::shoot(MeanNumberOfQuanta,sigma)+0.5));
551 if (LeffVar > 1) LeffVar = 1.00000;
552 if (LeffVar < 0) LeffVar = 0;
556 if(TotalEnergyDeposit < 1/ScintillationYield || NumQuanta < 0)
562 G4int NumIons = NumQuanta - NumExcitons;
568 G4double dE, dx=0, LET=0, recombProb;
570 if ( particleName !=
"e-" && particleName !=
"e+" && z1 != z2 &&
571 particleName !=
"mu-" && particleName !=
"mu+" ) {
577 if(LET) dx = dE/(Density*LET);
578 if(
abs(aParticle->GetPDGcode())==2112) dx=0;
582 if(dx) LET = (dE/dx)*(1/Density);
583 if ( LET > 0 && dE > 0 && dx > 0 ) {
586 particleName ==
"e-" ) {
589 DokeBirks[1] = DokeBirks[0]/(1-DokeBirks[2]);
591 recombProb = (DokeBirks[0]*LET)/(1+DokeBirks[1]*LET)+DokeBirks[2];
592 if ( Phase == kStateLiquid ) {
593 if ( z1 == 54 ) recombProb *= (Density/
Density_LXe);
594 if ( z1 == 18 ) recombProb *= (Density/
Density_LAr);
597 if(recombProb<0) recombProb=0;
598 if(recombProb>1) recombProb=1;
602 G4int NumPhotons = NumExcitons +
BinomFluct(NumIons,recombProb);
603 G4int NumElectrons = NumQuanta - NumPhotons;
613 G4double nonIonizingEnergy = TotalEnergyDeposit;
614 nonIonizingEnergy *= 1.0*NumPhotons/NumQuanta;
615 aParticleChange.ProposeNonIonizingEnergyDeposit(nonIonizingEnergy);
616 return G4VRestDiscreteProcess::PostStepDoIt(aTrack, aStep);
624 char numExc[80];
char numIon[80];
char numPho[80];
char numEle[80];
625 sprintf(numExc,
"N_EXC_%i",counter); sprintf(numIon,
"N_ION_%i",counter);
626 NumExcitons += (G4int)aMaterialPropertiesTable->
627 GetConstProperty( numExc );
628 NumIons += (G4int)aMaterialPropertiesTable->
629 GetConstProperty( numIon );
630 aMaterialPropertiesTable->AddConstProperty( numExc, NumExcitons );
631 aMaterialPropertiesTable->AddConstProperty( numIon, NumIons );
632 sprintf(numPho,
"N_PHO_%i",counter); sprintf(numEle,
"N_ELE_%i",counter);
633 NumPhotons +=(G4int)aMaterialPropertiesTable->
634 GetConstProperty( numPho );
635 NumElectrons +=(G4int)aMaterialPropertiesTable->
636 GetConstProperty( numEle );
637 aMaterialPropertiesTable->AddConstProperty( numPho, NumPhotons );
638 aMaterialPropertiesTable->AddConstProperty( numEle, NumElectrons );
642 char trackL[80];
char time00[80];
char time01[80];
char energy[80];
643 sprintf(trackL,
"TRACK_%i",counter); sprintf(energy,
"ENRGY_%i",counter);
644 sprintf(time00,
"TIME0_%i",counter); sprintf(time01,
"TIME1_%i",counter);
645 delta = aMaterialPropertiesTable->GetConstProperty( trackL );
646 G4double energ = aMaterialPropertiesTable->GetConstProperty( energy );
648 aMaterialPropertiesTable->AddConstProperty( trackL, delta );
649 aMaterialPropertiesTable->AddConstProperty( energy, energ );
650 if ( TotalEnergyDeposit > 0 ) {
651 G4double deltaTime = aMaterialPropertiesTable->
652 GetConstProperty( time00 );
655 if (aParticle->GetCharge() != 0) {
657 aMaterialPropertiesTable->AddConstProperty( time00, t0 );
661 aMaterialPropertiesTable->AddConstProperty( time00, t1 );
663 deltaTime = aMaterialPropertiesTable->GetConstProperty( time01 );
666 aMaterialPropertiesTable->AddConstProperty( time01, t1 );
670 TotalEnergyDeposit=aMaterialPropertiesTable->
671 GetConstProperty(
"ENERGY_DEPOSIT_TOT");
672 InitialKinetEnergy=aMaterialPropertiesTable->
673 GetConstProperty(
"ENERGY_DEPOSIT_GOL");
674 if(InitialKinetEnergy >
HIENLIM &&
681 if( !anExcitationEnergy && pDef->GetParticleType() ==
"nucleus" &&
682 aTrack.GetTrackStatus() != fAlive && !
fAlpha )
683 InitialKinetEnergy = TotalEnergyDeposit;
684 if ( particleName ==
"neutron" || particleName ==
"antineutron" )
685 InitialKinetEnergy = TotalEnergyDeposit;
690 if( fabs(TotalEnergyDeposit-InitialKinetEnergy)<safety ||
691 TotalEnergyDeposit>=InitialKinetEnergy ){
695 NumPhotons = 0; NumElectrons = 0;
697 sprintf(numPho,
"N_PHO_%d",i); sprintf(numEle,
"N_ELE_%d",i);
698 NumPhotons +=(G4int)aMaterialPropertiesTable->
699 GetConstProperty( numPho );
700 NumElectrons+=(G4int)aMaterialPropertiesTable->
701 GetConstProperty( numEle );
702 sprintf(trackL,
"TRACK_%d",i); sprintf(energy,
"ENRGY_%d",i);
704 dx += aMaterialPropertiesTable->GetConstProperty(trackL);
705 dE += aMaterialPropertiesTable->GetConstProperty(energy);
708 aParticleChange.SetNumberOfSecondaries(
709 buffer*(NumPhotons+NumElectrons));
711 if (aTrack.GetTrackStatus() == fAlive )
712 aParticleChange.ProposeTrackStatus(fSuspend);
719 sprintf(xCoord,
"POS_X_%d",i); sprintf(yCoord,
"POS_Y_%d",i);
720 sprintf(zCoord,
"POS_Z_%d",i);
721 sprintf(numExc,
"N_EXC_%d",i); sprintf(numIon,
"N_ION_%d",i);
722 sprintf(numPho,
"N_PHO_%d",i); sprintf(numEle,
"N_ELE_%d",i);
723 NumExcitons = (G4int)aMaterialPropertiesTable->
724 GetConstProperty( numExc );
725 NumIons = (G4int)aMaterialPropertiesTable->
726 GetConstProperty( numIon );
727 sprintf(trackL,
"TRACK_%d",i); sprintf(energy,
"ENRGY_%d",i);
728 sprintf(time00,
"TIME0_%d",i); sprintf(time01,
"TIME1_%d",i);
729 delta = aMaterialPropertiesTable->GetConstProperty( trackL );
730 energ = aMaterialPropertiesTable->GetConstProperty( energy );
731 t0 = aMaterialPropertiesTable->GetConstProperty( time00 );
732 t1 = aMaterialPropertiesTable->GetConstProperty( time01 );
739 if( z1 == 54 && ElectricField &&
740 Phase == kStateLiquid ) {
741 if (
abs ( z1 - z2 ) &&
742 abs ( aParticle->GetPDGcode() ) != 2112 ) {
743 ThomasImel = 0.056776*
pow(ElectricField,-0.11844);
745 ThomasImel=0.057675*
pow(ElectricField,-0.49362);
751 -0.15169*
pow((ElectricField+215.25),0.01811)+0.20952;
754 if (ThomasImel > 0.19) ThomasImel = 0.19;
755 if (ThomasImel < 0.00) ThomasImel = 0.00;
757 if ( Phase == kStateLiquid ) {
758 if ( z1 == 54 ) ThomasImel *=
pow((Density/2.84),0.3);
766 xi = (G4double(NumIons)/4.)*ThomasImel;
769 (0.17163+162.32/(ElectricField+191.39));
770 if ( NumIonsEff > 1e6 ) NumIonsEff = 1e6;
771 xi = (G4double(NumIonsEff)/4.)*ThomasImel;
773 if (
fKr83m && ElectricField==0 )
774 xi = (G4double(1.3*NumIons)/4.)*ThomasImel;
775 recombProb = 1-log(1+xi)/xi;
776 if(recombProb<0) recombProb=0;
777 if(recombProb>1) recombProb=1;
780 NumPhotons = NumExcitons +
BinomFluct(NumIons,recombProb);
781 NumElectrons = (NumExcitons + NumIons) - NumPhotons;
783 aMaterialPropertiesTable->
784 AddConstProperty( numPho, NumPhotons );
785 aMaterialPropertiesTable->
786 AddConstProperty( numEle, NumElectrons );
791 NumPhotons = (G4int)aMaterialPropertiesTable->
792 GetConstProperty( numPho );
793 NumElectrons =(G4int)aMaterialPropertiesTable->
794 GetConstProperty( numEle );
797 G4double FanoFactor =0;
800 2575.9*
pow((ElectricField+15.154),-0.64064)-1.4707;
802 if ( (dE/
CLHEP::keV) <= 100 && ElectricField >= 0 ) {
803 G4double keVee = (TotalEnergyDeposit/(100.*
CLHEP::keV));
805 FanoFactor *= -0.00075+0.4625*keVee+34.375*
pow(keVee,2.);
807 FanoFactor *= 0.069554+1.7322*keVee-.80215*
pow(keVee,2.);
810 if ( Phase == kStateGas && Density>0.5 ) FanoFactor =
811 0.42857-4.7857*Density+7.8571*
pow(Density,2.);
813 NumQuanta = NumPhotons + NumElectrons;
814 if(z1==54 && FanoFactor) NumElectrons = G4int(
815 floor(G4RandGauss::shoot(NumElectrons,
816 sqrt(FanoFactor*NumElectrons))+0.5));
817 NumPhotons = NumQuanta - NumElectrons;
818 if ( NumElectrons <= 0 ) NumElectrons = 0;
819 if ( NumPhotons <= 0 ) NumPhotons = 0;
824 } NumElectrons = G4int(floor(NumElectrons*
phe_per_e+0.5));
834 aMaterialPropertiesTable->AddConstProperty( numExc, 0 );
835 aMaterialPropertiesTable->AddConstProperty( numIon, 0 );
836 aMaterialPropertiesTable->AddConstProperty( numPho, 0 );
837 aMaterialPropertiesTable->AddConstProperty( numEle, 0 );
840 if( InitialKinetEnergy < MAX_ENE && InitialKinetEnergy >
MIN_ENE &&
842 NumQuanta = NumPhotons + NumElectrons;
844 for(k = 0; k < NumQuanta; k++) {
845 G4double sampledEnergy;
846 G4DynamicParticle* aQuantum;
849 G4double cost = 1. - 2.*G4UniformRand();
850 G4double sint = std::sqrt((1.-cost)*(1.+cost));
852 G4double sinp = std::sin(phi); G4double cosp = std::cos(phi);
853 G4double
px = sint*cosp; G4double
py = sint*sinp;
857 G4ParticleMomentum photonMomentum(px, py, pz);
860 if (k < NumPhotons) {
862 G4double sx = cost*cosp;
863 G4double sy = cost*sinp;
865 G4ThreeVector photonPolarization(sx, sy, sz);
866 G4ThreeVector perp = photonMomentum.cross(photonPolarization);
868 sinp = std::sin(phi);
869 cosp = std::cos(phi);
870 photonPolarization = cosp * photonPolarization + sinp * perp;
871 photonPolarization = photonPolarization.unit();
874 sampledEnergy = G4RandGauss::shoot(PhotMean,PhotWidth);
876 new G4DynamicParticle(G4OpticalPhoton::OpticalPhoton(),
878 aQuantum->SetPolarization(photonPolarization.x(),
879 photonPolarization.y(),
880 photonPolarization.z());
886 G4ParticleMomentum electronMomentum(0, 0, -FieldSign);
890 if ( Phase == kStateGas ) {
909 aQuantum->SetKineticEnergy(sampledEnergy);
911 G4cout <<
"sampledEnergy = " << sampledEnergy << G4endl;
920 G4double aSecondaryTime = t0+G4UniformRand()*(t1-
t0)+evtStrt;
924 if ( aQuantum->GetDefinition()->
925 GetParticleName()==
"opticalphoton" ) {
927 abs(aParticle->GetPDGcode()) != 2112 ) {
934 if ( Phase == kStateLiquid && z1 == 54 )
935 tauR = 3.5*((1+0.41*LET)/(0.18*LET))*
CLHEP::ns 936 *exp(-0.00900*ElectricField);
943 SingTripRatioX = G4RandGauss::shoot(0.17,0.05);
944 SingTripRatioR = G4RandGauss::shoot(0.8,0.2);
946 SingTripRatioR = 0.2701+0.003379*LET-4.7338e-5*
pow(LET,2.)
947 +8.1449e-6*
pow(LET,3.); SingTripRatioX = SingTripRatioR;
949 SingTripRatioX = G4RandGauss::shoot(0.36,0.06);
950 SingTripRatioR = G4RandGauss::shoot(0.5,0.2); }
954 SingTripRatioR = G4RandGauss::shoot(2.3,0.51);
957 if (z1==18) SingTripRatioR = (-0.065492+1.9996
958 *exp(-dE/CLHEP::MeV))/(1+0.082154/
pow(dE/CLHEP::MeV,2.)) + 2.1811;
959 SingTripRatioX = SingTripRatioR;
964 SingTripRatioR = G4RandGauss::shoot(7.8,1.5);
965 if (z1==18) SingTripRatioR = 0.22218*
pow(energ/
CLHEP::keV,0.48211);
966 SingTripRatioX = SingTripRatioR;
971 if ( k > NumExcitons ) {
974 aSecondaryTime += tauR*(1./G4UniformRand()-1);
975 if(G4UniformRand()<SingTripRatioR/(1+SingTripRatioR))
976 aSecondaryTime -= tau1*log(G4UniformRand());
977 else aSecondaryTime -= tau3*log(G4UniformRand());
980 if(G4UniformRand()<SingTripRatioX/(1+SingTripRatioX))
981 aSecondaryTime -= tau1*log(G4UniformRand());
982 else aSecondaryTime -= tau3*log(G4UniformRand());
986 G4double gainField = 12;
987 G4double tauTrap = 884.83-62.069*gainField;
988 if ( Phase == kStateLiquid )
989 aSecondaryTime -= tauTrap*
CLHEP::ns*log(G4UniformRand());
998 x0[0] = aMaterialPropertiesTable->GetConstProperty( xCoord );
999 x0[1] = aMaterialPropertiesTable->GetConstProperty( yCoord );
1000 x0[2] = aMaterialPropertiesTable->GetConstProperty( zCoord );
1001 G4double radius = sqrt(
pow(x0[0],2.)+
pow(x0[1],2.));
1004 if ( radius >=
R_TOL ) {
1007 radius -=
R_TOL; phi = atan ( x0[1] / x0[0] );
1008 x0[0] = fabs(radius*cos(phi))*((fabs(x0[0]))/(x0[0]));
1009 x0[1] = fabs(radius*sin(phi))*((fabs(x0[1]))/(x0[1]));
1012 G4ThreeVector aSecondaryPosition = x0;
1013 if ( k >= NumPhotons &&
diffusion && ElectricField > 0 ) {
1014 G4double D_T = 64*
pow(1
e-3*ElectricField,-.17);
1016 G4double D_L = 13.859*
pow(1
e-3*ElectricField,-0.58559);
1018 if ( Phase == kStateLiquid && z1 == 18 ) {
1019 D_T = 93.342*
pow(ElectricField/nDensity,0.041322);
1021 if ( Phase == kStateGas && z1 == 54 ) {
1022 D_L=4.265+19097/ElectricField-1.7397e6/
pow(ElectricField,2.)+
1023 1.2477e8/
pow(ElectricField,3.); D_T *= 0.01;
1027 if (ElectricField<100 && Phase == kStateLiquid) {
1030 G4double vDrift = sqrt((2*sampledEnergy)/(
EMASS));
1031 if (
BORDER == 0 ) x0[2] = 0;
1032 G4double sigmaDT = sqrt(2*D_T*fabs(
BORDER-x0[2])/vDrift);
1033 G4double sigmaDL = sqrt(2*D_L*fabs(
BORDER-x0[2])/vDrift);
1034 G4double dr = fabs(G4RandGauss::shoot(0.,sigmaDT));
1036 aSecondaryPosition[0] += cos(phi) * dr;
1037 aSecondaryPosition[1] += sin(phi) * dr;
1038 aSecondaryPosition[2] += G4RandGauss::shoot(0.,sigmaDL);
1039 radius = sqrt(
pow(aSecondaryPosition[0],2.)+
1040 pow(aSecondaryPosition[1],2.));
1041 if(aSecondaryPosition[2] >=
BORDER && Phase == kStateLiquid) {
1043 if(aSecondaryPosition[2] <=
PMT && !GlobalFields)
1044 aSecondaryPosition[2] =
PMT +
R_TOL;
1048 if ( aSecondaryTime < 0 ) aSecondaryTime = 0;
1049 G4Track * aSecondaryTrack =
1050 new G4Track(aQuantum,aSecondaryTime,aSecondaryPosition);
1051 if ( k < NumPhotons || radius <
R_MAX )
1052 aParticleChange.AddSecondary(aSecondaryTrack);
1056 aMaterialPropertiesTable->AddConstProperty( xCoord, 999*
CLHEP::km );
1057 aMaterialPropertiesTable->AddConstProperty( yCoord, 999*
CLHEP::km );
1058 aMaterialPropertiesTable->AddConstProperty( zCoord, 999*
CLHEP::km );
1059 aMaterialPropertiesTable->AddConstProperty( trackL, 0*
CLHEP::um );
1060 aMaterialPropertiesTable->AddConstProperty( energy, 0*
CLHEP::eV );
1061 aMaterialPropertiesTable->AddConstProperty( time00, DBL_MAX );
1062 aMaterialPropertiesTable->AddConstProperty( time01, -1*
CLHEP::ns );
1064 if (verboseLevel>0) {
1065 G4cout <<
"\n Exiting from G4S1Light::DoIt -- " 1066 <<
"NumberOfSecondaries = " 1067 << aParticleChange.GetNumberOfSecondaries() << G4endl;
1072 aMaterialPropertiesTable->
1073 AddConstProperty(
"TOTALNUM_INT_SITES", 0 );
1074 aMaterialPropertiesTable->
1075 AddConstProperty(
"ENERGY_DEPOSIT_TOT", 0*
CLHEP::keV );
1076 aMaterialPropertiesTable->
1077 AddConstProperty(
"ENERGY_DEPOSIT_GOL", 0*CLHEP::MeV );
1084 aParticleChange.SetNumberOfSecondaries(0);
1085 return G4VRestDiscreteProcess::PostStepDoIt(aTrack, aStep);
1089 return G4VRestDiscreteProcess::PostStepDoIt(aTrack, aStep);
1096 G4ForceCondition* condition)
1098 *condition = StronglyForced;
1111 G4ForceCondition* condition)
1113 *condition = Forced;
1119 G4bool Miller, G4int
Z) {
1120 if(efieldinput<0) efieldinput *= (-1);
1122 G4double onea=144623.235704015,
1123 oneb=850.812714257629,
1124 onec=1192.87056676815,
1125 oned=-395969.575204061,
1126 onef=-355.484170008875,
1127 oneg=-227.266219627672,
1128 oneh=223831.601257495,
1129 onei=6.1778950907965,
1130 onej=18.7831533426398,
1131 onek=-76132.6018884368;
1133 G4double twoa=17486639.7118995,
1134 twob=-113.174284723134,
1135 twoc=28.005913193763,
1136 twod=167994210.094027,
1137 twof=-6766.42962575088,
1138 twog=901.474643115395,
1139 twoh=-185240292.471665,
1140 twoi=-633.297790813084,
1141 twoj=87.1756135457949;
1143 G4double thra=10626463726.9833,
1144 thrb=224025158.134792,
1145 thrc=123254826.300172,
1146 thrd=-4563.5678061122,
1147 thrf=-1715.269592063,
1148 thrg=-694181.921834368,
1149 thrh=-50.9753281079838,
1150 thri=58.3785811395493,
1151 thrj=201512.080026704;
1152 G4double y1=0,y2=0,
f1=0,
f2=0,
f3=0,edrift=0,
1153 t1=0,t2=0,frac=0,slope=0,intercept=0;
1156 f1=onea/(1+exp(-(efieldinput-oneb)/onec))+oned/
1157 (1+exp(-(efieldinput-onef)/oneg))+
1158 oneh/(1+exp(-(efieldinput-onei)/onej))+onek;
1159 f2=twoa/(1+exp(-(efieldinput-twob)/twoc))+twod/
1160 (1+exp(-(efieldinput-twof)/twog))+
1161 twoh/(1+exp(-(efieldinput-twoi)/twoj));
1162 f3=thra*exp(-thrb*efieldinput)+thrc*exp(-(
pow(efieldinput-thrd,2))/
1164 thrg*exp(-(
pow(efieldinput-thrh,2)/(thri*thri)))+thrj;
1166 if(efieldinput<20 && efieldinput>=0) {
1167 f1=2951*efieldinput;
1168 f2=5312*efieldinput;
1169 f3=7101*efieldinput;
1172 if(tempinput<200.0 && tempinput>165.0) {
1178 if(tempinput<230.0 && tempinput>200.0) {
1184 if((tempinput>230.0 || tempinput<165.0) && !Miller) {
1185 G4cout <<
"\nWARNING: TEMPERATURE OUT OF RANGE (165-230 K)\n";
1188 if (tempinput == 165.0) edrift =
f1;
1189 else if (tempinput == 200.0) edrift =
f2;
1190 else if (tempinput == 230.0) edrift =
f3;
1192 frac=(tempinput-
t1)/(t2-
t1);
1193 slope = (y1-y2)/(
t1-t2);
1194 intercept=y1-slope*
t1;
1195 edrift=slope*tempinput+intercept;
1199 if ( efieldinput <= 40. )
1200 edrift = -0.13274+0.041082*efieldinput-0.0006886*
pow(efieldinput,2.)+
1201 5.5503e-6*
pow(efieldinput,3.);
1203 edrift = 0.060774*efieldinput/
pow(1+0.11336*
pow(efieldinput,0.5218),2.);
1204 if ( efieldinput >= 1e5 ) edrift = 2.7;
1205 if ( efieldinput >= 100 )
1206 edrift -= 0.017 * ( tempinput - 163 );
1208 edrift += 0.017 * ( tempinput - 163 );
1211 if ( Z == 18 ) edrift = 1e5 * (
1212 .097384*
pow(log10(efieldinput),3.0622)-.018614*sqrt(efieldinput) );
1213 if ( edrift < 0 ) edrift = 0.;
1223 if ( E >= 1 ) LET = 58.482-61.183*log10(E)+19.749*
pow(log10(E),2)+
1224 2.3101*
pow(log10(E),3)-3.3469*
pow(log10(E),4)+
1225 0.96788*
pow(log10(E),5)-0.12619*
pow(log10(E),6)+0.0065108*
pow(log10(E),7);
1229 else if ( E>0 && E<1 ) LET = 6.9463+815.98*E-4828*
pow(E,2)+17079*
pow(E,3)-
1230 36394*
pow(E,4)+44553*
pow(E,5)-28659*
pow(E,6)+7483.8*
pow(E,7);
1235 if ( E >= 1 ) LET = 116.70-162.97*log10(E)+99.361*
pow(log10(E),2)-
1236 33.405*
pow(log10(E),3)+6.5069*
pow(log10(E),4)-
1237 0.69334*
pow(log10(E),5)+.031563*
pow(log10(E),6);
1238 else if ( E>0 && E<1 ) LET = 100;
1246 G4double
mean = N0*prob;
1247 G4double sigma = sqrt(N0*prob*(1-prob));
1249 if ( prob == 0.00 )
return N1;
1250 if ( prob == 1.00 )
return N0;
1253 for(G4int i = 0; i < N0; i++) {
1254 if(G4UniformRand() < prob) N1++;
1258 N1 = G4int(floor(G4RandGauss::shoot(mean,sigma)+0.5));
1260 if ( N1 > N0 ) N1 = N0;
1261 if ( N1 < 0 ) N1 = 0;
1266 char xCoord[80];
char yCoord[80];
char zCoord[80];
1267 char numExc[80];
char numIon[80];
char numPho[80];
char numEle[80];
1268 char trackL[80];
char time00[80];
char time01[80];
char energy[80];
1271 for( G4int i=0; i<10000; i++ ) {
1272 sprintf(xCoord,
"POS_X_%d",i); sprintf(yCoord,
"POS_Y_%d",i);
1273 sprintf(zCoord,
"POS_Z_%d",i);
1274 nobleElementMat->AddConstProperty( xCoord, 999*
CLHEP::km );
1275 nobleElementMat->AddConstProperty( yCoord, 999*
CLHEP::km );
1276 nobleElementMat->AddConstProperty( zCoord, 999*
CLHEP::km );
1277 sprintf(numExc,
"N_EXC_%d",i); sprintf(numIon,
"N_ION_%d",i);
1278 sprintf(numPho,
"N_PHO_%d",i); sprintf(numEle,
"N_ELE_%d",i);
1279 nobleElementMat->AddConstProperty( numExc, 0 );
1280 nobleElementMat->AddConstProperty( numIon, 0 );
1281 nobleElementMat->AddConstProperty( numPho, 0 );
1282 nobleElementMat->AddConstProperty( numEle, 0 );
1283 sprintf(trackL,
"TRACK_%d",i); sprintf(energy,
"ENRGY_%d",i);
1284 sprintf(time00,
"TIME0_%d",i); sprintf(time01,
"TIME1_%d",i);
1285 nobleElementMat->AddConstProperty( trackL, 0*
CLHEP::um );
1286 nobleElementMat->AddConstProperty( energy, 0*
CLHEP::eV );
1287 nobleElementMat->AddConstProperty( time00, DBL_MAX );
1288 nobleElementMat->AddConstProperty( time01,-1*
CLHEP::ns );
1294 nobleElementMat->AddConstProperty(
"TOTALNUM_INT_SITES", 0 );
1295 nobleElementMat->AddConstProperty(
"ENERGY_DEPOSIT_TOT", 0*
CLHEP::keV );
1296 nobleElementMat->AddConstProperty(
"ENERGY_DEPOSIT_GOL", 0*
CLHEP::MeV );
1301 G4double a_0 = 5.29e-11*
CLHEP::m; G4double
a = 0.626*a_0*
pow(Z,(-1./3.));
1304 G4double zeta_0 =
pow(Z,(1./6.)); G4double m_N = A*1.66e-27*
CLHEP::kg;
1309 G4double s_n = log(1+1.1383*epsilon)/(2.*(epsilon +
1310 0.01321*
pow(epsilon,0.21226) +
1311 0.19593*sqrt(epsilon)));
1312 G4double s_e = (a_0*zeta_0/
a)*hbar*sqrt(8*epsilon*2.*
CLHEP::twopi*epsilon_0/
1314 return 1.38e5*0.5*(1+tanh(50*epsilon-0.25))*epsilon*(s_e/s_n);
static constexpr double cm
G4double GetGasElectronDriftSpeed(G4double efieldinput, G4double density)
code to link reconstructed objects back to the MC truth information
static constexpr double keV
G4double GetMeanFreePath(const G4Track &aTrack, G4double, G4ForceCondition *)
static constexpr double g
G4double UnivScreenFunc(G4double E, G4double Z, G4double A)
static constexpr double cm3
G4bool fTrackSecondariesFirst
static constexpr double kg
static constexpr double MeV
static constexpr double km
kilovolt_as<> kilovolt
Type of potential stored in kilovolt, in double precision.
void InitMatPropValues(G4MaterialPropertiesTable *nobleElementMat)
bool exists(std::string path)
static G4ThermalElectron * ThermalElectron()
static constexpr double eV
static constexpr double cm2
G4int BinomFluct(G4int N0, G4double prob)
def convert(inputfile, outputfile="wire-cell-garfield-fine-response.json.bz2", average=False, shaped=False)
G4double CalculateElectronLET(G4double E, G4int Z)
G4double GetMeanLifeTime(const G4Track &aTrack, G4ForceCondition *)
double gamma(double KE, const simb::MCParticle *part)
G4VParticleChange * AtRestDoIt(const G4Track &aTrack, const G4Step &aStep)
G4VParticleChange * PostStepDoIt(const G4Track &aTrack, const G4Step &aStep)
static constexpr double mm
G4S1Light(const G4String &processName="S1", G4ProcessType type=fElectromagnetic)
G4bool fMultipleScattering
G4double GetLiquidElectronDriftSpeed(double T, double F, G4bool M, G4int Z)
double mean(sqlite3 *db, std::string const &table_name, std::string const &column_name)