39 , fAdjointComptonModel(nullptr)
40 , fAdjointBremModel(nullptr)
50 delete fParticleChange;
55 std::ostream& out)
const
57 out <<
"Forced interaction for gamma.\n";
64 fCSManager->BuildCrossSectionMatrices();
65 fCSManager->BuildTotalSigmaTables();
93 if(fCopyGammaForForced)
96 fParticleChange->AddSecondary(
98 fParticleChange->SetParentWeightByProcess(
false);
99 fParticleChange->SetSecondaryWeightByProcess(
false);
105 G4bool is_scat_proj_to_proj_case =
false;
107 if(!fAdjointComptonModel && !fAdjointBremModel)
108 return fParticleChange;
109 if(!fAdjointComptonModel)
111 theSelectedModel = fAdjointBremModel;
112 is_scat_proj_to_proj_case =
false;
118 else if(!fAdjointBremModel)
120 theSelectedModel = fAdjointComptonModel;
121 is_scat_proj_to_proj_case =
true;
125 G4double bremAdjCS = fAdjointBremModel->AdjointCrossSection(
129 theSelectedModel = fAdjointBremModel;
130 is_scat_proj_to_proj_case =
false;
131 factor=bremAdjCS/fLastAdjCS/0.5;
135 theSelectedModel = fAdjointComptonModel;
136 is_scat_proj_to_proj_case =
true;
137 factor=(fLastAdjCS-bremAdjCS)/fLastAdjCS/0.5;
143 (1. - std::exp(fNbAdjIntLength - fTotNbAdjIntLength)) / fLastAdjCS/fCSBias;
149 factor*fLastAdjCS * invEffectiveAdjointCS);
154 fContinueGammaAsNewFreeFlight =
true;
156 return fParticleChange;
168 fLastAdjCS = fCSManager->GetTotalAdjointCS(track.
GetDefinition(), ekin,
170 G4double nb_fwd_interaction_length_over_step =
175 G4double nb_adj_interaction_length_over_step = stepLength * fLastAdjCS;
177 std::exp(-nb_fwd_interaction_length_over_step);
178 G4double mc_induced_survival_probability = 1.;
183 fTotNbAdjIntLength += nb_adj_interaction_length_over_step;
184 fAccTrackLength += stepLength;
188 G4double previous_acc_nb_adj_interaction_length = fNbAdjIntLength;
189 fNbAdjIntLength += fCSBias*nb_adj_interaction_length_over_step;
193 if(std::abs(fTotNbAdjIntLength - previous_acc_nb_adj_interaction_length) <=
196 mc_induced_survival_probability = 1.e50;
200 mc_induced_survival_probability =
201 std::exp(-fNbAdjIntLength) - std::exp(-fTotNbAdjIntLength);
202 mc_induced_survival_probability /=
203 (std::exp(-previous_acc_nb_adj_interaction_length) -
204 std::exp(-fTotNbAdjIntLength));
208 fwd_survival_probability / mc_induced_survival_probability;
217 fParticleChange->SetParentWeightByProcess(
false);
218 fParticleChange->SetSecondaryWeightByProcess(
false);
219 fParticleChange->ProposeParentWeight(new_weight);
221 return fParticleChange;
231 fCopyGammaForForced =
false;
234 (track_id != fLastFreeFlightTrackId + 1 || fContinueGammaAsNewFreeFlight);
237 if(step_id == 1 || fContinueGammaAsNewFreeFlight)
242 fCopyGammaForForced =
true;
243 fLastFreeFlightTrackId = track_id;
244 fAccTrackLength = 0.;
245 fTotNbAdjIntLength = 0.;
246 fContinueGammaAsNewFreeFlight =
false;
258 fCSBias=0.000001/fTotNbAdjIntLength;
259 fTotNbAdjIntLength*=fCSBias;
260 G4double min_val = std::exp(-fTotNbAdjIntLength);
264 fNbAdjIntLength = 0.;
270 if(thePostPhysVolume)
272 postCS = fCSManager->GetTotalAdjointCS(
G4double condition(const G4ErrorSymMatrix &m)
CLHEP::Hep3Vector G4ThreeVector
static G4AdjointCSManager * GetAdjointCSManager()
G4double GetContinuousStepLimit(const G4Track &aTrack, G4double previousStepSize, G4double currentMinimumStep, G4double ¤tSafety) override
G4double GetMeanFreePath(const G4Track &track, G4double previousStepSize, G4ForceCondition *condition) override
~G4AdjointForcedInteractionForGamma() override
G4AdjointForcedInteractionForGamma(const G4String &process_name)
G4VParticleChange * AlongStepDoIt(const G4Track &track, const G4Step &step) override
void ProcessDescription(std::ostream &) const override
G4double PostStepGetPhysicalInteractionLength(const G4Track &track, G4double previousStepSize, G4ForceCondition *condition) override
void BuildPhysicsTable(const G4ParticleDefinition &) override
G4VParticleChange * PostStepDoIt(const G4Track &, const G4Step &) override
static G4AdjointGamma * AdjointGamma()
const G4MaterialCutsCouple * GetMaterialCutsCouple() const
G4VPhysicalVolume * GetPhysicalVolume() const
G4double GetWeight() const
G4StepPoint * GetPreStepPoint() const
G4double GetStepLength() const
G4StepPoint * GetPostStepPoint() const
const G4ThreeVector & GetPosition() const
G4int GetCurrentStepNumber() const
G4ThreeVector GetMomentum() const
G4ParticleDefinition * GetDefinition() const
G4double GetKineticEnergy() const
const G4MaterialCutsCouple * GetMaterialCutsCouple() const
const G4Step * GetStep() const
G4VContinuousDiscreteProcess(const G4String &, G4ProcessType aType=fNotDefined)
virtual void SampleSecondaries(const G4Track &aTrack, G4bool isScatProjToProj, G4ParticleChange *fParticleChange)=0
void SetAdditionalWeightCorrectionFactorForPostStepOutsideModel(G4double factor)
virtual G4double AdjointCrossSection(const G4MaterialCutsCouple *aCouple, G4double primEnergy, G4bool isScatProjToProj)
void SetCorrectWeightForPostStepInModel(G4bool aBool)
virtual void Initialize(const G4Track &)
G4LogicalVolume * GetLogicalVolume() const
G4double theInitialNumberOfInteractionLength
G4double theNumberOfInteractionLengthLeft