Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:39

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 // G4MCTSimEvent
0027 
0028 // Author: Youhei Morita, 12.09.2001
0029 // --------------------------------------------------------------------
0030 #ifndef G4MCTSIMEVENT_HH
0031 #define G4MCTSIMEVENT_HH 1
0032 
0033 #include <iostream>
0034 #include <vector>
0035 #include <map>
0036 
0037 #include "G4Types.hh"
0038 
0039 class G4MCTSimParticle;
0040 class G4MCTSimVertex;
0041 
0042 using G4MCTSimParticleContainer = std::map<int, G4MCTSimParticle*>;
0043 using G4MCTSimVertexContainer = std::vector<G4MCTSimVertex*>;
0044 
0045 class G4MCTSimEvent
0046 {
0047   public:
0048 
0049     G4MCTSimEvent();
0050     ~G4MCTSimEvent();
0051 
0052     inline G4MCTSimEvent(const G4MCTSimEvent& right);
0053     inline G4MCTSimEvent& operator=(const G4MCTSimEvent& right);
0054       // copy constructor and assignment operator
0055 
0056     G4bool AddParticle(const G4MCTSimParticle* aparticle);
0057     inline G4int GetNofParticles() const;
0058     inline G4int GetNofVertices() const;
0059     G4int GetNofStoredParticles() const;
0060     G4int GetNofStoredVertices() const;
0061     G4MCTSimParticle* FindParticle(G4int tid) const;
0062     G4MCTSimVertex* GetVertex(G4int vid) const;
0063 
0064     void BuildVertexContainer();
0065     void ClearEvent();
0066     void Print(std::ostream& ostr = std::cout) const;
0067 
0068     // iterators
0069     using particle_iterator = G4MCTSimParticleContainer::iterator;
0070     using particle_const_iterator = G4MCTSimParticleContainer::const_iterator;
0071     inline particle_iterator particles_begin();
0072     inline particle_iterator particles_end();
0073     inline particle_const_iterator particles_begin() const;
0074     inline particle_const_iterator particles_end() const;
0075 
0076     using vertex_iterator = G4MCTSimVertexContainer::iterator;
0077     using vertex_const_iterator = G4MCTSimVertexContainer::const_iterator;
0078     inline vertex_iterator vertices_begin();
0079     inline vertex_iterator vertices_end();
0080     inline vertex_const_iterator vertices_begin() const;
0081     inline vertex_const_iterator vertices_end() const;
0082 
0083   protected:
0084 
0085     G4MCTSimParticleContainer particleMap;
0086     G4MCTSimVertexContainer vertexVec;
0087 };
0088 
0089 // ====================================================================
0090 // inline methods
0091 // ====================================================================
0092 
0093 inline G4MCTSimEvent::G4MCTSimEvent(const G4MCTSimEvent& right)
0094 {
0095   *this = right;
0096 }
0097 
0098 inline G4MCTSimEvent& G4MCTSimEvent::operator=(const G4MCTSimEvent& right)
0099 {
0100   particleMap = right.particleMap;  // shallow copy
0101 
0102   return *this;
0103 }
0104 
0105 inline G4int G4MCTSimEvent::GetNofParticles() const
0106 {
0107   return (G4int)particleMap.size();
0108 }
0109 
0110 inline G4int G4MCTSimEvent::GetNofVertices() const
0111 {
0112   return (G4int)vertexVec.size();
0113 }
0114 
0115 // iterators
0116 inline G4MCTSimEvent::particle_iterator G4MCTSimEvent::particles_begin()
0117 {
0118   return particleMap.begin();
0119 }
0120 
0121 inline G4MCTSimEvent::particle_iterator G4MCTSimEvent::particles_end()
0122 {
0123   return particleMap.end();
0124 }
0125 
0126 inline G4MCTSimEvent::particle_const_iterator G4MCTSimEvent::particles_begin()
0127   const
0128 {
0129   return particleMap.cbegin();
0130 }
0131 
0132 inline G4MCTSimEvent::particle_const_iterator G4MCTSimEvent::particles_end()
0133   const
0134 {
0135   return particleMap.cend();
0136 }
0137 
0138 inline G4MCTSimEvent::vertex_iterator G4MCTSimEvent::vertices_begin()
0139 {
0140   return vertexVec.begin();
0141 }
0142 
0143 inline G4MCTSimEvent::vertex_iterator G4MCTSimEvent::vertices_end()
0144 {
0145   return vertexVec.end();
0146 }
0147 
0148 inline G4MCTSimEvent::vertex_const_iterator G4MCTSimEvent::vertices_begin()
0149   const
0150 {
0151   return vertexVec.cbegin();
0152 }
0153 
0154 inline G4MCTSimEvent::vertex_const_iterator G4MCTSimEvent::vertices_end() const
0155 {
0156   return vertexVec.cend();
0157 }
0158 
0159 #endif