Geant4-11
Public Member Functions | Protected Attributes
G4MCTSimParticle Class Reference

#include <G4MCTSimParticle.hh>

Public Member Functions

G4int AssociateParticle (G4MCTSimParticle *p)
 
 G4MCTSimParticle ()
 
 G4MCTSimParticle (const G4MCTSimParticle &right)
 
 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)
 
G4MCTSimParticle * GetAssociatedParticle (G4int i) const
 
const G4LorentzVector & GetMomentumAtVertex () const
 
G4int GetNofAssociatedParticles () const
 
G4MCTSimParticle * GetParentParticle () const
 
G4int GetParentTrackID () const
 
const G4String & GetParticleName () const
 
G4int GetPdgID () const
 
G4bool GetPrimaryFlag () const
 
G4bool GetStoreFlag () const
 
G4int GetTrackID () const
 
G4int GetTreeLevel () const
 
G4MCTSimVertex * GetVertex () const
 
G4MCTSimParticle & operator= (const G4MCTSimParticle &right)
 
void Print (std::ostream &ostr=std::cout, G4bool qrevorder=false) const
 
void PrintSingle (std::ostream &ostr=std::cout) const
 
void SetMomentumAtVertex (const G4LorentzVector &p)
 
void SetParentParticle (const G4MCTSimParticle *p)
 
void SetParentTrackID (G4int id)
 
void SetParticleName (std::string aname)
 
void SetPdgID (G4int id)
 
void SetPrimaryFlag (G4bool q)
 
void SetStoreFlag (G4bool q)
 
void SetStoreFlagToParentTree (G4bool q=true)
 
void SetTrackID (G4int id)
 
void SetVertex (const G4MCTSimVertex *v)
 
virtual ~G4MCTSimParticle ()
 

Protected Attributes

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

Detailed Description

Definition at line 45 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

References 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 associatedParticleList.size();
84}
void SetParentParticle(const G4MCTSimParticle *p)

References associatedParticleList, and SetParentParticle().

◆ GetAssociatedParticle()

G4MCTSimParticle * G4MCTSimParticle::GetAssociatedParticle ( G4int  i) const

Definition at line 93 of file G4MCTSimParticle.cc.

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

References associatedParticleList.

◆ GetMomentumAtVertex()

const G4LorentzVector & G4MCTSimParticle::GetMomentumAtVertex ( ) const
inline

Definition at line 204 of file G4MCTSimParticle.hh.

205{
206 return momentumAtVertex;
207}

References momentumAtVertex.

◆ GetNofAssociatedParticles()

G4int G4MCTSimParticle::GetNofAssociatedParticles ( ) const

Definition at line 87 of file G4MCTSimParticle.cc.

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

References associatedParticleList.

◆ GetParentParticle()

G4MCTSimParticle * G4MCTSimParticle::GetParentParticle ( ) const
inline

Definition at line 144 of file G4MCTSimParticle.hh.

145{
146 return parentParticle;
147}
G4MCTSimParticle * parentParticle

References parentParticle.

Referenced by GetTreeLevel().

◆ GetParentTrackID()

G4int G4MCTSimParticle::GetParentTrackID ( ) const
inline

Definition at line 194 of file G4MCTSimParticle.hh.

195{
196 return parentTrackID;
197}

References parentTrackID.

◆ GetParticleName()

const G4String & G4MCTSimParticle::GetParticleName ( ) const
inline

Definition at line 154 of file G4MCTSimParticle.hh.

155{
156 return name;
157}

References name.

◆ GetPdgID()

G4int G4MCTSimParticle::GetPdgID ( ) const
inline

Definition at line 164 of file G4MCTSimParticle.hh.

165{
166 return pdgID;
167}

References pdgID.

◆ GetPrimaryFlag()

G4bool G4MCTSimParticle::GetPrimaryFlag ( ) const
inline

Definition at line 184 of file G4MCTSimParticle.hh.

185{
186 return primaryFlag;
187}

References primaryFlag.

◆ GetStoreFlag()

G4bool G4MCTSimParticle::GetStoreFlag ( ) const
inline

Definition at line 224 of file G4MCTSimParticle.hh.

