143{
146 G4double etotalToSetParticleProperties;
147
158
160
163
167 G4double lindhardAngleNumberHighLimit0;
168
170
171
172 G4double x1=0.,x2=0.,x3=0.,x4=0.,y1=0.,y2=0.,y3=0.,y4=0.;
173
174 G4double tx1=0.,tx2=0.,tx3=0.,tx4=0.,ty1=0.,ty2=0.,ty3=0.,ty4=0.;
175
176 G4double kvx1=0.,kvx2=0.,kvx3=0.,kvx4=0.,kvy1=0.,kvy2=0.,kvy3=0.,kvy4=0.;
177
179
181
183
184
186
188 fCrystalData->SetGeometryParameters(crystallogic);
189
190
191 if (fRad)
192 {
194
195 fBaierKatkov->ResetRadIntegral();
196 }
197
201
202 G4String particleName =
204
205 lindhardAngleNumberHighLimit0 =
207 GetParticleDefinition()->GetParticleDefinitionID());
209 GetParticleDefinition()->GetParticleDefinitionID());
210
211
212 fCrystalData->SetParticleProperties(etotal, mass, charge, particleName);
213
214
216
217
219 xyz = fCrystalData->CoordinatesFromBoxToLattice(xyz0);
223
225
226
227
228 tx0 = std::atan(momentumDirection.
x()/momentumDirection.
z());
229 ty0 = std::atan(momentumDirection.
y()/momentumDirection.
z());
230
231
232 tx = fCrystalData->AngleXFromBoxToLattice(tx0,z);
233 ty = ty0;
234
235 etotalToSetParticleProperties = etotal*0.999;
237
238 do
239 {
240
241 tGlobalPreStep=tGlobal;
242
243 xyz0PreStep = xyz0;
244
245 txPreStep = tx;
246 tyPreStep = ty;
247 etotalPreStep = etotal;
248
249 dz = fCrystalData->GetSimulationStep(tx,ty);
250 dzd3=dz/3;
251 dzd8=dz/8;
252
253
254
255
256
257
258
259 kvx1=fCrystalData->Ex(x,y);
260 x1=x+tx*dzd3;
261 tx1=tx+(kvx1-fCrystalData->GetCurv(z)*fCrystalData->GetCorrectionZ())*dzd3;
262 if (fCrystalData->GetModel()==2)
263 {
264 kvy1=fCrystalData->Ey(x,y);
265 y1=y+ty*dzd3;
266 ty1=ty+kvy1*dzd3;
267 }
268
269
270 kvx2=fCrystalData->Ex(x1,y1);
271 x2=x-tx*dzd3+tx1*dz;
272 tx2=tx-(kvx1-fCrystalData->GetCurv(z)*fCrystalData->GetCorrectionZ())*dzd3+
273 (kvx2-fCrystalData->GetCurv(z)*fCrystalData->GetCorrectionZ())*dz;
274 if (fCrystalData->GetModel()==2)
275 {
276 kvy2=fCrystalData->Ey(x1,y1);
277 y2=y-ty*dzd3+ty1*dz;
278 ty2=ty-kvy1*dzd3+kvy2*dz;
279 }
280
281
282 kvx3=fCrystalData->Ex(x2,y2);
283 x3=x+(tx-tx1+tx2)*dz;
284 tx3=tx+(kvx1-kvx2+kvx3-fCrystalData->GetCurv(z)*fCrystalData->GetCorrectionZ())*dz;
285 if (fCrystalData->GetModel()==2)
286 {
287 kvy3=fCrystalData->Ey(x2,y2);
288 y3=y+(ty-ty1+ty2)*dz;
289 ty3=ty+(kvy1-kvy2+kvy3)*dz;
290 }
291
292
293 kvx4=fCrystalData->Ex(x3,y3);
294 x4=x+(tx+3.*tx1+3.*tx2+tx3)*dzd8;
295 tx4=tx+(kvx1+3.*kvx2+3.*kvx3+kvx4)*dzd8-
296 fCrystalData->GetCurv(z)*fCrystalData->GetCorrectionZ()*dz;
297 if (fCrystalData->GetModel()==2)
298 {
299 kvy4=fCrystalData->Ey(x3,y3);
300 y4=y+(ty+3.*ty1+3.*ty2+ty3)*dzd8;
301 ty4=ty+(kvy1+3.*kvy2+3.*kvy3+kvy4)*dzd8;
302 }
303 else
304 {
305 y4 =y+ty*dz;
306 ty4=ty;
307 }
308
309 x=x4;
310 tx=tx4;
311 y=y4;
312 ty=ty4;
313
314 z+=dz*fCrystalData->GetCorrectionZ();
315
316
317 xyz = fCrystalData->ChannelChange(x,y,z);
321
322
323
324
325 xyz0=fCrystalData->CoordinatesFromLatticeToBox(xyz);
326
327 momentumDirectionStep=
328 dz*std::sqrt(1+std::pow(std::tan(tx),2)+std::pow(std::tan(ty),2));
329 tGlobal+=momentumDirectionStep/(fCrystalData->GetBeta())/CLHEP::c_light;
330
331
333
334
335 for (
G4int i = 0; i < fCrystalData->GetNelements(); i++)
336 {
337
338 effectiveStep = momentumDirectionStep*fCrystalData->NuclearDensity(x,y,i);
339
340 scatteringAnglesAndEnergyLoss += fCrystalData->
341 CoulombAtomicScattering(effectiveStep,momentumDirectionStep,i);
342
343
344 elossAccum += fCrystalData->IonizationLosses(momentumDirectionStep, i);
345 }
346
347 scatteringAnglesAndEnergyLoss += fCrystalData->CoulombElectronScattering(
348 fCrystalData->MinIonizationEnergy(x,y),
349 fCrystalData->ElectronDensity(x,y),
350 momentumDirectionStep);
351 tx += scatteringAnglesAndEnergyLoss.
x();
352 ty += scatteringAnglesAndEnergyLoss.
y();
353 elossAccum += scatteringAnglesAndEnergyLoss.
z();
354
355
356
357 if (etotalToSetParticleProperties>etotal)
358 {
359 fCrystalData->SetParticleProperties(etotal, mass, charge, particleName);
360 etotalToSetParticleProperties = etotal*0.999;
361 }
362
363
364
365
366 if (inside)
367 {
368
370 GetParticleDefinition()->
371 GetParticleDefinitionID()))
372 {inCrystal = false;}
373
374
375 else if (fCrystalData->GetModel()==1)
376 {
377
378 if (std::abs(tx) >=
379 std::max(lindhardAngleNumberHighLimit0*
380 fCrystalData->GetLindhardAngle(),
381 highAngleLimit0))
382 {inCrystal = false;}
383 }
384 else if (fCrystalData->GetModel()==2)
385 {
386
387 if (std::sqrt(tx*tx+ty*ty) >=
388 std::max(lindhardAngleNumberHighLimit0*
389 fCrystalData->GetLindhardAngle(),
390 highAngleLimit0))
391 {inCrystal = false;}
392 }
393
394
395
396 if (fRad)
397 {
398
399 tx0 = fCrystalData->AngleXFromLatticeToBox(tx,z);
400 ty0 = ty;
401
402
403
404 if(fBaierKatkov->DoRadiation(etotal,mass,
405 tx0,ty0,
406 scatteringAnglesAndEnergyLoss.
x(),
407 scatteringAnglesAndEnergyLoss.
y(),
408 momentumDirectionStep,tGlobal,xyz0,
409 crystallogic->
410 GetSolid()->
411 Inside(xyz0)!=
kInside&&inCrystal))
412
413
414 {
415
416
417 etotal = fBaierKatkov->GetParticleNewTotalEnergy();
418 tx0 = fBaierKatkov->GetParticleNewAngleX();
419 ty0 = fBaierKatkov->GetParticleNewAngleY();
420 tGlobal = fBaierKatkov->GetNewGlobalTime();
421 xyz0 = fBaierKatkov->GetParticleNewCoordinateXYZ();
422
423
424 fBaierKatkov->GeneratePhoton(fastStep);
425
426
427 fCrystalData->SetParticleProperties(etotal, mass, charge, particleName);
428
429
430 xyz = fCrystalData->CoordinatesFromBoxToLattice(xyz0);
434
435
436 tx = fCrystalData->AngleXFromBoxToLattice(tx0,z);
437 ty = ty0;
438 }
439 }
440 else
441 {
442
443
444 etotal -= elossAccum;
445 eDeposited += elossAccum;
446 elossAccum=0;
447 ekinetic = etotal-mass;
448 if(ekinetic<1*keV)
449 {
450 G4cout <<
"Warning in G4ChannelingFastSimModel: " <<
451 ekinetic <<
"<" << 1*keV <<
" !" <<
G4endl;
452 eDeposited-=(1*keV-ekinetic);
453 ekinetic = 1*keV;
454 G4cout <<
"Setting deposited energy=" <<
455 eDeposited <<
" & ekinetic=" << ekinetic <<
G4endl;
456 etotal = mass+ekinetic;
457 }
458 }
459
460
463 {
464
465
466 tGlobal = tGlobalPreStep;
467 xyz0 = xyz0PreStep;
468 tx = txPreStep;
469 ty = tyPreStep;
470 etotal = etotalPreStep;
471 z-=dz*fCrystalData->GetCorrectionZ();
472
473
474
475 inCrystal = false;
476 }
477 }
478 else
479 {
480
483 {inside = true;}
484
485
488 {inCrystal = false;}
489 }
490 }
491 while (inCrystal);
492
493
494 tx0 = fCrystalData->AngleXFromLatticeToBox(tx,z);
495 ty0 = ty;
496
497
499
501
502
503 etotal -= elossAccum;
504 eDeposited += elossAccum;
505 ekinetic = etotal-mass;
506 if(ekinetic<1*keV)
507 {
508 G4cout <<
"Warning in G4ChannelingFastSimModel: " <<
509 ekinetic <<
"<" << 1*keV <<
" !" <<
G4endl;
510 eDeposited-=(1*keV-ekinetic);
511 ekinetic = 1*keV;
512 G4cout <<
"Setting deposited energy=" <<
513 eDeposited <<
" & ekinetic=" << ekinetic <<
G4endl;
514 }
516
518
519
520
522 1./std::sqrt(1.+std::pow(std::tan(tx0),2)+std::pow(std::tan(ty0),2));
525 momentumDirectionZ*std::tan(ty0),
526 momentumDirectionZ));
527}
CLHEP::Hep3Vector G4ThreeVector
G4GLOB_DLL std::ostream G4cout
G4double GetHighAngleLimit(G4int particleDefinitionID)
G4double GetLindhardAngleNumberHighLimit(G4int particleDefinitionID)
G4double GetLowKineticEnergyLimit(G4int particleDefinitionID)
get cuts
void SetNumberOfSecondaryTracks(G4int)
void ProposeTotalEnergyDeposited(G4double anEnergyPart)
void ProposePrimaryTrackFinalPosition(const G4ThreeVector &, G4bool localCoordinates=true)
void ProposePrimaryTrackFinalTime(G4double)
void ProposePrimaryTrackFinalKineticEnergy(G4double)
void ProposePrimaryTrackFinalMomentumDirection(const G4ThreeVector &, G4bool localCoordinates=true)
G4ThreeVector GetPrimaryTrackLocalPosition() const
const G4Track * GetPrimaryTrack() const
G4ThreeVector GetPrimaryTrackLocalDirection() const
G4LogicalVolume * GetEnvelopeLogicalVolume() const
G4VSolid * GetSolid() const
G4double GetPDGMass() const
G4double GetPDGCharge() const
const G4String & GetParticleName() const
const G4ParticleDefinition * GetParticleDefinition() const
G4double GetGlobalTime() const
G4double GetKineticEnergy() const