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

#include <G4AdjointCSManager.hh>

Public Member Functions

 ~G4AdjointCSManager ()
 
G4int GetNbProcesses ()
 
size_t RegisterEmAdjointModel (G4VEmAdjointModel *)
 
void RegisterEmProcess (G4VEmProcess *aProcess, G4ParticleDefinition *aPartDef)
 
void RegisterEnergyLossProcess (G4VEnergyLossProcess *aProcess, G4ParticleDefinition *aPartDef)
 
void RegisterAdjointParticle (G4ParticleDefinition *aPartDef)
 
void BuildCrossSectionMatrices ()
 
void BuildTotalSigmaTables ()
 
G4double GetTotalAdjointCS (G4ParticleDefinition *aPartDef, G4double Ekin, const G4MaterialCutsCouple *aCouple)
 
G4double GetTotalForwardCS (G4ParticleDefinition *aPartDef, G4double Ekin, const G4MaterialCutsCouple *aCouple)
 
G4double GetAdjointSigma (G4double Ekin_nuc, size_t index_model, G4bool is_scat_proj_to_proj, const G4MaterialCutsCouple *aCouple)
 
void GetEminForTotalCS (G4ParticleDefinition *aPartDef, const G4MaterialCutsCouple *aCouple, G4double &emin_adj, G4double &emin_fwd)
 
void GetMaxFwdTotalCS (G4ParticleDefinition *aPartDef, const G4MaterialCutsCouple *aCouple, G4double &e_sigma_max, G4double &sigma_max)
 
void GetMaxAdjTotalCS (G4ParticleDefinition *aPartDef, const G4MaterialCutsCouple *aCouple, G4double &e_sigma_max, G4double &sigma_max)
 
G4double GetCrossSectionCorrection (G4ParticleDefinition *aPartDef, G4double PreStepEkin, const G4MaterialCutsCouple *aCouple, G4bool &fwd_is_used, G4double &fwd_TotCS)
 
void SetFwdCrossSectionMode (G4bool aBool)
 
G4double GetContinuousWeightCorrection (G4ParticleDefinition *aPartDef, G4double PreStepEkin, G4double AfterStepEkin, const G4MaterialCutsCouple *aCouple, G4double step_length)
 
G4double GetPostStepWeightCorrection ()
 
G4double ComputeAdjointCS (G4Material *aMaterial, G4VEmAdjointModel *aModel, G4double PrimEnergy, G4double Tcut, G4bool IsScatProjToProjCase, std::vector< G4double > &AdjointCS_for_each_element)
 
G4ElementSampleElementFromCSMatrices (G4Material *aMaterial, G4VEmAdjointModel *aModel, G4double PrimEnergy, G4double Tcut, G4bool IsScatProjToProjCase)
 
G4double ComputeTotalAdjointCS (const G4MaterialCutsCouple *aMatCutCouple, G4ParticleDefinition *aPart, G4double PrimEnergy)
 
G4ParticleDefinitionGetAdjointParticleEquivalent (G4ParticleDefinition *theFwdPartDef)
 
G4ParticleDefinitionGetForwardParticleEquivalent (G4ParticleDefinition *theAdjPartDef)
 
void SetTmin (G4double aVal)
 
void SetTmax (G4double aVal)
 
void SetNbins (G4int aInt)
 
void SetIon (G4ParticleDefinition *adjIon, G4ParticleDefinition *fwdIon)
 

Static Public Member Functions

static G4AdjointCSManagerGetAdjointCSManager ()
 

Friends

class G4ThreadLocalSingleton< G4AdjointCSManager >
 

Detailed Description

Definition at line 68 of file G4AdjointCSManager.hh.

Constructor & Destructor Documentation

◆ ~G4AdjointCSManager()

G4AdjointCSManager::~G4AdjointCSManager ( )

Definition at line 117 of file G4AdjointCSManager.cc.

118{;
119}

Member Function Documentation

◆ BuildCrossSectionMatrices()

void G4AdjointCSManager::BuildCrossSectionMatrices ( )

Definition at line 181 of file G4AdjointCSManager.cc.

