Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4SmartVoxelStat.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// G4SmartVoxelStat class implementation
27//
28// Stores information on the performance of the smart voxel algorithm
29// for an individual logical volume.
30//
31// Author: D.C.Williams, UCSC ([email protected])
32// --------------------------------------------------------------------
33
34#include "G4SmartVoxelStat.hh"
35#include "G4SmartVoxelHeader.hh"
36#include "G4SmartVoxelNode.hh"
37#include "G4SmartVoxelProxy.hh"
38
39//
40// Constructor
41//
43 const G4SmartVoxelHeader* theVoxel,
44 G4double theSysTime,
45 G4double theUserTime )
46 : volume(theVolume),
47 voxel(theVoxel),
48 sysTime(theSysTime),
49 userTime(theUserTime)
50{
52}
53
54//
55// Simple Accessors
56//
58{
59 return volume;
60}
61
63{
64 return voxel;
65}
66
68{
69 return sysTime;
70}
71
73{
74 return userTime;
75}
76
78{
79 return sysTime + userTime;
80}
81
83{
84 return heads;
85}
86
88{
89 return nodes;
90}
91
93{
94 return pointers;
95}
96
97//
98// Return approximate memory use
99//
101{
102 static const G4long headSize = sizeof(G4SmartVoxelHeader)
103 + sizeof(G4SmartVoxelProxy);
104
105 static const G4long nodeSize = sizeof(G4SmartVoxelNode)
106 + sizeof(G4SmartVoxelProxy);
107
108 static const G4long pointerSize = sizeof(G4SmartVoxelProxy*);
109
110 return nodes*nodeSize + heads*headSize + pointers*pointerSize;
111}
112
113//
114// CountHeadsAndNodes
115//
116// Recursively count the number of voxel headers and nodes,
117// updating class member variables heads and nodes on the way.
118//
120{
121 std::size_t numSlices = head->GetNoSlices();
122
123 pointers += numSlices;
124
125 const G4SmartVoxelProxy* lastProxy = nullptr;
126
127 for(std::size_t i=0; i<numSlices; ++i)
128 {
129 const G4SmartVoxelProxy *proxy = head->GetSlice(i);
130 if (proxy == lastProxy) continue;
131
132 lastProxy = proxy;
133
134 if (proxy->IsNode())
135 {
136 ++nodes;
137 }
138 else
139 {
140 ++heads;
142 }
143 }
144}
double G4double
Definition: G4Types.hh:83
long G4long
Definition: G4Types.hh:87
std::size_t GetNoSlices() const
G4SmartVoxelProxy * GetSlice(std::size_t n) const
G4bool IsNode() const
G4SmartVoxelHeader * GetHeader() const
const G4SmartVoxelHeader * GetVoxel() const
G4SmartVoxelStat(const G4LogicalVolume *theVolume, const G4SmartVoxelHeader *theVoxel, G4double theSysTime, G4double theUserTime)
G4double GetUserTime() const
void CountHeadsAndNodes(const G4SmartVoxelHeader *head)
G4long GetMemoryUse() const
const G4SmartVoxelHeader * voxel
G4double GetTotalTime() const
const G4LogicalVolume * volume
G4long GetNumberPointers() const
G4long GetNumberHeads() const
G4double GetSysTime() const
const G4LogicalVolume * GetVolume() const
G4long GetNumberNodes() const