Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4WeightWindowStore Class Reference

G4WeightWindowStore is an concrete implementation of a weight window store according to the G4VWeightWindowStore interface. More...

#include <G4WeightWindowStore.hh>

Inheritance diagram for G4WeightWindowStore:

Public Member Functions

G4double GetLowerWeight (const G4GeometryCell &gCell, G4double partEnergy) const override
G4bool IsKnown (const G4GeometryCell &gCell) const override
void Clear ()
void SetWorldVolume ()
void SetParallelWorldVolume (const G4String &paraName)
const G4VPhysicalVolumeGetWorldVolume () const override
const G4VPhysicalVolumeGetParallelWorldVolumePointer () const
void AddLowerWeights (const G4GeometryCell &gCell, const std::vector< G4double > &lowerWeights)
void AddUpperEboundLowerWeightPairs (const G4GeometryCell &gCell, const G4UpperEnergyToLowerWeightMap &enWeMap)
void SetGeneralUpperEnergyBounds (const std::set< G4double, std::less< G4double > > &enBounds)
Public Member Functions inherited from G4VWeightWindowStore
 G4VWeightWindowStore ()=default
virtual ~G4VWeightWindowStore ()=default

Static Public Member Functions

static G4WeightWindowStoreGetInstance ()
static G4WeightWindowStoreGetInstance (const G4String &ParallelWorldName)

Detailed Description

G4WeightWindowStore is an concrete implementation of a weight window store according to the G4VWeightWindowStore interface.

Definition at line 50 of file G4WeightWindowStore.hh.

Member Function Documentation

◆ AddLowerWeights()

void G4WeightWindowStore::AddLowerWeights ( const G4GeometryCell & gCell,
const std::vector< G4double > & lowerWeights )

Adds lower weights. Only if general upper energy bounds have been set.

Definition at line 154 of file G4WeightWindowStore.cc.

157{
158 if (fGeneralUpperEnergyBounds.empty())
159 {
160 Error("AddLowerWeights() - No general upper energy limits set!");
161 }
162 if (IsKnown(gCell))
163 {
164 Error("AddLowerWeights() - Cell already in the store.");
165 }
166 if (lowerWeights.size() != fGeneralUpperEnergyBounds.size())
167 {
168 std::ostringstream err_mess;
169 err_mess << "AddLowerWeights() - Mismatch between "
170 << "number of lower weights (" << lowerWeights.size()
171 << ") and energy bounds (" << fGeneralUpperEnergyBounds.size()
172 << ")!";
173 Error(err_mess.str());
174 }
176 G4int i = 0;
177 for (G4double fGeneralUpperEnergyBound : fGeneralUpperEnergyBounds)
178 {
179 map[fGeneralUpperEnergyBound] = lowerWeights[i];
180 ++i;
181 }
182 fCellToUpEnBoundLoWePairsMap[gCell] = std::move(map);
183}
std::map< G4double, G4double, std::less< G4double > > G4UpperEnergyToLowerWeightMap
G4UpperEnergyToLowerWeightMap and G4GeometryCellWeight are maps used internally by the weight window ...
double G4double
Definition G4Types.hh:83
int G4int
Definition G4Types.hh:85
G4bool IsKnown(const G4GeometryCell &gCell) const override

◆ AddUpperEboundLowerWeightPairs()

void G4WeightWindowStore::AddUpperEboundLowerWeightPairs ( const G4GeometryCell & gCell,
const G4UpperEnergyToLowerWeightMap & enWeMap )

Sets upper energy - lower weight pairs for a cell.

Definition at line 185 of file G4WeightWindowStore.cc.

188{
189 if (IsKnown(gCell))
190 {
191 Error("AddUpperEboundLowerWeightPairs() - Cell already in the store.");
192 }
193 if (IsKnown(gCell))
194 {
195 Error("AddUpperEboundLowerWeightPairs() - Cell already in the store.");
196 }
197 fCellToUpEnBoundLoWePairsMap[gCell] = enWeMap;
198
199}

◆ Clear()

void G4WeightWindowStore::Clear ( )

Clears the cells weights map.

Definition at line 122 of file G4WeightWindowStore.cc.

123{
124 fCellToUpEnBoundLoWePairsMap.clear();
125}

◆ GetInstance() [1/2]

G4WeightWindowStore * G4WeightWindowStore::GetInstance ( )
static

Returns a pointer to the singleton instance of the class.

Definition at line 223 of file G4WeightWindowStore.cc.

224{
225 if (fInstance == nullptr)
226 {
227 fInstance = new G4WeightWindowStore();
228 }
229 return fInstance;
230}

Referenced by G4WeightWindowBiasing::ConstructProcess().

◆ GetInstance() [2/2]

G4WeightWindowStore * G4WeightWindowStore::GetInstance ( const G4String & ParallelWorldName)
static

Returns a pointer to the singleton instance of the class, given the name of the parallel world of reference.

Definition at line 237 of file G4WeightWindowStore.cc.