182{
183 if (CrossSectionMatrixesAreBuilt) return;
184 //Tcut, Tmax
185 //The matrices will be computed probably just once
186 //When Tcut will change some PhysicsTable will be recomputed
187 // for each MaterialCutCouple but not all the matrices
188 //The Tcut defines a lower limit in the energy of the Projectile before the scattering
189 //In the Projectile to Scattered Projectile case we have
190 // E_ScatProj<E_Proj-Tcut
191 //Therefore in the adjoint case we have
192 // Eproj> E_ScatProj+Tcut
193 //This implies that when computing the adjoint CS we should integrate over Epro
194 // from E_ScatProj+Tcut to Emax
195 //In the Projectile to Secondary case Tcut plays a role only in the fact that
196 // Esecond should be greater than Tcut to have the possibility to have any adjoint
197 //process
198 //To avoid to recompute the matrices for all changes of MaterialCutCouple
199 //We propose to compute the matrices only once for the minimum possible Tcut and then
200 //to interpolate the probability for a new Tcut (implemented in G4VAdjointEmModel)
201
202
203 theAdjointCSMatricesForScatProjToProj.clear();
204 theAdjointCSMatricesForProdToProj.clear();
205 const G4ElementTable* theElementTable = G4Element::GetElementTable();
206 const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
207
208 G4cout<<"========== Computation of cross section matrices for adjoint models =========="<<G4endl;
209 for (size_t i=0; i<listOfAdjointEMModel.size();i++){
210 G4VEmAdjointModel* aModel =listOfAdjointEMModel[i];
211 G4cout<<"Build adjoint cross section matrices for "<<aModel->GetName()<<G4endl;
212 if (aModel->GetUseMatrix()){
213 std::vector<G4AdjointCSMatrix*>* aListOfMat1 = new std::vector<G4AdjointCSMatrix*>();
214 std::vector<G4AdjointCSMatrix*>* aListOfMat2 = new std::vector<G4AdjointCSMatrix*>();
215 aListOfMat1->clear();
216 aListOfMat2->clear();
217 if (aModel->GetUseMatrixPerElement()){
219 std::vector<G4AdjointCSMatrix*>
220 two_matrices=BuildCrossSectionsMatricesForAGivenModelAndElement(aModel,1, 1, 80);
221 aListOfMat1->push_back(two_matrices[0]);
222 aListOfMat2->push_back(two_matrices[1]);
223 }
224 else {
225 for (size_t j=0; j<theElementTable->size();j++){
226 G4Element* anElement=(*theElementTable)[j];
227 G4int Z = G4lrint(anElement->GetZ());
228 G4int A = G4lrint(anElement->GetN());
229 std::vector<G4AdjointCSMatrix*>
230 two_matrices=BuildCrossSectionsMatricesForAGivenModelAndElement(aModel,Z, A, 40);
231 aListOfMat1->push_back(two_matrices[0]);
232 aListOfMat2->push_back(two_matrices[1]);
233 }
234 }
235 }
236 else { //Per material case
237 for (size_t j=0; j<theMaterialTable->size();j++){
238 G4Material* aMaterial=(*theMaterialTable)[j];
239 std::vector<G4AdjointCSMatrix*>
240 two_matrices=BuildCrossSectionsMatricesForAGivenModelAndMaterial(aModel,aMaterial, 40);
241 aListOfMat1->push_back(two_matrices[0]);
242 aListOfMat2->push_back(two_matrices[1]);
243 }
244
245 }
246 theAdjointCSMatricesForProdToProj.push_back(*aListOfMat1);
247 theAdjointCSMatricesForScatProjToProj.push_back(*aListOfMat2);
248 aModel->SetCSMatrices(aListOfMat1, aListOfMat2);
249 }
250 else { G4cout<<"The model "<<aModel->GetName()<<" does not use cross section matrices"<<G4endl;
251 std::vector<G4AdjointCSMatrix*> two_empty_matrices;
252 theAdjointCSMatricesForProdToProj.push_back(two_empty_matrices);
253 theAdjointCSMatricesForScatProjToProj.push_back(two_empty_matrices);
254
255 }
256 }
257 G4cout<<" All adjoint cross section matrices are computed!"<<G4endl;
258 G4cout<<"======================================================================"<<G4endl;
259
260 CrossSectionMatrixesAreBuilt = true;
261
262
263}
double A(double temperature)
std::vector< G4Element * > G4ElementTable
std::vector< G4Material * > G4MaterialTable
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
static G4ElementTable * GetElementTable()
Definition: G4Element.cc:397
G4double GetZ() const
Definition: G4Element.hh:130
G4double GetN() const
Definition: G4Element.hh:134
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:637
void SetCSMatrices(std::vector< G4AdjointCSMatrix * > *Vec1CSMatrix, std::vector< G4AdjointCSMatrix * > *Vec2CSMatrix)
G4bool GetUseOnlyOneMatrixForAllElements()
int G4lrint(double ad)
Definition: templates.hh:134

Referenced by G4AdjointForcedInteractionForGamma::BuildPhysicsTable(), and G4VAdjointReverseReaction::BuildPhysicsTable().

◆ BuildTotalSigmaTables()

void G4AdjointCSManager::BuildTotalSigmaTables ( )

Definition at line 268 of file G4AdjointCSManager.cc.

