| 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,v 1.17 2007/06/01 07:53:27 ahoward Exp $
|
|---|
| 28 | // GEANT4 tag $Name: geant4-09-04-beta-01 $
|
|---|
| 29 | //
|
|---|
| 30 | // --------------------------------------------------------------
|
|---|
| 31 | // History
|
|---|
| 32 | //
|
|---|
| 33 | // 15-04-98 first implementation, mma
|
|---|
| 34 | // 07-04-03 migrade to cut per region (V.Ivanchenko)
|
|---|
| 35 | // 18-09-03 substitute manager for the loss tables (V.Ivanchenko)
|
|---|
| 36 | // 23-01-04 add protection for charged geantino in range cut (H.Kurashige)
|
|---|
| 37 | // 09-09-04 tracking cut applied only if Rmin or Emin > DBL_MIN
|
|---|
| 38 | // --------------------------------------------------------------
|
|---|
| 39 |
|
|---|
| 40 | #include "G4UserSpecialCuts.hh"
|
|---|
| 41 |
|
|---|
| 42 | #include "G4Step.hh"
|
|---|
| 43 | #include "G4UserLimits.hh"
|
|---|
| 44 | #include "G4VParticleChange.hh"
|
|---|
| 45 | #include "G4LossTableManager.hh"
|
|---|
| 46 |
|
|---|
| 47 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 48 |
|
|---|
| 49 | G4UserSpecialCuts::G4UserSpecialCuts(const G4String& aName)
|
|---|
| 50 | : G4VProcess(aName)
|
|---|
| 51 | {
|
|---|
| 52 | if (verboseLevel>0)
|
|---|
| 53 | {
|
|---|
| 54 | G4cout << GetProcessName() << " is created "<< G4endl;
|
|---|
| 55 | }
|
|---|
| 56 | theLossTableManager = G4LossTableManager::Instance();
|
|---|
| 57 | }
|
|---|
| 58 |
|
|---|
| 59 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 60 |
|
|---|
| 61 | G4UserSpecialCuts::~G4UserSpecialCuts()
|
|---|
| 62 | {
|
|---|
| 63 | }
|
|---|
| 64 |
|
|---|
| 65 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 66 |
|
|---|
| 67 | G4UserSpecialCuts::G4UserSpecialCuts(G4UserSpecialCuts& right)
|
|---|
| 68 | : G4VProcess(right)
|
|---|
| 69 | {
|
|---|
| 70 | }
|
|---|
| 71 |
|
|---|
| 72 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 73 |
|
|---|
| 74 | G4double G4UserSpecialCuts::
|
|---|
| 75 | PostStepGetPhysicalInteractionLength( const G4Track& aTrack,
|
|---|
| 76 | G4double, // previousStepSize
|
|---|
| 77 | G4ForceCondition* condition )
|
|---|
| 78 | {
|
|---|
| 79 | // condition is set to "Not Forced"
|
|---|
| 80 | *condition = NotForced;
|
|---|
| 81 |
|
|---|
| 82 | G4double ProposedStep = DBL_MAX;
|
|---|
| 83 | G4UserLimits* pUserLimits =
|
|---|
| 84 | aTrack.GetVolume()->GetLogicalVolume()->GetUserLimits();
|
|---|
| 85 | if (pUserLimits)
|
|---|
| 86 | {
|
|---|
| 87 | // max track length
|
|---|
| 88 | //
|
|---|
| 89 | ProposedStep = (pUserLimits->GetUserMaxTrackLength(aTrack)
|
|---|
| 90 | - aTrack.GetTrackLength());
|
|---|
| 91 | if (ProposedStep < 0.) return 0.;
|
|---|
| 92 |
|
|---|
| 93 | // max time limit
|
|---|
| 94 | //
|
|---|
| 95 | G4double beta = (aTrack.GetDynamicParticle()->GetTotalMomentum())
|
|---|
| 96 | /(aTrack.GetTotalEnergy());
|
|---|
| 97 | G4double dTime = (pUserLimits->GetUserMaxTime(aTrack)
|
|---|
| 98 | - aTrack.GetGlobalTime());
|
|---|
| 99 | G4double temp = beta*c_light*dTime;
|
|---|
| 100 | if (temp < 0.) return 0.;
|
|---|
| 101 | if (ProposedStep > temp) ProposedStep = temp;
|
|---|
| 102 |
|
|---|
| 103 | // min remaining range
|
|---|
| 104 | // (only for charged particle except for chargedGeantino)
|
|---|
| 105 | //
|
|---|
| 106 | G4ParticleDefinition* Particle = aTrack.GetDefinition();
|
|---|
| 107 | if ( (Particle->GetPDGCharge() != 0.)
|
|---|
| 108 | && (Particle->GetParticleType() != "geantino"))
|
|---|
| 109 | {
|
|---|
| 110 | G4double Ekine = aTrack.GetKineticEnergy();
|
|---|
| 111 | const G4MaterialCutsCouple* couple = aTrack.GetMaterialCutsCouple();
|
|---|
| 112 | G4double RangeNow = theLossTableManager->GetRange(Particle,Ekine,couple);
|
|---|
| 113 | G4double Rmin = pUserLimits->GetUserMinRange(aTrack);
|
|---|
| 114 | if (Rmin > DBL_MIN) {
|
|---|
| 115 | temp = RangeNow - Rmin;
|
|---|
| 116 | if (temp < 0.) return 0.;
|
|---|
| 117 | if (ProposedStep > temp) ProposedStep = temp;
|
|---|
| 118 | }
|
|---|
| 119 |
|
|---|
| 120 | // min kinetic energy (only for charged particle)
|
|---|
| 121 | //
|
|---|
| 122 | G4double Emin = pUserLimits->GetUserMinEkine(aTrack);
|
|---|
| 123 | if (Emin > DBL_MIN) {
|
|---|
| 124 | Rmin = theLossTableManager->GetRange(Particle,Emin,couple);
|
|---|
| 125 | temp = RangeNow - Rmin;
|
|---|
| 126 | if (temp < 0.) return 0.;
|
|---|
| 127 | if (ProposedStep > temp) ProposedStep = temp;
|
|---|
| 128 | }
|
|---|
| 129 | }
|
|---|
| 130 | }
|
|---|
| 131 | return ProposedStep;
|
|---|
| 132 | }
|
|---|
| 133 |
|
|---|
| 134 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 135 |
|
|---|
| 136 | G4VParticleChange*
|
|---|
| 137 | G4UserSpecialCuts::PostStepDoIt( const G4Track& aTrack,
|
|---|
| 138 | const G4Step& )
|
|---|
| 139 | //
|
|---|
| 140 | // Kill the current particle, if requested by G4UserLimits
|
|---|
| 141 | //
|
|---|
| 142 | {
|
|---|
| 143 | aParticleChange.Initialize(aTrack);
|
|---|
| 144 | aParticleChange.ProposeEnergy(0.) ;
|
|---|
| 145 | aParticleChange.ProposeLocalEnergyDeposit(aTrack.GetKineticEnergy()) ;
|
|---|
| 146 | aParticleChange.ProposeTrackStatus(fStopAndKill);
|
|---|
| 147 | return &aParticleChange;
|
|---|
| 148 | }
|
|---|
| 149 |
|
|---|
| 150 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 151 |
|
|---|
| 152 |
|
|---|
| 153 |
|
|---|
| 154 |
|
|---|
| 155 |
|
|---|
| 156 |
|
|---|
| 157 |
|
|---|
| 158 |
|
|---|
| 159 |
|
|---|
| 160 |
|
|---|
| 161 |
|
|---|
| 162 |
|
|---|