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

#include <G4PhysicsTableHelper.hh>

Static Public Member Functions

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

Protected Member Functions

 G4PhysicsTableHelper ()
 
 ~G4PhysicsTableHelper ()
 
 G4PhysicsTableHelper (const G4PhysicsTableHelper &right)
 
G4PhysicsTableHelperoperator= (const G4PhysicsTableHelper &)
 

Static Protected Attributes

static G4int verboseLevel = 1
 

Detailed Description

Definition at line 52 of file G4PhysicsTableHelper.hh.

Constructor & Destructor Documentation

◆ G4PhysicsTableHelper() [1/2]

G4PhysicsTableHelper::G4PhysicsTableHelper ( )
protected

Definition at line 46 of file G4PhysicsTableHelper.cc.

47{
48}

◆ ~G4PhysicsTableHelper()

G4PhysicsTableHelper::~G4PhysicsTableHelper ( )
protected

Definition at line 50 of file G4PhysicsTableHelper.cc.

51{
52}

◆ G4PhysicsTableHelper() [2/2]

G4PhysicsTableHelper::G4PhysicsTableHelper ( const G4PhysicsTableHelper right)
protected

Definition at line 54 of file G4PhysicsTableHelper.cc.

55{
56}

Member Function Documentation

◆ GetVerboseLevel()

G4int G4PhysicsTableHelper::GetVerboseLevel ( )
inlinestatic

Definition at line 98 of file G4PhysicsTableHelper.hh.

99{
100 return verboseLevel;
101}

◆ operator=()

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

Definition at line 58 of file G4PhysicsTableHelper.cc.

59{
60 return *this;
61}

◆ PreparePhysicsTable()

G4PhysicsTable * G4PhysicsTableHelper::PreparePhysicsTable ( G4PhysicsTable physTable)
static

Definition at line 64 of file G4PhysicsTableHelper.cc.

65{
67 size_t numberOfMCC = cutTable->GetTableSize();
68
69 if ( physTable !=0) {
70 // compare size of physics table and number of material-cuts-couple
71 if ( physTable->size() < numberOfMCC) {
72 // enlarge physcis table
73 physTable->resize(numberOfMCC, (G4PhysicsVector*)(0));
74#ifdef G4VERBOSE
75 if (verboseLevel>2) {
76 G4cerr << "G4PhysicsTableHelper::PreparePhysicsTable ";
77 G4cerr << "Physics Table "<< physTable ;
78 G4cerr << " is resized to " << numberOfMCC << G4endl;
79 }
80#endif
81 } else if ( physTable->size() > numberOfMCC){
82 // ERROR: this situation should not occur
83 // size of physics table is shorter than number of material-cuts-couple
84 physTable->resize(numberOfMCC);
85#ifdef G4VERBOSE
86 if (verboseLevel>0) {
87 G4cerr << "G4PhysicsTableHelper::PreparePhysicsTable ";
88 G4cerr << "Physics Table "<< physTable ;
89 G4cerr << " is longer than number of material-cuts-couple " << G4endl;
90 }
91#endif
92 G4Exception( "G4PhysicsTableHelper::PreparePhysicsTable()",
93 "ProcCuts001", FatalException,
94 "Physics Table is inconsistent with material-cuts-couple");
95 }
96 } else {
97 // create PhysicsTable is given poitner is null
98 physTable = new G4PhysicsTable(numberOfMCC);
99 if (physTable!=0) {
100 physTable->resize(numberOfMCC, (G4PhysicsVector*)(0));
101 } else {
102 G4Exception( "G4PhysicsTableHelper::PreparePhysicsTable()",
103 "ProcCuts002", FatalException,
104 "Can't create Physics Table");
105 }
106 }
107
108#ifdef G4VERBOSE
109 if (verboseLevel>2) {
110 if ( physTable !=0) {
111 G4cerr << "Physics Table size "<< physTable->size();
112 } else {
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 (size_t idx = 0; idx <numberOfMCC; idx +=1){
123 const G4MaterialCutsCouple* mcc = cutTable->GetMaterialCutsCouple(idx);
124 //check if re-calculation of the physics vector is needed
125 // MCC is not used
126 if ( !mcc->IsUsed() ) physTable->ClearFlag(idx);
127
128 // RecalcNeeded flag of MCC is not asserted
129 if ( !mcc->IsRecalcNeeded() ) physTable->ClearFlag(idx);
130 }
131
132 return physTable;
133}
@ FatalException
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cerr
void resize(size_t, G4PhysicsVector *vec=(G4PhysicsVector *)(0))
void ClearFlag(size_t i)
const G4MaterialCutsCouple * GetMaterialCutsCouple(G4int i) const
static G4ProductionCutsTable * GetProductionCutsTable()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

Referenced by G4VEnergyLossProcess::BuildDEDXTable(), G4LossTableBuilder::BuildTableForModel(), G4eplusPolarizedAnnihilation::PreparePhysicsTable(), G4PolarizedCompton::PreparePhysicsTable(), G4VEmProcess::PreparePhysicsTable(), and G4VEnergyLossProcess::PreparePhysicsTable().

◆ RetrievePhysicsTable()

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

Definition at line 137 of file G4PhysicsTableHelper.cc.

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

Referenced by G4VEmProcess::RetrievePhysicsTable().

◆ SetPhysicsVector()

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

Definition at line 199 of file G4PhysicsTableHelper.cc.

202{
203 if ( physTable ==0) { return; }
204
205 if ( physTable->size() <= idx) {
206#ifdef G4VERBOSE
207 if (verboseLevel>0) {
208 G4cerr << "G4PhysicsTableHelper::SetPhysicsVector ";
209 G4cerr << "Given index (" << idx << ") exceeds ";
210 G4cerr << "size of the physics table ";
211 G4cerr << "( size =" << physTable->size()<< ")";
212 G4cerr << G4endl;
213 }
214#endif
215 G4Exception( "G4ProductionCutsTable::SetPhysicsVector()",
216 "ProcCuts107",
217 JustWarning, "Illegal index ");
218 return;
219 }
220
221 // set physics vector
222 (*physTable)[idx] = vec;
223 // clear flag
224 physTable->ClearFlag(idx);
225
226
227}

Referenced by G4eplusPolarizedAnnihilation::BuildAsymmetryTable(), G4PolarizedCompton::BuildAsymmetryTable(), G4VEnergyLossProcess::BuildDEDXTable(), G4LossTableBuilder::BuildDEDXTable(), G4LossTableBuilder::BuildInverseRangeTable(), G4VEnergyLossProcess::BuildLambdaTable(), G4LossTableBuilder::BuildRangeTable(), and G4LossTableBuilder::BuildTableForModel().

◆ SetVerboseLevel()

void G4PhysicsTableHelper::SetVerboseLevel ( G4int  value)
inlinestatic

Definition at line 92 of file G4PhysicsTableHelper.hh.

93{
94 verboseLevel = value;
95}

Member Data Documentation

◆ verboseLevel

G4int G4PhysicsTableHelper::verboseLevel = 1
staticprotected

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