269{ if (TotalSigmaTableAreBuilt) return;
270
271
273
274
275 //Prepare the Sigma table for all AdjointEMModel, will be filled later on
276 for (size_t i=0; i<listOfAdjointEMModel.size();i++){
277 listSigmaTableForAdjointModelScatProjToProj[i]->clearAndDestroy();
278 listSigmaTableForAdjointModelProdToProj[i]->clearAndDestroy();
279 for (size_t j=0;j<theCoupleTable->GetTableSize();j++){
280 listSigmaTableForAdjointModelScatProjToProj[i]->push_back(new G4PhysicsLogVector(Tmin, Tmax, nbins));
281 listSigmaTableForAdjointModelProdToProj[i]->push_back(new G4PhysicsLogVector(Tmin, Tmax, nbins));
282 }
283 }
284
285
286
287 for (size_t i=0;i<theListOfAdjointParticlesInAction.size();i++){
288 G4ParticleDefinition* thePartDef = theListOfAdjointParticlesInAction[i];
289 DefineCurrentParticle(thePartDef);
290 theTotalForwardSigmaTableVector[i]->clearAndDestroy();
291 theTotalAdjointSigmaTableVector[i]->clearAndDestroy();
292 EminForFwdSigmaTables[i].clear();
293 EminForAdjSigmaTables[i].clear();
294 EkinofFwdSigmaMax[i].clear();
295 EkinofAdjSigmaMax[i].clear();
296 //G4cout<<thePartDef->GetParticleName();
297
298 for (size_t j=0;j<theCoupleTable->GetTableSize();j++){
299 const G4MaterialCutsCouple* couple = theCoupleTable->GetMaterialCutsCouple(j);
300
301 /*
302 G4String file_name1=couple->GetMaterial()->GetName()+"_"+thePartDef->GetParticleName()+"_adj_totCS.txt";
303 G4String file_name2=couple->GetMaterial()->GetName()+"_"+thePartDef->GetParticleName()+"_fwd_totCS.txt";
304
305 std::fstream FileOutputAdjCS(file_name1, std::ios::out);
306 std::fstream FileOutputFwdCS(file_name2, std::ios::out);
307
308
309
310 FileOutputAdjCS<<std::setiosflags(std::ios::scientific);
311 FileOutputAdjCS<<std::setprecision(6);
312 FileOutputFwdCS<<std::setiosflags(std::ios::scientific);
313 FileOutputFwdCS<<std::setprecision(6);
314 */
315
316
317 //make first the total fwd CS table for FwdProcess
318 G4PhysicsVector* aVector = new G4PhysicsLogVector(Tmin, Tmax, nbins);
319 G4bool Emin_found=false;
320 G4double sigma_max =0.;
321 G4double e_sigma_max =0.;
322 for(size_t l=0; l<aVector->GetVectorLength(); l++) {
323 G4double totCS=0.;
324 G4double e=aVector->GetLowEdgeEnergy(l);
325 for (size_t k=0; k<listOfForwardEmProcess[i]->size(); k++){
326 totCS+=(*listOfForwardEmProcess[i])[k]->GetLambda(e, couple);
327 }
328 for (size_t k=0; k<listOfForwardEnergyLossProcess[i]->size(); k++){
329 if (thePartDef == theAdjIon) { // e is considered already as the scaled energy
330 size_t mat_index = couple->GetIndex();
331 G4VEmModel* currentModel = (*listOfForwardEnergyLossProcess[i])[k]->SelectModelForMaterial(e,mat_index);
332 G4double chargeSqRatio = currentModel->GetChargeSquareRatio(theFwdIon,couple->GetMaterial(),e/massRatio);
333 (*listOfForwardEnergyLossProcess[i])[k]->SetDynamicMassCharge(massRatio,chargeSqRatio);
334 }
335 G4double e1=e/massRatio;
336 totCS+=(*listOfForwardEnergyLossProcess[i])[k]->GetLambda(e1, couple);
337 }
338 aVector->PutValue(l,totCS);
339 if (totCS>sigma_max){
340 sigma_max=totCS;
341 e_sigma_max = e;
342
343 }
344 //FileOutputFwdCS<<e<<'\t'<<totCS<<G4endl;
345
346 if (totCS>0 && !Emin_found) {
347 EminForFwdSigmaTables[i].push_back(e);
348 Emin_found=true;
349 }
350
351
352 }
353 //FileOutputFwdCS.close();
354
355 EkinofFwdSigmaMax[i].push_back(e_sigma_max);
356
357
358 if(!Emin_found) EminForFwdSigmaTables[i].push_back(Tmax);
359
360 theTotalForwardSigmaTableVector[i]->push_back(aVector);
361
362
363 Emin_found=false;
364 sigma_max=0;
365 e_sigma_max =0.;
366 G4PhysicsVector* aVector1 = new G4PhysicsLogVector(Tmin, Tmax, nbins);
367 for(eindex=0; eindex<aVector->GetVectorLength(); eindex++) {
368 G4double e=aVector->GetLowEdgeEnergy(eindex);
369 G4double totCS =ComputeTotalAdjointCS(couple,thePartDef,e*0.9999999/massRatio); //massRatio needed for ions
370 aVector1->PutValue(eindex,totCS);
371 if (totCS>sigma_max){
372 sigma_max=totCS;
373 e_sigma_max = e;
374
375 }
376 //FileOutputAdjCS<<e<<'\t'<<totCS<<G4endl;
377 if (totCS>0 && !Emin_found) {
378 EminForAdjSigmaTables[i].push_back(e);
379 Emin_found=true;
380 }
381
382 }
383 //FileOutputAdjCS.close();
384 EkinofAdjSigmaMax[i].push_back(e_sigma_max);
385 if(!Emin_found) EminForAdjSigmaTables[i].push_back(Tmax);
386
387 theTotalAdjointSigmaTableVector[i]->push_back(aVector1);
388
389 }
390 }
391 TotalSigmaTableAreBuilt =true;
392
393}
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
G4double ComputeTotalAdjointCS(const G4MaterialCutsCouple *aMatCutCouple, G4ParticleDefinition *aPart, G4double PrimEnergy)
const G4Material * GetMaterial() const
G4double GetLowEdgeEnergy(std::size_t binNumber) const
void PutValue(std::size_t index, G4double theValue)
std::size_t GetVectorLength() const
const G4MaterialCutsCouple * GetMaterialCutsCouple(G4int i) const
std::size_t GetTableSize() const
static G4ProductionCutsTable * GetProductionCutsTable()
virtual G4double GetChargeSquareRatio(const G4ParticleDefinition *, const G4Material *, G4double kineticEnergy)
Definition: G4VEmModel.cc:391

Referenced by G4AdjointForcedInteractionForGamma::BuildPhysicsTable(), and G4VAdjointReverseReaction::BuildPhysicsTable().

◆ ComputeAdjointCS()

G4double G4AdjointCSManager::ComputeAdjointCS ( G4Material aMaterial,
G4VEmAdjointModel aModel,
G4double  PrimEnergy,
G4double  Tcut,
G4bool  IsScatProjToProjCase,
std::vector< G4double > &  AdjointCS_for_each_element 
)

Definition at line 533 of file G4AdjointCSManager.cc.

539{
540
541 G4double EminSec=0;
542 G4double EmaxSec=0;
543
544 if (IsScatProjToProjCase){
545 EminSec= aModel->GetSecondAdjEnergyMinForScatProjToProjCase(PrimEnergy,Tcut);
546 EmaxSec= aModel->GetSecondAdjEnergyMaxForScatProjToProjCase(PrimEnergy);
547 }
548 else if (PrimEnergy > Tcut || !aModel->GetApplyCutInRange()) {
549 EminSec= aModel->GetSecondAdjEnergyMinForProdToProjCase(PrimEnergy);
550 EmaxSec= aModel->GetSecondAdjEnergyMaxForProdToProjCase(PrimEnergy);
551 }
552 if (EminSec >= EmaxSec) return 0.;
553
554
555 G4bool need_to_compute=false;
556 if ( aMaterial!= lastMaterial || PrimEnergy != lastPrimaryEnergy || Tcut != lastTcut){
557 lastMaterial =aMaterial;
558 lastPrimaryEnergy = PrimEnergy;
559 lastTcut=Tcut;
560 listOfIndexOfAdjointEMModelInAction.clear();
561 listOfIsScatProjToProjCase.clear();
562 lastAdjointCSVsModelsAndElements.clear();
563 need_to_compute=true;
564
565 }
566 size_t ind=0;
567 if (!need_to_compute){
568 need_to_compute=true;
569 for (size_t i=0;i<listOfIndexOfAdjointEMModelInAction.size();i++){
570 size_t ind1=listOfIndexOfAdjointEMModelInAction[i];
571 if (aModel == listOfAdjointEMModel[ind1] && IsScatProjToProjCase == listOfIsScatProjToProjCase[i]){
572 need_to_compute=false;
573 CS_Vs_Element = lastAdjointCSVsModelsAndElements[ind];
574 }
575 ind++;
576 }
577 }
578
579 if (need_to_compute){
580 size_t ind_model=0;
581 for (size_t i=0;i<listOfAdjointEMModel.size();i++){
582 if (aModel == listOfAdjointEMModel[i]){
583 ind_model=i;
584 break;
585 }
586 }
587 G4double Tlow=Tcut;
588 if (!listOfAdjointEMModel[ind_model]->GetApplyCutInRange()) Tlow =listOfAdjointEMModel[ind_model]->GetLowEnergyLimit();
589 listOfIndexOfAdjointEMModelInAction.push_back(ind_model);
590 listOfIsScatProjToProjCase.push_back(IsScatProjToProjCase);
591 CS_Vs_Element.clear();
592 if (!aModel->GetUseMatrix()){
593 CS_Vs_Element.push_back(aModel->AdjointCrossSection(currentCouple,PrimEnergy,IsScatProjToProjCase));
594
595
596 }
597 else if (aModel->GetUseMatrixPerElement()){
598 size_t n_el = aMaterial->GetNumberOfElements();
600 G4AdjointCSMatrix* theCSMatrix;
601 if (IsScatProjToProjCase){
602 theCSMatrix=theAdjointCSMatricesForScatProjToProj[ind_model][0];
603 }
604 else theCSMatrix=theAdjointCSMatricesForProdToProj[ind_model][0];
605 G4double CS =0.;
606 if (PrimEnergy > Tlow)
607 CS = ComputeAdjointCS(PrimEnergy,theCSMatrix,Tlow);
608 G4double factor=0.;
609 for (size_t i=0;i<n_el;i++){ //this could be computed only once
610 //size_t ind_el = aMaterial->GetElement(i)->GetIndex();
611 factor+=aMaterial->GetElement(i)->GetZ()*aMaterial->GetVecNbOfAtomsPerVolume()[i];
612 }
613 CS *=factor;
614 CS_Vs_Element.push_back(CS);
615
616 }
617 else {
618 for (size_t i=0;i<n_el;i++){
619 size_t ind_el = aMaterial->GetElement(i)->GetIndex();
620 //G4cout<<aMaterial->GetName()<<G4endl;
621 G4AdjointCSMatrix* theCSMatrix;
622 if (IsScatProjToProjCase){
623 theCSMatrix=theAdjointCSMatricesForScatProjToProj[ind_model][ind_el];
624 }
625 else theCSMatrix=theAdjointCSMatricesForProdToProj[ind_model][ind_el];
626 G4double CS =0.;
627 if (PrimEnergy > Tlow)
628 CS = ComputeAdjointCS(PrimEnergy,theCSMatrix,Tlow);
629 //G4cout<<CS<<G4endl;
630 CS_Vs_Element.push_back(CS*(aMaterial->GetVecNbOfAtomsPerVolume()[i]));
631 }
632 }
633
634 }
635 else {
636 size_t ind_mat = aMaterial->GetIndex();
637 G4AdjointCSMatrix* theCSMatrix;
638 if (IsScatProjToProjCase){
639 theCSMatrix=theAdjointCSMatricesForScatProjToProj[ind_model][ind_mat];
640 }
641 else theCSMatrix=theAdjointCSMatricesForProdToProj[ind_model][ind_mat];
642 G4double CS =0.;
643 if (PrimEnergy > Tlow)
644 CS = ComputeAdjointCS(PrimEnergy,theCSMatrix,Tlow);
645 CS_Vs_Element.push_back(CS);
646
647
648 }
649 lastAdjointCSVsModelsAndElements.push_back(CS_Vs_Element);
650
651 }
652
653
654 G4double CS=0;
655 for (size_t i=0;i<CS_Vs_Element.size();i++){
656 CS+=CS_Vs_Element[i]; //We could put the progressive sum of the CS instead of the CS of an element itself
657
658 }
659 return CS;
660}
G4double ComputeAdjointCS(G4Material *aMaterial, G4VEmAdjointModel *aModel, G4double PrimEnergy, G4double Tcut, G4bool IsScatProjToProjCase, std::vector< G4double > &AdjointCS_for_each_element)
size_t GetIndex() const
Definition: G4Element.hh:181
const G4Element * GetElement(G4int iel) const
Definition: G4Material.hh:200
size_t GetNumberOfElements() const
Definition: G4Material.hh:184
const G4double * GetVecNbOfAtomsPerVolume() const
Definition: G4Material.hh:204
size_t GetIndex() const
Definition: G4Material.hh:258
virtual G4double GetSecondAdjEnergyMaxForProdToProjCase(G4double PrimAdjEnergy)
virtual G4double GetSecondAdjEnergyMaxForScatProjToProjCase(G4double PrimAdjEnergy)
virtual G4double GetSecondAdjEnergyMinForProdToProjCase(G4double PrimAdjEnergy)
virtual G4double AdjointCrossSection(const G4MaterialCutsCouple *aCouple, G4double primEnergy, G4bool IsScatProjToProjCase)
virtual G4double GetSecondAdjEnergyMinForScatProjToProjCase(G4double PrimAdjEnergy, G4double Tcut=0)

