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

#include <G4PhysicsTableHelper.hh>

Public Member Functions

 G4PhysicsTableHelper (const G4PhysicsTableHelper &)=delete
 
G4PhysicsTableHelperoperator= (const G4PhysicsTableHelper &)=delete
 

Static Public Member Functions

static G4PhysicsTablePreparePhysicsTable (G4PhysicsTable *physTable)
 
static G4bool RetrievePhysicsTable (G4PhysicsTable *physTable, const G4String &fileName, G4bool ascii, G4bool spline)
 
static void SetPhysicsVector (G4PhysicsTable *physTable, std::size_t idx, G4PhysicsVector *vec)
 
static void SetVerboseLevel (G4int value)
 
static G4int GetVerboseLevel ()
 

Protected Member Functions

 G4PhysicsTableHelper ()
 
 ~G4PhysicsTableHelper ()
 

Static Protected Attributes

static G4int verboseLevel = 1
 

Detailed Description

Definition at line 42 of file G4PhysicsTableHelper.hh.

Constructor & Destructor Documentation

◆ G4PhysicsTableHelper() [1/2]

G4PhysicsTableHelper::G4PhysicsTableHelper ( const G4PhysicsTableHelper & )
delete

◆ G4PhysicsTableHelper() [2/2]

G4PhysicsTableHelper::G4PhysicsTableHelper ( )
protected

Definition at line 40 of file G4PhysicsTableHelper.cc.

41{
42}

◆ ~G4PhysicsTableHelper()

G4PhysicsTableHelper::~G4PhysicsTableHelper ( )
protected

Definition at line 45 of file G4PhysicsTableHelper.cc.

46{
47}

Member Function Documentation

◆ GetVerboseLevel()

G4int G4PhysicsTableHelper::GetVerboseLevel ( )
static

Definition at line 213 of file G4PhysicsTableHelper.cc.

214{
215 return verboseLevel;
216}

◆ operator=()

G4PhysicsTableHelper & G4PhysicsTableHelper::operator= ( const G4PhysicsTableHelper & )
delete

◆ PreparePhysicsTable()

G4PhysicsTable * G4PhysicsTableHelper::PreparePhysicsTable ( G4PhysicsTable * physTable)
static

Definition at line 51 of file G4PhysicsTableHelper.cc.

52{
53 G4ProductionCutsTable* cutTable
55 std::size_t numberOfMCC = cutTable->GetTableSize();
56
57 if ( physTable != nullptr )
58 {
59 // compare size of physics table and number of material-cuts-couple
60 if ( physTable->size() < numberOfMCC )
61 {
62#ifdef G4VERBOSE
63 if (verboseLevel>2)
64 {
65 G4cout << "G4PhysicsTableHelper::PreparePhysicsTable: "
66 << " the table " << physTable << " size="
67 << physTable->size()
68 << " will be is resized to " << numberOfMCC << G4endl;
69 }
70#endif
71 // enlarge physics table
72 physTable->resize(numberOfMCC, nullptr);
73 }
74 else if ( physTable->size() > numberOfMCC )
75 {
76 // ERROR: this situation should not occur
77 // size of physics table is larger than number of material-cuts-couple
79 ed << "table " << physTable << " size=" << physTable->size()
80 << " is longer than number of material-cuts-couple " << numberOfMCC;
81 G4Exception( "G4PhysicsTableHelper::PreparePhysicsTable()",
82 "ProcCuts001", FatalException, ed);
83 }
84 }
85 else
86 {
87 // create PhysicsTable is given poitner is null
88 physTable = new G4PhysicsTable();
89 physTable->resize(numberOfMCC, nullptr);
90 }
91
92#ifdef G4VERBOSE
93 if (verboseLevel>2)
94 {
95 G4cout << "G4PhysicsTableHelper::PreparePhysicsTable: "
96 << " the table "<< physTable
97 << " size=" << numberOfMCC << G4endl;
98 }
99#endif
100
101 // Reset recal-needed flag for all physics vectors
102 physTable->ResetFlagArray();
103
104 for (std::size_t idx = 0; idx <numberOfMCC; ++idx)
105 {
106 const G4MaterialCutsCouple* mcc = cutTable->GetMaterialCutsCouple((G4int)idx);
107
108 // check if re-calculation of the physics vector is needed
109 // MCC is not used
110 if ( !mcc->IsUsed() ) physTable->ClearFlag(idx);
111
112 // RecalcNeeded flag of MCC is not asserted
113 if ( !mcc->IsRecalcNeeded() ) physTable->ClearFlag(idx);
114 }
115
116 return physTable;
117}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
int G4int
Definition G4Types.hh:85
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
void resize(std::size_t, G4PhysicsVector *vec=nullptr)
void ClearFlag(std::size_t i)
const G4MaterialCutsCouple * GetMaterialCutsCouple(G4int i) const
std::size_t GetTableSize() const
static G4ProductionCutsTable * GetProductionCutsTable()