225{
226 return storeFlag;
227}

References storeFlag.

◆ GetTrackID()

G4int G4MCTSimParticle::GetTrackID ( ) const
inline

Definition at line 174 of file G4MCTSimParticle.hh.

175{
176 return trackID;
177}

References trackID.

Referenced by G4MCTSimVertex::AddOutParticle(), G4MCTSimEvent::AddParticle(), and G4MCTSimVertex::SetInParticle().

◆ 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

References GetParentParticle().

◆ GetVertex()

G4MCTSimVertex * G4MCTSimParticle::GetVertex ( ) const
inline

Definition at line 214 of file G4MCTSimParticle.hh.

215{
216 return vertex;
217}

References vertex.

◆ 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}

References associatedParticleList, momentumAtVertex, name, parentParticle, parentTrackID, pdgID, primaryFlag, trackID, and vertex.

◆ 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

References associatedParticleList, parentParticle, Print(), and PrintSingle().

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}
static constexpr double mm
Definition: G4SIunits.hh:95
static constexpr double GeV
Definition: G4SIunits.hh:203
#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
Definition: xmlparse.cc:614

References CLHEP::HepLorentzVector::e(), G4endl, G4MCTSimVertex::GetCreatorProcessName(), G4MCTSimVertex::GetID(), G4MCTSimVertex::GetPosition(), G4MCTSimVertex::GetStoreFlag(), G4MCTSimVertex::GetTime(), G4MCTSimVertex::GetVolumeName(), G4MCTSimVertex::GetVolumeNumber(), GeV, mm, momentumAtVertex, name, ns, parentTrackID, pdgID, primaryFlag, storeFlag, trackID, vertex, CLHEP::HepLorentzVector::x(), CLHEP::Hep3Vector::x(), CLHEP::HepLorentzVector::y(), CLHEP::Hep3Vector::y(), CLHEP::HepLorentzVector::z(), and CLHEP::Hep3Vector::z().

Referenced by Print().

◆ SetMomentumAtVertex()

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

Definition at line 199 of file G4MCTSimParticle.hh.

200{
202}

References momentumAtVertex.

◆ SetParentParticle()

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

Definition at line 139 of file G4MCTSimParticle.hh.

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

References parentParticle.

Referenced by AssociateParticle().

◆ SetParentTrackID()

void G4MCTSimParticle::SetParentTrackID ( G4int  id)
inline

Definition at line 189 of file G4MCTSimParticle.hh.

190{
191 parentTrackID = id;
192}

References parentTrackID.

◆ SetParticleName()

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

Definition at line 149 of file G4MCTSimParticle.hh.

150{
151 name = aname;
152}

References name.

◆ SetPdgID()

void G4MCTSimParticle::SetPdgID ( G4int  id)
inline

Definition at line 159 of file G4MCTSimParticle.hh.

160{
161 pdgID = id;
162}

References pdgID.

◆ SetPrimaryFlag()

void G4MCTSimParticle::SetPrimaryFlag ( G4bool  q)
inline

Definition at line 179 of file G4MCTSimParticle.hh.

180{
181 primaryFlag = q;
182}

References primaryFlag.

◆ SetStoreFlag()

void G4MCTSimParticle::SetStoreFlag ( G4bool  q)
inline

Definition at line 219 of file G4MCTSimParticle.hh.

220{
221 storeFlag = q;
222}

References storeFlag.

◆ 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)

References parentParticle, primaryFlag, G4MCTSimVertex::SetStoreFlag(), SetStoreFlagToParentTree(), storeFlag, and vertex.

Referenced by SetStoreFlagToParentTree().

◆ SetTrackID()

void G4MCTSimParticle::SetTrackID ( G4int  id)
inline

Definition at line 169 of file G4MCTSimParticle.hh.

170{
171 trackID = id;
172}

References trackID.

◆ SetVertex()

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

Definition at line 209 of file G4MCTSimParticle.hh.

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

References vertex.

Field 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

Definition at line 108 of file G4MCTSimParticle.hh.

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

◆ pdgID

G4int G4MCTSimParticle::pdgID = 0
protected

Definition at line 106 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 107 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: