Index: trunk/source/processes/electromagnetic/adjoint/include/G4AdjointAlongStepWeightCorrection.hh
===================================================================
--- trunk/source/processes/electromagnetic/adjoint/include/G4AdjointAlongStepWeightCorrection.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/adjoint/include/G4AdjointAlongStepWeightCorrection.hh	(revision 1196)
@@ -24,9 +24,12 @@
 // ********************************************************************
 //
+// $Id: G4AdjointAlongStepWeightCorrection.hh,v 1.4 2009/11/20 10:31:20 ldesorgh Exp $
+// GEANT4 tag $Name: geant4-09-03-cand-01 $
+//
 /////////////////////////////////////////////////////////////////////////////////
-//      Module:		G4AdjointAlongStepWeightCorrection.hh
+//      Class:		G4AdjointAlongStepWeightCorrection
 //	Author:       	L. Desorgher
-//	Date:		10 May 2007
 // 	Organisation: 	SpaceIT GmbH
+//	Contract:	ESA contract 21435/08/NL/AT
 // 	Customer:     	ESA/ESTEC
 /////////////////////////////////////////////////////////////////////////////////
@@ -35,9 +38,17 @@
 // --------------
 //      ChangeHistory: 
-//	 	10 May 2007 creation by L. Desorgher  		
+//	 	10 May 2007 creation by L. Desorgher  
+//		October 2009 implementation of the mode where the total adjoint and forward cross sections are equivalent. L. Desorgher		
 //
 //-------------------------------------------------------------
 //	Documentation:
 //		Continuous processes acting on adjoint particles to correct continuously their weight during the adjoint reverse tracking.
+//		Thi process is needed whene the adjoint cross section are not scaled such that the total adjoint cross section match the total forward cross section. 
+//		By default the mode where the total adjoint cross section is equal to the total forward cross section is used an therefore this along step weight 
+//		correction factor is 1.
+//		However in some cases (some energy ranges) the total forward cross section or the total adjoint cross section can be null, in this case the along step 
+//		weight correction is neede and is given by exp(-(Sigma_tot_adj-Sigma_tot_fwd).dx)
+//		
+// 
 //
 
@@ -120,19 +131,9 @@
     currentMaterial = couple->GetMaterial();
     currentMaterialIndex = couple->GetIndex();
-    //G4cout<<"Define Material"<<std::endl;
-    //if(!meanFreePath) ResetNumberOfInteractionLengthLeft();
+  
   }
 }
 
 
-///////////////////////////////////////////////////////
-//
-inline G4double G4AdjointAlongStepWeightCorrection::GetContinuousStepLimit(const G4Track& track,
-                G4double , G4double , G4double& )
-{ 
-  G4double x = DBL_MAX;
-  DefineMaterial(track.GetMaterialCutsCouple());
-  preStepKinEnergy = track.GetKineticEnergy();
-  return x;
-}
+
 #endif
Index: trunk/source/processes/electromagnetic/adjoint/include/G4AdjointBremsstrahlungModel.hh
===================================================================
--- trunk/source/processes/electromagnetic/adjoint/include/G4AdjointBremsstrahlungModel.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/adjoint/include/G4AdjointBremsstrahlungModel.hh	(revision 1196)
@@ -24,9 +24,12 @@
 // ********************************************************************
 //
+// $Id: G4AdjointBremsstrahlungModel.hh,v 1.4 2009/11/20 10:31:20 ldesorgh Exp $
+// GEANT4 tag $Name: geant4-09-03-cand-01 $
+//
 /////////////////////////////////////////////////////////////////////////////////
-//      Module:		G4AdjointBremsstrahlungModel.hh
+//      Class:		G4AdjointBremsstrahlungModel
 //	Author:       	L. Desorgher
-//	Date:		15 June 2007
 // 	Organisation: 	SpaceIT GmbH
+//	Contract:	ESA contract 21435/08/NL/AT
 // 	Customer:     	ESA/ESTEC
 /////////////////////////////////////////////////////////////////////////////////
@@ -35,5 +38,11 @@
 // --------------
 //      ChangeHistory: 
-//	 	15 June 2007 creation by L. Desorgher. Adapted from G4eBremsstrahlungModel  		
+//	 	15 June 2007 creation by L. Desorgher. Adapted from G4eBremsstrahlungModel  
+//		20-10-2009 Remove all the screening effect that are not considered in the direct models blow 10 GeV. L.Desorgher
+//		4-11-2009  Implement the use of a simple biased differential cross section (C(Z)/Egamma) allowing a rapid computation of adjoint CS
+//			   and rapid sampling of adjoint secondaries. By this way cross section matrices are not used anymore, avoiding a rather 
+//			   time consuming computation of adjoint brem cross section matrices for each material at initialisation. This mode is switch on/off
+//			   by selecting SetUseMatrix(false)/ SetUseMatrix(true) in the constructor. L.Desorgher	
+//		  	  		
 //
 //-------------------------------------------------------------
@@ -49,4 +58,7 @@
 #include "G4VEmAdjointModel.hh"
 #include "G4eBremsstrahlungModel.hh"
+//#include "G4PenelopeBremsstrahlungModel.hh"
+#include "G4PhysicsTable.hh"
+//#include "G4EmModelManager.hh"
 class G4Timer;
 class G4AdjointBremsstrahlungModel: public G4VEmAdjointModel
@@ -60,5 +72,7 @@
                                 G4bool IsScatProjToProjCase,
 				G4ParticleChange* fParticleChange);
-  
+  void RapidSampleSecondaries(const G4Track& aTrack,
+                                G4bool IsScatProjToProjCase,
+				G4ParticleChange* fParticleChange);
   virtual G4double DiffCrossSectionPerVolumePrimToSecond(
   				      const G4Material* aMaterial,
@@ -66,68 +80,51 @@
                                       G4double kinEnergyProd // kinetic energy of the secondary particle 
 				      ); 
