Geant4 VMC Version 6.6
Loading...
Searching...
No Matches
TG4VSpecialCuts.cxx
Go to the documentation of this file.
1//------------------------------------------------
2// The Geant4 Virtual Monte Carlo package
3// Copyright (C) 2007 - 2014 Ivana Hrivnacova
4// All rights reserved.
5//
6// For the licensing terms see geant4_vmc/LICENSE.
7// Contact: root-vmc@cern.ch
8//-------------------------------------------------
9
14
15#include "TG4VSpecialCuts.h"
16#include "TG4G3CutVector.h"
17#include "TG4GeometryServices.h"
18#include "TG4Limits.h"
19#include "TG4TrackInformation.h"
20#include "TG4TrackManager.h"
21
22#include <G4EnergyLossTables.hh>
23#include <G4LossTableManager.hh>
24#include <G4PhysicalConstants.hh>
25#include <G4TransportationProcessType.hh>
26#include <G4UserLimits.hh>
27
28//_____________________________________________________________________________
29TG4VSpecialCuts::TG4VSpecialCuts(const G4String& processName)
30 : G4VProcess(processName, fUserDefined),
31 fLossTableManager(G4LossTableManager::Instance()),
32 fTrackManager(TG4TrackManager::Instance())
33{
35
36 SetProcessSubType(USER_SPECIAL_CUTS);
37}
38
39//_____________________________________________________________________________
44
45//
46// public methods
47//
48
49//_____________________________________________________________________________
51 const G4Track& track, G4double /*previousStepSize*/,
52 G4ForceCondition* condition)
53{
56
57 // set condition
58 *condition = NotForced;
59 G4double proposedStep = DBL_MAX;
60
61 // get limits
62#ifdef MCDEBUG
64 track.GetVolume()->GetLogicalVolume()->GetUserLimits());
65#else
66 TG4Limits* limits =
67 (TG4Limits*)track.GetVolume()->GetLogicalVolume()->GetUserLimits();
68#endif
69
70 if (!limits) return proposedStep;
71
72 // tracks flagged to stop
73 TG4TrackInformation* trackInformation =
75 if (trackInformation && trackInformation->IsStop()) {
76 return 0.;
77 }
78
79 // min kinetic energy (from limits)
80 G4double minEkine = GetMinEkine(*limits, track);
81 if (track.GetKineticEnergy() <= minEkine) return 0.;
82
83 // max track length
84 proposedStep =
85 (limits->GetUserMaxTrackLength(track) - track.GetTrackLength());
86 if (proposedStep < 0.) return 0.;
87
88 // max time limit
89 G4double tlimit = limits->GetUserMaxTime(track);
90 if (tlimit < DBL_MAX) {
91 G4double beta = (track.GetDynamicParticle()->GetTotalMomentum()) /
92 (track.GetTotalEnergy());
93 G4double dTime = (tlimit - track.GetGlobalTime());
94 G4double temp = beta * c_light * dTime;
95 if (temp < 0.) {
96 return 0.;
97 }
98 if (proposedStep > temp) {
99 proposedStep = temp;
100 }
101 }
102
103 // min remaining range
104 // (only for charged particle except for chargedGeantino)
105 G4double rmin = limits->GetUserMinRange(track);
106 if (rmin > DBL_MIN) {
107 G4ParticleDefinition* particle = track.GetDefinition();
108 if ((particle->GetPDGCharge() != 0.) && (particle->GetPDGMass() > 0.0)) {
109 G4double ekin = track.GetKineticEnergy();
110 const G4MaterialCutsCouple* couple = track.GetMaterialCutsCouple();
111 G4double rangeNow = fLossTableManager->GetRange(particle, ekin, couple);
112 G4double temp = rangeNow - rmin;
113 if (temp < 0.) {
114 return 0.;
115 }
116 if (proposedStep > temp) {
117 proposedStep = temp;
118 }
119 }
120 }
121 return proposedStep;
122}
123
124//_____________________________________________________________________________
126 const G4Track& track, const G4Step& /*step*/)
127{
131
132 aParticleChange.Initialize(track);
133 aParticleChange.ProposeEnergy(0.);
134 aParticleChange.ProposeLocalEnergyDeposit(track.GetKineticEnergy());
135 aParticleChange.ProposeTrackStatus(fStopButAlive);
136 return &aParticleChange;
137}
Definition of the TG4G3CutVector class.
Definition of the TG4GeometryServices class.
Definition of the TG4Limits class.
Definition of the TG4TrackInformation class.
Definition of the TG4TrackManager class.
Definition of the TG4VSpecialCuts class.
static TG4GeometryServices * Instance()
TG4Limits * GetLimits(G4UserLimits *limits) const
Extended G4UserLimits class.
Definition TG4Limits.h:38
Defines additional track information.
G4bool IsStop() const
The class for storing G4 tracks in VMC sack.
TG4TrackInformation * GetTrackInformation(const G4Track *track) const
virtual ~TG4VSpecialCuts()
virtual G4double GetMinEkine(const TG4Limits &limits, const G4Track &track) const =0
Return the kinetic energy limit.
TG4TrackManager * fTrackManager
Cached pointer to thread-local track manager.
G4LossTableManager * fLossTableManager
The G4LossTableManager instance.
virtual G4double PostStepGetPhysicalInteractionLength(const G4Track &track, G4double previousStepSize, G4ForceCondition *condition)
virtual G4VParticleChange * PostStepDoIt(const G4Track &track, const G4Step &step)
TG4VSpecialCuts()
Not implemented.