1 | // |
---|
2 | // ******************************************************************** |
---|
3 | // * License and Disclaimer * |
---|
4 | // * * |
---|
5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
7 | // * conditions of the Geant4 Software License, included in the file * |
---|
8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
9 | // * include a list of copyright holders. * |
---|
10 | // * * |
---|
11 | // * Neither the authors of this software system, nor their employing * |
---|
12 | // * institutes,nor the agencies providing financial support for this * |
---|
13 | // * work make any representation or warranty, express or implied, * |
---|
14 | // * regarding this software system or assume any liability for its * |
---|
15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
16 | // * for the full disclaimer and the limitation of liability. * |
---|
17 | // * * |
---|
18 | // * This code implementation is the result of the scientific and * |
---|
19 | // * technical work of the GEANT4 collaboration. * |
---|
20 | // * By using, copying, modifying or distributing the software (or * |
---|
21 | // * any work based on the software) you agree to acknowledge its * |
---|
22 | // * use in resulting scientific publications, and indicate your * |
---|
23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
24 | // ******************************************************************** |
---|
25 | // |
---|
26 | // $Id: G4AdjointAlongStepWeightCorrection.cc,v 1.5 2009/11/23 09:02:35 gcosmo Exp $ |
---|
27 | // GEANT4 tag $Name: geant4-09-04-beta-01 $ |
---|
28 | // |
---|
29 | #include "G4AdjointAlongStepWeightCorrection.hh" |
---|
30 | #include "G4Step.hh" |
---|
31 | #include "G4ParticleDefinition.hh" |
---|
32 | #include "G4VParticleChange.hh" |
---|
33 | #include "G4AdjointCSManager.hh" |
---|
34 | |
---|
35 | /////////////////////////////////////////////////////// |
---|
36 | // |
---|
37 | |
---|
38 | G4AdjointAlongStepWeightCorrection::G4AdjointAlongStepWeightCorrection(const G4String& name, |
---|
39 | G4ProcessType type): G4VContinuousProcess(name, type) |
---|
40 | {fParticleChange = new G4ParticleChange(); |
---|
41 | } |
---|
42 | |
---|
43 | /////////////////////////////////////////////////////// |
---|
44 | // |
---|
45 | |
---|
46 | G4AdjointAlongStepWeightCorrection::~G4AdjointAlongStepWeightCorrection() |
---|
47 | {; |
---|
48 | } |
---|
49 | /////////////////////////////////////////////////////// |
---|
50 | // |
---|
51 | void G4AdjointAlongStepWeightCorrection::PreparePhysicsTable( |
---|
52 | const G4ParticleDefinition& ) |
---|
53 | { |
---|
54 | ; |
---|
55 | } |
---|
56 | /////////////////////////////////////////////////////// |
---|
57 | // |
---|
58 | |
---|
59 | void G4AdjointAlongStepWeightCorrection::BuildPhysicsTable(const G4ParticleDefinition& ) |
---|
60 | {; |
---|
61 | } |
---|
62 | /////////////////////////////////////////////////////// |
---|
63 | // |
---|
64 | G4VParticleChange* G4AdjointAlongStepWeightCorrection::AlongStepDoIt(const G4Track& track, |
---|
65 | const G4Step& step) |
---|
66 | { |
---|
67 | |
---|
68 | fParticleChange->Initialize(track); |
---|
69 | |
---|
70 | // Get the actual (true) Step length |
---|
71 | //---------------------------------- |
---|
72 | G4double length = step.GetStepLength(); |
---|
73 | |
---|
74 | |
---|
75 | G4double Tkin = step.GetPostStepPoint()->GetKineticEnergy(); |
---|
76 | G4ParticleDefinition* thePartDef= const_cast<G4ParticleDefinition*> (track.GetDynamicParticle()->GetDefinition()); |
---|
77 | G4double weight_correction=G4AdjointCSManager::GetAdjointCSManager()->GetContinuousWeightCorrection(thePartDef, |
---|
78 | preStepKinEnergy,Tkin, currentCouple,length); |
---|
79 | |
---|
80 | |
---|
81 | |
---|
82 | G4double new_weight=weight_correction*track.GetWeight(); |
---|
83 | |
---|
84 | //if (weight_correction >2.) new_weight=1.e-300; |
---|
85 | |
---|
86 | |
---|
87 | //The following test check for zero weight. |
---|
88 | //This happens after weight correction of gamma for photo electric effect. |
---|
89 | //When the new weight is 0 it will be later on consider as nan by G4. |
---|
90 | //Therefore we do put a lower limit of 1.e-300. for new_weight |
---|
91 | //Correction by L.Desorgher on 15 July 2009 |
---|
92 | #ifdef WIN32 |
---|
93 | if (!!_isnan(new_weight) || new_weight==0){ |
---|
94 | #else |
---|
95 | if (std::isnan(new_weight) || new_weight==0){ |
---|
96 | #endif |
---|
97 | //G4cout<<new_weight<<'\t'<<weight_correction<<'\t'<<track.GetWeight()<<G4endl; |
---|
98 | new_weight=1.e-300; |
---|
99 | } |
---|
100 | |
---|
101 | //G4cout<<new_weight<<'\t'<<weight_correction<<'\t'<<track.GetWeight()<<G4endl; |
---|
102 | fParticleChange->SetParentWeightByProcess(false); |
---|
103 | fParticleChange->SetSecondaryWeightByProcess(false); |
---|
104 | fParticleChange->ProposeParentWeight(new_weight); |
---|
105 | |
---|
106 | |
---|
107 | return fParticleChange; |
---|
108 | |
---|
109 | } |
---|
110 | /////////////////////////////////////////////////////// |
---|
111 | // |
---|
112 | G4double G4AdjointAlongStepWeightCorrection::GetContinuousStepLimit(const G4Track& track, |
---|
113 | G4double , G4double , G4double& ) |
---|
114 | { |
---|
115 | G4double x = DBL_MAX; |
---|
116 | DefineMaterial(track.GetMaterialCutsCouple()); |
---|
117 | preStepKinEnergy = track.GetKineticEnergy(); |
---|
118 | return x; |
---|
119 | } |
---|