Geant4 Cross Reference |
1 // 2 // ******************************************************************** 3 // * License and Disclaimer * 4 // * * 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. * 10 // * * 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitation of liability. * 17 // * * 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************************************** 25 // 26 // G4MCTSimParticle 27 28 // Author: Youhei Morita, 12.09.2001 29 // -------------------------------------------------------------------- 30 #ifndef G4MCTSIMPARTICLE_HH 31 #define G4MCTSIMPARTICLE_HH 1 32 33 #include <vector> 34 #include <iostream> 35 36 #include "G4String.hh" 37 #include "G4Types.hh" 38 #include "G4LorentzVector.hh" 39 40 class G4MCTSimVertex; 41 class G4MCTSimParticle; 42 43 using SimParticleList = std::vector<G4MCTSimParticle*>; 44 45 class G4MCTSimParticle 46 { 47 public: 48 49 G4MCTSimParticle(); 50 G4MCTSimParticle(const G4String& aname, 51 G4int apcode, G4int atid, G4int ptid, 52 const G4LorentzVector& p); 53 G4MCTSimParticle(const G4String& aname, 54 G4int apcode, G4int atid, G4int ptid, 55 const G4LorentzVector& p, const G4MCTSimVertex* v); 56 virtual ~G4MCTSimParticle(); 57 58 inline G4MCTSimParticle(const G4MCTSimParticle& right); 59 inline G4MCTSimParticle& operator=(const G4MCTSimParticle& right); 60 // copy constructor and assignment operator 61 62 inline void SetParentParticle(const G4MCTSimParticle* p); 63 inline G4MCTSimParticle* GetParentParticle() const; 64 65 inline void SetParticleName(const G4String& aname); 66 inline const G4String& GetParticleName() const; 67 68 inline void SetPdgID(G4int id); 69 inline G4int GetPdgID() const; 70 71 inline void SetTrackID(G4int id); 72 inline G4int GetTrackID() const; 73 74 inline void SetParentTrackID(G4int id); 75 inline G4int GetParentTrackID() const; 76 77 inline void SetPrimaryFlag(G4bool q); 78 inline G4bool GetPrimaryFlag() const; 79 80 inline void SetMomentumAtVertex(const G4LorentzVector& p); 81 inline const G4LorentzVector& GetMomentumAtVertex() const; 82 83 inline void SetVertex(const G4MCTSimVertex* v); 84 inline G4MCTSimVertex* GetVertex() const; 85 86 inline void SetStoreFlag(G4bool q); 87 inline G4bool GetStoreFlag() const; 88 89 G4int AssociateParticle(G4MCTSimParticle* p); 90 G4int GetNofAssociatedParticles() const; 91 G4MCTSimParticle* GetAssociatedParticle(G4int i) const; 92 G4int GetTreeLevel() const; 93 void SetStoreFlagToParentTree(G4bool q = true); 94 95 void Print(std::ostream& ostr = std::cout, G4bool qrevorder = false) const; 96 void PrintSingle(std::ostream& ostr = std::cout) const; 97 98 protected: 99 100 G4MCTSimParticle* parentParticle = nullptr; 101 std::vector<G4MCTSimParticle*> associatedParticleList; 102 103 G4String name; 104 G4LorentzVector momentumAtVertex; 105 G4MCTSimVertex* vertex = nullptr; 106 G4int pdgID = 0; 107 G4int trackID = 0; 108 G4int parentTrackID = 0; 109 G4bool primaryFlag = false; 110 G4bool storeFlag = false; 111 }; 112 113 // ==================================================================== 114 // inline methods 115 // ==================================================================== 116 117 inline G4MCTSimParticle::G4MCTSimParticle(const G4MCTSimParticle& right) 118 { 119 *this = right; 120 } 121 122 inline G4MCTSimParticle& G4MCTSimParticle::operator=( 123 const G4MCTSimParticle& right) 124 { 125 parentParticle = right.parentParticle; 126 associatedParticleList = right.associatedParticleList; // shallow copy 127 128 name = right.name; 129 pdgID = right.pdgID; 130 trackID = right.trackID; 131 parentTrackID = right.parentTrackID; 132 primaryFlag = right.primaryFlag; 133 momentumAtVertex = right.momentumAtVertex; 134 vertex = right.vertex; 135 136 return *this; 137 } 138 139 inline void G4MCTSimParticle::SetParentParticle(const G4MCTSimParticle* p) 140 { 141 parentParticle = const_cast<G4MCTSimParticle*>(p); 142 } 143 144 inline G4MCTSimParticle* G4MCTSimParticle::GetParentParticle() const 145 { 146 return parentParticle; 147 } 148 149 inline void G4MCTSimParticle::SetParticleName(const G4String& aname) 150 { 151 name = aname; 152 } 153 154 inline const G4String& G4MCTSimParticle::GetParticleName() const 155 { 156 return name; 157 } 158 159 inline void G4MCTSimParticle::SetPdgID(G4int id) 160 { 161 pdgID = id; 162 } 163 164 inline G4int G4MCTSimParticle::GetPdgID() const 165 { 166 return pdgID; 167 } 168 169 inline void G4MCTSimParticle::SetTrackID(G4int id) 170 { 171 trackID = id; 172 } 173 174 inline G4int G4MCTSimParticle::GetTrackID() const 175 { 176 return trackID; 177 } 178 179 inline void G4MCTSimParticle::SetPrimaryFlag(G4bool q) 180 { 181 primaryFlag = q; 182 } 183 184 inline G4bool G4MCTSimParticle::GetPrimaryFlag() const 185 { 186 return primaryFlag; 187 } 188 189 inline void G4MCTSimParticle::SetParentTrackID(G4int id) 190 { 191 parentTrackID = id; 192 } 193 194 inline G4int G4MCTSimParticle::GetParentTrackID() const 195 { 196 return parentTrackID; 197 } 198 199 inline void G4MCTSimParticle::SetMomentumAtVertex(const G4LorentzVector& p) 200 { 201 momentumAtVertex = p; 202 } 203 204 inline const G4LorentzVector& G4MCTSimParticle::GetMomentumAtVertex() const 205 { 206 return momentumAtVertex; 207 } 208 209 inline void G4MCTSimParticle::SetVertex(const G4MCTSimVertex* v) 210 { 211 vertex = const_cast<G4MCTSimVertex*>(v); 212 } 213 214 inline G4MCTSimVertex* G4MCTSimParticle::GetVertex() const 215 { 216 return vertex; 217 } 218 219 inline void G4MCTSimParticle::SetStoreFlag(G4bool q) 220 { 221 storeFlag = q; 222 } 223 224 inline G4bool G4MCTSimParticle::GetStoreFlag() const 225 { 226 return storeFlag; 227 } 228 229 #endif 230