44 is_free_flight_gamma =
false;
45 copy_gamma_for_forced_interaction =
false;
46 last_free_flight_trackid=1000;
48 theAdjointComptonModel =0;
49 theAdjointBremModel=0;
52 acc_nb_adj_interaction_length=0.;
53 acc_nb_fwd_interaction_length=0.;
54 total_acc_nb_adj_interaction_length=0.;
55 total_acc_nb_fwd_interaction_length=0.;
56 continue_gamma_as_new_free_flight =
false;
65{
if (fParticleChange)
delete fParticleChange;
102 if (copy_gamma_for_forced_interaction) {
112 G4bool is_scat_proj_to_proj_case=
false;
113 if (!theAdjointComptonModel && !theAdjointBremModel)
return fParticleChange;
114 if (!theAdjointComptonModel) {
115 theSelectedModel = theAdjointBremModel;
116 is_scat_proj_to_proj_case=
false;
122 else if (!theAdjointBremModel) {
123 theSelectedModel = theAdjointComptonModel;
124 is_scat_proj_to_proj_case=
true;
131 theSelectedModel = theAdjointBremModel;
132 is_scat_proj_to_proj_case=
false;
135 theSelectedModel = theAdjointComptonModel;
136 is_scat_proj_to_proj_case=
true;
141 G4double one_over_effectiveAdjointCS= (1.-std::exp(acc_nb_adj_interaction_length-total_acc_nb_adj_interaction_length))/lastAdjCS;
142 G4double weight_correction_factor = lastAdjCS*one_over_effectiveAdjointCS;
147 theSelectedModel->
SampleSecondaries(track,is_scat_proj_to_proj_case,fParticleChange);
150 continue_gamma_as_new_free_flight =
true;
152 return fParticleChange;
162 G4double nb_fwd_interaction_length_over_step=0.;
163 G4double nb_adj_interaction_length_over_step=0.;
167 nb_fwd_interaction_length_over_step = stepLength*lastFwdCS;
168 nb_adj_interaction_length_over_step = stepLength*lastAdjCS;
169 G4double fwd_survival_probability=std::exp(-nb_fwd_interaction_length_over_step);
170 G4double mc_induced_survival_probability=1.;
172 if (is_free_flight_gamma) {
174 total_acc_nb_fwd_interaction_length+=nb_fwd_interaction_length_over_step;
175 total_acc_nb_adj_interaction_length+=nb_adj_interaction_length_over_step;
176 acc_track_length+=stepLength;
179 G4double previous_acc_nb_adj_interaction_length =acc_nb_adj_interaction_length;
180 acc_nb_fwd_interaction_length+=nb_fwd_interaction_length_over_step;
181 acc_nb_adj_interaction_length+=nb_adj_interaction_length_over_step;
187 if (std::abs(total_acc_nb_adj_interaction_length - previous_acc_nb_adj_interaction_length) <= 1.e-15) {
188 mc_induced_survival_probability = 1.e50;
199 mc_induced_survival_probability= std::exp(-acc_nb_adj_interaction_length)-std::exp(-total_acc_nb_adj_interaction_length);
200 mc_induced_survival_probability=mc_induced_survival_probability/(std::exp(-previous_acc_nb_adj_interaction_length)-std::exp(-total_acc_nb_adj_interaction_length));
203 G4double weight_correction = fwd_survival_probability/mc_induced_survival_probability;
221 return fParticleChange;
231 copy_gamma_for_forced_interaction =
false;
233 is_free_flight_gamma = (track_id != last_free_flight_trackid+1 || continue_gamma_as_new_free_flight);
234 if (is_free_flight_gamma) {
235 if (step_id == 1 || continue_gamma_as_new_free_flight) {
238 copy_gamma_for_forced_interaction =
true;
239 last_free_flight_trackid = track_id;
241 total_acc_nb_adj_interaction_length=0.;
242 total_acc_nb_fwd_interaction_length=0.;
243 continue_gamma_as_new_free_flight=
false;
253 G4double min_val= std::exp(-total_acc_nb_adj_interaction_length);
256 acc_nb_adj_interaction_length=0.;
257 acc_nb_fwd_interaction_length=0.;
262 if (thePostPhysVolume){
G4double condition(const G4ErrorSymMatrix &m)
void BuildTotalSigmaTables()
G4double GetTotalForwardCS(G4ParticleDefinition *aPartDef, G4double Ekin, const G4MaterialCutsCouple *aCouple)
static G4AdjointCSManager * GetAdjointCSManager()
G4double GetTotalAdjointCS(G4ParticleDefinition *aPartDef, G4double Ekin, const G4MaterialCutsCouple *aCouple)
void BuildCrossSectionMatrices()
G4AdjointForcedInteractionForGamma(G4String process_name)
virtual G4double GetContinuousStepLimit(const G4Track &aTrack, G4double previousStepSize, G4double currentMinimumStep, G4double ¤tSafety)
virtual G4VParticleChange * PostStepDoIt(const G4Track &, const G4Step &)
virtual G4double GetMeanFreePath(const G4Track &track, G4double previousStepSize, G4ForceCondition *condition)
void PreparePhysicsTable(const G4ParticleDefinition &)
virtual ~G4AdjointForcedInteractionForGamma()
virtual G4double PostStepGetPhysicalInteractionLength(const G4Track &track, G4double previousStepSize, G4ForceCondition *condition)
virtual G4VParticleChange * AlongStepDoIt(const G4Track &track, const G4Step &step)
void BuildPhysicsTable(const G4ParticleDefinition &)
static G4AdjointGamma * AdjointGamma()
const G4MaterialCutsCouple * GetMaterialCutsCouple() const
void AddSecondary(G4Track *aSecondary)
virtual void Initialize(const G4Track &)
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
virtual void SampleSecondaries(const G4Track &aTrack, G4bool IsScatProjToProjCase, G4ParticleChange *fParticleChange)=0
void SetAdditionalWeightCorrectionFactorForPostStepOutsideModel(G4double factor)
void SetCorrectWeightForPostStepInModel(G4bool aBool)
virtual G4double AdjointCrossSection(const G4MaterialCutsCouple *aCouple, G4double primEnergy, G4bool IsScatProjToProjCase)
void SetSecondaryWeightByProcess(G4bool)
void SetParentWeightByProcess(G4bool)
void ProposeParentWeight(G4double finalWeight)
G4LogicalVolume * GetLogicalVolume() const
G4double theInitialNumberOfInteractionLength
G4double theNumberOfInteractionLengthLeft