Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4LivermorePolarizedComptonModel Class Reference

#include <G4LivermorePolarizedComptonModel.hh>

+ Inheritance diagram for G4LivermorePolarizedComptonModel:

Public Member Functions

 G4LivermorePolarizedComptonModel (const G4ParticleDefinition *p=nullptr, const G4String &nam="LivermorePolarizedCompton")
 
virtual ~G4LivermorePolarizedComptonModel ()
 
void Initialise (const G4ParticleDefinition *, const G4DataVector &) override
 
void InitialiseLocal (const G4ParticleDefinition *, G4VEmModel *masterModel) override
 
void InitialiseForElement (const G4ParticleDefinition *, G4int Z) override
 
G4double ComputeCrossSectionPerAtom (const G4ParticleDefinition *, G4double kinEnergy, G4double Z, G4double A=0, G4double cut=0, G4double emax=DBL_MAX) override
 
void SampleSecondaries (std::vector< G4DynamicParticle * > *, const G4MaterialCutsCouple *, const G4DynamicParticle *, G4double tmin, G4double maxEnergy) override
 
G4LivermorePolarizedComptonModeloperator= (const G4LivermorePolarizedComptonModel &right)=delete
 
 G4LivermorePolarizedComptonModel (const G4LivermorePolarizedComptonModel &)=delete
 
- Public Member Functions inherited from G4VEmModel
 G4VEmModel (const G4String &nam)
 
virtual ~G4VEmModel ()
 
virtual void InitialiseForMaterial (const G4ParticleDefinition *, const G4Material *)
 
virtual G4double ComputeDEDXPerVolume (const G4Material *, const G4ParticleDefinition *, G4double kineticEnergy, G4double cutEnergy=DBL_MAX)
 
virtual G4double CrossSectionPerVolume (const G4Material *, const G4ParticleDefinition *, G4double kineticEnergy, G4double cutEnergy=0.0, G4double maxEnergy=DBL_MAX)
 
virtual G4double GetPartialCrossSection (const G4Material *, G4int level, const G4ParticleDefinition *, G4double kineticEnergy)
 
virtual G4double ComputeCrossSectionPerShell (const G4ParticleDefinition *, G4int Z, G4int shellIdx, G4double kinEnergy, G4double cutEnergy=0.0, G4double maxEnergy=DBL_MAX)
 
virtual G4double ChargeSquareRatio (const G4Track &)
 
virtual G4double GetChargeSquareRatio (const G4ParticleDefinition *, const G4Material *, G4double kineticEnergy)
 
virtual G4double GetParticleCharge (const G4ParticleDefinition *, const G4Material *, G4double kineticEnergy)
 
virtual void StartTracking (G4Track *)
 
virtual void CorrectionsAlongStep (const G4MaterialCutsCouple *, const G4DynamicParticle *, const G4double &length, G4double &eloss)
 
virtual G4double Value (const G4MaterialCutsCouple *, const G4ParticleDefinition *, G4double kineticEnergy)
 
virtual G4double MinPrimaryEnergy (const G4Material *, const G4ParticleDefinition *, G4double cut=0.0)
 
virtual G4double MinEnergyCut (const G4ParticleDefinition *, const G4MaterialCutsCouple *)
 
virtual void SetupForMaterial (const G4ParticleDefinition *, const G4Material *, G4double kineticEnergy)
 
virtual void DefineForRegion (const G4Region *)
 
virtual void FillNumberOfSecondaries (G4int &numberOfTriplets, G4int &numberOfRecoil)
 
virtual void ModelDescription (std::ostream &outFile) const
 
void InitialiseElementSelectors (const G4ParticleDefinition *, const G4DataVector &)
 
std::vector< G4EmElementSelector * > * GetElementSelectors ()
 
void SetElementSelectors (std::vector< G4EmElementSelector * > *)
 
G4double ComputeDEDX (const G4MaterialCutsCouple *, const G4ParticleDefinition *, G4double kineticEnergy, G4double cutEnergy=DBL_MAX)
 
G4double CrossSection (const G4MaterialCutsCouple *, const G4ParticleDefinition *, G4double kineticEnergy, G4double cutEnergy=0.0, G4double maxEnergy=DBL_MAX)
 
G4double ComputeMeanFreePath (const G4ParticleDefinition *, G4double kineticEnergy, const G4Material *, G4double cutEnergy=0.0, G4double maxEnergy=DBL_MAX)
 
G4double ComputeCrossSectionPerAtom (const G4ParticleDefinition *, const G4Element *, G4double kinEnergy, G4double cutEnergy=0.0, G4double maxEnergy=DBL_MAX)
 
const G4ElementSelectRandomAtom (const G4MaterialCutsCouple *, const G4ParticleDefinition *, G4double kineticEnergy, G4double cutEnergy=0.0, G4double maxEnergy=DBL_MAX)
 
const G4ElementSelectTargetAtom (const G4MaterialCutsCouple *, const G4ParticleDefinition *, G4double kineticEnergy, G4double logKineticEnergy, G4double cutEnergy=0.0, G4double maxEnergy=DBL_MAX)
 
