VMC Examples Version 6.6
Loading...
Searching...
No Matches
Ex01MCStack Class Reference

Implementation of the TVirtualMCStack interface. More...

#include <Ex01MCStack.h>

Inheritance diagram for Ex01MCStack:

Public Member Functions

 Ex01MCStack (Int_t size)
 
 Ex01MCStack ()
 
virtual ~Ex01MCStack ()
 
virtual void PushTrack (Int_t toBeDone, Int_t parent, Int_t pdg, Double_t px, Double_t py, Double_t pz, Double_t e, Double_t vx, Double_t vy, Double_t vz, Double_t tof, Double_t polx, Double_t poly, Double_t polz, TMCProcess mech, Int_t &ntr, Double_t weight, Int_t is)
 
virtual TParticle * PopNextTrack (Int_t &itrack)
 
virtual TParticle * PopPrimaryForTracking (Int_t i)
 
virtual void SetCurrentTrack (Int_t itrack)
 
virtual Int_t GetNtrack () const
 
virtual Int_t GetNprimary () const
 
virtual TParticle * GetCurrentTrack () const
 
virtual Int_t GetCurrentTrackNumber () const
 
virtual Int_t GetCurrentParentTrackNumber () const
 

Private Member Functions

Ex01ParticleGetParticle (Int_t id) const
 

Private Attributes

std::stack< Ex01Particle * > fStack
 The stack of particles (transient)
 
TObjArray * fParticles
 The array of particle (persistent)
 
Int_t fCurrentTrack
 The current track number.
 
Int_t fNPrimary
 The number of primaries.
 

Detailed Description

Implementation of the TVirtualMCStack interface.

Date
05/04/2002
Author
I. Hrivnacova; IPN, Orsay

Definition at line 32 of file Ex01MCStack.h.

Constructor & Destructor Documentation

◆ Ex01MCStack() [1/2]

Ex01MCStack::Ex01MCStack ( Int_t size)

Standard constructor

Parameters
sizeThe stack size

Definition at line 29 of file Ex01MCStack.cxx.

31{
32 /// Standard constructor
33 /// \param size The stack size
34
35 fParticles = new TObjArray(size);
36}
TObjArray * fParticles
The array of particle (persistent)
Definition Ex01MCStack.h:63
Int_t fNPrimary
The number of primaries.
Definition Ex01MCStack.h:65
Int_t fCurrentTrack
The current track number.
Definition Ex01MCStack.h:64

◆ Ex01MCStack() [2/2]

Ex01MCStack::Ex01MCStack ( )

Default constructor

Definition at line 39 of file Ex01MCStack.cxx.

40{
41 /// Default constructor
42}

◆ ~Ex01MCStack()

Ex01MCStack::~Ex01MCStack ( )
virtual

Destructor

Definition at line 45 of file Ex01MCStack.cxx.

46{
47 /// Destructor
48
49 if (fParticles) fParticles->Delete();
50 delete fParticles;
51}

Member Function Documentation

◆ PushTrack()

void Ex01MCStack::PushTrack ( Int_t toBeDone,
Int_t parent,
Int_t pdg,
Double_t px,
Double_t py,
Double_t pz,
Double_t e,
Double_t vx,
Double_t vy,
Double_t vz,
Double_t tof,
Double_t polx,
Double_t poly,
Double_t polz,
TMCProcess mech,
Int_t & ntr,
Double_t weight,
Int_t is )
virtual

Create a new particle and push into stack; adds it to the particles array (fParticles) and if not done to the stack (fStack).