239{
240 if (fInstance == nullptr)
241 {
242#ifdef G4VERBOSE
243 G4cout << "G4IStore:: Creating new Parallel IStore "
244 << ParallelWorldName << G4endl;
245#endif
246 fInstance = new G4WeightWindowStore(ParallelWorldName);
247 }
248 return fInstance;
249}
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout

◆ GetLowerWeight()

G4double G4WeightWindowStore::GetLowerWeight ( const G4GeometryCell & gCell,
G4double partEnergy ) const
overridevirtual

Derives a lower weight bound value of a "cell" addressed by a G4GeometryCell and the corresponding energy from the store.

Implements G4VWeightWindowStore.

Definition at line 59 of file G4WeightWindowStore.cc.

62{
63 SetInternalIterator(gCell);
64 auto gCellIterator = fCurrentIterator;
65 if (gCellIterator == fCellToUpEnBoundLoWePairsMap.cend())
66 {
67 Error("GetLowerWitgh() - Cell does not exist!");
68 return 0.;
69 }
70 G4UpperEnergyToLowerWeightMap upEnLoWeiPairs = fCurrentIterator->second;
71 G4double lowerWeight = -1;
72 G4bool found = false;
73 for (const auto & upEnLoWeiPair : upEnLoWeiPairs)
74 {
75 if (partEnergy < upEnLoWeiPair.first)
76 {
77 lowerWeight = upEnLoWeiPair.second;
78 found = true;
79 break;
80 }
81 }
82 if (!found)
83 {
84 std::ostringstream err_mess;
85 err_mess << "GetLowerWitgh() - Couldn't find lower weight bound." << G4endl
86 << "Energy: " << partEnergy << ".";
87 Error(err_mess.str());
88 }
89 return lowerWeight;
90}
bool G4bool
Definition G4Types.hh:86

◆ GetParallelWorldVolumePointer()

const G4VPhysicalVolume * G4WeightWindowStore::GetParallelWorldVolumePointer ( ) const

Returns a pointer to the world volume of the "weightwindow" geometry.

Definition at line 148 of file G4WeightWindowStore.cc.

150{
151 return fWorldVolume;
152}

◆ GetWorldVolume()

const G4VPhysicalVolume & G4WeightWindowStore::GetWorldVolume ( ) const
overridevirtual

Returns a reference to the world volume of the "weightwindow" geometry.

Implements G4VWeightWindowStore.

Definition at line 143 of file G4WeightWindowStore.cc.

144{
145 return *fWorldVolume;
146}

◆ IsKnown()

G4bool G4WeightWindowStore::IsKnown ( const G4GeometryCell & gCell) const
overridevirtual

Returns true if 'gCell' is in the store, else false.

Parameters
[in]gCellThe cell of reference.
Returns
true if present in the store, false otherwise.

Implements G4VWeightWindowStore.

Definition at line 109 of file G4WeightWindowStore.cc.

111{
112 G4bool inWorldKnown(IsInWorld(gCell.GetPhysicalVolume()));
113
114 if ( inWorldKnown )
115 {
116 SetInternalIterator(gCell);
117 inWorldKnown = (fCurrentIterator!=fCellToUpEnBoundLoWePairsMap.cend());
118 }
119 return inWorldKnown;
120}
const G4VPhysicalVolume & GetPhysicalVolume() const

Referenced by AddLowerWeights(), and AddUpperEboundLowerWeightPairs().

◆ SetGeneralUpperEnergyBounds()

void G4WeightWindowStore::SetGeneralUpperEnergyBounds ( const std::set< G4double, std::less< G4double > > & enBounds)

Sets the energy bounds.

Definition at line 201 of file G4WeightWindowStore.cc.

204{
205 if (!fGeneralUpperEnergyBounds.empty())
206 {
207 Error("SetGeneralUpperEnergyBounds() - Energy bounds already set.");
208 }
209 fGeneralUpperEnergyBounds = enBounds;
210}

◆ SetParallelWorldVolume()

void G4WeightWindowStore::SetParallelWorldVolume ( const G4String & paraName)

Sets a reference to parallel world volume of the "weightwindow" geometry.

Definition at line 136 of file G4WeightWindowStore.cc.

137{
139 ->GetParallelWorld(paraName);
140 // fGeometryCelli = new G4GeometryCellImportance;
141}
G4VPhysicalVolume * GetParallelWorld(const G4String &worldName)
static G4TransportationManager * GetTransportationManager()

◆ SetWorldVolume()

void G4WeightWindowStore::SetWorldVolume ( )

Sets a reference to world volume of the "weightwindow" geometry.

Definition at line 127 of file G4WeightWindowStore.cc.

128{
129 G4cout << " G4IStore:: SetWorldVolume " << G4endl;
132 G4cout << " World volume is: " << fWorldVolume->GetName() << G4endl;
133 // fGeometryCelli = new G4GeometryCellImportance;
134}
G4VPhysicalVolume * GetWorldVolume() const
G4Navigator * GetNavigatorForTracking() const
const G4String & GetName() const

The documentation for this class was generated from the following files: