Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4SmartVoxelStat.cc
이 파일의 문서화 페이지로 가기
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: G4SmartVoxelStat.cc 66356 2012-12-18 09:02:32Z gcosmo $
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 //
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 {
62 }
63 
64 
65 //
66 // Simple Accessors
67 //
69 {
70  return volume;
71 }
72 
74 {
75  return voxel;
76 }
77 
79 {
80  return sysTime;
81 }
82 
84 {
85  return userTime;
86 }
87 
89 {
90  return sysTime + userTime;
91 }
92 
94 {
95  return heads;
96 }
97 
99 {
100  return nodes;
101 }
102 
104 {
105  return pointers;
106 }
107 
108 
109 //
110 // Return approximate memory use
111 //
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 //
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 }
G4SmartVoxelHeader * GetHeader() const
G4int GetNoSlices() const
G4double GetUserTime() const
G4long GetNumberHeads() const
G4SmartVoxelProxy * GetSlice(G4int n) const
G4bool IsNode() const
G4double GetSysTime() const
const G4SmartVoxelHeader * GetVoxel() const
double G4double
Definition: G4Types.hh:76
long G4long
Definition: G4Types.hh:80
G4SmartVoxelStat(const G4LogicalVolume *theVolume, const G4SmartVoxelHeader *theVoxel, G4double theSysTime, G4double theUserTime)
const G4LogicalVolume * GetVolume() const
G4long GetMemoryUse() const
G4long GetNumberNodes() const
const G4SmartVoxelHeader * voxel
int G4int
Definition: G4Types.hh:78
G4double GetTotalTime() const
const G4LogicalVolume * volume
G4long GetNumberPointers() const
void CountHeadsAndNodes(const G4SmartVoxelHeader *head)