Referenced by G4VEmAdjointModel::AdjointCrossSection(), ComputeAdjointCS(), ComputeTotalAdjointCS(), and SampleElementFromCSMatrices().

◆ ComputeTotalAdjointCS()

G4double G4AdjointCSManager::ComputeTotalAdjointCS ( const G4MaterialCutsCouple aMatCutCouple,
G4ParticleDefinition aPart,
G4double  PrimEnergy 
)

Definition at line 688 of file G4AdjointCSManager.cc.

691{
692 G4double TotalCS=0.;
693
694 DefineCurrentMaterial(aCouple);
695
696
697 std::vector<G4double> CS_Vs_Element;
698 G4double CS;
699 for (size_t i=0; i<listOfAdjointEMModel.size();i++){
700
701 G4double Tlow=0;
702 if (!listOfAdjointEMModel[i]->GetApplyCutInRange()) Tlow =listOfAdjointEMModel[i]->GetLowEnergyLimit();
703 else {
704 G4ParticleDefinition* theDirSecondPartDef =
705 GetForwardParticleEquivalent(listOfAdjointEMModel[i]->GetAdjointEquivalentOfDirectSecondaryParticleDefinition());
706 size_t idx=56;
707 if (theDirSecondPartDef->GetParticleName() == "gamma") idx = 0;
708 else if (theDirSecondPartDef->GetParticleName() == "e-") idx = 1;
709 else if (theDirSecondPartDef->GetParticleName() == "e+") idx = 2;
710 if (idx <56) {
711 const std::vector<G4double>* aVec = G4ProductionCutsTable::GetProductionCutsTable()->GetEnergyCutsVector(idx);
712 Tlow =(*aVec)[aCouple->GetIndex()];
713 }
714
715
716 }
717 if ( Ekin<=listOfAdjointEMModel[i]->GetHighEnergyLimit() && Ekin>=listOfAdjointEMModel[i]->GetLowEnergyLimit()){
718 if (aPartDef == listOfAdjointEMModel[i]->GetAdjointEquivalentOfDirectPrimaryParticleDefinition()){
719 CS=ComputeAdjointCS(currentMaterial,
720 listOfAdjointEMModel[i],
721 Ekin, Tlow,true,CS_Vs_Element);
722 TotalCS += CS;
723 (*listSigmaTableForAdjointModelScatProjToProj[i])[currentMatIndex]->PutValue(eindex,CS);
724 }
725 if (aPartDef == listOfAdjointEMModel[i]->GetAdjointEquivalentOfDirectSecondaryParticleDefinition()){
726 CS = ComputeAdjointCS(currentMaterial,
727 listOfAdjointEMModel[i],
728 Ekin, Tlow,false, CS_Vs_Element);
729 TotalCS += CS;
730 (*listSigmaTableForAdjointModelProdToProj[i])[currentMatIndex]->PutValue(eindex,CS);
731 }
732
733 }
734 else {
735 (*listSigmaTableForAdjointModelScatProjToProj[i])[currentMatIndex]->PutValue(eindex,0.);
736 (*listSigmaTableForAdjointModelProdToProj[i])[currentMatIndex]->PutValue(eindex,0.);
737
738 }
739 }
740 return TotalCS;
741
742
743}
G4ParticleDefinition * GetForwardParticleEquivalent(G4ParticleDefinition *theAdjPartDef)
const G4String & GetParticleName() const
const std::vector< G4double > * GetEnergyCutsVector(std::size_t pcIdx) const

Referenced by BuildTotalSigmaTables().

