Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4IStore.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// G4IStore.cc
33//
34// ----------------------------------------------------------------------
35
36#include "G4IStore.hh"
37#include "G4VPhysicalVolume.hh"
38#include "G4GeometryCell.hh"
40#include "G4LogicalVolume.hh"
41
43 fWorldVolume(worldvolume)
44{}
45
47{}
48
50{
51 return fWorldVolume;
52}
53
54void G4IStore::SetInternalIterator(const G4GeometryCell &gCell) const
55{
56 fCurrentIterator = fGeometryCelli.find(gCell);
57}
58
60 const G4GeometryCell &gCell){
61 if (importance < 0 ) {
62 Error("AddImportanceGeometryCell() - Invalid importance value given.");
63 }
64 if (!IsInWorld(gCell.GetPhysicalVolume()) ) {
65 Error("AddImportanceGeometryCell() - Physical volume not found!");
66 }
67 SetInternalIterator(gCell);
68 if (fCurrentIterator!=fGeometryCelli.end()) {
69 Error("AddImportanceGeometryCell() - Region already existing!");
70 }
71 fGeometryCelli[gCell] = importance;
72}
73
75 const G4VPhysicalVolume &aVolume,
76 G4int aRepNum)
77{
79 G4GeometryCell(aVolume, aRepNum));
80}
81
83 const G4GeometryCell &gCell){
84 if (importance < 0 ) {
85 Error("ChangeImportance() - Invalid importance value given.");
86 }
87 if (!IsInWorld(gCell.GetPhysicalVolume()) ) {
88 Error("ChangeImportance() - Physical volume not found!");
89 }
90 SetInternalIterator(gCell);
91 if (fCurrentIterator==fGeometryCelli.end()) {
92 Error("ChangeImportance() - Region does not exist!");
93 }
94 fGeometryCelli[gCell] = importance;
95
96}
98 const G4VPhysicalVolume &aVolume,
99 G4int aRepNum)
100{
101 ChangeImportance(importance, G4GeometryCell(aVolume, aRepNum));
102}
103
105 G4int aRepNum) const
106{
107 SetInternalIterator(G4GeometryCell(aVolume, aRepNum));
108 G4GeometryCellImportance::const_iterator gCellIterator = fCurrentIterator;
109 if (gCellIterator==fGeometryCelli.end()) {
110 Error("GetImportance() - Region does not exist!");
111 return 0.;
112 }
113 return (*fCurrentIterator).second;
114}
115
116
118{
119 SetInternalIterator(gCell);
120 G4GeometryCellImportance::const_iterator gCellIterator = fCurrentIterator;
121 if (gCellIterator==fGeometryCelli.end()) {
122 std::ostringstream err_mess;
123 err_mess << "GetImportance() - Region does not exist!" << G4endl
124 << "Geometry cell, " << gCell
125 << ", not found in: " << fGeometryCelli << ".";
126 Error(err_mess.str());
127 return 0.;
128 }
129 return (*fCurrentIterator).second;
130}
131
133 G4bool inWorldKnown(IsInWorld(gCell.GetPhysicalVolume()));
134
135 if ( inWorldKnown ) {
136 SetInternalIterator(gCell);
137 inWorldKnown = (fCurrentIterator!=fGeometryCelli.end());
138 }
139 return inWorldKnown;
140}
141
142G4bool G4IStore::IsInWorld(const G4VPhysicalVolume &aVolume) const
143{
144 G4bool isIn(true);
145 if (!(aVolume == fWorldVolume)) {
146 isIn = fWorldVolume.GetLogicalVolume()->IsAncestor(&aVolume);
147 }
148 return isIn;
149}
150
151
152
153void G4IStore::Error(const G4String &msg) const
154{
155 G4Exception("G4IStore::Error()", "GeomBias0002", FatalException, msg);
156}
@ FatalException
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
bool G4bool
Definition: G4Types.hh:67
#define G4endl
Definition: G4ios.hh:52
const G4VPhysicalVolume & GetPhysicalVolume() const
virtual G4double GetImportance(const G4GeometryCell &gCell) const
Definition: G4IStore.cc:117
void AddImportanceGeometryCell(G4double importance, const G4GeometryCell &gCell)
Definition: G4IStore.cc:59
virtual const G4VPhysicalVolume & GetWorldVolume() const
Definition: G4IStore.cc:49
void ChangeImportance(G4double importance, const G4GeometryCell &gCell)
Definition: G4IStore.cc:82
virtual ~G4IStore()
Definition: G4IStore.cc:46
G4IStore(const G4VPhysicalVolume &worldvolume)
Definition: G4IStore.cc:42
virtual G4bool IsKnown(const G4GeometryCell &gCell) const
Definition: G4IStore.cc:132
G4bool IsAncestor(const G4VPhysicalVolume *p) const
G4LogicalVolume * GetLogicalVolume() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41