-  G4double DiffCrossSectionPerVolumePrimToSecond1(
+  G4double DiffCrossSectionPerVolumePrimToSecondApproximated1(
   				      const G4Material* aMaterial,
                                       G4double kinEnergyProj,  // kinetic energy of the primary particle before the interaction 
                                       G4double kinEnergyProd // kinetic energy of the secondary particle 
 				      ); 
-  G4double DiffCrossSectionPerVolumePrimToSecond2(
+  G4double DiffCrossSectionPerVolumePrimToSecondApproximated2(
   				      const G4Material* aMaterial,
                                       G4double kinEnergyProj,  // kinetic energy of the primary particle before the interaction 
                                       G4double kinEnergyProd // kinetic energy of the secondary particle 
 				      ); 
-  G4double DiffCrossSectionPerVolumePrimToSecond3(
-  				      const G4Material* aMaterial,
-                                      G4double kinEnergyProj,  // kinetic energy of the primary particle before the interaction 
-                                      G4double kinEnergyProd // kinetic energy of the secondary particle 
-				      ); 				      
-  void DefineDirectBremModel(G4eBremsstrahlungModel* aModel);
-  inline void SetdCSModel(G4String aString) {ModeldCS=aString;}
- 				      
+  virtual G4double AdjointCrossSection(const G4MaterialCutsCouple* aCouple,
+				             G4double primEnergy,
+				             G4bool IsScatProjToProjCase); 
   
-private:
-  
-  void InitialiseParameters();
-  G4double SupressionFunction(const G4Material* material, G4double tkin,
-                                    G4double gammaEnergy);
-				    
+ 
+ // private void InitialiseFwdModels();
+
 
 private:  
-  G4eBremsstrahlungModel* theDirectBremModel;
+   G4eBremsstrahlungModel* theDirectStdBremModel;
+  //G4PenelopeBremsstrahlungModel* theDirectPenelopeBremModel;
+
 
   G4double highKinEnergy;
   G4double lowKinEnergy;
-  G4double probsup;
-  G4double MigdalConstant;
-  G4double LPMconstant;
-  G4double highEnergyTh;
-  G4bool   theLPMflag;
-  G4bool   isElectron;
+ 
   
-  //Vector 
+  std::vector<G4DataVector*> partialSumSigma;
   
-  std::vector<float> FZ;
-  std::vector<float> ah1;
-  std::vector<float> ah2;
-  std::vector<float> ah3;
-  
-  std::vector<float> bh1;
-  std::vector<float> bh2;
-  std::vector<float> bh3;
-  
-  std::vector<float> al0;
-  std::vector<float> al1;
-  std::vector<float> al2;
-  
-  std::vector<float> bl0;
-  std::vector<float> bl1;
-  std::vector<float> bl2; 
+ 
   
   std::vector<float> SigmaPerAtom; 
   G4Timer* theTimer;
   
-  G4String ModeldCS;
+  G4double MigdalConstant;
+  G4double lastCZ;
+  
+
+ /* 
+  G4bool UsePenelopeModel;
+  G4EmModelManager* theEmModelManagerForFwdModels;
+  G4bool isPenelopeModelInitialised ;
+ */ 
   
   
 };
 
+
 #endif
Index: trunk/source/processes/electromagnetic/adjoint/include/G4AdjointCSManager.hh
===================================================================
--- trunk/source/processes/electromagnetic/adjoint/include/G4AdjointCSManager.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/adjoint/include/G4AdjointCSManager.hh	(revision 1196)
@@ -24,9 +24,12 @@
 // ********************************************************************
 //
+// $Id: G4AdjointCSManager.hh,v 1.4 2009/11/20 10:31:20 ldesorgh Exp $
+// GEANT4 tag $Name: geant4-09-03-cand-01 $
+//
 /////////////////////////////////////////////////////////////////////////////////
-//      Module:		G4AdjointCSManager.hh
+//      Class:		G4AdjointCSManager
 //	Author:       	L. Desorgher
-//	Date:		1st April 2007
 // 	Organisation: 	SpaceIT GmbH
+//	Contract:	ESA contract 21435/08/NL/AT
 // 	Customer:     	ESA/ESTEC
 /////////////////////////////////////////////////////////////////////////////////
@@ -36,9 +39,12 @@
 //      ChangeHistory: 
 //	 	1st April 2007 creation by L. Desorgher  		
+//		
+//		September-October 2009. Implementation of the mode where the adjoint cross sections are scaled such that the total used adjoint cross sections is in 
+//		most of the cases equal to the total forward cross section. L.Desorgher
 //
 //-------------------------------------------------------------
 //	Documentation:
 //		Is responsible for the management of all adjoint cross sections matrices, and for the computation of the total forward and adjoint cross sections.
-//		Total adjoint and forward cross sections are needed to correct continuously the weight of a particle after a tracking step. 
+//		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. 
 //		It is also used to sample an adjoint secondary from a given adjoint cross section matrix.
 //
@@ -82,5 +88,5 @@
 	void RegisterAdjointParticle(G4ParticleDefinition* aPartDef);
 	
-	//Building of thr CS Matrices and Total Forward and Adjoint LambdaTables
+	//Building of the CS Matrices and Total Forward and Adjoint LambdaTables
 	//----------------------------------------------------------------------
 	
@@ -89,11 +95,29 @@
 	
 	
-	//Get TotalCrossSections form Total Lambda Tables
+	//Get TotalCrossSections form Total Lambda Tables, Needed for Weight correction and scaling of the 
 	//-------------------------------------------------
 	G4double GetTotalAdjointCS(G4ParticleDefinition* aPartDef, G4double Ekin,
 	 		   	     const G4MaterialCutsCouple* aCouple);
 	G4double GetTotalForwardCS(G4ParticleDefinition* aPartDef, G4double Ekin,
-	 		   	     const G4MaterialCutsCouple* aCouple);			     
-	
+	 		   	     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);
+				     
+				     			     			     
+	
+	//CrossSection Correction  1 or FwdCS/AdjCS following the G4boolean value of forward_CS_is_used and forward_CS_mode
+	//-------------------------------------------------
+	G4double GetCrossSectionCorrection(G4ParticleDefinition* aPartDef,G4double PreStepEkin,const G4MaterialCutsCouple* aCouple, G4bool& fwd_is_used, G4double& fwd_TotCS);
+	
+	
+	//Cross section mode
+	//------------------
+	inline void SetFwdCrossSectionMode(G4bool aBool){forward_CS_mode=aBool;}
 	
 	
@@ -103,18 +127,22 @@
 	G4double GetContinuousWeightCorrection(G4ParticleDefinition* aPartDef, G4double PreStepEkin,G4double AfterStepEkin,
 	 		   	     const G4MaterialCutsCouple* aCouple, G4double step_length);