const G4ElementSelectRandomAtom (const G4Material *, const G4ParticleDefinition *, G4double kineticEnergy, G4double cutEnergy=0.0, G4double maxEnergy=DBL_MAX)
 
const G4ElementGetCurrentElement (const G4Material *mat=nullptr) const
 
G4int SelectRandomAtomNumber (const G4Material *) const
 
const G4IsotopeGetCurrentIsotope (const G4Element *elm=nullptr) const
 
G4int SelectIsotopeNumber (const G4Element *) const
 
void SetParticleChange (G4VParticleChange *, G4VEmFluctuationModel *f=nullptr)
 
void SetCrossSectionTable (G4PhysicsTable *, G4bool isLocal)
 
G4ElementDataGetElementData ()
 
G4PhysicsTableGetCrossSectionTable ()
 
G4VEmFluctuationModelGetModelOfFluctuations ()
 
G4VEmAngularDistributionGetAngularDistribution ()
 
G4VEmModelGetTripletModel ()
 
void SetTripletModel (G4VEmModel *)
 
void SetAngularDistribution (G4VEmAngularDistribution *)
 
G4double HighEnergyLimit () const
 
G4double LowEnergyLimit () const
 
G4double HighEnergyActivationLimit () const
 
G4double LowEnergyActivationLimit () const
 
G4double PolarAngleLimit () const
 
G4double SecondaryThreshold () const
 
G4bool DeexcitationFlag () const
 
G4bool ForceBuildTableFlag () const
 
G4bool UseAngularGeneratorFlag () const
 
void SetAngularGeneratorFlag (G4bool)
 
void SetHighEnergyLimit (G4double)
 
void SetLowEnergyLimit (G4double)
 
void SetActivationHighEnergyLimit (G4double)
 
void SetActivationLowEnergyLimit (G4double)
 
G4bool IsActive (G4double kinEnergy) const
 
void SetPolarAngleLimit (G4double)
 
void SetSecondaryThreshold (G4double)
 
void SetDeexcitationFlag (G4bool val)
 
void SetForceBuildTable (G4bool val)
 
void SetFluctuationFlag (G4bool val)
 
void SetMasterThread (G4bool val)
 
G4bool IsMaster () const
 
void SetUseBaseMaterials (G4bool val)
 
G4bool UseBaseMaterials () const
 
G4double MaxSecondaryKinEnergy (const G4DynamicParticle *dynParticle)
 
const G4StringGetName () const
 
void SetCurrentCouple (const G4MaterialCutsCouple *)
 
G4bool IsLocked () const
 
void SetLocked (G4bool)
 
void SetLPMFlag (G4bool)
 
G4VEmModeloperator= (const G4VEmModel &right)=delete
 
 G4VEmModel (const G4VEmModel &)=delete
 

Additional Inherited Members

- Protected Member Functions inherited from G4VEmModel
G4ParticleChangeForLossGetParticleChangeForLoss ()
 
G4ParticleChangeForGammaGetParticleChangeForGamma ()
 
virtual G4double MaxSecondaryEnergy (const G4ParticleDefinition *, G4double kineticEnergy)
 
const G4MaterialCutsCoupleCurrentCouple () const
 
void SetCurrentElement (const G4Element *)
 
- Protected Attributes inherited from G4VEmModel
G4ElementDatafElementData = nullptr
 
G4VParticleChangepParticleChange = nullptr
 
G4PhysicsTablexSectionTable = nullptr
 
const G4MaterialpBaseMaterial = nullptr
 
const std::vector< G4double > * theDensityFactor = nullptr
 
const std::vector< G4int > * theDensityIdx = nullptr
 
G4double inveplus
 
G4double pFactor = 1.0
 
std::size_t currentCoupleIndex = 0
 
std::size_t basedCoupleIndex = 0
 
G4bool lossFlucFlag = true
 

Detailed Description

Definition at line 44 of file G4LivermorePolarizedComptonModel.hh.

Constructor & Destructor Documentation

◆ G4LivermorePolarizedComptonModel() [1/2]

G4LivermorePolarizedComptonModel::G4LivermorePolarizedComptonModel ( const G4ParticleDefinition * p = nullptr,
const G4String & nam = "LivermorePolarizedCompton" )
explicit

Definition at line 84 of file G4LivermorePolarizedComptonModel.cc.

85 :G4VEmModel(nam),isInitialised(false)
86{
87 verboseLevel= 1;
88 // Verbosity scale:
89 // 0 = nothing
90 // 1 = warning for energy non-conservation
91 // 2 = details of energy budget
92 // 3 = calculation of cross sections, file openings, sampling of atoms
93 // 4 = entering in methods
94
95 if( verboseLevel>1 )
96 G4cout << "Livermore Polarized Compton is constructed " << G4endl;
97
98 //Mark this model as "applicable" for atomic deexcitation
100
101 fParticleChange = nullptr;
102 fAtomDeexcitation = nullptr;
103 fEntanglementModelID = G4PhysicsModelCatalog::GetModelID("model_GammaGammaEntanglement");
104}
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
static G4int GetModelID(const G4int modelIndex)
void SetDeexcitationFlag(G4bool val)
G4VEmModel(const G4String &nam)
Definition G4VEmModel.cc:67

