114 fTrackSecondariesFirst(false),
115 fFiniteRiseTime(false),
117 fExcitationRatio(1.0),
118 fScintillationByParticleType(false),
119 fScintillationTrackInfo(false),
122 fEmSaturation(nullptr)
126 #ifdef G4DEBUG_SCINTILLATION
128 ScintTrackYield = 0.;
216 if (!aMaterialPropertiesTable)
220 aMaterialPropertiesTable->
GetProperty(
"FASTCOMPONENT");
222 aMaterialPropertiesTable->
GetProperty(
"SLOWCOMPONENT");
224 if (!Fast_Intensity && !Slow_Intensity )
228 if (Fast_Intensity && Slow_Intensity) nscnt = 2;
233 if (fScintillationByParticleType) {
241 ScintillationYield = aMaterialPropertiesTable->
242 GetConstProperty(
"SCINTILLATIONYIELD");
245 ScintillationYield *= fYieldFactor;
248 G4double ResolutionScale = aMaterialPropertiesTable->
249 GetConstProperty(
"RESOLUTIONSCALE");
262 if (fScintillationByParticleType)
263 MeanNumberOfPhotons = ScintillationYield;
264 else if (fEmSaturation)
265 MeanNumberOfPhotons = ScintillationYield*
268 MeanNumberOfPhotons = ScintillationYield*TotalEnergyDeposit;
270 if (MeanNumberOfPhotons > 10.)
272 G4double sigma = ResolutionScale * std::sqrt(MeanNumberOfPhotons);
280 if ( fNumPhotons <= 0 || !fStackingFlag )
293 if (fTrackSecondariesFirst) {
305 G4int Num = fNumPhotons;
307 for (
G4int scnt = 1; scnt <= nscnt; scnt++) {
316 if (Fast_Intensity) {
317 ScintillationTime = aMaterialPropertiesTable->
318 GetConstProperty(
"FASTTIMECONSTANT");
319 if (fFiniteRiseTime) {
320 ScintillationRiseTime = aMaterialPropertiesTable->
321 GetConstProperty(
"FASTSCINTILLATIONRISETIME");
323 ScintillationType =
Fast;
324 ScintillationIntegral =
328 if (Slow_Intensity) {
329 ScintillationTime = aMaterialPropertiesTable->
330 GetConstProperty(
"SLOWTIMECONSTANT");
331 if (fFiniteRiseTime) {
332 ScintillationRiseTime = aMaterialPropertiesTable->
333 GetConstProperty(
"SLOWSCINTILLATIONRISETIME");
335 ScintillationType =
Slow;
336 ScintillationIntegral =
342 G4double yieldRatio = aMaterialPropertiesTable->
343 GetConstProperty(
"YIELDRATIO");
344 if ( fExcitationRatio == 1.0 || fExcitationRatio == 0.0) {
350 ScintillationTime = aMaterialPropertiesTable->
351 GetConstProperty(
"FASTTIMECONSTANT");
352 if (fFiniteRiseTime) {
353 ScintillationRiseTime = aMaterialPropertiesTable->
354 GetConstProperty(
"FASTSCINTILLATIONRISETIME");
356 ScintillationType =
Fast;
357 ScintillationIntegral =
363 Num = fNumPhotons - Num;
364 ScintillationTime = aMaterialPropertiesTable->
365 GetConstProperty(
"SLOWTIMECONSTANT");
366 if (fFiniteRiseTime) {
367 ScintillationRiseTime = aMaterialPropertiesTable->
368 GetConstProperty(
"SLOWSCINTILLATIONRISETIME");
370 ScintillationType =
Slow;
371 ScintillationIntegral =
376 if (!ScintillationIntegral)
continue;
382 for (
G4int i = 0; i < Num; i++) {
388 ScintillationIntegral->
GetEnergy(CIIvalue);
391 G4cout <<
"sampledEnergy = " << sampledEnergy <<
G4endl;
398 G4double sint = std::sqrt((1.-cost)*(1.+cost));
423 sinp = std::sin(phi);
424 cosp = std::cos(phi);
426 photonPolarization = cosp * photonPolarization + sinp * perp;
428 photonPolarization = photonPolarization.
unit();
436 (photonPolarization.
x(),
437 photonPolarization.
y(),
438 photonPolarization.
z());
458 if (ScintillationRiseTime==0.0) {
459 deltaTime = deltaTime -
462 deltaTime = deltaTime +
463 sample_time(ScintillationRiseTime, ScintillationTime);
466 G4double aSecondaryTime = t0 + deltaTime;
481 if (fScintillationTrackInfo) aSecondaryTrack->
490 G4cout <<
"\n Exiting from G4Scintillation::DoIt -- NumberOfSecondaries = "
518 for (
G4int i=0 ; i < numOfMaterials; i++)
528 G4Material* aMaterial = (*theMaterialTable)[i];
533 if (aMaterialPropertiesTable) {
536 aMaterialPropertiesTable->
GetProperty(
"FASTCOMPONENT");
538 if (theFastLightVector) {
543 G4double currentIN = (*theFastLightVector)[0];
545 if (currentIN >= 0.0) {
554 aPhysicsOrderedFreeVector->
555 InsertValues(currentPM , currentCII);
570 currentPM = theFastLightVector->
Energy(ii);
571 currentIN = (*theFastLightVector)[ii];
573 currentCII = 0.5 * (prevIN + currentIN);
575 currentCII = prevCII +
576 (currentPM - prevPM) * currentCII;
578 aPhysicsOrderedFreeVector->
579 InsertValues(currentPM, currentCII);
582 prevCII = currentCII;
590 aMaterialPropertiesTable->
GetProperty(
"SLOWCOMPONENT");
592 if (theSlowLightVector) {
597 G4double currentIN = (*theSlowLightVector)[0];
599 if (currentIN >= 0.0) {
608 bPhysicsOrderedFreeVector->
609 InsertValues(currentPM , currentCII);
624 currentPM = theSlowLightVector->
Energy(ii);
625 currentIN = (*theSlowLightVector)[ii];
627 currentCII = 0.5 * (prevIN + currentIN);
629 currentCII = prevCII +
630 (currentPM - prevPM) * currentCII;
632 bPhysicsOrderedFreeVector->
633 InsertValues(currentPM, currentCII);
636 prevCII = currentCII;
657 G4Exception(
"G4Scintillation::SetScintillationByParticleType",
"Scint02",
658 JustWarning,
"Redefinition: Birks Saturation is replaced by ScintillationByParticleType!");
661 fScintillationByParticleType = scintType;
706 G4double t = -1.0*tau2*std::log(1-ran1);
708 if (ran2 <= bi_exp(t,tau1,tau2)/gg)
return t;
732 Scint_Yield_Vector = aMaterialPropertiesTable->
733 GetProperty(
"PROTONSCINTILLATIONYIELD");
737 Scint_Yield_Vector = aMaterialPropertiesTable->
738 GetProperty(
"DEUTERONSCINTILLATIONYIELD");
742 Scint_Yield_Vector = aMaterialPropertiesTable->
743 GetProperty(
"TRITONSCINTILLATIONYIELD");
747 Scint_Yield_Vector = aMaterialPropertiesTable->
748 GetProperty(
"ALPHASCINTILLATIONYIELD");
754 Scint_Yield_Vector = aMaterialPropertiesTable->
755 GetProperty(
"IONSCINTILLATIONYIELD");
761 Scint_Yield_Vector = aMaterialPropertiesTable->
762 GetProperty(
"ELECTRONSCINTILLATIONYIELD");
766 Scint_Yield_Vector = aMaterialPropertiesTable->
767 GetProperty(
"ELECTRONSCINTILLATIONYIELD");
771 if(!Scint_Yield_Vector)
772 Scint_Yield_Vector = aMaterialPropertiesTable->
773 GetProperty(
"ELECTRONSCINTILLATIONYIELD");
776 if (!Scint_Yield_Vector) {
778 ed <<
"\nG4Scintillation::PostStepDoIt(): "
779 <<
"Request for scintillation yield for energy deposit and particle\n"
780 <<
"type without correct entry in MaterialPropertiesTable.\n"
781 <<
"ScintillationByParticleType requires at minimum that \n"
782 <<
"ELECTRONSCINTILLATIONYIELD is set by the user\n"
784 G4String comments =
"Missing MaterialPropertiesTable entry - No correct entry in MaterialPropertiesTable";
785 G4Exception(
"G4Scintillation::PostStepDoIt",
"Scint01",
802 if(PreStepKineticEnergy <= Scint_Yield_Vector->GetMaxEnergy()){
803 G4double Yield1 = Scint_Yield_Vector->
Value(PreStepKineticEnergy);
804 G4double Yield2 = Scint_Yield_Vector->
805 Value(PreStepKineticEnergy - StepEnergyDeposit);
806 ScintillationYield = Yield1 - Yield2;
809 ed <<
"\nG4Scintillation::GetScintillationYieldByParticleType(): Request\n"
810 <<
"for scintillation light yield above the available energy range\n"
811 <<
"specifed in G4MaterialPropertiesTable. A linear interpolation\n"
812 <<
"will be performed to compute the scintillation light yield using\n"
813 <<
"(L_max / E_max) as the photon yield per unit energy."
815 G4String cmt =
"\nScintillation yield may be unphysical!\n";
816 G4Exception(
"G4Scintillation::GetScintillationYieldByParticleType()",
823 ScintillationYield = LinearYield * StepEnergyDeposit;
826 #ifdef G4DEBUG_SCINTILLATION
829 ScintTrackYield += ScintillationYield;
830 ScintTrackEDep += StepEnergyDeposit;
832 G4cout <<
"\n--- G4Scintillation::GetScintillationYieldByParticleType() ---\n"
835 <<
"-- TrackID = " << aTrack.
GetTrackID() <<
"\n"
836 <<
"-- ParentID = " << aTrack.
GetParentID() <<
"\n"
839 <<
"-- Track EDep = " << ScintTrackEDep/
MeV <<
" MeV\n"
841 <<
"-- Step yield = " << ScintillationYield <<
" photons\n"
842 <<
"-- Track yield = " << ScintTrackYield <<
" photons\n"
851 ScintTrackYield = 0.;
856 return ScintillationYield;
void SetScintillationByParticleType(const G4bool)
G4double condition(const G4ErrorSymMatrix &m)
G4Scintillation(const G4String &processName="Scintillation", G4ProcessType type=fElectromagnetic)
static G4Electron * ElectronDefinition()
static G4Triton * TritonDefinition()
G4int GetParentID() const
ThreeVector shoot(const G4int Ap, const G4int Af)
G4long G4Poisson(G4double mean)
G4int GetNumberOfSecondaries() const
G4double GetMaxEnergy() const
virtual G4VParticleChange * PostStepDoIt(const G4Track &, const G4Step &)
std::ostringstream G4ExceptionDescription
void BuildThePhysicsTable()
G4double GetStepLength() const
const G4DynamicParticle * GetDynamicParticle() const
G4PhysicsTable * fFastIntegralTable
G4StepStatus GetStepStatus() const
G4TrackStatus GetTrackStatus() const
static G4MaterialTable * GetMaterialTable()
static G4Proton * ProtonDefinition()
std::vector< G4Material * > G4MaterialTable
G4PhysicsTable * fSlowIntegralTable
G4VParticleChange * PostStepDoIt(const G4Track &aTrack, const G4Step &aStep) override
void SetTouchableHandle(const G4TouchableHandle &apValue)
G4ParticleDefinition * GetDefinition() const
void BuildPhysicsTable(const G4ParticleDefinition &aParticleType) override
G4double GetVelocity() const
size_t GetVectorLength() const
const G4String & GetParticleName() const
static constexpr double twopi
G4StepPoint * GetPreStepPoint() const
G4double GetKineticEnergy() const
G4double GetMeanLifeTime(const G4Track &aTrack, G4ForceCondition *) override
G4GLOB_DLL std::ostream G4cout
G4double GetVertexKineticEnergy() const
const G4ThreeVector & GetPosition() const
const G4ParticleDefinition * GetParticleDefinition() const
void SetProcessSubType(G4int)
const G4String & GetParticleType() const
void SetPolarization(G4double polX, G4double polY, G4double polZ)
G4double Energy(size_t index) const
G4double Value(G4double theEnergy, size_t &lastidx) const
static size_t GetNumberOfMaterials()
const G4String & GetProcessName() const
G4double VisibleEnergyDepositionAtAStep(const G4Step *) const
void SetKineticEnergy(G4double aEnergy)
G4double GetEnergy(G4double aValue)
G4double GetTotalEnergyDeposit() const
G4Material * GetMaterial() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
static G4OpticalPhoton * OpticalPhoton()
virtual void Initialize(const G4Track &)
G4MaterialPropertiesTable * GetMaterialPropertiesTable() const
void SetNumberOfSecondaries(G4int totSecondaries)
void SetParentID(const G4int aValue)
G4StepPoint * GetPostStepPoint() const
G4ParticleChange aParticleChange
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
void AddSecondary(G4Track *aSecondary)
void insertAt(size_t, G4PhysicsVector *)
G4double GetGlobalTime() const
static constexpr double MeV
Hep3Vector cross(const Hep3Vector &) const
G4double GetMeanFreePath(const G4Track &aTrack, G4double, G4ForceCondition *) override
G4double GetKineticEnergy() const
void ProposeTrackStatus(G4TrackStatus status)
G4double GetPDGCharge() const
G4ThreeVector GetDeltaPosition() const
G4double GetScintillationYieldByParticleType(const G4Track &aTrack, const G4Step &aStep)
static G4Deuteron * DeuteronDefinition()
static G4Alpha * AlphaDefinition()
static G4Neutron * NeutronDefinition()
G4MaterialPropertyVector * GetProperty(const char *key)
const G4TouchableHandle & GetTouchableHandle() const
G4VParticleChange * AtRestDoIt(const G4Track &aTrack, const G4Step &aStep) override
static G4Gamma * GammaDefinition()