-	G4double GetPostStepWeightCorrection(G4ParticleDefinition* aPrimPartDef, G4ParticleDefinition* aSecondPartDef,
-					    G4double EkinPrim,G4double EkinSecond,
-	 		   	     const G4MaterialCutsCouple* aCouple);
+	G4double GetPostStepWeightCorrection();
 				     
 	
-	double ComputeAdjointCS(G4Material* aMaterial,
+	
+	
+	//Method Called by the adjoint model to get there CS, if not precised otherwise
+	//-------------------------------
+	
+	G4double ComputeAdjointCS(G4Material* aMaterial,
 					    G4VEmAdjointModel* aModel, 
 					    G4double PrimEnergy,
 					    G4double Tcut,
 					    G4bool IsScatProjToProjCase,
-					    std::vector<double>& 
+					    std::vector<G4double>& 
 					         AdjointCS_for_each_element);
 					 
-	
+	//Method Called by the adjoint model to sample the secondary energy form the CS matrix
+	//--------------------------------------------------------------------------------
 	G4Element*  SampleElementFromCSMatrices(G4Material* aMaterial,
 						       G4VEmAdjointModel* aModel,
@@ -122,5 +150,13 @@
 						        G4double Tcut,
 						       G4bool IsScatProjToProjCase);
-	G4double ComputeTotalAdjointCS(const G4MaterialCutsCouple* aMatCutCouple,G4ParticleDefinition* aPart,G4double PrimEnergy);							
+						       
+						       
+	//Total Adjoint CS  is computed at initialisation phase 
+	//-----------------------------------------------------					       
+	G4double ComputeTotalAdjointCS(const G4MaterialCutsCouple* aMatCutCouple,G4ParticleDefinition* aPart,G4double PrimEnergy);
+	
+	
+	
+								
 	G4ParticleDefinition* GetAdjointParticleEquivalent(G4ParticleDefinition* theFwdPartDef);
 	G4ParticleDefinition* GetForwardParticleEquivalent(G4ParticleDefinition* theAdjPartDef);
@@ -130,12 +166,6 @@
 	inline void SetTmax(G4double aVal){Tmax=aVal;}
 	inline void SetNbins(G4int aInt){nbins=aInt;}
-	
-	
-	
-	//inline
-	inline void ConsiderContinuousWeightCorrection(G4bool aBool){consider_continuous_weight_correction=aBool;}
-	inline void ConsiderPoststepWeightCorrection(G4bool aBool){consider_poststep_weight_correction=aBool;}
-	
-	
+	inline void SetIon(G4ParticleDefinition* adjIon,
+		           G4ParticleDefinition* fwdIon) {theAdjIon=adjIon; theFwdIon =fwdIon;}
 	
 	
@@ -163,6 +193,8 @@
 	std::vector< size_t> listOfIndexOfAdjointEMModelInAction;
 	std::vector< G4bool> listOfIsScatProjToProjCase;
-	std::vector< std::vector<double> > lastAdjointCSVsModelsAndElements;
+	std::vector< std::vector<G4double> > lastAdjointCSVsModelsAndElements;
 	G4bool CrossSectionMatrixesAreBuilt;
+	size_t  currentParticleIndex;
+	G4ParticleDefinition* currentParticleDef;
 	
 	//total adjoint and total forward cross section table in function of material and in function of adjoint particle type
@@ -170,4 +202,11 @@
 	std::vector<G4PhysicsTable*>        theTotalForwardSigmaTableVector;
 	std::vector<G4PhysicsTable*>        theTotalAdjointSigmaTableVector;
+	std::vector< std::vector<G4double> > 	EminForFwdSigmaTables;	
+	std::vector< std::vector<G4double> > 	EminForAdjSigmaTables;	
+	std::vector< std::vector<G4double> > 	EkinofFwdSigmaMax;	
+	std::vector< std::vector<G4double> > 	EkinofAdjSigmaMax;
+	
+	
+	
 	 
 	//list of forward G4VEMLossProcess and of G4VEMProcess for the different adjoint particle
@@ -177,5 +216,5 @@
 	
 	//list of adjoint particles considered
-	
+	//--------------------------------------------------------------
 	std::vector< G4ParticleDefinition*> theListOfAdjointParticlesInAction;
 	
@@ -191,16 +230,40 @@
 	size_t  currentMatIndex;
 	
-	int verbose;
-	
-	
-	//Weight correction
-	//------------------
-	G4bool consider_continuous_weight_correction;
-	G4bool consider_poststep_weight_correction;
+	G4int verbose;
+	
+	
+	
+	
+	//Two CS mode are possible :forward_CS_mode = false the Adjoint CS are used as it is implying a AlongStep Weight Correction.
+	// 			   :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.
+	//					     For energy range  where the total FwdCS or the total adjoint CS are null, the scaling is not possble and
+	//					     forward_CS_is_used is set to false 	
+	//--------------------------------------------
+	G4bool forward_CS_is_used;
+	G4bool forward_CS_mode;
+	
+	//Adj and Fwd CS values for re-use 
+	//------------------------
+	
+	G4double PreadjCS,PostadjCS;
+	G4double PrefwdCS,PostfwdCS;
+	G4double LastEkinForCS;
+	G4double LastCSCorrectionFactor;
+	G4ParticleDefinition* lastPartDefForCS;
+	
+	//Ion
+	//----------------
+	G4ParticleDefinition* theAdjIon; //at the moment Only one ion can be considered by simulation
+	G4ParticleDefinition* theFwdIon;
+	G4double massRatio;
+	
+	
+	
 
   private:
         G4AdjointCSManager();  
 	void DefineCurrentMaterial(const G4MaterialCutsCouple* couple);
-	double ComputeAdjointCS(G4double aPrimEnergy, G4AdjointCSMatrix* anAdjointCSMatrix, G4double Tcut);
+	void DefineCurrentParticle(const G4ParticleDefinition* aPartDef);
+	G4double ComputeAdjointCS(G4double aPrimEnergy, G4AdjointCSMatrix* anAdjointCSMatrix, G4double Tcut);
 
 };
Index: trunk/source/processes/electromagnetic/adjoint/include/G4AdjointCSMatrix.hh
===================================================================
--- trunk/source/processes/electromagnetic/adjoint/include/G4AdjointCSMatrix.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/adjoint/include/G4AdjointCSMatrix.hh	(revision 1196)
@@ -24,9 +24,12 @@
 // ********************************************************************
 //
+// $Id: G4AdjointCSMatrix.hh,v 1.4 2009/11/20 10:31:20 ldesorgh Exp $
+// GEANT4 tag $Name: geant4-09-03-cand-01 $
+//
 /////////////////////////////////////////////////////////////////////////////////
-//      Module:		G4AdjointCSMatrix.hh
+//      Class:		G4AdjointCSMatrix.hh
 //	Author:       	L. Desorgher
-//	Date:		1st April 2007
 // 	Organisation: 	SpaceIT GmbH
+//	Contract:	ESA contract 21435/08/NL/AT
 // 	Customer:     	ESA/ESTEC
 /////////////////////////////////////////////////////////////////////////////////
@@ -65,17 +68,17 @@
 	~G4AdjointCSMatrix();
 
-        ////////////
-        // Methods
-	////////////
+        //////////////
+        // Methods  // 
+	//////////////
 	void Clear();
-	void AddData(G4double aPrimEnergy,G4double aCS, std::vector< G4double>* aLogSecondEnergyVector,
-	 					        std::vector< G4double>* aLogProbVector,size_t n_pro_decade=0);	
+	void AddData(G4double aPrimEnergy,G4double aCS, std::vector< double>* aLogSecondEnergyVector,
+	 					        std::vector< double>* aLogProbVector,size_t n_pro_decade=0);	
 	
-	bool GetData(unsigned int i, G4double& aPrimEnergy,G4double& aCS,G4double& log0, std::vector< G4double>*& aLogSecondEnergyVector,
-	 							      std::vector< G4double>*& aLogProbVector,
+	G4bool GetData(unsigned int i, G4double& aPrimEnergy,G4double& aCS,G4double& log0, std::vector< double>*& aLogSecondEnergyVector,
+	 							      std::vector< double>*& aLogProbVector,
 								      std::vector< size_t>*& aLogProbVectorIndex);
 	
-	inline std::vector< G4double >* GetLogPrimEnergyVector(){return &theLogPrimEnergyVector;}
-	inline std::vector< G4double >* GetLogCrossSectionvector(){return &theLogCrossSectionVector;}
+	inline std::vector< double>* GetLogPrimEnergyVector(){return &theLogPrimEnergyVector;}
+	inline std::vector< double>* GetLogCrossSectionvector(){return &theLogCrossSectionVector;}
 	inline G4double GetDlog(){return dlog;} 	
 	inline G4bool IsScatProjToProjCase(){return is_scat_proj_to_proj_case;} 
@@ -87,11 +90,11 @@
 	// we did first try to use G4PhysicsOrderedVector but they are not general enough for our purpose
 	
-	std::vector< G4double > theLogPrimEnergyVector; 
-        std::vector< G4double > theLogCrossSectionVector; //Adjoint Cross sections in function of primary energy
-        std::vector< std::vector< G4double >* > theLogSecondEnergyMatrix;
-	std::vector< std::vector< G4double >* > theLogProbMatrix; //Each column represents the integrated probability of getting a secondary 
+	std::vector< double> theLogPrimEnergyVector; 
+        std::vector< double> theLogCrossSectionVector; //Adjoint Cross sections in function of primary energy
+        std::vector< std::vector< double>* > theLogSecondEnergyMatrix;
+	std::vector< std::vector< double>* > theLogProbMatrix; //Each column represents the integrated probability of getting a secondary 
 								      // in function of their energy 
-	std::vector< std::vector< size_t >* > theLogProbMatrixIndex; //index of euqidistant LogProb
-	std::vector< G4double > log0Vector;
+	std::vector< std::vector< size_t >* > theLogProbMatrixIndex; //index of equidistant LogProb
+	std::vector< double> log0Vector;
 	
 	unsigned int nb_of_PrimEnergy;
Index: trunk/source/processes/electromagnetic/adjoint/include/G4AdjointComptonModel.hh
===================================================================
--- trunk/source/processes/electromagnetic/adjoint/include/G4AdjointComptonModel.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/adjoint/include/G4AdjointComptonModel.hh	(revision 1196)
@@ -24,9 +24,12 @@
 // ********************************************************************
 //
+// $Id: G4AdjointComptonModel.hh,v 1.5 2009/11/20 10:31:20 ldesorgh Exp $
+// GEANT4 tag $Name: geant4-09-03-cand-01 $
+//
 /////////////////////////////////////////////////////////////////////////////////
-//      Module:		G4AdjointComptonModel.hh
+//      Class:		G4AdjointComptonModel
 //	Author:       	L. Desorgher
-//	Date:		1 September 2007
 // 	Organisation: 	SpaceIT GmbH
+//	Contract:	ESA contract 21435/08/NL/AT
 // 	Customer:     	ESA/ESTEC
 /////////////////////////////////////////////////////////////////////////////////
@@ -35,9 +38,10 @@
 // --------------
 //      ChangeHistory: 
-//	 	1 September 2007 creation by L. Desorgher  		
+//	 	1 September 2007 creation by L. Desorgher 
+//		11 November 2009 Implement the use of approximated diffCS as an alternative of CSMatrix. 		
 //
 //-------------------------------------------------------------
 //	Documentation:
-//		Model for the adjoint compton scattering
+//		Model for the adjoint compton scattering.
 //
 
@@ -48,4 +52,5 @@
 #include "globals.hh"
 #include "G4VEmAdjointModel.hh"
+#include "G4VEmProcess.hh"
 class G4AdjointComptonModel: public G4VEmAdjointModel
 
@@ -58,4 +63,7 @@
   
   virtual void SampleSecondaries(const G4Track& aTrack,
+                                G4bool IsScatProjToProjCase,
+				G4ParticleChange* fParticleChange);
+  void RapidSampleSecondaries(const G4Track& aTrack,
                                 G4bool IsScatProjToProjCase,
 				G4ParticleChange* fParticleChange);
@@ -71,13 +79,20 @@
 				      G4double Z, 
                                       G4double A = 0.);
+ 
   virtual G4double GetSecondAdjEnergyMaxForScatProjToProjCase(G4double PrimAdjEnergy);
   virtual G4double GetSecondAdjEnergyMinForProdToProjCase(G4double PrimAdjEnergy);
-
+  
+  
+  virtual G4double AdjointCrossSection(const G4MaterialCutsCouple* aCouple,
+				             G4double primEnergy,
+				             G4bool IsScatProjToProjCase);
 
   
   
-  			      
+  inline void SetDirectProcess(G4VEmProcess* aProcess){theDirectEMProcess = aProcess;};			      
   
 private:
+  G4VEmProcess* theDirectEMProcess;
+  G4double G4direct_CS;
   
     
Index: trunk/source/processes/electromagnetic/adjoint/include/G4AdjointInterpolator.hh
===================================================================
--- trunk/source/processes/electromagnetic/adjoint/include/G4AdjointInterpolator.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/adjoint/include/G4AdjointInterpolator.hh	(revision 1196)
@@ -24,9 +24,12 @@
 // ********************************************************************
 //
+// $Id: G4AdjointInterpolator.hh,v 1.4 2009/11/20 10:31:20 ldesorgh Exp $
+// GEANT4 tag $Name: geant4-09-03-cand-01 $
+//
 /////////////////////////////////////////////////////////////////////////////////
-//      Module:		G4AdjointInterpolator.hh
+//      Module:		G4AdjointInterpolator
 //	Author:       	L. Desorgher
-//	Date:		1st April 2007
 // 	Organisation: 	SpaceIT GmbH
+//	Contract:	ESA contract 21435/08/NL/AT
 // 	Customer:     	ESA/ESTEC
 /////////////////////////////////////////////////////////////////////////////////
@@ -77,15 +80,15 @@
 	
 	
-	size_t FindPosition(G4double& x,std::vector<double>& x_vec,size_t ind_min=0, size_t ind_max=0);
+	size_t FindPosition(G4double& x,std::vector<G4double>& x_vec,size_t ind_min=0, size_t ind_max=0);
 	
-	size_t FindPositionForLogVector(G4double& x,std::vector<double>& x_vec);
+	size_t FindPositionForLogVector(G4double& x,std::vector<G4double>& x_vec);
 	
-	G4double Interpolate(G4double& x,std::vector<double>& x_vec,std::vector<double>& y_vec,G4String InterPolMethod="Log"); //xvec should monotically increase			
+	G4double Interpolate(G4double& x,std::vector<G4double>& x_vec,std::vector<G4double>& y_vec,G4String InterPolMethod="Log"); //xvec should monotically increase			
 	
-	G4double InterpolateWithIndexVector(G4double& x,std::vector<double>& x_vec,std::vector<double>& y_vec,
+	G4double InterpolateWithIndexVector(G4double& x,std::vector<G4double>& x_vec,std::vector<G4double>& y_vec,
 					    std::vector<size_t>& index_vec, G4double x0,G4double dx); //xvec should monotically increase			
 	
 	
-	G4double InterpolateForLogVector(G4double& x,std::vector<double>& x_vec,std::vector<double>& y_vec);
+	G4double InterpolateForLogVector(G4double& x,std::vector<G4double>& x_vec,std::vector<G4double>& y_vec);
    
    private:
Index: trunk/source/processes/electromagnetic/adjoint/include/G4AdjointPhotoElectricModel.hh
===================================================================
--- trunk/source/processes/electromagnetic/adjoint/include/G4AdjointPhotoElectricModel.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/adjoint/include/G4AdjointPhotoElectricModel.hh	(revision 1196)
@@ -24,9 +24,12 @@
 // ********************************************************************
 //
+// $Id: G4AdjointPhotoElectricModel.hh,v 1.4 2009/11/20 10:31:20 ldesorgh Exp $
+// GEANT4 tag $Name: geant4-09-03-cand-01 $
+//
 /////////////////////////////////////////////////////////////////////////////////
-//      Module:		G4AdjointPhotoElectricModel.hh
+//      Module:		G4AdjointPhotoElectricModel
 //	Author:       	L. Desorgher
-//	Date:		10 October 2007
 // 	Organisation: 	SpaceIT GmbH
+//	Contract:	ESA contract 21435/08/NL/AT
 // 	Customer:     	ESA/ESTEC
 /////////////////////////////////////////////////////////////////////////////////
@@ -35,5 +38,15 @@
 // --------------
 //      ChangeHistory: 
-//	 	1 September 2007 creation by L. Desorgher  		
+//		-1 September 2007 creation by L. Desorgher  
+//		
+//		-January 2009. L. Desorgher	
+//		 Put a higher limit on the CS to avoid a high rate of  Inverse Photo e- effect at low energy. The very high adjoint CS of the reverse 
+//		 photo electric reaction produce a high rate of reverse photo electric reaction in the inner side of a shielding for eaxmple, the correction of this occurence
+//		 by weight correction in the StepDoIt method is not statistically sufficient at small energy. The problem is partially solved by setting an higher CS limit 
+//		 and compensating it by an extra weight correction factor. However when  coupling it with other reverse  processes the reverse photo-electric is still 
+//		 the source of very occasional high weight that decrease the efficiency of the computation. A way to solve this problemn is still needed but is difficult
+//		 to find as it happens in rarea case but does give a weighrt that is outside the noemal distribution. (Very Tricky!)  
+//		
+//	 	-October 2009	Correction of Element sampling. L. Desorgher		
 //
 //-------------------------------------------------------------
@@ -61,5 +74,4 @@
                                 G4bool IsScatProjToProjCase,
 				G4ParticleChange* fParticleChange);
-  
   virtual G4double AdjointCrossSection(const G4MaterialCutsCouple* aCouple,
 				G4double primEnergy,
@@ -73,4 +85,9 @@
   						       DefineDirectEMModel(aModel);} 				      
   
+  virtual void CorrectPostStepWeight(G4ParticleChange* fParticleChange, 
+  				     G4double old_weight, 
+				     G4double adjointPrimKinEnergy, 
+				     G4double projectileKinEnergy,
+				     G4bool IsScatProjToProjCase);
   
   
@@ -78,4 +95,10 @@
   G4double  xsec[40];
   G4double  totAdjointCS;
+  G4double  totBiasedAdjointCS;
+  G4double  factorCSBiasing;
+  G4double  pre_step_AdjointCS;
+  G4double  post_step_AdjointCS;
+  
+  
   G4double  shell_prob[40][40];
  
Index: trunk/source/processes/electromagnetic/adjoint/include/G4ContinuousGainOfEnergy.hh
===================================================================
--- trunk/source/processes/electromagnetic/adjoint/include/G4ContinuousGainOfEnergy.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/adjoint/include/G4ContinuousGainOfEnergy.hh	(revision 1196)
@@ -24,9 +24,12 @@
 // ********************************************************************
 //
+// $Id: G4ContinuousGainOfEnergy.hh,v 1.4 2009/11/20 10:31:20 ldesorgh Exp $
+// GEANT4 tag $Name: geant4-09-03-cand-01 $
+//
 /////////////////////////////////////////////////////////////////////////////////
-//      Module:		G4ContinuousGainOfEnergy.hh
+//      Class:		G4ContinuousGainOfEnergy
 //	Author:       	L. Desorgher
-//	Date:		10 May 2007
 // 	Organisation: 	SpaceIT GmbH
+//	Contract:	ESA contract 21435/08/NL/AT
 // 	Customer:     	ESA/ESTEC
 /////////////////////////////////////////////////////////////////////////////////
@@ -35,9 +38,12 @@
 // --------------
 //      ChangeHistory: 
-//	 	10 May 2007 creation by L. Desorgher  		
+//	 	-10 May 2007 creation by L. Desorgher  
+//		-February-March 2009 Update for protons by L.Desorgher
+//		-July August 2009  Update for ion by L.Desorgher
 //
 //-------------------------------------------------------------
 //	Documentation:
-//		Continuous process acting on adjoint particles to compute the continuous gain of energy of charged particels whern they are tracked back! 
+//		Continuous process acting on adjoint particles to compute the continuous gain of energy of charged particles when they are tracked back! 
+//		
 //
 #ifndef G4ContinuousGainOfEnergy_h
@@ -52,4 +58,5 @@
 #include "G4ParticleChange.hh"
 #include "G4VEnergyLossProcess.hh"
+#include "G4ProductionCutsTable.hh"
 
 
@@ -106,5 +113,5 @@
   inline void SetDirectEnergyLossProcess(G4VEnergyLossProcess* aProcess){theDirectEnergyLossProcess=aProcess;};  
  
-  inline void SetDirectParticle(G4ParticleDefinition* p){theDirectPartDef=p;};
+  void SetDirectParticle(G4ParticleDefinition* p);
 
 protected:
@@ -116,4 +123,6 @@
 
   void DefineMaterial(const G4MaterialCutsCouple* couple);
+  void SetDynamicMassCharge(const G4Track& track, G4double energy);
+ 
  
   // hide  assignment operator
@@ -128,6 +137,9 @@
   const G4MaterialCutsCouple* currentCouple;
   size_t   currentMaterialIndex; 
+  size_t   currentCoupleIndex; 
   G4double currentTcut;
+  G4double currentCutInRange;
   G4double preStepKinEnergy;
+  
   
  
@@ -142,4 +154,16 @@
   G4bool is_integral;
   
+  //adding for Ions
+  //----------------
+  G4bool IsIon; 
+  G4double massRatio;
+  G4double chargeSqRatio;
+  G4VEmModel* currentModel; 
+  G4double preStepChargeSqRatio;
+  G4double preStepScaledKinEnergy;
+
+  
+  
+  
   
 };
@@ -153,29 +177,15 @@
     currentCouple   = couple;
     currentMaterial = couple->GetMaterial();