◆ GetAdjointCSManager()

◆ GetAdjointParticleEquivalent()

G4ParticleDefinition * G4AdjointCSManager::GetAdjointParticleEquivalent ( G4ParticleDefinition theFwdPartDef)

Definition at line 948 of file G4AdjointCSManager.cc.

949{
950 if (theFwdPartDef->GetParticleName() == "e-") return G4AdjointElectron::AdjointElectron();
951 else if (theFwdPartDef->GetParticleName() == "gamma") return G4AdjointGamma::AdjointGamma();
952 else if (theFwdPartDef->GetParticleName() == "proton") return G4AdjointProton::AdjointProton();
953 else if (theFwdPartDef ==theFwdIon) return theAdjIon;
954
955 return 0;
956}
static G4AdjointElectron * AdjointElectron()
static G4AdjointGamma * AdjointGamma()
static G4AdjointProton * AdjointProton()

Referenced by RegisterEmProcess(), and RegisterEnergyLossProcess().

◆ GetAdjointSigma()

G4double G4AdjointCSManager::GetAdjointSigma ( G4double  Ekin_nuc,
size_t  index_model,
G4bool  is_scat_proj_to_proj,
const G4MaterialCutsCouple aCouple 
)

Definition at line 419 of file G4AdjointCSManager.cc.

421{ DefineCurrentMaterial(aCouple);
422 G4bool b;
423 if (is_scat_proj_to_proj) return (((*listSigmaTableForAdjointModelScatProjToProj[index_model])[currentMatIndex])->GetValue(Ekin_nuc, b));
424 else return (((*listSigmaTableForAdjointModelProdToProj[index_model])[currentMatIndex])->GetValue(Ekin_nuc, b));
425}

◆ GetContinuousWeightCorrection()

G4double G4AdjointCSManager::GetContinuousWeightCorrection ( G4ParticleDefinition aPartDef,
G4double  PreStepEkin,
G4double  AfterStepEkin,
const G4MaterialCutsCouple aCouple,
G4double  step_length 
)

Definition at line 503 of file G4AdjointCSManager.cc.

505{ G4double corr_fac = 1.;
506 //return corr_fac;
507 //G4double after_adjCS = GetTotalAdjointCS(aPartDef, AfterStepEkin,aCouple);
508 G4double after_fwdCS = GetTotalForwardCS(aPartDef, AfterStepEkin,aCouple);
509 G4double pre_adjCS = GetTotalAdjointCS(aPartDef, PreStepEkin,aCouple);
510 if (!forward_CS_is_used || pre_adjCS ==0. || after_fwdCS==0.) {
511 forward_CS_is_used=false;
512 G4double pre_fwdCS = GetTotalForwardCS(aPartDef, PreStepEkin,aCouple);
513 corr_fac *=std::exp((pre_adjCS-pre_fwdCS)*step_length);
514 LastCSCorrectionFactor = 1.;
515 }
516 else {
517 LastCSCorrectionFactor = after_fwdCS/pre_adjCS;
518 }
519
520
521
522 return corr_fac;
523}
G4double GetTotalForwardCS(G4ParticleDefinition *aPartDef, G4double Ekin, const G4MaterialCutsCouple *aCouple)
G4double GetTotalAdjointCS(G4ParticleDefinition *aPartDef, G4double Ekin, const G4MaterialCutsCouple *aCouple)

Referenced by G4AdjointAlongStepWeightCorrection::AlongStepDoIt().

◆ GetCrossSectionCorrection()

G4double G4AdjointCSManager::GetCrossSectionCorrection ( G4ParticleDefinition aPartDef,
G4double  PreStepEkin,
const G4MaterialCutsCouple aCouple,
G4bool fwd_is_used,
G4double fwd_TotCS 
)

Definition at line 466 of file G4AdjointCSManager.cc.

468{ G4double corr_fac = 1.;
469 if (forward_CS_mode && aPartDef ) {
470 fwd_TotCS=PrefwdCS;
471 if (LastEkinForCS != PreStepEkin || aPartDef != lastPartDefForCS || aCouple!=currentCouple) {
472 DefineCurrentMaterial(aCouple);
473 PreadjCS = GetTotalAdjointCS(aPartDef, PreStepEkin,aCouple);
474 PrefwdCS = GetTotalForwardCS(aPartDef, PreStepEkin,aCouple);
475 LastEkinForCS = PreStepEkin;
476 lastPartDefForCS = aPartDef;
477 if (PrefwdCS >0. && PreadjCS >0.) {
478 forward_CS_is_used = true;
479 LastCSCorrectionFactor = PrefwdCS/PreadjCS;
480 }
481 else {
482 forward_CS_is_used = false;
483 LastCSCorrectionFactor = 1.;
484
485 }
486
487 }
488 corr_fac =LastCSCorrectionFactor;
489
490
491
492 }
493 else {
494 forward_CS_is_used = false;
495 LastCSCorrectionFactor = 1.;
496 }
497 fwd_TotCS=PrefwdCS;
498 fwd_is_used = forward_CS_is_used;
499 return corr_fac;
500}

Referenced by G4VAdjointReverseReaction::GetMeanFreePath().

◆ GetEminForTotalCS()

void G4AdjointCSManager::GetEminForTotalCS ( G4ParticleDefinition aPartDef,
const G4MaterialCutsCouple aCouple,
G4double emin_adj,
G4double emin_fwd 
)

