Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4WeightWindowStore.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// G4WeightWindowStore
27//
28// Class description:
29//
30// Implementation of a weight window store according to the
31// G4VWeightWindowStore interface.
32// See also G4VWeightWindowStore.
33
34// Author: Michael Dressel (CERN), 2003 - Created
35// Alex Howard (CERN), 2013 - Changed class to a 'singleton'
36// ----------------------------------------------------------------------
37#ifndef G4WEIGHTWINDOWSTORE_HH
38#define G4WEIGHTWINDOWSTORE_HH
39
42#include <set>
43#include <vector>
44
45/**
46 * @brief G4WeightWindowStore is an concrete implementation of a weight window
47 * store according to the G4VWeightWindowStore interface.
48 */
49
50class G4WeightWindowStore: public G4VWeightWindowStore
51{
52 public:
53
54 /**
55 * Returns a pointer to the singleton instance of the class.
56 */
57 static G4WeightWindowStore* GetInstance();
58
59 /**
60 * Returns a pointer to the singleton instance of the class, given
61 * the name of the parallel world of reference.
62 */
63 static G4WeightWindowStore* GetInstance(const G4String& ParallelWorldName);
64
65 /**
66 * Derives a lower weight bound value of a "cell" addressed by a
67 * G4GeometryCell and the corresponding energy from the store.
68 */
70 G4double partEnergy) const override;
71
72 /**
73 * Returns true if 'gCell' is in the store, else false.
74 * @param[in] gCell The cell of reference.
75 * @returns true if present in the store, false otherwise.
76 */
77 G4bool IsKnown(const G4GeometryCell &gCell) const override;
78
79 /**
80 * Clears the cells weights map.
81 */
82 void Clear();
83
84 /**
85 * Sets a reference to world volume of the "weightwindow" geometry.
86 */
87 void SetWorldVolume();
88
89 /**
90 * Sets a reference to parallel world volume of the "weightwindow" geometry.
91 */
92 void SetParallelWorldVolume(const G4String& paraName);
93
94 /**
95 * Returns a reference to the world volume of the "weightwindow" geometry.
96 */
97 const G4VPhysicalVolume& GetWorldVolume() const override;
98
99 /**
100 * Returns a pointer to the world volume of the "weightwindow" geometry.
101 */
103
104 /**
105 * Adds lower weights. Only if general upper energy bounds have been set.
106 */
107 void AddLowerWeights(const G4GeometryCell& gCell,
108 const std::vector<G4double>& lowerWeights);
109
110 /**
111 * Sets upper energy - lower weight pairs for a cell.
112 */
114 const G4UpperEnergyToLowerWeightMap& enWeMap);
115
116 /**
117 * Sets the energy bounds.
118 */
119 void SetGeneralUpperEnergyBounds(const std::set<G4double,
120 std::less<G4double> >& enBounds);
121 private:
122
123 /**
124 * Constructors. Initialise the weight window store for the given geometry.
125 */
126 explicit G4WeightWindowStore();
127 explicit G4WeightWindowStore(const G4String& ParallelWorldName);
128
129 /**
130 * Default Destructor.
131 */
132 ~G4WeightWindowStore() override = default;
133
134 /**
135 * Internal utilities.
136 */
137 G4bool IsInWorld(const G4VPhysicalVolume&) const;
138 void SetInternalIterator(const G4GeometryCell& gCell) const;
139
140 /**
141 * Internal logger.
142 */
143 void Error(const G4String& m) const;
144
145 private:
146
147 const G4VPhysicalVolume* fWorldVolume = nullptr;
148
149 std::set<G4double, std::less<G4double> > fGeneralUpperEnergyBounds;
150 G4GeometryCellWeight fCellToUpEnBoundLoWePairsMap;
151 mutable G4GeometryCellWeight::const_iterator fCurrentIterator;
152
153 static G4ThreadLocal G4WeightWindowStore* fInstance;
154};
155
156#endif
std::map< G4double, G4double, std::less< G4double > > G4UpperEnergyToLowerWeightMap
G4UpperEnergyToLowerWeightMap and G4GeometryCellWeight are maps used internally by the weight window ...
std::map< G4GeometryCell, G4UpperEnergyToLowerWeightMap, G4GeometryCellComp > G4GeometryCellWeight
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
G4GeometryCell is used for scoring and importance sampling. It defines a "cell", which,...
G4VPhysicalVolume is an abstract base class for the representation of a positioned volume....
G4VWeightWindowStore()=default
void AddLowerWeights(const G4GeometryCell &gCell, const std::vector< G4double > &lowerWeights)
void SetParallelWorldVolume(const G4String &paraName)
const G4VPhysicalVolume * GetParallelWorldVolumePointer() const
void SetGeneralUpperEnergyBounds(const std::set< G4double, std::less< G4double > > &enBounds)
static G4WeightWindowStore * GetInstance()
G4bool IsKnown(const G4GeometryCell &gCell) const override
const G4VPhysicalVolume & GetWorldVolume() const override
G4double GetLowerWeight(const G4GeometryCell &gCell, G4double partEnergy) const override
void AddUpperEboundLowerWeightPairs(const G4GeometryCell &gCell, const G4UpperEnergyToLowerWeightMap &enWeMap)
#define G4ThreadLocal
Definition tls.hh:77