Parameters
toBeDone1 if particles should go to tracking, 0 otherwise
parentnumber of the parent track, -1 if track is primary
pdgPDG encoding
pxparticle momentum - x component [GeV/c]
pyparticle momentum - y component [GeV/c]
pzparticle momentum - z component [GeV/c]
etotal energy [GeV]
vxposition - x component [cm]
vyposition - y component [cm]
vzposition - z component [cm]
toftime of flight [s]
polxpolarization - x component
polypolarization - y component
polzpolarization - z component
mechcreator process VMC code
ntrtrack number (is filled by the stack
weightparticle weight
isgeneration status code

Definition at line 70 of file Ex01MCStack.cxx.

74{
75 /// Create a new particle and push into stack;
76 /// adds it to the particles array (fParticles) and if not done to the
77 /// stack (fStack).
78 /// \param toBeDone 1 if particles should go to tracking, 0 otherwise
79 /// \param parent number of the parent track, -1 if track is primary
80 /// \param pdg PDG encoding
81 /// \param px particle momentum - x component [GeV/c]
82 /// \param py particle momentum - y component [GeV/c]
83 /// \param pz particle momentum - z component [GeV/c]
84 /// \param e total energy [GeV]
85 /// \param vx position - x component [cm]
86 /// \param vy position - y component [cm]
87 /// \param vz position - z component [cm]
88 /// \param tof time of flight [s]
89 /// \param polx polarization - x component
90 /// \param poly polarization - y component
91 /// \param polz polarization - z component
92 /// \param mech creator process VMC code
93 /// \param ntr track number (is filled by the stack
94 /// \param weight particle weight
95 /// \param is generation status code
96
97 const Int_t kFirstDaughter = -1;
98 const Int_t kLastDaughter = -1;
99
100 TParticle* particleDef = new TParticle(pdg, is, parent, -1, kFirstDaughter,
101 kLastDaughter, px, py, pz, e, vx, vy, vz, tof);
102
103 particleDef->SetPolarisation(polx, poly, polz);
104 particleDef->SetWeight(weight);
105 particleDef->SetUniqueID(mech);
106
107 Ex01Particle* mother = 0;
108 if (parent >= 0)
109 mother = GetParticle(parent);
110 else
111 fNPrimary++;
112
113 Ex01Particle* particle = new Ex01Particle(GetNtrack(), particleDef, mother);
114
115 fParticles->Add(particle);
116
117 if (toBeDone) fStack.push(particle);
118
119 ntr = GetNtrack() - 1;
120}
virtual Int_t GetNtrack() const
Ex01Particle * GetParticle(Int_t id) const
std::stack< Ex01Particle * > fStack
The stack of particles (transient)
Definition Ex01MCStack.h:62
Extended TParticle with pointers to mother and daughter particles.

◆ PopNextTrack()

TParticle * Ex01MCStack::PopNextTrack ( Int_t & itrack)
virtual

Get next particle for tracking from the stack.

Returns
The popped particle object
Parameters
itrackThe index of the popped track

Definition at line 123 of file Ex01MCStack.cxx.

124{
125 /// Get next particle for tracking from the stack.
126 /// \return The popped particle object
127 /// \param itrack The index of the popped track
128
129 itrack = -1;
130 if (fStack.empty()) return 0;
131
132 Ex01Particle* particle = fStack.top();
133 fStack.pop();
134
135 if (!particle) return 0;
136
137 itrack = particle->GetID();
138 fCurrentTrack = itrack;
139
140 return particle->GetParticle();
141}
Int_t GetID() const
TParticle * GetParticle() const

◆ PopPrimaryForTracking()

TParticle * Ex01MCStack::PopPrimaryForTracking ( Int_t i)
virtual

Return i -th particle in fParticles.

Returns
The popped primary particle object
Parameters
iThe index of primary particle to be popped

Definition at line 144 of file Ex01MCStack.cxx.

145{
146 /// Return \em i -th particle in fParticles.
147 /// \return The popped primary particle object
148 /// \param i The index of primary particle to be popped
149
150 if (i < 0 || i >= fNPrimary)
151 Fatal("GetPrimaryForTracking", "Index out of range");
152
153 return ((Ex01Particle*)fParticles->At(i))->GetParticle();
154}

◆ SetCurrentTrack()

void Ex01MCStack::SetCurrentTrack ( Int_t itrack)
virtual

Set the current track number to a given value.

Parameters
itrackThe current track number

Definition at line 157 of file Ex01MCStack.cxx.

158{
159 /// Set the current track number to a given value.
160 /// \param itrack The current track number
161
162 fCurrentTrack = itrack;
163}

◆ GetNtrack()

Int_t Ex01MCStack::GetNtrack ( ) const
virtual
Returns
The total number of all tracks.

Definition at line 166 of file Ex01MCStack.cxx.

167{
168 /// \return The total number of all tracks.
169
170 return fParticles->GetEntriesFast();
171}

◆ GetNprimary()

Int_t Ex01MCStack::GetNprimary ( ) const
virtual
Returns
The total number of primary tracks.

Definition at line 174 of file Ex01MCStack.cxx.

175{
176 /// \return The total number of primary tracks.
177
178 return fNPrimary;
179}

◆ GetCurrentTrack()

TParticle * Ex01MCStack::GetCurrentTrack ( ) const
virtual
Returns
The current track particle

Definition at line 182 of file Ex01MCStack.cxx.

183{
184 /// \return The current track particle
185
187
188 if (current)
189 return current->GetParticle();
190 else
191 return 0;
192}

◆ GetCurrentTrackNumber()

Int_t Ex01MCStack::GetCurrentTrackNumber ( ) const
virtual
Returns
The current track number

Definition at line 195 of file Ex01MCStack.cxx.

196{
197 /// \return The current track number
198
199 return fCurrentTrack;
200}

◆ GetCurrentParentTrackNumber()

Int_t Ex01MCStack::GetCurrentParentTrackNumber ( ) const
virtual
Returns
The current track parent ID.

Definition at line 202 of file Ex01MCStack.cxx.

203{
204 /// \return The current track parent ID.
205
207
208 if (!current) return -1;
209
210 Ex01Particle* mother = current->GetMother();
211
212 if (!mother) return -1;
213
214 return mother->GetID();
215}
Ex01Particle * GetMother() const

◆ GetParticle()

Ex01Particle * Ex01MCStack::GetParticle ( Int_t id) const
private
Returns
The id -th particle in fParticles
Parameters
idThe index of the particle to be returned

Definition at line 56 of file Ex01MCStack.cxx.

57{
58 /// \return The \em id -th particle in fParticles
59 /// \param id The index of the particle to be returned
60
61 if (id < 0 || id >= fParticles->GetEntriesFast())
62 Fatal("GetParticle", "Index out of range");
63
64 return (Ex01Particle*)fParticles->At(id);
65}

Member Data Documentation

◆ fStack

std::stack<Ex01Particle*> Ex01MCStack::fStack
private

The stack of particles (transient)

Definition at line 62 of file Ex01MCStack.h.

◆ fParticles

TObjArray* Ex01MCStack::fParticles
private

The array of particle (persistent)

Definition at line 63 of file Ex01MCStack.h.

◆ fCurrentTrack

Int_t Ex01MCStack::fCurrentTrack
private

The current track number.

Definition at line 64 of file Ex01MCStack.h.

◆ fNPrimary

Int_t Ex01MCStack::fNPrimary
private

The number of primaries.

Definition at line 65 of file Ex01MCStack.h.


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