◆ ~G4LivermorePolarizedComptonModel()

G4LivermorePolarizedComptonModel::~G4LivermorePolarizedComptonModel ( )
virtual

Definition at line 108 of file G4LivermorePolarizedComptonModel.cc.

109{
110 if(IsMaster()) {
111 delete shellData;
112 shellData = nullptr;
113 delete profileData;
114 profileData = nullptr;
115 delete scatterFunctionData;
116 scatterFunctionData = nullptr;
117 for(G4int i=0; i<maxZ; ++i) {
118 if(data[i]) {
119 delete data[i];
120 data[i] = nullptr;
121 }
122 }
123 }
124}
int G4int
Definition G4Types.hh:85
G4bool IsMaster() const

◆ G4LivermorePolarizedComptonModel() [2/2]

G4LivermorePolarizedComptonModel::G4LivermorePolarizedComptonModel ( const G4LivermorePolarizedComptonModel & )
delete

Member Function Documentation

◆ ComputeCrossSectionPerAtom()

G4double G4LivermorePolarizedComptonModel::ComputeCrossSectionPerAtom ( const G4ParticleDefinition * ,
G4double kinEnergy,
G4double Z,
G4double A = 0,
G4double cut = 0,
G4double emax = DBL_MAX )
overridevirtual

Reimplemented from G4VEmModel.

Definition at line 258 of file G4LivermorePolarizedComptonModel.cc.

263{
264 if (verboseLevel > 3)
265 G4cout << "Calling ComputeCrossSectionPerAtom() of G4LivermorePolarizedComptonModel" << G4endl;
266
267 G4double cs = 0.0;
268
269 if (GammaEnergy < LowEnergyLimit())
270 return 0.0;
271
272 G4int intZ = G4lrint(Z);
273 if(intZ < 1 || intZ > maxZ) { return cs; }
274
275 G4PhysicsFreeVector* pv = data[intZ];
276
277 // if element was not initialised
278 // do initialisation safely for MT mode
279 if(!pv)
280 {
281 InitialiseForElement(0, intZ);
282 pv = data[intZ];
283 if(!pv) { return cs; }
284 }
285
286 G4int n = G4int(pv->GetVectorLength() - 1);
287 G4double e1 = pv->Energy(0);
288 G4double e2 = pv->Energy(n);
289
290 if(GammaEnergy <= e1) { cs = GammaEnergy/(e1*e1)*pv->Value(e1); }
291 else if(GammaEnergy <= e2) { cs = pv->Value(GammaEnergy)/GammaEnergy; }
292 else if(GammaEnergy > e2) { cs = pv->Value(e2)/GammaEnergy; }
293
294 return cs;
295
296}
double G4double
Definition G4Types.hh:83
void InitialiseForElement(const G4ParticleDefinition *, G4int Z) override
G4double Energy(const std::size_t index) const
G4double Value(const G4double energy, std::size_t &lastidx) const
std::size_t GetVectorLength() const
G4double LowEnergyLimit() const
int G4lrint(double ad)
Definition templates.hh:134

◆ Initialise()

void G4LivermorePolarizedComptonModel::Initialise ( const G4ParticleDefinition * particle,
const G4DataVector & cuts )
overridevirtual

Implements G4VEmModel.

Definition at line 128 of file G4LivermorePolarizedComptonModel.cc.

130{
131 if (verboseLevel > 1)
132 G4cout << "Calling G4LivermorePolarizedComptonModel::Initialise()" << G4endl;
133
134 // Initialise element selector
135 if(IsMaster()) {
136 // Access to elements
137 const char* path = G4FindDataDir("G4LEDATA");
138
139 G4ProductionCutsTable* theCoupleTable =
141
142 G4int numOfCouples = (G4int)theCoupleTable->GetTableSize();
143
144 for(G4int i=0; i<numOfCouples; ++i) {
145 const G4Material* material =
146 theCoupleTable->GetMaterialCutsCouple(i)->GetMaterial();
147 const G4ElementVector* theElementVector = material->GetElementVector();
148 std::size_t nelm = material->GetNumberOfElements();
149
150 for (std::size_t j=0; j<nelm; ++j) {
151 G4int Z = G4lrint((*theElementVector)[j]->GetZ());
152 if(Z < 1) { Z = 1; }
153 else if(Z > maxZ){ Z = maxZ; }
154
155 if( (!data[Z]) ) { ReadData(Z, path); }
156 }
157 }
158
159 // For Doppler broadening
160 if(!shellData) {
161 shellData = new G4ShellData();
162 shellData->SetOccupancyData();
163 G4String file = "/doppler/shell-doppler";
164 shellData->LoadData(file);
165 }
166 if(!profileData) { profileData = new G4DopplerProfile(); }
167
168 // Scattering Function
169 if(!scatterFunctionData)
170 {
171
172 G4VDataSetAlgorithm* scatterInterpolation = new G4LogLogInterpolation;
173 G4String scatterFile = "comp/ce-sf-";
174 scatterFunctionData = new G4CompositeEMDataSet(scatterInterpolation, 1., 1.);
175 scatterFunctionData->LoadData(scatterFile);
176 }
177
178 InitialiseElementSelectors(particle, cuts);
179 }
180
181 if (verboseLevel > 2) {
182 G4cout << "Loaded cross section files" << G4endl;
183 }
184
185 if( verboseLevel>1 ) {
186 G4cout << "G4LivermoreComptonModel is initialized " << G4endl
187 << "Energy range: "
188 << LowEnergyLimit() / eV << " eV - "
189 << HighEnergyLimit() / GeV << " GeV"
190 << G4endl;
191 }
192 //
193 if(isInitialised) { return; }
194
195 fParticleChange = GetParticleChangeForGamma();
196 fAtomDeexcitation = G4LossTableManager::Instance()->AtomDeexcitation();
197 isInitialised = true;
198}
std::vector< const G4Element * > G4ElementVector
const char * G4FindDataDir(const char *)
virtual G4bool LoadData(const G4String &fileName)
static G4LossTableManager * Instance()
G4VAtomDeexcitation * AtomDeexcitation()
const G4Material * GetMaterial() const
const G4ElementVector * GetElementVector() const
std::size_t GetNumberOfElements() const
const G4MaterialCutsCouple * GetMaterialCutsCouple(G4int i) const
std::size_t GetTableSize() const
static G4ProductionCutsTable * GetProductionCutsTable()
void SetOccupancyData()
void LoadData(const G4String &fileName)
G4ParticleChangeForGamma * GetParticleChangeForGamma()
G4double HighEnergyLimit() const
void InitialiseElementSelectors(const G4ParticleDefinition *, const G4DataVector &)