-    currentMaterialIndex = couple->GetIndex();
-    currentTcut = couple->GetProductionCuts()->GetProductionCut(theDirectPartDef->GetParticleName());
-    //G4cout<<"Define Material"<<std::endl;
+    currentCoupleIndex = couple->GetIndex();
+    currentMaterialIndex = currentMaterial->GetIndex();
+    
+    size_t idx=1;
+    const std::vector<G4double>* aVec = G4ProductionCutsTable::GetProductionCutsTable()->GetEnergyCutsVector(idx);
+    currentTcut=(*aVec)[currentCoupleIndex];
+    currentCutInRange = couple->GetProductionCuts()->GetProductionCut(theDirectPartDef->GetParticleName());
+    //G4cout<<"Define Material"<<G4endl;
     //if(!meanFreePath) ResetNumberOfInteractionLengthLeft();
   }
 }
-///////////////////////////////////////////////////////
-//
-inline G4double G4ContinuousGainOfEnergy::GetContinuousStepLimit(const G4Track& track,
-                G4double , G4double , G4double& )
-{ 
-  G4double x = DBL_MAX;
-  x=.1*mm;
- 
-  //G4cout<<x<<std::endl;
-  DefineMaterial(track.GetMaterialCutsCouple());
-  preStepKinEnergy = track.GetKineticEnergy();
-  G4double maxE=1.2*preStepKinEnergy;
-  G4double r = theDirectEnergyLossProcess->GetRange(preStepKinEnergy, currentCouple);
-  G4double r1 = theDirectEnergyLossProcess->GetRange(maxE, currentCouple);
-  x=std::max(r1-r,.1);
- 
-  return x;
-  
- 
-}
+
 #endif
Index: trunk/source/processes/electromagnetic/adjoint/include/G4InversePEEffect.hh
===================================================================
--- trunk/source/processes/electromagnetic/adjoint/include/G4InversePEEffect.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/adjoint/include/G4InversePEEffect.hh	(revision 1196)
@@ -24,9 +24,12 @@
 // ********************************************************************
 //
+// $Id: G4InversePEEffect.hh,v 1.4 2009/11/20 10:31:20 ldesorgh Exp $
+// GEANT4 tag $Name: geant4-09-03-cand-01 $
+//
 /////////////////////////////////////////////////////////////////////////////////
-//      Module:		G4AdjointPEEffect.hh
+//      Module:		G4InversePEEffect.hh
 //	Author:       	L. Desorgher
-//	Date:		25 October 2007
 // 	Organisation: 	SpaceIT GmbH
+//	Contract:	ESA contract 21435/08/NL/AT
 // 	Customer:     	ESA/ESTEC
 /////////////////////////////////////////////////////////////////////////////////
@@ -45,8 +48,8 @@
 #define G4InversePEEffect_h 1
 
-#include "G4VAdjointInverseScattering.hh"
+#include "G4VAdjointReverseReaction.hh"
 #include "globals.hh"
 class G4AdjointPhotoElectricModel;