Referenced by G4LossTableBuilder::BuildTableForModel(), G4WentzelVIModel::Initialise(), G4EmDataHandler::MakeTable(), and G4EmDataHandler::MakeTable().

◆ RetrievePhysicsTable()

G4bool G4PhysicsTableHelper::RetrievePhysicsTable ( G4PhysicsTable * physTable,
const G4String & fileName,
G4bool ascii,
G4bool spline )
static

Definition at line 120 of file G4PhysicsTableHelper.cc.

123{
124 if (physTable == nullptr ) return false;
125
126 // retrieve physics table from the given file
127 G4PhysicsTable* tempTable = new G4PhysicsTable();
128 if (! tempTable->RetrievePhysicsTable(fileName,ascii,spline) )
129 {
131 ed << "Cannot retrieve physics table from the file <" << fileName << ">";
132 G4Exception( "G4ProductionCutsTable::RetrievePhysicsTable()",
133 "ProcCuts105", JustWarning, ed);
134 delete tempTable;
135 return false;
136 }
137
138 G4ProductionCutsTable* cutTable
140 const G4MCCIndexConversionTable* converter
141 = cutTable->GetMCCIndexConversionTable();
142
143 // check physics table size
144 if ( tempTable->size() != converter->size())
145 {
147 ed << "Physics table in " << fileName
148 << "\n size=" << tempTable->size() << " "
149 << " is inconsistent with material-cut-couple "
150 << "size=" << converter->size() << " the table is not retrieved!";
151 G4Exception("G4ProductionCutsTable::RetrievePhysicsTable()",
152 "ProcCuts106", JustWarning, ed);
153 delete tempTable;
154 return false;
155 }
156
157 // fill the given physics table with retrieved physics vectors
158 for (std::size_t idx=0; idx<converter->size(); ++idx)
159 {
160 if (converter->IsUsed(idx))
161 {
162 G4int i = converter->GetIndex(idx);
163 if(i < 0)
164 {
165 tempTable->clearAndDestroy();
166 delete tempTable;
167 return false;
168 }
169 G4PhysicsVector* vec = (*physTable)[i];
170 if (vec != nullptr ) delete vec;
171 (*physTable)[i] = (*tempTable)[idx];
172 physTable->ClearFlag(i);
173 }
174 }
175 tempTable->clear();
176 delete tempTable;
177
178 return true;
179}
@ JustWarning
G4bool IsUsed(std::size_t index) const
G4int GetIndex(std::size_t index) const
void clearAndDestroy()
G4bool RetrievePhysicsTable(const G4String &filename, G4bool ascii=false, G4bool spline=false)
const G4MCCIndexConversionTable * GetMCCIndexConversionTable() const

Referenced by G4EmDataHandler::RetrievePhysicsTable(), and G4EmTableUtil::RetrieveTable().

◆ SetPhysicsVector()

void G4PhysicsTableHelper::SetPhysicsVector ( G4PhysicsTable * physTable,
std::size_t idx,
G4PhysicsVector * vec )
static

Definition at line 182 of file G4PhysicsTableHelper.cc.

185{
186 if ( physTable == nullptr) { return; }
187
188 if ( physTable->size() <= idx)
189 {
191 ed << "Given index (" << idx << ") exceeds "
192 << "the size of the physics table "
193 << "( size =" << physTable->size() << ") the vector is not added!";
194 G4Exception("G4ProductionCutsTable::SetPhysicsVector()",
195 "ProcCuts107",
196 JustWarning, ed);
197 return;
198 }
199
200 // set physics vector
201 (*physTable)[idx] = vec;
202 // clear flag
203 physTable->ClearFlag(idx);
204}

Referenced by G4EmTableUtil::BuildDEDXTable(), G4LossTableBuilder::BuildDEDXTable(), G4LossTableBuilder::BuildInverseRangeTable(), G4EmTableUtil::BuildLambdaTable(), G4EmTableUtil::BuildLambdaTable(), G4TransportationWithMsc::BuildPhysicsTable(), G4LossTableBuilder::BuildRangeTable(), G4LossTableBuilder::BuildTableForModel(), G4GammaGeneralProcess::InitialiseProcess(), and G4NeutronGeneralProcess::PreparePhysicsTable().

◆ SetVerboseLevel()

void G4PhysicsTableHelper::SetVerboseLevel ( G4int value)
static

Definition at line 207 of file G4PhysicsTableHelper.cc.

208{
210}
G4bool IsWorkerThread()

Member Data Documentation

◆ verboseLevel

G4int G4PhysicsTableHelper::verboseLevel = 1
staticprotected

Definition at line 77 of file G4PhysicsTableHelper.hh.

Referenced by GetVerboseLevel(), PreparePhysicsTable(), and SetVerboseLevel().


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