Geant4 11.3.0
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4MCTSimParticle Class Reference

#include <G4MCTSimParticle.hh>

Public Member Functions

 G4MCTSimParticle ()
 
 G4MCTSimParticle (const G4String &aname, G4int apcode, G4int atid, G4int ptid, const G4LorentzVector &p)
 
 G4MCTSimParticle (const G4String &aname, G4int apcode, G4int atid, G4int ptid, const G4LorentzVector &p, const G4MCTSimVertex *v)
 
virtual ~G4MCTSimParticle ()
 
 G4MCTSimParticle (const G4MCTSimParticle &right)
 
G4MCTSimParticleoperator= (const G4MCTSimParticle &right)
 
void SetParentParticle (const G4MCTSimParticle *p)
 
G4MCTSimParticleGetParentParticle () const
 
void SetParticleName (const G4String &aname)
 
const G4StringGetParticleName () const
 
void SetPdgID (G4int id)
 
G4int GetPdgID () const
 
void SetTrackID (G4int id)
 
G4int GetTrackID () const
 
void SetParentTrackID (G4int id)
 
G4int GetParentTrackID () const
 
void SetPrimaryFlag (G4bool q)
 
G4bool GetPrimaryFlag () const
 
void SetMomentumAtVertex (const G4LorentzVector &p)
 
const G4LorentzVectorGetMomentumAtVertex () const
 
void SetVertex (const G4MCTSimVertex *v)
 
G4MCTSimVertexGetVertex () const
 
void SetStoreFlag (G4bool q)
 
G4bool GetStoreFlag () const
 
G4int AssociateParticle (G4MCTSimParticle *p)
 
G4int GetNofAssociatedParticles () const
 
G4MCTSimParticleGetAssociatedParticle (G4int i) const
 
G4int GetTreeLevel () const
 
void SetStoreFlagToParentTree (G4bool q=true)
 
void Print (std::ostream &ostr=std::cout, G4bool qrevorder=false) const
 
void PrintSingle (std::ostream &ostr=std::cout) const
 

Protected Attributes

G4MCTSimParticleparentParticle = nullptr
 
std::vector< G4MCTSimParticle * > associatedParticleList
 
G4String name
 
G4LorentzVector momentumAtVertex
 
G4MCTSimVertexvertex = nullptr
 
G4int pdgID = 0
 
G4int trackID = 0
 
G4int parentTrackID = 0
 
G4bool primaryFlag = false
 
G4bool storeFlag = false
 

Detailed Description

Definition at line 45 of file G4MCTSimParticle.hh.

Constructor & Destructor Documentation

◆ G4MCTSimParticle() [1/4]

G4MCTSimParticle::G4MCTSimParticle ( )

◆ G4MCTSimParticle() [2/4]

G4MCTSimParticle::G4MCTSimParticle ( const G4String & aname,
G4int apcode,
G4int atid,
G4int ptid,
const G4LorentzVector & p )

Definition at line 47 of file G4MCTSimParticle.cc.

50 : name(aname)
52 , pdgID(apcode)
53 , trackID(atid)
54 , parentTrackID(ptid)
55{
56}
G4LorentzVector momentumAtVertex

◆ G4MCTSimParticle() [3/4]

G4MCTSimParticle::G4MCTSimParticle ( const G4String & aname,
G4int apcode,
G4int atid,
G4int ptid,
const G4LorentzVector & p,
const G4MCTSimVertex * v )

Definition at line 59 of file G4MCTSimParticle.cc.

63 : name(aname)
65 , vertex(const_cast<G4MCTSimVertex*>(v))
66 , pdgID(apcode)
67 , trackID(atid)
68 , parentTrackID(ptid)
69{
70}
G4MCTSimVertex * vertex

◆ ~G4MCTSimParticle()

G4MCTSimParticle::~G4MCTSimParticle ( )
virtual

Definition at line 73 of file G4MCTSimParticle.cc.

74{
76}
std::vector< G4MCTSimParticle * > associatedParticleList

◆ G4MCTSimParticle() [4/4]

G4MCTSimParticle::G4MCTSimParticle ( const G4MCTSimParticle & right)
inline

Definition at line 117 of file G4MCTSimParticle.hh.

118{
119 *this = right;
120}

Member Function Documentation

◆ AssociateParticle()

G4int G4MCTSimParticle::AssociateParticle ( G4MCTSimParticle * p)

Definition at line 79 of file G4MCTSimParticle.cc.

80{
81 associatedParticleList.push_back(p);
82 p->SetParentParticle(this);
83 return (G4int)associatedParticleList.size();
84}
int G4int
Definition G4Types.hh:85
void SetParentParticle(const G4MCTSimParticle *p)

◆ GetAssociatedParticle()

G4MCTSimParticle * G4MCTSimParticle::GetAssociatedParticle ( G4int i) const

Definition at line 93 of file G4MCTSimParticle.cc.

