Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ChannelingFastSimCrystalData.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//
26
28#include "G4SystemOfUnits.hh"
30
35
36//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
37
39 const G4String &lattice)
40{
41 G4String filename=crystal->GetName(); //input file
42 filename.erase(0,3);
43
44 if (fVerbosity)
45 {
46 G4cout <<
47 "======================================================================="
48 << G4endl;
49 G4cout <<
50 "====== Crystal lattice data ========"
51 << G4endl;
52 G4cout <<
53 "======================================================================="
54 << G4endl;
55 G4cout << "Crystal material: " << filename << G4endl;
56 }
57
58 //choice between planes (1D model) and axes (2D model)
59 if (lattice.compare(0,1,"(")==0)
60 {
61 iModel=1; //planes
62 filename = filename + "_planes_"; //temporary name
63 if (fVerbosity)
64 G4cout << "Crystal planes: " << lattice << G4endl;
65 }
66 else if (lattice.compare(0,1,"<")==0)
67 {
68 iModel=2; //axes
69 filename = filename + "_axes_"; //temporary name
70 if (fVerbosity)
71 G4cout << "Crystal axes: " << lattice << G4endl;
72 }
73
74 //input file:
75 filename = filename + lattice.substr(1,(lattice.length())-2) + ".dat";
76
78 for(G4int i=0; i<fNelements; i++)
79 {
80 fZ1.push_back(crystal->GetElement(i)->GetZ());
81 fAN.push_back(crystal->GetElement(i)->GetAtomicMassAmu());
82 fI0.push_back(crystal->GetElement(i)->GetIonisation()->GetMeanExcitationEnergy());
83 }
84
85 G4double var;//just variable
86 G4double unitIF;//unit of interpolation function
87
88 std::ifstream vfilein;
89 vfilein.open(filename);
90
91 //read nuclear concentration
92 for(G4int i=0; i<fNelements; i++)
93 {
94 vfilein >> var;
95 fN0.push_back(var/cm3);
96 }
97
98 //read amplitude of thermal oscillations
99 for(G4int i=0; i<fNelements; i++)
100 {
101 vfilein >> var;
102 fU1.push_back(var*cm);
103 }
104
105 if (iModel==1)
106 {
107 // read channel dimensions
108 vfilein >> fDx;
109 fDx*=cm;
110 // read interpolation step size
111 vfilein >> fNpointsx;
112
113 fDy = fDx;
114 fNpointsy = 0;
115 }
116 else if (iModel==2)
117 {
118 // read channel dimensions
119 vfilein >> fDx >> fDy;
120 fDx*=cm;
121 fDy*=cm;
122 // read the number of nodes of interpolation
123 vfilein >> fNpointsx >> fNpointsy;
124 }
125
126 //read the height of the potential well, necessary only for step length calculation
127 vfilein >> fVmax;
128 fVmax*=eV;
129 fVmax2=2.*fVmax;
130
131 //read the on-zero minimal potential inside the crystal,
132 //necessary for angle recalculation for entrance/exit through
133 //the crystal lateral surface
134 vfilein >> fVMinCrystal;
135 fVMinCrystal*=eV;
136
137 // to create the class of interpolation for any function
139 new G4ChannelingFastSimInterpolation(fDx,fDy,fNpointsx,fNpointsy,iModel);
140 if(iModel==2) {fElectricFieldY =
141 new G4ChannelingFastSimInterpolation(fDx,fDy,fNpointsx,fNpointsy,iModel);}
143 new G4ChannelingFastSimInterpolation(fDx,fDy,fNpointsx,fNpointsy,iModel);
145 new G4ChannelingFastSimInterpolation(fDx,fDy,fNpointsx,fNpointsy,iModel);
146
147 // do it for any element of crystal material
148 for(G4int i=0; i<fNelements; i++)
149 {
150 fNucleiDensity.push_back(
151 new G4ChannelingFastSimInterpolation(fDx,fDy,fNpointsx,fNpointsy,iModel));
152 }
153
154 if (iModel==1)
155 {
156 G4double ai, bi, ci, di;
157 for(G4int i=0; i<fNpointsx; i++)
158 {
159 //reading the coefficients of cubic spline
160 vfilein >> ai >> bi >> ci >> di;
161 //setting spline coefficients for electric field
162 unitIF=eV/cm;
163 fElectricFieldX->SetCoefficients1D(ai*unitIF, bi*unitIF,
164 ci*unitIF, di*unitIF, i);
165
166 //reading the coefficients of cubic spline
167 vfilein >> ai >> bi >> ci >> di;
168 //setting spline coefficients for nuclear density (first element)
169 unitIF=1.;
170 fNucleiDensity[0]->SetCoefficients1D(ai*unitIF, bi*unitIF,
171 ci*unitIF, di*unitIF, i);
172
173 //reading the coefficients of cubic spline
174 vfilein >> ai >> bi >> ci >> di;
175 //setting spline coefficients for electron density
176 unitIF=1./cm3;
177 fElectronDensity->SetCoefficients1D(ai*unitIF, bi*unitIF,
178 ci*unitIF, di*unitIF, i);
179
180 //reading the coefficients of cubic spline
181 vfilein >> ai >> bi >> ci >> di;
182 //setting spline coefficients for minimal ionization energy
183 unitIF=eV;
184 fMinIonizationEnergy->SetCoefficients1D(ai*unitIF, bi*unitIF,
185 ci*unitIF, di*unitIF, i);
186
187 for(G4int ii=1; ii<fNelements; ii++)
188 {
189 //reading the coefficients of cubic spline
190 vfilein >> ai >> bi >> ci >> di;
191 //setting spline coefficients for nuclear density (other elements if any)
192 unitIF=1.;
193 fNucleiDensity[ii]->SetCoefficients1D(ai*unitIF, bi*unitIF,
194 ci*unitIF, di*unitIF, i);
195 }
196 }
197 }
198 else if (iModel==2)
199 {
200 G4double ai3D, bi3D, ci3D;
201 for(G4int j=0; j<fNpointsy; j++)
202 {
203 for(G4int i=0; i<fNpointsx+1; i++)
204 {
205 for(G4int k=0; k<2; k++)
206 {
207 //reading the coefficients of cubic spline
208 vfilein >> ai3D >> bi3D >> ci3D;
209 unitIF=eV;
210 //setting spline coefficients for minimal ionization energy
211 fMinIonizationEnergy->SetCoefficients2D(ai3D*unitIF, bi3D*unitIF, ci3D*unitIF,
212 i, j, k);
213
214 //reading the coefficients of cubic spline
215 vfilein >> ai3D >> bi3D >> ci3D;
216 //setting spline coefficients for horizontal electric field
217 unitIF=eV/cm;
218 fElectricFieldX->SetCoefficients2D(ai3D*unitIF, bi3D*unitIF, ci3D*unitIF,
219 i, j, k);
220
221 //reading the coefficients of cubic spline
222 vfilein >> ai3D >> bi3D >> ci3D;
223 //setting spline coefficients for vertical electric field
224 unitIF=eV/cm;
225 fElectricFieldY->SetCoefficients2D(ai3D*unitIF, bi3D*unitIF, ci3D*unitIF,
226 i, j, k);
227
228 //reading the coefficients of cubic spline
229 vfilein >> ai3D >> bi3D >> ci3D;
230 //setting spline coefficients for nuclear density (first element)
231 unitIF=1.;
232 fNucleiDensity[0]->SetCoefficients2D(ai3D*unitIF, bi3D*unitIF, ci3D*unitIF,
233 i, j, k);
234
235 //reading the coefficients of cubic spline
236 vfilein >> ai3D >> bi3D >> ci3D;
237 //setting spline coefficients for electron density
238 unitIF=1./cm3;
239 fElectronDensity->SetCoefficients2D(ai3D*unitIF, bi3D*unitIF, ci3D*unitIF,
240 i, j, k);
241
242 for(G4int ii=1; ii<fNelements; ii++)
243 {
244 //reading the coefficients of cubic spline
245 vfilein >> ai3D >> bi3D >> ci3D;
246 //setting spline coefficients for nuclear density (other elements if any)
247 unitIF=1.;
248 fNucleiDensity[ii]->SetCoefficients2D(ai3D*unitIF, bi3D*unitIF,
249 ci3D*unitIF,
250 i, j, k);
251 }
252
253 }
254 }
255 }
256 }
257
258 vfilein.close();
259
260 //set special values and coefficients
261 G4double alphahbarc2=std::pow(CLHEP::fine_structure_const*CLHEP::hbarc ,2.);
262 fK30=2.*CLHEP::pi*alphahbarc2/CLHEP::electron_mass_c2;
263
264 for(G4int i=0; i<fNelements; i++)
265 {
266 fRF.push_back((std::pow(9*CLHEP::pi*CLHEP::pi/128/fZ1[i],1/3.))
267 *0.5291772109217*angstrom);//Thomas-Fermi screening radius
268
269 fTetamax0.push_back(CLHEP::hbarc/(fR0*std::pow(fAN[i],1./3.)));
270 fTeta10.push_back(CLHEP::hbarc/fRF[i]);
271 fPu11.push_back(std::pow(fU1[i]/CLHEP::hbarc,2.));
272
273 fK20.push_back(alphahbarc2*4*CLHEP::pi*fN0[i]*fZ1[i]*fZ1[i]);
274
275 fK40.push_back(3.76*std::pow(CLHEP::fine_structure_const*fZ1[i],2.));
276
277 fKD.push_back(fK30*fZ1[i]*fN0[i]);
278 }
279
280 fBB.resize(fNelements);
281 fE1XBbb.resize(fNelements);
282 fBBDEXP.resize(fNelements);
283 fPzu11.resize(fNelements);
284 fTeta12.resize(fNelements);
285 fTetamax2.resize(fNelements);
286 fTetamax12.resize(fNelements);
287 fK2.resize(fNelements);
288
289 fChangeStep = CLHEP::pi*std::min(fDx,fDy)/fNsteps;//necessary to define simulation
290 //step = fChannelingStep =
291 // = fChannelingStep0*sqrt(pv)
292}
293
294//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
295
297 (const G4ThreeVector &pos0)
298{
299 G4double x0=pos0.x(),y0=pos0.y(),z0=pos0.z();
301 G4double x,y,z;
302
303 if (fBent)
304 {
305 // for bent crystal
306 G4double rsqrt = std::sqrt(fBendingRsquare -
308 x0*x0 + z0*z0);
309 //transform to co-rotating reference system connected with "central plane/axis"
310 x = fBendingR - rsqrt;
311 y = y0;
312 z = fBendingR*std::asin((z0*fCosMiscutAngle + x0*fSinMiscutAngle)/rsqrt);
313 }
314 else
315 {
316 //for straight crystal
318 y = y0;
320
321 //for crystalline undulator
322 if(fCU){x-=GetCUx(z);}
323 }
324
325 //calculation of coordinates within a channel (periodic cell)
326 fNChannelx=std::floor(x/fDx); //remember the horizontal channel number
327 //to track the particle
328 x-=fNChannelx*fDx;
329 fNChannely=std::floor(y/fDy);//remember the vertical channel number
330 //to track the particle (=0 for planar case)
331 y-=fNChannely*fDy;
332 //correction of the longitudinal coordinate
333 if (fBent) {fCorrectionZ = fBendingR/(fBendingR-fNChannelx*fDx);}
334
335 return G4ThreeVector(x,y,z);
336}
337
338//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
339
341 const G4ThreeVector &pos)
342{
343 G4double x=pos.x(),y=pos.y(),z=pos.z();
344
345 //transform to co-rotating reference system connected with "central plane/axis"
346 x+=fNChannelx*fDx;
347 y+=fNChannely*fDy;
348
349 G4double x0,y0,z0;
350
351 if (fBent)
352 {
353 // for bent crystal
354 G4double rcos = (fBendingR - x)*(1. - std::cos(z/fBendingR));
355 G4double a = x + rcos;
356 G4double b = std::sqrt(x*x + fBending2R*rcos - a*a);
357
358 //transform to Box coordinates
360 y0 = y;
362 }
363 else
364 {
365 //for crystalline undulator
366 if(fCU){x+=GetCUx(z);}
367
368 //for straight crystal
370 y0 = y;
372 }
373
374 return G4ThreeVector(x0,y0,z0-fHalfDimBoundingBox.z());
375}
376
377//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
378
380 G4double& y,
381 G4double& z)
382{
383
384 //test of enter in other channel
385 if (x<0)
386 {
387 fNChannelx-=1;
388 x+=fDx; //enter in other channel
389 //correction of the longitudinal coordinate
390 if (fBent) {fCorrectionZ = fBendingR/(fBendingR-fNChannelx*fDx);}
391 }
392 else if (x>=fDx)
393 {
394 fNChannelx+=1;
395 x-=fDx; //enter in other channel
396 //correction of the longitudinal coordinate
397 if (fBent) {fCorrectionZ = fBendingR/(fBendingR-fNChannelx*fDx);}
398 }
399
400 //test of enter in other channel
401 if (y<0)
402 {
403 fNChannely-=1;
404 y+=fDy; //enter in other channel
405 }
406 else if (y>=fDy)
407 {
408 fNChannely+=1;
409 y-=fDy; //enter in other channel
410 }
411
412 return G4ThreeVector(x,y,z);
413}
414
415//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
Definition of the G4ChannelingFastSimCrystalData class The class inherits G4VChannelingFastSimCrystal...
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition G4Types.hh:83
int G4int
Definition G4Types.hh:85
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
double z() const
double x() const
double y() const
G4ThreeVector CoordinatesFromBoxToLattice(const G4ThreeVector &pos0)
void SetMaterialProperties(const G4Material *crystal, const G4String &lattice)
G4ThreeVector ChannelChange(G4double &x, G4double &y, G4double &z)
change the channel if necessary, recalculate x o y
G4ThreeVector CoordinatesFromLatticeToBox(const G4ThreeVector &pos)
void SetCoefficients1D(G4double AI0, G4double BI0, G4double CI0, G4double DI0, G4int i)
Set spline coefficients.
void SetCoefficients2D(G4double AI3D0, G4double BI3D0, G4double CI3D0, G4int i, G4int j, G4int k)
G4double GetAtomicMassAmu() const
Definition G4Element.hh:124
G4double GetZ() const
Definition G4Element.hh:119
G4IonisParamElm * GetIonisation() const
Definition G4Element.hh:171
G4double GetMeanExcitationEnergy() const
const G4Element * GetElement(G4int iel) const
std::size_t GetNumberOfElements() const
const G4String & GetName() const
std::vector< G4double > fK20
coefficients necessary for multiple and single coulomb scattering
std::vector< G4ChannelingFastSimInterpolation * > fNucleiDensity
G4ChannelingFastSimInterpolation * fMinIonizationEnergy
G4ChannelingFastSimInterpolation * fElectricFieldY
G4ThreeVector fHalfDimBoundingBox
values related to the crystal geometry
G4ChannelingFastSimInterpolation * fElectricFieldX
classes containing interpolation coefficients
G4ChannelingFastSimInterpolation * fElectronDensity
G4int fNelements
values related to the crystal lattice
std::vector< G4double > fTeta10
angles necessary for multiple and single coulomb scattering
G4double GetCUx(G4double z)
get crystalline undulator wave function
std::vector< G4double > fPu11
coefficients for multiple scattering suppression