G4IStore.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 // ----------------------------------------------------------------------
00030 // GEANT 4 class source file
00031 //
00032 // G4IStore.cc
00033 //
00034 // ----------------------------------------------------------------------
00035 
00036 #include "G4IStore.hh"
00037 #include "G4VPhysicalVolume.hh"
00038 #include "G4GeometryCell.hh"
00039 #include "G4GeometryCellStepStream.hh"
00040 #include "G4LogicalVolume.hh"
00041 
00042 G4IStore::G4IStore(const G4VPhysicalVolume &worldvolume) :
00043   fWorldVolume(worldvolume)
00044 {}
00045 
00046 G4IStore::~G4IStore()
00047 {}
00048 
00049 const G4VPhysicalVolume &G4IStore::GetWorldVolume() const 
00050 {
00051   return fWorldVolume;
00052 }
00053 
00054 void G4IStore::SetInternalIterator(const G4GeometryCell &gCell) const
00055 {
00056   fCurrentIterator = fGeometryCelli.find(gCell);
00057 }
00058 
00059 void G4IStore::AddImportanceGeometryCell(G4double importance,
00060                          const G4GeometryCell &gCell){
00061   if (importance < 0 ) {
00062     Error("AddImportanceGeometryCell() - Invalid importance value given.");
00063   }  
00064   if (!IsInWorld(gCell.GetPhysicalVolume()) ) {
00065     Error("AddImportanceGeometryCell() - Physical volume not found!");
00066   }
00067   SetInternalIterator(gCell);
00068   if (fCurrentIterator!=fGeometryCelli.end()) {
00069     Error("AddImportanceGeometryCell() - Region already existing!");
00070   }
00071   fGeometryCelli[gCell] = importance;
00072 }
00073 
00074 void G4IStore::AddImportanceGeometryCell(G4double importance,
00075                                    const G4VPhysicalVolume &aVolume,
00076                                    G4int aRepNum)
00077 {
00078   AddImportanceGeometryCell(importance,
00079                       G4GeometryCell(aVolume, aRepNum));
00080 }
00081 
00082 void G4IStore::ChangeImportance(G4double importance,
00083                                 const G4GeometryCell &gCell){
00084   if (importance < 0 ) {
00085     Error("ChangeImportance() - Invalid importance value given.");
00086   }
00087   if (!IsInWorld(gCell.GetPhysicalVolume()) ) {
00088     Error("ChangeImportance() - Physical volume not found!");
00089   }
00090   SetInternalIterator(gCell);
00091   if (fCurrentIterator==fGeometryCelli.end()) {
00092     Error("ChangeImportance() - Region does not exist!");
00093   }
00094   fGeometryCelli[gCell] = importance;
00095 
00096 }
00097 void G4IStore::ChangeImportance(G4double importance,
00098                                 const G4VPhysicalVolume &aVolume,
00099                                 G4int aRepNum)
00100 {
00101   ChangeImportance(importance, G4GeometryCell(aVolume, aRepNum));
00102 }
00103 
00104 G4double G4IStore::GetImportance(const G4VPhysicalVolume &aVolume,
00105                                  G4int aRepNum) const
00106 {  
00107   SetInternalIterator(G4GeometryCell(aVolume, aRepNum));
00108   G4GeometryCellImportance::const_iterator gCellIterator = fCurrentIterator;
00109   if (gCellIterator==fGeometryCelli.end()) {
00110     Error("GetImportance() - Region does not exist!");
00111     return 0.;
00112   }
00113   return (*fCurrentIterator).second;
00114 }
00115 
00116 
00117 G4double G4IStore::GetImportance(const G4GeometryCell &gCell) const
00118 {
00119   SetInternalIterator(gCell);
00120   G4GeometryCellImportance::const_iterator gCellIterator = fCurrentIterator;
00121   if (gCellIterator==fGeometryCelli.end()) {
00122     std::ostringstream err_mess;
00123     err_mess << "GetImportance() - Region does not exist!" << G4endl
00124              << "Geometry cell, " << gCell
00125              << ", not found in: " << fGeometryCelli << ".";
00126     Error(err_mess.str());
00127     return 0.;
00128   }
00129   return (*fCurrentIterator).second;
00130 }
00131 
00132 G4bool G4IStore::IsKnown(const G4GeometryCell &gCell) const {
00133   G4bool inWorldKnown(IsInWorld(gCell.GetPhysicalVolume()));
00134                       
00135   if ( inWorldKnown ) {
00136     SetInternalIterator(gCell);
00137     inWorldKnown = (fCurrentIterator!=fGeometryCelli.end());
00138   }
00139   return inWorldKnown;
00140 }
00141 
00142 G4bool G4IStore::IsInWorld(const G4VPhysicalVolume &aVolume) const
00143 {
00144   G4bool isIn(true);
00145   if (!(aVolume == fWorldVolume)) {
00146     isIn = fWorldVolume.GetLogicalVolume()->IsAncestor(&aVolume);
00147   }
00148   return isIn;
00149 }
00150 
00151 
00152 
00153 void G4IStore::Error(const G4String &msg) const
00154 {
00155   G4Exception("G4IStore::Error()", "GeomBias0002", FatalException, msg);
00156 }

Generated on Mon May 27 17:48:41 2013 for Geant4 by  doxygen 1.4.7