Geant4  10.01.p02
G4UserSpecialCuts.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 //
26 //
27 // $Id: G4UserSpecialCuts.cc 81366 2014-05-27 12:58:10Z gcosmo $
28 //
29 // --------------------------------------------------------------
30 // History
31 //
32 // 15-04-98 first implementation, mma
33 // 07-04-03 migrade to cut per region (V.Ivanchenko)
34 // 18-09-03 substitute manager for the loss tables (V.Ivanchenko)
35 // 23-01-04 add protection for charged geantino in range cut (H.Kurashige)
36 // 09-09-04 tracking cut applied only if Rmin or Emin > DBL_MIN
37 // 21-01-11 changed order of checks: 1st energy tracking cut, 2nd track
38 // length, 3d time cut, 4th range for charged particles
39 // with non-zero mass; removed string comparisons (V.Ivanchenko)
40 // --------------------------------------------------------------
41 
42 #include "G4UserSpecialCuts.hh"
44 
45 #include "G4PhysicalConstants.hh"
46 #include "G4Step.hh"
47 #include "G4UserLimits.hh"
48 #include "G4VParticleChange.hh"
49 #include "G4LossTableManager.hh"
50 
51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
52 
54  : G4VProcess(aName, fGeneral )
55 {
56  // set Process Sub Type
57  SetProcessSubType(static_cast<int>(USER_SPECIAL_CUTS));
58 
59  if (verboseLevel>0)
60  {
61  G4cout << GetProcessName() << " is created "<< G4endl;
62  }
64 }
65 
66 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
67 
69 {
70 }
71 
72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
73 
75  : G4VProcess(right)
76 {
78 }
79 
80 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
81 
84  G4double, // previousStepSize
86 {
87  // condition is set to "Not Forced"
88  *condition = NotForced;
89 
90  G4double ProposedStep = DBL_MAX;
91  G4UserLimits* pUserLimits =
93  if (pUserLimits)
94  {
95  // check max kinetic energy first
96  //
97  G4double Ekine = aTrack.GetKineticEnergy();
98  if(Ekine <= pUserLimits->GetUserMinEkine(aTrack)) { return 0.; }
99 
100  // max track length
101  //
102  ProposedStep = (pUserLimits->GetUserMaxTrackLength(aTrack)
103  - aTrack.GetTrackLength());
104  if (ProposedStep < 0.) { return 0.; }
105 
106  // max time limit
107  //
108  G4double tlimit = pUserLimits->GetUserMaxTime(aTrack);
109  if(tlimit < DBL_MAX) {
110  G4double beta = (aTrack.GetDynamicParticle()->GetTotalMomentum())
111  /(aTrack.GetTotalEnergy());
112  G4double dTime = (tlimit - aTrack.GetGlobalTime());
113  G4double temp = beta*c_light*dTime;
114  if (temp < 0.) { return 0.; }
115  if (ProposedStep > temp) { ProposedStep = temp; }
116  }
117 
118  // min remaining range
119  // (only for charged particle except for chargedGeantino)
120  //
121  G4double Rmin = pUserLimits->GetUserMinRange(aTrack);
122  if (Rmin > DBL_MIN) {
123  G4ParticleDefinition* Particle = aTrack.GetDefinition();
124  if ( (Particle->GetPDGCharge() != 0.) && (Particle->GetPDGMass() > 0.0))
125  {
126  const G4MaterialCutsCouple* couple = aTrack.GetMaterialCutsCouple();
127  G4double RangeNow = theLossTableManager->GetRange(Particle,Ekine,couple);
128  G4double temp = RangeNow - Rmin;
129  if (temp < 0.) { return 0.; }
130  if (ProposedStep > temp) { ProposedStep = temp; }
131  }
132  }
133  }
134  return ProposedStep;
135 }
136 
137 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
138 
141  const G4Step& )
142 //
143 // Kill the current particle, if requested by G4UserLimits
144 //
145 {
146  aParticleChange.Initialize(aTrack);
150  return &aParticleChange;
151 }
152 
153 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
154 
155 
156 
157 
158 
159 
160 
161 
162 
163 
164 
165 
G4double condition(const G4ErrorSymMatrix &m)
G4ParticleDefinition * GetDefinition() const
G4UserSpecialCuts(const G4String &processName="UserSpecialCut")
virtual ~G4UserSpecialCuts()
static G4LossTableManager * Instance()
G4int verboseLevel
Definition: G4VProcess.hh:368
const G4DynamicParticle * GetDynamicParticle() const
const G4MaterialCutsCouple * GetMaterialCutsCouple() const
virtual G4VParticleChange * PostStepDoIt(const G4Track &, const G4Step &)
G4LossTableManager * theLossTableManager
virtual G4double GetUserMaxTrackLength(const G4Track &)
virtual G4double PostStepGetPhysicalInteractionLength(const G4Track &track, G4double previousStepSize, G4ForceCondition *condition)
void ProposeLocalEnergyDeposit(G4double anEnergyPart)
G4double GetTotalMomentum() const
G4double GetKineticEnergy() const
G4GLOB_DLL std::ostream G4cout
virtual G4double GetUserMaxTime(const G4Track &)
void SetProcessSubType(G4int)
Definition: G4VProcess.hh:432
Definition: G4Step.hh:76
G4double GetGlobalTime() const
const G4String & GetProcessName() const
Definition: G4VProcess.hh:408
G4double GetTrackLength() const
G4UserLimits * GetUserLimits() const
virtual void Initialize(const G4Track &)
G4LogicalVolume * GetLogicalVolume() const
G4double GetPDGMass() const
void ProposeEnergy(G4double finalEnergy)
#define DBL_MIN
Definition: templates.hh:75
G4ParticleChange aParticleChange
Definition: G4VProcess.hh:289
virtual G4double GetUserMinRange(const G4Track &)
G4VPhysicalVolume * GetVolume() const
G4double GetTotalEnergy() const
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
void ProposeTrackStatus(G4TrackStatus status)
G4ForceCondition
G4double GetPDGCharge() const
#define DBL_MAX
Definition: templates.hh:83
G4double GetRange(const G4ParticleDefinition *aParticle, G4double kineticEnergy, const G4MaterialCutsCouple *couple)