source: trunk/source/processes/cuts/include/G4ProductionCutsTable.hh @ 1007

Last change on this file since 1007 was 1007, checked in by garnier, 15 years ago

update to geant4.9.2

File size: 12.0 KB
Line 
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.9 2008/03/02 10:52:55 kurasige Exp $
28// GEANT4 tag $Name: geant4-09-02 $
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
55class G4RegionStore;
56class G4VRangeToEnergyConverter;
57class G4LogicalVolume;
58class G4VPhysicalVolume;
59class G4ProductionCuts;
60
61class 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
72class 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
99    void DumpCouples() const;
100    // Display a list of registored couples
101
102    const G4MCCIndexConversionTable* GetMCCIndexConversionTable() const;
103    // gives the pointer to the MCCIndexConversionTable
104
105  private:
106
107   static G4ProductionCutsTable* fG4ProductionCutsTable;
108
109   typedef std::vector<G4MaterialCutsCouple*> G4CoupleTable;
110   typedef std::vector<G4MaterialCutsCouple*>::const_iterator CoupleTableIterator;
111   typedef std::vector<G4double> G4CutVectorForAParticle;
112   typedef std::vector<G4CutVectorForAParticle*> G4CutTable;
113   G4CoupleTable coupleTable;
114   G4CutTable rangeCutTable;
115   G4CutTable energyCutTable;
116
117   G4RegionStore* fG4RegionStore;
118   G4VRangeToEnergyConverter* converters[NumberOfG4CutIndex]; 
119
120   G4ProductionCuts* defaultProductionCuts;
121
122   G4MCCIndexConversionTable mccConversionTable;
123
124// These two vectors are for the backward comparibility
125   G4double* rangeDoubleVector[NumberOfG4CutIndex];
126   G4double* energyDoubleVector[NumberOfG4CutIndex];
127
128  public: 
129   const std::vector<G4double>* GetRangeCutsVector(size_t pcIdx) const;
130   const std::vector<G4double>* GetEnergyCutsVector(size_t pcIdx) const;
131
132// These two vectors are for the backward comparibility
133   G4double* GetRangeCutsDoubleVector(size_t pcIdx) const;
134   G4double* GetEnergyCutsDoubleVector(size_t pcIdx) const;
135 
136  public: // with description
137   size_t GetTableSize() const;
138     // This method returns the size of the couple table.
139
140   const G4MaterialCutsCouple* GetMaterialCutsCouple(G4int i) const;
141    // This method returns the pointer to the couple.
142
143   const G4MaterialCutsCouple*
144     GetMaterialCutsCouple(const G4Material* aMat,
145                           const G4ProductionCuts* aCut) const;
146    // This method returns the pointer to the couple.
147
148   G4int GetCoupleIndex(const G4MaterialCutsCouple* aCouple) const;
149   G4int GetCoupleIndex(const G4Material* aMat,
150                           const G4ProductionCuts* aCut) const;
151    // These methods return the index of the couple.
152    // -1 is returned if index is not found.
153
154   G4bool IsModified() const;
155    // This method returns TRUE if at least one production cut value is modified.
156 
157   void PhysicsTableUpdated();
158    // This method resets the status of IsModified(). This method must
159    // be exclusively used by RunManager when physics tables are built.
160
161   G4ProductionCuts* GetDefaultProductionCuts() const;
162    // This method returns the default production cuts.
163 
164   G4double ConvertRangeToEnergy(const G4ParticleDefinition* particle,
165                                 const G4Material*           material, 
166                                 G4double                    range    );
167    // This method gives energy corresponding to range value 
168    //
169    // -1 is returned if particle or material is not found.
170   
171  private:
172    void ScanAndSetCouple(G4LogicalVolume* aLV,
173                          G4MaterialCutsCouple* aCouple,
174                          G4Region* aRegion);
175
176    bool IsCoupleUsedInTheRegion(const G4MaterialCutsCouple* aCouple,
177                                 const G4Region* aRegion) const;
178
179  public: // with description
180   // Store cuts and material information in files under the specified directory.
181  G4bool  StoreCutsTable(const G4String& directory, 
182                         G4bool          ascii = false);
183 
184  // Retrieve material cut couple information
185  //  in files under the specified directory.
186  G4bool  RetrieveCutsTable(const G4String& directory,
187                            G4bool          ascii = false);
188 
189  // check stored material and cut values are consistent with the current detector setup.
190  G4bool CheckForRetrieveCutsTable(const G4String& directory, 
191                                   G4bool          ascii = false);
192
193  protected:
194
195  // Store material information in files under the specified directory.
196  virtual G4bool  StoreMaterialInfo(const G4String& directory, 
197                                    G4bool          ascii = false);
198
199  // check stored material is consistent with the current detector setup.
200  virtual G4bool  CheckMaterialInfo(const G4String& directory, 
201                                    G4bool          ascii = false);
202 
203  // Store materialCutsCouple information in files under the specified directory.
204  virtual G4bool  StoreMaterialCutsCoupleInfo(const G4String& directory, 
205                                    G4bool          ascii = false);
206
207  // check stored materialCutsCouple is consistent with the current detector setup.
208  virtual G4bool  CheckMaterialCutsCoupleInfo(const G4String& directory, 
209                                    G4bool          ascii = false);
210
211  // Store cut values information in files under the specified directory.
212  virtual G4bool  StoreCutsInfo(const G4String& directory, 
213                                G4bool          ascii = false);
214 
215 // Retrieve cut values information in files under the specified directory.
216  virtual G4bool  RetrieveCutsInfo(const G4String& directory,
217                                   G4bool          ascii = false);
218
219  private:
220   G4bool firstUse;
221   enum { FixedStringLengthForStore = 32 }; 
222
223  public: // with description 
224      void  SetVerboseLevel(G4int value);
225      G4int GetVerboseLevel() const;
226      // controle flag for output message
227      //  0: Silent
228      //  1: Warning message
229      //  2: More
230
231  private:
232    G4int verboseLevel;
233    G4ProductionCutsTableMessenger* fMessenger;
234
235};
236
237inline 
238 const std::vector<G4double>* G4ProductionCutsTable::GetRangeCutsVector(size_t pcIdx) const
239{ 
240  return rangeCutTable[pcIdx]; 
241}
242
243inline 
244 const std::vector<G4double>* G4ProductionCutsTable::GetEnergyCutsVector(size_t pcIdx) const
245{
246 return energyCutTable[pcIdx]; 
247}
248
249inline 
250 size_t G4ProductionCutsTable::GetTableSize() const
251{
252  return coupleTable.size(); 
253}
254
255inline 
256 const G4MaterialCutsCouple* G4ProductionCutsTable::GetMaterialCutsCouple(G4int i) const
257{ 
258  return coupleTable[size_t(i)]; 
259}
260
261inline 
262 G4bool G4ProductionCutsTable::IsModified() const
263{ 
264  if(firstUse) return true;
265  for(G4ProductionCutsTable::CoupleTableIterator itr=coupleTable.begin();
266    itr!=coupleTable.end();itr++){ 
267    if((*itr)->IsRecalcNeeded())
268    {
269      return true; 
270    }
271  }
272  return false;
273}
274 
275inline 
276 void G4ProductionCutsTable::PhysicsTableUpdated()
277{ 
278  for(G4ProductionCutsTable::CoupleTableIterator itr=coupleTable.begin();itr!=coupleTable.end();itr++){ 
279    (*itr)->PhysicsTableUpdated(); 
280  }
281}
282
283inline
284 G4double* G4ProductionCutsTable::GetRangeCutsDoubleVector(size_t pcIdx) const
285{ return rangeDoubleVector[pcIdx]; }
286
287inline
288 G4double* G4ProductionCutsTable::GetEnergyCutsDoubleVector(size_t pcIdx) const
289{ return energyDoubleVector[pcIdx]; }
290
291inline
292 G4ProductionCuts* G4ProductionCutsTable::GetDefaultProductionCuts() const
293{ return defaultProductionCuts; }
294
295inline
296bool G4ProductionCutsTable::IsCoupleUsedInTheRegion(
297                                 const G4MaterialCutsCouple* aCouple,
298                                 const G4Region* aRegion) const
299{
300  G4ProductionCuts* fProductionCut = aRegion->GetProductionCuts();
301  std::vector<G4Material*>::const_iterator mItr = aRegion->GetMaterialIterator();
302  size_t nMaterial = aRegion->GetNumberOfMaterials();
303  for(size_t iMate=0;iMate<nMaterial;iMate++, mItr++){
304    if(aCouple->GetMaterial()==(*mItr) &&
305       aCouple->GetProductionCuts()==fProductionCut){
306      return true;
307    }
308  }
309  return false;
310}
311
312inline
313const G4MaterialCutsCouple* 
314     G4ProductionCutsTable::GetMaterialCutsCouple(const G4Material* aMat,
315                           const G4ProductionCuts* aCut) const
316{ 
317  for(CoupleTableIterator cItr=coupleTable.begin();cItr!=coupleTable.end();cItr++)
318  { 
319    if((*cItr)->GetMaterial()!=aMat) continue;
320    if((*cItr)->GetProductionCuts()==aCut) return (*cItr);
321  }
322  return 0;
323}
324
325inline
326G4int G4ProductionCutsTable::GetCoupleIndex(const G4MaterialCutsCouple* aCouple) const
327{ 
328  G4int idx = 0;
329  for(CoupleTableIterator cItr=coupleTable.begin();cItr!=coupleTable.end();cItr++)
330  {
331    if((*cItr)==aCouple) return idx;
332    idx++;
333  }
334  return -1;
335}
336
337inline
338G4int G4ProductionCutsTable:: GetCoupleIndex(const G4Material* aMat,
339                           const G4ProductionCuts* aCut) const
340{
341  const G4MaterialCutsCouple* aCouple = GetMaterialCutsCouple(aMat,aCut);
342  return GetCoupleIndex(aCouple);
343}
344
345inline 
346 G4int G4ProductionCutsTable::GetVerboseLevel() const
347{
348   return verboseLevel;
349}
350
351inline
352 const G4MCCIndexConversionTable* 
353   G4ProductionCutsTable::GetMCCIndexConversionTable() const
354{
355  return &mccConversionTable;
356}
357
358#endif
359
360
361
362
363
364
Note: See TracBrowser for help on using the repository browser.