Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4SmartTrackStack Class Reference

#include <G4SmartTrackStack.hh>

Public Member Functions

 G4SmartTrackStack ()
 
 ~G4SmartTrackStack ()
 
G4SmartTrackStackoperator= (const G4SmartTrackStack &)=delete
 
G4bool operator== (const G4SmartTrackStack &) const =delete
 
G4bool operator!= (const G4SmartTrackStack &) const =delete
 
void PushToStack (const G4StackedTrack &aStackedTrack)
 
G4StackedTrack PopFromStack ()
 
void clear ()
 
void clearAndDestroy ()
 
void TransferTo (G4TrackStack *aStack)
 
G4double getEnergyOfStack (G4TrackStack *aTrackStack)
 
void dumpStatistics ()
 
G4int GetNTrack () const
 
G4int GetMaxNTrack () const
 

Detailed Description

Definition at line 42 of file G4SmartTrackStack.hh.

Constructor & Destructor Documentation

◆ G4SmartTrackStack()

G4SmartTrackStack::G4SmartTrackStack ( )

Definition at line 47 of file G4SmartTrackStack.cc.

48 : fTurn(0), nTurn(5), maxNTracks(0), nTracks(0)
49{
50 for(G4int i=0; i<nTurn; ++i)
51 {
52 stacks[i] = new G4TrackStack(5000);
53 energies[i] = 0.;
54 }
55}
int G4int
Definition: G4Types.hh:85

◆ ~G4SmartTrackStack()

G4SmartTrackStack::~G4SmartTrackStack ( )

Definition at line 57 of file G4SmartTrackStack.cc.

58{
59 for (G4int i=0; i<nTurn; ++i)
60 {
61 delete stacks[i];
62 }
63}

Member Function Documentation

◆ clear()

void G4SmartTrackStack::clear ( )

Definition at line 142 of file G4SmartTrackStack.cc.

143{
144 for (G4int i = 0; i < nTurn; ++i)
145 {
146 stacks[i]->clear();
147 energies[i] = 0.0;
148 fTurn = 0;
149 }
150 nTracks = 0;
151}

◆ clearAndDestroy()

void G4SmartTrackStack::clearAndDestroy ( )

Definition at line 153 of file G4SmartTrackStack.cc.

154{
155 for (G4int i = 0; i < nTurn; ++i)
156 {
157 stacks[i]->clearAndDestroy();
158 energies[i] = 0.0;
159 fTurn = 0;
160 }
161 nTracks = 0;
162}
void clearAndDestroy()
Definition: G4TrackStack.cc:41

◆ dumpStatistics()

void G4SmartTrackStack::dumpStatistics ( )

Definition at line 35 of file G4SmartTrackStack.cc.

36{
37 // Print to stderr so that we can split stats output from normal
38 // output of Geant4 which is typically being printed to stdout
39 for (G4int i=0; i<nTurn; ++i)
40 {
41 G4cerr << stacks[i]->GetNTrack() << " ";
42 G4cerr << stacks[i]->getTotalEnergy() << " ";
43 }
44 G4cerr << G4endl;
45}
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
G4double getTotalEnergy(void) const
Definition: G4TrackStack.cc:68
std::size_t GetNTrack() const
Definition: G4TrackStack.hh:68

◆ getEnergyOfStack()

G4double G4SmartTrackStack::getEnergyOfStack ( G4TrackStack aTrackStack)

◆ GetMaxNTrack()

G4int G4SmartTrackStack::GetMaxNTrack ( ) const
inline

Definition at line 62 of file G4SmartTrackStack.hh.

62{ return maxNTracks; }

◆ GetNTrack()

G4int G4SmartTrackStack::GetNTrack ( ) const
inline

Definition at line 61 of file G4SmartTrackStack.hh.

61{ return nTracks; }

Referenced by PopFromStack(), and PushToStack().

◆ operator!=()

G4bool G4SmartTrackStack::operator!= ( const G4SmartTrackStack ) const
delete

◆ operator=()

G4SmartTrackStack & G4SmartTrackStack::operator= ( const G4SmartTrackStack )
delete

◆ operator==()

G4bool G4SmartTrackStack::operator== ( const G4SmartTrackStack ) const
delete

◆ PopFromStack()

G4StackedTrack G4SmartTrackStack::PopFromStack ( )

Definition at line 74 of file G4SmartTrackStack.cc.

75{
76 G4StackedTrack aStackedTrack;
77
78 if (nTracks)
79 {
80 while (true)
81 {
82 if (stacks[fTurn]->GetNTrack())
83 {
84 aStackedTrack = stacks[fTurn]->PopFromStack();
85 energies[fTurn] -= aStackedTrack.GetTrack()->GetDynamicParticle()->GetTotalEnergy();
86 --nTracks;
87 break;
88 }
89 else
90 {
91 fTurn = (fTurn+1) % nTurn;
92 }
93 }
94 }
95
96 return aStackedTrack;
97}
G4double GetTotalEnergy() const
G4int GetNTrack() const
G4Track * GetTrack() const
G4StackedTrack PopFromStack()
Definition: G4TrackStack.hh:61
const G4DynamicParticle * GetDynamicParticle() const

◆ PushToStack()

void G4SmartTrackStack::PushToStack ( const G4StackedTrack aStackedTrack)

Definition at line 104 of file G4SmartTrackStack.cc.

105{
106
107 G4int iDest = 0;
108 if (aStackedTrack.GetTrack()->GetParentID())
109 {
110 G4int code = aStackedTrack.GetTrack()->GetDynamicParticle()->GetPDGcode();
111 if (code == electronCode)
112 iDest = 2;
113 else if (code == gammaCode)
114 iDest = 3;
115 else if (code == positronCode)
116 iDest = 4;
117 else if (code == neutronCode)
118 iDest = 1;
119 }
120 else
121 {
122 // We have a primary track, which should go first.
123 fTurn = 0; // reseting the turn
124 }
125 stacks[iDest]->PushToStack(aStackedTrack);
126 energies[iDest] += aStackedTrack.GetTrack()->GetDynamicParticle()->GetTotalEnergy();
127 ++nTracks;
128
129 G4int dy1 = stacks[iDest]->GetNTrack() - stacks[iDest]->GetSafetyValue1();
130 G4int dy2 = stacks[fTurn]->GetNTrack() - stacks[fTurn]->GetSafetyValue2();
131
132 if (dy1 > 0 || dy1 > dy2 ||
133 (iDest == 2 &&
134 stacks[iDest]->GetNTrack() < 50 && energies[iDest] < energies[fTurn]))
135 {
136 fTurn = iDest;
137 }
138
139 if (nTracks > maxNTracks) maxNTracks = nTracks;
140}
@ electronCode
@ neutronCode
@ gammaCode
@ positronCode
G4int GetPDGcode() const
void PushToStack(const G4StackedTrack &aStackedTrack)
Definition: G4TrackStack.hh:59
G4int GetSafetyValue2() const
Definition: G4TrackStack.hh:71
G4int GetSafetyValue1() const
Definition: G4TrackStack.hh:70
G4int GetParentID() const
Definition: inftrees.h:24

Referenced by G4TrackStack::TransferTo().

◆ TransferTo()

void G4SmartTrackStack::TransferTo ( G4TrackStack aStack)

Definition at line 65 of file G4SmartTrackStack.cc.

66{
67 for (G4int i=0; i<nTurn; ++i)
68 {
69 stacks[i]->TransferTo(aStack);
70 }
71 nTracks = 0;
72}
void TransferTo(G4TrackStack *aStack)
Definition: G4TrackStack.cc:51

The documentation for this class was generated from the following files: