Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4IStore.hh
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// G4IStore
27//
28// Class description:
29//
30// An implementation of an "importance store" with the interface
31// G4VIStore. See description in G4VIStore.
32// This implementation uses G4GeometryCellImportance as the container
33// to store the "cells" together with the importance values.
34// Giving a cell the importance 0 is allowed as a flagging that no biasing
35// should happen between this cell and its neighbors.
36// If a cell is not known by the importance store no biasing should be
37// applied between this cell and its nighbors.
38
39// Author: Michael Dressel (CERN), 2002 - Created
40// Alex Howard (CERN), 2013 - Changed class to a 'singleton'
41// ----------------------------------------------------------------------
42#ifndef G4ISTORE_HH
43#define G4ISTORE_HH
44
45#include "G4VIStore.hh"
48
49/**
50 * @brief G4IStore is a concrete implementation of an "importance store", as
51 * derived from G4VIStore. It is a singleton, using G4GeometryCellImportance
52 * as the container to store the "cells" together with the importance values.
53 * Giving a cell, the importance 0 is allowed as a flagging that no biasing
54 * should happen between this cell and its neighbors.
55 * If a cell is not known by the importance store no biasing should be
56 * applied between this cell and its nighbors.
57 */
58
59class G4IStore : public G4VIStore
60{
61 public:
62
63 /**
64 * Returns a pointer to the singleton instance of the class.
65 */
66 static G4IStore* GetInstance();
67
68 /**
69 * Returns a pointer to the singleton instance of the class, given
70 * the name of the parallel world of reference.
71 */
72 static G4IStore* GetInstance(const G4String& ParallelWorldName);
73
74 /**
75 * Returns the importance value of a "cell" from the store addressed
76 * by 'gCell'.
77 * @param[in] gCell The cell of reference.
78 * @returns The associated importance weight.
79 */
80 G4double GetImportance(const G4GeometryCell& gCell) const override;
81
82 /**
83 * Returns true if 'gCell' is in the store, else false.
84 * @param[in] gCell The cell of reference.
85 * @returns true if present in the store, false otherwise.
86 */
87 G4bool IsKnown(const G4GeometryCell& gCell) const override;
88
89 /**
90 * Clears the cells importance store.
91 */
92 void Clear();
93
94 /**
95 * Sets a reference to world volume of the "importance" geometry.
96 */
97 void SetWorldVolume();
98
99 /**
100 * Sets a reference to parallel world volume of the "importance" geometry.
101 */
102 void SetParallelWorldVolume(const G4String& paraName);
103
104 /**
105 * Returns a reference to the world volume of the "importance" geometry.
106 */
107 const G4VPhysicalVolume& GetWorldVolume() const override;
108
109 /**
110 * Returns a pointer to the world volume of the "importance" geometry.
111 */
113
114 /**
115 * Methods to add a "cell" together with an importance value to the store.
116 */
117 void AddImportanceGeometryCell(G4double importance,
118 const G4GeometryCell &gCell);
119 void AddImportanceGeometryCell(G4double importance,
120 const G4VPhysicalVolume &,
121 G4int aRepNum = 0);
122
123 /**
124 * Methods to change an importance value of a "cell".
125 */
126 void ChangeImportance(G4double importance, const G4GeometryCell& gCell);
127 void ChangeImportance(G4double importance, const G4VPhysicalVolume&,
128 G4int aRepNum = 0);
129
130 /**
131 * Returns the importance weight, given the volume and replica number.
132 */
133 G4double GetImportance(const G4VPhysicalVolume& vol, G4int rpNum = 0) const;
134
135 private:
136
137 /**
138 * Constructors. Initialising the importance store for the given geometry.
139 */
140 explicit G4IStore();
141 explicit G4IStore(const G4String& ParallelWorldName);
142
143 /**
144 * Default Destructor.
145 */
146 ~G4IStore() override = default;
147
148 /**
149 * Internal utilities.
150 */
151 G4bool IsInWorld(const G4VPhysicalVolume&) const;
152 void SetInternalIterator(const G4GeometryCell& gCell) const;
153
154 /**
155 * Internal logger.
156 */
157 void Error(const G4String& m) const;
158
159 private:
160
161 const G4VPhysicalVolume* fWorldVolume = nullptr;
162 G4GeometryCellImportance fGeometryCelli;
163
164 mutable G4GeometryCellImportance::const_iterator fCurrentIterator;
165
166 static G4ThreadLocal G4IStore* fInstance;
167};
168
169#endif
std::map< G4GeometryCell, G4double, G4GeometryCellComp > G4GeometryCellImportance
G4GeometryCellImportance is a map used internually by importance sampling. It is a container for "cel...
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
G4GeometryCell is used for scoring and importance sampling. It defines a "cell", which,...
G4double GetImportance(const G4GeometryCell &gCell) const override
Definition G4IStore.cc:177
void AddImportanceGeometryCell(G4double importance, const G4GeometryCell &gCell)
Definition G4IStore.cc:107
const G4VPhysicalVolume & GetWorldVolume() const override
Definition G4IStore.cc:92
G4bool IsKnown(const G4GeometryCell &gCell) const override
Definition G4IStore.cc:197
static G4IStore * GetInstance()
Definition G4IStore.cc:232
void Clear()
Definition G4IStore.cc:69
void ChangeImportance(G4double importance, const G4GeometryCell &gCell)
Definition G4IStore.cc:133
void SetParallelWorldVolume(const G4String &paraName)
Definition G4IStore.cc:83
const G4VPhysicalVolume * GetParallelWorldVolumePointer() const
Definition G4IStore.cc:97
void SetWorldVolume()
Definition G4IStore.cc:74
G4VIStore()=default
G4VPhysicalVolume is an abstract base class for the representation of a positioned volume....
#define G4ThreadLocal
Definition tls.hh:77