◆ InitialiseForElement()

void G4LivermorePolarizedComptonModel::InitialiseForElement ( const G4ParticleDefinition * ,
G4int Z )
overridevirtual

Reimplemented from G4VEmModel.

Definition at line 954 of file G4LivermorePolarizedComptonModel.cc.

956{
957 G4AutoLock l(&LivermorePolarizedComptonModelMutex);
958 if(!data[Z]) { ReadData(Z); }
959 l.unlock();
960}

Referenced by ComputeCrossSectionPerAtom().

◆ InitialiseLocal()

void G4LivermorePolarizedComptonModel::InitialiseLocal ( const G4ParticleDefinition * ,
G4VEmModel * masterModel )
overridevirtual

Reimplemented from G4VEmModel.

Definition at line 201 of file G4LivermorePolarizedComptonModel.cc.

203{
205}
void SetElementSelectors(std::vector< G4EmElementSelector * > *)
std::vector< G4EmElementSelector * > * GetElementSelectors()

◆ operator=()

G4LivermorePolarizedComptonModel & G4LivermorePolarizedComptonModel::operator= ( const G4LivermorePolarizedComptonModel & right)
delete

◆ SampleSecondaries()

void G4LivermorePolarizedComptonModel::SampleSecondaries ( std::vector< G4DynamicParticle * > * fvect,
const G4MaterialCutsCouple * couple,
const G4DynamicParticle * aDynamicGamma,
G4double tmin,
G4double maxEnergy )
overridevirtual

Implements G4VEmModel.

Definition at line 300 of file G4LivermorePolarizedComptonModel.cc.

