Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 G4ThreadLocal G4int verboseLevel = 1
 

Detailed Description

Definition at line 52 of file G4PhysicsTableHelper.hh.

Constructor & Destructor Documentation

G4PhysicsTableHelper::G4PhysicsTableHelper ( )
protected

Definition at line 46 of file G4PhysicsTableHelper.cc.

47 {
48 }
G4PhysicsTableHelper::~G4PhysicsTableHelper ( )
protected

Definition at line 50 of file G4PhysicsTableHelper.cc.

51 {
52 }
G4PhysicsTableHelper::G4PhysicsTableHelper ( const G4PhysicsTableHelper right)
protected

Definition at line 54 of file G4PhysicsTableHelper.cc.

55 {
56 }

Member Function Documentation

G4int G4PhysicsTableHelper::GetVerboseLevel ( )
static

Definition at line 235 of file G4PhysicsTableHelper.cc.

236 {
237  return verboseLevel;
238 }
static G4ThreadLocal G4int verboseLevel
G4PhysicsTableHelper & G4PhysicsTableHelper::operator= ( const G4PhysicsTableHelper )
protected

Definition at line 58 of file G4PhysicsTableHelper.cc.

59 {
60  return *this;
61 }
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 }
G4bool IsRecalcNeeded() const
static G4ThreadLocal G4int verboseLevel
void ClearFlag(size_t i)
void resize(size_t, G4PhysicsVector *vec=(G4PhysicsVector *)(0))
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
static G4ProductionCutsTable * GetProductionCutsTable()
const G4MaterialCutsCouple * GetMaterialCutsCouple(G4int i) const
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr

Here is the call graph for this function:

Here is the caller graph for this function:

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 }
G4bool RetrievePhysicsTable(const G4String &filename, G4bool ascii=false)
G4int GetIndex(size_t index) const
G4bool IsUsed(size_t index) const
static G4ThreadLocal G4int verboseLevel
void ClearFlag(size_t i)
const G4MCCIndexConversionTable * GetMCCIndexConversionTable() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
static G4ProductionCutsTable * GetProductionCutsTable()
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr

Here is the call graph for this function:

Here is the caller graph for this function:

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 }
static G4ThreadLocal G4int verboseLevel
void ClearFlag(size_t i)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr

Here is the call graph for this function:

Here is the caller graph for this function:

void G4PhysicsTableHelper::SetVerboseLevel ( G4int  value)
static

Definition at line 230 of file G4PhysicsTableHelper.cc.

231 {
233 }
static G4ThreadLocal G4int verboseLevel
const XML_Char int const XML_Char * value
Definition: expat.h:331

Member Data Documentation

G4ThreadLocal G4int G4PhysicsTableHelper::verboseLevel = 1
staticprotected

Definition at line 87 of file G4PhysicsTableHelper.hh.


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