Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ProductionCutsTable.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// G4ProductionCutsTable
27//
28// Class description:
29//
30// G4ProductionCutsTable is a singleton class for a table of
31// G4ProductionCuts objects. This class manages tables of production
32// cuts and energy cuts for each particle type.
33
34// Author: M.Asai, 5 October 2002 - First implementation
35// Modifications: H.Kurashige, 2004-2008
36// --------------------------------------------------------------------
37#ifndef G4ProductionCutsTable_hh
38#define G4ProductionCutsTable_hh 1
39
40#include <cmath>
41#include <vector>
42
43#include "globals.hh"
44#include "G4ios.hh"
47#include "G4Region.hh"
48
49class G4RegionStore;
51class G4LogicalVolume;
55
57{
58 public:
59
61 // This static method returns the singleton pointer of this class object.
62 // At first invocation, the singleton object is instantiated
63
66
67 virtual ~G4ProductionCutsTable();
68
69 void UpdateCoupleTable(G4VPhysicalVolume* currentWorld);
70 // Triggers an update of the table of G4ProductionCuts objects
71
72 void SetEnergyRange(G4double lowedge, G4double highedge);
73 // Sets the limits of energy cuts for all particles
74
77 // Get the limits of energy cuts for all particles
78
80 void SetMaxEnergyCut(G4double value);
81 // Get/set max cut energy of RangeToEnergy converter
82 // for all particle types
83
84 void DumpCouples() const;
85 // Displays a list of registered couples
86
88 // Gives the pointer to the MCCIndexConversionTable
89
90 const std::vector<G4double>* GetRangeCutsVector(std::size_t pcIdx) const;
91 const std::vector<G4double>* GetEnergyCutsVector(std::size_t pcIdx) const;
92
93 std::size_t GetTableSize() const;
94 // Returns the size of the couple table
95
97 // Returns the pointer to the couple
98
100 const G4ProductionCuts* aCut) const;
101 // Returns the pointer to the couple
102
103 G4int GetCoupleIndex(const G4MaterialCutsCouple* aCouple) const;
104 G4int GetCoupleIndex(const G4Material* aMat,
105 const G4ProductionCuts* aCut) const;
106 // Return the index of the couple.
107 // -1 is returned if index is not found
108
109 G4bool IsModified() const;
110 // Returns TRUE if at least one production cut value is modified
111
112 void PhysicsTableUpdated();
113 // Resets the status of IsModified(). This method must be exclusively
114 // used by the RunManager when physics tables are built
115
117 // Returns the default production cuts
118
120 const G4Material* material,
121 G4double range);
122 // Gives energy corresponding to range value.
123 // -1 is returned if particle or material is not found
124
125 void ResetConverters();
126 // Resets all range to energy converters
127
128 G4bool StoreCutsTable(const G4String& directory,
129 G4bool ascii = false);
130 // Stores cuts and material information in files under the
131 // the specified directory
132
133 G4bool RetrieveCutsTable(const G4String& directory,
134 G4bool ascii = false);
135 // Retrieve material cut couple information
136 // in files under the specified directory
137
138 G4bool CheckForRetrieveCutsTable(const G4String& directory,
139 G4bool ascii = false);
140 // Checks stored material and cut values are consistent
141 // with the current detector setup
142
143 G4double* GetRangeCutsDoubleVector(std::size_t pcIdx) const;
144 G4double* GetEnergyCutsDoubleVector(std::size_t pcIdx) const;
145 // Methods for backward compatibility
146
147 void SetVerboseLevel(G4int value);
148 G4int GetVerboseLevel() const;
149 // Control flag for output message
150 // 0: Silent
151 // 1: Warning message
152 // 2: More
153
154 protected:
155
157
158 virtual G4bool StoreMaterialInfo(const G4String& directory,
159 G4bool ascii = false);
160 // Stores material information in files under the specified directory
161
162 virtual G4bool CheckMaterialInfo(const G4String& directory,
163 G4bool ascii = false);
164 // Checks stored material is consistent with the current detector setup
165
166 virtual G4bool StoreMaterialCutsCoupleInfo(const G4String& directory,
167 G4bool ascii = false);
168 // Stores materialCutsCouple information in files under the
169 // specified directory
170
171 virtual G4bool CheckMaterialCutsCoupleInfo(const G4String& directory,
172 G4bool ascii = false);
173 // Checks stored materialCutsCouple is consistent with
174 // the current detector setup
175
176 virtual G4bool StoreCutsInfo(const G4String& directory,
177 G4bool ascii = false);
178 // Stores cut values information in files under the specified directory
179
180 virtual G4bool RetrieveCutsInfo(const G4String& directory,
181 G4bool ascii = false);
182 // Retrieves cut values information in files under the
183 // specified directory
184
185 private:
186
187 void ScanAndSetCouple(G4LogicalVolume* aLV,
188 G4MaterialCutsCouple* aCouple,
189 G4Region* aRegion);
190
191 G4bool IsCoupleUsedInTheRegion(const G4MaterialCutsCouple* aCouple,
192 const G4Region* aRegion) const;
193
194 private:
195
196 static G4ProductionCutsTable* fProductionCutsTable;
197
198 std::vector<G4MaterialCutsCouple*> coupleTable;
199 std::vector<std::vector<G4double>*> rangeCutTable;
200 std::vector<std::vector<G4double>*> energyCutTable;
201
202 G4RegionStore* fG4RegionStore = nullptr;
204
205 G4ProductionCuts* defaultProductionCuts = nullptr;
206
207 G4MCCIndexConversionTable mccConversionTable;
208
209 // These two vectors are for backward compatibility
210 G4double* rangeDoubleVector[NumberOfG4CutIndex];
211 G4double* energyDoubleVector[NumberOfG4CutIndex];
212
213 enum { FixedStringLengthForStore = 32 };
214
215 G4ProductionCutsTableMessenger* fMessenger = nullptr;
216 G4int verboseLevel = 1;
217 G4bool firstUse = true;
218};
219
220// ------------------
221// Inline methods
222// ------------------
223
224inline
225const std::vector<G4double>*
227{
228 return rangeCutTable[pcIdx];
229}
230
231inline
232const std::vector<G4double>*
234{
235 return energyCutTable[pcIdx];
236}
237
238inline
240{
241 return coupleTable.size();
242}
243
244inline
247{
248 return coupleTable[std::size_t(i)];
249}
250
251inline
253{
254 if(firstUse) return true;
255 for(auto itr=coupleTable.cbegin(); itr!=coupleTable.cend(); ++itr)
256 {
257 if((*itr)->IsRecalcNeeded())
258 {
259 return true;
260 }
261 }
262 return false;
263}
264
265inline
267{
268 for(auto itr=coupleTable.cbegin(); itr!=coupleTable.cend(); ++itr)
269 {
270 (*itr)->PhysicsTableUpdated();
271 }
272}
273
274inline
277{
278 return rangeDoubleVector[pcIdx];
279}
280
281inline
284{
285 return energyDoubleVector[pcIdx];
286}
287
288inline
290{
291 return defaultProductionCuts;
292}
293
294inline
295G4bool G4ProductionCutsTable::IsCoupleUsedInTheRegion(
296 const G4MaterialCutsCouple* aCouple,
297 const G4Region* aRegion) const
298{
299 G4ProductionCuts* fProductionCut = aRegion->GetProductionCuts();
300 auto mItr = aRegion->GetMaterialIterator();
301 std::size_t nMaterial = aRegion->GetNumberOfMaterials();
302 for(std::size_t iMate=0;iMate<nMaterial; ++iMate, ++mItr)
303 {
304 if(aCouple->GetMaterial()==(*mItr) &&
305 aCouple->GetProductionCuts()==fProductionCut)
306 {
307 return true;
308 }
309 }
310 return false;
311}
312
313inline
316 const G4ProductionCuts* aCut) const
317{
318 for(auto cItr=coupleTable.cbegin(); cItr!=coupleTable.cend(); ++cItr)
319 {
320 if((*cItr)->GetMaterial()!=aMat) continue;
321 if((*cItr)->GetProductionCuts()==aCut) return (*cItr);
322 }
323 return nullptr;
324}
325
326inline
327G4int
329{
330 G4int idx = 0;
331 for(auto cItr=coupleTable.cbegin(); cItr!=coupleTable.cend(); ++cItr)
332 {
333 if((*cItr)==aCouple) return idx;
334 ++idx;
335 }
336 return -1;
337}
338
339inline
341 const G4ProductionCuts* aCut) const
342{
343 const G4MaterialCutsCouple* aCouple = GetMaterialCutsCouple(aMat,aCut);
344 return GetCoupleIndex(aCouple);
345}
346
347inline
349{
350 return verboseLevel;
351}
352
353inline
356{
357 return &mccConversionTable;
358}
359
360#endif
@ NumberOfG4CutIndex
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
const G4Material * GetMaterial() const
G4ProductionCuts * GetProductionCuts() const
const std::vector< G4double > * GetRangeCutsVector(std::size_t pcIdx) const
virtual G4bool RetrieveCutsInfo(const G4String &directory, G4bool ascii=false)
G4double * GetEnergyCutsDoubleVector(std::size_t pcIdx) const
G4bool RetrieveCutsTable(const G4String &directory, G4bool ascii=false)
virtual G4bool StoreCutsInfo(const G4String &directory, G4bool ascii=false)
G4double GetLowEdgeEnergy() const
const G4MaterialCutsCouple * GetMaterialCutsCouple(G4int i) const
void SetMaxEnergyCut(G4double value)
void UpdateCoupleTable(G4VPhysicalVolume *currentWorld)
void SetVerboseLevel(G4int value)
std::size_t GetTableSize() const
virtual G4bool CheckMaterialInfo(const G4String &directory, G4bool ascii=false)
virtual G4bool StoreMaterialInfo(const G4String &directory, G4bool ascii=false)
G4double GetHighEdgeEnergy() const
G4double * GetRangeCutsDoubleVector(std::size_t pcIdx) const
const std::vector< G4double > * GetEnergyCutsVector(std::size_t pcIdx) const
G4bool StoreCutsTable(const G4String &directory, G4bool ascii=false)
G4ProductionCutsTable & operator=(const G4ProductionCutsTable &)=delete
const G4MCCIndexConversionTable * GetMCCIndexConversionTable() const
G4bool CheckForRetrieveCutsTable(const G4String &directory, G4bool ascii=false)
void SetEnergyRange(G4double lowedge, G4double highedge)
static G4ProductionCutsTable * GetProductionCutsTable()
G4int GetCoupleIndex(const G4MaterialCutsCouple *aCouple) const
virtual G4bool CheckMaterialCutsCoupleInfo(const G4String &directory, G4bool ascii=false)
G4ProductionCuts * GetDefaultProductionCuts() const
G4ProductionCutsTable(const G4ProductionCutsTable &)=delete
G4double ConvertRangeToEnergy(const G4ParticleDefinition *particle, const G4Material *material, G4double range)
virtual G4bool StoreMaterialCutsCoupleInfo(const G4String &directory, G4bool ascii=false)
std::size_t GetNumberOfMaterials() const
G4ProductionCuts * GetProductionCuts() const
std::vector< G4Material * >::const_iterator GetMaterialIterator() const