305{
306 // The scattered gamma energy is sampled according to Klein - Nishina formula.
307 // The random number techniques of Butcher & Messel are used (Nuc Phys 20(1960),15).
308 // GEANT4 internal units
309 //
310 // Note : Effects due to binding of atomic electrons are negliged.
311
312 if (verboseLevel > 3)
313 G4cout << "Calling SampleSecondaries() of G4LivermorePolarizedComptonModel" << G4endl;
314
315 G4double gammaEnergy0 = aDynamicGamma->GetKineticEnergy();
316
317 // do nothing below the threshold
318 // should never get here because the XS is zero below the limit
319 if (gammaEnergy0 < LowEnergyLimit())
320 return ;
321
322 G4ThreeVector gammaPolarization0 = aDynamicGamma->GetPolarization();
323
324 // Protection: a polarisation parallel to the
325 // direction causes problems;
326 // in that case find a random polarization
327 G4ThreeVector gammaDirection0 = aDynamicGamma->GetMomentumDirection();
328
329 // Make sure that the polarization vector is perpendicular to the
330 // gamma direction. If not
331 if(!(gammaPolarization0.isOrthogonal(gammaDirection0, 1e-6))||(gammaPolarization0.mag()==0))
332 { // only for testing now
333 gammaPolarization0 = GetRandomPolarization(gammaDirection0);
334 }
335 else
336 {
337 if ( gammaPolarization0.howOrthogonal(gammaDirection0) != 0)
338 {
339 gammaPolarization0 = GetPerpendicularPolarization(gammaDirection0, gammaPolarization0);
340 }
341 }
342 // End of Protection
343
344 G4double E0_m = gammaEnergy0 / electron_mass_c2 ;
345
346 // Select randomly one element in the current material
347 //G4int Z = crossSectionHandler->SelectRandomAtom(couple,gammaEnergy0);
348 const G4ParticleDefinition* particle = aDynamicGamma->GetDefinition();
349 const G4Element* elm = SelectRandomAtom(couple,particle,gammaEnergy0);
350 G4int Z = (G4int)elm->GetZ();
351
352 // Sample the energy and the polarization of the scattered photon
353 G4double epsilon, epsilonSq, onecost, sinThetaSqr, greject ;
354
355 G4double epsilon0Local = 1./(1. + 2*E0_m);
356 G4double epsilon0Sq = epsilon0Local*epsilon0Local;
357 G4double alpha1 = - G4Log(epsilon0Local);
358 G4double alpha2 = 0.5*(1.- epsilon0Sq);
359
360 G4double wlGamma = h_Planck*c_light/gammaEnergy0;
361 G4double gammaEnergy1;
362 G4ThreeVector gammaDirection1;
363
364 do {
365 if ( alpha1/(alpha1+alpha2) > G4UniformRand() )
366 {
367 epsilon = G4Exp(-alpha1*G4UniformRand());
368 epsilonSq = epsilon*epsilon;
369 }
370 else
371 {
372 epsilonSq = epsilon0Sq + (1.- epsilon0Sq)*G4UniformRand();
373 epsilon = std::sqrt(epsilonSq);
374 }
375
376 onecost = (1.- epsilon)/(epsilon*E0_m);
377 sinThetaSqr = onecost*(2.-onecost);
378
379 // Protection
380 if (sinThetaSqr > 1.)
381 {
382 G4cout
383 << " -- Warning -- G4LivermorePolarizedComptonModel::SampleSecondaries "
384 << "sin(theta)**2 = "
385 << sinThetaSqr
386 << "; set to 1"
387 << G4endl;
388 sinThetaSqr = 1.;
389 }
390 if (sinThetaSqr < 0.)
391 {
392 G4cout
393 << " -- Warning -- G4LivermorePolarizedComptonModel::SampleSecondaries "
394 << "sin(theta)**2 = "
395 << sinThetaSqr
396 << "; set to 0"
397 << G4endl;
398 sinThetaSqr = 0.;
399 }
400 // End protection
401
402 G4double x = std::sqrt(onecost/2.) / (wlGamma/cm);;
403 G4double scatteringFunction = scatterFunctionData->FindValue(x,Z-1);
404 greject = (1. - epsilon*sinThetaSqr/(1.+ epsilonSq))*scatteringFunction;
405
406 } while(greject < G4UniformRand()*Z);
407
408
409 // ****************************************************
410 // Phi determination
411 // ****************************************************
412 G4double phi = SetPhi(epsilon,sinThetaSqr);
413
414 //
415 // scattered gamma angles. ( Z - axis along the parent gamma)
416 //
417 G4double cosTheta = 1. - onecost;
418
419 // Protection
420 if (cosTheta > 1.)
421 {
422 G4cout
423 << " -- Warning -- G4LivermorePolarizedComptonModel::SampleSecondaries "
424 << "cosTheta = "
425 << cosTheta
426 << "; set to 1"
427 << G4endl;
428 cosTheta = 1.;
429 }
430 if (cosTheta < -1.)
431 {
432 G4cout
433 << " -- Warning -- G4LivermorePolarizedComptonModel::SampleSecondaries "
434 << "cosTheta = "
435 << cosTheta
436 << "; set to -1"
437 << G4endl;
438 cosTheta = -1.;
439 }
440 // End protection
441
442 G4double sinTheta = std::sqrt (sinThetaSqr);
443
444 // Protection
445 if (sinTheta > 1.)
446 {
447 G4cout
448 << " -- Warning -- G4LivermorePolarizedComptonModel::SampleSecondaries "
449 << "sinTheta = "
450 << sinTheta
451 << "; set to 1"
452 << G4endl;
453 sinTheta = 1.;
454 }
455 if (sinTheta < -1.)
456 {
457 G4cout
458 << " -- Warning -- G4LivermorePolarizedComptonModel::SampleSecondaries "
459 << "sinTheta = "
460 << sinTheta
461 << "; set to -1"
462 << G4endl;
463 sinTheta = -1.;
464 }
465 // End protection
466
467 // Check for entanglement and re-sample phi if necessary
468
469 const auto* auxInfo
470 = fParticleChange->GetCurrentTrack()->GetAuxiliaryTrackInformation(fEntanglementModelID);
471 if (auxInfo) {
472 const auto* entanglementAuxInfo = dynamic_cast<const G4EntanglementAuxInfo*>(auxInfo);
473 if (entanglementAuxInfo) {
474 auto* clipBoard = dynamic_cast<G4eplusAnnihilationEntanglementClipBoard*>
475 (entanglementAuxInfo->GetEntanglementClipBoard());
476 if (clipBoard) {
477 // This is an entangled photon from eplus annihilation at rest.
478 // If this is the first scatter of the first photon, place theta and
479 // phi on the clipboard.
480 // If this is the first scatter of the second photon, use theta and
481 // phi of the first scatter of the first photon, together with the
482 // theta of the second photon, to sample phi.
483 if (clipBoard->IsTrack1Measurement()) {
484 // Check we have the relevant track. Not sure this is strictly
485 // necessary but I want to be sure tracks from, say, more than one
486 // entangled system are properly paired.
487 // Note: the tracking manager pops the tracks in the reverse order. We
488 // will rely on that. (If not, the logic here would have to be a bit
489 // more complicated to ensure we matched the right tracks.)
490 // So our track 1 is clipboard track B.
491 if (clipBoard->GetTrackB() == fParticleChange->GetCurrentTrack()) {
492 // This is the first scatter of the first photon. Reset flag.
493 // // Debug
494 // auto* track1 = fParticleChange->GetCurrentTrack();
495 // G4cout
496 // << "This is the first scatter of the first photon. Reset flag."
497 // << "\nTrack: " << track1->GetTrackID()
498 // << ", Parent: " << track1->GetParentID()
499 // << ", Name: " << clipBoard->GetParentParticleDefinition()->GetParticleName()
500 // << G4endl;
501 // // End debug
502 clipBoard->ResetTrack1Measurement();
503 // Store cos(theta),phi of first photon.
504 clipBoard->SetComptonCosTheta1(cosTheta);
505 clipBoard->SetComptonPhi1(phi);
506 }
507 } else if (clipBoard->IsTrack2Measurement()) {
508 // Check we have the relevant track.
509 // Remember our track 2 is clipboard track A.
510 if (clipBoard->GetTrackA() == fParticleChange->GetCurrentTrack()) {
511 // This is the first scatter of the second photon. Reset flag.
512 // // Debug
513 // auto* track2 = fParticleChange->GetCurrentTrack();
514 // G4cout
515 // << "This is the first scatter of the second photon. Reset flag."
516 // << "\nTrack: " << track2->GetTrackID()
517 // << ", Parent: " << track2->GetParentID()
518 // << ", Name: " << clipBoard->GetParentParticleDefinition()->GetParticleName()
519 // << G4endl;
520 // // End debug
521 clipBoard->ResetTrack2Measurement();
522
523 // Get cos(theta),phi of first photon.
524 const G4double& cosTheta1 = clipBoard->GetComptonCosTheta1();
525 const G4double& phi1 = clipBoard->GetComptonPhi1();
526 // For clarity make aliases for the current cos(theta),phi.
527 const G4double& cosTheta2 = cosTheta;
528 G4double& phi2 = phi;
529 // G4cout << "cosTheta1,phi1: " << cosTheta1 << ',' << phi1 << G4endl;
530 // G4cout << "cosTheta2,phi2: " << cosTheta2 << ',' << phi2 << G4endl;
531
532 // Re-sample phi
533 // Draw the difference of azimuthal angles, deltaPhi, from
534 // A + B * cos(2*deltaPhi), or rather C + D * cos(2*deltaPhi), where
535 // C = A / (A + |B|) and D = B / (A + |B|), so that maximum is 1.
536 const G4double sin2Theta1 = 1.-cosTheta1*cosTheta1;
537 const G4double sin2Theta2 = 1.-cosTheta2*cosTheta2;
538
539 // Pryce and Ward, Nature No 4065 (1947) p.435.
540 auto* g4Pow = G4Pow::GetInstance();
541 const G4double A =
542 ((g4Pow->powN(1.-cosTheta1,3))+2.)*(g4Pow->powN(1.-cosTheta2,3)+2.)/
543 ((g4Pow->powN(2.-cosTheta1,3)*g4Pow->powN(2.-cosTheta2,3)));
544 const G4double B = -(sin2Theta1*sin2Theta2)/
545 ((g4Pow->powN(2.-cosTheta1,2)*g4Pow->powN(2.-cosTheta2,2)));
546
547 // // Snyder et al, Physical Review 73 (1948) p.440.
548 // // (This is an alternative formulation but result is identical.)
549 // const G4double& k0 = gammaEnergy0;
550 // const G4double k1 = k0/(2.-cosTheta1);
551 // const G4double k2 = k0/(2.-cosTheta2);
552 // const G4double gamma1 = k1/k0+k0/k1;
553 // const G4double gamma2 = k2/k0+k0/k2;
554 // const G4double A1 = gamma1*gamma2-gamma1*sin2Theta2-gamma2*sin2Theta1;
555 // const G4double B1 = 2.*sin2Theta1*sin2Theta2;
556 // // That's A1 + B1*sin2(deltaPhi) = A1 + B1*(0.5*(1.-cos(2.*deltaPhi).
557 // const G4double A = A1 + 0.5*B1;
558 // const G4double B = -0.5*B1;
559
560 const G4double maxValue = A + std::abs(B);
561 const G4double C = A / maxValue;
562 const G4double D = B / maxValue;
563 // G4cout << "A,B,C,D: " << A << ',' << B << ',' << C << ',' << D << G4endl;
564
565 // Sample delta phi
566 G4double deltaPhi;
567 const G4int maxCount = 999999;
568 G4int iCount = 0;
569 for (; iCount < maxCount; ++iCount) {
570 deltaPhi = twopi * G4UniformRand();
571 if (G4UniformRand() < C + D * cos(2.*deltaPhi)) break;
572 }
573 if (iCount >= maxCount ) {
574 G4cout << "G4LivermorePolarizedComptonModel::SampleSecondaries: "
575 << "Re-sampled delta phi not found in " << maxCount
576 << " tries - carrying on anyway." << G4endl;
577 }
578
579 // Thus, the desired second photon azimuth
580 phi2 = deltaPhi - phi1 + halfpi;
581 // The minus sign is in above statement because, since the two
582 // annihilation photons are in opposite directions, their phi's
583 // are measured in the opposite direction.
584 // halfpi is added for the following reason:
585 // In this function phi is relative to the polarisation - see
586 // SystemOfRefChange below. We know from G4eplusAnnihilation that
587 // the polarisations of the two annihilation photons are perpendicular
588 // to each other, i.e., halfpi different.
589 // Furthermore, only sin(phi) and cos(phi) are used below so no
590 // need to place any range constraints.
591 // if (phi2 > pi) {
592 // phi2 -= twopi;
593 // }
594 // if (phi2 < -pi) {
595 // phi2 += twopi;
596 // }
597 }
598 }
599 }
600 }
601 }
602
603 // End of entanglement
604
605 G4double dirx = sinTheta*std::cos(phi);
606 G4double diry = sinTheta*std::sin(phi);
607 G4double dirz = cosTheta ;
608
609 // oneCosT , eom
610
611 // Doppler broadening - Method based on:
612 // Y. Namito, S. Ban and H. Hirayama,
613 // "Implementation of the Doppler Broadening of a Compton-Scattered Photon Into the EGS4 Code"
614 // NIM A 349, pp. 489-494, 1994
615
616 // Maximum number of sampling iterations
617 static G4int maxDopplerIterations = 1000;
618 G4double bindingE = 0.;
619 G4double photonEoriginal = epsilon * gammaEnergy0;
620 G4double photonE = -1.;
621 G4int iteration = 0;
622 G4double eMax = gammaEnergy0;
623
624 G4int shellIdx = 0;
625
626 if (verboseLevel > 3) {
627 G4cout << "Started loop to sample broading" << G4endl;
628 }
629
630 do
631 {
632 iteration++;
633 // Select shell based on shell occupancy
634 shellIdx = shellData->SelectRandomShell(Z);
635 bindingE = shellData->BindingEnergy(Z,shellIdx);
636
637 if (verboseLevel > 3) {
638 G4cout << "Shell ID= " << shellIdx
639 << " Ebind(keV)= " << bindingE/keV << G4endl;
640 }
641 eMax = gammaEnergy0 - bindingE;
642
643 // Randomly sample bound electron momentum (memento: the data set is in Atomic Units)
644 G4double pSample = profileData->RandomSelectMomentum(Z,shellIdx);
645
646 if (verboseLevel > 3) {
647 G4cout << "pSample= " << pSample << G4endl;
648 }
649 // Rescale from atomic units
650 G4double pDoppler = pSample * fine_structure_const;
651 G4double pDoppler2 = pDoppler * pDoppler;
652 G4double var2 = 1. + onecost * E0_m;
653 G4double var3 = var2*var2 - pDoppler2;
654 G4double var4 = var2 - pDoppler2 * cosTheta;
655 G4double var = var4*var4 - var3 + pDoppler2 * var3;
656 if (var > 0.)
657 {
658 G4double varSqrt = std::sqrt(var);
659 G4double scale = gammaEnergy0 / var3;
660 // Random select either root
661 if (G4UniformRand() < 0.5) photonE = (var4 - varSqrt) * scale;
662 else photonE = (var4 + varSqrt) * scale;
663 }
664 else
665 {
666 photonE = -1.;
667 }
668 } while ( iteration <= maxDopplerIterations &&
669 (photonE < 0. || photonE > eMax || photonE < eMax*G4UniformRand()) );
670
671 // End of recalculation of photon energy with Doppler broadening
672 // Revert to original if maximum number of iterations threshold has been reached
673 if (iteration >= maxDopplerIterations)
674 {
675 photonE = photonEoriginal;
676 bindingE = 0.;
677 }
678
679 gammaEnergy1 = photonE;
680
681 //
682 // update G4VParticleChange for the scattered photon
683 //
684 // New polarization
685 G4ThreeVector gammaPolarization1 = SetNewPolarization(epsilon,
686 sinThetaSqr,
687 phi,
688 cosTheta);
689
690 // Set new direction
691 G4ThreeVector tmpDirection1( dirx,diry,dirz );
692 gammaDirection1 = tmpDirection1;
693
694 // Change reference frame.
695 SystemOfRefChange(gammaDirection0,gammaDirection1,
696 gammaPolarization0,gammaPolarization1);
697
698 if (gammaEnergy1 > 0.)
699 {
700 fParticleChange->SetProposedKineticEnergy( gammaEnergy1 ) ;
701 fParticleChange->ProposeMomentumDirection( gammaDirection1 );
702 fParticleChange->ProposePolarization( gammaPolarization1 );
703 }
704 else
705 {
706 gammaEnergy1 = 0.;
707 fParticleChange->SetProposedKineticEnergy(0.) ;
708 fParticleChange->ProposeTrackStatus(fStopAndKill);
709 }
710
711 //
712 // kinematic of the scattered electron
713 //
714 G4double ElecKineEnergy = gammaEnergy0 - gammaEnergy1 -bindingE;
715
716 // SI -protection against negative final energy: no e- is created
717 // like in G4LivermoreComptonModel.cc
718 if(ElecKineEnergy < 0.0) {
719 fParticleChange->ProposeLocalEnergyDeposit(gammaEnergy0 - gammaEnergy1);
720 return;
721 }
722
723 G4double ElecMomentum = std::sqrt(ElecKineEnergy*(ElecKineEnergy+2.*electron_mass_c2));
724
725 G4ThreeVector ElecDirection((gammaEnergy0 * gammaDirection0 -
726 gammaEnergy1 * gammaDirection1) * (1./ElecMomentum));
727
728 G4DynamicParticle* dp =
729 new G4DynamicParticle (G4Electron::Electron(),ElecDirection.unit(),ElecKineEnergy) ;
730 fvect->push_back(dp);
731
732 // sample deexcitation
733 //
734 if (verboseLevel > 3) {
735 G4cout << "Started atomic de-excitation " << fAtomDeexcitation << G4endl;
736 }
737
738 if(fAtomDeexcitation && iteration < maxDopplerIterations) {
739 G4int index = couple->GetIndex();
740 if(fAtomDeexcitation->CheckDeexcitationActiveRegion(index)) {
741 std::size_t nbefore = fvect->size();
743 const G4AtomicShell* shell = fAtomDeexcitation->GetAtomicShell(Z, as);
744 fAtomDeexcitation->GenerateParticles(fvect, shell, Z, index);
745 std::size_t nafter = fvect->size();
746 if(nafter > nbefore) {
747 for (std::size_t i=nbefore; i<nafter; ++i) {
748 //Check if there is enough residual energy
749 if (bindingE >= ((*fvect)[i])->GetKineticEnergy())
750 {
751 //Ok, this is a valid secondary: keep it
752 bindingE -= ((*fvect)[i])->GetKineticEnergy();
753 }
754 else
755 {
756 //Invalid secondary: not enough energy to create it!
757 //Keep its energy in the local deposit
758 delete (*fvect)[i];
759 (*fvect)[i]=0;
760 }
761 }
762 }
763 }
764 }
765 //This should never happen
766 if(bindingE < 0.0)
767 G4Exception("G4LivermoreComptonModel::SampleSecondaries()",
768 "em2050",FatalException,"Negative local energy deposit");
769
770 fParticleChange->ProposeLocalEnergyDeposit(bindingE);
771
772}
G4double epsilon(G4double density, G4double temperature)
G4double C(G4double temp)
G4double B(G4double temperature)
G4double D(G4double temp)
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4double G4Exp(G4double initial_x)
Exponential Function double precision.
Definition G4Exp.hh:180
G4double G4Log(G4double x)
Definition G4Log.hh:227
@ fStopAndKill
const G4double A[17]
const G4double alpha2
#define G4UniformRand()
Definition Randomize.hh:52
bool isOrthogonal(const Hep3Vector &v, double epsilon=tolerance) const
double mag() const
double howOrthogonal(const Hep3Vector &v) const
virtual G4double FindValue(G4double x, G4int componentId=0) const
G4double RandomSelectMomentum(G4int Z, G4int shellIndex) const
const G4ThreeVector & GetMomentumDirection() const
G4ParticleDefinition * GetDefinition() const
G4double GetKineticEnergy() const
const G4ThreeVector & GetPolarization() const
static G4Electron * Electron()
Definition G4Electron.cc:91
G4double GetZ() const
Definition G4Element.hh:119
void SetProposedKineticEnergy(G4double proposedKinEnergy)
void ProposePolarization(const G4ThreeVector &dir)
void ProposeMomentumDirection(const G4ThreeVector &Pfinal)
static G4Pow * GetInstance()
Definition G4Pow.cc:41
G4double BindingEnergy(G4int Z, G4int shellIndex) const
G4int SelectRandomShell(G4int Z) const
G4VAuxiliaryTrackInformation * GetAuxiliaryTrackInformation(G4int id) const
Definition G4Track.cc:229
G4bool CheckDeexcitationActiveRegion(G4int coupleIndex)
virtual const G4AtomicShell * GetAtomicShell(G4int Z, G4AtomicShellEnumerator shell)=0
void GenerateParticles(std::vector< G4DynamicParticle * > *secVect, const G4AtomicShell *, G4int Z, G4int coupleIndex)
const G4Element * SelectRandomAtom(const G4MaterialCutsCouple *, const G4ParticleDefinition *, G4double kineticEnergy, G4double cutEnergy=0.0, G4double maxEnergy=DBL_MAX)
void ProposeTrackStatus(G4TrackStatus status)
const G4Track * GetCurrentTrack() const
void ProposeLocalEnergyDeposit(G4double anEnergyPart)

The documentation for this class was generated from the following files: