Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 09:15:03

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // G4MCTSimParticle
0027 
0028 // Author: Youhei Morita, 12.09.2001
0029 // --------------------------------------------------------------------
0030 #ifndef G4MCTSIMPARTICLE_HH
0031 #define G4MCTSIMPARTICLE_HH 1
0032 
0033 #include <vector>
0034 #include <iostream>
0035 
0036 #include "G4String.hh"
0037 #include "G4Types.hh"
0038 #include "G4LorentzVector.hh"
0039 
0040 class G4MCTSimVertex;
0041 class G4MCTSimParticle;
0042 
0043 using SimParticleList = std::vector<G4MCTSimParticle*>;
0044 
0045 class G4MCTSimParticle
0046 {
0047   public:
0048 
0049     G4MCTSimParticle();
0050     G4MCTSimParticle(const G4String& aname,
0051                      G4int apcode, G4int atid, G4int ptid,
0052                      const G4LorentzVector& p);
0053     G4MCTSimParticle(const G4String& aname,
0054                      G4int apcode, G4int atid, G4int ptid,
0055                      const G4LorentzVector& p, const G4MCTSimVertex* v);
0056     virtual ~G4MCTSimParticle();
0057 
0058     inline G4MCTSimParticle(const G4MCTSimParticle& right);
0059     inline G4MCTSimParticle& operator=(const G4MCTSimParticle& right);
0060       // copy constructor and assignment operator
0061 
0062     inline void SetParentParticle(const G4MCTSimParticle* p);
0063     inline G4MCTSimParticle* GetParentParticle() const;
0064 
0065     inline void SetParticleName(const G4String& aname);
0066     inline const G4String& GetParticleName() const;
0067 
0068     inline void SetPdgID(G4int id);
0069     inline G4int GetPdgID() const;
0070 
0071     inline void SetTrackID(G4int id);
0072     inline G4int GetTrackID() const;
0073 
0074     inline void SetParentTrackID(G4int id);
0075     inline G4int GetParentTrackID() const;
0076 
0077     inline void SetPrimaryFlag(G4bool q);
0078     inline G4bool GetPrimaryFlag() const;
0079 
0080     inline void SetMomentumAtVertex(const G4LorentzVector& p);
0081     inline const G4LorentzVector& GetMomentumAtVertex() const;
0082 
0083     inline void SetVertex(const G4MCTSimVertex* v);
0084     inline G4MCTSimVertex* GetVertex() const;
0085 
0086     inline void SetStoreFlag(G4bool q);
0087     inline G4bool GetStoreFlag() const;
0088 
0089     G4int AssociateParticle(G4MCTSimParticle* p);
0090     G4int GetNofAssociatedParticles() const;
0091     G4MCTSimParticle* GetAssociatedParticle(G4int i) const;
0092     G4int GetTreeLevel() const;
0093     void SetStoreFlagToParentTree(G4bool q = true);
0094 
0095     void Print(std::ostream& ostr = std::cout, G4bool qrevorder = false) const;
0096     void PrintSingle(std::ostream& ostr = std::cout) const;
0097 
0098   protected:
0099 
0100     G4MCTSimParticle* parentParticle = nullptr;
0101     std::vector<G4MCTSimParticle*> associatedParticleList;
0102 
0103     G4String name;
0104     G4LorentzVector momentumAtVertex;
0105     G4MCTSimVertex* vertex = nullptr;
0106     G4int pdgID = 0;
0107     G4int trackID = 0;
0108     G4int parentTrackID = 0;
0109     G4bool primaryFlag = false;
0110     G4bool storeFlag = false;
0111 };
0112 
0113 // ====================================================================
0114 // inline methods
0115 // ====================================================================
0116 
0117 inline G4MCTSimParticle::G4MCTSimParticle(const G4MCTSimParticle& right)
0118 {
0119   *this = right;
0120 }
0121 
0122 inline G4MCTSimParticle& G4MCTSimParticle::operator=(
0123   const G4MCTSimParticle& right)
0124 {
0125   parentParticle         = right.parentParticle;
0126   associatedParticleList = right.associatedParticleList;  // shallow copy
0127 
0128   name             = right.name;
0129   pdgID            = right.pdgID;
0130   trackID          = right.trackID;
0131   parentTrackID    = right.parentTrackID;
0132   primaryFlag      = right.primaryFlag;
0133   momentumAtVertex = right.momentumAtVertex;
0134   vertex           = right.vertex;
0135 
0136   return *this;
0137 }
0138 
0139 inline void G4MCTSimParticle::SetParentParticle(const G4MCTSimParticle* p)
0140 {
0141   parentParticle = const_cast<G4MCTSimParticle*>(p);
0142 }
0143 
0144 inline G4MCTSimParticle* G4MCTSimParticle::GetParentParticle() const
0145 {
0146   return parentParticle;
0147 }
0148 
0149 inline void G4MCTSimParticle::SetParticleName(const G4String& aname)
0150 {
0151   name = aname;
0152 }
0153 
0154 inline const G4String& G4MCTSimParticle::GetParticleName() const
0155 {
0156   return name;
0157 }
0158 
0159 inline void G4MCTSimParticle::SetPdgID(G4int id)
0160 {
0161   pdgID = id;
0162 }
0163 
0164 inline G4int G4MCTSimParticle::GetPdgID() const
0165 {
0166   return pdgID;
0167 }
0168 
0169 inline void G4MCTSimParticle::SetTrackID(G4int id)
0170 {
0171   trackID = id;
0172 }
0173 
0174 inline G4int G4MCTSimParticle::GetTrackID() const
0175 {
0176   return trackID;
0177 }
0178 
0179 inline void G4MCTSimParticle::SetPrimaryFlag(G4bool q)
0180 {
0181   primaryFlag = q;
0182 }
0183 
0184 inline G4bool G4MCTSimParticle::GetPrimaryFlag() const
0185 {
0186   return primaryFlag;
0187 }
0188 
0189 inline void G4MCTSimParticle::SetParentTrackID(G4int id)
0190 {
0191   parentTrackID = id;
0192 }
0193 
0194 inline G4int G4MCTSimParticle::GetParentTrackID() const
0195 {
0196   return parentTrackID;
0197 }
0198 
0199 inline void G4MCTSimParticle::SetMomentumAtVertex(const G4LorentzVector& p)
0200 {
0201   momentumAtVertex = p;
0202 }
0203 
0204 inline const G4LorentzVector& G4MCTSimParticle::GetMomentumAtVertex() const
0205 {
0206   return momentumAtVertex;
0207 }
0208 
0209 inline void G4MCTSimParticle::SetVertex(const G4MCTSimVertex* v)
0210 {
0211   vertex = const_cast<G4MCTSimVertex*>(v);
0212 }
0213 
0214 inline G4MCTSimVertex* G4MCTSimParticle::GetVertex() const
0215 {
0216   return vertex;
0217 }
0218 
0219 inline void G4MCTSimParticle::SetStoreFlag(G4bool q)
0220 {
0221   storeFlag = q;
0222 }
0223 
0224 inline G4bool G4MCTSimParticle::GetStoreFlag() const
0225 {
0226   return storeFlag;
0227 }
0228 
0229 #endif