Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 69 of file G4AdjointCSManager.hh.

Constructor & Destructor Documentation

G4AdjointCSManager::~G4AdjointCSManager ( )

Definition at line 118 of file G4AdjointCSManager.cc.

119 {;
120 }

Member Function Documentation

void G4AdjointCSManager::BuildCrossSectionMatrices ( )

Definition at line 182 of file G4AdjointCSManager.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:

void G4AdjointCSManager::BuildTotalSigmaTables ( )

Definition at line 269 of file G4AdjointCSManager.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 534 of file G4AdjointCSManager.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 689 of file G4AdjointCSManager.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:

G4AdjointCSManager * G4AdjointCSManager::GetAdjointCSManager ( )
static

Definition at line 61 of file G4AdjointCSManager.cc.

62 {
63  if(theInstance == nullptr) {
65  theInstance = inst.Instance();
66  }
67  return theInstance;
68 }

Here is the call graph for this function:

Here is the caller graph for this function:

G4ParticleDefinition * G4AdjointCSManager::GetAdjointParticleEquivalent ( G4ParticleDefinition theFwdPartDef)

Definition at line 949 of file G4AdjointCSManager.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 420 of file G4AdjointCSManager.cc.

422 { DefineCurrentMaterial(aCouple);
423  G4bool b;
424  if (is_scat_proj_to_proj) return (((*listSigmaTableForAdjointModelScatProjToProj[index_model])[currentMatIndex])->GetValue(Ekin_nuc, b));
425  else return (((*listSigmaTableForAdjointModelProdToProj[index_model])[currentMatIndex])->GetValue(Ekin_nuc, b));
426 }
bool G4bool
Definition: G4Types.hh:79
G4double G4AdjointCSManager::GetContinuousWeightCorrection ( G4ParticleDefinition aPartDef,
G4double  PreStepEkin,
G4double  AfterStepEkin,
const G4MaterialCutsCouple aCouple,
G4double  step_length 
)

Definition at line 504 of file G4AdjointCSManager.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 467 of file G4AdjointCSManager.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 429 of file G4AdjointCSManager.cc.

431 { DefineCurrentMaterial(aCouple);
432  DefineCurrentParticle(aPartDef);
433  emin_adj = EminForAdjSigmaTables[currentParticleIndex][currentMatIndex]/massRatio;
434  emin_fwd = EminForFwdSigmaTables[currentParticleIndex][currentMatIndex]/massRatio;
435 
436 
437 
438 }
G4ParticleDefinition * G4AdjointCSManager::GetForwardParticleEquivalent ( G4ParticleDefinition theAdjPartDef)

Definition at line 960 of file G4AdjointCSManager.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 454 of file G4AdjointCSManager.cc.

456 { DefineCurrentMaterial(aCouple);
457  DefineCurrentParticle(aPartDef);
458  e_sigma_max = EkinofAdjSigmaMax[currentParticleIndex][currentMatIndex];
459  G4bool b;
460  sigma_max =((*theTotalAdjointSigmaTableVector[currentParticleIndex])[currentMatIndex])->GetValue(e_sigma_max, b);
461  e_sigma_max/=massRatio;
462 
463 
464 }
bool G4bool
Definition: G4Types.hh:79
void G4AdjointCSManager::GetMaxFwdTotalCS ( G4ParticleDefinition aPartDef,
const G4MaterialCutsCouple aCouple,
G4double e_sigma_max,
G4double sigma_max 
)

Definition at line 441 of file G4AdjointCSManager.cc.

443 { DefineCurrentMaterial(aCouple);
444  DefineCurrentParticle(aPartDef);
445  e_sigma_max = EkinofFwdSigmaMax[currentParticleIndex][currentMatIndex];
446  G4bool b;
447  sigma_max =((*theTotalForwardSigmaTableVector[currentParticleIndex])[currentMatIndex])->GetValue(e_sigma_max, b);
448  e_sigma_max/=massRatio;
449 
450 
451 }
bool G4bool
Definition: G4Types.hh:79
G4int G4AdjointCSManager::GetNbProcesses ( )
G4double G4AdjointCSManager::GetPostStepWeightCorrection ( )

