Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
54 void 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 {
78  AddImportanceGeometryCell(importance,
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 
142 G4bool 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 
153 void G4IStore::Error(const G4String &msg) const
154 {
155  G4Exception("G4IStore::Error()", "GeomBias0002", FatalException, msg);
156 }