Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // 26 // G4ProductionCutsTable << 27 // 23 // 28 // Class description: << 24 // $Id: G4ProductionCutsTable.hh,v 1.3 2004/02/03 08:29:35 kurasige Exp $ >> 25 // GEANT4 tag $Name: geant4-06-02 $ 29 // 26 // 30 // G4ProductionCutsTable is a singleton class << 27 // 31 // G4ProductionCuts objects. This class manage << 28 // ------------------------------------------------------------ 32 // cuts and energy cuts for each particle type << 29 // GEANT 4 class header file 33 << 30 // 34 // Author: M.Asai, 5 October 2002 - First impl << 31 // 35 // Modifications: H.Kurashige, 2004-2008 << 32 // ------------------------------------------------------------ 36 // ------------------------------------------- << 33 // First Implementation 05 Oct. 2002 M.Asai 37 #ifndef G4ProductionCutsTable_hh << 34 // 38 #define G4ProductionCutsTable_hh 1 << 35 // Modified 03 Feb 2004 H.Kurashige >> 36 // Modify RetrieveCutsTable to allow ordering of materials and >> 37 // couples can be different from one in file (i.e. at storing) >> 38 // ------------------------------------------------------------ 39 39 40 #include <cmath> << 40 #ifndef G4ProductionCutsTable_h 41 #include <vector> << 41 #define G4ProductionCutsTable_h 1 >> 42 >> 43 class G4RegionStore; >> 44 class G4VRangeToEnergyConverter; >> 45 class G4LogicalVolume; >> 46 class G4ProductionCuts; 42 47 43 #include "globals.hh" 48 #include "globals.hh" 44 #include "G4ios.hh" 49 #include "G4ios.hh" >> 50 #include <vector> 45 #include "G4MaterialCutsCouple.hh" 51 #include "G4MaterialCutsCouple.hh" 46 #include "G4MCCIndexConversionTable.hh" << 47 #include "G4Region.hh" 52 #include "G4Region.hh" 48 53 49 class G4RegionStore; << 50 class G4VRangeToEnergyConverter; << 51 class G4LogicalVolume; << 52 class G4VPhysicalVolume; << 53 class G4ProductionCuts; << 54 class G4ProductionCutsTableMessenger; << 55 54 56 class G4ProductionCutsTable 55 class G4ProductionCutsTable 57 { 56 { 58 public: << 57 // Class Description >> 58 // G4ProductionCutsTable is a static singleton class of a table of >> 59 // G4ProductionCuts objects. This class also manages tables of >> 60 // production cut and energy cut for each particle type. 59 61 >> 62 public: // with description 60 static G4ProductionCutsTable* GetProductio 63 static G4ProductionCutsTable* GetProductionCutsTable(); 61 // This static method returns the single << 64 // This static method returns the singleton pointer of this class object. 62 // At first invocation, the singleton ob << 65 // At the first invokation of this method, the singleton object is instantiated. 63 66 64 G4ProductionCutsTable(const G4ProductionCu << 67 protected: 65 G4ProductionCutsTable& operator=(const G4P << 68 G4ProductionCutsTable(); >> 69 private: >> 70 G4ProductionCutsTable(const G4ProductionCutsTable& right); 66 71 >> 72 public: 67 virtual ~G4ProductionCutsTable(); 73 virtual ~G4ProductionCutsTable(); 68 74 69 void CreateCoupleTables(); << 75 public: // with description 70 // Creates material cuts couples table a << 76 void UpdateCoupleTable(); 71 << 77 // This method triggers an update of the table of G4ProductionCuts objects. 72 void UpdateCoupleTable(G4VPhysicalVolume* << 73 // Triggers an update of the table of G4 << 74 78 75 void SetEnergyRange(G4double lowedge, G4do 79 void SetEnergyRange(G4double lowedge, G4double highedge); 76 // Sets the limits of energy cuts for al << 80 // This method sets the limits of energy cuts for all particles. 77 81 78 G4double GetLowEdgeEnergy() const; 82 G4double GetLowEdgeEnergy() const; 79 G4double GetHighEdgeEnergy() const; 83 G4double GetHighEdgeEnergy() const; 80 // Get the limits of energy cuts for all << 84 // These methods get the limits of energy cuts for all particles. 81 << 82 G4double GetMaxEnergyCut(); << 83 void SetMaxEnergyCut(G4double value); << 84 // Get/set max cut energy of RangeToEner << 85 // for all particle types << 86 85 87 void DumpCouples() const; 86 void DumpCouples() const; 88 // Displays a list of registered couples << 87 // Display a list of registored couples >> 88 >> 89 private: 89 90 90 const G4MCCIndexConversionTable* GetMCCInd << 91 static G4ProductionCutsTable* fG4ProductionCutsTable; 91 // Gives the pointer to the MCCIndexConv << 92 92 93 const std::vector<G4double>* GetRangeCutsV << 93 typedef std::vector<G4MaterialCutsCouple*> G4CoupleTable; 94 const std::vector<G4double>* GetEnergyCuts << 94 typedef std::vector<G4MaterialCutsCouple*>::const_iterator CoupleTableIterator; >> 95 typedef std::vector<G4double> G4CutVectorForAParticle; >> 96 typedef std::vector<G4CutVectorForAParticle*> G4CutTable; >> 97 G4CoupleTable coupleTable; >> 98 G4CutTable rangeCutTable; >> 99 G4CutTable energyCutTable; >> 100 >> 101 G4RegionStore* fG4RegionStore; >> 102 G4VRangeToEnergyConverter* converters[NumberOfG4CutIndex]; >> 103 >> 104 G4ProductionCuts* defaultProductionCuts; >> 105 >> 106 // These two vectors are for the backward comparibility >> 107 G4double* rangeDoubleVector[NumberOfG4CutIndex]; >> 108 G4double* energyDoubleVector[NumberOfG4CutIndex]; >> 109 >> 110 public: >> 111 const std::vector<G4double>* GetRangeCutsVector(size_t pcIdx) const; >> 112 const std::vector<G4double>* GetEnergyCutsVector(size_t pcIdx) const; >> 113 >> 114 // These two vectors are for the backward comparibility >> 115 G4double* GetRangeCutsDoubleVector(size_t pcIdx) const; >> 116 G4double* GetEnergyCutsDoubleVector(size_t pcIdx) const; 95 117 96 std::size_t GetTableSize() const; << 118 public: // with description 97 // Returns the size of the couple table << 119 size_t GetTableSize() const; >> 120 // This method returns the size of the couple table. >> 121 >> 122 const G4MaterialCutsCouple* GetMaterialCutsCouple(G4int i) const; >> 123 // This method returns the pointer to the couple. >> 124 >> 125 const G4MaterialCutsCouple* >> 126 GetMaterialCutsCouple(const G4Material* aMat, >> 127 const G4ProductionCuts* aCut) const; >> 128 // This method returns the pointer to the couple. >> 129 >> 130 G4int GetCoupleIndex(const G4MaterialCutsCouple* aCouple) const; >> 131 G4int GetCoupleIndex(const G4Material* aMat, >> 132 const G4ProductionCuts* aCut) const; >> 133 // These methods return the index of the couple. >> 134 // -1 is returned if index is not found. 98 135 99 const G4MaterialCutsCouple* GetMaterialCut << 136 G4bool IsModified() const; 100 // Returns the pointer to the couple << 137 // This method returns TRUE if at least one production cut value is modified. >> 138 >> 139 void PhysicsTableUpdated(); >> 140 // This method resets the status of IsModified(). This method must >> 141 // be exclusively used by RunManager when physics tables are built. >> 142 >> 143 G4ProductionCuts* GetDefaultProductionCuts() const; >> 144 // This method returns the default production cuts. >> 145 >> 146 private: >> 147 void ScanAndSetCouple(G4LogicalVolume* aLV, >> 148 G4MaterialCutsCouple* aCouple, >> 149 G4Region* aRegion); 101 150 102 const G4MaterialCutsCouple* GetMaterialCut << 151 bool IsCoupleUsedInTheRegion(const G4MaterialCutsCouple* aCouple, 103 co << 152 const G4Region* aRegion) const; 104 // Returns the pointer to the couple << 105 << 106 G4int GetCoupleIndex(const G4MaterialCutsC << 107 G4int GetCoupleIndex(const G4Material* aMa << 108 const G4ProductionCut << 109 // Return the index of the couple. << 110 // -1 is returned if index is not found << 111 153 112 G4bool IsModified() const; << 154 public: // with description 113 // Returns TRUE if at least one producti << 155 // Store cuts and material information in files under the specified directory. >> 156 G4bool StoreCutsTable(const G4String& directory, >> 157 G4bool ascii = false); 114 158 115 void PhysicsTableUpdated(); << 159 // Retrieve cuts values information in files under the specified directory. 116 // Resets the status of IsModified(). Th << 160 G4bool RetrieveCutsTable(const G4String& directory, 117 // used by the RunManager when physics t << 161 G4bool ascii = false); 118 << 162 119 G4ProductionCuts* GetDefaultProductionCuts << 163 // check stored material and cut values are consistent with the current detector setup. 120 // Returns the default production cuts << 164 G4bool CheckForRetrieveCutsTable(const G4String& directory, 121 << 165 G4bool ascii = false); 122 G4double ConvertRangeToEnergy(const G4Part << 123 const G4Mate << 124 G4doub << 125 // Gives energy corresponding to range v << 126 // -1 is returned if particle or materia << 127 << 128 void ResetConverters(); << 129 // Resets all range to energy converters << 130 << 131 G4bool StoreCutsTable(const G4String& dire << 132 G4bool ascii = false << 133 // Stores cuts and material information << 134 // the specified directory << 135 << 136 G4bool RetrieveCutsTable(const G4String& d << 137 G4bool ascii = fa << 138 // Retrieve material cut couple informat << 139 // in files under the specified director << 140 << 141 G4bool CheckForRetrieveCutsTable(const G4S << 142 G4bool as << 143 // Checks stored material and cut values << 144 // with the current detector setup << 145 << 146 G4double* GetRangeCutsDoubleVector(std::si << 147 G4double* GetEnergyCutsDoubleVector(std::s << 148 // Methods for backward compatibility << 149 << 150 void SetEnergyCutVector(const std::vector< << 151 // User defined cut vectors (idx < 4) ra << 152 // to avoid inconsistency in physics << 153 << 154 void SetVerboseLevel(G4int value); << 155 G4int GetVerboseLevel() const; << 156 // Control flag for output message << 157 // 0: Silent << 158 // 1: Warning message << 159 // 2: More << 160 166 161 protected: 167 protected: 162 168 163 G4ProductionCutsTable(); << 169 // Store material information in files under the specified directory. 164 << 170 virtual G4bool StoreMaterialInfo(const G4String& directory, 165 virtual G4bool StoreMaterialInfo(const G4S << 171 G4bool ascii = false); 166 G4bool as << 172 167 // Stores material information in files << 173 // check stored material is consistent with the current detector setup. 168 << 174 virtual G4bool CheckMaterialInfo(const G4String& directory, 169 virtual G4bool CheckMaterialInfo(const G4S << 175 G4bool ascii = false); 170 G4bool as << 176 171 // Checks stored material is consistent << 177 // Store materialCutsCouple information in files under the specified directory. 172 << 178 virtual G4bool StoreMaterialCutsCoupleInfo(const G4String& directory, 173 virtual G4bool StoreMaterialCutsCoupleInfo << 179 G4bool ascii = false); 174 << 180 175 // Stores materialCutsCouple information << 181 // Retreive materialCutsCouple information in files under the specified directory. 176 // specified directory << 182 virtual G4bool RetrieveMaterialCutsCoupleInfo(const G4String& directory, 177 << 183 G4bool ascii = false); 178 virtual G4bool CheckMaterialCutsCoupleInfo << 184 179 << 185 // check stored materialCutsCouple is consistent with the current detector setup. 180 // Checks stored materialCutsCouple is c << 186 virtual G4bool CheckMaterialCutsCoupleInfo(const G4String& directory, 181 // the current detector setup << 187 G4bool ascii = false); 182 << 188 183 virtual G4bool StoreCutsInfo(const G4Strin << 189 // Store cut values information in files under the specified directory. 184 G4bool ascii << 190 virtual G4bool StoreCutsInfo(const G4String& directory, 185 // Stores cut values information in file << 191 G4bool ascii = false); 186 << 192 187 virtual G4bool RetrieveCutsInfo(const G4S << 193 // Retrieve cut values information in files under the specified directory. 188 G4bool as << 194 virtual G4bool RetrieveCutsInfo(const G4String& directory, 189 // Retrieves cut values information in f << 195 G4bool ascii = false); 190 // specified directory << 191 196 192 private: 197 private: 193 << 198 G4bool firstUse; 194 void ScanAndSetCouple(G4LogicalVolume* aLV << 199 G4bool isNeedForRestoreCoupleInfo; 195 G4MaterialCutsCouple << 200 enum { FixedStringLengthForStore = 32 }; 196 G4Region* aRegion); << 201 197 << 202 public: // with description 198 G4bool IsCoupleUsedInTheRegion(const G4Mat << 203 void SetVerboseLevel(G4int value); 199 const G4Reg << 204 G4int GetVerboseLevel() const; 200 << 205 // controle flag for output message >> 206 // 0: Silent >> 207 // 1: Warning message >> 208 // 2: More 201 209 202 private: 210 private: >> 211 G4int verboseLevel; 203 212 204 static G4ProductionCutsTable* fProductionC << 205 << 206 std::vector<G4MaterialCutsCouple*> coupleT << 207 std::vector<std::vector<G4double>*> rangeC << 208 std::vector<std::vector<G4double>*> energy << 209 << 210 std::vector<G4double>* userEnergyCuts[4] = << 211 << 212 G4RegionStore* fG4RegionStore = nullptr; << 213 G4VRangeToEnergyConverter* converters[Numb << 214 << 215 G4ProductionCuts* defaultProductionCuts = << 216 << 217 G4MCCIndexConversionTable mccConversionTab << 218 << 219 // These two vectors are for backward comp << 220 G4double* rangeDoubleVector[NumberOfG4CutI << 221 G4double* energyDoubleVector[NumberOfG4Cut << 222 << 223 enum { FixedStringLengthForStore = 32 }; << 224 << 225 G4ProductionCutsTableMessenger* fMessenger << 226 G4int verboseLevel = 1; << 227 G4bool firstUse = true; << 228 }; 213 }; 229 214 230 // ------------------ << 231 // Inline methods << 232 // ------------------ << 233 << 234 inline 215 inline 235 const std::vector<G4double>* << 216 const std::vector<G4double>* G4ProductionCutsTable::GetRangeCutsVector(size_t pcIdx) const 236 G4ProductionCutsTable::GetRangeCutsVector(std: << 237 { 217 { 238 return rangeCutTable[pcIdx]; 218 return rangeCutTable[pcIdx]; 239 } 219 } 240 220 241 inline 221 inline 242 const std::vector<G4double>* << 222 const std::vector<G4double>* G4ProductionCutsTable::GetEnergyCutsVector(size_t pcIdx) const 243 G4ProductionCutsTable::GetEnergyCutsVector(std << 244 { 223 { 245 return energyCutTable[pcIdx]; << 224 return energyCutTable[pcIdx]; 246 } 225 } 247 226 248 inline 227 inline 249 std::size_t G4ProductionCutsTable::GetTableSiz << 228 size_t G4ProductionCutsTable::GetTableSize() const 250 { 229 { 251 return coupleTable.size(); 230 return coupleTable.size(); 252 } 231 } 253 232 254 inline 233 inline 255 const G4MaterialCutsCouple* << 234 const G4MaterialCutsCouple* G4ProductionCutsTable::GetMaterialCutsCouple(G4int i) const 256 G4ProductionCutsTable::GetMaterialCutsCouple(G << 257 { 235 { 258 return coupleTable[std::size_t(i)]; << 236 return coupleTable[size_t(i)]; 259 } 237 } 260 238 261 inline 239 inline 262 G4bool G4ProductionCutsTable::IsModified() con << 240 G4bool G4ProductionCutsTable::IsModified() const 263 { 241 { 264 if(firstUse) return true; 242 if(firstUse) return true; 265 for(auto itr=coupleTable.cbegin(); itr!=coup << 243 for(G4ProductionCutsTable::CoupleTableIterator itr=coupleTable.begin(); 266 { << 244 itr!=coupleTable.end();itr++){ 267 if((*itr)->IsRecalcNeeded()) 245 if((*itr)->IsRecalcNeeded()) 268 { 246 { 269 return true; 247 return true; 270 } 248 } 271 } 249 } 272 return false; 250 return false; 273 } 251 } 274 252 275 inline 253 inline 276 void G4ProductionCutsTable::PhysicsTableUpdate << 254 void G4ProductionCutsTable::PhysicsTableUpdated() 277 { 255 { 278 for(auto itr=coupleTable.cbegin(); itr!=coup << 256 for(G4ProductionCutsTable::CoupleTableIterator itr=coupleTable.begin();itr!=coupleTable.end();itr++){ 279 { << 280 (*itr)->PhysicsTableUpdated(); 257 (*itr)->PhysicsTableUpdated(); 281 } 258 } 282 } 259 } 283 260 284 inline 261 inline 285 G4double* << 262 G4double* G4ProductionCutsTable::GetRangeCutsDoubleVector(size_t pcIdx) const 286 G4ProductionCutsTable::GetRangeCutsDoubleVecto << 263 { return rangeDoubleVector[pcIdx]; } 287 { << 288 return rangeDoubleVector[pcIdx]; << 289 } << 290 264 291 inline 265 inline 292 G4double* << 266 G4double* G4ProductionCutsTable::GetEnergyCutsDoubleVector(size_t pcIdx) const 293 G4ProductionCutsTable::GetEnergyCutsDoubleVect << 267 { return energyDoubleVector[pcIdx]; } 294 { << 295 return energyDoubleVector[pcIdx]; << 296 } << 297 268 298 inline 269 inline 299 G4ProductionCuts* G4ProductionCutsTable::GetDe << 270 G4ProductionCuts* G4ProductionCutsTable::GetDefaultProductionCuts() const 300 { << 271 { return defaultProductionCuts; } 301 return defaultProductionCuts; << 302 } << 303 272 304 inline 273 inline 305 G4bool G4ProductionCutsTable::IsCoupleUsedInTh << 274 bool G4ProductionCutsTable::IsCoupleUsedInTheRegion( 306 const G4Mater 275 const G4MaterialCutsCouple* aCouple, 307 const G4Regio 276 const G4Region* aRegion) const 308 { 277 { 309 G4ProductionCuts* fProductionCut = aRegion-> 278 G4ProductionCuts* fProductionCut = aRegion->GetProductionCuts(); 310 auto mItr = aRegion->GetMaterialIterator(); << 279 std::vector<G4Material*>::const_iterator mItr = aRegion->GetMaterialIterator(); 311 std::size_t nMaterial = aRegion->GetNumberOf << 280 size_t nMaterial = aRegion->GetNumberOfMaterials(); 312 for(std::size_t iMate=0;iMate<nMaterial; ++i << 281 for(size_t iMate=0;iMate<nMaterial;iMate++, mItr++){ 313 { << 314 if(aCouple->GetMaterial()==(*mItr) && 282 if(aCouple->GetMaterial()==(*mItr) && 315 aCouple->GetProductionCuts()==fProducti << 283 aCouple->GetProductionCuts()==fProductionCut){ 316 { << 317 return true; 284 return true; 318 } 285 } 319 } 286 } 320 return false; 287 return false; 321 } 288 } 322 289 323 inline 290 inline 324 const G4MaterialCutsCouple* 291 const G4MaterialCutsCouple* 325 G4ProductionCutsTable::GetMaterialCutsCouple(c << 292 G4ProductionCutsTable::GetMaterialCutsCouple(const G4Material* aMat, 326 c << 293 const G4ProductionCuts* aCut) const 327 { << 294 { 328 for(auto cItr=coupleTable.cbegin(); cItr!=co << 295 for(CoupleTableIterator cItr=coupleTable.begin();cItr!=coupleTable.end();cItr++) 329 { 296 { 330 if((*cItr)->GetMaterial()!=aMat) continue; 297 if((*cItr)->GetMaterial()!=aMat) continue; 331 if((*cItr)->GetProductionCuts()==aCut) ret 298 if((*cItr)->GetProductionCuts()==aCut) return (*cItr); 332 } 299 } 333 return nullptr; << 300 return 0; 334 } 301 } 335 302 336 inline 303 inline 337 G4int << 304 G4int G4ProductionCutsTable::GetCoupleIndex(const G4MaterialCutsCouple* aCouple) const 338 G4ProductionCutsTable::GetCoupleIndex(const G4 << 339 { 305 { 340 G4int idx = 0; 306 G4int idx = 0; 341 for(auto cItr=coupleTable.cbegin(); cItr!=co << 307 for(CoupleTableIterator cItr=coupleTable.begin();cItr!=coupleTable.end();cItr++) 342 { 308 { 343 if((*cItr)==aCouple) return idx; 309 if((*cItr)==aCouple) return idx; 344 ++idx; << 310 idx++; 345 } 311 } 346 return -1; 312 return -1; 347 } 313 } 348 314 349 inline 315 inline 350 G4int G4ProductionCutsTable::GetCoupleIndex(co << 316 G4int G4ProductionCutsTable:: GetCoupleIndex(const G4Material* aMat, 351 co << 317 const G4ProductionCuts* aCut) const 352 { 318 { 353 const G4MaterialCutsCouple* aCouple = GetMat 319 const G4MaterialCutsCouple* aCouple = GetMaterialCutsCouple(aMat,aCut); 354 return GetCoupleIndex(aCouple); 320 return GetCoupleIndex(aCouple); 355 } 321 } 356 322 357 inline 323 inline 358 G4int G4ProductionCutsTable::GetVerboseLevel() << 324 void G4ProductionCutsTable::SetVerboseLevel(G4int value) 359 { 325 { 360 return verboseLevel; << 326 verboseLevel = value; 361 } 327 } 362 328 363 inline << 329 inline 364 const G4MCCIndexConversionTable* << 330 G4int G4ProductionCutsTable::GetVerboseLevel() const 365 G4ProductionCutsTable::GetMCCIndexConversionTa << 366 { 331 { 367 return &mccConversionTable; << 332 return verboseLevel; 368 } 333 } 369 334 >> 335 370 #endif 336 #endif >> 337 >> 338 >> 339 >> 340 >> 341 >> 342 371 343