Definition at line 428 of file G4AdjointCSManager.cc.

430{ DefineCurrentMaterial(aCouple);
431 DefineCurrentParticle(aPartDef);
432 emin_adj = EminForAdjSigmaTables[currentParticleIndex][currentMatIndex]/massRatio;
433 emin_fwd = EminForFwdSigmaTables[currentParticleIndex][currentMatIndex]/massRatio;
434
435
436
437}

◆ GetForwardParticleEquivalent()

G4ParticleDefinition * G4AdjointCSManager::GetForwardParticleEquivalent ( G4ParticleDefinition theAdjPartDef)

Definition at line 959 of file G4AdjointCSManager.cc.

960{
961 if (theAdjPartDef->GetParticleName() == "adj_e-") return G4Electron::Electron();
962 else if (theAdjPartDef->GetParticleName() == "adj_gamma") return G4Gamma::Gamma();
963 else if (theAdjPartDef->GetParticleName() == "adj_proton") return G4Proton::Proton();
964 else if (theAdjPartDef == theAdjIon) return theFwdIon;
965 return 0;
966}
static G4Electron * Electron()
Definition: G4Electron.cc:93
static G4Gamma * Gamma()
Definition: G4Gamma.cc:85
static G4Proton * Proton()
Definition: G4Proton.cc:92

Referenced by ComputeTotalAdjointCS().

◆ GetMaxAdjTotalCS()

void G4AdjointCSManager::GetMaxAdjTotalCS ( G4ParticleDefinition aPartDef,
const G4MaterialCutsCouple aCouple,
G4double e_sigma_max,
G4double sigma_max 
)

Definition at line 453 of file G4AdjointCSManager.cc.

455{ DefineCurrentMaterial(aCouple);
456 DefineCurrentParticle(aPartDef);
457 e_sigma_max = EkinofAdjSigmaMax[currentParticleIndex][currentMatIndex];
458 G4bool b;
459 sigma_max =((*theTotalAdjointSigmaTableVector[currentParticleIndex])[currentMatIndex])->GetValue(e_sigma_max, b);
460 e_sigma_max/=massRatio;
461
462
463}

◆ GetMaxFwdTotalCS()

void G4AdjointCSManager::GetMaxFwdTotalCS ( G4ParticleDefinition aPartDef,
const G4MaterialCutsCouple aCouple,
G4double e_sigma_max,
G4double sigma_max 
)

Definition at line 440 of file G4AdjointCSManager.cc.

442{ DefineCurrentMaterial(aCouple);
443 DefineCurrentParticle(aPartDef);
444 e_sigma_max = EkinofFwdSigmaMax[currentParticleIndex][currentMatIndex];
445 G4bool b;
446 sigma_max =((*theTotalForwardSigmaTableVector[currentParticleIndex])[currentMatIndex])->GetValue(e_sigma_max, b);
447 e_sigma_max/=massRatio;
448
449
450}

◆ GetNbProcesses()

G4int G4AdjointCSManager::GetNbProcesses ( )

◆ GetPostStepWeightCorrection()

◆ GetTotalAdjointCS()

G4double G4AdjointCSManager::GetTotalAdjointCS ( G4ParticleDefinition aPartDef,
G4double  Ekin,
const G4MaterialCutsCouple aCouple 
)

Definition at line 396 of file G4AdjointCSManager.cc.

398{ DefineCurrentMaterial(aCouple);
399 DefineCurrentParticle(aPartDef);
400 G4bool b;
401 return (((*theTotalAdjointSigmaTableVector[currentParticleIndex])[currentMatIndex])->GetValue(Ekin*massRatio, b));
402
403
404
405}

Referenced by G4AdjointForcedInteractionForGamma::AlongStepDoIt(), GetContinuousWeightCorrection(), GetCrossSectionCorrection(), and G4AdjointForcedInteractionForGamma::PostStepGetPhysicalInteractionLength().

◆ GetTotalForwardCS()

G4double G4AdjointCSManager::GetTotalForwardCS ( G4ParticleDefinition aPartDef,
G4double  Ekin,
const G4MaterialCutsCouple aCouple 
)

Definition at line 408 of file G4AdjointCSManager.cc.

410{ DefineCurrentMaterial(aCouple);
411 DefineCurrentParticle(aPartDef);
412 G4bool b;
413 return (((*theTotalForwardSigmaTableVector[currentParticleIndex])[currentMatIndex])->GetValue(Ekin*massRatio, b));
414
415
416}

Referenced by G4AdjointForcedInteractionForGamma::AlongStepDoIt(), GetContinuousWeightCorrection(), and GetCrossSectionCorrection().

◆ RegisterAdjointParticle()

void G4AdjointCSManager::RegisterAdjointParticle ( G4ParticleDefinition aPartDef)

Definition at line 160 of file G4AdjointCSManager.cc.

161{ G4int index=-1;
162 for (size_t i=0;i<theListOfAdjointParticlesInAction.size();i++){
163 if (aPartDef->GetParticleName() == theListOfAdjointParticlesInAction[i]->GetParticleName()) index=i;
164 }
165
166 if (index ==-1){
167 listOfForwardEnergyLossProcess.push_back(new std::vector<G4VEnergyLossProcess*>());
168 theTotalForwardSigmaTableVector.push_back(new G4PhysicsTable);
169 theTotalAdjointSigmaTableVector.push_back(new G4PhysicsTable);
170 listOfForwardEmProcess.push_back(new std::vector<G4VEmProcess*>());
171 theListOfAdjointParticlesInAction.push_back(aPartDef);
172 EminForFwdSigmaTables.push_back(std::vector<G4double> ());
173 EminForAdjSigmaTables.push_back(std::vector<G4double> ());
174 EkinofFwdSigmaMax.push_back(std::vector<G4double> ());
175 EkinofAdjSigmaMax.push_back(std::vector<G4double> ());
176
177 }
178}

