Geant4  10.03
XVCrystalPlanarAnalytical.cc
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 //
28 //
29 
31 #include "G4PhysicsLinearVector.hh"
32 
34  fNumberOfPlanes = 4;
35 }
36 
37 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
38 
40 }
41 
42 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
43 
45  fNumberOfPlanes = vNumberOfPlanes;
46 }
47 
48 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
49 
51  return fNumberOfPlanes;
52 }
53 
54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
55 
57 ComputeEC(G4ThreeVector vPositionVector,
58  XPhysicalLattice* vLattice){
59  G4VPhysicalVolume* vVolume = vLattice->GetVolume();
60 
61  G4double vInterplanarDistance =
63 
64  G4double vPosition = ComputePositionInUnitCell(vPositionVector,
65  vLattice).x();
66 
67  G4double vValue = 0.;
68  for(int i=-int(GetNumberOfPlanes()/2);i<=+int(GetNumberOfPlanes()/2);i++){
69  vValue += ComputeECForSinglePlane( ( vPosition + G4double(i) ) *
70  vInterplanarDistance ,
71  vLattice );
72  }
73 
74  return G4ThreeVector(vValue,0.,0.);
75 }
76 
77 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
78 
81  G4double vInterplanarPeriod = fPhysicalLattice->ComputeInterplanarPeriod();
82  G4double vX = vPosition.x();
83  if (vX < 0.0) {
84  vX += ((int( - vX / vInterplanarPeriod) + 1.0 )
85  * vInterplanarPeriod);
86  }
87  else if( vX > vInterplanarPeriod ){
88  vX -= ( int( vX / vInterplanarPeriod) * vInterplanarPeriod );
89  }
90  return G4ThreeVector(fVectorEC->Value(vX),0.,0.);
91 }
92 
93 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
94 
97  XPhysicalLattice* vLattice){
98  G4VPhysicalVolume* vVolume = vLattice->GetVolume();
99 
100  G4double vInterplanarPeriod =
102 
103  G4double vPositionX = vPosition.x();
104 
105  if((vPositionX >= 0.) &&
106  (vPositionX < vInterplanarPeriod)){
107  return G4ThreeVector(vPositionX/vInterplanarPeriod,0.,0.);
108  }
109  else if(vPositionX == vInterplanarPeriod){
110  return G4ThreeVector(0.,0.,0.);
111  }
112  else{
113  vPositionX -= std::fmod(vPosition.x(),vInterplanarPeriod)
114  * vInterplanarPeriod;
115  return G4ThreeVector(vPositionX/vInterplanarPeriod,0.,0.);
116  }
117 }
118 
119 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
120 
122  unsigned int vPrecision = 1024;
123  G4VPhysicalVolume* vVolume = vLattice->GetVolume();
125  / vPrecision;
126 
127  G4double vMaximum = -DBL_MAX;
128  G4double vValue;
129 
130  for(unsigned int i=0;i<vPrecision;i++){
131  if( (vValue = GetEC(G4ThreeVector(vStep * i,0.,0.),vLattice).x() )
132  > vMaximum) {vMaximum = vValue;}
133  }
134  return vMaximum;
135 }
136 
137 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
138 
140  unsigned int vPrecision = 1024;
141  G4VPhysicalVolume* vVolume = vLattice->GetVolume();
143  / vPrecision;
144 
145  G4double vMinimum = +DBL_MAX;
146  G4double vValue;
147 
148  for(unsigned int i=0;i<vPrecision;i++){
149  if( (vValue = GetEC(G4ThreeVector(vStep * i,0.,0.),vLattice).x() )
150  < vMinimum) {vMinimum = vValue;}
151  }
152  return vMinimum;
153 }
154 
155 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
156 
158  XPhysicalLattice* vLattice,
159  G4double vUnit){
160  std::ofstream vFileOut;
161  vFileOut.open(filename);
162  vFileOut << "pos val" << std::endl;
163 
164  G4int imax = 8192;
165  G4double vXposition = 0.;
166  G4double vInterplanarPeriod = vLattice->ComputeInterplanarPeriod();
167 
168  for(G4int i = 0;i<imax;i++){
169  vXposition = double(i) / double(imax) * vInterplanarPeriod;
170  vFileOut << vXposition / CLHEP::angstrom << " ";
171  vFileOut << GetEC(G4ThreeVector(vXposition,0.,0.),vLattice).x() / vUnit;
172  vFileOut << std::endl;
173  }
174 
175  vFileOut.close();
176 }
177 
178 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
179 
182  std::ifstream vFileIn;
183  vFileIn.open(filename);
184  std::string vTempString;
185  vFileIn >> vTempString >> vTempString;
186 
187  double vTempX;
188  double vTempVal;
189  std::vector<double> vTempXvector;
190  std::vector<double> vTempValvector;
191 
192  while(!vFileIn.eof()){
193  vFileIn >> vTempX;
194  vFileIn >> vTempVal;
195  vTempXvector.push_back(vTempX);
196  vTempValvector.push_back(vTempVal);
197  }
198 
199  vFileIn.close();
200 
201  G4int imax = vTempXvector.size();
202  G4double vInterplanarPeriod = vTempXvector.at(imax-1);
203 
205  vInterplanarPeriod*(imax-1)/imax,
206  imax);
207  for(G4int i = 0;i<imax;i++){
208  fVectorEC->PutValue(i,vTempValvector.at(i));
209  }
210 }
211 
212 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
213 
215  G4double vConversion){
216  std::ifstream vFileIn;
217  vFileIn.open(filename);
218 
219  G4int imax;
220  G4double xmax;
221 
222  vFileIn >> imax;
223  vFileIn >> xmax;
224 
225  xmax *= CLHEP::meter;
226  fMaximum = -DBL_MAX;
227  fMinimum = +DBL_MAX;
228 
229  fVectorEC = new G4PhysicsLinearVector(0,xmax,imax);
230 
231  for(G4int i=0;i<imax; i++){
232  double vTempX;
233  vFileIn >> vTempX;
234 
235  vTempX *= vConversion;
236  if(vTempX > fMaximum) {fMaximum = vTempX;}
237  if(vTempX < fMinimum) {fMinimum = vTempX;}
238  fVectorEC->PutValue(i,vTempX);
239  }
240 
241  G4cout << "XVCrystalPlanarAnalytical::ReadFromECHARM() - " <<
242  vConversion << " " << imax << " " << xmax << " " <<
243  fMinimum << " " << fMaximum << G4endl;
244 
245  vFileIn.close();
246 
247 }
248 
249 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
250 
252  G4int imax = 4096;
253  G4double vXposition = 0.;
254  G4double vInterplanarPeriod = fPhysicalLattice->ComputeInterplanarPeriod();
255 
257  vInterplanarPeriod*(imax-1)/imax,
258  imax);
259  for(G4int i = 0;i<imax;i++){
260  vXposition = double(i) / double(imax) * vInterplanarPeriod;
261  fVectorEC->PutValue(i,ComputeEC(G4ThreeVector(vXposition,0.,0.),
262  fPhysicalLattice).x());
263  }
264 }
265 
266 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
Definition of the XVCrystalPlanarAnalytical class.
virtual G4double ComputeECForSinglePlane(G4double, XPhysicalLattice *)=0
CLHEP::Hep3Vector G4ThreeVector
virtual void ReadFromFile(const G4String &, XPhysicalLattice *, G4double=1)
XPhysicalLattice * GetXPhysicalLattice(G4VPhysicalVolume *)
int G4int
Definition: G4Types.hh:78
static constexpr double meter
Definition: G4SIunits.hh:82
virtual G4double ComputeMaximum(XPhysicalLattice *)
G4GLOB_DLL std::ostream G4cout
XPhysicalLattice * fPhysicalLattice
G4ThreeVector ComputeECFromVector(G4ThreeVector)
void PutValue(size_t index, G4double theValue)
G4double Value(G4double theEnergy, size_t &lastidx) const
G4ThreeVector ComputePositionInUnitCell(G4ThreeVector, XPhysicalLattice *)
virtual void PrintOnFile(const G4String &, XPhysicalLattice *, G4double)
G4ThreeVector ComputeEC(G4ThreeVector, XPhysicalLattice *)
G4ThreeVector GetEC(G4ThreeVector, XPhysicalLattice *)
virtual G4double ComputeMinimum(XPhysicalLattice *)
#define G4endl
Definition: G4ios.hh:61
static constexpr double angstrom
Definition: G4SIunits.hh:102
static const G4int imax
double G4double
Definition: G4Types.hh:76
virtual void ReadFromECHARM(const G4String &, G4double=1)
#define DBL_MAX
Definition: templates.hh:83
G4double ComputeInterplanarPeriod()
G4VPhysicalVolume * GetVolume()