Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4AdjointCSManager.hh
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // $Id: G4AdjointCSManager.hh 66892 2013-01-17 10:57:59Z gunter $
27 //
28 /////////////////////////////////////////////////////////////////////////////////
29 // Class: G4AdjointCSManager
30 // Author: L. Desorgher
31 // Organisation: SpaceIT GmbH
32 // Contract: ESA contract 21435/08/NL/AT
33 // Customer: ESA/ESTEC
34 /////////////////////////////////////////////////////////////////////////////////
35 //
36 // CHANGE HISTORY
37 // --------------
38 // ChangeHistory:
39 // 1st April 2007 creation by L. Desorgher
40 //
41 // September-October 2009. Implementation of the mode where the adjoint cross sections are scaled such that the total used adjoint cross sections is in
42 // most of the cases equal to the total forward cross section. L.Desorgher
43 //
44 //-------------------------------------------------------------
45 // Documentation:
46 // Is responsible for the management of all adjoint cross sections matrices, and for the computation of the total forward and adjoint cross sections.
47 // Total adjoint and forward cross sections are needed to correct the weight of a particle after a tracking step or after the occurence of a reverse reaction.
48 // It is also used to sample an adjoint secondary from a given adjoint cross section matrix.
49 //
50 #ifndef G4AdjointCSManager_h
51 #define G4AdjointCSManager_h 1
52 
53 #include"globals.hh"
54 #include<vector>
55 #include"G4AdjointCSMatrix.hh"
56 
57 
58 class G4VEmAdjointModel;
60 class G4Material;
62 class G4Element;
63 class G4VEmProcess;
65 class G4PhysicsTable;
66 
67 ////////////////////////////////////////////////////////////////////////////////
68 //
70 {
71 
72  public:
75 
76  public:
78 
79  //Registration of the different models and processes
80 
82 
83  void RegisterEmProcess(G4VEmProcess* aProcess, G4ParticleDefinition* aPartDef);
84 
86 
88 
89  //Building of the CS Matrices and Total Forward and Adjoint LambdaTables
90  //----------------------------------------------------------------------
91 
93  void BuildTotalSigmaTables();
94 
95 
96  //Get TotalCrossSections form Total Lambda Tables, Needed for Weight correction and scaling of the
97  //-------------------------------------------------
99  const G4MaterialCutsCouple* aCouple);
101  const G4MaterialCutsCouple* aCouple);
102 
103  G4double GetAdjointSigma(G4double Ekin_nuc, size_t index_model,G4bool is_scat_proj_to_proj,
104  const G4MaterialCutsCouple* aCouple);
105 
107  const G4MaterialCutsCouple* aCouple, G4double& emin_adj, G4double& emin_fwd);
108  void GetMaxFwdTotalCS(G4ParticleDefinition* aPartDef,
109  const G4MaterialCutsCouple* aCouple, G4double& e_sigma_max, G4double& sigma_max);
110  void GetMaxAdjTotalCS(G4ParticleDefinition* aPartDef,
111  const G4MaterialCutsCouple* aCouple, G4double& e_sigma_max, G4double& sigma_max);
112 
113 
114 
115  //CrossSection Correction 1 or FwdCS/AdjCS following the G4boolean value of forward_CS_is_used and forward_CS_mode
116  //-------------------------------------------------
117  G4double GetCrossSectionCorrection(G4ParticleDefinition* aPartDef,G4double PreStepEkin,const G4MaterialCutsCouple* aCouple, G4bool& fwd_is_used, G4double& fwd_TotCS);
118 
119 
120  //Cross section mode
121  //------------------
122  inline void SetFwdCrossSectionMode(G4bool aBool){forward_CS_mode=aBool;}
123 
124 
125  //Weight correction
126  //------------------
127 
128  G4double GetContinuousWeightCorrection(G4ParticleDefinition* aPartDef, G4double PreStepEkin,G4double AfterStepEkin,
129  const G4MaterialCutsCouple* aCouple, G4double step_length);
131 
132 
133 
134 
135  //Method Called by the adjoint model to get there CS, if not precised otherwise
136  //-------------------------------
137 
139  G4VEmAdjointModel* aModel,
140  G4double PrimEnergy,
141  G4double Tcut,
142  G4bool IsScatProjToProjCase,
143  std::vector<G4double>&
144  AdjointCS_for_each_element);
145 
146  //Method Called by the adjoint model to sample the secondary energy form the CS matrix
147  //--------------------------------------------------------------------------------
149  G4VEmAdjointModel* aModel,
150  G4double PrimEnergy,
151  G4double Tcut,
152  G4bool IsScatProjToProjCase);
153 
154 
155  //Total Adjoint CS is computed at initialisation phase
156  //-----------------------------------------------------
157  G4double ComputeTotalAdjointCS(const G4MaterialCutsCouple* aMatCutCouple,G4ParticleDefinition* aPart,G4double PrimEnergy);
158 
159 
160 
161 
164 
165  //inline
166  inline void SetTmin(G4double aVal){Tmin=aVal;}
167  inline void SetTmax(G4double aVal){Tmax=aVal;}
168  inline void SetNbins(G4int aInt){nbins=aInt;}
169  inline void SetIon(G4ParticleDefinition* adjIon,
170  G4ParticleDefinition* fwdIon) {theAdjIon=adjIon; theFwdIon =fwdIon;}
171 
172 
173  private:
174  static G4ThreadLocal G4AdjointCSManager* theInstance;
175  std::vector< std::vector<G4AdjointCSMatrix*> > theAdjointCSMatricesForScatProjToProj; //x dim is for G4VAdjointEM* while y dim is for elements
176  std::vector< std::vector<G4AdjointCSMatrix*> > theAdjointCSMatricesForProdToProj;
177  std::vector< G4VEmAdjointModel*> listOfAdjointEMModel;
178 
179  std::vector<G4AdjointCSMatrix*>
180  BuildCrossSectionsMatricesForAGivenModelAndElement(G4VEmAdjointModel* aModel,
181  G4int Z,
182  G4int A,
183  G4int nbin_pro_decade);
184 
185  std::vector<G4AdjointCSMatrix*>
186  BuildCrossSectionsMatricesForAGivenModelAndMaterial(G4VEmAdjointModel* aModel,
187  G4Material* aMaterial,
188  G4int nbin_pro_decade);
189 
190 
191  G4Material* lastMaterial;
192  G4double lastPrimaryEnergy;
193  G4double lastTcut;
194  std::vector< size_t> listOfIndexOfAdjointEMModelInAction;
195  std::vector< G4bool> listOfIsScatProjToProjCase;
196  std::vector< std::vector<G4double> > lastAdjointCSVsModelsAndElements;
197  G4bool CrossSectionMatrixesAreBuilt;
198  size_t currentParticleIndex;
199  G4ParticleDefinition* currentParticleDef;
200 
201  //total adjoint and total forward cross section table in function of material and in function of adjoint particle type
202  //--------------------------------------------------------------------------------------------------------------------
203  std::vector<G4PhysicsTable*> theTotalForwardSigmaTableVector;
204  std::vector<G4PhysicsTable*> theTotalAdjointSigmaTableVector;
205  std::vector< std::vector<G4double> > EminForFwdSigmaTables;
206  std::vector< std::vector<G4double> > EminForAdjSigmaTables;
207  std::vector< std::vector<G4double> > EkinofFwdSigmaMax;
208  std::vector< std::vector<G4double> > EkinofAdjSigmaMax;
209  G4bool TotalSigmaTableAreBuilt;
210 
211  //Sigma tavle for each G4VAdjointEMModel
212  std::vector<G4PhysicsTable*> listSigmaTableForAdjointModelScatProjToProj;
213  std::vector<G4PhysicsTable*> listSigmaTableForAdjointModelProdToProj;
214 
215 
216 
217 
218  //list of forward G4VEMLossProcess and of G4VEMProcess for the different adjoint particle
219  //--------------------------------------------------------------
220  std::vector< std::vector<G4VEmProcess*>* > listOfForwardEmProcess;
221  std::vector< std::vector<G4VEnergyLossProcess*>* > listOfForwardEnergyLossProcess;
222 
223  //list of adjoint particles considered
224  //--------------------------------------------------------------
225  std::vector< G4ParticleDefinition*> theListOfAdjointParticlesInAction;
226 
227 
228  G4double Tmin,Tmax;
229  G4int nbins;
230 
231 
232  //Current material
233  //----------------
234  G4MaterialCutsCouple* currentCouple;
235  G4Material* currentMaterial;
236  size_t currentMatIndex;
237 
238  G4int verbose;
239 
240 
241 
242 
243  //Two CS mode are possible :forward_CS_mode = false the Adjoint CS are used as it is implying a AlongStep Weight Correction.
244  // :forward_CS_mode = true the Adjoint CS are scaled to have the total adjoint CS eual to the fwd one implying a PostStep Weight Correction.
245  // For energy range where the total FwdCS or the total adjoint CS are null, the scaling is not possble and
246  // forward_CS_is_used is set to false
247  //--------------------------------------------
248  G4bool forward_CS_is_used;
249  G4bool forward_CS_mode;
250 
251  //Adj and Fwd CS values for re-use
252  //------------------------
253 
254  G4double PreadjCS,PostadjCS;
255  G4double PrefwdCS,PostfwdCS;
256  G4double LastEkinForCS;
257  G4double LastCSCorrectionFactor;
258  G4ParticleDefinition* lastPartDefForCS;
259 
260  //Ion
261  //----------------
262  G4ParticleDefinition* theAdjIon; //at the moment Only one ion can be considered by simulation
263  G4ParticleDefinition* theFwdIon;
264  G4double massRatio;
265 
266 
267 
268 
269  private:
271  void DefineCurrentMaterial(const G4MaterialCutsCouple* couple);
272  void DefineCurrentParticle(const G4ParticleDefinition* aPartDef);
273  G4double ComputeAdjointCS(G4double aPrimEnergy, G4AdjointCSMatrix* anAdjointCSMatrix, G4double Tcut);
274  size_t eindex;
275 
276 };
277 #endif
G4double GetTotalAdjointCS(G4ParticleDefinition *aPartDef, G4double Ekin, const G4MaterialCutsCouple *aCouple)
G4double GetCrossSectionCorrection(G4ParticleDefinition *aPartDef, G4double PreStepEkin, const G4MaterialCutsCouple *aCouple, G4bool &fwd_is_used, G4double &fwd_TotCS)
void SetTmin(G4double aVal)
G4double GetAdjointSigma(G4double Ekin_nuc, size_t index_model, G4bool is_scat_proj_to_proj, const G4MaterialCutsCouple *aCouple)
G4double ComputeTotalAdjointCS(const G4MaterialCutsCouple *aMatCutCouple, G4ParticleDefinition *aPart, G4double PrimEnergy)
G4double GetPostStepWeightCorrection()
void GetMaxFwdTotalCS(G4ParticleDefinition *aPartDef, const G4MaterialCutsCouple *aCouple, G4double &e_sigma_max, G4double &sigma_max)
size_t RegisterEmAdjointModel(G4VEmAdjointModel *)
void SetIon(G4ParticleDefinition *adjIon, G4ParticleDefinition *fwdIon)
void RegisterEnergyLossProcess(G4VEnergyLossProcess *aProcess, G4ParticleDefinition *aPartDef)
#define G4ThreadLocal
Definition: tls.hh:52
void SetFwdCrossSectionMode(G4bool aBool)
int G4int
Definition: G4Types.hh:78
void RegisterAdjointParticle(G4ParticleDefinition *aPartDef)
G4ParticleDefinition * GetAdjointParticleEquivalent(G4ParticleDefinition *theFwdPartDef)
bool G4bool
Definition: G4Types.hh:79
void SetNbins(G4int aInt)
void SetTmax(G4double aVal)
G4double GetTotalForwardCS(G4ParticleDefinition *aPartDef, G4double Ekin, const G4MaterialCutsCouple *aCouple)
void GetEminForTotalCS(G4ParticleDefinition *aPartDef, const G4MaterialCutsCouple *aCouple, G4double &emin_adj, G4double &emin_fwd)
G4ParticleDefinition * GetForwardParticleEquivalent(G4ParticleDefinition *theAdjPartDef)
G4double GetContinuousWeightCorrection(G4ParticleDefinition *aPartDef, G4double PreStepEkin, G4double AfterStepEkin, const G4MaterialCutsCouple *aCouple, G4double step_length)
void RegisterEmProcess(G4VEmProcess *aProcess, G4ParticleDefinition *aPartDef)
void GetMaxAdjTotalCS(G4ParticleDefinition *aPartDef, const G4MaterialCutsCouple *aCouple, G4double &e_sigma_max, G4double &sigma_max)
double G4double
Definition: G4Types.hh:76
G4Element * SampleElementFromCSMatrices(G4Material *aMaterial, G4VEmAdjointModel *aModel, G4double PrimEnergy, G4double Tcut, G4bool IsScatProjToProjCase)
static G4AdjointCSManager * GetAdjointCSManager()
G4double ComputeAdjointCS(G4Material *aMaterial, G4VEmAdjointModel *aModel, G4double PrimEnergy, G4double Tcut, G4bool IsScatProjToProjCase, std::vector< G4double > &AdjointCS_for_each_element)