Definition at line 527 of file G4AdjointCSManager.cc.

528 {//return 1.;
529  return 1./LastCSCorrectionFactor;
530 
531 }

Here is the caller graph for this function:

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

Definition at line 397 of file G4AdjointCSManager.cc.

399 { DefineCurrentMaterial(aCouple);
400  DefineCurrentParticle(aPartDef);
401  G4bool b;
402  return (((*theTotalAdjointSigmaTableVector[currentParticleIndex])[currentMatIndex])->GetValue(Ekin*massRatio, b));
403 
404 
405 
406 }
bool G4bool
Definition: G4Types.hh:79

Here is the caller graph for this function:

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

Definition at line 409 of file G4AdjointCSManager.cc.

411 { DefineCurrentMaterial(aCouple);
412  DefineCurrentParticle(aPartDef);
413  G4bool b;
414  return (((*theTotalForwardSigmaTableVector[currentParticleIndex])[currentMatIndex])->GetValue(Ekin*massRatio, b));
415 
416 
417 }
bool G4bool
Definition: G4Types.hh:79

Here is the caller graph for this function:

void G4AdjointCSManager::RegisterAdjointParticle ( G4ParticleDefinition aPartDef)

Definition at line 161 of file G4AdjointCSManager.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:

size_t G4AdjointCSManager::RegisterEmAdjointModel ( G4VEmAdjointModel aModel)

Definition at line 123 of file G4AdjointCSManager.cc.

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

Here is the caller graph for this function:

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

Definition at line 132 of file G4AdjointCSManager.cc.

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

Here is the call graph for this function:

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

Definition at line 147 of file G4AdjointCSManager.cc.

148 {
149  G4ParticleDefinition* anAdjPartDef = GetAdjointParticleEquivalent(aFwdPartDef);
150  if (anAdjPartDef && aProcess){
151  RegisterAdjointParticle(anAdjPartDef);
152  G4int index=-1;
153  for (size_t i=0;i<theListOfAdjointParticlesInAction.size();i++){
154  if (anAdjPartDef->GetParticleName() == theListOfAdjointParticlesInAction[i]->GetParticleName()) index=i;
155  }
156  listOfForwardEnergyLossProcess[index]->push_back(aProcess);
157  }
158 }
int G4int
Definition: G4Types.hh:78
const G4String & GetParticleName() const
void RegisterAdjointParticle(G4ParticleDefinition *aPartDef)
G4ParticleDefinition * GetAdjointParticleEquivalent(G4ParticleDefinition *theFwdPartDef)

Here is the call graph for this function:

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

Definition at line 664 of file G4AdjointCSManager.cc.

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

Here is the call graph for this function:

void G4AdjointCSManager::SetFwdCrossSectionMode ( G4bool  aBool)
inline

Definition at line 124 of file G4AdjointCSManager.hh.

124 {forward_CS_mode=aBool;}
void G4AdjointCSManager::SetIon ( G4ParticleDefinition adjIon,
G4ParticleDefinition fwdIon 
)
inline

Definition at line 171 of file G4AdjointCSManager.hh.

172  {theAdjIon=adjIon; theFwdIon =fwdIon;}
void G4AdjointCSManager::SetNbins ( G4int  aInt)
inline

Definition at line 170 of file G4AdjointCSManager.hh.

170 {nbins=aInt;}
void G4AdjointCSManager::SetTmax ( G4double  aVal)
inline

Definition at line 169 of file G4AdjointCSManager.hh.

169 {Tmax=aVal;}
void G4AdjointCSManager::SetTmin ( G4double  aVal)
inline

Definition at line 168 of file G4AdjointCSManager.hh.

168 {Tmin=aVal;}

Friends And Related Function Documentation

Definition at line 72 of file G4AdjointCSManager.hh.


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