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