264{
266 fNumPhotons = 0;
267
269 const G4Material* aMaterial = aTrack.
GetMaterial();
270
273
277
279 if (0.0 >= TotalEnergyDeposit) {
281 }
282
284 if(!MPT)
286
287 G4int N_timeconstants = 1;
288
290 N_timeconstants = 3;
292 N_timeconstants = 2;
294 {
295
297 }
298
301
309
310 if(fScintillationByParticleType)
311 {
313 aTrack, aStep, yield1, yield2, yield3, timeconstant1, timeconstant2,
314 timeconstant3);
315 }
316 else
317 {
320 : 1.;
323 : 0.;
326 : 0.;
327
328
330
331
332 if(fEmSaturation)
333 MeanNumberOfPhotons *=
334 (fEmSaturation->VisibleEnergyDepositionAtAStep(&aStep));
335 else
336 MeanNumberOfPhotons *= TotalEnergyDeposit;
337 }
338 sum_yields = yield1 + yield2 + yield3;
339
340 if(MeanNumberOfPhotons > 10.)
341 {
342 G4double sigma = ResolutionScale * std::sqrt(MeanNumberOfPhotons);
343 fNumPhotons =
G4int(G4RandGauss::shoot(MeanNumberOfPhotons, sigma) + 0.5);
344 }
345 else
346 {
348 }
349
350 if(fNumPhotons <= 0 || !fStackingFlag)
351 {
352
355 }
356
358
359 if(fTrackSecondariesFirst)
360 {
363 }
364
365 std::size_t materialIndex = aMaterial->
GetIndex();
366 auto it = fIndexMPT.find(materialIndex);
367
368 std::size_t indexMPT = 0;
369 if(it != fIndexMPT.end())
370 {
371 indexMPT = it->second;
372 }
373 else
374 {
376 ed <<
"G4MaterialPropertiesTable for " << aMaterial->
GetName()
377 <<
" is not found!" <<
G4endl;
379 }
380
381
382
383 G4int numPhot = fNumPhotons;
386 G4PhysicsFreeVector* scintIntegral = nullptr;
388
393
394 for(
G4int scnt = 0; scnt < N_timeconstants; ++scnt)
395 {
396
397 if(scnt == 0)
398 {
399 if(N_timeconstants == 1)
400 {
401 numPhot = fNumPhotons;
402 }
403 else
404 {
405 numPhot = yield1 / sum_yields * fNumPhotons;
406 }
407 if(fScintillationByParticleType)
408 {
409 scintTime = timeconstant1;
410 }
411 else
412 {
414 }
415 if(fFiniteRiseTime)
416 {
418 }
420 scintIntegral = (G4PhysicsFreeVector*) ((*fIntegralTable1)(indexMPT));
421 }
422 else if(scnt == 1)
423 {
424
425 if(N_timeconstants == 2)
426 {
427 numPhot = fNumPhotons - numPhot;
428 }
429 else
430 {
431 numPhot = yield2 / sum_yields * fNumPhotons;
432 }
433 if(fScintillationByParticleType)
434 {
435 scintTime = timeconstant2;
436 }
437 else
438 {
440 }
441 if(fFiniteRiseTime)
442 {
444 }
446 scintIntegral = (G4PhysicsFreeVector*) ((*fIntegralTable2)(indexMPT));
447 }
448 else if(scnt == 2)
449 {
450 numPhot = yield3 / sum_yields * fNumPhotons;
451 if(fScintillationByParticleType)
452 {
453 scintTime = timeconstant3;
454 }
455 else
456 {
458 }
459 if(fFiniteRiseTime)
460 {
462 }
464 scintIntegral = (G4PhysicsFreeVector*) ((*fIntegralTable3)(indexMPT));
465 }
466
467 if(!scintIntegral)
468 continue;
469
470 for(
G4int i = 0; i < numPhot; ++i)
471 {
472
474
476 {
477 G4cout <<
"sampledEnergy = " << sampledEnergy <<
G4endl;
478 }
479
480
482 G4double sint = std::sqrt((1. - cost) * (1. + cost));
487
488
489 G4ThreeVector photonPolarization(cost * cosp, cost * sinp, -sint);
492 sinp = std::sin(phi);
493 cosp = std::cos(phi);
494 photonPolarization = (cosp * photonPolarization + sinp * perp).unit();
495
496
497 auto scintPhoton = new G4DynamicParticle(opticalphoton, photonMomentum);
498 scintPhoton->SetPolarization(photonPolarization);
499 scintPhoton->SetKineticEnergy(sampledEnergy);
500
501
503
504
507 delta / (pPreStepPoint->
GetVelocity() + 0.5 * rand * deltaVelocity);
508 if(riseTime == 0.0)
509 {
511 }
512 else
513 {
514 deltaTime += sample_time(riseTime, scintTime);
515 }
516
519
520 G4Track* secTrack = new G4Track(scintPhoton, secTime, secPosition);
524 if(fScintillationTrackInfo)
526 new G4ScintillationTrackInformation(scintType));
528 }
529 }
530
532 {
533 G4cout <<
"\n Exiting from G4Scintillation::DoIt -- NumberOfSecondaries = "
535 }
536
538}
@ kSCINTILLATIONRISETIME2
@ kSCINTILLATIONRISETIME1
@ kSCINTILLATIONRISETIME3
G4ThreeVector G4ParticleMomentum
G4long G4Poisson(G4double mean)
CLHEP::Hep3Vector G4ThreeVector
Hep3Vector cross(const Hep3Vector &) const
std::size_t GetIndex() const
const G4String & GetName() const
G4double GetScintillationYieldByParticleType(const G4Track &aTrack, const G4Step &aStep, G4double &yield1, G4double &yield2, G4double &yield3, G4double &timeconstant1, G4double &timeconstant2, G4double &timeconstant3)
G4double GetVelocity() const
G4double GetGlobalTime() const
const G4ThreeVector & GetPosition() const
const G4TouchableHandle & GetTouchableHandle() const
G4ThreeVector GetDeltaPosition() const
G4double GetStepLength() const
void SetTouchableHandle(const G4TouchableHandle &apValue)
void SetUserInformation(G4VUserTrackInformation *aValue) const
void SetCreatorModelID(const G4int id)
void SetParentID(const G4int aValue)
G4ParticleChange aParticleChange
virtual G4VParticleChange * PostStepDoIt(const G4Track &, const G4Step &)