54 , fIntegralTable1(nullptr)
55 , fIntegralTable2(nullptr)
56 , fIntegralTable3(nullptr)
57 , fEmSaturation(nullptr)
63#ifdef G4DEBUG_SCINTILLATION
78 if(fIntegralTable1 !=
nullptr)
80 fIntegralTable1->clearAndDestroy();
81 delete fIntegralTable1;
83 if(fIntegralTable2 !=
nullptr)
85 fIntegralTable2->clearAndDestroy();
86 delete fIntegralTable2;
88 if(fIntegralTable3 !=
nullptr)
90 fIntegralTable3->clearAndDestroy();
91 delete fIntegralTable3;
98 out <<
"Scintillation simulates production of optical photons produced\n"
99 "by a high energy particle traversing matter.\n"
100 "Various material properties need to be defined.\n";
149 std::size_t numOfMaterialsWithMPT = 0;
150 for(std::size_t i = 0; i < numOfMaterials; ++i)
152 if(((*materialTable)[i])->GetMaterialPropertiesTable())
154 ++numOfMaterialsWithMPT;
163 std::size_t indexMPT = 0;
164 for(std::size_t i = 0; i < numOfMaterials; ++i)
169 ((*materialTable)[i])->GetMaterialPropertiesTable();
181 fIntegralTable1->insertAt(indexMPT, vector1);
182 fIntegralTable2->insertAt(indexMPT, vector2);
183 fIntegralTable3->insertAt(indexMPT, vector3);
185 fIndexMPT.insert(std::make_pair(i, indexMPT));
200 if(MPV && (*MPV)[0] >= 0.0)
202 std::vector<G4double> cdf(MPV->GetVectorLength());
204 for (std::size_t ii = 1; ii < MPV->GetVectorLength() ; ++ii)
206 cdf[ii] = cdf[ii - 1] + 0.5 * (MPV->Energy(ii) - MPV->Energy(ii-1))
207 * ((*MPV)[ii] + (*MPV)[ii - 1]);
210 for (std::size_t ii = 0; ii < MPV->GetVectorLength(); ++ii)
212 cdf[ii] = cdf[ii] / cdf.back();
213 vec->InsertValues(cdf[ii], MPV->Energy(ii));
254 G4int N_timeconstants = 1;
277 if(fScintillationByParticleType)
280 aTrack, aStep, yield1, yield2, yield3, timeconstant1, timeconstant2,
300 MeanNumberOfPhotons *=
301 (fEmSaturation->VisibleEnergyDepositionAtAStep(&aStep));
303 MeanNumberOfPhotons *= TotalEnergyDeposit;
305 sum_yields = yield1 + yield2 + yield3;
307 if(MeanNumberOfPhotons > 10.)
309 G4double sigma = ResolutionScale * std::sqrt(MeanNumberOfPhotons);
310 fNumPhotons =
G4int(G4RandGauss::shoot(MeanNumberOfPhotons, sigma) + 0.5);
317 if(fNumPhotons <= 0 || !fStackingFlag)
326 if(fTrackSecondariesFirst)
332 std::size_t materialIndex = aMaterial->
GetIndex();
333 auto it = fIndexMPT.find(materialIndex);
335 std::size_t indexMPT = 0;
336 if(it != fIndexMPT.end())
338 indexMPT = it->second;
343 ed <<
"G4MaterialPropertiesTable for " << aMaterial->
GetName()
344 <<
" is not found!" <<
G4endl;
345 G4Exception(
"G4QuasiScintillation::PostStepDoIt",
"Scint04",
351 G4int numPhot = fNumPhotons;
362 for(
G4int scnt = 0; scnt < N_timeconstants; ++scnt)
367 if(N_timeconstants == 1)
369 numPhot = fNumPhotons;
373 numPhot = yield1 / sum_yields * fNumPhotons;
375 if(fScintillationByParticleType)
377 scintTime = timeconstant1;
393 if(N_timeconstants == 2)
395 numPhot = fNumPhotons - numPhot;
399 numPhot = yield2 / sum_yields * fNumPhotons;
401 if(fScintillationByParticleType)
403 scintTime = timeconstant2;
418 numPhot = yield3 / sum_yields * fNumPhotons;
419 if(fScintillationByParticleType)
421 scintTime = timeconstant3;
460 for(
G4int i = 0; i < numPhot; ++i)
467 G4cout <<
"sampledEnergy = " << sampledEnergy <<
G4endl;
472 G4double sint = std::sqrt((1. - cost) * (1. + cost));
479 G4ThreeVector photonPolarization(cost * cosp, cost * sinp, -sint);
482 sinp = std::sin(phi);
483 cosp = std::cos(phi);
484 photonPolarization = (cosp * photonPolarization + sinp * perp).unit();
488 scintPhoton->SetPolarization(photonPolarization);
489 scintPhoton->SetKineticEnergy(sampledEnergy);
497 delta / (pPreStepPoint->
GetVelocity() + 0.5 * rand * deltaVelocity);
504 deltaTime += sample_time(riseTime, scintTime);
510 G4Track* secTrack =
new G4Track(scintPhoton, secTime, secPosition);
514 if(fScintillationTrackInfo)
523 G4cout <<
"\n Exiting from G4QuasiScintillation::DoIt -- "
524 <<
" NumberOfSecondaries = "
765 if(yieldVector ==
nullptr)
768 ed <<
"\nG4QuasiScintillation::PostStepDoIt(): "
769 <<
"Request for scintillation yield for energy deposit and particle\n"
770 <<
"type without correct entry in MaterialPropertiesTable. A material\n"
771 <<
"property (vector) with name like PARTICLESCINTILLATIONYIELD is\n"
772 <<
"needed (hint: PARTICLE might not be the primary particle."
774 G4String comments =
"Missing MaterialPropertiesTable entry - No correct "
775 "entry in MaterialPropertiesTable";
792 if(PreStepKineticEnergy <= yieldVector->GetMaxEnergy())
798 yieldVector->
Value(PreStepKineticEnergy) -
799 yieldVector->
Value(PreStepKineticEnergy - StepEnergyDeposit);
803 ++fNumEnergyWarnings;
807 ed <<
"\nG4QuasiScintillation::GetScintillationYieldByParticleType(): "
809 <<
"for scintillation light yield above the available energy range\n"
810 <<
"specified in G4MaterialPropertiesTable. A linear interpolation\n"
811 <<
"will be performed to compute the scintillation light yield using\n"
812 <<
"(L_max / E_max) as the photon yield per unit energy." <<
G4endl;
813 G4String cmt =
"\nScintillation yield may be unphysical!\n";
815 if(fNumEnergyWarnings == 10)
817 ed <<
G4endl <<
"*** Scintillation energy warnings stopped.";
819 G4Exception(
"G4QuasiScintillation::GetScintillationYieldByParticleType()",
828#ifdef G4DEBUG_SCINTILLATION
830 ScintTrackYield += ScintillationYield;
831 ScintTrackEDep += StepEnergyDeposit;
834 <<
"G4QuasiScintillation::GetScintillationYieldByParticleType() --\n"
838 <<
"-- TrackID = " << aTrack.
GetTrackID() <<
"\n"
839 <<
"-- ParentID = " << aTrack.
GetParentID() <<
"\n"
844 <<
"-- Track EDep = " << ScintTrackEDep / MeV <<
" MeV\n"
847 <<
"-- Step yield = " << ScintillationYield <<
" photons\n"
848 <<
"-- Track yield = " << ScintTrackYield <<
" photons\n"
857 ScintTrackYield = 0.;
861 return ScintillationYield;
869 for(std::size_t i = 0; i < fIntegralTable1->entries(); ++i)
876 for(std::size_t i = 0; i < fIntegralTable2->entries(); ++i)
883 for(std::size_t i = 0; i < fIntegralTable3->entries(); ++i)
893 fTrackSecondariesFirst = state;
895 fTrackSecondariesFirst);
901 fFiniteRiseTime = state;
908 if(fEmSaturation && scintType)
910 G4Exception(
"G4QuasiScintillation::SetScintillationByParticleType",
912 "Redefinition: Birks Saturation is replaced by "
913 "ScintillationByParticleType!");
916 fScintillationByParticleType = scintType;
918 fScintillationByParticleType);
924 fScintillationTrackInfo = trackType;
931 fStackingFlag = stackingFlag;
938 fOffloadingFlag = offloadingFlag;
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
G4ThreeVector GetMomentum() 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 SetScintOffloadPhotons(G4bool)
G4bool GetScintOffloadPhotons() const
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
G4double GetPDGCharge() 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()
static G4QuasiOpticalPhoton * QuasiOpticalPhotonDefinition()
G4QuasiScintillation(const G4String &procName="QausiScintillation", G4ProcessType type=fElectromagnetic)
G4VParticleChange * PostStepDoIt(const G4Track &aTrack, const G4Step &aStep) override
G4bool IsApplicable(const G4ParticleDefinition &aParticleType) override
void SetStackPhotons(const G4bool)
void SetScintillationTrackInfo(const G4bool trackType)
void ProcessDescription(std::ostream &) const override
G4double GetMeanFreePath(const G4Track &aTrack, G4double, G4ForceCondition *) override
void DumpPhysicsTable() const
void BuildPhysicsTable(const G4ParticleDefinition &aParticleType) override
void SetVerboseLevel(G4int)
G4VParticleChange * AtRestDoIt(const G4Track &aTrack, const G4Step &aStep) override
G4double GetMeanLifeTime(const G4Track &aTrack, G4ForceCondition *) override
void SetTrackSecondariesFirst(const G4bool state)
G4double GetScintillationYieldByParticleType(const G4Track &aTrack, const G4Step &aStep, G4double &yield1, G4double &yield2, G4double &yield3, G4double &timeconstant1, G4double &timeconstant2, G4double &timeconstant3)
void PreparePhysicsTable(const G4ParticleDefinition &part) override
void SetScintillationByParticleType(const G4bool)
void SetOffloadPhotons(const G4bool)
void SetFiniteRiseTime(const G4bool state)
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 SetAuxiliaryTrackInformation(G4int id, G4VAuxiliaryTrackInformation *info) 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 &)