Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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 (std::string 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 46 of file G4MCTSimParticle.hh.

Constructor & Destructor Documentation

◆ G4MCTSimParticle() [1/4]

G4MCTSimParticle::G4MCTSimParticle ( )

Definition at line 42 of file G4MCTSimParticle.cc.

43{
44}

◆ 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 118 of file G4MCTSimParticle.hh.

119{
120 *this = right;
121}

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 205 of file G4MCTSimParticle.hh.

206{
207 return momentumAtVertex;
208}

◆ 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 145 of file G4MCTSimParticle.hh.

146{
147 return parentParticle;
148}
G4MCTSimParticle * parentParticle

Referenced by GetTreeLevel().

◆ GetParentTrackID()

G4int G4MCTSimParticle::GetParentTrackID ( ) const
inline

Definition at line 195 of file G4MCTSimParticle.hh.

196{
197 return parentTrackID;
198}

◆ GetParticleName()

const G4String & G4MCTSimParticle::GetParticleName ( ) const
inline

Definition at line 155 of file G4MCTSimParticle.hh.

156{
157 return name;
158}

◆ GetPdgID()

G4int G4MCTSimParticle::GetPdgID ( ) const
inline

Definition at line 165 of file G4MCTSimParticle.hh.

166{
167 return pdgID;
168}

◆ GetPrimaryFlag()

G4bool G4MCTSimParticle::GetPrimaryFlag ( ) const
inline

Definition at line 185 of file G4MCTSimParticle.hh.

186{
187 return primaryFlag;
188}

◆ GetStoreFlag()

G4bool G4MCTSimParticle::GetStoreFlag ( ) const
inline

Definition at line 225 of file G4MCTSimParticle.hh.

226{
227 return storeFlag;
228}

◆ 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 215 of file G4MCTSimParticle.hh.

216{
217 return vertex;
218}

◆ operator=()

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

Definition at line 123 of file G4MCTSimParticle.hh.

125{
127 associatedParticleList = right.associatedParticleList; // shallow copy
128
129 name = right.name;
130 pdgID = right.pdgID;
131 trackID = right.trackID;
133 primaryFlag = right.primaryFlag;
135 vertex = right.vertex;
136
137 return *this;
138}

◆ 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 Print(std::ostream &ostr=std::cout, G4bool qrevorder=false) const
void PrintSingle(std::ostream &ostr=std::cout) const

Referenced by Print().

◆ 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:57
double z() const
double x() const
double y() const
G4int GetVolumeNumber() const
const G4ThreeVector & GetPosition() const
G4double GetTime() const
const G4String & GetCreatorProcessName() const
G4int GetID() const
const G4String & GetVolumeName() const
G4bool GetStoreFlag() const
#define ns(x)
Definition: xmltok.c:1649

Referenced by Print().

◆ SetMomentumAtVertex()

void G4MCTSimParticle::SetMomentumAtVertex ( const G4LorentzVector p)
inline

Definition at line 200 of file G4MCTSimParticle.hh.

201{
203}

◆ SetParentParticle()

void G4MCTSimParticle::SetParentParticle ( const G4MCTSimParticle p)
inline

Definition at line 140 of file G4MCTSimParticle.hh.

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

Referenced by AssociateParticle().

◆ SetParentTrackID()

void G4MCTSimParticle::SetParentTrackID ( G4int  id)
inline

Definition at line 190 of file G4MCTSimParticle.hh.

191{
192 parentTrackID = id;
193}

◆ SetParticleName()

void G4MCTSimParticle::SetParticleName ( std::string  aname)
inline

Definition at line 150 of file G4MCTSimParticle.hh.

151{
152 name = aname;
153}

◆ SetPdgID()

void G4MCTSimParticle::SetPdgID ( G4int  id)
inline

Definition at line 160 of file G4MCTSimParticle.hh.

161{
162 pdgID = id;
163}

◆ SetPrimaryFlag()

void G4MCTSimParticle::SetPrimaryFlag ( G4bool  q)
inline

Definition at line 180 of file G4MCTSimParticle.hh.

181{
182 primaryFlag = q;
183}

◆ SetStoreFlag()

void G4MCTSimParticle::SetStoreFlag ( G4bool  q)
inline

Definition at line 220 of file G4MCTSimParticle.hh.

221{
222 storeFlag = q;
223}

◆ SetStoreFlagToParentTree()

void G4MCTSimParticle::SetStoreFlagToParentTree ( G4bool  q = true)

Definition at line 116 of file G4MCTSimParticle.cc.

117{
118 storeFlag = q;
119 if(vertex)
121 if(primaryFlag)
122 return;
125}
void SetStoreFlagToParentTree(G4bool q=true)
void SetStoreFlag(G4bool q)

Referenced by SetStoreFlagToParentTree().

◆ SetTrackID()

void G4MCTSimParticle::SetTrackID ( G4int  id)
inline

Definition at line 170 of file G4MCTSimParticle.hh.

171{
172 trackID = id;
173}

◆ SetVertex()

void G4MCTSimParticle::SetVertex ( const G4MCTSimVertex v)
inline

Definition at line 210 of file G4MCTSimParticle.hh.

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

Member Data Documentation

◆ associatedParticleList

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

◆ momentumAtVertex

G4LorentzVector G4MCTSimParticle::momentumAtVertex
protected

◆ name

G4String G4MCTSimParticle::name
protected

Definition at line 104 of file G4MCTSimParticle.hh.

Referenced by GetParticleName(), operator=(), PrintSingle(), and SetParticleName().

◆ parentParticle

G4MCTSimParticle* G4MCTSimParticle::parentParticle = nullptr
protected

◆ parentTrackID

G4int G4MCTSimParticle::parentTrackID = 0
protected

Definition at line 109 of file G4MCTSimParticle.hh.

Referenced by GetParentTrackID(), operator=(), PrintSingle(), and SetParentTrackID().

◆ pdgID

G4int G4MCTSimParticle::pdgID = 0
protected

Definition at line 107 of file G4MCTSimParticle.hh.

Referenced by GetPdgID(), operator=(), PrintSingle(), and SetPdgID().

◆ primaryFlag

G4bool G4MCTSimParticle::primaryFlag = false
protected

◆ storeFlag

G4bool G4MCTSimParticle::storeFlag = false
protected

◆ trackID

G4int G4MCTSimParticle::trackID = 0
protected

Definition at line 108 of file G4MCTSimParticle.hh.

Referenced by GetTrackID(), operator=(), PrintSingle(), and SetTrackID().

◆ vertex

G4MCTSimVertex* G4MCTSimParticle::vertex = nullptr
protected

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