ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4UserSpecialCuts.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4UserSpecialCuts.cc
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 //
28 // --------------------------------------------------------------
29 // History
30 //
31 // 15-04-98 first implementation, mma
32 // 07-04-03 migrade to cut per region (V.Ivanchenko)
33 // 18-09-03 substitute manager for the loss tables (V.Ivanchenko)
34 // 23-01-04 add protection for charged geantino in range cut (H.Kurashige)
35 // 09-09-04 tracking cut applied only if Rmin or Emin > DBL_MIN
36 // 21-01-11 changed order of checks: 1st energy tracking cut, 2nd track
37 // length, 3d time cut, 4th range for charged particles
38 // with non-zero mass; removed string comparisons (V.Ivanchenko)
39 // --------------------------------------------------------------
40 
41 #include "G4UserSpecialCuts.hh"
43 
44 #include "G4PhysicalConstants.hh"
45 #include "G4Step.hh"
46 #include "G4UserLimits.hh"
47 #include "G4VParticleChange.hh"
48 #include "G4LossTableManager.hh"
49 
50 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
51 
53  : G4VProcess(aName, fGeneral )
54 {
55  // set Process Sub Type
56  SetProcessSubType(static_cast<int>(USER_SPECIAL_CUTS));
57 
58  if (verboseLevel>0)
59  {
60  G4cout << GetProcessName() << " is created "<< G4endl;
61  }
63 }
64 
65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
66 
68 {
69 }
70 
71 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
72 
74  : G4VProcess(right)
75 {
77 }
78 
79 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
80 
83  G4double, // previousStepSize
85 {
86  // condition is set to "Not Forced"
87  *condition = NotForced;
88 
89  G4double ProposedStep = DBL_MAX;
90  G4UserLimits* pUserLimits =
92  if (pUserLimits)
93  {
94  // check max kinetic energy first
95  //
96  G4double Ekine = aTrack.GetKineticEnergy();
97  if(Ekine <= pUserLimits->GetUserMinEkine(aTrack)) { return 0.; }
98 
99  // max track length
100  //
101  ProposedStep = (pUserLimits->GetUserMaxTrackLength(aTrack)
102  - aTrack.GetTrackLength());
103  if (ProposedStep < 0.) { return 0.; }
104 
105  // max time limit
106  //
107  G4double tlimit = pUserLimits->GetUserMaxTime(aTrack);
108  if(tlimit < DBL_MAX) {
109  G4double beta = (aTrack.GetDynamicParticle()->GetTotalMomentum())
110  /(aTrack.GetTotalEnergy());
111  G4double dTime = (tlimit - aTrack.GetGlobalTime());
112  G4double temp = beta*c_light*dTime;
113  if (temp < 0.) { return 0.; }
114  if (ProposedStep > temp) { ProposedStep = temp; }
115  }
116 
117  // min remaining range
118  // (only for charged particle except for chargedGeantino)
119  //
120  G4double Rmin = pUserLimits->GetUserMinRange(aTrack);
121  if (Rmin > DBL_MIN) {
122  G4ParticleDefinition* Particle = aTrack.GetDefinition();
123  if ( (Particle->GetPDGCharge() != 0.) && (Particle->GetPDGMass() > 0.0))
124  {
125  const G4MaterialCutsCouple* couple = aTrack.GetMaterialCutsCouple();
126  G4double RangeNow = theLossTableManager->GetRange(Particle,Ekine,couple);
127  G4double temp = RangeNow - Rmin;
128  if (temp < 0.) { return 0.; }
129  if (ProposedStep > temp) { ProposedStep = temp; }
130  }
131  }
132  }
133  return ProposedStep;
134 }
135 
136 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
137 
140  const G4Step& )
141 //
142 // Kill the current particle, if requested by G4UserLimits
143 //
144 {
145  aParticleChange.Initialize(aTrack);
149  return &aParticleChange;
150 }
151 
152 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
153 
154 
155 
156 
157 
158 
159 
160 
161 
162 
163 
164