1 #define AVO 6.022e23 //Avogadro's number (#/mol) 2 #define EMASS 9.109e-31*CLHEP::kg 3 #define MillerDriftSpeed true 5 #define GASGAP 0.25*CLHEP::cm //S2 generation region 6 #define BORDER 0*CLHEP::cm //liquid-gas border z-coordinate 8 #define QE_EFF 1 //a base or maximum quantum efficiency 9 #define phe_per_e 1 //S2 gain for quick studies 12 #define WIN 0*CLHEP::mm //top Cu block (also, quartz window) 13 #define TOP 0 //top grid wires 14 #define ANE 0 //anode mesh 15 #define SRF 0 //liquid-gas interface 16 #define GAT 0 //gate grid 17 #define CTH 0 //cathode grid 18 #define BOT 0 //bottom PMT grid 19 #define PMT 0 //bottom Cu block and PMTs 20 #define MIN_ENE -1*CLHEP::eV //lets you turn NEST off BELOW a certain energy 21 #define MAX_ENE 1.*CLHEP::TeV //lets you turn NEST off ABOVE a certain energy 22 #define HIENLIM 5*CLHEP::MeV //energy at which Doke model used exclusively 23 #define R_TOL 0.2*CLHEP::mm //tolerance (for edge events) 24 #define R_MAX 1*CLHEP::km //for corraling diffusing electrons 25 #define Density_LXe 2.9 //reference density for density-dep. effects 26 #define Density_LAr 1.393 27 #define Density_LNe 1.207 28 #define Density_LKr 2.413 30 #include "Geant4/G4Ions.hh" 31 #include "Geant4/G4OpticalPhoton.hh" 32 #include "Geant4/G4VProcess.hh" 37 #include "CLHEP/Random/RandGauss.h" 38 #include "CLHEP/Random/RandFlat.h" 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() )
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;
237 ScintillationYield = 1 / (41.3*
CLHEP::eV);
239 ResolutionScale = 0.2;
246 ScintillationYield = 1 / (29.2*
CLHEP::eV);
248 ResolutionScale = 0.13;
251 tau3 = GaussGen.fire(15.4e3*
CLHEP::ns,200*CLHEP::ns);
254 ScintillationYield = 1 / (19.5*
CLHEP::eV);
256 ResolutionScale = 0.107;
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;
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;
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.);
290 ResolutionScale = 1.00 *
291 (0.12724-0.032152*Density-0.0013492*
pow(Density,2.));
293 if ( Phase == kStateLiquid ) {
294 ResolutionScale *= 1.5;
300 DokeBirks[0]= 19.171*
pow(ElectricField+25.552,-0.83057)+0.026772;
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);
338 tau1 = GaussGen.fire(5.18*CLHEP::ns,1.55*CLHEP::ns);
339 tau3 = GaussGen.fire(100.1*CLHEP::ns,7.9*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;
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;
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;
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;
566 if(dx) LET = (dE/dx)*(1/Density);
567 if ( LET > 0 && dE > 0 && dx > 0 ) {
570 particleName ==
"e-" ) {
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 );
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;
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);
730 xi = (G4double(NumIons)/4.)*ThomasImel;
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));
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));
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);
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 ) {
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 ) {
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());
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 ) {
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;
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));
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;
1051 std::cout <<
"WARNING: NestAlg::GetGasElectronDriftSpeed(G4double, G4double) " 1052 <<
"is not defined, returning bogus value of -999." <<
std::endl;
1060 G4double efieldinput,
1063 if(efieldinput<0) efieldinput *= (-1);
1065 G4double onea=144623.235704015,
1066 oneb=850.812714257629,
1067 onec=1192.87056676815,
1068 oned=-395969.575204061,
1069 onef=-355.484170008875,
1070 oneg=-227.266219627672,
1071 oneh=223831.601257495,
1072 onei=6.1778950907965,
1073 onej=18.7831533426398,
1074 onek=-76132.6018884368;
1076 G4double twoa=17486639.7118995,
1077 twob=-113.174284723134,
1078 twoc=28.005913193763,
1079 twod=167994210.094027,
1080 twof=-6766.42962575088,
1081 twog=901.474643115395,
1082 twoh=-185240292.471665,
1083 twoi=-633.297790813084,
1084 twoj=87.1756135457949;
1086 G4double thra=10626463726.9833,
1087 thrb=224025158.134792,
1088 thrc=123254826.300172,
1089 thrd=-4563.5678061122,
1090 thrf=-1715.269592063,
1091 thrg=-694181.921834368,
1092 thrh=-50.9753281079838,
1093 thri=58.3785811395493,
1094 thrj=201512.080026704;
1095 G4double y1=0,y2=0,
f1=0,
f2=0,
f3=0,edrift=0,
1096 t1=0,t2=0,slope=0,intercept=0;
1099 f1=onea/(1+exp(-(efieldinput-oneb)/onec))+oned/
1100 (1+exp(-(efieldinput-onef)/oneg))+
1101 oneh/(1+exp(-(efieldinput-onei)/onej))+onek;
1102 f2=twoa/(1+exp(-(efieldinput-twob)/twoc))+twod/
1103 (1+exp(-(efieldinput-twof)/twog))+
1104 twoh/(1+exp(-(efieldinput-twoi)/twoj));
1105 f3=thra*exp(-thrb*efieldinput)+thrc*exp(-(
pow(efieldinput-thrd,2))/
1107 thrg*exp(-(
pow(efieldinput-thrh,2)/(thri*thri)))+thrj;
1109 if(efieldinput<20 && efieldinput>=0) {
1110 f1=2951*efieldinput;
1111 f2=5312*efieldinput;
1112 f3=7101*efieldinput;
1115 if(tempinput<200.0 && tempinput>165.0) {
1121 if(tempinput<230.0 && tempinput>200.0) {
1127 if((tempinput>230.0 || tempinput<165.0) && !Miller) {
1128 G4cout <<
"\nWARNING: TEMPERATURE OUT OF RANGE (165-230 K)\n";
1131 if (tempinput == 165.0) edrift =
f1;
1132 else if (tempinput == 200.0) edrift =
f2;
1133 else if (tempinput == 230.0) edrift =
f3;
1136 slope = (y1-y2)/(
t1-t2);
1137 intercept=y1-slope*
t1;
1138 edrift=slope*tempinput+intercept;
1142 if ( efieldinput <= 40. )
1143 edrift = -0.13274+0.041082*efieldinput-0.0006886*
pow(efieldinput,2.)+
1144 5.5503e-6*
pow(efieldinput,3.);
1146 edrift = 0.060774*efieldinput/
pow(1+0.11336*
pow(efieldinput,0.5218),2.);
1147 if ( efieldinput >= 1e5 ) edrift = 2.7;
1148 if ( efieldinput >= 100 )
1149 edrift -= 0.017 * ( tempinput - 163 );
1151 edrift += 0.017 * ( tempinput - 163 );
1154 if ( Z == 18 ) edrift = 1e5 * (.097384*
pow(log10(efieldinput),3.0622)-.018614*sqrt(efieldinput) );
1155 if ( edrift < 0 ) edrift = 0.;
1166 if ( E >= 1 ) LET = 58.482-61.183*log10(E)+19.749*
pow(log10(E),2)+
1167 2.3101*
pow(log10(E),3)-3.3469*
pow(log10(E),4)+
1168 0.96788*
pow(log10(E),5)-0.12619*
pow(log10(E),6)+0.0065108*
pow(log10(E),7);
1172 else if ( E>0 && E<1 ) LET = 6.9463+815.98*E-4828*
pow(E,2)+17079*
pow(E,3)-
1173 36394*
pow(E,4)+44553*
pow(E,5)-28659*
pow(E,6)+7483.8*
pow(E,7);
1178 if ( E >= 1 ) LET = 116.70-162.97*log10(E)+99.361*
pow(log10(E),2)-
1179 33.405*
pow(log10(E),3)+6.5069*
pow(log10(E),4)-
1180 0.69334*
pow(log10(E),5)+.031563*
pow(log10(E),6);
1181 else if ( E>0 && E<1 ) LET = 100;
1190 CLHEP::RandGauss GaussGen(
fEngine);
1191 CLHEP::RandFlat UniformGen(
fEngine);
1193 G4double
mean = N0*prob;
1194 G4double sigma = sqrt(N0*prob*(1-prob));
1196 if ( prob == 0.00 )
return N1;
1197 if ( prob == 1.00 )
return N0;
1200 for(G4int i = 0; i < N0; i++) {
1201 if(UniformGen.fire() < prob) N1++;
1205 N1 = G4int(floor(GaussGen.fire(mean,sigma)+0.5));
1207 if ( N1 > N0 ) N1 = N0;
1208 if ( N1 < 0 ) N1 = 0;
1215 char xCoord[80];
char yCoord[80];
char zCoord[80];
1216 char numExc[80];
char numIon[80];
char numPho[80];
char numEle[80];
1217 char trackL[80];
char time00[80];
char time01[80];
char energy[80];
1220 for( G4int i=0; i<10000; i++ ) {
1221 sprintf(xCoord,
"POS_X_%d",i); sprintf(yCoord,
"POS_Y_%d",i);
1222 sprintf(zCoord,
"POS_Z_%d",i);
1223 nobleElementMat->AddConstProperty( xCoord, 999*
CLHEP::km );
1224 nobleElementMat->AddConstProperty( yCoord, 999*
CLHEP::km );
1225 nobleElementMat->AddConstProperty( zCoord, 999*
CLHEP::km );
1226 sprintf(numExc,
"N_EXC_%d",i); sprintf(numIon,
"N_ION_%d",i);
1227 sprintf(numPho,
"N_PHO_%d",i); sprintf(numEle,
"N_ELE_%d",i);
1228 nobleElementMat->AddConstProperty( numExc, 0 );
1229 nobleElementMat->AddConstProperty( numIon, 0 );
1230 nobleElementMat->AddConstProperty( numPho, 0 );
1231 nobleElementMat->AddConstProperty( numEle, 0 );
1232 sprintf(trackL,
"TRACK_%d",i); sprintf(energy,
"ENRGY_%d",i);
1233 sprintf(time00,
"TIME0_%d",i); sprintf(time01,
"TIME1_%d",i);
1234 nobleElementMat->AddConstProperty( trackL, 0*
CLHEP::um );
1235 nobleElementMat->AddConstProperty( energy, 0*
CLHEP::eV );
1236 nobleElementMat->AddConstProperty( time00, DBL_MAX );
1237 nobleElementMat->AddConstProperty( time01,-1*
CLHEP::ns );
1243 nobleElementMat->AddConstProperty(
"TOTALNUM_INT_SITES", 0 );
1244 nobleElementMat->AddConstProperty(
"ENERGY_DEPOSIT_TOT", 0*
CLHEP::keV );
1245 nobleElementMat->AddConstProperty(
"ENERGY_DEPOSIT_GOL", 0*
CLHEP::MeV );
1254 G4double a_0 = 5.29e-11*
CLHEP::m; G4double
a = 0.626*a_0*
pow(Z,(-1./3.));
1257 G4double zeta_0 =
pow(Z,(1./6.)); G4double m_N = A*1.66e-27*
CLHEP::kg;
1262 G4double s_n = log(1+1.1383*epsilon)/(2.*(epsilon +
1263 0.01321*
pow(epsilon,0.21226) +
1264 0.19593*sqrt(epsilon)));
1265 G4double s_e = (a_0*zeta_0/
a)*hbar*sqrt(8*epsilon*2.*
CLHEP::twopi*epsilon_0/
1267 return 1.38e5*0.5*(1+tanh(50*epsilon-0.25))*epsilon*(s_e/s_n);
static constexpr double cm
code to link reconstructed objects back to the MC truth information
static constexpr double keV
static constexpr double g
G4double GetLiquidElectronDriftSpeed(double T, double F, G4bool M, G4int Z)
static constexpr double cm3
NestAlg(CLHEP::HepRandomEngine &engine)
static constexpr double kg
double fYieldFactor
turns scint. on/off
static constexpr double MeV
static constexpr double km
G4VParticleChange fParticleChange
pointer to G4VParticleChange
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
static G4ThermalElectron * ThermalElectron()
static constexpr double eV
static constexpr double cm2
const G4VParticleChange & CalculateIonizationAndScintillation(G4Track const &aTrack, G4Step const &aStep)
def convert(inputfile, outputfile="wire-cell-garfield-fine-response.json.bz2", average=False, shaped=False)
G4double UnivScreenFunc(G4double E, G4double Z, G4double A)
G4double GetGasElectronDriftSpeed(G4double efieldinput, G4double density)
CLHEP::HepRandomEngine & fEngine
random engine
G4double CalculateElectronLET(G4double E, G4int Z)
double gamma(double KE, const simb::MCParticle *part)
void InitMatPropValues(G4MaterialPropertiesTable *nobleElementMat, int z)
std::map< int, bool > fElementPropInit
static constexpr double mm
double mean(sqlite3 *db, std::string const &table_name, std::string const &column_name)
double fEnergyDep
energy deposited by the step
QTextStream & endl(QTextStream &s)