94{
95 G4int size = (G4int)associatedParticleList.size();
96 if(i >= 0 && i < size)
97 return associatedParticleList[i];
98 else
99 return nullptr;
100}

◆ GetMomentumAtVertex()

const G4LorentzVector & G4MCTSimParticle::GetMomentumAtVertex ( ) const
inline

Definition at line 204 of file G4MCTSimParticle.hh.

205{
206 return momentumAtVertex;
207}

◆ GetNofAssociatedParticles()

G4int G4MCTSimParticle::GetNofAssociatedParticles ( ) const

Definition at line 87 of file G4MCTSimParticle.cc.

88{
89 return (G4int)associatedParticleList.size();
90}

◆ GetParentParticle()

G4MCTSimParticle * G4MCTSimParticle::GetParentParticle ( ) const
inline

Definition at line 144 of file G4MCTSimParticle.hh.

145{
146 return parentParticle;
147}
G4MCTSimParticle * parentParticle

Referenced by GetTreeLevel().

◆ GetParentTrackID()

G4int G4MCTSimParticle::GetParentTrackID ( ) const
inline

Definition at line 194 of file G4MCTSimParticle.hh.

195{
196 return parentTrackID;
197}

◆ GetParticleName()

const G4String & G4MCTSimParticle::GetParticleName ( ) const
inline

Definition at line 154 of file G4MCTSimParticle.hh.

155{
156 return name;
157}

◆ GetPdgID()

G4int G4MCTSimParticle::GetPdgID ( ) const
inline

Definition at line 164 of file G4MCTSimParticle.hh.

165{
166 return pdgID;
167}

◆ GetPrimaryFlag()

G4bool G4MCTSimParticle::GetPrimaryFlag ( ) const
inline

Definition at line 184 of file G4MCTSimParticle.hh.

185{
186 return primaryFlag;
187}

◆ GetStoreFlag()

G4bool G4MCTSimParticle::GetStoreFlag ( ) const
inline

Definition at line 224 of file G4MCTSimParticle.hh.

225{
226 return storeFlag;
227}

◆ GetTrackID()

G4int G4MCTSimParticle::GetTrackID ( ) const
inline

◆ GetTreeLevel()

G4int G4MCTSimParticle::GetTreeLevel ( ) const

Definition at line 103 of file G4MCTSimParticle.cc.

104{
105 const G4MCTSimParticle* p = this;
106 G4int nlevel;
107 for(nlevel = 1;; ++nlevel)
108 {
109 p = p->GetParentParticle();
110 if(p == nullptr)
111 return nlevel;
112 }
113}
G4MCTSimParticle * GetParentParticle() const

◆ GetVertex()

G4MCTSimVertex * G4MCTSimParticle::GetVertex ( ) const
inline

Definition at line 214 of file G4MCTSimParticle.hh.

215{
216 return vertex;
217}

◆ operator=()

G4MCTSimParticle & G4MCTSimParticle::operator= ( const G4MCTSimParticle & right)
inline

Definition at line 122 of file G4MCTSimParticle.hh.

124{
126 associatedParticleList = right.associatedParticleList; // shallow copy
127
128 name = right.name;
129 pdgID = right.pdgID;
130 trackID = right.trackID;
132 primaryFlag = right.primaryFlag;
134 vertex = right.vertex;
135
136 return *this;
137}

◆ Print()

void G4MCTSimParticle::Print ( std::ostream & ostr = std::cout,
G4bool qrevorder = false ) const

Definition at line 181 of file G4MCTSimParticle.cc.

182{
183 PrintSingle(ostr);
184
185 // recursively print associated particles
186 if(!qrevorder)
187 { // parent -> child
188 for(auto itr = associatedParticleList.cbegin();
189 itr != associatedParticleList.cend(); ++itr)
190 {
191 (*itr)->Print(ostr);
192 }
193 }
194 else
195 { // child -> parent
197 parentParticle->Print(ostr, true);
198 }
199}
void PrintSingle(std::ostream &ostr=std::cout) const

◆ PrintSingle()

void G4MCTSimParticle::PrintSingle ( std::ostream & ostr = std::cout) const

Definition at line 128 of file G4MCTSimParticle.cc.

