Geant4
9.6.p02
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
geant4_9_6_p02
source
geometry
management
src
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
//
27
// $Id$
28
//
29
// --------------------------------------------------------------------
30
// GEANT 4 class source file
31
//
32
// class G4SmartVoxelStat
33
//
34
// Stores information on the performance of the smart voxel algorithm
35
// for an individual logical volume.
36
//
37
// Author: D.C.Williams, UCSC (davidw@scipp.ucsc.edu)
38
//
39
// --------------------------------------------------------------------
40
41
#include "
G4SmartVoxelStat.hh
"
42
#include "
G4SmartVoxelHeader.hh
"
43
#include "
G4SmartVoxelNode.hh
"
44
#include "
G4SmartVoxelProxy.hh
"
45
46
//
47
// Constructor
48
//
49
G4SmartVoxelStat::G4SmartVoxelStat
(
const
G4LogicalVolume
*theVolume,
50
const
G4SmartVoxelHeader
*theVoxel,
51
G4double
theSysTime,
52
G4double
theUserTime )
53
: volume(theVolume),
54
voxel(theVoxel),
55
sysTime(theSysTime),
56
userTime(theUserTime),
57
heads(1),
58
nodes(0),
59
pointers(0)
60
{
61
CountHeadsAndNodes
(
voxel
);
62
}
63
64
65
//
66
// Simple Accessors
67
//
68
const
G4LogicalVolume
*
G4SmartVoxelStat::GetVolume
()
const
69
{
70
return
volume
;
71
}
72
73
const
G4SmartVoxelHeader
*
G4SmartVoxelStat::GetVoxel
()
const
74
{
75
return
voxel
;
76
}
77
78
G4double
G4SmartVoxelStat::GetSysTime
()
const
79
{
80
return
sysTime
;
81
}
82
83
G4double
G4SmartVoxelStat::GetUserTime
()
const
84
{
85
return
userTime
;
86
}
87
88
G4double
G4SmartVoxelStat::GetTotalTime
()
const
89
{
90
return
sysTime
+
userTime
;
91
}
92
93
G4long
G4SmartVoxelStat::GetNumberHeads
()
const
94
{
95
return
heads
;
96
}
97
98
G4long
G4SmartVoxelStat::GetNumberNodes
()
const
99
{
100
return
nodes
;
101
}
102
103
G4long
G4SmartVoxelStat::GetNumberPointers
()
const
104
{
105
return
pointers
;
106
}
107
108
109
//
110
// Return approximate memory use
111
//
112
G4long
G4SmartVoxelStat::GetMemoryUse
()
const
113
{
114
static
const
G4long
headSize =
sizeof
(
G4SmartVoxelHeader
)
115
+
sizeof
(
G4SmartVoxelProxy
);
116
117
static
const
G4long
nodeSize =
sizeof
(
G4SmartVoxelNode
)
118
+
sizeof
(
G4SmartVoxelProxy
);
119
120
static
const
G4long
pointerSize =
sizeof
(
G4SmartVoxelProxy
*);
121
122
return
nodes
*nodeSize +
heads
*headSize +
pointers
*pointerSize;
123
}
124
125
126
127
//
128
// CountHeadsAndNodes
129
//
130
// Recursively count the number of voxel headers and nodes,
131
// updating class member variables heads and nodes on the way.
132
//
133
void
G4SmartVoxelStat::CountHeadsAndNodes
(
const
G4SmartVoxelHeader
*head )
134
{
135
G4int
numSlices = head->
GetNoSlices
();
136
137
pointers
+= numSlices;
138
139
const
G4SmartVoxelProxy
*lastProxy = 0;
140
141
for
(
G4int
i=0;i<numSlices;++i) {
142
const
G4SmartVoxelProxy
*proxy = head->
GetSlice
(i);
143
if
(proxy == lastProxy)
continue
;
144
145
lastProxy = proxy;
146
147
if
(proxy->
IsNode
()) {
148
nodes
++;
149
}
150
else
{
151
heads
++;
152
CountHeadsAndNodes
(proxy->
GetHeader
());
153
}
154
}
155
}
Generated on Sat May 25 2013 14:33:11 for Geant4 by
1.8.4