Geant4 10.7.0
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)
 
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 G4ThreadLocal G4int verboseLevel = 1
 

Detailed Description

Definition at line 46 of file G4PhysicsTableHelper.hh.

Constructor & Destructor Documentation

◆ G4PhysicsTableHelper() [1/2]

G4PhysicsTableHelper::G4PhysicsTableHelper ( const G4PhysicsTableHelper )
delete

◆ G4PhysicsTableHelper() [2/2]

G4PhysicsTableHelper::G4PhysicsTableHelper ( )
protected

Definition at line 37 of file G4PhysicsTableHelper.cc.

38{
39}

◆ ~G4PhysicsTableHelper()

G4PhysicsTableHelper::~G4PhysicsTableHelper ( )
protected

Definition at line 42 of file G4PhysicsTableHelper.cc.

43{
44}

Member Function Documentation

◆ GetVerboseLevel()

G4int G4PhysicsTableHelper::GetVerboseLevel ( )
static

Definition at line 245 of file G4PhysicsTableHelper.cc.

246{
247 return verboseLevel;
248}
static G4ThreadLocal G4int verboseLevel

◆ operator=()

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

◆ PreparePhysicsTable()

G4PhysicsTable * G4PhysicsTableHelper::PreparePhysicsTable ( G4PhysicsTable physTable)
static

Definition at line 48 of file G4PhysicsTableHelper.cc.

49{
50 G4ProductionCutsTable* cutTable
52 std::size_t numberOfMCC = cutTable->GetTableSize();
53
54 if ( physTable != nullptr)
55 {
56 // compare size of physics table and number of material-cuts-couple
57 if ( physTable->size() < numberOfMCC)
58 {
59 // enlarge physics table
60 physTable->resize(numberOfMCC, nullptr);
61#ifdef G4VERBOSE
62 if (verboseLevel>2)
63 {
64 G4cerr << "G4PhysicsTableHelper::PreparePhysicsTable ";
65 G4cerr << "Physics Table "<< physTable ;
66 G4cerr << " is resized to " << numberOfMCC << G4endl;
67 }
68#endif
69 }
70 else if ( physTable->size() > numberOfMCC)
71 {
72 // ERROR: this situation should not occur
73 // size of physics table is shorter than number of material-cuts-couple
74 physTable->resize(numberOfMCC);
75#ifdef G4VERBOSE
76 if (verboseLevel>0)
77 {
78 G4cerr << "G4PhysicsTableHelper::PreparePhysicsTable ";
79 G4cerr << "Physics Table "<< physTable ;
80 G4cerr << " is longer than number of material-cuts-couple " << G4endl;
81 }
82#endif
83 G4Exception( "G4PhysicsTableHelper::PreparePhysicsTable()",
84 "ProcCuts001", FatalException,
85 "Physics Table is inconsistent with material-cuts-couple");
86 }
87 }
88 else
89 {
90 // create PhysicsTable is given poitner is null
91 physTable = new G4PhysicsTable(numberOfMCC);
92 if (physTable != nullptr)
93 {
94 physTable->resize(numberOfMCC, nullptr);
95 }
96 else
97 {
98 G4Exception( "G4PhysicsTableHelper::PreparePhysicsTable()",
99 "ProcCuts002", FatalException,
100 "Can't create Physics Table");
101 }
102 }
103
104#ifdef G4VERBOSE
105 if (verboseLevel>2)
106 {
107 if ( physTable != nullptr)
108 {
109 G4cerr << "Physics Table size "<< physTable->size();
110 }
111 else
112 {
113 G4cerr << "Physics Table does not exist ";
114 }
115 G4cerr << ": number of material-cuts-couple " << numberOfMCC << G4endl;
116 }
117#endif
118
119 // Reset recal-needed flag for all physics vectors
120 physTable->ResetFlagArray();
121
122 for (std::size_t idx = 0; idx <numberOfMCC; ++idx)
123 {
124 const G4MaterialCutsCouple* mcc = cutTable->GetMaterialCutsCouple(idx);
125
126 // check if re-calculation of the physics vector is needed
127 // MCC is not used
128 if ( !mcc->IsUsed() ) physTable->ClearFlag(idx);
129
130 // RecalcNeeded flag of MCC is not asserted
131 if ( !mcc->IsRecalcNeeded() ) physTable->ClearFlag(idx);
132 }
133
134 return physTable;
135}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
void resize(std::size_t, G4PhysicsVector *vec=(G4PhysicsVector *)(0))
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 G4VEnergyLossProcess::PreparePhysicsTable().

◆ RetrievePhysicsTable()

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

