G4ProductionCutsTable.hh

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 // 
00030 // ------------------------------------------------------------
00031 //      GEANT 4 class header file 
00032 //
00033 // Class Description
00034 //  G4ProductionCutsTable is a static singleton class of a table of
00035 //  G4ProductionCuts objects. This class also manages tables of
00036 //  production cut and energy cut for each particle type.
00037 //
00038 // ------------------------------------------------------------
00039 //   First Implementation          05 Oct. 2002  M.Asai    
00040 //
00041 //   Modified                      03 Feb 2004 H.Kurashige
00042 //    Modify RetrieveCutsTable to allow ordering of materials and 
00043 //    couples can be different from one in file (i.e. at storing)
00044 //   Modified                      20 Aug. 2004 H.Kurashige
00045 //    Modify RetrieveCutsTable to allow materials and 
00046 //    couples can be different from one in file (i.e. at storing)
00047 //   Modified                      2 Mar. 2008 H.Kurashige
00048 //    add messenger
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: // with description
00074     static G4ProductionCutsTable* GetProductionCutsTable();
00075     // This static method returns the singleton pointer of this class object.
00076     // At the first invokation of this method, the singleton object is instantiated.
00077 
00078   protected:
00079     G4ProductionCutsTable();
00080   private:
00081     G4ProductionCutsTable(const G4ProductionCutsTable& right);
00082 
00083   public:
00084     virtual ~G4ProductionCutsTable();
00085 
00086   public: // with description
00087     void UpdateCoupleTable(G4VPhysicalVolume* currentWorld);
00088     // This method triggers an update of the table of G4ProductionCuts objects.
00089 
00090     void SetEnergyRange(G4double lowedge, G4double highedge);
00091     // This method sets the limits of energy cuts for all particles.
00092 
00093     G4double GetLowEdgeEnergy() const;
00094     G4double GetHighEdgeEnergy() const;
00095     // These methods get the limits of energy cuts for all particles.
00096 
00097     //  get/set max cut energy of RangeToEnergy Converter for all particle type
00098     G4double GetMaxEnergyCut();
00099     void SetMaxEnergyCut(G4double value);
00100 
00101 
00102     void DumpCouples() const;
00103     // Display a list of registored couples
00104 
00105     const G4MCCIndexConversionTable* GetMCCIndexConversionTable() const;
00106     // gives the pointer to the MCCIndexConversionTable
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 // These two vectors are for the backward comparibility
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 // These two vectors are for the backward comparibility
00136    G4double* GetRangeCutsDoubleVector(size_t pcIdx) const;
00137    G4double* GetEnergyCutsDoubleVector(size_t pcIdx) const;
00138   
00139   public: // with description
00140    size_t GetTableSize() const;
00141      // This method returns the size of the couple table.
00142 
00143    const G4MaterialCutsCouple* GetMaterialCutsCouple(G4int i) const;
00144     // This method returns the pointer to the couple.
00145 
00146    const G4MaterialCutsCouple*
00147      GetMaterialCutsCouple(const G4Material* aMat,
00148                            const G4ProductionCuts* aCut) const;
00149     // This method returns the pointer to the couple.
00150 
00151    G4int GetCoupleIndex(const G4MaterialCutsCouple* aCouple) const;
00152    G4int GetCoupleIndex(const G4Material* aMat,
00153                            const G4ProductionCuts* aCut) const;
00154     // These methods return the index of the couple.
00155     // -1 is returned if index is not found.
00156 
00157    G4bool IsModified() const;
00158     // This method returns TRUE if at least one production cut value is modified.
00159   
00160    void PhysicsTableUpdated();
00161     // This method resets the status of IsModified(). This method must
00162     // be exclusively used by RunManager when physics tables are built.
00163 
00164    G4ProductionCuts* GetDefaultProductionCuts() const;
00165     // This method returns the default production cuts.
00166  
00167    G4double ConvertRangeToEnergy(const G4ParticleDefinition* particle,
00168                                  const G4Material*           material, 
00169                                  G4double                    range    );
00170     // This method gives energy corresponding to range value  
00171     // 
00172     // -1 is returned if particle or material is not found.
00173 
00174   void ResetConverters();
00175     // reset all Range To Energy Converters  
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: // with description
00186    // Store cuts and material information in files under the specified directory.
00187   G4bool  StoreCutsTable(const G4String& directory, 
00188                          G4bool          ascii = false);
00189   
00190   // Retrieve material cut couple information 
00191   //  in files under the specified directory.
00192   G4bool  RetrieveCutsTable(const G4String& directory,
00193                             G4bool          ascii = false);
00194   
00195   // check stored material and cut values are consistent with the current detector setup. 
00196   G4bool CheckForRetrieveCutsTable(const G4String& directory, 
00197                                    G4bool          ascii = false);
00198 
00199   protected:
00200 
00201   // Store material information in files under the specified directory.
00202   virtual G4bool  StoreMaterialInfo(const G4String& directory, 
00203                                     G4bool          ascii = false);
00204 
00205   // check stored material is consistent with the current detector setup. 
00206   virtual G4bool  CheckMaterialInfo(const G4String& directory, 
00207                                     G4bool          ascii = false);
00208   
00209   // Store materialCutsCouple information in files under the specified directory.
00210   virtual G4bool  StoreMaterialCutsCoupleInfo(const G4String& directory, 
00211                                     G4bool          ascii = false);
00212 
00213   // check stored materialCutsCouple is consistent with the current detector setup. 
00214   virtual G4bool  CheckMaterialCutsCoupleInfo(const G4String& directory, 
00215                                     G4bool          ascii = false);
00216 
00217   // Store cut values information in files under the specified directory.
00218   virtual G4bool  StoreCutsInfo(const G4String& directory, 
00219                                 G4bool          ascii = false);
00220   
00221  // Retrieve cut values information in files under the specified directory.
00222   virtual G4bool  RetrieveCutsInfo(const G4String& directory,
00223                                    G4bool          ascii = false);
00224 
00225   private:
00226    G4bool firstUse;
00227    enum { FixedStringLengthForStore = 32 }; 
00228 
00229   public: // with description  
00230       void  SetVerboseLevel(G4int value);
00231       G4int GetVerboseLevel() const;
00232       // controle flag for output message
00233       //  0: Silent
00234       //  1: Warning message
00235       //  2: More
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 

Generated on Mon May 27 17:49:26 2013 for Geant4 by  doxygen 1.4.7