45 is_free_flight_gamma =
false;
46 copy_gamma_for_forced_interaction =
false;
47 last_free_flight_trackid=1000;
49 theAdjointComptonModel =0;
50 theAdjointBremModel=0;
53 acc_nb_adj_interaction_length=0.;
54 acc_nb_fwd_interaction_length=0.;
55 total_acc_nb_adj_interaction_length=0.;
56 total_acc_nb_fwd_interaction_length=0.;
57 continue_gamma_as_new_free_flight =
false;
66 {
if (fParticleChange)
delete fParticleChange;
103 if (copy_gamma_for_forced_interaction) {
113 G4bool is_scat_proj_to_proj_case=
false;
114 if (!theAdjointComptonModel && !theAdjointBremModel)
return fParticleChange;
115 if (!theAdjointComptonModel) {
116 theSelectedModel = theAdjointBremModel;
117 is_scat_proj_to_proj_case=
false;
123 else if (!theAdjointBremModel) {
124 theSelectedModel = theAdjointComptonModel;
125 is_scat_proj_to_proj_case=
true;
132 theSelectedModel = theAdjointBremModel;
133 is_scat_proj_to_proj_case=
false;
136 theSelectedModel = theAdjointComptonModel;
137 is_scat_proj_to_proj_case=
true;
142 G4double one_over_effectiveAdjointCS= (1.-std::exp(acc_nb_adj_interaction_length-total_acc_nb_adj_interaction_length))/lastAdjCS;
143 G4double weight_correction_factor = lastAdjCS*one_over_effectiveAdjointCS;
148 theSelectedModel->
SampleSecondaries(track,is_scat_proj_to_proj_case,fParticleChange);
151 continue_gamma_as_new_free_flight =
true;
153 return fParticleChange;
163 G4double nb_fwd_interaction_length_over_step=0.;
164 G4double nb_adj_interaction_length_over_step=0.;
168 nb_fwd_interaction_length_over_step = stepLength*lastFwdCS;
169 nb_adj_interaction_length_over_step = stepLength*lastAdjCS;
170 G4double fwd_survival_probability=std::exp(-nb_fwd_interaction_length_over_step);
171 G4double mc_induced_survival_probability=1.;
173 if (is_free_flight_gamma) {
175 total_acc_nb_fwd_interaction_length+=nb_fwd_interaction_length_over_step;
176 total_acc_nb_adj_interaction_length+=nb_adj_interaction_length_over_step;
177 acc_track_length+=stepLength;
180 G4double previous_acc_nb_adj_interaction_length =acc_nb_adj_interaction_length;
181 acc_nb_fwd_interaction_length+=nb_fwd_interaction_length_over_step;
182 acc_nb_adj_interaction_length+=nb_adj_interaction_length_over_step;
187 mc_induced_survival_probability = 1.e50;
190 mc_induced_survival_probability= std::exp(-acc_nb_adj_interaction_length)-std::exp(-total_acc_nb_adj_interaction_length);
191 mc_induced_survival_probability=mc_induced_survival_probability/(std::exp(-previous_acc_nb_adj_interaction_length)-std::exp(-total_acc_nb_adj_interaction_length));
194 G4double weight_correction = fwd_survival_probability/mc_induced_survival_probability;
211 return fParticleChange;
221 copy_gamma_for_forced_interaction =
false;
223 is_free_flight_gamma = (track_id != last_free_flight_trackid+1 || continue_gamma_as_new_free_flight);
224 if (is_free_flight_gamma) {
225 if (step_id == 1 || continue_gamma_as_new_free_flight) {
228 copy_gamma_for_forced_interaction =
true;
229 last_free_flight_trackid = track_id;
231 total_acc_nb_adj_interaction_length=0.;
232 total_acc_nb_fwd_interaction_length=0.;
233 continue_gamma_as_new_free_flight=
false;
243 G4double min_val= std::exp(-total_acc_nb_adj_interaction_length);
246 acc_nb_adj_interaction_length=0.;
247 acc_nb_fwd_interaction_length=0.;
252 if (thePostPhysVolume){
G4double condition(const G4ErrorSymMatrix &m)
static G4AdjointGamma * AdjointGamma()
G4double GetTotalAdjointCS(G4ParticleDefinition *aPartDef, G4double Ekin, const G4MaterialCutsCouple *aCouple)
G4ParticleDefinition * GetDefinition() const
G4double GetWeight() const
G4double GetStepLength() const
virtual G4double PostStepGetPhysicalInteractionLength(const G4Track &track, G4double previousStepSize, G4ForceCondition *condition)
void ProposeParentWeight(G4double finalWeight)
const G4ThreeVector & GetPosition() const
void SetCorrectWeightForPostStepInModel(G4bool aBool)
const G4MaterialCutsCouple * GetMaterialCutsCouple() const
G4AdjointForcedInteractionForGamma(G4String process_name)
virtual G4double GetMeanFreePath(const G4Track &track, G4double previousStepSize, G4ForceCondition *condition)
G4double theNumberOfInteractionLengthLeft
void SetAdditionalWeightCorrectionFactorForPostStepOutsideModel(G4double factor)
const G4Step * GetStep() const
virtual G4VParticleChange * PostStepDoIt(const G4Track &, const G4Step &)
virtual void SampleSecondaries(const G4Track &aTrack, G4bool IsScatProjToProjCase, G4ParticleChange *fParticleChange)=0
G4StepPoint * GetPreStepPoint() const
void SetSecondaryWeightByProcess(G4bool)
void SetParentWeightByProcess(G4bool)
G4double GetKineticEnergy() const
G4int GetCurrentStepNumber() const
G4VPhysicalVolume * GetPhysicalVolume() const
virtual G4VParticleChange * AlongStepDoIt(const G4Track &track, const G4Step &step)
virtual ~G4AdjointForcedInteractionForGamma()
G4double GetTotalForwardCS(G4ParticleDefinition *aPartDef, G4double Ekin, const G4MaterialCutsCouple *aCouple)
G4ThreeVector GetMomentum() const
virtual void Initialize(const G4Track &)
virtual G4double AdjointCrossSection(const G4MaterialCutsCouple *aCouple, G4double primEnergy, G4bool IsScatProjToProjCase)
G4LogicalVolume * GetLogicalVolume() const
G4StepPoint * GetPostStepPoint() const
virtual G4double GetContinuousStepLimit(const G4Track &aTrack, G4double previousStepSize, G4double currentMinimumStep, G4double ¤tSafety)
void BuildTotalSigmaTables()
void AddSecondary(G4Track *aSecondary)
const G4MaterialCutsCouple * GetMaterialCutsCouple() const
void BuildCrossSectionMatrices()
G4double theInitialNumberOfInteractionLength
static G4AdjointCSManager * GetAdjointCSManager()
void BuildPhysicsTable(const G4ParticleDefinition &)
void PreparePhysicsTable(const G4ParticleDefinition &)