Referenced by RegisterEmProcess(), and RegisterEnergyLossProcess().

◆ RegisterEmAdjointModel()

size_t G4AdjointCSManager::RegisterEmAdjointModel ( G4VEmAdjointModel aModel)

Definition at line 122 of file G4AdjointCSManager.cc.

123{listOfAdjointEMModel.push_back(aModel);
124 listSigmaTableForAdjointModelScatProjToProj.push_back(new G4PhysicsTable);
125 listSigmaTableForAdjointModelProdToProj.push_back(new G4PhysicsTable);
126 return listOfAdjointEMModel.size() -1;
127
128}

Referenced by G4VEmAdjointModel::G4VEmAdjointModel().

◆ RegisterEmProcess()

void G4AdjointCSManager::RegisterEmProcess ( G4VEmProcess aProcess,
G4ParticleDefinition aPartDef 
)

Definition at line 131 of file G4AdjointCSManager.cc.

132{
133 G4ParticleDefinition* anAdjPartDef = GetAdjointParticleEquivalent(aFwdPartDef);
134 if (anAdjPartDef && aProcess){
135 RegisterAdjointParticle(anAdjPartDef);
136 G4int index=-1;
137
138 for (size_t i=0;i<theListOfAdjointParticlesInAction.size();i++){
139 if (anAdjPartDef->GetParticleName() == theListOfAdjointParticlesInAction[i]->GetParticleName()) index=i;
140 }
141 listOfForwardEmProcess[index]->push_back(aProcess);
142 }
143}
void RegisterAdjointParticle(G4ParticleDefinition *aPartDef)
G4ParticleDefinition * GetAdjointParticleEquivalent(G4ParticleDefinition *theFwdPartDef)

◆ RegisterEnergyLossProcess()

void G4AdjointCSManager::RegisterEnergyLossProcess ( G4VEnergyLossProcess aProcess,
G4ParticleDefinition aPartDef 
)

Definition at line 146 of file G4AdjointCSManager.cc.

147{
148 G4ParticleDefinition* anAdjPartDef = GetAdjointParticleEquivalent(aFwdPartDef);
149 if (anAdjPartDef && aProcess){
150 RegisterAdjointParticle(anAdjPartDef);
151 G4int index=-1;
152 for (size_t i=0;i<theListOfAdjointParticlesInAction.size();i++){
153 if (anAdjPartDef->GetParticleName() == theListOfAdjointParticlesInAction[i]->GetParticleName()) index=i;
154 }
155 listOfForwardEnergyLossProcess[index]->push_back(aProcess);
156 }
157}

◆ SampleElementFromCSMatrices()

G4Element * G4AdjointCSManager::SampleElementFromCSMatrices ( G4Material aMaterial,
G4VEmAdjointModel aModel,
G4double  PrimEnergy,
G4double  Tcut,
G4bool  IsScatProjToProjCase 
)

Definition at line 663 of file G4AdjointCSManager.cc.

668{ std::vector<G4double> CS_Vs_Element;
669 G4double CS = ComputeAdjointCS(aMaterial,aModel,PrimEnergy,Tcut,IsScatProjToProjCase,CS_Vs_Element);
670 G4double rand_var= G4UniformRand();
671 G4double SumCS=0.;
672 size_t ind=0;
673 for (size_t i=0;i<CS_Vs_Element.size();i++){
674 SumCS+=CS_Vs_Element[i];
675 if (rand_var<=SumCS/CS){
676 ind=i;
677 break;
678 }
679 }
680
681 return const_cast<G4Element*>(aMaterial->GetElement(ind));
682
683
684
685}
#define G4UniformRand()
Definition: Randomize.hh:52

◆ SetFwdCrossSectionMode()

void G4AdjointCSManager::SetFwdCrossSectionMode ( G4bool  aBool)
inline

Definition at line 123 of file G4AdjointCSManager.hh.

123{forward_CS_mode=aBool;}

◆ SetIon()

void G4AdjointCSManager::SetIon ( G4ParticleDefinition adjIon,
G4ParticleDefinition fwdIon 
)
inline

Definition at line 170 of file G4AdjointCSManager.hh.

171 {theAdjIon=adjIon; theFwdIon =fwdIon;}

◆ SetNbins()

void G4AdjointCSManager::SetNbins ( G4int  aInt)
inline

Definition at line 169 of file G4AdjointCSManager.hh.

169{nbins=aInt;}

◆ SetTmax()

void G4AdjointCSManager::SetTmax ( G4double  aVal)
inline

Definition at line 168 of file G4AdjointCSManager.hh.

168{Tmax=aVal;}

◆ SetTmin()

void G4AdjointCSManager::SetTmin ( G4double  aVal)
inline

Definition at line 167 of file G4AdjointCSManager.hh.

167{Tmin=aVal;}

Friends And Related Function Documentation

◆ G4ThreadLocalSingleton< G4AdjointCSManager >

Definition at line 1 of file G4AdjointCSManager.hh.


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