source: trunk/source/geometry/biasing/src/G4IStore.cc @ 1289

Last change on this file since 1289 was 1228, checked in by garnier, 14 years ago

update geant4.9.3 tag

File size: 5.1 KB
Line 
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: G4IStore.cc,v 1.14 2006/06/29 18:17:18 gunter Exp $
28// GEANT4 tag $Name: geant4-09-03 $
29//
30// ----------------------------------------------------------------------
31// GEANT 4 class source file
32//
33// G4IStore.cc
34//
35// ----------------------------------------------------------------------
36
37#include "G4IStore.hh"
38#include "G4VPhysicalVolume.hh"
39#include "G4GeometryCell.hh"
40#include "G4GeometryCellStepStream.hh"
41#include "G4LogicalVolume.hh"
42
43G4IStore::G4IStore(const G4VPhysicalVolume &worldvolume) :
44  fWorldVolume(worldvolume)
45{}
46
47G4IStore::~G4IStore()
48{}
49
50const G4VPhysicalVolume &G4IStore::GetWorldVolume() const 
51{
52  return fWorldVolume;
53}
54
55void G4IStore::SetInternalIterator(const G4GeometryCell &gCell) const
56{
57  fCurrentIterator = fGeometryCelli.find(gCell);
58}
59
60void G4IStore::AddImportanceGeometryCell(G4double importance,
61                         const G4GeometryCell &gCell){
62  if (importance < 0 ) {
63    Error("AddImportanceGeometryCell: invalid importance value given");
64  } 
65  if (!IsInWorld(gCell.GetPhysicalVolume()) ) {
66    Error("AddImportanceGeometryCell: physical volume not in this World");
67  }
68  SetInternalIterator(gCell);
69  if (fCurrentIterator!=fGeometryCelli.end()) {
70    Error("AddImportanceGeometryCell: Region allready exists");
71  }
72  fGeometryCelli[gCell] = importance;
73}
74
75void G4IStore::AddImportanceGeometryCell(G4double importance,
76                                   const G4VPhysicalVolume &aVolume,
77                                   G4int aRepNum)
78{
79  AddImportanceGeometryCell(importance,
80                      G4GeometryCell(aVolume, aRepNum));
81}
82
83void G4IStore::ChangeImportance(G4double importance,
84                                const G4GeometryCell &gCell){
85  if (importance < 0 ) {
86    Error("ChangeImportance: Invalid importance value given");
87  }
88  if (!IsInWorld(gCell.GetPhysicalVolume()) ) {
89    Error("ChangeImportance: physical volume not in this World");
90  }
91  SetInternalIterator(gCell);
92  if (fCurrentIterator==fGeometryCelli.end()) {
93    Error("ChangeImportance: Region does not exist");
94  }
95  fGeometryCelli[gCell] = importance;
96
97}
98void G4IStore::ChangeImportance(G4double importance,
99                                const G4VPhysicalVolume &aVolume,
100                                G4int aRepNum)
101{
102  ChangeImportance(importance, G4GeometryCell(aVolume, aRepNum));
103}
104
105G4double G4IStore::GetImportance(const G4VPhysicalVolume &aVolume,
106                                 G4int aRepNum) const
107{ 
108  SetInternalIterator(G4GeometryCell(aVolume, aRepNum));
109  if (fCurrentIterator==fGeometryCelli.end()) {
110    Error("GetImportance: Region does not exist");
111  }
112  return (*fCurrentIterator).second;
113}
114
115
116G4double G4IStore::GetImportance(const G4GeometryCell &gCell) const
117{
118  SetInternalIterator(gCell);
119  if (fCurrentIterator==fGeometryCelli.end()) {
120    G4cout << "PGeometryCell gCell: " << gCell << G4endl;
121    G4cout << "Not found in: " << G4endl;
122    G4cout << fGeometryCelli << G4endl;
123    Error("GetImportance(gCell): Region does not exist");
124  }
125  return (*fCurrentIterator).second;
126}
127
128G4bool G4IStore::IsKnown(const G4GeometryCell &gCell) const {
129  G4bool inWorldKnown(IsInWorld(gCell.GetPhysicalVolume()));
130                     
131  if ( inWorldKnown ) {
132    SetInternalIterator(gCell);
133    inWorldKnown = (fCurrentIterator!=fGeometryCelli.end());
134  }
135  return inWorldKnown;
136}
137
138G4bool G4IStore::IsInWorld(const G4VPhysicalVolume &aVolume) const
139{
140  G4bool isIn(true);
141  if (!(aVolume == fWorldVolume)) {
142    isIn = fWorldVolume.GetLogicalVolume()->IsAncestor(&aVolume);
143  }
144  return isIn;
145}
146
147
148
149void G4IStore::Error(const G4String &m) const
150{
151  G4cerr << "ERROR - G4IStore::" << m << G4endl;
152  G4Exception("G4IStore::Error()", "FatalException", FatalException, m);
153}
Note: See TracBrowser for help on using the repository browser.