Geant4  10.00.p02
G4BOptnForceCommonTruncatedExp.cc
Go to the documentation of this file.
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 //
29 
30 #include "Randomize.hh"
32 
34  : G4VBiasingOperation(name),
35  fInteractionOccured(false)
36 {
37  fCommonTruncatedExpLaw = new G4ILawCommonTruncatedExp("ExpLawForOperation"+name);
39  fTotalCrossSection = 0.0;
40 }
41 
43 {}
44 
46 {
48 }
49 
51 {
52  return Forced;
53 }
54 
56 {
57  if ( callingProcess->GetWrappedProcess() == fProcessToApply )
59  else return DBL_MAX;
60 }
61 
63 {
64  return CandidateForSelection;
65 }
66 
68  const G4Track*, const G4Step* step, G4double& )
69 {
70  G4double processGPIL = callingProcess->GetPostStepGPIL() < callingProcess->GetAlongStepGPIL() ?
71  callingProcess->GetPostStepGPIL() : callingProcess->GetAlongStepGPIL() ;
72  if ( processGPIL <= step->GetStepLength() )
73  {
74  G4bool denyProcess = (callingProcess->GetWrappedProcess() != fProcessToApply );
75  fInteractionOccured = (fInteractionOccured || !denyProcess);
76  return denyProcess;
77  }
78  else return true;
79 }
80 
82 {
84 }
85 
87 {
88 }
89 
91 {
92  fTotalCrossSection += crossSection;
93  fCrossSections[process] = crossSection;
97 }
98 
99 
101 {
102  fCrossSections.clear();
103  fTotalCrossSection = 0.0;
104  fNumberOfSharing = 0;
105  fProcessToApply = 0;
106  fInitialMomentum = track->GetMomentum();
107 
109  G4VSolid* currentSolid = track->GetVolume()->GetLogicalVolume()->GetSolid();
111  GetNavigatorForTracking()->
112  GetGlobalToLocalTransform()).TransformPoint(track->GetPosition());
114  GetNavigatorForTracking()->
115  GetGlobalToLocalTransform()).TransformAxis(track->GetMomentumDirection());
116  fMaximumDistance = currentSolid->DistanceToOut(localPosition, localDirection);
117  if ( fMaximumDistance <= DBL_MIN ) fMaximumDistance = 0.0;
119 }
120 
121 
123 {
124  fCrossSections.clear();
125  fTotalCrossSection = 0.0;
126  fNumberOfSharing = 0;
127  fProcessToApply = 0;
128 
131 }
132 
134 {
138 }
139 
140 
142 {
143  G4double sigmaRand = G4UniformRand() * fTotalCrossSection;
144  G4double sigmaSelect = 0.0;
145  for ( std::map< const G4VProcess*, G4double>::const_iterator it = fCrossSections.begin();
146  it != fCrossSections.end();
147  it++)
148  {
149  sigmaSelect += (*it).second;
150  if ( sigmaRand <= sigmaSelect )
151  {
152  fProcessToApply = (*it).first;
153  break;
154  }
155  }
156 }
std::map< const G4VProcess *, G4double > fCrossSections
CLHEP::Hep3Vector G4ThreeVector
G4double GetStepLength() const
G4String name
Definition: TRTMaterials.hh:40
void AddCrossSection(const G4VProcess *, G4double)
const G4ThreeVector & GetPosition() const
virtual G4bool DenyProcessPostStepDoIt(const G4BiasingProcessInterface *, const G4Track *, const G4Step *, G4double &)
G4VProcess * GetWrappedProcess() const
void SetOperation(G4BOptnForceCommonTruncatedExp *operation)
#define G4UniformRand()
Definition: Randomize.hh:87
virtual const G4VBiasingInteractionLaw * ProvideOccurenceBiasingInteractionLaw(const G4BiasingProcessInterface *)
bool G4bool
Definition: G4Types.hh:79
Definition: G4Step.hh:76
static G4TransportationManager * GetTransportationManager()
G4ThreeVector GetMomentum() const
const G4ThreeVector & GetMomentumDirection() const
G4LogicalVolume * GetLogicalVolume() const
void PostStepInteractionOccured(const G4VProcess *)
G4ILawCommonTruncatedExp * fCommonTruncatedExpLaw
#define DBL_MIN
Definition: templates.hh:75
G4double UpdateForStep(G4double truePathLength)
G4VPhysicalVolume * GetVolume() const
G4double GetInteractionDistance() const
double G4double
Definition: G4Types.hh:76
virtual G4GPILSelection ProposeGPILSelection(const G4GPILSelection processSelection)
virtual G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const =0
G4ForceCondition
virtual G4double ProposeAlongStepLimit(const G4BiasingProcessInterface *)
#define DBL_MAX
Definition: templates.hh:83
G4VSolid * GetSolid() const
G4GPILSelection
virtual G4ForceCondition ProposeForceCondition(const G4ForceCondition processCondition)