Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ProductionCutsTable.hh
Go to the documentation of this file.
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$
28//
29//
30// ------------------------------------------------------------
31// GEANT 4 class header file
32//
33// Class Description
34// G4ProductionCutsTable is a static singleton class of a table of
35// G4ProductionCuts objects. This class also manages tables of
36// production cut and energy cut for each particle type.
37//
38// ------------------------------------------------------------
39// First Implementation 05 Oct. 2002 M.Asai
40//
41// Modified 03 Feb 2004 H.Kurashige
42// Modify RetrieveCutsTable to allow ordering of materials and
43// couples can be different from one in file (i.e. at storing)
44// Modified 20 Aug. 2004 H.Kurashige
45// Modify RetrieveCutsTable to allow materials and
46// couples can be different from one in file (i.e. at storing)
47// Modified 2 Mar. 2008 H.Kurashige
48// add messenger
49// ------------------------------------------------------------
50
51#ifndef G4ProductionCutsTable_h
52#define G4ProductionCutsTable_h 1
53
54class G4RegionStore;
56class G4LogicalVolume;
59
61
62#include "globals.hh"
63#include <cmath>
64#include "G4ios.hh"
65#include <vector>
68#include "G4Region.hh"
69
70
72{
73 public: // with description
75 // This static method returns the singleton pointer of this class object.
76 // At the first invokation of this method, the singleton object is instantiated.
77
78 protected:
80 private:
82
83 public:
84 virtual ~G4ProductionCutsTable();
85
86 public: // with description
87 void UpdateCoupleTable(G4VPhysicalVolume* currentWorld);
88 // This method triggers an update of the table of G4ProductionCuts objects.
89
90 void SetEnergyRange(G4double lowedge, G4double highedge);
91 // This method sets the limits of energy cuts for all particles.
92
95 // These methods get the limits of energy cuts for all particles.
96
97 // get/set max cut energy of RangeToEnergy Converter for all particle type
99 void SetMaxEnergyCut(G4double value);
100
101
102 void DumpCouples() const;
103 // Display a list of registored couples
104
106 // gives the pointer to the MCCIndexConversionTable
107
108 private:
109
110 static G4ProductionCutsTable* fG4ProductionCutsTable;
111
112 typedef std::vector<G4MaterialCutsCouple*> G4CoupleTable;
113 typedef std::vector<G4MaterialCutsCouple*>::const_iterator CoupleTableIterator;
114 typedef std::vector<G4double> G4CutVectorForAParticle;
115 typedef std::vector<G4CutVectorForAParticle*> G4CutTable;
116 G4CoupleTable coupleTable;
117 G4CutTable rangeCutTable;
118 G4CutTable energyCutTable;
119
120 G4RegionStore* fG4RegionStore;
122
123 G4ProductionCuts* defaultProductionCuts;
124
125 G4MCCIndexConversionTable mccConversionTable;
126
127// These two vectors are for the backward comparibility
128 G4double* rangeDoubleVector[NumberOfG4CutIndex];
129 G4double* energyDoubleVector[NumberOfG4CutIndex];
130
131 public:
132 const std::vector<G4double>* GetRangeCutsVector(size_t pcIdx) const;
133 const std::vector<G4double>* GetEnergyCutsVector(size_t pcIdx) const;
134
135// These two vectors are for the backward comparibility
136 G4double* GetRangeCutsDoubleVector(size_t pcIdx) const;
137 G4double* GetEnergyCutsDoubleVector(size_t pcIdx) const;
138
139 public: // with description
140 size_t GetTableSize() const;
141 // This method returns the size of the couple table.
142
144 // This method returns the pointer to the couple.
145
148 const G4ProductionCuts* aCut) const;
149 // This method returns the pointer to the couple.
150
151 G4int GetCoupleIndex(const G4MaterialCutsCouple* aCouple) const;
152 G4int GetCoupleIndex(const G4Material* aMat,
153 const G4ProductionCuts* aCut) const;
154 // These methods return the index of the couple.
155 // -1 is returned if index is not found.
156
157 G4bool IsModified() const;
158 // This method returns TRUE if at least one production cut value is modified.
159
160 void PhysicsTableUpdated();
161 // This method resets the status of IsModified(). This method must
162 // be exclusively used by RunManager when physics tables are built.
163
165 // This method returns the default production cuts.
166
168 const G4Material* material,
169 G4double range );
170 // This method gives energy corresponding to range value
171 //
172 // -1 is returned if particle or material is not found.
173
174 void ResetConverters();
175 // reset all Range To Energy Converters
176
177 private:
178 void ScanAndSetCouple(G4LogicalVolume* aLV,
179 G4MaterialCutsCouple* aCouple,
180 G4Region* aRegion);
181
182 bool IsCoupleUsedInTheRegion(const G4MaterialCutsCouple* aCouple,
183 const G4Region* aRegion) const;
184
185 public: // with description
186 // Store cuts and material information in files under the specified directory.
187 G4bool StoreCutsTable(const G4String& directory,
188 G4bool ascii = false);
189
190 // Retrieve material cut couple information
191 // in files under the specified directory.
192 G4bool RetrieveCutsTable(const G4String& directory,
193 G4bool ascii = false);
194
195 // check stored material and cut values are consistent with the current detector setup.
196 G4bool CheckForRetrieveCutsTable(const G4String& directory,
197 G4bool ascii = false);
198
199 protected:
200
201 // Store material information in files under the specified directory.
202 virtual G4bool StoreMaterialInfo(const G4String& directory,
203 G4bool ascii = false);
204
205 // check stored material is consistent with the current detector setup.
206 virtual G4bool CheckMaterialInfo(const G4String& directory,
207 G4bool ascii = false);
208
209 // Store materialCutsCouple information in files under the specified directory.
210 virtual G4bool StoreMaterialCutsCoupleInfo(const G4String& directory,
211 G4bool ascii = false);
212
213 // check stored materialCutsCouple is consistent with the current detector setup.
214 virtual G4bool CheckMaterialCutsCoupleInfo(const G4String& directory,
215 G4bool ascii = false);
216
217 // Store cut values information in files under the specified directory.
218 virtual G4bool StoreCutsInfo(const G4String& directory,
219 G4bool ascii = false);
220
221 // Retrieve cut values information in files under the specified directory.
222 virtual G4bool RetrieveCutsInfo(const G4String& directory,
223 G4bool ascii = false);
224
225 private:
226 G4bool firstUse;
227 enum { FixedStringLengthForStore = 32 };
228
229 public: // with description
230 void SetVerboseLevel(G4int value);
231 G4int GetVerboseLevel() const;
232 // controle flag for output message
233 // 0: Silent
234 // 1: Warning message
235 // 2: More
236
237 private:
238 G4int verboseLevel;
240
241};
242
243inline
244 const std::vector<G4double>* G4ProductionCutsTable::GetRangeCutsVector(size_t pcIdx) const
245{
246 return rangeCutTable[pcIdx];
247}
248
249inline
250 const std::vector<G4double>* G4ProductionCutsTable::GetEnergyCutsVector(size_t pcIdx) const
251{
252 return energyCutTable[pcIdx];
253}
254
255inline
257{
258 return coupleTable.size();
259}
260
261inline
263{
264 return coupleTable[size_t(i)];
265}
266
267inline
269{
270 if(firstUse) return true;
271 for(G4ProductionCutsTable::CoupleTableIterator itr=coupleTable.begin();
272 itr!=coupleTable.end();itr++){
273 if((*itr)->IsRecalcNeeded())
274 {
275 return true;
276 }
277 }
278 return false;
279}
280
281inline
283{
284 for(G4ProductionCutsTable::CoupleTableIterator itr=coupleTable.begin();itr!=coupleTable.end();itr++){
285 (*itr)->PhysicsTableUpdated();
286 }
287}
288
289inline
291{ return rangeDoubleVector[pcIdx]; }
292
293inline
295{ return energyDoubleVector[pcIdx]; }
296
297inline
299{ return defaultProductionCuts; }
300
301inline
302bool G4ProductionCutsTable::IsCoupleUsedInTheRegion(
303 const G4MaterialCutsCouple* aCouple,
304 const G4Region* aRegion) const
305{
306 G4ProductionCuts* fProductionCut = aRegion->GetProductionCuts();
307 std::vector<G4Material*>::const_iterator mItr = aRegion->GetMaterialIterator();
308 size_t nMaterial = aRegion->GetNumberOfMaterials();
309 for(size_t iMate=0;iMate<nMaterial;iMate++, mItr++){
310 if(aCouple->GetMaterial()==(*mItr) &&
311 aCouple->GetProductionCuts()==fProductionCut){
312 return true;
313 }
314 }
315 return false;
316}
317
318inline
321 const G4ProductionCuts* aCut) const
322{
323 for(CoupleTableIterator cItr=coupleTable.begin();cItr!=coupleTable.end();cItr++)
324 {
325 if((*cItr)->GetMaterial()!=aMat) continue;
326 if((*cItr)->GetProductionCuts()==aCut) return (*cItr);
327 }
328 return 0;
329}
330
331inline
333{
334 G4int idx = 0;
335 for(CoupleTableIterator cItr=coupleTable.begin();cItr!=coupleTable.end();cItr++)
336 {
337 if((*cItr)==aCouple) return idx;
338 idx++;
339 }
340 return -1;
341}
342
343inline
345 const G4ProductionCuts* aCut) const
346{
347 const G4MaterialCutsCouple* aCouple = GetMaterialCutsCouple(aMat,aCut);
348 return GetCoupleIndex(aCouple);
349}
350
351inline
353{
354 return verboseLevel;
355}
356
357inline
360{
361 return &mccConversionTable;
362}
363
364#endif
365
366
367
368
369
370
@ NumberOfG4CutIndex
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
bool G4bool
Definition: G4Types.hh:67
const G4Material * GetMaterial() const
G4ProductionCuts * GetProductionCuts() const
virtual G4bool RetrieveCutsInfo(const G4String &directory, G4bool ascii=false)
G4bool RetrieveCutsTable(const G4String &directory, G4bool ascii=false)
virtual G4bool StoreCutsInfo(const G4String &directory, G4bool ascii=false)
const std::vector< G4double > * GetRangeCutsVector(size_t pcIdx) const
G4double GetLowEdgeEnergy() const
const G4MaterialCutsCouple * GetMaterialCutsCouple(G4int i) const
G4double * GetEnergyCutsDoubleVector(size_t pcIdx) const
void SetMaxEnergyCut(G4double value)
void UpdateCoupleTable(G4VPhysicalVolume *currentWorld)
void SetVerboseLevel(G4int value)
virtual G4bool CheckMaterialInfo(const G4String &directory, G4bool ascii=false)
virtual G4bool StoreMaterialInfo(const G4String &directory, G4bool ascii=false)
G4double GetHighEdgeEnergy() const
const std::vector< G4double > * GetEnergyCutsVector(size_t pcIdx) const
G4bool StoreCutsTable(const G4String &directory, G4bool ascii=false)
const G4MCCIndexConversionTable * GetMCCIndexConversionTable() const
G4double * GetRangeCutsDoubleVector(size_t pcIdx) const
G4bool CheckForRetrieveCutsTable(const G4String &directory, G4bool ascii=false)
void SetEnergyRange(G4double lowedge, G4double highedge)
static G4ProductionCutsTable * GetProductionCutsTable()
G4int GetCoupleIndex(const G4MaterialCutsCouple *aCouple) const
virtual G4bool CheckMaterialCutsCoupleInfo(const G4String &directory, G4bool ascii=false)
G4ProductionCuts * GetDefaultProductionCuts() const
G4double ConvertRangeToEnergy(const G4ParticleDefinition *particle, const G4Material *material, G4double range)
virtual G4bool StoreMaterialCutsCoupleInfo(const G4String &directory, G4bool ascii=false)
G4ProductionCuts * GetProductionCuts() const
size_t GetNumberOfMaterials() const
std::vector< G4Material * >::const_iterator GetMaterialIterator() const