-class G4InversePEEffect: public G4VAdjointInverseScattering
+class G4InversePEEffect: public G4VAdjointReverseReaction
 
 {
Index: trunk/source/processes/electromagnetic/adjoint/include/G4VEmAdjointModel.hh
===================================================================
--- trunk/source/processes/electromagnetic/adjoint/include/G4VEmAdjointModel.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/adjoint/include/G4VEmAdjointModel.hh	(revision 1196)
@@ -24,9 +24,12 @@
 // ********************************************************************
 //
+// $Id: G4VEmAdjointModel.hh,v 1.4 2009/11/20 10:31:20 ldesorgh Exp $
+// GEANT4 tag $Name: geant4-09-03-cand-01 $
+//
 /////////////////////////////////////////////////////////////////////////////////
-//      Module:		G4VEMAdjointModel.hh
+//      Module:		G4VEMAdjointModel
 //	Author:       	L. Desorgher
-//	Date:		1st April 2007
 // 	Organisation: 	SpaceIT GmbH
+//	Contract:	ESA contract 21435/08/NL/AT
 // 	Customer:     	ESA/ESTEC
 /////////////////////////////////////////////////////////////////////////////////
@@ -35,10 +38,12 @@
 // --------------
 //      ChangeHistory: 
-//	 	1st April 2007 creation by L. Desorgher  		
+//	 	10 September 2009 Move to a virtual class. L. Desorgher
+//		1st April 2007 creation by L. Desorgher  		
 //
 //-------------------------------------------------------------
 //	Documentation:
-//		Base class for Adjoint model
-//
+//		Base class for Adjoint EM model. It is based on the use of direct G4VEmModel.
+//
+
 
 #ifndef G4VEmAdjointModel_h
@@ -69,5 +74,5 @@
 {
 
-public:
+public: // public methods
 
   G4VEmAdjointModel(const G4String& nam);
@@ -76,14 +81,12 @@
 
   //------------------------------------------------------------------------
-  // Virtual methods to be implemented for the concrete model
+  // Virtual methods to be implemented for the sample secondaries concrete model
   //------------------------------------------------------------------------
-
-  //virtual void Initialise(const G4ParticleDefinition*, const G4DataVector&) = 0;
-
-
+  
+  //virtual void Initialise()=0;
+  
   virtual void SampleSecondaries(const G4Track& aTrack,
                                 G4bool IsScatProjToProjCase,
-				G4ParticleChange* fParticleChange);
-  
+				G4ParticleChange* fParticleChange)=0;
  
 
@@ -91,4 +94,6 @@
   // Methods for adjoint processes; may be overwritten if needed;  
   //------------------------------------------------------------------------
+  
+
   virtual G4double AdjointCrossSection(const G4MaterialCutsCouple* aCouple,
 				             G4double primEnergy,
@@ -121,13 +126,22 @@
 				      );
   
-  				      
-  
-  
-  G4double DiffCrossSectionFunction1(G4double kinEnergyProj);
-  G4double DiffCrossSectionMoller(G4double kinEnergyProj,G4double kinEnergyProd);
-  
-  G4double DiffCrossSectionFunction2(G4double kinEnergyProj);
-  
-  std::vector< std::vector< G4double >* >  ComputeAdjointCrossSectionVectorPerAtomForSecond(      
+  
+  //Energy limits of adjoint secondary
+  //------------------
+  
+  virtual G4double GetSecondAdjEnergyMaxForScatProjToProjCase(G4double PrimAdjEnergy);
+  virtual G4double GetSecondAdjEnergyMinForScatProjToProjCase(G4double PrimAdjEnergy,G4double Tcut=0);
+  virtual G4double GetSecondAdjEnergyMaxForProdToProjCase(G4double PrimAdjEnergy);
+  virtual G4double GetSecondAdjEnergyMinForProdToProjCase(G4double PrimAdjEnergy);
+  
+  
+  
+  //Other Methods
+  //---------------
+  
+  void  DefineCurrentMaterial(const G4MaterialCutsCouple* couple);
+  
+  
+  std::vector< std::vector< double>* >  ComputeAdjointCrossSectionVectorPerAtomForSecond(      
 				G4double kinEnergyProd,
 				G4double Z, 
@@ -135,5 +149,5 @@
 				G4int nbin_pro_decade=10
 				);
-  std::vector< std::vector< G4double >* >  ComputeAdjointCrossSectionVectorPerAtomForScatProj(      
+  std::vector< std::vector< double>* >  ComputeAdjointCrossSectionVectorPerAtomForScatProj(      
 				G4double kinEnergyProd,
 				G4double Z, 
@@ -142,37 +156,16 @@
 				);
   
-  std::vector< std::vector< G4double >* >  ComputeAdjointCrossSectionVectorPerVolumeForSecond(      
+  std::vector< std::vector< double>* >  ComputeAdjointCrossSectionVectorPerVolumeForSecond(      
 				G4Material* aMaterial,
 				G4double kinEnergyProd,
 				G4int nbin_pro_decade=10
 				);
-  std::vector< std::vector< G4double >* >  ComputeAdjointCrossSectionVectorPerVolumeForScatProj(      
+  std::vector< std::vector< double>* >  ComputeAdjointCrossSectionVectorPerVolumeForScatProj(      
 				G4Material* aMaterial,
 				G4double kinEnergyProd,
 				G4int nbin_pro_decade=10
 				);
-				
- 
-  							
-  virtual G4double SampleAdjSecEnergyFromCSMatrix(size_t MatrixIndex,G4double prim_energy,G4bool IsScatProjToProjCase);      
-  virtual G4double SampleAdjSecEnergyFromDiffCrossSectionPerAtom(G4double prim_energy,G4bool IsScatProjToProjCase);      
-  void CorrectPostStepWeight(G4ParticleChange* fParticleChange, G4double old_weight, G4double adjointPrimKinEnergy, G4double projectileKinEnergy);      
-  
-  //Set/Get methods
-  //------------------
-  
-  virtual G4double GetSecondAdjEnergyMaxForScatProjToProjCase(G4double PrimAdjEnergy);
-  virtual G4double GetSecondAdjEnergyMinForScatProjToProjCase(G4double PrimAdjEnergy,G4double Tcut=0);
-  virtual G4double GetSecondAdjEnergyMaxForProdToProjCase(G4double PrimAdjEnergy);
-  virtual G4double GetSecondAdjEnergyMinForProdToProjCase(G4double PrimAdjEnergy);
-  
-  virtual void SetCSBiasingFactor(G4double aVal) {CS_biasing_factor = aVal;}
-  
-  
-  
-  
-  
-  
-public:  
+  
+
   
   inline void SetCSMatrices(std::vector< G4AdjointCSMatrix* >* Vec1CSMatrix, std::vector< G4AdjointCSMatrix* >* Vec2CSMatrix){
@@ -191,23 +184,11 @@
   inline G4double GetLowEnergyLimit(){return LowEnergyLimit;}
   
-  inline void SetHighEnergyLimit(G4double aVal){HighEnergyLimit=aVal;}
-  
-  inline void SetLowEnergyLimit(G4double aVal){LowEnergyLimit=aVal;}
-  
-  inline void SetCorrectWeightMode(G4bool aBool){CorrectWeightMode=aBool;};
-  
-  inline void SetApplyBiasing(G4bool aBool){ApplyBiasing=aBool;};
-  
-  			      
+  void SetHighEnergyLimit(G4double aVal);
+  
+  void SetLowEnergyLimit(G4double aVal);
+  
   inline void DefineDirectEMModel(G4VEmModel* aModel){theDirectEMModel = aModel;}
   
-  inline void SetAdjointEquivalentOfDirectPrimaryParticleDefinition(G4ParticleDefinition* aPart){
-  	theAdjEquivOfDirectPrimPartDef=aPart;
-  	if (theAdjEquivOfDirectPrimPartDef->GetParticleName() =="adj_e-")
-					theDirectPrimaryPartDef=G4Electron::Electron();
-	if (theAdjEquivOfDirectPrimPartDef->GetParticleName() =="adj_gamma")
-					theDirectPrimaryPartDef=G4Gamma::Gamma();
-  
-  }
+  void SetAdjointEquivalentOfDirectPrimaryParticleDefinition(G4ParticleDefinition* aPart);
   
   inline void SetAdjointEquivalentOfDirectSecondaryParticleDefinition(G4ParticleDefinition* aPart){
@@ -217,5 +198,5 @@
   inline void SetSecondPartOfSameType(G4bool aBool){second_part_of_same_type =aBool;}
   
-  bool GetSecondPartOfSameType(){return second_part_of_same_type;}
+  inline G4bool GetSecondPartOfSameType(){return second_part_of_same_type;}
   
   inline void SetUseMatrix(G4bool aBool) { UseMatrix = aBool;}
@@ -225,20 +206,47 @@
   
   inline void SetApplyCutInRange(G4bool aBool){ ApplyCutInRange = aBool;} 
-  inline void SetIsIonisation(G4bool aBool){ IsIonisation = aBool;} 
-  
   inline G4bool GetUseMatrix() {return UseMatrix;}
   inline G4bool GetUseMatrixPerElement(){ return UseMatrixPerElement;} 
   inline G4bool GetUseOnlyOneMatrixForAllElements(){ return UseOnlyOneMatrixForAllElements;} 
   inline G4bool GetApplyCutInRange(){ return ApplyCutInRange;} 
-  void  DefineCurrentMaterial(const G4MaterialCutsCouple* couple);
-  
-  inline G4String GetName(){ return name;} 
-
-private: //Methods
-  
-  
-  
-  				    
-protected:
+  
+  inline G4String GetName(){ return name;}
+  inline virtual void SetCSBiasingFactor(G4double aVal) {CS_biasing_factor = aVal;} 
+  				      
+protected: 
+
+  //Some of them can be overriden by daughter classes
+  
+  
+  G4double DiffCrossSectionFunction1(G4double kinEnergyProj);
+  G4double DiffCrossSectionFunction2(G4double kinEnergyProj);
+  G4double DiffCrossSectionPerVolumeFunctionForIntegrationOverEkinProj(G4double EkinProd);
+  
+  
+				
+  //General methods to sample secondary energy 
+  //--------------------------------------
+  G4double SampleAdjSecEnergyFromCSMatrix(size_t MatrixIndex,G4double prim_energy,G4bool IsScatProjToProjCase);
+  G4double SampleAdjSecEnergyFromCSMatrix(G4double prim_energy,G4bool IsScatProjToProjCase);
+  void	   SelectCSMatrix(G4bool IsScatProjToProjCase); 		      
+ 
+  virtual G4double SampleAdjSecEnergyFromDiffCrossSectionPerAtom(G4double prim_energy,G4bool IsScatProjToProjCase);
+  
+  
+  
+  //Post  Step weight correction
+  //----------------------------
+  virtual void CorrectPostStepWeight(G4ParticleChange* fParticleChange, 
+  				     G4double old_weight, 
+				     G4double adjointPrimKinEnergy, 
+				     G4double projectileKinEnergy,
+				     G4bool IsScatProjToProjCase);      
+  
+ 
+  
+ 
+ 
+  
+protected: //attributes
   
   G4VEmModel* theDirectEMModel;
@@ -246,11 +254,6 @@
   
 
-protected:
-
-  //  hide assignment operator
-  G4VEmAdjointModel & operator=(const  G4VEmAdjointModel &right);
-  G4VEmAdjointModel(const  G4VEmAdjointModel&);
-  
-  
+
+ 
   //Name
   //-----
@@ -266,4 +269,5 @@
   G4double kinEnergyProdForIntegration;
   G4double kinEnergyScatProjForIntegration;
+  G4double kinEnergyProjForIntegration;
   
   
@@ -274,8 +278,13 @@
   std::vector< G4AdjointCSMatrix* >* pOnCSMatrixForProdToProjBackwardScattering;
   std::vector< G4AdjointCSMatrix* >* pOnCSMatrixForScatProjToProjBackwardScattering;
-  std::vector<double> CS_Vs_ElementForScatProjToProjCase;
-  std::vector<double> CS_Vs_ElementForProdToProjCase;
+  std::vector<G4double> CS_Vs_ElementForScatProjToProjCase;
+  std::vector<G4double> CS_Vs_ElementForProdToProjCase;
   
   G4double lastCS;
+  G4double lastAdjointCSForScatProjToProjCase;
+  G4double lastAdjointCSForProdToProjCase;
+  
+  
+  
   
   //particle definition
@@ -286,4 +295,9 @@
   G4ParticleDefinition*	theDirectPrimaryPartDef;
   G4bool second_part_of_same_type;
+  
+  
+  //Prestep energy
+  //-------------
+  G4double preStepEnergy;
   
   //Current couple material
@@ -298,13 +312,5 @@
   
  
-  //CorrectWeightMode
-  //------------------
-  
-  bool CorrectWeightMode;
-  
-  //Apply biasing
-  //------------
-  
-  bool ApplyBiasing;
+ 
   
   
@@ -317,4 +323,5 @@
   G4double HighEnergyLimit;
   G4double LowEnergyLimit; 
+
   
   
@@ -326,8 +333,15 @@
   //Type of Model with Matrix or not
   //--------------------------------
-   bool UseMatrix;
-   bool UseMatrixPerElement; //other possibility is per Material
-   bool UseOnlyOneMatrixForAllElements;
-   bool IsIonisation;
+   G4bool UseMatrix;
+   G4bool UseMatrixPerElement; //other possibility is per Material
+   G4bool UseOnlyOneMatrixForAllElements;
+  
+  
+   //Index of Cross section matrices to be used
+   //------------
+   size_t indexOfUsedCrossSectionMatrix;
+   
+   
+   
    
    
Index: trunk/source/processes/electromagnetic/adjoint/include/G4eInverseBremsstrahlung.hh
===================================================================
--- trunk/source/processes/electromagnetic/adjoint/include/G4eInverseBremsstrahlung.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/adjoint/include/G4eInverseBremsstrahlung.hh	(revision 1196)
@@ -24,9 +24,12 @@
 // ********************************************************************
 //
+// $Id: G4eInverseBremsstrahlung.hh,v 1.4 2009/11/20 10:31:20 ldesorgh Exp $
+// GEANT4 tag $Name: geant4-09-03-cand-01 $
+//
 /////////////////////////////////////////////////////////////////////////////////
 //      Module:		G4eInverseBremstrahlung.hh
 //	Author:       	L. Desorgher
-//	Date:		25 October 2007
 // 	Organisation: 	SpaceIT GmbH
+//	Contract:	ESA contract 21435/08/NL/AT
 // 	Customer:     	ESA/ESTEC
 /////////////////////////////////////////////////////////////////////////////////
@@ -46,9 +49,9 @@
 #define G4eInverseBremsstrahlung_h 1
 
-#include "G4VAdjointInverseScattering.hh"
+#include "G4VAdjointReverseReaction.hh"
 #include "globals.hh"
 #include "G4eIonisation.hh"
 class G4AdjointBremsstrahlungModel;
-class G4eInverseBremsstrahlung: public G4VAdjointInverseScattering
+class G4eInverseBremsstrahlung: public G4VAdjointReverseReaction
 
 {
Index: trunk/source/processes/electromagnetic/adjoint/include/G4eInverseCompton.hh
===================================================================
--- trunk/source/processes/electromagnetic/adjoint/include/G4eInverseCompton.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/adjoint/include/G4eInverseCompton.hh	(revision 1196)
@@ -24,9 +24,12 @@
 // ********************************************************************
 //
+// $Id: G4eInverseCompton.hh,v 1.4 2009/11/20 10:31:20 ldesorgh Exp $
+// GEANT4 tag $Name: geant4-09-03-cand-01 $
+//
 /////////////////////////////////////////////////////////////////////////////////
 //      Module:		G4eInverseCompton.hh
 //	Author:       	L. Desorgher
-//	Date:		25 October 2007
 // 	Organisation: 	SpaceIT GmbH
+//	Contract:	ESA contract 21435/08/NL/AT
 // 	Customer:     	ESA/ESTEC
 /////////////////////////////////////////////////////////////////////////////////
@@ -46,9 +49,9 @@
 #define G4eInverseCompton_h 1
 
-#include "G4VAdjointInverseScattering.hh"
+#include "G4VAdjointReverseReaction.hh"
 #include "globals.hh"
 #include "G4eIonisation.hh"
 class G4AdjointComptonModel;
-class G4eInverseCompton: public G4VAdjointInverseScattering
+class G4eInverseCompton: public G4VAdjointReverseReaction
 
 {
Index: trunk/source/processes/electromagnetic/adjoint/include/G4eInverseIonisation.hh
===================================================================
--- trunk/source/processes/electromagnetic/adjoint/include/G4eInverseIonisation.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/adjoint/include/G4eInverseIonisation.hh	(revision 1196)
@@ -24,9 +24,12 @@
 // ********************************************************************
 //
+// $Id: G4eInverseIonisation.hh,v 1.4 2009/11/20 10:31:20 ldesorgh Exp $
+// GEANT4 tag $Name: geant4-09-03-cand-01 $
+//
 /////////////////////////////////////////////////////////////////////////////////
 //      Module:		G4eInverseIonisation.hh
 //	Author:       	L. Desorgher
-//	Date:		15 April 2007
 // 	Organisation: 	SpaceIT GmbH
+//	Contract:	ESA contract 21435/08/NL/AT
 // 	Customer:     	ESA/ESTEC
 /////////////////////////////////////////////////////////////////////////////////
@@ -39,5 +42,5 @@
 //-------------------------------------------------------------
 //	Documentation:
-//		Adjoint/revrese discrete ionisation
+//		Adjoint/reverse discrete ionisation
 //
 
@@ -45,9 +48,9 @@
 #define G4eInverseIonisation_h 1
 
-#include "G4VAdjointInverseScattering.hh"
+#include "G4VAdjointReverseReaction.hh"
 #include "globals.hh"
 #include "G4eIonisation.hh"
 #include "G4VEmAdjointModel.hh"
-class G4eInverseIonisation: public G4VAdjointInverseScattering
+class G4eInverseIonisation: public G4VAdjointReverseReaction
 
 {
