00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 #ifndef G4ProductionCutsTable_h
00052 #define G4ProductionCutsTable_h 1
00053
00054 class G4RegionStore;
00055 class G4VRangeToEnergyConverter;
00056 class G4LogicalVolume;
00057 class G4VPhysicalVolume;
00058 class G4ProductionCuts;
00059
00060 class G4ProductionCutsTableMessenger;
00061
00062 #include "globals.hh"
00063 #include <cmath>
00064 #include "G4ios.hh"
00065 #include <vector>
00066 #include "G4MaterialCutsCouple.hh"
00067 #include "G4MCCIndexConversionTable.hh"
00068 #include "G4Region.hh"
00069
00070
00071 class G4ProductionCutsTable
00072 {
00073 public:
00074 static G4ProductionCutsTable* GetProductionCutsTable();
00075
00076
00077
00078 protected:
00079 G4ProductionCutsTable();
00080 private:
00081 G4ProductionCutsTable(const G4ProductionCutsTable& right);
00082
00083 public:
00084 virtual ~G4ProductionCutsTable();
00085
00086 public:
00087 void UpdateCoupleTable(G4VPhysicalVolume* currentWorld);
00088
00089
00090 void SetEnergyRange(G4double lowedge, G4double highedge);
00091
00092
00093 G4double GetLowEdgeEnergy() const;
00094 G4double GetHighEdgeEnergy() const;
00095
00096
00097
00098 G4double GetMaxEnergyCut();
00099 void SetMaxEnergyCut(G4double value);
00100
00101
00102 void DumpCouples() const;
00103
00104
00105 const G4MCCIndexConversionTable* GetMCCIndexConversionTable() const;
00106
00107
00108 private:
00109
00110 static G4ProductionCutsTable* fG4ProductionCutsTable;
00111
00112 typedef std::vector<G4MaterialCutsCouple*> G4CoupleTable;
00113 typedef std::vector<G4MaterialCutsCouple*>::const_iterator CoupleTableIterator;
00114 typedef std::vector<G4double> G4CutVectorForAParticle;
00115 typedef std::vector<G4CutVectorForAParticle*> G4CutTable;
00116 G4CoupleTable coupleTable;
00117 G4CutTable rangeCutTable;
00118 G4CutTable energyCutTable;
00119
00120 G4RegionStore* fG4RegionStore;
00121 G4VRangeToEnergyConverter* converters[NumberOfG4CutIndex];
00122
00123 G4ProductionCuts* defaultProductionCuts;
00124
00125 G4MCCIndexConversionTable mccConversionTable;
00126
00127
00128 G4double* rangeDoubleVector[NumberOfG4CutIndex];
00129 G4double* energyDoubleVector[NumberOfG4CutIndex];
00130
00131 public:
00132 const std::vector<G4double>* GetRangeCutsVector(size_t pcIdx) const;
00133 const std::vector<G4double>* GetEnergyCutsVector(size_t pcIdx) const;
00134
00135
00136 G4double* GetRangeCutsDoubleVector(size_t pcIdx) const;
00137 G4double* GetEnergyCutsDoubleVector(size_t pcIdx) const;
00138
00139 public:
00140 size_t GetTableSize() const;
00141
00142
00143 const G4MaterialCutsCouple* GetMaterialCutsCouple(G4int i) const;
00144
00145
00146 const G4MaterialCutsCouple*
00147 GetMaterialCutsCouple(const G4Material* aMat,
00148 const G4ProductionCuts* aCut) const;
00149
00150
00151 G4int GetCoupleIndex(const G4MaterialCutsCouple* aCouple) const;
00152 G4int GetCoupleIndex(const G4Material* aMat,
00153 const G4ProductionCuts* aCut) const;
00154
00155
00156
00157 G4bool IsModified() const;
00158
00159
00160 void PhysicsTableUpdated();
00161
00162
00163
00164 G4ProductionCuts* GetDefaultProductionCuts() const;
00165
00166
00167 G4double ConvertRangeToEnergy(const G4ParticleDefinition* particle,
00168 const G4Material* material,
00169 G4double range );
00170
00171
00172
00173
00174 void ResetConverters();
00175
00176
00177 private:
00178 void ScanAndSetCouple(G4LogicalVolume* aLV,
00179 G4MaterialCutsCouple* aCouple,
00180 G4Region* aRegion);
00181
00182 bool IsCoupleUsedInTheRegion(const G4MaterialCutsCouple* aCouple,
00183 const G4Region* aRegion) const;
00184
00185 public:
00186
00187 G4bool StoreCutsTable(const G4String& directory,
00188 G4bool ascii = false);
00189
00190
00191
00192 G4bool RetrieveCutsTable(const G4String& directory,
00193 G4bool ascii = false);
00194
00195
00196 G4bool CheckForRetrieveCutsTable(const G4String& directory,
00197 G4bool ascii = false);
00198
00199 protected:
00200
00201
00202 virtual G4bool StoreMaterialInfo(const G4String& directory,
00203 G4bool ascii = false);
00204
00205
00206 virtual G4bool CheckMaterialInfo(const G4String& directory,
00207 G4bool ascii = false);
00208
00209
00210 virtual G4bool StoreMaterialCutsCoupleInfo(const G4String& directory,
00211 G4bool ascii = false);
00212
00213
00214 virtual G4bool CheckMaterialCutsCoupleInfo(const G4String& directory,
00215 G4bool ascii = false);
00216
00217
00218 virtual G4bool StoreCutsInfo(const G4String& directory,
00219 G4bool ascii = false);
00220
00221
00222 virtual G4bool RetrieveCutsInfo(const G4String& directory,
00223 G4bool ascii = false);
00224
00225 private:
00226 G4bool firstUse;
00227 enum { FixedStringLengthForStore = 32 };
00228
00229 public:
00230 void SetVerboseLevel(G4int value);
00231 G4int GetVerboseLevel() const;
00232
00233
00234
00235
00236
00237 private:
00238 G4int verboseLevel;
00239 G4ProductionCutsTableMessenger* fMessenger;
00240
00241 };
00242
00243 inline
00244 const std::vector<G4double>* G4ProductionCutsTable::GetRangeCutsVector(size_t pcIdx) const
00245 {
00246 return rangeCutTable[pcIdx];
00247 }
00248
00249 inline
00250 const std::vector<G4double>* G4ProductionCutsTable::GetEnergyCutsVector(size_t pcIdx) const
00251 {
00252 return energyCutTable[pcIdx];
00253 }
00254
00255 inline
00256 size_t G4ProductionCutsTable::GetTableSize() const
00257 {
00258 return coupleTable.size();
00259 }
00260
00261 inline
00262 const G4MaterialCutsCouple* G4ProductionCutsTable::GetMaterialCutsCouple(G4int i) const
00263 {
00264 return coupleTable[size_t(i)];
00265 }
00266
00267 inline
00268 G4bool G4ProductionCutsTable::IsModified() const
00269 {
00270 if(firstUse) return true;
00271 for(G4ProductionCutsTable::CoupleTableIterator itr=coupleTable.begin();
00272 itr!=coupleTable.end();itr++){
00273 if((*itr)->IsRecalcNeeded())
00274 {
00275 return true;
00276 }
00277 }
00278 return false;
00279 }
00280
00281 inline
00282 void G4ProductionCutsTable::PhysicsTableUpdated()
00283 {
00284 for(G4ProductionCutsTable::CoupleTableIterator itr=coupleTable.begin();itr!=coupleTable.end();itr++){
00285 (*itr)->PhysicsTableUpdated();
00286 }
00287 }
00288
00289 inline
00290 G4double* G4ProductionCutsTable::GetRangeCutsDoubleVector(size_t pcIdx) const
00291 { return rangeDoubleVector[pcIdx]; }
00292
00293 inline
00294 G4double* G4ProductionCutsTable::GetEnergyCutsDoubleVector(size_t pcIdx) const
00295 { return energyDoubleVector[pcIdx]; }
00296
00297 inline
00298 G4ProductionCuts* G4ProductionCutsTable::GetDefaultProductionCuts() const
00299 { return defaultProductionCuts; }
00300
00301 inline
00302 bool G4ProductionCutsTable::IsCoupleUsedInTheRegion(
00303 const G4MaterialCutsCouple* aCouple,
00304 const G4Region* aRegion) const
00305 {
00306 G4ProductionCuts* fProductionCut = aRegion->GetProductionCuts();
00307 std::vector<G4Material*>::const_iterator mItr = aRegion->GetMaterialIterator();
00308 size_t nMaterial = aRegion->GetNumberOfMaterials();
00309 for(size_t iMate=0;iMate<nMaterial;iMate++, mItr++){
00310 if(aCouple->GetMaterial()==(*mItr) &&
00311 aCouple->GetProductionCuts()==fProductionCut){
00312 return true;
00313 }
00314 }
00315 return false;
00316 }
00317
00318 inline
00319 const G4MaterialCutsCouple*
00320 G4ProductionCutsTable::GetMaterialCutsCouple(const G4Material* aMat,
00321 const G4ProductionCuts* aCut) const
00322 {
00323 for(CoupleTableIterator cItr=coupleTable.begin();cItr!=coupleTable.end();cItr++)
00324 {
00325 if((*cItr)->GetMaterial()!=aMat) continue;
00326 if((*cItr)->GetProductionCuts()==aCut) return (*cItr);
00327 }
00328 return 0;
00329 }
00330
00331 inline
00332 G4int G4ProductionCutsTable::GetCoupleIndex(const G4MaterialCutsCouple* aCouple) const
00333 {
00334 G4int idx = 0;
00335 for(CoupleTableIterator cItr=coupleTable.begin();cItr!=coupleTable.end();cItr++)
00336 {
00337 if((*cItr)==aCouple) return idx;
00338 idx++;
00339 }
00340 return -1;
00341 }
00342
00343 inline
00344 G4int G4ProductionCutsTable:: GetCoupleIndex(const G4Material* aMat,
00345 const G4ProductionCuts* aCut) const
00346 {
00347 const G4MaterialCutsCouple* aCouple = GetMaterialCutsCouple(aMat,aCut);
00348 return GetCoupleIndex(aCouple);
00349 }
00350
00351 inline
00352 G4int G4ProductionCutsTable::GetVerboseLevel() const
00353 {
00354 return verboseLevel;
00355 }
00356
00357 inline
00358 const G4MCCIndexConversionTable*
00359 G4ProductionCutsTable::GetMCCIndexConversionTable() const
00360 {
00361 return &mccConversionTable;
00362 }
00363
00364 #endif
00365
00366
00367
00368
00369
00370