91 , fIntegralTable1(nullptr)
92 , fIntegralTable2(nullptr)
93 , fIntegralTable3(nullptr)
94 , fEmSaturation(nullptr)
100#ifdef G4DEBUG_SCINTILLATION
102 ScintTrackYield = 0.;
115 if(fIntegralTable1 !=
nullptr)
118 delete fIntegralTable1;
120 if(fIntegralTable2 !=
nullptr)
123 delete fIntegralTable2;
125 if(fIntegralTable3 !=
nullptr)
128 delete fIntegralTable3;
135 out <<
"Scintillation simulates production of optical photons produced\n"
136 "by a high energy particle traversing matter.\n"
137 "Various material properties need to be defined.\n";
180 if(fIntegralTable1 !=
nullptr)
183 delete fIntegralTable1;
184 fIntegralTable1 =
nullptr;
186 if(fIntegralTable2 !=
nullptr)
189 delete fIntegralTable2;
190 fIntegralTable2 =
nullptr;
192 if(fIntegralTable3 !=
nullptr)
195 delete fIntegralTable3;
196 fIntegralTable3 =
nullptr;
210 for(std::size_t i = 0; i < numOfMaterials; ++i)
219 ((*materialTable)[i])->GetMaterialPropertiesTable();
235 vector1->InsertValues(currentPM, currentCII);
246 currentPM = MPV->
Energy(ii);
247 currentIN = (*MPV)[ii];
249 prevCII + 0.5 * (currentPM - prevPM) * (prevIN + currentIN);
251 vector1->InsertValues(currentPM, currentCII);
254 prevCII = currentCII;
271 vector2->InsertValues(currentPM, currentCII);
282 currentPM = MPV->
Energy(ii);
283 currentIN = (*MPV)[ii];
285 prevCII + 0.5 * (currentPM - prevPM) * (prevIN + currentIN);
287 vector2->InsertValues(currentPM, currentCII);
290 prevCII = currentCII;
306 vector3->InsertValues(currentPM, currentCII);
317 currentPM = MPV->
Energy(ii);
318 currentIN = (*MPV)[ii];
320 prevCII + 0.5 * (currentPM - prevPM) * (prevIN + currentIN);
322 vector3->InsertValues(currentPM, currentCII);
325 prevCII = currentCII;
331 fIntegralTable1->
insertAt(i, vector1);
332 fIntegralTable2->
insertAt(i, vector2);
333 fIntegralTable3->
insertAt(i, vector3);
373 G4int N_timeconstants = 1;
393 if(fScintillationByParticleType)
396 aTrack, aStep, yield1, yield2, yield3);
415 MeanNumberOfPhotons *=
418 MeanNumberOfPhotons *= TotalEnergyDeposit;
420 sum_yields = yield1 + yield2 + yield3;
422 if(MeanNumberOfPhotons > 10.)
424 G4double sigma = ResolutionScale * std::sqrt(MeanNumberOfPhotons);
425 fNumPhotons =
G4int(G4RandGauss::shoot(MeanNumberOfPhotons, sigma) + 0.5);
432 if(fNumPhotons <= 0 || !fStackingFlag)
441 if(fTrackSecondariesFirst)
451 std::size_t numPhot = fNumPhotons;
457 for(
G4int scnt = 0; scnt < N_timeconstants; ++scnt)
462 if(N_timeconstants == 1)
464 numPhot = fNumPhotons;
468 numPhot = yield1 / sum_yields * fNumPhotons;
482 if(N_timeconstants == 2)
484 numPhot = fNumPhotons - numPhot;
488 numPhot = yield2 / sum_yields * fNumPhotons;
501 numPhot = yield3 / sum_yields * fNumPhotons;
516 for(std::size_t i = 0; i < numPhot; ++i)
524 G4cout <<
"sampledEnergy = " << sampledEnergy <<
G4endl;
530 G4double sint = std::sqrt((1. - cost) * (1. + cost));
537 G4ThreeVector photonPolarization(cost * cosp, cost * sinp, -sint);
540 sinp = std::sin(phi);
541 cosp = std::cos(phi);
542 photonPolarization = (cosp * photonPolarization + sinp * perp).unit();
546 scintPhoton->SetPolarization(photonPolarization);
547 scintPhoton->SetKineticEnergy(sampledEnergy);
569 deltaTime += sample_time(riseTime, scintTime);
575 G4Track* secTrack =
new G4Track(scintPhoton, secTime, secPosition);
580 if(fScintillationTrackInfo)
589 G4cout <<
"\n Exiting from G4Scintillation::DoIt -- NumberOfSecondaries = "
626 G4double t = -1.0 * tau2 * std::log(1. - ran1);
627 G4double gg = d * single_exp(t, tau2);
628 if(ran2 <= bi_exp(t, tau1, tau2) / gg)
746 ed <<
"\nG4Scintillation::PostStepDoIt(): "
747 <<
"Request for scintillation yield for energy deposit and particle\n"
748 <<
"type without correct entry in MaterialPropertiesTable.\n"
749 <<
"ScintillationByParticleType requires at minimum that \n"
750 <<
"ELECTRONSCINTILLATIONYIELD is set by the user\n"
752 G4String comments =
"Missing MaterialPropertiesTable entry - No correct "
753 "entry in MaterialPropertiesTable";
769 if(PreStepKineticEnergy <= yieldVector->GetMaxEnergy())
775 yieldVector->
Value(PreStepKineticEnergy) -
776 yieldVector->
Value(PreStepKineticEnergy - StepEnergyDeposit);
781 ed <<
"\nG4Scintillation::GetScintillationYieldByParticleType(): Request\n"
782 <<
"for scintillation light yield above the available energy range\n"
783 <<
"specified in G4MaterialPropertiesTable. A linear interpolation\n"
784 <<
"will be performed to compute the scintillation light yield using\n"
785 <<
"(L_max / E_max) as the photon yield per unit energy." <<
G4endl;
786 G4String cmt =
"\nScintillation yield may be unphysical!\n";
787 G4Exception(
"G4Scintillation::GetScintillationYieldByParticleType()",
795#ifdef G4DEBUG_SCINTILLATION
797 ScintTrackYield += ScintillationYield;
798 ScintTrackEDep += StepEnergyDeposit;
800 G4cout <<
"\n--- G4Scintillation::GetScintillationYieldByParticleType() ---\n"
804 <<
"-- TrackID = " << aTrack.
GetTrackID() <<
"\n"
805 <<
"-- ParentID = " << aTrack.
GetParentID() <<
"\n"
810 <<
"-- Track EDep = " << ScintTrackEDep / MeV <<
" MeV\n"
813 <<
"-- Step yield = " << ScintillationYield <<
" photons\n"
814 <<
"-- Track yield = " << ScintTrackYield <<
" photons\n"
823 ScintTrackYield = 0.;
827 return ScintillationYield;
835 for(std::size_t i = 0; i < fIntegralTable1->
entries(); ++i)
842 for(std::size_t i = 0; i < fIntegralTable2->
entries(); ++i)
849 for(std::size_t i = 0; i < fIntegralTable3->
entries(); ++i)
859 fTrackSecondariesFirst = state;
861 fTrackSecondariesFirst);
867 fFiniteRiseTime = state;
874 if(fEmSaturation && scintType)
876 G4Exception(
"G4Scintillation::SetScintillationByParticleType",
"Scint02",
878 "Redefinition: Birks Saturation is replaced by "
879 "ScintillationByParticleType!");
882 fScintillationByParticleType = scintType;
884 fScintillationByParticleType);
890 fScintillationTrackInfo = trackType;
897 fStackingFlag = stackingFlag;
G4double condition(const G4ErrorSymMatrix &m)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
@ kSCINTILLATIONCOMPONENT1
@ kSCINTILLATIONCOMPONENT2
@ kSCINTILLATIONCOMPONENT3
@ kELECTRONSCINTILLATIONYIELD
@ kALPHASCINTILLATIONYIELD
@ kPROTONSCINTILLATIONYIELD
@ kDEUTERONSCINTILLATIONYIELD
@ kTRITONSCINTILLATIONYIELD
@ kSCINTILLATIONTIMECONSTANT1
@ kSCINTILLATIONRISETIME2
@ kTRITONSCINTILLATIONYIELD1
@ kDEUTERONSCINTILLATIONYIELD3
@ kIONSCINTILLATIONYIELD1
@ kSCINTILLATIONRISETIME1
@ kDEUTERONSCINTILLATIONYIELD2
@ kTRITONSCINTILLATIONYIELD2
@ kALPHASCINTILLATIONYIELD2
@ kELECTRONSCINTILLATIONYIELD3
@ kALPHASCINTILLATIONYIELD1
@ kELECTRONSCINTILLATIONYIELD2
@ kIONSCINTILLATIONYIELD2
@ kIONSCINTILLATIONYIELD3
@ kSCINTILLATIONRISETIME3
@ kPROTONSCINTILLATIONYIELD2
@ kDEUTERONSCINTILLATIONYIELD1
@ kTRITONSCINTILLATIONYIELD3
@ kSCINTILLATIONTIMECONSTANT3
@ kPROTONSCINTILLATIONYIELD3
@ kELECTRONSCINTILLATIONYIELD1
@ kALPHASCINTILLATIONYIELD3
@ kSCINTILLATIONTIMECONSTANT2
@ kPROTONSCINTILLATIONYIELD1
std::vector< G4Material * > G4MaterialTable
G4long G4Poisson(G4double mean)
G4GLOB_DLL std::ostream G4cout
Hep3Vector cross(const Hep3Vector &) const
static G4Alpha * AlphaDefinition()
static G4Deuteron * DeuteronDefinition()
G4ParticleDefinition * GetDefinition() const
G4double VisibleEnergyDepositionAtAStep(const G4Step *) const
G4bool ConstPropertyExists(const G4String &key) const
G4double GetConstProperty(const G4String &key) const
G4MaterialPropertyVector * GetProperty(const char *key) const
G4MaterialPropertiesTable * GetMaterialPropertiesTable() const
static size_t GetNumberOfMaterials()
static G4MaterialTable * GetMaterialTable()
static G4Neutron * NeutronDefinition()
void SetScintByParticleType(G4bool)
void SetScintTrackSecondariesFirst(G4bool)
G4int GetScintVerboseLevel() const
void SetScintVerboseLevel(G4int)
void SetScintStackPhotons(G4bool)
G4bool GetScintStackPhotons() const
static G4OpticalParameters * Instance()
void SetScintFiniteRiseTime(G4bool)
G4bool GetScintByParticleType() const
void SetScintTrackInfo(G4bool)
G4bool GetScintFiniteRiseTime() const
G4bool GetScintTrackInfo() const
G4bool GetScintTrackSecondariesFirst() const
void AddSecondary(G4Track *aSecondary)
void Initialize(const G4Track &) override
const G4String & GetParticleType() const
G4bool IsShortLived() const
G4double GetPDGCharge() const
const G4String & GetParticleName() const
static G4int GetModelID(const G4int modelIndex)
std::size_t entries() const
void insertAt(std::size_t, G4PhysicsVector *)
G4double GetEnergy(const G4double value) const
G4double GetMaxEnergy() const
G4double GetMaxValue() const
G4double Energy(const std::size_t index) const
G4double Value(const G4double energy, std::size_t &lastidx) const
std::size_t GetVectorLength() const
static G4Proton * ProtonDefinition()
G4VParticleChange * AtRestDoIt(const G4Track &aTrack, const G4Step &aStep) override
G4double GetScintillationYieldByParticleType(const G4Track &aTrack, const G4Step &aStep, G4double &yield1, G4double &yield2, G4double &yield3)
void SetTrackSecondariesFirst(const G4bool state)
void SetStackPhotons(const G4bool)
G4double GetMeanFreePath(const G4Track &aTrack, G4double, G4ForceCondition *) override
void BuildPhysicsTable(const G4ParticleDefinition &aParticleType) override
void SetVerboseLevel(G4int)
void SetScintillationTrackInfo(const G4bool trackType)
G4double GetMeanLifeTime(const G4Track &aTrack, G4ForceCondition *) override
G4VParticleChange * PostStepDoIt(const G4Track &aTrack, const G4Step &aStep) override
G4bool IsApplicable(const G4ParticleDefinition &aParticleType) override
void DumpPhysicsTable() const
void SetFiniteRiseTime(const G4bool state)
G4Scintillation(const G4String &processName="Scintillation", G4ProcessType type=fElectromagnetic)
void PreparePhysicsTable(const G4ParticleDefinition &part) override
void SetScintillationByParticleType(const G4bool)
void ProcessDescription(std::ostream &) const override
G4StepStatus GetStepStatus() const
G4double GetVelocity() const
G4double GetGlobalTime() const
const G4ThreeVector & GetPosition() const
const G4TouchableHandle & GetTouchableHandle() const
G4double GetKineticEnergy() const
G4ThreeVector GetDeltaPosition() const
G4StepPoint * GetPreStepPoint() const
G4double GetStepLength() const
G4double GetTotalEnergyDeposit() const
G4StepPoint * GetPostStepPoint() const
G4TrackStatus GetTrackStatus() const
G4double GetVertexKineticEnergy() const
const G4ParticleDefinition * GetParticleDefinition() const
void SetTouchableHandle(const G4TouchableHandle &apValue)
G4Material * GetMaterial() const
const G4DynamicParticle * GetDynamicParticle() const
G4double GetKineticEnergy() const
void SetUserInformation(G4VUserTrackInformation *aValue) const
void SetCreatorModelID(const G4int id)
G4int GetParentID() const
void SetParentID(const G4int aValue)
static G4Triton * TritonDefinition()
void ProposeTrackStatus(G4TrackStatus status)
G4int GetNumberOfSecondaries() const
void SetNumberOfSecondaries(G4int totSecondaries)
G4ParticleChange aParticleChange
void SetProcessSubType(G4int)
virtual void DumpInfo() const
const G4String & GetProcessName() const
virtual G4VParticleChange * PostStepDoIt(const G4Track &, const G4Step &)