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

Last change on this file since 912 was 819, checked in by garnier, 17 years ago

import all except CVS

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