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