Geant4  10.03
G4InterpolationManager.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 //
28 #ifndef G4InterpolationManager_h
29 #define G4InterpolationManager_h 1
30 
31 #include "globals.hh"
32 #include "G4InterpolationScheme.hh"
33 #include "G4ios.hh"
34 #include <fstream>
35 #include "G4HadronicException.hh"
36 
38 {
39  public:
40 
42 
44  {
45  nRanges = 1;
46  start = new G4int[1];
47  start[0] = 0;
48  range = new G4int[1];
49  range [0] = 100000;
51  scheme[0] = LINLIN;
52  nEntries = 0;
53  }
54 
56  {
57  if(start!=0) delete [] start;
58  if(range!=0) delete [] range;
59  if(scheme!=0) delete [] scheme;
60  }
61 
63  {
64  if(this != &aManager)
65  {
66  nRanges = aManager.nRanges;
67  nEntries = aManager.nEntries;
68  if(scheme!=0) delete [] scheme;
69  if(start!=0) delete [] start;
70  if(range!=0) delete [] range;
72  start = new G4int[nRanges];
73  range = new G4int[nRanges];
74  for(G4int i=0; i<nRanges; i++)
75  {
76  scheme[i]=aManager.scheme[i];
77  start[i]=aManager.start[i];
78  range[i]=aManager.range[i];
79  }
80  }
81  return *this;
82  }
83 
84  inline void Init(G4int aScheme, G4int aRange)
85  {
86  nRanges = 1;
87  start[0] = 0;
88  range [0] = aRange;
89  scheme[0] = MakeScheme(aScheme);
90  nEntries = aRange;
91  }
92  inline void Init(G4InterpolationScheme aScheme, G4int aRange)
93  {
94  nRanges = 1;
95  start[0] = 0;
96  range [0] = aRange;
97  scheme[0] = aScheme;
98  nEntries = aRange;
99  }
100 
101  inline void Init(std::istream & aDataFile)
102  {
103  delete [] start;
104  delete [] range;
105  delete [] scheme;
106  aDataFile >> nRanges;
107  start = new G4int[nRanges];
108  range = new G4int[nRanges];
110  start[0] = 0;
111  G4int it;
112  for(G4int i=0; i<nRanges; i++)
113  {
114  aDataFile>>range[i];
115  //***************************************************************
116  //EMendoza -> there is a bug here.
117  /*
118  if(i!=0) start[i] = start[i-1]+range[i-1];
119  */
120  //***************************************************************
121  if(i!=0) start[i] = range[i-1];
122  //***************************************************************
123  aDataFile>>it;
124  scheme[i] = MakeScheme(it);
125  }
126  nEntries = start[nRanges-1]+range[nRanges-1];
127  }
128 
130 
132  {
133  G4int it = 0;
134  for(G4int i=1; i<nRanges; i++)
135  {
136  if(index<start[i]) break;
137  it = i;
138  }
139  return scheme[it];
140  }
141 
142  inline void CleanUp()
143  {
144  nRanges = 0;
145  nEntries = 0;
146  }
147 
149  {
150  G4InterpolationScheme result = GetScheme(index);
151  if(result == HISTO)
152  {
153  result = RANDOM;
154  }
155  else if(result == LINLOG)
156  {
157  result = LOGLIN;
158  }
159  else if(result == LOGLIN)
160  {
161  result = LINLOG;
162  }
163  else if(result == CHISTO)
164  {
165  result = CRANDOM;
166  }
167  else if(result == CLINLOG)
168  {
169  result = CLOGLIN;
170  }
171  else if(result == CLOGLIN)
172  {
173  result = CLINLOG;
174  }
175  else if(result == UHISTO)
176  {
177  result = URANDOM;
178  }
179  else if(result == ULINLOG)
180  {
181  result = ULOGLIN;
182  }
183  else if(result == ULOGLIN)
184  {
185  result = ULINLOG;
186  }
187  return result;
188  }
189 
190  void AppendScheme(G4int aPoint, const G4InterpolationScheme & aScheme);
191 
192  private:
193 
199 
200 };
201 #endif
void Init(G4int aScheme, G4int aRange)
G4InterpolationManager & operator=(const G4InterpolationManager &aManager)
int G4int
Definition: G4Types.hh:78
void Init(G4InterpolationScheme aScheme, G4int aRange)
void AppendScheme(G4int aPoint, const G4InterpolationScheme &aScheme)
G4InterpolationScheme GetScheme(G4int index) const
G4InterpolationScheme
G4InterpolationScheme MakeScheme(G4int it)
void Init(std::istream &aDataFile)
G4InterpolationScheme GetInverseScheme(G4int index)
G4InterpolationScheme * scheme