129{
130 std::ostringstream os;
131 char cqp = ' ';
132 if(storeFlag)
133 cqp = '+';
134 os << cqp << trackID << '\0';
135 std::string stid(os.str());
136 ostr << std::setw(6) << stid;
137 // ostr << std::setw(4) << trackID;
138
139 if(primaryFlag)
140 ostr << "*";
141 else
142 ostr << " ";
143 ostr << "<" << std::setw(5) << parentTrackID;
144 ostr.setf(std::ios::fixed);
145 ostr << ": P(" << std::setw(7) << std::setprecision(3)
146 << momentumAtVertex.x() / GeV << "," << std::setw(7)
147 << std::setprecision(3) << momentumAtVertex.y() / GeV << ","
148 << std::setw(7) << std::setprecision(3) << momentumAtVertex.z() / GeV
149 << "," << std::setw(7) << std::setprecision(3)
150 << momentumAtVertex.e() / GeV << ") @";
151 ostr << name << "(" << pdgID << ")";
152
153 if(vertex != nullptr)
154 {
155 ostr << " %" << vertex->GetCreatorProcessName() << G4endl;
156
157 std::ostringstream osv;
158 char cqv = ' ';
159 if(vertex->GetStoreFlag())
160 cqv = '+';
161 osv << cqv << vertex->GetID() << '\0';
162 std::string svid(osv.str());
163 ostr << " " << std::setw(6) << svid;
164 // ostr << " " << std::setw(4) << vertex-> GetID();
165 ostr.unsetf(std::ios::fixed);
166 ostr.setf(std::ios::scientific | std::ios::right | std::ios::showpoint);
167 ostr << "- X(" << std::setw(9) << std::setprecision(2)
168 << vertex->GetPosition().x() / mm << "," << std::setw(9)
169 << std::setprecision(2) << vertex->GetPosition().y() / mm << ","
170 << std::setw(9) << std::setprecision(2)
171 << vertex->GetPosition().z() / mm << "," << std::setw(9)
172 << std::setprecision(2) << vertex->GetTime() / ns << ")";
173 ostr.unsetf(std::ios::scientific);
174
175 ostr << " @" << vertex->GetVolumeName() << "-" << vertex->GetVolumeNumber();
176 }
177 ostr << G4endl;
178}
#define G4endl
Definition G4ios.hh:67
#define ns(x)
Definition xmltok.c:1649

Referenced by Print().

◆ SetMomentumAtVertex()

void G4MCTSimParticle::SetMomentumAtVertex ( const G4LorentzVector & p)
inline

Definition at line 199 of file G4MCTSimParticle.hh.

200{
202}

◆ SetParentParticle()

void G4MCTSimParticle::SetParentParticle ( const G4MCTSimParticle * p)
inline

Definition at line 139 of file G4MCTSimParticle.hh.

140{
141 parentParticle = const_cast<G4MCTSimParticle*>(p);
142}

Referenced by AssociateParticle().

◆ SetParentTrackID()

void G4MCTSimParticle::SetParentTrackID ( G4int id)
inline

Definition at line 189 of file G4MCTSimParticle.hh.

190{
191 parentTrackID = id;
192}

◆ SetParticleName()

void G4MCTSimParticle::SetParticleName ( const G4String & aname)
inline

Definition at line 149 of file G4MCTSimParticle.hh.

150{
151 name = aname;
152}

◆ SetPdgID()

void G4MCTSimParticle::SetPdgID ( G4int id)
inline

Definition at line 159 of file G4MCTSimParticle.hh.

160{
161 pdgID = id;
162}

◆ SetPrimaryFlag()

void G4MCTSimParticle::SetPrimaryFlag ( G4bool q)
inline

Definition at line 179 of file G4MCTSimParticle.hh.

180{
181 primaryFlag = q;
182}

◆ SetStoreFlag()

void G4MCTSimParticle::SetStoreFlag ( G4bool q)
inline

Definition at line 219 of file G4MCTSimParticle.hh.

220{
221 storeFlag = q;
222}

◆ SetStoreFlagToParentTree()

void G4MCTSimParticle::SetStoreFlagToParentTree ( G4bool q = true)

Definition at line 116 of file G4MCTSimParticle.cc.

117{
118 storeFlag = q;
119 if(vertex)
120 vertex->SetStoreFlag(q);
121 if(primaryFlag)
122 return;
124 parentParticle->SetStoreFlagToParentTree(q);
125}

◆ SetTrackID()

void G4MCTSimParticle::SetTrackID ( G4int id)
inline

Definition at line 169 of file G4MCTSimParticle.hh.

170{
171 trackID = id;
172}

◆ SetVertex()

void G4MCTSimParticle::SetVertex ( const G4MCTSimVertex * v)
inline

Definition at line 209 of file G4MCTSimParticle.hh.

210{
211 vertex = const_cast<G4MCTSimVertex*>(v);
212}

Member Data Documentation

◆ associatedParticleList

std::vector<G4MCTSimParticle*> G4MCTSimParticle::associatedParticleList
protected

◆ momentumAtVertex

G4LorentzVector G4MCTSimParticle::momentumAtVertex
protected

◆ name

G4String G4MCTSimParticle::name
protected

◆ parentParticle

G4MCTSimParticle* G4MCTSimParticle::parentParticle = nullptr
protected

◆ parentTrackID

G4int G4MCTSimParticle::parentTrackID = 0
protected

◆ pdgID

G4int G4MCTSimParticle::pdgID = 0
protected

◆ primaryFlag

G4bool G4MCTSimParticle::primaryFlag = false
protected

◆ storeFlag

G4bool G4MCTSimParticle::storeFlag = false
protected

◆ trackID

G4int G4MCTSimParticle::trackID = 0
protected

◆ vertex

G4MCTSimVertex* G4MCTSimParticle::vertex = nullptr
protected

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