91 , fIntegralTable1(nullptr)
92 , fIntegralTable2(nullptr)
93 , fIntegralTable3(nullptr)
94 , fEmSaturation(nullptr)
100#ifdef G4DEBUG_SCINTILLATION
102 ScintTrackYield = 0.;
115 if(fIntegralTable1 !=
nullptr)
117 fIntegralTable1->clearAndDestroy();
118 delete fIntegralTable1;
120 if(fIntegralTable2 !=
nullptr)
122 fIntegralTable2->clearAndDestroy();
123 delete fIntegralTable2;
125 if(fIntegralTable3 !=
nullptr)
127 fIntegralTable3->clearAndDestroy();
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 std::size_t numOfMaterialsWithMPT = 0;
181 for(std::size_t i = 0; i < numOfMaterials; ++i)
183 if(((*materialTable)[i])->GetMaterialPropertiesTable())
185 ++numOfMaterialsWithMPT;
194 std::size_t indexMPT = 0;
195 for(std::size_t i = 0; i < numOfMaterials; ++i)
200 ((*materialTable)[i])->GetMaterialPropertiesTable();
212 fIntegralTable1->insertAt(indexMPT, vector1);
213 fIntegralTable2->insertAt(indexMPT, vector2);
214 fIntegralTable3->insertAt(indexMPT, vector3);
216 fIndexMPT.insert(std::make_pair(i, indexMPT));
230 if(MPV && (*MPV)[0] >= 0.0)
232 std::vector<G4double> cdf(MPV->GetVectorLength());
234 for (std::size_t ii = 1; ii < MPV->GetVectorLength() ; ++ii)
236 cdf[ii] = cdf[ii - 1] + 0.5 * (MPV->Energy(ii) - MPV->Energy(ii-1))
237 * ((*MPV)[ii] + (*MPV)[ii - 1]);
240 for (std::size_t ii = 0; ii < MPV->GetVectorLength(); ++ii)
242 cdf[ii] = cdf[ii] / cdf.back();
243 vec->InsertValues(cdf[ii], MPV->Energy(ii));
279 if (0.0 >= TotalEnergyDeposit) {
287 G4int N_timeconstants = 1;
310 if(fScintillationByParticleType)
313 aTrack, aStep, yield1, yield2, yield3, timeconstant1, timeconstant2,
333 MeanNumberOfPhotons *=
334 (fEmSaturation->VisibleEnergyDepositionAtAStep(&aStep));
336 MeanNumberOfPhotons *= TotalEnergyDeposit;
338 sum_yields = yield1 + yield2 + yield3;
340 if(MeanNumberOfPhotons > 10.)
342 G4double sigma = ResolutionScale * std::sqrt(MeanNumberOfPhotons);
343 fNumPhotons =
G4int(G4RandGauss::shoot(MeanNumberOfPhotons, sigma) + 0.5);
350 if(fNumPhotons <= 0 || !fStackingFlag)
359 if(fTrackSecondariesFirst)
365 std::size_t materialIndex = aMaterial->
GetIndex();
366 auto it = fIndexMPT.find(materialIndex);
368 std::size_t indexMPT = 0;
369 if(it != fIndexMPT.end())
371 indexMPT = it->second;
376 ed <<
"G4MaterialPropertiesTable for " << aMaterial->
GetName()
377 <<
" is not found!" <<
G4endl;
383 G4int numPhot = fNumPhotons;
394 for(
G4int scnt = 0; scnt < N_timeconstants; ++scnt)
399 if(N_timeconstants == 1)
401 numPhot = fNumPhotons;
405 numPhot = yield1 / sum_yields * fNumPhotons;
407 if(fScintillationByParticleType)
409 scintTime = timeconstant1;
425 if(N_timeconstants == 2)
427 numPhot = fNumPhotons - numPhot;
431 numPhot = yield2 / sum_yields * fNumPhotons;
433 if(fScintillationByParticleType)
435 scintTime = timeconstant2;
450 numPhot = yield3 / sum_yields * fNumPhotons;
451 if(fScintillationByParticleType)
453 scintTime = timeconstant3;
470 for(
G4int i = 0; i < numPhot; ++i)
477 G4cout <<
"sampledEnergy = " << sampledEnergy <<
G4endl;
482 G4double sint = std::sqrt((1. - cost) * (1. + cost));
489 G4ThreeVector photonPolarization(cost * cosp, cost * sinp, -sint);
492 sinp = std::sin(phi);
493 cosp = std::cos(phi);
494 photonPolarization = (cosp * photonPolarization + sinp * perp).unit();
498 scintPhoton->SetPolarization(photonPolarization);
499 scintPhoton->SetKineticEnergy(sampledEnergy);
507 delta / (pPreStepPoint->
GetVelocity() + 0.5 * rand * deltaVelocity);
514 deltaTime += sample_time(riseTime, scintTime);
520 G4Track* secTrack =
new G4Track(scintPhoton, secTime, secPosition);
524 if(fScintillationTrackInfo)
533 G4cout <<
"\n Exiting from G4Scintillation::DoIt -- NumberOfSecondaries = "
774 if(yieldVector ==
nullptr)
777 ed <<
"\nG4Scintillation::PostStepDoIt(): "
778 <<
"Request for scintillation yield for energy deposit and particle\n"
779 <<
"type without correct entry in MaterialPropertiesTable. A material\n"
780 <<
"property (vector) with name like PARTICLESCINTILLATIONYIELD is\n"
781 <<
"needed (hint: PARTICLE might not be the primary particle."
783 G4String comments =
"Missing MaterialPropertiesTable entry - No correct "
784 "entry in MaterialPropertiesTable";
801 if(PreStepKineticEnergy <= yieldVector->GetMaxEnergy())
807 yieldVector->
Value(PreStepKineticEnergy) -
808 yieldVector->
Value(PreStepKineticEnergy - StepEnergyDeposit);
812 ++fNumEnergyWarnings;
816 ed <<
"\nG4Scintillation::GetScintillationYieldByParticleType(): Request\n"
817 <<
"for scintillation light yield above the available energy range\n"
818 <<
"specified in G4MaterialPropertiesTable. A linear interpolation\n"
819 <<
"will be performed to compute the scintillation light yield using\n"
820 <<
"(L_max / E_max) as the photon yield per unit energy." <<
G4endl;
821 G4String cmt =
"\nScintillation yield may be unphysical!\n";
823 if(fNumEnergyWarnings == 10)
825 ed <<
G4endl <<
"*** Scintillation energy warnings stopped.";
827 G4Exception(
"G4Scintillation::GetScintillationYieldByParticleType()",
836#ifdef G4DEBUG_SCINTILLATION
838 ScintTrackYield += ScintillationYield;
839 ScintTrackEDep += StepEnergyDeposit;
841 G4cout <<
"\n--- G4Scintillation::GetScintillationYieldByParticleType() ---\n"
845 <<
"-- TrackID = " << aTrack.
GetTrackID() <<
"\n"
846 <<
"-- ParentID = " << aTrack.
GetParentID() <<
"\n"
851 <<
"-- Track EDep = " << ScintTrackEDep / MeV <<
" MeV\n"
854 <<
"-- Step yield = " << ScintillationYield <<
" photons\n"
855 <<
"-- Track yield = " << ScintTrackYield <<
" photons\n"
864 ScintTrackYield = 0.;
868 return ScintillationYield;
876 for(std::size_t i = 0; i < fIntegralTable1->entries(); ++i)
883 for(std::size_t i = 0; i < fIntegralTable2->entries(); ++i)
890 for(std::size_t i = 0; i < fIntegralTable3->entries(); ++i)
900 fTrackSecondariesFirst = state;
902 fTrackSecondariesFirst);
908 fFiniteRiseTime = state;
915 if(fEmSaturation && scintType)
917 G4Exception(
"G4Scintillation::SetScintillationByParticleType",
"Scint02",
919 "Redefinition: Birks Saturation is replaced by "
920 "ScintillationByParticleType!");
923 fScintillationByParticleType = scintType;
925 fScintillationByParticleType);
931 fScintillationTrackInfo = trackType;
938 fStackingFlag = stackingFlag;
G4double condition(const G4ErrorSymMatrix &m)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
G4double G4Exp(G4double initial_x)
Exponential Function double precision.
G4double G4Log(G4double x)
@ kSCINTILLATIONCOMPONENT1
@ kSCINTILLATIONCOMPONENT2
@ kSCINTILLATIONCOMPONENT3
@ kELECTRONSCINTILLATIONYIELD
@ kALPHASCINTILLATIONYIELD
@ kPROTONSCINTILLATIONYIELD
@ kDEUTERONSCINTILLATIONYIELD
@ kTRITONSCINTILLATIONYIELD
@ kSCINTILLATIONTIMECONSTANT1
@ kSCINTILLATIONRISETIME2
@ kTRITONSCINTILLATIONYIELD1
@ kDEUTERONSCINTILLATIONYIELD3
@ kIONSCINTILLATIONYIELD1
@ kSCINTILLATIONRISETIME1
@ kPROTONSCINTILLATIONTIMECONSTANT2
@ kALPHASCINTILLATIONTIMECONSTANT1
@ kELECTRONSCINTILLATIONTIMECONSTANT2
@ kDEUTERONSCINTILLATIONYIELD2
@ kELECTRONSCINTILLATIONTIMECONSTANT3
@ kDEUTERONSCINTILLATIONTIMECONSTANT1
@ kTRITONSCINTILLATIONTIMECONSTANT2
@ kTRITONSCINTILLATIONYIELD2
@ kALPHASCINTILLATIONYIELD2
@ kELECTRONSCINTILLATIONYIELD3
@ kTRITONSCINTILLATIONTIMECONSTANT1
@ kALPHASCINTILLATIONYIELD1
@ kALPHASCINTILLATIONTIMECONSTANT2
@ kPROTONSCINTILLATIONTIMECONSTANT3
@ kDEUTERONSCINTILLATIONTIMECONSTANT3
@ kELECTRONSCINTILLATIONYIELD2
@ kIONSCINTILLATIONYIELD2
@ kIONSCINTILLATIONYIELD3
@ kSCINTILLATIONRISETIME3
@ kPROTONSCINTILLATIONYIELD2
@ kDEUTERONSCINTILLATIONYIELD1
@ kTRITONSCINTILLATIONTIMECONSTANT3
@ kTRITONSCINTILLATIONYIELD3
@ kSCINTILLATIONTIMECONSTANT3
@ kIONSCINTILLATIONTIMECONSTANT1
@ kIONSCINTILLATIONTIMECONSTANT3
@ kPROTONSCINTILLATIONYIELD3
@ kIONSCINTILLATIONTIMECONSTANT2
@ kALPHASCINTILLATIONTIMECONSTANT3
@ kELECTRONSCINTILLATIONYIELD1
@ kALPHASCINTILLATIONYIELD3
@ kSCINTILLATIONTIMECONSTANT2
@ kPROTONSCINTILLATIONYIELD1
@ kDEUTERONSCINTILLATIONTIMECONSTANT2
@ kPROTONSCINTILLATIONTIMECONSTANT1
@ kELECTRONSCINTILLATIONTIMECONSTANT1
G4PhysicsFreeVector G4MaterialPropertyVector
std::vector< G4Material * > G4MaterialTable
G4ThreeVector G4ParticleMomentum
G4long G4Poisson(G4double mean)
CLHEP::Hep3Vector G4ThreeVector
G4GLOB_DLL std::ostream G4cout
Hep3Vector cross(const Hep3Vector &) const
static G4Alpha * AlphaDefinition()
static G4Deuteron * DeuteronDefinition()
G4ParticleDefinition * GetDefinition() const
G4bool ConstPropertyExists(const G4String &key) const
G4double GetConstProperty(const G4String &key) const
G4MaterialPropertyVector * GetProperty(const char *key) const
G4MaterialPropertiesTable * GetMaterialPropertiesTable() const
static std::size_t GetNumberOfMaterials()
std::size_t GetIndex() const
static G4MaterialTable * GetMaterialTable()
const G4String & GetName() const
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
const G4String & GetParticleType() const
G4bool IsShortLived() const
const G4String & GetParticleName() const
static G4int GetModelID(const G4int modelIndex)
G4double GetMaxEnergy() const
G4double GetMaxValue() const
G4double Value(const G4double energy, std::size_t &lastidx) const
static G4Proton * ProtonDefinition()
G4VParticleChange * AtRestDoIt(const G4Track &aTrack, const G4Step &aStep) override
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
G4double GetScintillationYieldByParticleType(const G4Track &aTrack, const G4Step &aStep, G4double &yield1, G4double &yield2, G4double &yield3, G4double &timeconstant1, G4double &timeconstant2, G4double &timeconstant3)
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()
G4ParticleChange aParticleChange
void SetProcessSubType(G4int)
virtual void DumpInfo() const
const G4String & GetProcessName() const
G4VRestDiscreteProcess(const G4String &, G4ProcessType aType=fNotDefined)
virtual G4VParticleChange * PostStepDoIt(const G4Track &, const G4Step &)