Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4Event.cc
Go to the documentation of this file.
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// G4Event class implementation
27//
28// Author: M.Asai, SLAC
29// --------------------------------------------------------------------
30
31#include "G4Event.hh"
32#include "G4VVisManager.hh"
33#include "G4VHitsCollection.hh"
34#include "G4VDigiCollection.hh"
35#include "G4ios.hh"
36
38{
39 G4ThreadLocalStatic G4Allocator<G4Event>* _instance = nullptr;
40 return _instance;
41}
42
44 : eventID(evID)
45{
46}
47
49{
50 G4PrimaryVertex* nextVertex = thePrimaryVertex;
51 while(nextVertex != nullptr)
52 {
53 G4PrimaryVertex* thisVertex = nextVertex;
54 nextVertex = thisVertex->GetNext();
55 thisVertex->ClearNext();
56 delete thisVertex;
57 }
58 thePrimaryVertex = nullptr;
59 delete HC;
60 delete DC;
61 if(trajectoryContainer != nullptr)
62 {
63 trajectoryContainer->clearAndDestroy();
64 delete trajectoryContainer;
65 }
66 delete userInfo;
67 delete randomNumberStatus;
68 delete randomNumberStatusForProcessing;
69}
70
72{
73 return ( eventID == right.eventID );
74}
75
77{
78 return ( eventID != right.eventID );
79}
80
81void G4Event::Print() const
82{
83 G4cout << "G4Event " << eventID << G4endl;
84}
85
86void G4Event::Draw() const
87{
89 if(pVVisManager == nullptr) return;
90
91 if(trajectoryContainer != nullptr)
92 {
93 std::size_t n_traj = trajectoryContainer->entries();
94 for(std::size_t i=0; i<n_traj; ++i)
95 { (*trajectoryContainer)[i]->DrawTrajectory(); }
96 }
97
98 if(HC != nullptr)
99 {
100 std::size_t n_HC = HC->GetCapacity();
101 for(std::size_t j=0; j<n_HC; ++j)
102 {
103 G4VHitsCollection* VHC = HC->GetHC((G4int)j);
104 if(VHC != nullptr) VHC->DrawAllHits();
105 }
106 }
107
108 if(DC != nullptr)
109 {
110 std::size_t n_DC = DC->GetCapacity();
111 for(std::size_t j=0; j<n_DC; ++j)
112 {
113 G4VDigiCollection* VDC = DC->GetDC((G4int)j);
114 if(VDC != nullptr) VDC->DrawAllDigi();
115 }
116 }
117}
G4Allocator< G4Event > *& anEventAllocator()
Definition: G4Event.cc:37
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
G4VDigiCollection * GetDC(G4int i) const
size_t GetCapacity() const
void Print() const
Definition: G4Event.cc:81
~G4Event()
Definition: G4Event.cc:48
G4Event()=default
G4bool operator!=(const G4Event &right) const
Definition: G4Event.cc:76
G4bool operator==(const G4Event &right) const
Definition: G4Event.cc:71
void Draw() const
Definition: G4Event.cc:86
G4VHitsCollection * GetHC(G4int i)
G4PrimaryVertex * GetNext() const
std::size_t entries() const
virtual void DrawAllDigi()
virtual void DrawAllHits()
static G4VVisManager * GetConcreteInstance()
#define G4ThreadLocalStatic
Definition: tls.hh:76