234{
236 fNumPhotons = 0;
237
239 const G4Material* aMaterial = aTrack.
GetMaterial();
240
243
247
249
251 if(!MPT)
253
254 G4int N_timeconstants = 1;
255
257 N_timeconstants = 3;
259 N_timeconstants = 2;
261 {
262
264 }
265
268
276
277 if(fScintillationByParticleType)
278 {
280 aTrack, aStep, yield1, yield2, yield3, timeconstant1, timeconstant2,
281 timeconstant3);
282 }
283 else
284 {
287 : 1.;
290 : 0.;
293 : 0.;
294
295
297
298
299 if(fEmSaturation)
300 MeanNumberOfPhotons *=
301 (fEmSaturation->VisibleEnergyDepositionAtAStep(&aStep));
302 else
303 MeanNumberOfPhotons *= TotalEnergyDeposit;
304 }
305 sum_yields = yield1 + yield2 + yield3;
306
307 if(MeanNumberOfPhotons > 10.)
308 {
309 G4double sigma = ResolutionScale * std::sqrt(MeanNumberOfPhotons);
310 fNumPhotons =
G4int(G4RandGauss::shoot(MeanNumberOfPhotons, sigma) + 0.5);
311 }
312 else
313 {
315 }
316
317 if(fNumPhotons <= 0 || !fStackingFlag)
318 {
319
322 }
323
325
326 if(fTrackSecondariesFirst)
327 {
330 }
331
332 std::size_t materialIndex = aMaterial->
GetIndex();
333 auto it = fIndexMPT.find(materialIndex);
334
335 std::size_t indexMPT = 0;
336 if(it != fIndexMPT.end())
337 {
338 indexMPT = it->second;
339 }
340 else
341 {
343 ed <<
"G4MaterialPropertiesTable for " << aMaterial->
GetName()
344 <<
" is not found!" <<
G4endl;
345 G4Exception(
"G4QuasiScintillation::PostStepDoIt",
"Scint04",
347 }
348
349
350
351 G4int numPhot = fNumPhotons;
354 G4PhysicsFreeVector* scintIntegral = nullptr;
356
361
362 for(
G4int scnt = 0; scnt < N_timeconstants; ++scnt)
363 {
364
365 if(scnt == 0)
366 {
367 if(N_timeconstants == 1)
368 {
369 numPhot = fNumPhotons;
370 }
371 else
372 {
373 numPhot = yield1 / sum_yields * fNumPhotons;
374 }
375 if(fScintillationByParticleType)
376 {
377 scintTime = timeconstant1;
378 }
379 else
380 {
382 }
383 if(fFiniteRiseTime)
384 {
386 }
388 scintIntegral = (G4PhysicsFreeVector*) ((*fIntegralTable1)(indexMPT));
389 }
390 else if(scnt == 1)
391 {
392
393 if(N_timeconstants == 2)
394 {
395 numPhot = fNumPhotons - numPhot;
396 }
397 else
398 {
399 numPhot = yield2 / sum_yields * fNumPhotons;
400 }
401 if(fScintillationByParticleType)
402 {
403 scintTime = timeconstant2;
404 }
405 else
406 {
408 }
409 if(fFiniteRiseTime)
410 {
412 }
414 scintIntegral = (G4PhysicsFreeVector*) ((*fIntegralTable2)(indexMPT));
415 }
416 else if(scnt == 2)
417 {
418 numPhot = yield3 / sum_yields * fNumPhotons;
419 if(fScintillationByParticleType)
420 {
421 scintTime = timeconstant3;
422 }
423 else
424 {
426 }
427 if(fFiniteRiseTime)
428 {
430 }
432 scintIntegral = (G4PhysicsFreeVector*) ((*fIntegralTable3)(indexMPT));
433 }
434
435 if(!scintIntegral)
436 continue;
437
438 if(fOffloadingFlag)
439 {
440
441 auto quasiPhoton = new G4DynamicParticle(
444
445
446 G4Track* aSecondaryTrack = new G4Track(quasiPhoton, t0, x0);
450
451
452 G4QuasiOpticalData quasiTrackData{aMaterial->
GetIndex(), numPhot,
456 new G4ScintillationQuasiTrackInfo(quasiTrackData, scintTime, riseTime));
458 }
459
460 for(
G4int i = 0; i < numPhot; ++i)
461 {
462
464
466 {
467 G4cout <<
"sampledEnergy = " << sampledEnergy <<
G4endl;
468 }
469
470
472 G4double sint = std::sqrt((1. - cost) * (1. + cost));
477
478
479 G4ThreeVector photonPolarization(cost * cosp, cost * sinp, -sint);
482 sinp = std::sin(phi);
483 cosp = std::cos(phi);
484 photonPolarization = (cosp * photonPolarization + sinp * perp).unit();
485
486
487 auto scintPhoton = new G4DynamicParticle(opticalphoton, photonMomentum);
488 scintPhoton->SetPolarization(photonPolarization);
489 scintPhoton->SetKineticEnergy(sampledEnergy);
490
491
493
494
497 delta / (pPreStepPoint->
GetVelocity() + 0.5 * rand * deltaVelocity);
498 if(riseTime == 0.0)
499 {
501 }
502 else
503 {
504 deltaTime += sample_time(riseTime, scintTime);
505 }
506
509
510 G4Track* secTrack = new G4Track(scintPhoton, secTime, secPosition);
514 if(fScintillationTrackInfo)
516 new G4ScintillationTrackInformation(scintType));
518 }
519 }
520
522 {
523 G4cout <<
"\n Exiting from G4QuasiScintillation::DoIt -- "
524 << " NumberOfSecondaries = "
526 }
527
529}
@ kSCINTILLATIONRISETIME2
@ kSCINTILLATIONRISETIME1
@ kSCINTILLATIONRISETIME3
G4ThreeVector G4ParticleMomentum
G4long G4Poisson(G4double mean)
CLHEP::Hep3Vector G4ThreeVector
Hep3Vector cross(const Hep3Vector &) const
G4ThreeVector GetMomentum() const
std::size_t GetIndex() const
const G4String & GetName() const
G4double GetPDGCharge() const
static G4QuasiOpticalPhoton * QuasiOpticalPhotonDefinition()
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 SetAuxiliaryTrackInformation(G4int id, G4VAuxiliaryTrackInformation *info) 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 &)