Definition at line 138 of file G4PhysicsTableHelper.cc.

141{
142 if (physTable == nullptr ) return false;
143
144 // retrieve physics table from the given file
145 G4PhysicsTable* tempTable = new G4PhysicsTable();
146 if (! tempTable->RetrievePhysicsTable(fileName,ascii) )
147 {
148#ifdef G4VERBOSE
149 if (verboseLevel>1)
150 {
151 G4cerr << "G4PhysicsTableHelper::RetrievePhysicsTable ";
152 G4cerr << "Fail to retrieve from "<< fileName << G4endl;
153 }
154#endif
155 G4Exception( "G4ProductionCutsTable::RetrievePhysicsTable()",
156 "ProcCuts105",
157 JustWarning, "Can not retrieve physics tables from file");
158 delete tempTable;
159 return false;
160 }
161
162 G4ProductionCutsTable* cutTable
164 const G4MCCIndexConversionTable* converter
165 = cutTable->GetMCCIndexConversionTable();
166
167 // check physics table size
168 if ( tempTable->size() != converter->size())
169 {
170#ifdef G4VERBOSE
171 if (verboseLevel>0)
172 {
173 G4cerr << "G4PhysicsTableHelper::RetrievePhysicsTable ";
174 G4cerr << "Size of the physics table in "<< fileName;
175 G4cerr << "( size =" << tempTable->size() << ")";
176 G4cerr << " is inconsistent with material-cut info";
177 G4cerr << "( size =" << converter->size() << ")";
178 G4cerr << G4endl;
179 }
180#endif
181 G4Exception("G4ProductionCutsTable::RetrievePhysicsTable()",
182 "ProcCuts106", JustWarning,
183 "Retrieved file is inconsistent with current physics tables!");
184 delete tempTable;
185 return false;
186 }
187
188 // fill the given physics table with retrieved physics vectors
189 for (std::size_t idx=0; idx<converter->size(); ++idx)
190 {
191 if (converter->IsUsed(idx))
192 {
193 if (converter->GetIndex(idx)<0) continue;
194 std::size_t i = converter->GetIndex(idx);
195 G4PhysicsVector* vec = (*physTable)[i];
196 if (vec != nullptr ) delete vec;
197 (*physTable)[i] = (*tempTable)[idx];
198 physTable->ClearFlag(i);
199 }
200 }
201 tempTable->clear();
202 delete tempTable;
203
204 return true;
205}
@ JustWarning
G4bool IsUsed(std::size_t index) const
G4int GetIndex(std::size_t index) const
G4bool RetrievePhysicsTable(const G4String &filename, G4bool ascii=false)
const G4MCCIndexConversionTable * GetMCCIndexConversionTable() const

Referenced by G4VEmProcess::RetrievePhysicsTable(), and G4EmDataHandler::RetrievePhysicsTable().

◆ SetPhysicsVector()

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

Definition at line 208 of file G4PhysicsTableHelper.cc.

211{
212 if ( physTable == nullptr) { return; }
213
214 if ( physTable->size() <= idx)
215 {
216#ifdef G4VERBOSE
217 if (verboseLevel>0)
218 {
219 G4cerr << "G4PhysicsTableHelper::SetPhysicsVector ";
220 G4cerr << "Given index (" << idx << ") exceeds ";
221 G4cerr << "size of the physics table ";
222 G4cerr << "( size =" << physTable->size()<< ")";
223 G4cerr << G4endl;
224 }
225#endif
226 G4Exception("G4ProductionCutsTable::SetPhysicsVector()",
227 "ProcCuts107",
228 JustWarning, "Illegal index!");
229 return;
230 }
231
232 // set physics vector
233 (*physTable)[idx] = vec;
234 // clear flag
235 physTable->ClearFlag(idx);
236}

Referenced by G4VEnergyLossProcess::BuildDEDXTable(), G4LossTableBuilder::BuildDEDXTable(), G4LossTableBuilder::BuildInverseRangeTable(), G4VEnergyLossProcess::BuildLambdaTable(), G4LossTableBuilder::BuildRangeTable(), G4LossTableBuilder::BuildTableForModel(), and G4GammaGeneralProcess::InitialiseProcess().

◆ SetVerboseLevel()

void G4PhysicsTableHelper::SetVerboseLevel ( G4int  value)
static

Definition at line 239 of file G4PhysicsTableHelper.cc.

240{
241 verboseLevel = value;
242}

Member Data Documentation

◆ verboseLevel

G4ThreadLocal G4int G4PhysicsTableHelper::verboseLevel = 1
staticprotected

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