source: trunk/source/processes/electromagnetic/utils/src/G4VMscModel.cc @ 1340

Last change on this file since 1340 was 1340, checked in by garnier, 14 years ago

update ti head

File size: 5.5 KB
Line 
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: G4VMscModel.cc,v 1.18 2010/09/07 16:05:33 vnivanch Exp $
27// GEANT4 tag $Name: emutils-V09-03-23 $
28//
29// -------------------------------------------------------------------
30//
31// GEANT4 Class file
32//
33//
34// File name:     G4VMscModel
35//
36// Author:        Vladimir Ivanchenko
37//
38// Creation date: 07.03.2008
39//
40// Modifications:
41//
42//
43// Class Description:
44//
45// General interface to msc models
46
47// -------------------------------------------------------------------
48//
49
50#include "G4VMscModel.hh"
51#include "G4ParticleChangeForMSC.hh"
52#include "G4TransportationManager.hh"
53
54//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
55//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
56
57G4VMscModel::G4VMscModel(const G4String& nam):
58  G4VEmModel(nam), 
59  safetyHelper(0),
60  facrange(0.04),
61  facgeom(2.5),
62  facsafety(0.3),
63  skin(1.0),
64  dtrl(0.05),
65  lambdalimit(mm),
66  geomMin(1.e-6*CLHEP::mm),
67  geomMax(1.e50*CLHEP::mm),
68  steppingAlgorithm(fUseSafety),
69  samplez(false),
70  latDisplasment(true)
71{}
72
73//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
74
75G4VMscModel::~G4VMscModel()
76{}
77
78//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
79
80G4ParticleChangeForMSC* G4VMscModel::GetParticleChangeForMSC()
81{
82  G4ParticleChangeForMSC* p = 0;
83  if (pParticleChange) {
84    p = static_cast<G4ParticleChangeForMSC*>(pParticleChange);
85  } else {
86    p = new G4ParticleChangeForMSC();
87  }
88  return p;
89}
90
91//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
92
93void G4VMscModel::InitialiseSafetyHelper()
94{
95  if(!safetyHelper) {
96    safetyHelper = G4TransportationManager::GetTransportationManager()
97      ->GetSafetyHelper();
98    safetyHelper->InitialiseHelper();
99  }
100}
101
102//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
103
104void G4VMscModel::ComputeDisplacement(G4ParticleChangeForMSC* fParticleChange, 
105                                      const G4ThreeVector& dir,
106                                      G4double displacement,
107                                      G4double postsafety)
108{
109  if(displacement <= geomMin) { return; }
110  const G4ThreeVector* pos = fParticleChange->GetProposedPosition();
111
112  // displaced point is definitely within the volume
113  if(displacement < postsafety) {
114
115    // compute new endpoint of the Step
116    G4ThreeVector newPosition = *pos + displacement*dir;
117    safetyHelper->ReLocateWithinVolume(newPosition);
118    fParticleChange->ProposePosition(newPosition);
119    return;
120  }
121
122  // displaced point may be outside the volume
123  G4double newsafety = safetyHelper->ComputeSafety(*pos);
124
125  // add a factor which ensure numerical stability
126  G4double r = std::min(displacement, newsafety*0.99); 
127
128  if(r > geomMin) {
129
130    // compute new endpoint of the Step
131    G4ThreeVector newPosition = *pos + r*dir;
132    safetyHelper->ReLocateWithinVolume(newPosition);
133    fParticleChange->ProposePosition(newPosition);
134  }
135}
136
137//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
138
139void G4VMscModel::SampleScattering(const G4DynamicParticle*, G4double)
140{}
141
142//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
143
144G4double G4VMscModel::ComputeTruePathLengthLimit(const G4Track&, 
145                                                 G4PhysicsTable*, 
146                                                 G4double)
147{
148  return DBL_MAX;
149}
150
151//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
152
153G4double G4VMscModel::ComputeGeomPathLength(G4double truePathLength)
154{
155  return truePathLength;
156}
157
158//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
159
160G4double G4VMscModel::ComputeTrueStepLength(G4double geomPathLength)
161{
162  return geomPathLength;
163}
164
165//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
166
167void G4VMscModel::SampleSecondaries(std::vector<G4DynamicParticle*>*,
168                                    const G4MaterialCutsCouple*,
169                                    const G4DynamicParticle*,
170                                    G4double, G4double)
171{}
172
173//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Note: See TracBrowser for help on using the repository browser.