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;
396 if(fScintillationByParticleType)
399 aTrack, aStep, yield1, yield2, yield3, timeconstant1, timeconstant2,
419 MeanNumberOfPhotons *=
422 MeanNumberOfPhotons *= TotalEnergyDeposit;
424 sum_yields = yield1 + yield2 + yield3;
426 if(MeanNumberOfPhotons > 10.)
428 G4double sigma = ResolutionScale * std::sqrt(MeanNumberOfPhotons);
429 fNumPhotons =
G4int(G4RandGauss::shoot(MeanNumberOfPhotons, sigma) + 0.5);
436 if(fNumPhotons <= 0 || !fStackingFlag)
445 if(fTrackSecondariesFirst)
455 std::size_t numPhot = fNumPhotons;
461 for(
G4int scnt = 0; scnt < N_timeconstants; ++scnt)
466 if(N_timeconstants == 1)
468 numPhot = fNumPhotons;
472 numPhot = yield1 / sum_yields * fNumPhotons;
474 if(fScintillationByParticleType)
476 scintTime = timeconstant1;
493 if(N_timeconstants == 2)
495 numPhot = fNumPhotons - numPhot;
499 numPhot = yield2 / sum_yields * fNumPhotons;
501 if(fScintillationByParticleType)
503 scintTime = timeconstant2;
519 numPhot = yield3 / sum_yields * fNumPhotons;
520 if(fScintillationByParticleType)
522 scintTime = timeconstant3;
541 for(std::size_t i = 0; i < numPhot; ++i)
549 G4cout <<
"sampledEnergy = " << sampledEnergy <<
G4endl;
555 G4double sint = std::sqrt((1. - cost) * (1. + cost));
562 G4ThreeVector photonPolarization(cost * cosp, cost * sinp, -sint);
565 sinp = std::sin(phi);
566 cosp = std::cos(phi);
567 photonPolarization = (cosp * photonPolarization + sinp * perp).unit();
571 scintPhoton->SetPolarization(photonPolarization);
572 scintPhoton->SetKineticEnergy(sampledEnergy);
594 deltaTime += sample_time(riseTime, scintTime);
600 G4Track* secTrack =
new G4Track(scintPhoton, secTime, secPosition);
605 if(fScintillationTrackInfo)
614 G4cout <<
"\n Exiting from G4Scintillation::DoIt -- NumberOfSecondaries = "
855 if(yieldVector ==
nullptr)
858 ed <<
"\nG4Scintillation::PostStepDoIt(): "
859 <<
"Request for scintillation yield for energy deposit and particle\n"
860 <<
"type without correct entry in MaterialPropertiesTable. A material\n"
861 <<
"property (vector) with name like PARTICLESCINTILLATIONYIELD is\n"
862 <<
"needed (hint: PARTICLE might not be the primary particle."
864 G4String comments =
"Missing MaterialPropertiesTable entry - No correct "
865 "entry in MaterialPropertiesTable";
882 if(PreStepKineticEnergy <= yieldVector->GetMaxEnergy())
888 yieldVector->
Value(PreStepKineticEnergy) -
889 yieldVector->
Value(PreStepKineticEnergy - StepEnergyDeposit);
893 ++fNumEnergyWarnings;
897 ed <<
"\nG4Scintillation::GetScintillationYieldByParticleType(): Request\n"
898 <<
"for scintillation light yield above the available energy range\n"
899 <<
"specified in G4MaterialPropertiesTable. A linear interpolation\n"
900 <<
"will be performed to compute the scintillation light yield using\n"
901 <<
"(L_max / E_max) as the photon yield per unit energy." <<
G4endl;
902 G4String cmt =
"\nScintillation yield may be unphysical!\n";
904 if(fNumEnergyWarnings == 10)
906 ed <<
G4endl <<
"*** Scintillation energy warnings stopped.";
908 G4Exception(
"G4Scintillation::GetScintillationYieldByParticleType()",
917#ifdef G4DEBUG_SCINTILLATION
919 ScintTrackYield += ScintillationYield;
920 ScintTrackEDep += StepEnergyDeposit;
922 G4cout <<
"\n--- G4Scintillation::GetScintillationYieldByParticleType() ---\n"
926 <<
"-- TrackID = " << aTrack.
GetTrackID() <<
"\n"
927 <<
"-- ParentID = " << aTrack.
GetParentID() <<
"\n"
932 <<
"-- Track EDep = " << ScintTrackEDep / MeV <<
" MeV\n"
935 <<
"-- Step yield = " << ScintillationYield <<
" photons\n"
936 <<
"-- Track yield = " << ScintTrackYield <<
" photons\n"
945 ScintTrackYield = 0.;
949 return ScintillationYield;
957 for(std::size_t i = 0; i < fIntegralTable1->
entries(); ++i)
964 for(std::size_t i = 0; i < fIntegralTable2->
entries(); ++i)
971 for(std::size_t i = 0; i < fIntegralTable3->
entries(); ++i)
981 fTrackSecondariesFirst = state;
983 fTrackSecondariesFirst);
989 fFiniteRiseTime = state;
996 if(fEmSaturation && scintType)
998 G4Exception(
"G4Scintillation::SetScintillationByParticleType",
"Scint02",
1000 "Redefinition: Birks Saturation is replaced by "
1001 "ScintillationByParticleType!");
1004 fScintillationByParticleType = scintType;
1006 fScintillationByParticleType);
1012 fScintillationTrackInfo = trackType;
1019 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
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 std::size_t GetNumberOfMaterials()
std::size_t GetIndex() const
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
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()
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 &)