Index: trunk/source/processes/electromagnetic/adjoint/GNUmakefile
===================================================================
--- trunk/source/processes/electromagnetic/adjoint/GNUmakefile	(revision 966)
+++ trunk/source/processes/electromagnetic/adjoint/GNUmakefile	(revision 966)
@@ -0,0 +1,37 @@
+# $Id: GNUmakefile,v 1.2 2008/11/14 20:47:47 vnivanch Exp $
+# --------------------------------------------------------------------
+# GNUmakefile for electromagnetic sub-library.  G.Cosmo, 14/11/2008.
+# --------------------------------------------------------------------
+
+name := G4emadjoint
+
+ifndef G4INSTALL
+  G4INSTALL = ../../../..
+endif
+
+include $(G4INSTALL)/config/architecture.gmk
+
+CPPFLAGS += -I$(G4BASE)/global/management/include \
+            -I$(G4BASE)/global/HEPRandom/include \
+            -I$(G4BASE)/global/HEPGeometry/include \
+            -I$(G4BASE)/global/HEPNumerics/include \
+            -I$(G4BASE)/geometry/management/include \
+            -I$(G4BASE)/geometry/volumes/include \
+            -I$(G4BASE)/track/include \
+            -I$(G4BASE)/processes/management/include \
+            -I$(G4BASE)/processes/cuts/include \
+            -I$(G4BASE)/processes/electromagnetic/utils/include \
+            -I$(G4BASE)/processes/electromagnetic/standard/include \
+            -I$(G4BASE)/particles/management/include \
+            -I$(G4BASE)/particles/adjoint/include \
+            -I$(G4BASE)/particles/management/include \
+            -I$(G4BASE)/particles/bosons/include \
+            -I$(G4BASE)/particles/leptons/include \
+            -I$(G4BASE)/particles/hadrons/barions/include \
+            -I$(G4BASE)/particles/hadrons/mesons/include \
+            -I$(G4BASE)/particles/hadrons/ions/include \
+            -I$(G4BASE)/intercoms/include \
+            -I$(G4BASE)/materials/include
+
+include $(G4INSTALL)/config/common.gmk
+
Index: trunk/source/processes/electromagnetic/adjoint/History
===================================================================
--- trunk/source/processes/electromagnetic/adjoint/History	(revision 966)
+++ trunk/source/processes/electromagnetic/adjoint/History	(revision 966)
@@ -0,0 +1,22 @@
+$Id: History,v 1.1 2008/11/14 19:54:40 gcosmo Exp $
+-------------------------------------------------------------------
+
+     =========================================================
+     Geant4 - an Object-Oriented Toolkit for Simulation in HEP
+     =========================================================
+
+                      Category History file
+                      ---------------------
+This file should be used by G4 developers and category coordinators
+to briefly summarize all major modifications introduced in the code
+and keep track of all category-tags.
+It DOES NOT substitute the  CVS log-message one should put at every
+committal in the CVS repository !
+
+     ----------------------------------------------------------
+     * Reverse chronological order (last date on top), please *
+     ----------------------------------------------------------
+
+14 Nov 2008: G.Cosmo (emadjoint-V09-01-00)
+- First commit.
+
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 966)
@@ -0,0 +1,138 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+/////////////////////////////////////////////////////////////////////////////////
+//      Module:		G4AdjointAlongStepWeightCorrection.hh
+//	Author:       	L. Desorgher
+//	Date:		10 May 2007
+// 	Organisation: 	SpaceIT GmbH
+// 	Customer:     	ESA/ESTEC
+/////////////////////////////////////////////////////////////////////////////////
+//
+// CHANGE HISTORY
+// --------------
+//      ChangeHistory: 
+//	 	10 May 2007 creation by L. Desorgher  		
+//
+//-------------------------------------------------------------
+//	Documentation:
+//		Continuous processes acting on adjoint particles to correct continuously their weight during the adjoint reverse tracking.
+//
+
+
+#ifndef G4AdjointAlongStepWeightCorrection_h
+#define G4AdjointAlongStepWeightCorrection_h 1
+
+#include "G4VContinuousProcess.hh"
+#include "globals.hh"
+#include "G4Material.hh"
+#include "G4MaterialCutsCouple.hh"
+#include "G4Track.hh"
+#include "G4ParticleChange.hh"
+
+class G4Step;
+class G4ParticleDefinition;
+
+
+
+class G4AdjointAlongStepWeightCorrection : public G4VContinuousProcess
+{
+public:
+
+  G4AdjointAlongStepWeightCorrection(const G4String& name = "ContinuousWeightCorrection",
+                         G4ProcessType type = fElectromagnetic);
+
+  virtual ~G4AdjointAlongStepWeightCorrection();
+
+
+protected:
+  virtual G4double GetContinuousStepLimit(const G4Track& track,
+                                                G4double previousStepSize,
+                                                G4double currentMinimumStep,
+                                                G4double& currentSafety);
+					
+
+  //------------------------------------------------------------------------
+  // Generic methods common to all processes 
+  //------------------------------------------------------------------------
+public:
+
+  void PreparePhysicsTable(const G4ParticleDefinition&);
+
+  void BuildPhysicsTable(const G4ParticleDefinition&);
+
+  G4VParticleChange* AlongStepDoIt(const G4Track&, const G4Step&);
+
+
+private:
+
+  void DefineMaterial(const G4MaterialCutsCouple* couple);
+ 
+
+
+  G4AdjointAlongStepWeightCorrection(G4AdjointAlongStepWeightCorrection &);
+  G4AdjointAlongStepWeightCorrection & operator=(const G4AdjointAlongStepWeightCorrection &right);
+
+
+
+protected:
+
+  G4ParticleChange* fParticleChange;
+  
+  
+private:
+ 
+  const G4Material*  currentMaterial;
+  const G4MaterialCutsCouple* currentCouple;
+  size_t   currentMaterialIndex; 
+  G4double currentTcut;
+  G4double preStepKinEnergy;
+  
+};
+
+inline void G4AdjointAlongStepWeightCorrection::DefineMaterial(
+            const G4MaterialCutsCouple* couple)
+{
+  if(couple != currentCouple) {
+    currentCouple   = couple;
+    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 966)
@@ -0,0 +1,133 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+/////////////////////////////////////////////////////////////////////////////////
+//      Module:		G4AdjointBremsstrahlungModel.hh
+//	Author:       	L. Desorgher
+//	Date:		15 June 2007
+// 	Organisation: 	SpaceIT GmbH
+// 	Customer:     	ESA/ESTEC
+/////////////////////////////////////////////////////////////////////////////////
+//
+// CHANGE HISTORY
+// --------------
+//      ChangeHistory: 
+//	 	15 June 2007 creation by L. Desorgher. Adapted from G4eBremsstrahlungModel  		
+//
+//-------------------------------------------------------------
+//	Documentation:
+//		Adjoint Model for e- Bremsstrahlung
+//
+
+
+
+#ifndef G4AdjointBremsstrahlungModel_h
+#define G4AdjointBremsstrahlungModel_h 1
+#include "globals.hh"
+#include "G4VEmAdjointModel.hh"
+#include "G4eBremsstrahlungModel.hh"
+class G4Timer;
+class G4AdjointBremsstrahlungModel: public G4VEmAdjointModel
+
+{
+public:
+
+  G4AdjointBremsstrahlungModel();
+  ~G4AdjointBremsstrahlungModel();
+  virtual void SampleSecondaries(const G4Track& aTrack,
+                                G4bool IsScatProjToProjCase,
+				G4ParticleChange* fParticleChange);
+  
+  virtual G4double DiffCrossSectionPerVolumePrimToSecond(
+  				      const G4Material* aMaterial,
+                                      G4double kinEnergyProj,  // kinetic energy of the primary particle before the interaction 
+                                      G4double kinEnergyProd // kinetic energy of the secondary particle 
+				      ); 
+  G4double DiffCrossSectionPerVolumePrimToSecond1(
+  				      const G4Material* aMaterial,
+                                      G4double kinEnergyProj,  // kinetic energy of the primary particle before the interaction 
+                                      G4double kinEnergyProd // kinetic energy of the secondary particle 
+				      ); 
+  G4double DiffCrossSectionPerVolumePrimToSecond2(
+  				      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;}
+ 				      
+  
+private:
+  
+  void InitialiseParameters();
+  G4double SupressionFunction(const G4Material* material, G4double tkin,
+                                    G4double gammaEnergy);
+				    
+
+private:  
+  G4eBremsstrahlungModel* theDirectBremModel;
+
+  G4double highKinEnergy;
+  G4double lowKinEnergy;
+  G4double probsup;
+  G4double MigdalConstant;
+  G4double LPMconstant;
+  G4double highEnergyTh;
+  G4bool   theLPMflag;
+  G4bool   isElectron;
+  
+  //Vector 
+  
+  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;
+  
+  
+};
+
+#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 966)
@@ -0,0 +1,207 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+/////////////////////////////////////////////////////////////////////////////////
+//      Module:		G4AdjointCSManager.hh
+//	Author:       	L. Desorgher
+//	Date:		1st April 2007
+// 	Organisation: 	SpaceIT GmbH
+// 	Customer:     	ESA/ESTEC
+/////////////////////////////////////////////////////////////////////////////////
+//
+// CHANGE HISTORY
+// --------------
+//      ChangeHistory: 
+//	 	1st April 2007 creation by 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. 
+//		It is also used to sample an adjoint secondary from a given adjoint cross section matrix.
+//
+#ifndef G4AdjointCSManager_h
+#define G4AdjointCSManager_h 1
+
+#include"globals.hh"
+#include<vector>
+#include"G4AdjointCSMatrix.hh"
+
+
+class G4VEmAdjointModel;
+class G4MaterialCutsCouple;
+class G4Material;
+class G4ParticleDefinition;
+class G4Element;
+class G4VEmProcess;
+class G4VEnergyLossProcess;
+class G4PhysicsTable;
+
+////////////////////////////////////////////////////////////////////////////////
+//
+class G4AdjointCSManager
+{
+	
+  public:
+        ~G4AdjointCSManager();
+	static G4AdjointCSManager* GetAdjointCSManager();
+
+  public:
+        G4int GetNbProcesses();
+	
+	//Registration of the different models and processes
+	
+	void RegisterEmAdjointModel(G4VEmAdjointModel*);
+	
+	void RegisterEmProcess(G4VEmProcess* aProcess, G4ParticleDefinition* aPartDef);
+	
+	void RegisterEnergyLossProcess(G4VEnergyLossProcess* aProcess, G4ParticleDefinition* aPartDef);
+	
+	void RegisterAdjointParticle(G4ParticleDefinition* aPartDef);
+	
+	//Building of thr CS Matrices and Total Forward and Adjoint LambdaTables
+	//----------------------------------------------------------------------
+	
+	void BuildCrossSectionMatrices();
+	void BuildTotalSigmaTables();
+	
+	
+	//Get TotalCrossSections form Total Lambda Tables
+	//-------------------------------------------------
+	G4double GetTotalAdjointCS(G4ParticleDefinition* aPartDef, G4double Ekin,
+	 		   	     const G4MaterialCutsCouple* aCouple);
+	G4double GetTotalForwardCS(G4ParticleDefinition* aPartDef, G4double Ekin,
+	 		   	     const G4MaterialCutsCouple* aCouple);			     
+	
+	
+	
+	//Weight correction 
+	//------------------
+	
+	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);
+				     
+	
+	double ComputeAdjointCS(G4Material* aMaterial,
+					    G4VEmAdjointModel* aModel, 
+					    G4double PrimEnergy,
+					    G4double Tcut,
+					    G4bool IsScatProjToProjCase,
+					    std::vector<double>& 
+					         AdjointCS_for_each_element);
+					 
+	
+	G4Element*  SampleElementFromCSMatrices(G4Material* aMaterial,
+						       G4VEmAdjointModel* aModel,
+					 	       G4double PrimEnergy,
+						        G4double Tcut,
+						       G4bool IsScatProjToProjCase);
+	G4double ComputeTotalAdjointCS(const G4MaterialCutsCouple* aMatCutCouple,G4ParticleDefinition* aPart,G4double PrimEnergy);							
+	G4ParticleDefinition* GetAdjointParticleEquivalent(G4ParticleDefinition* theFwdPartDef);
+	G4ParticleDefinition* GetForwardParticleEquivalent(G4ParticleDefinition* theAdjPartDef);
+	
+	//inline
+	inline void SetTmin(G4double aVal){Tmin=aVal;}
+	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;}
+	
+	
+	
+	
+  private:
+        static 	G4AdjointCSManager* theInstance;
+  	std::vector< std::vector<G4AdjointCSMatrix*> > theAdjointCSMatricesForScatProjToProj; //x dim is for G4VAdjointEM* while y dim is for elements
+	std::vector< std::vector<G4AdjointCSMatrix*> > theAdjointCSMatricesForProdToProj;
+	std::vector< G4VEmAdjointModel*> listOfAdjointEMModel;
+		
+	std::vector<G4AdjointCSMatrix*> 
+				BuildCrossSectionsMatricesForAGivenModelAndElement(G4VEmAdjointModel* aModel,
+										   G4int Z,
+										   G4int A,
+										   G4int nbin_pro_decade);
+	
+	std::vector<G4AdjointCSMatrix*> 
+				BuildCrossSectionsMatricesForAGivenModelAndMaterial(G4VEmAdjointModel* aModel,
+										   G4Material* aMaterial,
+										   G4int nbin_pro_decade);
+	
+	
+	G4Material* lastMaterial;
+	G4double    lastPrimaryEnergy;
+	G4double    lastTcut;	
+	std::vector< size_t> listOfIndexOfAdjointEMModelInAction;
+	std::vector< G4bool> listOfIsScatProjToProjCase;
+	std::vector< std::vector<double> > lastAdjointCSVsModelsAndElements;
+	G4bool CrossSectionMatrixesAreBuilt;
+	
+	//total adjoint and total forward cross section table in function of material and in function of adjoint particle type
+	//--------------------------------------------------------------------------------------------------------------------
+	std::vector<G4PhysicsTable*>        theTotalForwardSigmaTableVector;
+	std::vector<G4PhysicsTable*>        theTotalAdjointSigmaTableVector;
+	 
+	//list of forward G4VEMLossProcess and of G4VEMProcess for the different adjoint particle
+	//--------------------------------------------------------------
+	std::vector< std::vector<G4VEmProcess*>* >		listOfForwardEmProcess;
+	std::vector< std::vector<G4VEnergyLossProcess*>* > 	listOfForwardEnergyLossProcess;
+	
+	//list of adjoint particles considered
+	
+	std::vector< G4ParticleDefinition*> theListOfAdjointParticlesInAction;
+	
+	
+	G4double Tmin,Tmax;
+	G4int nbins;
+	
+	
+	//Current material
+	//----------------
+	G4MaterialCutsCouple* currentCouple;  
+	G4Material* currentMaterial;
+	size_t  currentMatIndex;
+	
+	int verbose;
+	
+	
+	//Weight correction
+	//------------------
+	G4bool consider_continuous_weight_correction;
+	G4bool consider_poststep_weight_correction;
+
+  private:
+        G4AdjointCSManager();  
+	void DefineCurrentMaterial(const G4MaterialCutsCouple* couple);
+	double ComputeAdjointCS(G4double aPrimEnergy, G4AdjointCSMatrix* anAdjointCSMatrix, G4double Tcut);
+
+};
+#endif
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 966)
@@ -0,0 +1,103 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+/////////////////////////////////////////////////////////////////////////////////
+//      Module:		G4AdjointCSMatrix.hh
+//	Author:       	L. Desorgher
+//	Date:		1st April 2007
+// 	Organisation: 	SpaceIT GmbH
+// 	Customer:     	ESA/ESTEC
+/////////////////////////////////////////////////////////////////////////////////
+//
+// CHANGE HISTORY
+// --------------
+//      ChangeHistory: 
+//	 	1st April 2007 creation by L. Desorgher  		
+//
+//-------------------------------------------------------------
+//	Documentation:
+//		An adjoint CS matrix is used by the model of a reverse process to sample an adjoint secondary (being equivalent to a forward primary). 
+//		It represents the integration over the energy of the adjoint secondary (therefore the forward primary) of the differential cross section 
+//		of the equiavlent forward  discrete process (Ionisation, Brem, PE effect, Compton,..) . Each reverse model has its own cross section matrix for a given cut, 
+//		material couple. It is therefore recompute after a modification  of the cuts by the user. 
+//		
+//		
+//
+
+#ifndef G4AdjointCSMatrix_h
+#define G4AdjointCSMatrix_h 1
+
+#include"globals.hh"
+#include<vector>
+#include"G4ParticleDefinition.hh"
+
+////////////////////////////////////////////////////////////////////////////////
+//
+class G4AdjointCSMatrix
+{
+        ////////////////////////////////
+        // Constructors and Destructor
+        ////////////////////////////////
+public:
+	G4AdjointCSMatrix(G4bool aBool);
+	~G4AdjointCSMatrix();
+
+        ////////////
+        // Methods
+	////////////
+	void Clear();
+	void AddData(G4double aPrimEnergy,G4double aCS, std::vector< G4double>* aLogSecondEnergyVector,
+	 					        std::vector< G4double>* 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,
+								      std::vector< size_t>*& aLogProbVectorIndex);
+	
+	inline std::vector< G4double >* GetLogPrimEnergyVector(){return &theLogPrimEnergyVector;}
+	inline std::vector< G4double >* GetLogCrossSectionvector(){return &theLogCrossSectionVector;}
+	inline G4double GetDlog(){return dlog;} 	
+	inline G4bool IsScatProjToProjCase(){return is_scat_proj_to_proj_case;} 
+	void Write(G4String file_name);
+	void Read(G4String file_name);		
+
+private:
+        
+	// 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 
+								      // in function of their energy 
+	std::vector< std::vector< size_t >* > theLogProbMatrixIndex; //index of euqidistant LogProb
+	std::vector< G4double > log0Vector;
+	
+	unsigned int nb_of_PrimEnergy;
+	G4bool is_scat_proj_to_proj_case;
+	G4double dlog;
+	
+
+};
+#endif
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 966)
@@ -0,0 +1,86 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+/////////////////////////////////////////////////////////////////////////////////
+//      Module:		G4AdjointComptonModel.hh
+//	Author:       	L. Desorgher
+//	Date:		1 September 2007
+// 	Organisation: 	SpaceIT GmbH
+// 	Customer:     	ESA/ESTEC
+/////////////////////////////////////////////////////////////////////////////////
+//
+// CHANGE HISTORY
+// --------------
+//      ChangeHistory: 
+//	 	1 September 2007 creation by L. Desorgher  		
+//
+//-------------------------------------------------------------
+//	Documentation:
+//		Model for the adjoint compton scattering
+//
+
+#ifndef G4AdjointComptonModel_h
+#define G4AdjointComptonModel_h 1
+
+
+#include "globals.hh"
+#include "G4VEmAdjointModel.hh"
+class G4AdjointComptonModel: public G4VEmAdjointModel
+
+{
+public:
+
+  G4AdjointComptonModel();
+  ~G4AdjointComptonModel(); 
+  
+  
+  virtual void SampleSecondaries(const G4Track& aTrack,
+                                G4bool IsScatProjToProjCase,
+				G4ParticleChange* fParticleChange);
+  
+  virtual G4double DiffCrossSectionPerAtomPrimToScatPrim( 
+                                      G4double kinEnergyProj,  // kinetic energy of the primary particle before the interaction 
+                                      G4double kinEnergyScatProj, // kinetic energy of the primary particle after the interaction 
+				      G4double Z, 
+                                      G4double A = 0.); 
+  virtual G4double DiffCrossSectionPerAtomPrimToSecond(
+                                      G4double kinEnergyProj,  // kinetic energy of the primary particle before the interaction 
+                                      G4double kinEnergyProd, // kinetic energy of the secondary particle 
+				      G4double Z, 
+                                      G4double A = 0.);
+  virtual G4double GetSecondAdjEnergyMaxForScatProjToProjCase(G4double PrimAdjEnergy);
+  virtual G4double GetSecondAdjEnergyMinForProdToProjCase(G4double PrimAdjEnergy);
+
+
+  
+  
+  			      
+  
+private:
+  
+    
+};
+
+#endif
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 966)
@@ -0,0 +1,98 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+/////////////////////////////////////////////////////////////////////////////////
+//      Module:		G4AdjointInterpolator.hh
+//	Author:       	L. Desorgher
+//	Date:		1st April 2007
+// 	Organisation: 	SpaceIT GmbH
+// 	Customer:     	ESA/ESTEC
+/////////////////////////////////////////////////////////////////////////////////
+//
+// CHANGE HISTORY
+// --------------
+//      ChangeHistory: 
+//	 	1st April 2007 creation by L. Desorgher  		
+//
+//-------------------------------------------------------------
+//	Documentation:
+//		Used by  G4AdjointCSManager for interpolation purpose. 
+//
+#ifndef G4AdjointInterpolator_h
+#define G4AdjointInterpolator_h 1
+
+#include"globals.hh"
+#include<vector>
+
+////////////////////////////////////////////////////////////////////////////////
+//
+class G4AdjointInterpolator
+{
+	
+  public:
+	static G4AdjointInterpolator* GetAdjointInterpolator();
+	static G4AdjointInterpolator* GetInstance();
+        
+  public:
+ 
+	 ////////////////////////////////
+        // Constructors and Destructor
+        ////////////////////////////////
+ 
+	
+	~G4AdjointInterpolator();
+
+        ////////////
+        // Methods
+	////////////
+	
+	//Caution everywher it is considere thta x_vec increase monotically
+	
+	G4double LinearInterpolation(G4double& x,G4double& x1,G4double& x2,G4double& y1,G4double& y2); 
+	G4double LogarithmicInterpolation(G4double& x,G4double& x1,G4double& x2,G4double& y1,G4double& y2);
+	G4double ExponentialInterpolation(G4double& x,G4double& x1,G4double& x2,G4double& y1,G4double& y2);
+	G4double Interpolation(G4double& x,G4double& x1,G4double& x2,G4double& y1,G4double &y2,G4String InterPolMethod="Log");
+	
+	
+	size_t FindPosition(G4double& x,std::vector<double>& x_vec,size_t ind_min=0, size_t ind_max=0);
+	
+	size_t FindPositionForLogVector(G4double& x,std::vector<double>& x_vec);
+	
+	G4double Interpolate(G4double& x,std::vector<double>& x_vec,std::vector<double>& y_vec,G4String InterPolMethod="Log"); //xvec should monotically increase			
+	
+	G4double InterpolateWithIndexVector(G4double& x,std::vector<double>& x_vec,std::vector<double>& 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);
+   
+   private:
+  	static 	G4AdjointInterpolator* theInstance;
+   
+   private:
+  	G4AdjointInterpolator();  
+        
+};
+#endif
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 966)
@@ -0,0 +1,94 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+/////////////////////////////////////////////////////////////////////////////////
+//      Module:		G4AdjointPhotoElectricModel.hh
+//	Author:       	L. Desorgher
+//	Date:		10 October 2007
+// 	Organisation: 	SpaceIT GmbH
+// 	Customer:     	ESA/ESTEC
+/////////////////////////////////////////////////////////////////////////////////
+//
+// CHANGE HISTORY
+// --------------
+//      ChangeHistory: 
+//	 	1 September 2007 creation by L. Desorgher  		
+//
+//-------------------------------------------------------------
+//	Documentation:
+//		Model for the adjoint photo electric process
+//
+#ifndef G4AdjointPhotoElectricModel_h
+#define G4AdjointPhotoElectricModel_h 1
+
+
+#include "globals.hh"
+#include "G4VEmAdjointModel.hh"
+#include "G4PEEffectModel.hh"
+class G4AdjointPhotoElectricModel: public G4VEmAdjointModel
+
+{
+public:
+
+  G4AdjointPhotoElectricModel();
+  ~G4AdjointPhotoElectricModel();
+  
+  
+  
+  virtual void SampleSecondaries(const G4Track& aTrack,
+                                G4bool IsScatProjToProjCase,
+				G4ParticleChange* fParticleChange);
+  
+  virtual G4double AdjointCrossSection(const G4MaterialCutsCouple* aCouple,
+				G4double primEnergy,
+				G4bool IsScatProjToProjCase);
+  				
+  G4double AdjointCrossSectionPerAtom(const G4Element*  anElement,G4double electronEnergy);
+  
+  
+  
+  inline void SetTheDirectPEEffectModel(G4PEEffectModel* aModel){theDirectPEEffectModel = aModel; 
+  						       DefineDirectEMModel(aModel);} 				      
+  
+  
+  
+private:
+  G4double  xsec[40];
+  G4double  totAdjointCS;
+  G4double  shell_prob[40][40];
+ 
+  
+  G4PEEffectModel* theDirectPEEffectModel;
+  size_t index_element;
+  G4double current_eEnergy;
+  
+  
+private:  
+  void DefineCurrentMaterialAndElectronEnergy(const G4MaterialCutsCouple* aCouple,
+				G4double eEnergy);
+    
+};
+
+#endif
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 966)
@@ -0,0 +1,181 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+/////////////////////////////////////////////////////////////////////////////////
+//      Module:		G4ContinuousGainOfEnergy.hh
+//	Author:       	L. Desorgher
+//	Date:		10 May 2007
+// 	Organisation: 	SpaceIT GmbH
+// 	Customer:     	ESA/ESTEC
+/////////////////////////////////////////////////////////////////////////////////
+//
+// CHANGE HISTORY
+// --------------
+//      ChangeHistory: 
+//	 	10 May 2007 creation 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! 
+//
+#ifndef G4ContinuousGainOfEnergy_h
+#define G4ContinuousGainOfEnergy_h 1
+
+#include "G4VContinuousProcess.hh"
+#include "globals.hh"
+#include "G4Material.hh"
+#include "G4MaterialCutsCouple.hh"
+#include "G4Track.hh"
+#include "G4UnitsTable.hh"
+#include "G4ParticleChange.hh"
+#include "G4VEnergyLossProcess.hh"
+
+
+class G4Step;
+class G4ParticleDefinition;
+class G4VEmModel;
+class G4VEmFluctuationModel;
+
+
+
+class G4ContinuousGainOfEnergy : public G4VContinuousProcess
+{
+public:
+
+  G4ContinuousGainOfEnergy(const G4String& name = "EnergyGain",
+                         G4ProcessType type = fElectromagnetic);
+
+  virtual ~G4ContinuousGainOfEnergy();
+
+
+protected:
+
+ 
+  //------------------------------------------------------------------------
+  // Methods with standard implementation; may be overwritten if needed 
+  //------------------------------------------------------------------------
+protected:
+
+ 
+  virtual G4double GetContinuousStepLimit(const G4Track& track,
+                                                G4double previousStepSize,
+                                                G4double currentMinimumStep,
+                                                G4double& currentSafety);
+					
+
+  //------------------------------------------------------------------------
+  // Generic methods common to all processes 
+  //------------------------------------------------------------------------
+public:
+
+  
+
+  void PreparePhysicsTable(const G4ParticleDefinition&);
+
+  void BuildPhysicsTable(const G4ParticleDefinition&);
+
+ 
+  G4VParticleChange* AlongStepDoIt(const G4Track&, const G4Step&);
+
+
+  void SetLossFluctuations(G4bool val);
+  inline void SetIsIntegral(G4bool val){is_integral= val;}
+  
+  inline void SetDirectEnergyLossProcess(G4VEnergyLossProcess* aProcess){theDirectEnergyLossProcess=aProcess;};  
+ 
+  inline void SetDirectParticle(G4ParticleDefinition* p){theDirectPartDef=p;};
+
+protected:
+
+  
+ 
+
+private:
+
+  void DefineMaterial(const G4MaterialCutsCouple* couple);
+ 
+  // hide  assignment operator
+
+  G4ContinuousGainOfEnergy(G4ContinuousGainOfEnergy &);
+  G4ContinuousGainOfEnergy & operator=(const G4ContinuousGainOfEnergy &right);
+
+  
+private:
+ 
+  const G4Material*  currentMaterial;
+  const G4MaterialCutsCouple* currentCouple;
+  size_t   currentMaterialIndex; 
+  G4double currentTcut;
+  G4double preStepKinEnergy;
+  
+ 
+  G4double linLossLimit; 
+  G4bool   lossFluctuationFlag;
+  G4bool   lossFluctuationArePossible;
+  
+  G4VEnergyLossProcess* theDirectEnergyLossProcess;
+  G4ParticleDefinition* theDirectPartDef;
+ 
+  
+  G4bool is_integral;
+  
+  
+};
+
+///////////////////////////////////////////////////////
+//
+inline void G4ContinuousGainOfEnergy::DefineMaterial(
+            const G4MaterialCutsCouple* couple)
+{
+  if(couple != currentCouple) {
+    currentCouple   = couple;
+    currentMaterial = couple->GetMaterial();
+    currentMaterialIndex = couple->GetIndex();
+    currentTcut = couple->GetProductionCuts()->GetProductionCut(theDirectPartDef->GetParticleName());
+    //G4cout<<"Define Material"<<std::endl;
+    //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 966)
@@ -0,0 +1,62 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+/////////////////////////////////////////////////////////////////////////////////
+//      Module:		G4AdjointPEEffect.hh
+//	Author:       	L. Desorgher
+//	Date:		25 October 2007
+// 	Organisation: 	SpaceIT GmbH
+// 	Customer:     	ESA/ESTEC
+/////////////////////////////////////////////////////////////////////////////////
+//
+// CHANGE HISTORY
+// --------------
+//      ChangeHistory: 
+//	 	25 October 2007 creation by L. Desorgher  		
+//
+//-------------------------------------------------------------
+//	Documentation:
+//		Adjoint/reverse photo electric process
+//
+
+#ifndef G4InversePEEffect_h
+#define G4InversePEEffect_h 1
+
+#include "G4VAdjointInverseScattering.hh"
+#include "globals.hh"
+class G4AdjointPhotoElectricModel;
+class G4InversePEEffect: public G4VAdjointInverseScattering
+
+{
+public:
+
+  G4InversePEEffect(G4String process_name, G4AdjointPhotoElectricModel* aModel);
+  ~G4InversePEEffect();
+  
+private:
+    
+};
+
+#endif
Index: trunk/source/processes/electromagnetic/adjoint/include/G4VAdjointInverseScattering.hh
===================================================================
--- trunk/source/processes/electromagnetic/adjoint/include/G4VAdjointInverseScattering.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/adjoint/include/G4VAdjointInverseScattering.hh	(revision 966)
@@ -0,0 +1,114 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+/////////////////////////////////////////////////////////////////////////////////
+//      Module:		G4VAdjointInverseScattering.hh
+//	Author:       	L. Desorgher
+//	Date:		1st April 2007
+// 	Organisation: 	SpaceIT GmbH
+// 	Customer:     	ESA/ESTEC
+/////////////////////////////////////////////////////////////////////////////////
+//
+// CHANGE HISTORY
+// --------------
+//      ChangeHistory: 
+//	 	1st April 2007 creation by L. Desorgher  		
+//
+//-------------------------------------------------------------
+//	Documentation:
+//		Abastract class for adjoint/reverse discrete scattering
+//
+
+#ifndef G4VAdjointInverseScattering_h
+#define G4VAdjointInverseScattering_h 1
+
+#include "globals.hh"
+#include "G4DynamicParticle.hh"
+#include "G4ParticleDefinition.hh"
+#include "G4MaterialCutsCouple.hh"
+#include "G4Material.hh"
+#include "G4Element.hh"
+#include "G4ElementVector.hh"
+#include "Randomize.hh"
+#include "G4ParticleDefinition.hh"
+#include "G4VDiscreteProcess.hh"
+
+
+
+class G4PhysicsTable;
+class G4Region;
+class G4VParticleChange;
+class G4ParticleChange;
+class G4Track;
+class G4VEmAdjointModel;
+class G4AdjointCSMatrix;
+class G4AdjointCSManager;
+class G4Material;
+class G4MaterialCutsCouple;
+
+
+class G4VAdjointInverseScattering : public G4VDiscreteProcess
+{
+
+public:
+
+  G4VAdjointInverseScattering(G4String process_name,G4bool whichScatCase);
+
+  virtual ~G4VAdjointInverseScattering();
+  
+public:
+  void PreparePhysicsTable(const G4ParticleDefinition&);
+  
+  void BuildPhysicsTable(const G4ParticleDefinition&);
+  
+  virtual G4VParticleChange* PostStepDoIt(const G4Track&, const G4Step&); 
+ 
+protected :// with description  
+	
+   virtual G4double GetMeanFreePath(const G4Track& track,
+                                         G4double previousStepSize,
+                                         G4ForceCondition* condition);
+
+protected:
+   G4VEmAdjointModel* theAdjointEMModel;	
+   G4ParticleChange* fParticleChange;
+   G4AdjointCSManager* theAdjointCSManager;
+  
+
+private:
+  G4Material*  currentMaterial;
+  G4MaterialCutsCouple* currentCouple;
+  size_t   currentMaterialIndex; 
+  G4double currentTcut;
+  G4double lastCS;
+  std::vector<double> CS_Vs_Element;
+  G4bool IsScatProjToProjCase;
+
+ 
+
+};  
+
+#endif
+
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 966)
@@ -0,0 +1,341 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+/////////////////////////////////////////////////////////////////////////////////
+//      Module:		G4VEMAdjointModel.hh
+//	Author:       	L. Desorgher
+//	Date:		1st April 2007
+// 	Organisation: 	SpaceIT GmbH
+// 	Customer:     	ESA/ESTEC
+/////////////////////////////////////////////////////////////////////////////////
+//
+// CHANGE HISTORY
+// --------------
+//      ChangeHistory: 
+//	 	1st April 2007 creation by L. Desorgher  		
+//
+//-------------------------------------------------------------
+//	Documentation:
+//		Base class for Adjoint model
+//
+
+#ifndef G4VEmAdjointModel_h
+#define G4VEmAdjointModel_h 1
+
+#include "globals.hh"
+#include "G4DynamicParticle.hh"
+#include "G4ParticleDefinition.hh"
+#include "G4MaterialCutsCouple.hh"
+#include "G4Material.hh"
+#include "G4Element.hh"
+#include "G4ElementVector.hh"
+#include "Randomize.hh"
+#include "G4ParticleDefinition.hh"
+#include "G4VEmModel.hh"
+#include "G4Electron.hh"
+#include "G4Gamma.hh"
+#include "G4ProductionCutsTable.hh"
+
+class G4PhysicsTable;
+class G4Region;
+class G4VParticleChange;
+class G4ParticleChange;
+class G4Track;
+class G4AdjointCSMatrix;
+
+class G4VEmAdjointModel
+{
+
+public:
+
+  G4VEmAdjointModel(const G4String& nam);
+
+  virtual ~G4VEmAdjointModel();
+
+  //------------------------------------------------------------------------
+  // Virtual methods to be implemented for the concrete model
+  //------------------------------------------------------------------------
+
+  //virtual void Initialise(const G4ParticleDefinition*, const G4DataVector&) = 0;
+
+
+  virtual void SampleSecondaries(const G4Track& aTrack,
+                                G4bool IsScatProjToProjCase,
+				G4ParticleChange* fParticleChange);
+  
+ 
+
+  //------------------------------------------------------------------------
+  // Methods for adjoint processes; may be overwritten if needed;  
+  //------------------------------------------------------------------------
+  virtual G4double AdjointCrossSection(const G4MaterialCutsCouple* aCouple,
+				             G4double primEnergy,
+				             G4bool IsScatProjToProjCase);
+  				
+  virtual G4double DiffCrossSectionPerAtomPrimToSecond(
+                                      G4double kinEnergyProj,  // kinetic energy of the primary particle before the interaction 
+                                      G4double kinEnergyProd, // kinetic energy of the secondary particle 
+				      G4double Z, 
+                                      G4double A = 0.);
+ 				      
+  virtual G4double DiffCrossSectionPerAtomPrimToScatPrim( 
+                                      G4double kinEnergyProj,  // kinetic energy of the primary particle before the interaction 
+                                      G4double kinEnergyScatProj, // kinetic energy of the primary particle after the interaction 
+				      G4double Z, 
+                                      G4double A = 0.);
+  
+ 
+  
+  virtual G4double DiffCrossSectionPerVolumePrimToSecond(
+  				      const G4Material* aMaterial,
+                                      G4double kinEnergyProj,  // kinetic energy of the primary particle before the interaction 
+                                      G4double kinEnergyProd // kinetic energy of the secondary particle 
+				      );
+ 				      
+  virtual G4double DiffCrossSectionPerVolumePrimToScatPrim(
+  				      const G4Material* aMaterial, 
+                                      G4double kinEnergyProj,  // kinetic energy of the primary particle before the interaction 
+                                      G4double kinEnergyScatProj // kinetic energy of the primary particle after the interaction 
+				      );
+  
+  				      
+  
+  
+  G4double DiffCrossSectionFunction1(G4double kinEnergyProj);
+  G4double DiffCrossSectionMoller(G4double kinEnergyProj,G4double kinEnergyProd);
+  
+  G4double DiffCrossSectionFunction2(G4double kinEnergyProj);
+  
+  std::vector< std::vector< G4double >* >  ComputeAdjointCrossSectionVectorPerAtomForSecond(      
+				G4double kinEnergyProd,
+				G4double Z, 
+                                G4double A = 0.,
+				G4int nbin_pro_decade=10
+				);
+  std::vector< std::vector< G4double >* >  ComputeAdjointCrossSectionVectorPerAtomForScatProj(      
+				G4double kinEnergyProd,
+				G4double Z, 
+                                G4double A = 0.,
+				G4int nbin_pro_decade=10
+				);
+  
+  std::vector< std::vector< G4double >* >  ComputeAdjointCrossSectionVectorPerVolumeForSecond(      
+				G4Material* aMaterial,
+				G4double kinEnergyProd,
+				G4int nbin_pro_decade=10
+				);
+  std::vector< std::vector< G4double >* >  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){
+  				 pOnCSMatrixForProdToProjBackwardScattering = Vec1CSMatrix;
+				 pOnCSMatrixForScatProjToProjBackwardScattering = Vec2CSMatrix;
+				 
+  	
+  };
+  
+  inline G4ParticleDefinition* GetAdjointEquivalentOfDirectPrimaryParticleDefinition(){return theAdjEquivOfDirectPrimPartDef;}
+  
+  inline G4ParticleDefinition* GetAdjointEquivalentOfDirectSecondaryParticleDefinition(){return theAdjEquivOfDirectSecondPartDef;}	
+  
+  inline G4double GetHighEnergyLimit(){return HighEnergyLimit;}
+  
+  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;};
+  
+  			      
+  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();
+  
+  }
+  
+  inline void SetAdjointEquivalentOfDirectSecondaryParticleDefinition(G4ParticleDefinition* aPart){
+  	theAdjEquivOfDirectSecondPartDef =aPart;
+  }
+  
+  inline void SetSecondPartOfSameType(G4bool aBool){second_part_of_same_type =aBool;}
+  
+  bool GetSecondPartOfSameType(){return second_part_of_same_type;}
+  
+  inline void SetUseMatrix(G4bool aBool) { UseMatrix = aBool;}
+  
+  inline void SetUseMatrixPerElement(G4bool aBool){ UseMatrixPerElement = aBool;}
+  inline void SetUseOnlyOneMatrixForAllElements(G4bool aBool){ UseOnlyOneMatrixForAllElements = aBool;}
+  
+  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:
+  
+  G4VEmModel* theDirectEMModel;
+  G4VParticleChange*  pParticleChange;
+  
+
+protected:
+
+  //  hide assignment operator
+  G4VEmAdjointModel & operator=(const  G4VEmAdjointModel &right);
+  G4VEmAdjointModel(const  G4VEmAdjointModel&);
+  
+  
+  //Name
+  //-----
+  
+  const G4String  name;
+  
+  //Needed for CS integration at the initialisation phase
+  //-----------------------------------------------------
+  
+  G4int ASelectedNucleus;
+  G4int ZSelectedNucleus;
+  G4Material* SelectedMaterial;
+  G4double kinEnergyProdForIntegration;
+  G4double kinEnergyScatProjForIntegration;
+  
+  
+  //for the adjoint simulation  we need for each element or material:
+  //an adjoint CS Matrix 
+  //-----------------------------
+  
+  std::vector< G4AdjointCSMatrix* >* pOnCSMatrixForProdToProjBackwardScattering;
+  std::vector< G4AdjointCSMatrix* >* pOnCSMatrixForScatProjToProjBackwardScattering;
+  std::vector<double> CS_Vs_ElementForScatProjToProjCase;
+  std::vector<double> CS_Vs_ElementForProdToProjCase;
+  
+  G4double lastCS;
+  
+  //particle definition
+  //------------------
+  
+  G4ParticleDefinition*	theAdjEquivOfDirectPrimPartDef;
+  G4ParticleDefinition*	theAdjEquivOfDirectSecondPartDef;
+  G4ParticleDefinition*	theDirectPrimaryPartDef;
+  G4bool second_part_of_same_type;
+  
+  //Current couple material
+  //----------------------
+  G4Material*  currentMaterial;
+  G4MaterialCutsCouple* currentCouple;
+  size_t   currentMaterialIndex; 
+  size_t   currentCoupleIndex; 
+  G4double currentTcutForDirectPrim;
+  G4double currentTcutForDirectSecond;
+  G4bool ApplyCutInRange;
+  
+ 
+  //CorrectWeightMode
+  //------------------
+  
+  bool CorrectWeightMode;
+  
+  //Apply biasing
+  //------------
+  
+  bool ApplyBiasing;
+  
+  
+ 
+  
+  
+  //Energy limits
+  //-------------
+  
+  G4double HighEnergyLimit;
+  G4double LowEnergyLimit; 
+  
+  
+  //Cross Section biasing factor
+  //---------------------------
+  G4double CS_biasing_factor;
+  
+  
+  //Type of Model with Matrix or not
+  //--------------------------------
+   bool UseMatrix;
+   bool UseMatrixPerElement; //other possibility is per Material
+   bool UseOnlyOneMatrixForAllElements;
+   bool IsIonisation;
+   
+   
+   
+
+  
+};
+
+
+#endif
+
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 966)
@@ -0,0 +1,64 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+/////////////////////////////////////////////////////////////////////////////////
+//      Module:		G4eInverseBremstrahlung.hh
+//	Author:       	L. Desorgher
+//	Date:		25 October 2007
+// 	Organisation: 	SpaceIT GmbH
+// 	Customer:     	ESA/ESTEC
+/////////////////////////////////////////////////////////////////////////////////
+//
+// CHANGE HISTORY
+// --------------
+//      ChangeHistory: 
+//	 	25 October 2007 creation by L. Desorgher  		
+//
+//-------------------------------------------------------------
+//	Documentation:
+//		Adjoint/reverse bremstrahlung
+//
+
+
+#ifndef G4eInverseBremsstrahlung_h
+#define G4eInverseBremsstrahlung_h 1
+
+#include "G4VAdjointInverseScattering.hh"
+#include "globals.hh"
+#include "G4eIonisation.hh"
+class G4AdjointBremsstrahlungModel;
+class G4eInverseBremsstrahlung: public G4VAdjointInverseScattering
+
+{
+public:
+
+  G4eInverseBremsstrahlung(G4bool whichScatCase, G4String process_name, G4AdjointBremsstrahlungModel* aEmAdjointModel);
+  ~G4eInverseBremsstrahlung();
+  
+private:
+    
+};
+
+#endif
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 966)
@@ -0,0 +1,64 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+/////////////////////////////////////////////////////////////////////////////////
+//      Module:		G4eInverseCompton.hh
+//	Author:       	L. Desorgher
+//	Date:		25 October 2007
+// 	Organisation: 	SpaceIT GmbH
+// 	Customer:     	ESA/ESTEC
+/////////////////////////////////////////////////////////////////////////////////
+//
+// CHANGE HISTORY
+// --------------
+//      ChangeHistory: 
+//	 	25 October 2007 creation by L. Desorgher  		
+//
+//-------------------------------------------------------------
+//	Documentation:
+//		Adjoint/reverse Compton
+//
+
+
+#ifndef G4eInverseCompton_h
+#define G4eInverseCompton_h 1
+
+#include "G4VAdjointInverseScattering.hh"
+#include "globals.hh"
+#include "G4eIonisation.hh"
+class G4AdjointComptonModel;
+class G4eInverseCompton: public G4VAdjointInverseScattering
+
+{
+public:
+
+  G4eInverseCompton(G4bool whichScatCase, G4String process_name, G4AdjointComptonModel* aEmAdjointModel);
+  ~G4eInverseCompton();
+  
+private:
+    
+};
+
+#endif
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 966)
@@ -0,0 +1,63 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+/////////////////////////////////////////////////////////////////////////////////
+//      Module:		G4eInverseIonisation.hh
+//	Author:       	L. Desorgher
+//	Date:		15 April 2007
+// 	Organisation: 	SpaceIT GmbH
+// 	Customer:     	ESA/ESTEC
+/////////////////////////////////////////////////////////////////////////////////
+//
+// CHANGE HISTORY
+// --------------
+//      ChangeHistory: 
+//	 	15 April 2007 creation by L. Desorgher  		
+//
+//-------------------------------------------------------------
+//	Documentation:
+//		Adjoint/revrese discrete ionisation
+//
+
+#ifndef G4eInverseIonisation_h
+#define G4eInverseIonisation_h 1
+
+#include "G4VAdjointInverseScattering.hh"
+#include "globals.hh"
+#include "G4eIonisation.hh"
+#include "G4VEmAdjointModel.hh"
+class G4eInverseIonisation: public G4VAdjointInverseScattering
+
+{
+public:
+
+  G4eInverseIonisation(G4bool whichScatCase, G4String process_name, G4VEmAdjointModel* aEmAdjointModel);
+  ~G4eInverseIonisation();
+  
+private:
+    
+};
+
+#endif
Index: trunk/source/processes/electromagnetic/adjoint/src/G4AdjointAlongStepWeightCorrection.cc
===================================================================
--- trunk/source/processes/electromagnetic/adjoint/src/G4AdjointAlongStepWeightCorrection.cc	(revision 966)
+++ trunk/source/processes/electromagnetic/adjoint/src/G4AdjointAlongStepWeightCorrection.cc	(revision 966)
@@ -0,0 +1,97 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+#include "G4AdjointAlongStepWeightCorrection.hh"
+#include "G4Step.hh"
+#include "G4ParticleDefinition.hh"
+#include "G4VParticleChange.hh"
+#include "G4AdjointCSManager.hh"
+
+
+///////////////////////////////////////////////////////
+//
+
+G4AdjointAlongStepWeightCorrection::G4AdjointAlongStepWeightCorrection(const G4String& name, 
+  G4ProcessType type): G4VContinuousProcess(name, type)
+{fParticleChange = new G4ParticleChange();
+}
+
+///////////////////////////////////////////////////////
+//
+
+G4AdjointAlongStepWeightCorrection::~G4AdjointAlongStepWeightCorrection()
+{; 
+}
+
+
+///////////////////////////////////////////////////////
+//
+
+void G4AdjointAlongStepWeightCorrection::PreparePhysicsTable(
+     const G4ParticleDefinition& )
+{
+; 
+
+}
+
+///////////////////////////////////////////////////////
+//
+
+void G4AdjointAlongStepWeightCorrection::BuildPhysicsTable(const G4ParticleDefinition& )
+{;
+}
+
+
+
+
+///////////////////////////////////////////////////////
+//
+G4VParticleChange* G4AdjointAlongStepWeightCorrection::AlongStepDoIt(const G4Track& track,
+                                                       const G4Step& step)
+{
+   
+  fParticleChange->Initialize(track);
+  
+  // Get the actual (true) Step length
+  //----------------------------------
+  G4double length = step.GetStepLength();
+ 
+
+  G4double Tkin = step.GetPostStepPoint()->GetKineticEnergy();
+  G4ParticleDefinition* thePartDef= const_cast<G4ParticleDefinition*>  (track.GetDynamicParticle()->GetDefinition());
+  G4double weight_correction=G4AdjointCSManager::GetAdjointCSManager()->GetContinuousWeightCorrection(thePartDef,
+  									preStepKinEnergy,Tkin, currentCouple,length);
+	
+ 
+  
+  G4double new_weight=weight_correction*track.GetWeight();
+  fParticleChange->SetParentWeightByProcess(false);
+  fParticleChange->SetSecondaryWeightByProcess(false);
+  fParticleChange->ProposeParentWeight(new_weight);
+  
+
+  return fParticleChange;
+
+}
Index: trunk/source/processes/electromagnetic/adjoint/src/G4AdjointBremsstrahlungModel.cc
===================================================================
--- trunk/source/processes/electromagnetic/adjoint/src/G4AdjointBremsstrahlungModel.cc	(revision 966)
+++ trunk/source/processes/electromagnetic/adjoint/src/G4AdjointBremsstrahlungModel.cc	(revision 966)
@@ -0,0 +1,664 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+#include "G4AdjointBremsstrahlungModel.hh"
+#include "G4AdjointCSManager.hh"
+#include "G4Integrator.hh"
+#include "G4TrackStatus.hh"
+#include "G4ParticleChange.hh"
+#include "G4AdjointElectron.hh"
+#include "G4Timer.hh"
+
+////////////////////////////////////////////////////////////////////////////////
+//
+G4AdjointBremsstrahlungModel::G4AdjointBremsstrahlungModel():
+ G4VEmAdjointModel("AdjointBremModel"),
+ probsup(1.0),
+ MigdalConstant(classic_electr_radius*electron_Compton_length*electron_Compton_length/pi),
+ LPMconstant(fine_structure_const*electron_mass_c2*electron_mass_c2/(4.*pi*hbarc)),
+ theLPMflag(true)
+
+{ isElectron= true;
+  SetUseMatrix(true);
+  SetUseMatrixPerElement(false);
+  SetApplyCutInRange(true);
+  SetIsIonisation(false);
+  highKinEnergy= 100.*TeV;
+  lowKinEnergy = 1.0*keV;
+  theTimer =new G4Timer();
+  
+  theTimer->Start();
+  InitialiseParameters();
+  theTimer->Stop();
+  G4cout<<"Time elapsed in second for the initialidation of AdjointBrem "<<theTimer->GetRealElapsed()<<std::endl;
+  
+  ModeldCS="MODEL1";
+  
+}
+////////////////////////////////////////////////////////////////////////////////
+//
+G4AdjointBremsstrahlungModel::~G4AdjointBremsstrahlungModel()
+{;}
+////////////////////////////////////////////////////////////////////////////////
+//
+/*G4double G4AdjointBremsstrahlungModel::DiffCrossSectionPerVolumePrimToSecond(
+  				      const G4Material* aMaterial,
+                                      G4double kinEnergyProj,  // kinetic energy of the primary particle before the interaction 
+                                      G4double kinEnergyProd // kinetic energy of the secondary particle 
+				      )
+{
+ 
+ static const G4double
+     ah10 = 4.67733E+00, ah11 =-6.19012E-01, ah12 = 2.02225E-02,
+     ah20 =-7.34101E+00, ah21 = 1.00462E+00, ah22 =-3.20985E-02,
+     ah30 = 2.93119E+00, ah31 =-4.03761E-01, ah32 = 1.25153E-02;
+
+  static const G4double
+     bh10 = 4.23071E+00, bh11 =-6.10995E-01, bh12 = 1.95531E-02,
+     bh20 =-7.12527E+00, bh21 = 9.69160E-01, bh22 =-2.74255E-02,
+     bh30 = 2.69925E+00, bh31 =-3.63283E-01, bh32 = 9.55316E-03;
+
+  static const G4double
+     al00 =-2.05398E+00, al01 = 2.38815E-02, al02 = 5.25483E-04,
+     al10 =-7.69748E-02, al11 =-6.91499E-02, al12 = 2.22453E-03,
+     al20 = 4.06463E-02, al21 =-1.01281E-02, al22 = 3.40919E-04;
+
+  static const G4double
+     bl00 = 1.04133E+00, bl01 =-9.43291E-03, bl02 =-4.54758E-04,
+     bl10 = 1.19253E-01, bl11 = 4.07467E-02, bl12 =-1.30718E-03,
+     bl20 =-1.59391E-02, bl21 = 7.27752E-03, bl22 =-1.94405E-04;
+
+  static const G4double tlow = 1.*MeV;
+  
+  G4double dCrossEprod=0.;
+  G4double Emax_proj = GetSecondAdjEnergyMaxForProdToProjCase(kinEnergyProd);
+  G4double Emin_proj = GetSecondAdjEnergyMinForProdToProjCase(kinEnergyProd);
+ 
+ 
+ if (kinEnergyProj>Emin_proj && kinEnergyProj<=Emax_proj){
+ 	
+  	G4double cross = 0.0;
+	
+
+	
+	G4double E1=kinEnergyProd;
+ 	G4double E2=kinEnergyProd*1.000000001;
+ 	G4double dE=(E2-E1);
+
+  	const G4ElementVector* theElementVector = aMaterial->GetElementVector();
+  	const G4double* theAtomNumDensityVector = aMaterial->GetAtomicNumDensityVector();
+  	G4double dum=0.;
+  
+  	for (size_t i=0; i<aMaterial->GetNumberOfElements(); i++) {
+
+    		G4double fac=
+		
+		cross += theAtomNumDensityVector[i] * theDirectEMModel->ComputeCrossSectionPerAtom(G4Electron::Electron(),
+                      kinEnergyProj, (*theElementVector)[i]->GetZ(), dum,E1);
+    	
+      		
+    		
+  	} 
+ 	dCrossEprod=(cross1-cross2)/dE; //first term
+	
+	//Now come the correction
+	//-----------------------
+	
+	//First compute fsig for E1
+	//-------------------------
+	
+	
+	G4double totalEnergy = kinEnergyProj+electron_mass_c2 ;
+  	G4double kp2 = MigdalConstant*totalEnergy*totalEnergy
+                                             *(aMaterial->GetElectronDensity());
+
+  	G4double fsig = 0.;
+  	G4int nmax = 100;
+  	G4double vmin=std::log(E1);
+  	G4double vmax=std::log(kinEnergyProj) ;
+  	G4int nn = (G4int)(nmax*(vmax-vmin)/(std::log(highKinEnergy)-vmin));
+  	G4double u,fac,c,v,dv,y ;
+  	if(nn > 0) {
+
+      		dv = (vmax-vmin)/nn ;
+      		v  = vmin-dv ;
+      		for(G4int n=0; n<=nn; n++) {
+
+        		v += dv;  
+        		u = std::exp(v);              
+        		fac = SupressionFunction(aMaterial, kinEnergyProj, u);
+        		y = u/kinEnergyProj;
+        		fac *= (4.-4.*y+3.*y*y)/3.;
+        		fac *= probsup*(u*u/(u*u+kp2))+1.-probsup;
+
+        		if ((n==0)||(n==nn)) c=0.5;
+        		else    c=1. ;
+
+        		fac  *= c;
+        		fsig += fac;
+      		}
+      		y = E1/kinEnergyProj ;
+      		fsig *=dv/(-4.*std::log(y)/3.-4.*(1.-y)/3.+0.5*(1.-y*y));
+
+  	} 
+	else {
+		fsig = 1.;
+  	}
+  	if (fsig > 1.) fsig = 1.;
+	
+	dCrossEprod*=fsig;
+	//return dCrossEprod;
+	//Now we  compute dfsig 
+	//-------------------------
+	G4double dfsig = 0.;
+  	nn=20;
+	vmax=std::log(E2) ;
+	dv = (vmax-vmin)/nn ;
+      	v  = vmin-dv ;
+      	for(G4int n=0; n<=nn; n++) {
+		v += dv;  
+        	u = std::exp(v);              
+        	fac = SupressionFunction(aMaterial, kinEnergyProj, u);
+        	y = u/kinEnergyProj;
+        	fac *= (4.-4.*y+3.*y*y)/3.;
+        	fac *= probsup*(u*u/(u*u+kp2))+1.-probsup;
+
+        	if ((n==0)||(n==nn)) c=0.5;
+        	else    c=1. ;
+
+        	fac  *= c;
+        	dfsig += fac;
+      	}
+      	y = E1/kinEnergyProj;
+      	dfsig *=dv/(-4.*std::log(y)/3.-4.*(1.-y)/3.+0.5*(1.-y*y));
+	
+	dCrossEprod+=dfsig*cross1/dE;
+	
+	
+	
+	 
+	
+ }
+ return dCrossEprod;
+  
+} 
+*/
+G4double G4AdjointBremsstrahlungModel::DiffCrossSectionPerVolumePrimToSecond(const G4Material* aMaterial,
+                                      G4double kinEnergyProj,  // kinetic energy of the primary particle before the interaction 
+                                      G4double kinEnergyProd // kinetic energy of the secondary particle 
+				      )
+{if (ModeldCS=="MODEL2") return  DiffCrossSectionPerVolumePrimToSecond2(aMaterial,
+                                      			         kinEnergyProj,  // kinetic energy of the primary particle before the interaction 
+                                      			         kinEnergyProd);
+ if (ModeldCS=="MODEL3") return  DiffCrossSectionPerVolumePrimToSecond3(aMaterial,
+                                      			         kinEnergyProj,  // kinetic energy of the primary particle before the interaction 
+                                      			         kinEnergyProd);
+ return  DiffCrossSectionPerVolumePrimToSecond1(aMaterial,
+                                      			         kinEnergyProj,  // kinetic energy of the primary particle before the interaction 
+                                      			         kinEnergyProd);								 
+}				      
+////////////////////////////////////////////////////////////////////////////////
+// the one used till now
+G4double G4AdjointBremsstrahlungModel::DiffCrossSectionPerVolumePrimToSecond1(
+  				      const G4Material* aMaterial,
+                                      G4double kinEnergyProj,  // kinetic energy of the primary particle before the interaction 
+                                      G4double kinEnergyProd // kinetic energy of the secondary particle 
+				      )
+{
+ G4double dCrossEprod=0.;
+ G4double Emax_proj = GetSecondAdjEnergyMaxForProdToProjCase(kinEnergyProd);
+ G4double Emin_proj = GetSecondAdjEnergyMinForProdToProjCase(kinEnergyProd);
+ 
+ 
+ if (kinEnergyProj>Emin_proj && kinEnergyProj<=Emax_proj){
+ 	
+  	G4double cross1 = 0.0;
+	G4double cross2 = 0.0;
+
+	
+	G4double E1=kinEnergyProd;
+ 	G4double E2=kinEnergyProd*1.01;
+ 	G4double dE=(E2-E1);
+
+  	const G4ElementVector* theElementVector = aMaterial->GetElementVector();
+  	const G4double* theAtomNumDensityVector = aMaterial->GetAtomicNumDensityVector();
+  	G4double dum=0.;
+  
+  	for (size_t i=0; i<aMaterial->GetNumberOfElements(); i++) {
+
+    		cross1 += theAtomNumDensityVector[i] * theDirectEMModel->ComputeCrossSectionPerAtom(G4Electron::Electron(),
+                      kinEnergyProj, (*theElementVector)[i]->GetZ(), dum,E1);
+    	
+      		cross2 += theAtomNumDensityVector[i] * theDirectEMModel->ComputeCrossSectionPerAtom(G4Electron::Electron(),
+                     kinEnergyProj, (*theElementVector)[i]->GetZ(), dum, E2);
+    		
+  	} 
+ 	dCrossEprod=(cross1-cross2)/dE; //first term
+	
+	//Now come the correction
+	//-----------------------
+	
+	//First compute fsig for E1
+	//-------------------------
+	
+	
+	G4double totalEnergy = kinEnergyProj+electron_mass_c2 ;
+  	G4double kp2 = MigdalConstant*totalEnergy*totalEnergy
+                                             *(aMaterial->GetElectronDensity());
+
+  	G4double fsig1 = 0.;
+  	G4int nmax = 100;
+  	G4double vmin=std::log(E1);
+  	G4double vmax=std::log(kinEnergyProj) ;
+  	G4int nn = (G4int)(nmax*(vmax-vmin)/(std::log(highKinEnergy)-vmin));
+  	G4double u,fac,c,v,dv,y ;
+  	if(nn > 0) {
+
+      		dv = (vmax-vmin)/nn ;
+      		v  = vmin-dv ;
+      		for(G4int n=0; n<=nn; n++) {
+
+        		v += dv;  
+        		u = std::exp(v);              
+        		fac = SupressionFunction(aMaterial, kinEnergyProj, u);
+        		y = u/kinEnergyProj;
+        		fac *= (4.-4.*y+3.*y*y)/3.;
+        		fac *= probsup*(u*u/(u*u+kp2))+1.-probsup;
+
+        		if ((n==0)||(n==nn)) c=0.5;
+        		else    c=1. ;
+
+        		fac  *= c;
+        		fsig1 += fac;
+      		}
+      		y = E1/kinEnergyProj ;
+      		fsig1 *=dv/(-4.*std::log(y)/3.-4.*(1.-y)/3.+0.5*(1.-y*y));
+
+  	} 
+	else {
+		fsig1 = 1.;
+  	}
+  	if (fsig1 > 1.) fsig1 = 1.;
+	
+	dCrossEprod*=fsig1;
+	
+	
+	G4double fsig2 = 0.;
+  	vmin=std::log(E2);
+	nn = (G4int)(nmax*(vmax-vmin)/(std::log(highKinEnergy)-vmin));
+  	if(nn > 0) {
+
+      		dv = (vmax-vmin)/nn ;
+      		v  = vmin-dv ;
+      		for(G4int n=0; n<=nn; n++) {
+
+        		v += dv;  
+        		u = std::exp(v);              
+        		fac = SupressionFunction(aMaterial, kinEnergyProj, u);
+        		y = u/kinEnergyProj;
+        		fac *= (4.-4.*y+3.*y*y)/3.;
+        		fac *= probsup*(u*u/(u*u+kp2))+1.-probsup;
+
+        		if ((n==0)||(n==nn)) c=0.5;
+        		else    c=1. ;
+
+        		fac  *= c;
+        		fsig2 += fac;
+      		}
+      		y = E2/kinEnergyProj ;
+      		fsig2 *=dv/(-4.*std::log(y)/3.-4.*(1.-y)/3.+0.5*(1.-y*y));
+
+  	} 
+	else {
+		fsig2 = 1.;
+  	}
+  	if (fsig2 > 1.) fsig2 = 1.;
+	
+
+	G4double dfsig=(fsig2-fsig1);
+	dCrossEprod+=dfsig*cross1/dE;
+	
+	dCrossEprod=(fsig1*cross1-fsig2*cross2)/dE;
+	
+	
+	
+	
+	
+	/*if (fsig < 1.){
+		//Now we  compute dfsig 
+		//-------------------------
+		G4double dfsig = 0.;
+  		nn=20;
+		vmax=std::log(E2) ;
+		dv = (vmax-vmin)/nn ;
+      		v  = vmin-dv ;
+      		for(G4int n=0; n<=nn; n++) {
+			v += dv;  
+        		u = std::exp(v);              
+        		fac = SupressionFunction(aMaterial, kinEnergyProj, u);
+        		y = u/kinEnergyProj;
+        		fac *= (4.-4.*y+3.*y*y)/3.;
+        		fac *= probsup*(u*u/(u*u+kp2))+1.-probsup;
+
+        		if ((n==0)||(n==nn)) c=0.5;
+        		else    c=1. ;
+
+        		fac  *= c;
+        		dfsig += fac;
+      		}
+      		y = E1/kinEnergyProj;
+      		dfsig *=dv/(-4.*std::log(y)/3.-4.*(1.-y)/3.+0.5*(1.-y*y));
+		dCrossEprod+=dfsig*cross1/dE;
+		
+	}	
+	*/
+	
+	
+	
+	
+	
+	 
+	
+ }
+ return dCrossEprod;
+  
+} 
+
+
+////////////////////////////////////////////////////////////////////////////////
+//
+G4double G4AdjointBremsstrahlungModel::DiffCrossSectionPerVolumePrimToSecond2(
+  				      const G4Material* aMaterial,
+                                      G4double kinEnergyProj,  // kinetic energy of the primary particle before the interaction 
+                                      G4double kinEnergyProd // kinetic energy of the secondary particle 
+				      )
+{
+ G4double dCrossEprod=0.;
+ G4double Emax_proj = GetSecondAdjEnergyMaxForProdToProjCase(kinEnergyProd);
+ G4double Emin_proj = GetSecondAdjEnergyMinForProdToProjCase(kinEnergyProd);
+ 
+ 
+ if (kinEnergyProj>Emin_proj && kinEnergyProj<=Emax_proj){
+ 	
+  	G4double dEdX1 = 0.0;
+	G4double dEdX2 = 0.0;
+
+	
+	G4double E1=kinEnergyProd;
+ 	G4double E2=kinEnergyProd*1.001;
+ 	G4double dE=(E2-E1);
+  	//G4double dum=0.;
+	
+	dEdX1 = theDirectEMModel->ComputeDEDXPerVolume(aMaterial,G4Electron::Electron(),kinEnergyProj,E1); 
+	dEdX2 = theDirectEMModel->ComputeDEDXPerVolume(aMaterial,G4Electron::Electron(),kinEnergyProj,E2);
+	dCrossEprod=(dEdX2-dEdX1)/dE/E1;
+	
+	 
+	
+	
+	
+	 
+	
+ }
+ return dCrossEprod;
+  
+}
+////////////////////////////////////////////////////////////////////////////////
+//
+G4double G4AdjointBremsstrahlungModel::DiffCrossSectionPerVolumePrimToSecond3(
+  				      const G4Material* aMaterial,
+                                      G4double kinEnergyProj,  // kinetic energy of the primary particle before the interaction 
+                                      G4double kinEnergyProd // kinetic energy of the secondary particle 
+				      )
+{
+ 
+ return G4VEmAdjointModel::DiffCrossSectionPerVolumePrimToSecond(aMaterial,
+                                      			         kinEnergyProj,  // kinetic energy of the primary particle before the interaction 
+                                      			         kinEnergyProd);
+  
+}
+
+////////////////////////////////////////////////////////////////////////////////
+//
+G4double G4AdjointBremsstrahlungModel::SupressionFunction(const G4Material* material,
+                                 G4double kineticEnergy, G4double gammaEnergy)
+{
+  // supression due to the LPM effect+polarisation of the medium/
+  // supression due to the polarisation alone
+
+
+  G4double totEnergy = kineticEnergy+electron_mass_c2 ;
+  G4double totEnergySquare = totEnergy*totEnergy ;
+
+  G4double LPMEnergy = LPMconstant*(material->GetRadlen()) ;
+
+  G4double gammaEnergySquare = gammaEnergy*gammaEnergy ;
+
+  G4double electronDensity = material->GetElectronDensity();
+
+  G4double sp = gammaEnergySquare/
+   (gammaEnergySquare+MigdalConstant*totEnergySquare*electronDensity);
+
+  G4double supr = 1.0;
+
+  if (theLPMflag) {
+
+    G4double s2lpm = LPMEnergy*gammaEnergy/totEnergySquare;
+
+    if (s2lpm < 1.) {
+
+      G4double LPMgEnergyLimit = totEnergySquare/LPMEnergy ;
+      G4double LPMgEnergyLimit2 = LPMgEnergyLimit*LPMgEnergyLimit;
+      G4double splim = LPMgEnergyLimit2/
+        (LPMgEnergyLimit2+MigdalConstant*totEnergySquare*electronDensity);
+      G4double w = 1.+1./splim ;
+
+      if ((1.-sp) < 1.e-6) w = s2lpm*(3.-sp);
+      else                 w = s2lpm*(1.+1./sp);
+
+      supr = (std::sqrt(w*w+4.*s2lpm)-w)/(std::sqrt(w*w+4.)-w) ;
+      supr /= sp;    
+    } 
+    
+  } 
+  return supr;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+//
+void G4AdjointBremsstrahlungModel::SampleSecondaries(const G4Track& aTrack,
+                       G4bool IsScatProjToProjCase,
+	               G4ParticleChange* fParticleChange)
+{ 
+
+  //G4cout<<"Adjoint Brem"<<std::endl;
+  const G4DynamicParticle* theAdjointPrimary =aTrack.GetDynamicParticle();
+  
+  size_t ind=0;
+  
+  if (UseMatrixPerElement ) { //Select Material
+   	std::vector<double>* CS_Vs_Element = &CS_Vs_ElementForScatProjToProjCase;
+  	if ( !IsScatProjToProjCase) CS_Vs_Element = &CS_Vs_ElementForProdToProjCase;
+  	G4double rand_var= G4UniformRand();
+  	G4double SumCS=0.;
+  	for (size_t i=0;i<CS_Vs_Element->size();i++){
+ 		SumCS+=(*CS_Vs_Element)[i];
+		if (rand_var<=SumCS/lastCS){
+			ind=i;
+			break;
+		}
+  	}
+  }
+  else 	{
+  	ind = currentMaterialIndex;
+  }
+ 
+ 
+ //Elastic inverse scattering modified compared to general G4VEmAdjointModel
+ //---------------------------
+ G4double adjointPrimKinEnergy = theAdjointPrimary->GetKineticEnergy();
+ G4double adjointPrimTotalEnergy = theAdjointPrimary->GetTotalEnergy();
+ //G4double adjointPrimP =theAdjointPrimary->GetTotalMomentum();
+ if (adjointPrimKinEnergy>HighEnergyLimit*0.999){
+ 	return;
+ }
+ 
+ //Sample secondary energy
+ //-----------------------
+ 
+ G4double projectileKinEnergy = SampleAdjSecEnergyFromCSMatrix(ind,
+ 						   adjointPrimKinEnergy,
+						   IsScatProjToProjCase);
+				   
+ 
+ 
+ 
+ //Weight correction
+ //-----------------------					   
+ CorrectPostStepWeight(fParticleChange, aTrack.GetWeight(), adjointPrimKinEnergy,projectileKinEnergy);	
+ 
+ 
+ //Kinematic
+ //---------
+ 
+ G4double projectileM0 = electron_mass_c2;
+ G4double projectileTotalEnergy = projectileM0+projectileKinEnergy;
+ G4double projectileP2 = projectileTotalEnergy*projectileTotalEnergy - projectileM0*projectileM0;	
+ G4double projectileP = std::sqrt(projectileP2);
+ 
+ 
+ //Angle of the gamma direction with the projectile taken from G4eBremsstrahlungModel
+ //------------------------------------------------
+  G4double u;
+  const G4double a1 = 0.625 , a2 = 3.*a1 , d = 27. ;
+
+  if (9./(9.+d) > G4UniformRand()) u = - std::log(G4UniformRand()*G4UniformRand())/a1;
+     else                          u = - std::log(G4UniformRand()*G4UniformRand())/a2;
+
+  G4double theta = u*electron_mass_c2/projectileTotalEnergy;
+
+  G4double sint = std::sin(theta);
+  G4double cost = std::cos(theta);
+
+  G4double phi = twopi * G4UniformRand() ;
+  
+  G4ThreeVector projectileMomentum;
+  projectileMomentum=G4ThreeVector(std::cos(phi)*sint,std::sin(phi)*sint,cost)*projectileP; //gamma frame
+  if (IsScatProjToProjCase) {//the adjoint primary is the scattered e-
+  	G4ThreeVector gammaMomentum = (projectileTotalEnergy-adjointPrimTotalEnergy)*G4ThreeVector(0.,0.,1.);
+	G4ThreeVector dirProd=projectileMomentum-gammaMomentum;
+	G4double cost1 = std::cos(dirProd.angle(projectileMomentum));
+	G4double sint1 =  std::sqrt(1.-cost1*cost1);
+	projectileMomentum=G4ThreeVector(std::cos(phi)*sint1,std::sin(phi)*sint1,cost1)*projectileP;
+  
+  }
+  
+  projectileMomentum.rotateUz(theAdjointPrimary->GetMomentumDirection());
+ 
+ 
+ 
+  if (!IsScatProjToProjCase && CorrectWeightMode){ //kill the primary and add a secondary
+ 	fParticleChange->ProposeTrackStatus(fStopAndKill);
+ 	fParticleChange->AddSecondary(new G4DynamicParticle(theAdjEquivOfDirectPrimPartDef,projectileMomentum));
+	//G4cout<<"projectileMomentum "<<projectileMomentum<<std::endl;
+  }
+  else {
+ 	fParticleChange->ProposeEnergy(projectileKinEnergy);
+	fParticleChange->ProposeMomentumDirection(projectileMomentum.unit());
+	//G4cout<<"projectileMomentum "<<projectileMomentum<<std::endl;
+  }	
+} 
+////////////////////////////////////////////////////////////////////////////////
+//
+void G4AdjointBremsstrahlungModel::DefineDirectBremModel(G4eBremsstrahlungModel* aModel)
+{theDirectBremModel=aModel;
+ DefineDirectEMModel(aModel);
+} 
+////////////////////////////////////////////////////////////////////////////////
+//
+void G4AdjointBremsstrahlungModel::InitialiseParameters()
+{  
+  static const G4double
+     ah10 = 4.67733E+00, ah11 =-6.19012E-01, ah12 = 2.02225E-02,
+     ah20 =-7.34101E+00, ah21 = 1.00462E+00, ah22 =-3.20985E-02,
+     ah30 = 2.93119E+00, ah31 =-4.03761E-01, ah32 = 1.25153E-02;
+
+  static const G4double
+     bh10 = 4.23071E+00, bh11 =-6.10995E-01, bh12 = 1.95531E-02,
+     bh20 =-7.12527E+00, bh21 = 9.69160E-01, bh22 =-2.74255E-02,
+     bh30 = 2.69925E+00, bh31 =-3.63283E-01, bh32 = 9.55316E-03;
+
+ /* static const G4double
+     al00 =-2.05398E+00, al01 = 2.38815E-02, al02 = 5.25483E-04,
+     al10 =-7.69748E-02, al11 =-6.91499E-02, al12 = 2.22453E-03,
+     al20 = 4.06463E-02, al21 =-1.01281E-02, al22 = 3.40919E-04;
+
+  static const G4double
+     bl00 = 1.04133E+00, bl01 =-9.43291E-03, bl02 =-4.54758E-04,
+     bl10 = 1.19253E-01, bl11 = 4.07467E-02, bl12 =-1.30718E-03,
+     bl20 =-1.59391E-02, bl21 = 7.27752E-03, bl22 =-1.94405E-04;*/
+ 
+  
+  const G4ElementTable* theElementTable = G4Element::GetElementTable();
+  FZ.clear();
+  ah1.clear();
+  ah2.clear();
+  ah3.clear();
+  
+  bh1.clear();
+  bh2.clear();
+  bh3.clear();
+  
+  al0.clear();
+  al1.clear();
+  al2.clear();
+  
+  bl0.clear();
+  bl1.clear();
+  bl2.clear();
+  SigmaPerAtom.clear(); 
+  
+  for (size_t j=0; j<theElementTable->size();j++){
+	
+	G4Element* anElement=(*theElementTable)[j]; 
+	G4double lnZ = 3.*(anElement->GetIonisation()->GetlogZ3());
+  	FZ.push_back(lnZ* (4.- 0.55*lnZ));
+  	G4double ZZ = anElement->GetIonisation()->GetZZ3();
+	
+	ah1.push_back(ah10 + ZZ* (ah11 + ZZ* ah12));
+        ah2.push_back(ah20 + ZZ* (ah21 + ZZ* ah22));
+        ah3.push_back(ah30 + ZZ* (ah31 + ZZ* ah32));
+
+        bh1.push_back(bh10 + ZZ* (bh11 + ZZ* bh12));
+        bh2.push_back(bh20 + ZZ* (bh21 + ZZ* bh22));
+        bh3.push_back(bh30 + ZZ* (bh31 + ZZ* bh32));
+	/*SigmaPerAtom.push_back(theDirectEMModel->ComputeCrossSectionPerAtom(
+					theDirectPrimaryPartDef,GetHighEnergyLimit()/2., 
+					anElement->GetZ(),1.,GetLowEnergyLimit(),1.e20));*/
+	
+	
+  	
+  }	
+}
Index: trunk/source/processes/electromagnetic/adjoint/src/G4AdjointCSManager.cc
===================================================================
--- trunk/source/processes/electromagnetic/adjoint/src/G4AdjointCSManager.cc	(revision 966)
+++ trunk/source/processes/electromagnetic/adjoint/src/G4AdjointCSManager.cc	(revision 966)
@@ -0,0 +1,873 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+#include "G4AdjointCSManager.hh"
+#include "G4AdjointCSMatrix.hh"
+#include "G4AdjointInterpolator.hh"
+#include "G4AdjointCSMatrix.hh"
+#include "G4VEmAdjointModel.hh"
+#include "G4ElementTable.hh"
+#include "G4Element.hh"
+#include "G4ParticleDefinition.hh"
+#include "G4Element.hh"
+#include "G4VEmProcess.hh"
+#include "G4VEnergyLossProcess.hh"
+#include "G4PhysicsTable.hh" 
+#include "G4PhysicsLogVector.hh"
+#include "G4PhysicsTableHelper.hh"
+#include "G4Electron.hh"
+#include "G4Gamma.hh"
+#include "G4AdjointElectron.hh"
+#include "G4AdjointGamma.hh"
+#include "G4ProductionCutsTable.hh"
+#include "G4ProductionCutsTable.hh"
+
+
+G4AdjointCSManager* G4AdjointCSManager::theInstance = 0;
+///////////////////////////////////////////////////////
+//
+G4AdjointCSManager* G4AdjointCSManager::GetAdjointCSManager()
+{ if(theInstance == 0) {
+    static G4AdjointCSManager ins;
+     theInstance = &ins;
+  }
+ return theInstance; 
+}
+
+///////////////////////////////////////////////////////
+//
+G4AdjointCSManager::G4AdjointCSManager()
+{ CrossSectionMatrixesAreBuilt=false;
+  theTotalForwardSigmaTableVector.clear();
+  theTotalAdjointSigmaTableVector.clear();
+  listOfForwardEmProcess.clear();
+  listOfForwardEnergyLossProcess.clear();
+  theListOfAdjointParticlesInAction.clear();
+  Tmin=0.1*keV;
+  Tmax=100.*TeV;
+  nbins=240;
+  
+  RegisterAdjointParticle(G4AdjointElectron::AdjointElectron());
+  RegisterAdjointParticle(G4AdjointGamma::AdjointGamma());
+  
+  verbose  = 1;
+  
+  consider_continuous_weight_correction =true;
+  consider_poststep_weight_correction =false;
+ 
+}
+///////////////////////////////////////////////////////
+//
+G4AdjointCSManager::~G4AdjointCSManager()
+{;
+}
+///////////////////////////////////////////////////////
+//
+void G4AdjointCSManager::RegisterEmAdjointModel(G4VEmAdjointModel* aModel)
+{listOfAdjointEMModel.push_back(aModel);
+}
+///////////////////////////////////////////////////////
+//
+void G4AdjointCSManager::RegisterEmProcess(G4VEmProcess* aProcess, G4ParticleDefinition* aFwdPartDef)
+{ 
+  G4ParticleDefinition* anAdjPartDef = GetAdjointParticleEquivalent(aFwdPartDef);
+  if (anAdjPartDef && aProcess){
+  	RegisterAdjointParticle(anAdjPartDef);
+	int index=-1;
+	
+  	for (size_t i=0;i<theListOfAdjointParticlesInAction.size();i++){
+  		if (anAdjPartDef->GetParticleName() == theListOfAdjointParticlesInAction[i]->GetParticleName()) index=i;
+  	}
+  	listOfForwardEmProcess[index]->push_back(aProcess);
+  }
+}
+///////////////////////////////////////////////////////
+//
+void G4AdjointCSManager::RegisterEnergyLossProcess(G4VEnergyLossProcess* aProcess, G4ParticleDefinition* aFwdPartDef)
+{
+  G4ParticleDefinition* anAdjPartDef = GetAdjointParticleEquivalent(aFwdPartDef);
+  if (anAdjPartDef && aProcess){
+        RegisterAdjointParticle(anAdjPartDef);
+  	int index=-1;
+  	for (size_t i=0;i<theListOfAdjointParticlesInAction.size();i++){
+  		if (anAdjPartDef->GetParticleName() == theListOfAdjointParticlesInAction[i]->GetParticleName()) index=i;
+  	}
+  	listOfForwardEnergyLossProcess[index]->push_back(aProcess);
+   }
+}
+///////////////////////////////////////////////////////
+//
+void G4AdjointCSManager::RegisterAdjointParticle(G4ParticleDefinition* aPartDef)
+{  int index=-1;
+   for (size_t i=0;i<theListOfAdjointParticlesInAction.size();i++){
+  	if (aPartDef->GetParticleName() == theListOfAdjointParticlesInAction[i]->GetParticleName()) index=i;
+   }
+  
+   if (index ==-1){
+  	listOfForwardEnergyLossProcess.push_back(new std::vector<G4VEnergyLossProcess*>());
+	theTotalForwardSigmaTableVector.push_back(new G4PhysicsTable);
+	theTotalAdjointSigmaTableVector.push_back(new G4PhysicsTable);
+	listOfForwardEmProcess.push_back(new std::vector<G4VEmProcess*>());
+	theListOfAdjointParticlesInAction.push_back(aPartDef);
+   }
+}
+///////////////////////////////////////////////////////
+//
+void G4AdjointCSManager::BuildCrossSectionMatrices()
+{	
+	if (CrossSectionMatrixesAreBuilt) return;
+		//Tcut, Tmax 
+			//The matrices will be computed probably just once
+			  //When Tcut will change some PhysicsTable will be recomputed  
+			  // for each MaterialCutCouple but not all the matrices	
+			  //The Tcut defines a lower limit in the energy of the Projectile before the scattering
+			  //In the Projectile to Scattered Projectile case we have
+			  // 			E_ScatProj<E_Proj-Tcut
+			  //Therefore in the adjoint case we have
+			  //			Eproj> E_ScatProj+Tcut
+			  //This implies that when computing the adjoint CS we should integrate over Epro
+			  // from E_ScatProj+Tcut to Emax
+			  //In the Projectile to Secondary case Tcut plays a role only in the fact that  
+			  // Esecond should be greater than Tcut to have the possibility to have any adjoint
+			  //process 		 
+			  //To avoid to recompute the matrices for all changes of MaterialCutCouple
+			  //We propose to compute the matrices only once for the minimum possible Tcut and then
+			  //to interpolate the probability for a new Tcut (implemented in G4VAdjointEmModel)
+	
+	
+	theAdjointCSMatricesForScatProjToProj.clear();
+	theAdjointCSMatricesForProdToProj.clear();
+	const G4ElementTable* theElementTable = G4Element::GetElementTable();
+	const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
+	for (size_t i=0; i<listOfAdjointEMModel.size();i++){
+		G4VEmAdjointModel* aModel =listOfAdjointEMModel[i];
+		G4cout<<"Build adjoint cross section matrices for "<<aModel->GetName()<<std::endl;
+		if (aModel->GetUseMatrix()){
+			std::vector<G4AdjointCSMatrix*>* aListOfMat1 = new std::vector<G4AdjointCSMatrix*>();
+			std::vector<G4AdjointCSMatrix*>* aListOfMat2 = new std::vector<G4AdjointCSMatrix*>();
+			aListOfMat1->clear();
+			aListOfMat2->clear();
+			if (aModel->GetUseMatrixPerElement()){
+				if (aModel->GetUseOnlyOneMatrixForAllElements()){
+						std::vector<G4AdjointCSMatrix*>
+						two_matrices=BuildCrossSectionsMatricesForAGivenModelAndElement(aModel,1, 1, 10);
+						aListOfMat1->push_back(two_matrices[0]);
+						aListOfMat2->push_back(two_matrices[1]);
+				}
+				else {		
+					for (size_t j=0; j<theElementTable->size();j++){
+						G4Element* anElement=(*theElementTable)[j];
+						G4int Z = G4int(anElement->GetZ());
+						G4int A = G4int(anElement->GetA());
+						std::vector<G4AdjointCSMatrix*>
+							two_matrices=BuildCrossSectionsMatricesForAGivenModelAndElement(aModel,Z, A, 10);
+						aListOfMat1->push_back(two_matrices[0]);
+						aListOfMat2->push_back(two_matrices[1]);
+					}
+				}	
+			}
+			else { //Per material case
+				for (size_t j=0; j<theMaterialTable->size();j++){
+					G4Material* aMaterial=(*theMaterialTable)[j];
+					std::vector<G4AdjointCSMatrix*>
+						two_matrices=BuildCrossSectionsMatricesForAGivenModelAndMaterial(aModel,aMaterial, 10);
+					aListOfMat1->push_back(two_matrices[0]);
+					aListOfMat2->push_back(two_matrices[1]);
+				}
+			
+			}
+			theAdjointCSMatricesForProdToProj.push_back(*aListOfMat1);
+			theAdjointCSMatricesForScatProjToProj.push_back(*aListOfMat2);	
+			aModel->SetCSMatrices(aListOfMat1, aListOfMat2); 	
+		}
+		else {  std::vector<G4AdjointCSMatrix*> two_empty_matrices;
+			theAdjointCSMatricesForProdToProj.push_back(two_empty_matrices);
+			theAdjointCSMatricesForScatProjToProj.push_back(two_empty_matrices);
+			
+		}		
+	}
+	G4cout<<"All adjoint cross section matrices are built "<<std::endl;
+	CrossSectionMatrixesAreBuilt = true;
+}
+
+
+///////////////////////////////////////////////////////
+//
+void G4AdjointCSManager::BuildTotalSigmaTables()
+{ 
+  const G4ProductionCutsTable* theCoupleTable= G4ProductionCutsTable::GetProductionCutsTable();
+  for (size_t i=0;i<theListOfAdjointParticlesInAction.size();i++){
+  	G4ParticleDefinition* thePartDef = theListOfAdjointParticlesInAction[i];
+  	theTotalForwardSigmaTableVector[i]->clearAndDestroy();
+	theTotalAdjointSigmaTableVector[i]->clearAndDestroy();
+  	for (size_t j=0;j<theCoupleTable->GetTableSize();j++){
+		const G4MaterialCutsCouple* couple = theCoupleTable->GetMaterialCutsCouple(j);
+		
+		//make first the total fwd CS table for FwdProcess
+		G4PhysicsVector* aVector =  new G4PhysicsLogVector(Tmin, Tmax, nbins);
+		for(size_t l=0; l<aVector->GetVectorLength(); l++) { 
+			G4double totCS=0;
+			G4double e=aVector->GetLowEdgeEnergy(l);
+			for (size_t k=0; k<listOfForwardEmProcess[i]->size(); k++){
+				totCS+=(*listOfForwardEmProcess[i])[k]->GetLambda(e, couple);
+			}
+			for (size_t k=0; k<listOfForwardEnergyLossProcess[i]->size(); k++){
+				totCS+=(*listOfForwardEnergyLossProcess[i])[k]->GetLambda(e, couple);
+			}
+			//G4cout<<totCS<<std::endl;
+			aVector->PutValue(l,totCS);
+		
+		}
+		theTotalForwardSigmaTableVector[i]->push_back(aVector);
+		
+		G4PhysicsVector* aVector1 =  new G4PhysicsLogVector(Tmin, Tmax, nbins);
+		for(size_t l=0; l<aVector->GetVectorLength(); l++) { 
+			G4double e=aVector->GetLowEdgeEnergy(l);
+			G4double totCS =ComputeTotalAdjointCS(couple,thePartDef,e);
+			//G4cout<<totCS<<std::endl;
+			aVector1->PutValue(l,totCS);
+		
+		}	
+		theTotalAdjointSigmaTableVector[i]->push_back(aVector1);
+		
+	}
+  }
+   
+}
+///////////////////////////////////////////////////////
+//
+G4double G4AdjointCSManager::GetTotalAdjointCS(G4ParticleDefinition* aPartDef, G4double Ekin,
+	 		   	     const G4MaterialCutsCouple* aCouple)
+{ DefineCurrentMaterial(aCouple);
+  int index=-1;
+  for (size_t i=0;i<theListOfAdjointParticlesInAction.size();i++){
+  	if (aPartDef == theListOfAdjointParticlesInAction[i]) index=i;
+  }	
+  if (index == -1) return 0.;
+  
+  G4bool b;
+  return (((*theTotalAdjointSigmaTableVector[index])[currentMatIndex])->GetValue(Ekin, b));
+  
+  
+  
+}				     
+///////////////////////////////////////////////////////
+//				     
+G4double G4AdjointCSManager::GetTotalForwardCS(G4ParticleDefinition* aPartDef, G4double Ekin,
+	 		   	     const G4MaterialCutsCouple* aCouple)
+{ DefineCurrentMaterial(aCouple);
+  int index=-1;
+  for (size_t i=0;i<theListOfAdjointParticlesInAction.size();i++){
+  	if (aPartDef == theListOfAdjointParticlesInAction[i]) index=i;
+  }	
+  if (index == -1) return 0.;
+  G4bool b;
+  return (((*theTotalForwardSigmaTableVector[index])[currentMatIndex])->GetValue(Ekin, b));
+  
+  
+}				     
+///////////////////////////////////////////////////////
+//				     			     
+G4double G4AdjointCSManager::GetContinuousWeightCorrection(G4ParticleDefinition* aPartDef, G4double PreStepEkin,G4double AfterStepEkin,
+	 		   	     const G4MaterialCutsCouple* aCouple, G4double step_length)
+{ //G4double fwdCS = GetTotalForwardCS(aPartDef, AfterStepEkin,aCouple);
+  
+  G4double corr_fac = 1.;
+  if (consider_continuous_weight_correction) {
+  	
+	G4double adjCS = GetTotalAdjointCS(aPartDef, PreStepEkin,aCouple);
+	G4double PrefwdCS;
+	PrefwdCS = GetTotalForwardCS(aPartDef, PreStepEkin,aCouple);
+  	G4double fwdCS = GetTotalForwardCS(aPartDef, (AfterStepEkin+PreStepEkin)/2.,aCouple);
+	G4cout<<adjCS<<'\t'<<fwdCS<<std::endl;
+	//if (aPartDef ==G4AdjointGamma::AdjointGamma()) G4cout<<adjCS<<'\t'<<fwdCS<<std::endl;
+  	/*if (adjCS >0 ) corr_fac = std::exp((PrefwdCS-fwdCS)*step_length);
+	else corr_fac = std::exp(-fwdCS*step_length);*/
+	corr_fac *=std::exp((adjCS-fwdCS)*step_length);
+	corr_fac=std::max(corr_fac,1.e-6);
+	corr_fac *=PreStepEkin/AfterStepEkin;
+   	
+  }
+  G4cout<<"Cont "<<corr_fac<<std::endl;
+  G4cout<<"Ekin0 "<<PreStepEkin<<std::endl;
+  G4cout<<"Ekin1 "<<AfterStepEkin<<std::endl;
+  G4cout<<"step_length "<<step_length<<std::endl;
+  return corr_fac; 
+}				     
+///////////////////////////////////////////////////////
+//				     			     
+G4double G4AdjointCSManager::GetPostStepWeightCorrection(G4ParticleDefinition* , G4ParticleDefinition* ,
+					    		  G4double ,G4double ,
+	 		   	     			  const G4MaterialCutsCouple* )
+{ G4double corr_fac = 1.;
+  if (consider_poststep_weight_correction) {
+	/*G4double fwdCS = GetTotalForwardCS(aSecondPartDef, EkinPrim,aCouple);
+  	G4double adjCS = GetTotalAdjointCS(aPrimPartDef, EkinPrim,aCouple);*/
+  	//G4double fwd1CS = GetTotalForwardCS(aPrimPartDef, EkinPrim,aCouple);
+  	//if (adjCS>0 && fwd1CS>0) adjCS = fwd1CS;
+  	//corr_fac =fwdCS*EkinSecond/adjCS/EkinPrim;
+  	//corr_fac = adjCS/fwdCS;
+  }
+  return corr_fac;
+}							  
+///////////////////////////////////////////////////////
+//
+double  G4AdjointCSManager::ComputeAdjointCS(G4Material* aMaterial,
+					    		 G4VEmAdjointModel* aModel, 
+					    		 G4double PrimEnergy,
+					    		 G4double Tcut,
+					    		 G4bool IsScatProjToProjCase,
+							 std::vector<double>& CS_Vs_Element)
+{ 
+  
+  G4bool need_to_compute=false;
+  if ( aMaterial!= lastMaterial || PrimEnergy != lastPrimaryEnergy || Tcut != lastTcut){
+  	lastMaterial =aMaterial;
+  	lastPrimaryEnergy = PrimEnergy;
+  	lastTcut=Tcut;
+	listOfIndexOfAdjointEMModelInAction.clear();
+	listOfIsScatProjToProjCase.clear();
+	lastAdjointCSVsModelsAndElements.clear();
+	need_to_compute=true;
+	
+  }
+  size_t ind=0;
+  if (!need_to_compute){
+  	need_to_compute=true;
+  	for (size_t i=0;i<listOfIndexOfAdjointEMModelInAction.size();i++){
+		size_t ind1=listOfIndexOfAdjointEMModelInAction[i];
+		if (aModel == listOfAdjointEMModel[ind1] && IsScatProjToProjCase == listOfIsScatProjToProjCase[i]){
+			need_to_compute=false;
+			CS_Vs_Element = lastAdjointCSVsModelsAndElements[ind];
+		}
+		ind++;
+	}
+  }
+  
+  if (need_to_compute){
+  	size_t ind_model=0;
+	for (size_t i=0;i<listOfAdjointEMModel.size();i++){
+		if (aModel == listOfAdjointEMModel[i]){
+			ind_model=i;
+			break;
+		}
+	}
+	G4double Tlow=Tcut;
+	if (!listOfAdjointEMModel[ind_model]->GetApplyCutInRange()) Tlow =listOfAdjointEMModel[ind_model]->GetLowEnergyLimit();
+	listOfIndexOfAdjointEMModelInAction.push_back(ind_model);	
+	listOfIsScatProjToProjCase.push_back(IsScatProjToProjCase);
+	CS_Vs_Element.clear();
+	if (!aModel->GetUseMatrix()){
+		return aModel->AdjointCrossSection(currentCouple,PrimEnergy,IsScatProjToProjCase);
+				         
+	
+	}
+	else if (aModel->GetUseMatrixPerElement()){
+			size_t n_el = aMaterial->GetNumberOfElements();
+		if (aModel->GetUseOnlyOneMatrixForAllElements()){
+			G4AdjointCSMatrix* theCSMatrix;
+			if (IsScatProjToProjCase){
+				theCSMatrix=theAdjointCSMatricesForScatProjToProj[ind_model][0];
+			}
+			else  	theCSMatrix=theAdjointCSMatricesForProdToProj[ind_model][0];
+			G4double CS =0.;
+			if (PrimEnergy > Tlow)
+					CS = ComputeAdjointCS(PrimEnergy,theCSMatrix,Tlow);
+			G4double factor=0.;
+			for (size_t i=0;i<n_el;i++){
+				size_t ind_el = aMaterial->GetElement(i)->GetIndex();
+				factor+=aMaterial->GetElement(i)->GetZ()*aMaterial->GetVecNbOfAtomsPerVolume()[i];
+				G4AdjointCSMatrix* theCSMatrix;
+				if (IsScatProjToProjCase){
+					theCSMatrix=theAdjointCSMatricesForScatProjToProj[ind_model][ind_el];
+				}
+				else  	theCSMatrix=theAdjointCSMatricesForProdToProj[ind_model][ind_el];
+				//G4double CS =0.;
+				
+				//G4cout<<CS<<std::endl;			
+				
+			}
+			CS *=factor;
+			CS_Vs_Element.push_back(CS);
+								
+		}
+		else {
+			for (size_t i=0;i<n_el;i++){
+				size_t ind_el = aMaterial->GetElement(i)->GetIndex();
+				//G4cout<<aMaterial->GetName()<<std::endl;
+				G4AdjointCSMatrix* theCSMatrix;
+				if (IsScatProjToProjCase){
+					theCSMatrix=theAdjointCSMatricesForScatProjToProj[ind_model][ind_el];
+				}
+				else  	theCSMatrix=theAdjointCSMatricesForProdToProj[ind_model][ind_el];
+				G4double CS =0.;
+				if (PrimEnergy > Tlow)
+					CS = ComputeAdjointCS(PrimEnergy,theCSMatrix,Tlow);
+				//G4cout<<CS<<std::endl;			
+				CS_Vs_Element.push_back(CS*(aMaterial->GetVecNbOfAtomsPerVolume()[i]));	
+			}
+		}		
+		
+	}
+	else {
+		size_t ind_mat = aMaterial->GetIndex();
+		G4AdjointCSMatrix* theCSMatrix;
+		if (IsScatProjToProjCase){
+			theCSMatrix=theAdjointCSMatricesForScatProjToProj[ind_model][ind_mat];
+		}
+		else  	theCSMatrix=theAdjointCSMatricesForProdToProj[ind_model][ind_mat];
+		G4double CS =0.;
+		if (PrimEnergy > Tlow)
+			CS = ComputeAdjointCS(PrimEnergy,theCSMatrix,Tlow);
+		CS_Vs_Element.push_back(CS);							
+			
+		
+	}
+	lastAdjointCSVsModelsAndElements.push_back(CS_Vs_Element);
+	
+  }
+  
+  
+  G4double CS=0;
+  for (size_t i=0;i<CS_Vs_Element.size();i++){
+  	CS+=CS_Vs_Element[i];
+  }
+
+  return CS;
+  	
+  
+  
+  
+  
+  
+  
+  
+}							
+///////////////////////////////////////////////////////
+//	
+G4Element* G4AdjointCSManager::SampleElementFromCSMatrices(G4Material* aMaterial,
+						       		   G4VEmAdjointModel* aModel,
+					 	       		   G4double PrimEnergy,
+						        	   G4double Tcut,
+						       		   G4bool IsScatProjToProjCase)
+{ std::vector<double> CS_Vs_Element;
+  G4double CS = ComputeAdjointCS(aMaterial,aModel,PrimEnergy,Tcut,IsScatProjToProjCase,CS_Vs_Element);
+  G4double rand_var= G4UniformRand();
+  G4double SumCS=0.;
+  size_t ind=0;
+  for (size_t i=0;i<CS_Vs_Element.size();i++){
+ 	SumCS+=CS_Vs_Element[i];
+	if (rand_var<=SumCS/CS){
+		ind=i;
+		break;
+	}
+  }
+ 
+  return const_cast<G4Element*>(aMaterial->GetElement(ind));
+ 
+ 
+					    
+}								
+///////////////////////////////////////////////////////
+//
+G4double G4AdjointCSManager::ComputeTotalAdjointCS(const G4MaterialCutsCouple* aCouple,
+							     G4ParticleDefinition* aPartDef,
+							     G4double Ekin)
+{
+ G4double TotalCS=0.;
+// G4ParticleDefinition* theDirPartDef = GetForwardParticleEquivalent(aPartDef);
+ DefineCurrentMaterial(aCouple);
+/* size_t idx=-1;
+ if (theDirPartDef->GetParticleName() == "gamma") idx = 0;
+ else if (theDirPartDef->GetParticleName() == "e-") idx = 1;
+ else if (theDirPartDef->GetParticleName() == "e+") idx = 2;
+ 
+ //THe tCut computation is wrong this should be on Tcut per model the secondary determioming the Tcut
+ const std::vector<G4double>* aVec = G4ProductionCutsTable::GetProductionCutsTable()->GetEnergyCutsVector(idx);
+ //G4cout<<aVec<<std::endl;
+ G4double Tcut =(*aVec)[aCouple->GetIndex()];*/
+ //G4cout<<"Tcut "<<Tcut<<std::endl;
+ //G4cout<<(*aVec)[0]<<std::endl;
+// G4double Tcut =converters[idx]->Convert(Rcut,aCouple->GetMaterial());
+ 
+  
+ std::vector<double> CS_Vs_Element;
+ for (size_t i=0; i<listOfAdjointEMModel.size();i++){
+ 	/*G4ParticleDefinition* theDirSecondPartDef = 
+			GetForwardParticleEquivalent(listOfAdjointEMModel[i]->GetAdjointEquivalentOfDirectSecondaryParticleDefinition());
+ 	
+	*/
+	
+	
+	G4double Tlow=0;
+	if (!listOfAdjointEMModel[i]->GetApplyCutInRange()) Tlow =listOfAdjointEMModel[i]->GetLowEnergyLimit();
+	else {
+		G4ParticleDefinition* theDirSecondPartDef = 
+			GetForwardParticleEquivalent(listOfAdjointEMModel[i]->GetAdjointEquivalentOfDirectSecondaryParticleDefinition());
+		G4int idx=-1;
+ 		if (theDirSecondPartDef->GetParticleName() == "gamma") idx = 0;
+		else if (theDirSecondPartDef->GetParticleName() == "e-") idx = 1;
+ 		else if (theDirSecondPartDef->GetParticleName() == "e+") idx = 2;
+		const std::vector<G4double>* aVec = G4ProductionCutsTable::GetProductionCutsTable()->GetEnergyCutsVector(idx);
+ 		Tlow =(*aVec)[aCouple->GetIndex()];
+		
+	
+	}
+ 	
+ 	if ( Ekin<=listOfAdjointEMModel[i]->GetHighEnergyLimit() && Ekin>=listOfAdjointEMModel[i]->GetLowEnergyLimit()){
+		if (aPartDef == listOfAdjointEMModel[i]->GetAdjointEquivalentOfDirectPrimaryParticleDefinition()){
+			//G4cout<<"Yes1 before "<<std::endl;
+			TotalCS += ComputeAdjointCS(currentMaterial,
+					    	       listOfAdjointEMModel[i], 
+					    	       Ekin, Tlow,true,CS_Vs_Element);
+			//G4cout<<"Yes1 "<<Ekin<<'\t'<<TotalCS<<std::endl;			       
+		}
+		if (aPartDef == listOfAdjointEMModel[i]->GetAdjointEquivalentOfDirectSecondaryParticleDefinition()){
+			TotalCS += ComputeAdjointCS(currentMaterial,
+					    	       listOfAdjointEMModel[i], 
+					    	       Ekin, Tlow,false, CS_Vs_Element);
+						       
+			//G4cout<<"Yes2 "<<TotalCS<<std::endl;
+		}
+		
+	}
+ }
+ return TotalCS;
+    
+ 
+}	
+///////////////////////////////////////////////////////
+//
+std::vector<G4AdjointCSMatrix*>
+G4AdjointCSManager::BuildCrossSectionsMatricesForAGivenModelAndElement(G4VEmAdjointModel* aModel,G4int Z,G4int A,
+								        int nbin_pro_decade)
+{ 
+  G4AdjointCSMatrix* theCSMatForProdToProjBackwardScattering = new G4AdjointCSMatrix(false);
+  G4AdjointCSMatrix* theCSMatForScatProjToProjBackwardScattering = new G4AdjointCSMatrix(true);
+ 
+ 
+  //make the vector of primary energy of the adjoint particle, could try to make this just once ? 
+  
+   G4double EkinMin =aModel->GetLowEnergyLimit();
+   G4double EkinMaxForScat =aModel->GetHighEnergyLimit()*0.999;
+   G4double EkinMaxForProd =aModel->GetHighEnergyLimit()*0.999;
+   if (aModel->GetSecondPartOfSameType() )EkinMaxForProd =EkinMaxForProd/2.;
+   
+    
+   
+   
+   
+   
+   
+   //Product to projectile backward scattering
+   //-----------------------------------------
+   G4double fE=std::pow(10.,1./nbin_pro_decade);
+   G4double E2=std::pow(10.,G4double( G4int(std::log10(EkinMin)*nbin_pro_decade)+1)/nbin_pro_decade)/fE;
+   G4double E1=EkinMin;
+   while (E1 <EkinMaxForProd){
+   	E1=std::max(EkinMin,E2);
+	E1=std::min(EkinMaxForProd,E1);
+	std::vector< std::vector< G4double >* >  aMat= aModel->ComputeAdjointCrossSectionVectorPerAtomForSecond(E1,Z,A,nbin_pro_decade);
+	if (aMat.size()>=2) {
+		std::vector< G4double >* log_ESecVec=aMat[0];
+		std::vector< G4double >* log_CSVec=aMat[1];
+		G4double log_adjointCS=log_CSVec->back();
+		//normalise CSVec such that it becomes a probability vector
+ 		/*for (size_t j=0;j<log_CSVec->size();j++) (*log_CSVec)[j]=(*log_CSVec)[j]-log_adjointCS;
+		(*log_CSVec)[0]=-90.;*/
+	
+	
+		for (size_t j=0;j<log_CSVec->size();j++) {
+	        	//G4cout<<"CSMan1 "<<(*log_CSVec)[j]<<std::endl;
+			if (j==0) (*log_CSVec)[j] = 0.; 
+			else (*log_CSVec)[j]=std::log(1.-std::exp((*log_CSVec)[j]-log_adjointCS));
+			//G4cout<<"CSMan2 "<<(*log_CSVec)[j]<<std::endl;
+		}	
+		(*log_CSVec)[log_CSVec->size()-1]=(*log_CSVec)[log_CSVec->size()-2]-1.;
+		theCSMatForProdToProjBackwardScattering->AddData(std::log(E1),log_adjointCS,log_ESecVec,log_CSVec,0);
+	}	
+   	E1=E2;
+   	E2*=fE;
+   }
+   
+   //Scattered projectile to projectile backward scattering
+   //-----------------------------------------
+   
+   E2=std::pow(10.,G4double( G4int(std::log10(EkinMin)*nbin_pro_decade)+1)/nbin_pro_decade)/fE;
+   E1=EkinMin;
+   while (E1 <EkinMaxForScat){
+   	E1=std::max(EkinMin,E2);
+	E1=std::min(EkinMaxForScat,E1);
+	std::vector< std::vector< G4double >* >  aMat= aModel->ComputeAdjointCrossSectionVectorPerAtomForScatProj(E1,Z,A,nbin_pro_decade);
+	if (aMat.size()>=2) {
+		std::vector< G4double >* log_ESecVec=aMat[0];
+		std::vector< G4double >* log_CSVec=aMat[1];
+		G4double log_adjointCS=log_CSVec->back();
+		//normalise CSVec such that it becomes a probability vector
+ 		for (size_t j=0;j<log_CSVec->size();j++) {
+	        	//G4cout<<"CSMan1 "<<(*log_CSVec)[j]<<std::endl;
+			if (j==0) (*log_CSVec)[j] = 0.; 
+			else (*log_CSVec)[j]=std::log(1.-std::exp((*log_CSVec)[j]-log_adjointCS));
+		//G4cout<<"CSMan2 "<<(*log_CSVec)[j]<<std::endl;
+		}	
+		(*log_CSVec)[log_CSVec->size()-1]=(*log_CSVec)[log_CSVec->size()-2]-1.;
+		theCSMatForScatProjToProjBackwardScattering->AddData(std::log(E1),log_adjointCS,log_ESecVec,log_CSVec,0);
+   	}
+	E1=E2;
+   	E2*=fE;
+   }
+   
+   
+   
+   
+   
+   
+   
+  std::vector<G4AdjointCSMatrix*> res;
+  res.clear();
+  
+  res.push_back(theCSMatForProdToProjBackwardScattering);
+  res.push_back(theCSMatForScatProjToProjBackwardScattering);
+  
+
+#ifdef TEST_MODE
+  G4String file_name;
+  std::stringstream astream;
+  G4String str_Z;
+  astream<<Z;
+  astream>>str_Z;  
+  theCSMatForProdToProjBackwardScattering->Write(aModel->GetName()+G4String("_CSMat_Z")+str_Z+"_ProdToProj.txt"); 
+  theCSMatForScatProjToProjBackwardScattering->Write(aModel->GetName()+G4String("_CSMat_Z")+str_Z+"_ScatProjToProj.txt");
+ 
+  /*G4AdjointCSMatrix* aMat1 = new G4AdjointCSMatrix(false);
+  G4AdjointCSMatrix* aMat2 = new G4AdjointCSMatrix(true);
+  
+  aMat1->Read(G4String("test_Z")+str_Z+"_1.txt");
+  aMat2->Read(G4String("test_Z")+str_Z+"_2.txt");
+  aMat1->Write(G4String("test_Z")+str_Z+"_11.txt");
+  aMat2->Write(G4String("test_Z")+str_Z+"_22.txt"); */
+#endif 
+  
+  return res;
+  
+  
+}
+///////////////////////////////////////////////////////
+//
+std::vector<G4AdjointCSMatrix*>
+G4AdjointCSManager::BuildCrossSectionsMatricesForAGivenModelAndMaterial(G4VEmAdjointModel* aModel,
+								        G4Material* aMaterial,
+								        G4int nbin_pro_decade)
+{ 
+  G4AdjointCSMatrix* theCSMatForProdToProjBackwardScattering = new G4AdjointCSMatrix(false);
+  G4AdjointCSMatrix* theCSMatForScatProjToProjBackwardScattering = new G4AdjointCSMatrix(true);
+ 
+ 
+  //make the vector of primary energy of the adjoint particle, could try to make this just once ? 
+  
+   G4double EkinMin =aModel->GetLowEnergyLimit();
+   G4double EkinMaxForScat =aModel->GetHighEnergyLimit()*0.999;
+   G4double EkinMaxForProd =aModel->GetHighEnergyLimit()*0.999;
+   if (aModel->GetSecondPartOfSameType() )EkinMaxForProd =EkinMaxForProd/2.;
+   
+    
+   
+   
+   
+   
+   
+   //Product to projectile backward scattering
+   //-----------------------------------------
+   G4double fE=std::pow(10.,1./nbin_pro_decade);
+   G4double E2=std::pow(10.,G4double( G4int(std::log10(EkinMin)*nbin_pro_decade)+1)/nbin_pro_decade)/fE;
+   G4double E1=EkinMin;
+   while (E1 <EkinMaxForProd){
+   	E1=std::max(EkinMin,E2);
+	E1=std::min(EkinMaxForProd,E1);
+	std::vector< std::vector< G4double >* >  aMat= aModel->ComputeAdjointCrossSectionVectorPerVolumeForSecond(aMaterial,E1,nbin_pro_decade);
+	if (aMat.size()>=2) {
+		std::vector< G4double >* log_ESecVec=aMat[0];
+		std::vector< G4double >* log_CSVec=aMat[1];
+		G4double log_adjointCS=log_CSVec->back();
+	
+		//normalise CSVec such that it becomes a probability vector
+		for (size_t j=0;j<log_CSVec->size();j++) {
+	        	//G4cout<<"CSMan1 "<<(*log_CSVec)[j]<<std::endl;
+			if (j==0) (*log_CSVec)[j] = 0.; 
+			else (*log_CSVec)[j]=std::log(1.-std::exp((*log_CSVec)[j]-log_adjointCS));
+			//G4cout<<"CSMan2 "<<(*log_CSVec)[j]<<std::endl;
+		}	
+		(*log_CSVec)[log_CSVec->size()-1]=(*log_CSVec)[log_CSVec->size()-2]-1.;
+		theCSMatForProdToProjBackwardScattering->AddData(std::log(E1),log_adjointCS,log_ESecVec,log_CSVec,0);
+	}	
+	
+ 	
+	
+   	E1=E2;
+   	E2*=fE;
+   }
+   
+   //Scattered projectile to projectile backward scattering
+   //-----------------------------------------
+   
+   E2=std::pow(10.,G4double( G4int(std::log10(EkinMin)*nbin_pro_decade)+1)/nbin_pro_decade)/fE;
+   E1=EkinMin;
+   while (E1 <EkinMaxForScat){
+   	E1=std::max(EkinMin,E2);
+	E1=std::min(EkinMaxForScat,E1);
+	std::vector< std::vector< G4double >* >  aMat= aModel->ComputeAdjointCrossSectionVectorPerVolumeForScatProj(aMaterial,E1,nbin_pro_decade);
+	if (aMat.size()>=2) {
+		std::vector< G4double >* log_ESecVec=aMat[0];
+		std::vector< G4double >* log_CSVec=aMat[1];
+		G4double log_adjointCS=log_CSVec->back();
+	
+		for (size_t j=0;j<log_CSVec->size();j++) {
+	        	//G4cout<<"CSMan1 "<<(*log_CSVec)[j]<<std::endl;
+			if (j==0) (*log_CSVec)[j] = 0.; 
+			else (*log_CSVec)[j]=std::log(1.-std::exp((*log_CSVec)[j]-log_adjointCS));
+		//G4cout<<"CSMan2 "<<(*log_CSVec)[j]<<std::endl;
+		}	
+		(*log_CSVec)[log_CSVec->size()-1]=(*log_CSVec)[log_CSVec->size()-2]-1.;
+	
+		theCSMatForScatProjToProjBackwardScattering->AddData(std::log(E1),log_adjointCS,log_ESecVec,log_CSVec,0);
+   	}
+	E1=E2;
+   	E2*=fE;	
+   }
+   
+   
+   
+   
+   
+   
+   
+  std::vector<G4AdjointCSMatrix*> res;
+  res.clear();
+  
+  res.push_back(theCSMatForProdToProjBackwardScattering);
+  res.push_back(theCSMatForScatProjToProjBackwardScattering); 
+  
+#ifdef TEST_MODE
+  theCSMatForProdToProjBackwardScattering->Write(aModel->GetName()+"_CSMat_"+aMaterial->GetName()+"_ProdToProj.txt");
+  theCSMatForScatProjToProjBackwardScattering->Write(aModel->GetName()+"_CSMat_"+aMaterial->GetName()+"_ScatProjToProj.txt");
+#endif
+
+
+  return res;
+  
+  
+}
+
+///////////////////////////////////////////////////////
+//
+G4ParticleDefinition* G4AdjointCSManager::GetAdjointParticleEquivalent(G4ParticleDefinition* theFwdPartDef)
+{
+ if (theFwdPartDef->GetParticleName() == "e-") return G4AdjointElectron::AdjointElectron();
+ if (theFwdPartDef->GetParticleName() == "gamma") return G4AdjointGamma::AdjointGamma();
+ return 0; 	
+}
+///////////////////////////////////////////////////////
+//
+G4ParticleDefinition* G4AdjointCSManager::GetForwardParticleEquivalent(G4ParticleDefinition* theAdjPartDef)
+{
+ if (theAdjPartDef->GetParticleName() == "adj_e-") return G4Electron::Electron();
+ if (theAdjPartDef->GetParticleName() == "adj_gamma") return G4Gamma::Gamma();
+ return 0; 	
+}
+///////////////////////////////////////////////////////
+//
+void G4AdjointCSManager::DefineCurrentMaterial(const G4MaterialCutsCouple* couple)
+{
+  if(couple != currentCouple) {
+    currentCouple   = const_cast<G4MaterialCutsCouple*> (couple);
+    currentMaterial = const_cast<G4Material*> (couple->GetMaterial());
+    currentMatIndex = couple->GetIndex();
+    //G4cout<<"Index material "<<currentMatIndex<<std::endl;
+  }  
+}
+
+
+
+///////////////////////////////////////////////////////
+//
+double G4AdjointCSManager::ComputeAdjointCS(G4double aPrimEnergy,G4AdjointCSMatrix*
+				anAdjointCSMatrix,G4double Tcut)
+{ 
+  std::vector< G4double > *theLogPrimEnergyVector = anAdjointCSMatrix->GetLogPrimEnergyVector();
+  if (theLogPrimEnergyVector->size() ==0){
+ 	G4cout<<"No data are contained in the given AdjointCSMatrix!"<<std::endl;
+	G4cout<<"The sampling procedure will be stopped."<<std::endl;
+	return 0.;
+	
+  }
+  //G4cout<<"A prim/Tcut "<<aPrimEnergy<<'\t'<<Tcut<<std::endl; 
+  G4double log_Tcut = std::log(Tcut);
+  G4double log_E =std::log(aPrimEnergy);
+  
+  if (aPrimEnergy <= Tcut || log_E > theLogPrimEnergyVector->back()) return 0.;
+  
+  
+
+  G4AdjointInterpolator* theInterpolator=G4AdjointInterpolator::GetInstance();
+ 
+  size_t ind =theInterpolator->FindPositionForLogVector(log_E,*theLogPrimEnergyVector);
+  //G4cout<<"Prim energy "<<(*thePrimEnergyVector)[0]<<std::endl;
+  //G4cout<<"Prim energy[ind]"<<(*thePrimEnergyVector)[ind]<<std::endl;
+  //G4cout<<"Prim energy ind"<<ind<<std::endl;
+  
+  G4double aLogPrimEnergy1,aLogPrimEnergy2;
+  G4double aLogCS1,aLogCS2;
+  G4double log01,log02;
+  std::vector< G4double>* aLogSecondEnergyVector1 =0;
+  std::vector< G4double>* aLogSecondEnergyVector2  =0;
+  std::vector< G4double>* aLogProbVector1=0;
+  std::vector< G4double>* aLogProbVector2=0;
+  std::vector< size_t>* aLogProbVectorIndex1=0;
+  std::vector< size_t>* aLogProbVectorIndex2=0;
+  
+	 							     
+  anAdjointCSMatrix->GetData(ind, aLogPrimEnergy1,aLogCS1,log01, aLogSecondEnergyVector1,aLogProbVector1,aLogProbVectorIndex1);
+  anAdjointCSMatrix->GetData(ind+1, aLogPrimEnergy2,aLogCS2,log02, aLogSecondEnergyVector2,aLogProbVector2,aLogProbVectorIndex2);
+  //G4cout<<"aSecondEnergyVector1.size() "<<aSecondEnergyVector1->size()<<std::endl;
+  //G4cout<<aSecondEnergyVector1<<std::endl;
+  //G4cout<<"aSecondEnergyVector2.size() "<<aSecondEnergyVector2->size()<<std::endl;
+  if (anAdjointCSMatrix->IsScatProjToProjCase()){ //case where the Tcut plays a role
+	G4double log_minimum_prob1, log_minimum_prob2;
+	
+	//G4cout<<aSecondEnergyVector1->size()<<std::endl;
+	log_minimum_prob1=theInterpolator->InterpolateForLogVector(log_Tcut,*aLogSecondEnergyVector1,*aLogProbVector1);
+	log_minimum_prob2=theInterpolator->InterpolateForLogVector(log_Tcut,*aLogSecondEnergyVector2,*aLogProbVector2);
+	//G4cout<<"minimum_prob1 "<< std::exp(log_minimum_prob1)<<std::endl;
+	//G4cout<<"minimum_prob2 "<< std::exp(log_minimum_prob2)<<std::endl;
+	//G4cout<<"Tcut "<<std::endl;
+	aLogCS1+= log_minimum_prob1;
+	aLogCS2+= log_minimum_prob2;
+  }
+ 
+  G4double log_adjointCS = theInterpolator->LinearInterpolation(log_E,aLogPrimEnergy1,aLogPrimEnergy2,aLogCS1,aLogCS2);
+  return std::exp(log_adjointCS); 
+  
+  
+}	 
Index: trunk/source/processes/electromagnetic/adjoint/src/G4AdjointCSMatrix.cc
===================================================================
--- trunk/source/processes/electromagnetic/adjoint/src/G4AdjointCSMatrix.cc	(revision 966)
+++ trunk/source/processes/electromagnetic/adjoint/src/G4AdjointCSMatrix.cc	(revision 966)
@@ -0,0 +1,201 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+#include "G4AdjointCSMatrix.hh"
+#include <iomanip>
+#include <fstream>
+
+#include "G4AdjointInterpolator.hh"
+
+///////////////////////////////////////////////////////
+//
+G4AdjointCSMatrix::G4AdjointCSMatrix(G4bool aBool){
+	theLogPrimEnergyVector.clear();
+	theLogCrossSectionVector.clear();
+	theLogSecondEnergyMatrix.clear();
+	theLogProbMatrix.clear();
+	theLogProbMatrixIndex.clear();
+	log0Vector.clear();
+	nb_of_PrimEnergy=0;
+	is_scat_proj_to_proj_case  =aBool;
+}
+///////////////////////////////////////////////////////
+//
+G4AdjointCSMatrix::~G4AdjointCSMatrix(){
+	theLogPrimEnergyVector.clear();
+	theLogCrossSectionVector.clear();
+	theLogSecondEnergyMatrix.clear();
+	theLogProbMatrix.clear();
+}
+///////////////////////////////////////////////////////
+//
+void G4AdjointCSMatrix::Clear()
+{
+	theLogPrimEnergyVector.clear();
+	theLogCrossSectionVector.clear();
+	theLogSecondEnergyMatrix.clear();
+	theLogProbMatrix.clear();
+	theLogProbMatrixIndex.clear();
+	log0Vector.clear();
+	nb_of_PrimEnergy=0;
+}
+///////////////////////////////////////////////////////
+//
+ void G4AdjointCSMatrix::AddData(G4double aLogPrimEnergy,G4double aLogCS, std::vector< G4double>* aLogSecondEnergyVector,
+	 							       std::vector< G4double>* aLogProbVector,size_t n_pro_decade){
+	
+	G4AdjointInterpolator* theInterpolator=G4AdjointInterpolator::GetInstance();
+	//Add this time we consider that the energy are given monotically
+	
+	theLogPrimEnergyVector.push_back(aLogPrimEnergy);
+	theLogCrossSectionVector.push_back(aLogCS);
+	theLogSecondEnergyMatrix.push_back(aLogSecondEnergyVector);
+	//G4cout<<"Test Add Data "<<this<<'\t'<<aSecondEnergyVector->size()<<std::endl;
+	//G4cout<<theSecondEnergyMatrix.size()<<std::endl;
+	theLogProbMatrix.push_back(aLogProbVector);
+	//G4cout<<"Test Add Data 1 "<<this<<'\t'<<aSecondEnergyVector->size()<<std::endl;
+	//G4cout<<theSecondEnergyMatrix.size()<<std::endl;
+	std::vector< size_t>* aLogProbVectorIndex = 0;
+	dlog =0;
+	if (n_pro_decade > 0 && aLogProbVector->size()>0) {
+		aLogProbVectorIndex = new std::vector< size_t>();
+		dlog=std::log(10.)/n_pro_decade;
+		G4double log_val = int(std::min((*aLogProbVector)[0],aLogProbVector->back())/dlog)*dlog;
+		log0Vector.push_back(log_val);
+		while(log_val<0.) {
+			aLogProbVectorIndex->push_back(theInterpolator->FindPosition(log_val,(*aLogProbVector)));
+			log_val+=dlog;
+		} 
+	}
+	else {
+		log0Vector.push_back(0.);
+	}
+	theLogProbMatrixIndex.push_back(aLogProbVectorIndex);
+	
+	
+	nb_of_PrimEnergy++;
+	
+	
+}
+///////////////////////////////////////////////////////
+//
+bool G4AdjointCSMatrix::GetData(unsigned int i, G4double& aLogPrimEnergy,G4double& aLogCS,G4double& log0, std::vector< G4double>*& aLogSecondEnergyVector,
+	 							       std::vector< G4double>*& aLogProbVector, std::vector< size_t>*& aLogProbVectorIndex)
+{	if (i>= nb_of_PrimEnergy) return false;
+	//G4cout<<"Test Get Data "<<std::endl;
+	aLogPrimEnergy = theLogPrimEnergyVector[i];
+	aLogCS = theLogCrossSectionVector[i];
+	aLogSecondEnergyVector = theLogSecondEnergyMatrix[i];
+	//G4cout<<"Test Get Data "<<this<<'\t'<<theSecondEnergyMatrix[i]->size()<<std::endl;
+	//G4cout<<"Test Get Data "<<this<<'\t'<<aSecondEnergyVector->size()<<std::endl;
+	//G4cout<<"Test Get Data "<<this<<'\t'<<aSecondEnergyVector<<std::endl;
+	aLogProbVector = theLogProbMatrix[i];
+	aLogProbVectorIndex = theLogProbMatrixIndex[i];
+	log0=log0Vector[i];
+	//G4cout<<"Test Get Data 1 "<<this<<'\t'<<theProbMatrix[i]->size()<<std::endl;
+	//G4cout<<"Test Get Data 1 "<<this<<'\t'<<aProbVector->size()<<std::endl;
+	//G4cout<<"Test Get Data 1 "<<this<<'\t'<<aLogProbVectorIndex<<std::endl;
+	return true;
+	
+}
+///////////////////////////////////////////////////////
+//
+void G4AdjointCSMatrix::Write(G4String file_name)
+{	std::fstream FileOutput(file_name, std::ios::out);			  
+ 	FileOutput<<std::setiosflags(std::ios::scientific);
+ 	FileOutput<<std::setprecision(6);
+	FileOutput<<theLogPrimEnergyVector.size()<<std::endl;
+	for (size_t i=0;i<theLogPrimEnergyVector.size();i++){
+		FileOutput<<std::exp(theLogPrimEnergyVector[i])/MeV<<'\t'<<std::exp(theLogCrossSectionVector[i])<<std::endl;
+		size_t j1=0;
+		FileOutput<<theLogSecondEnergyMatrix[i]->size()<<std::endl;
+		for (size_t j=0;j<theLogSecondEnergyMatrix[i]->size();j++){
+			FileOutput<<std::exp((*theLogSecondEnergyMatrix[i])[j]);
+			j1++;
+			if (j1<10) FileOutput<<'\t';
+			else  {
+				FileOutput<<std::endl;
+				j1=0;
+			}	
+		}
+		if (j1>0) FileOutput<<std::endl;
+		j1=0;
+		FileOutput<<theLogProbMatrix[i]->size()<<std::endl;
+		for (size_t j=0;j<theLogProbMatrix[i]->size();j++){
+			FileOutput<<std::exp((*theLogProbMatrix[i])[j]);
+			j1++;
+			if (j1<10) FileOutput<<'\t';
+			else  {
+				FileOutput<<std::endl;
+				j1=0;
+			}	
+		}
+		if (j1>0) FileOutput<<std::endl;
+		
+		
+	}
+	
+}
+///////////////////////////////////////////////////////
+//
+void G4AdjointCSMatrix::Read(G4String file_name)
+{	std::fstream FileOutput(file_name, std::ios::in);
+	size_t n1,n2;
+	
+	
+	theLogPrimEnergyVector.clear();
+	theLogCrossSectionVector.clear();
+	theLogSecondEnergyMatrix.clear();
+	theLogProbMatrix.clear();
+	FileOutput>>n1;
+	for (size_t i=0; i<n1;i++){
+		G4double E,CS;
+		FileOutput>>E>>CS;
+		theLogPrimEnergyVector.push_back(E);
+		theLogCrossSectionVector.push_back(CS);
+		FileOutput>>n2;
+		theLogSecondEnergyMatrix.push_back(new std::vector<double>());
+		theLogProbMatrix.push_back(new std::vector<double>());
+		
+		for (size_t j=0; j<n2;j++){
+			G4double E1;
+			FileOutput>>E1;
+			theLogSecondEnergyMatrix[i]->push_back(E1);
+		}
+		FileOutput>>n2;
+		for (size_t j=0; j<n2;j++){
+			G4double prob;
+			FileOutput>>prob;
+			theLogProbMatrix[i]->push_back(prob);
+		}
+		
+		
+		
+	}
+	
+				  
+ 	
+	
+}
Index: trunk/source/processes/electromagnetic/adjoint/src/G4AdjointComptonModel.cc
===================================================================
--- trunk/source/processes/electromagnetic/adjoint/src/G4AdjointComptonModel.cc	(revision 966)
+++ trunk/source/processes/electromagnetic/adjoint/src/G4AdjointComptonModel.cc	(revision 966)
@@ -0,0 +1,252 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+#include "G4AdjointComptonModel.hh"
+#include "G4AdjointCSManager.hh"
+
+
+#include "G4Integrator.hh"
+#include "G4TrackStatus.hh"
+#include "G4ParticleChange.hh"
+#include "G4AdjointElectron.hh"
+#include "G4AdjointGamma.hh"
+#include "G4Gamma.hh"
+
+
+////////////////////////////////////////////////////////////////////////////////
+//
+G4AdjointComptonModel::G4AdjointComptonModel():
+ G4VEmAdjointModel("AdjointCompton")
+
+{ SetApplyCutInRange(false);
+  SetUseMatrix(true);
+  SetUseMatrixPerElement(true);
+  SetIsIonisation(false);
+  SetUseOnlyOneMatrixForAllElements(true);
+  theAdjEquivOfDirectPrimPartDef =G4AdjointGamma::AdjointGamma();
+  theAdjEquivOfDirectSecondPartDef=G4AdjointElectron::AdjointElectron();
+  theDirectPrimaryPartDef=G4Gamma::Gamma();
+  second_part_of_same_type=false;
+ 
+}
+////////////////////////////////////////////////////////////////////////////////
+//
+G4AdjointComptonModel::~G4AdjointComptonModel()
+{;}
+////////////////////////////////////////////////////////////////////////////////
+//
+void G4AdjointComptonModel::SampleSecondaries(const G4Track& aTrack,
+                       G4bool IsScatProjToProjCase,
+	               G4ParticleChange* fParticleChange)
+{ 
+   
+   
+   //A recall of the compton scattering law is 
+   //Egamma2=Egamma1/(1+(Egamma1/E0_electron)(1.-cos_th))
+   //Therefore Egamma2_max= Egamma2(cos_th=1) = Egamma1
+   //Therefore Egamma2_min= Egamma2(cos_th=-1) = Egamma1/(1+2.(Egamma1/E0_electron))
+   
+   
+  const G4DynamicParticle* theAdjointPrimary =aTrack.GetDynamicParticle();
+  //DefineCurrentMaterial(aTrack->GetMaterialCutsCouple());
+  size_t ind= 0;
+  
+  
+ 
+ 
+ //Elastic inverse scattering //not correct in all the cases 
+ //---------------------------------------------------------
+ G4double adjointPrimKinEnergy = theAdjointPrimary->GetKineticEnergy();
+ 
+ //G4cout<<adjointPrimKinEnergy<<std::endl;
+ if (adjointPrimKinEnergy>HighEnergyLimit*0.999){
+ 	return;
+ }
+ 
+ //Sample secondary energy
+ //-----------------------
+ G4double gammaE1;
+
+ gammaE1 = SampleAdjSecEnergyFromCSMatrix(ind,
+ 						  adjointPrimKinEnergy,
+						  IsScatProjToProjCase);
+ 
+ 
+ //gammaE2
+ //-----------
+ 
+ G4double gammaE2 = adjointPrimKinEnergy;
+ if (!IsScatProjToProjCase) gammaE2 = gammaE1 - adjointPrimKinEnergy;	
+ 
+ 
+ 
+ 
+ 
+ 
+ //Cos th
+ //-------
+// G4cout<<"Compton scattering "<<gammaE1<<'\t'<<gammaE2<<std::endl;
+ G4double cos_th = 1.+ electron_mass_c2*(1./gammaE1 -1./gammaE2);
+ if (!IsScatProjToProjCase) {
+ 	G4double p_elec=theAdjointPrimary->GetTotalMomentum();
+	cos_th = (gammaE1 - gammaE2*cos_th)/p_elec;
+ }
+ G4double sin_th = 0.;
+ if (std::abs(cos_th)>1){
+ 	//G4cout<<"Problem in compton scattering with cos_th "<<cos_th<<std::endl;
+	if (cos_th>0) {
+		cos_th=1.;
+	}
+	else 	cos_th=-1.;
+	sin_th=0.;
+ }
+ else  sin_th = std::sqrt(1.-cos_th*cos_th);
+
+ 
+ 
+ 
+ //gamma0 momentum
+ //--------------------
+
+ 
+ G4ThreeVector dir_parallel=theAdjointPrimary->GetMomentumDirection();
+ G4double phi =G4UniformRand()*2.*3.1415926;
+ G4ThreeVector gammaMomentum1 = gammaE1*G4ThreeVector(std::cos(phi)*sin_th,std::sin(phi)*sin_th,cos_th);
+ gammaMomentum1.rotateUz(dir_parallel);
+// G4cout<<gamma0Energy<<'\t'<<gamma0Momentum<<std::endl;
+ 
+ 
+ //It is important to correct the weight of particles before adding the secondary
+ //------------------------------------------------------------------------------
+ CorrectPostStepWeight(fParticleChange, aTrack.GetWeight(), adjointPrimKinEnergy,gammaE1);
+ 
+ if (!IsScatProjToProjCase && CorrectWeightMode){ //kill the primary and add a secondary
+ 	fParticleChange->ProposeTrackStatus(fStopAndKill);
+ 	fParticleChange->AddSecondary(new G4DynamicParticle(theAdjEquivOfDirectPrimPartDef,gammaMomentum1));
+	//G4cout<<"gamma0Momentum "<<gamma0Momentum<<std::endl;
+ }
+ else {
+ 	fParticleChange->ProposeEnergy(gammaE1);
+	fParticleChange->ProposeMomentumDirection(gammaMomentum1.unit());
+ }
+ 
+ 	
+} 			
+////////////////////////////////////////////////////////////////////////////////
+//
+//The implementation here is correct for energy loss process, for the photoelectric and compton scattering the method should be redefine  
+G4double G4AdjointComptonModel::DiffCrossSectionPerAtomPrimToSecond(
+                                      G4double gamEnergy0, 
+                                      G4double kinEnergyElec,
+				      G4double Z, 
+                                      G4double A)
+{ 
+  G4double gamEnergy1 =  gamEnergy0 - kinEnergyElec;
+  G4double dSigmadEprod=0.;
+  if (gamEnergy1>0.) dSigmadEprod=DiffCrossSectionPerAtomPrimToScatPrim(gamEnergy0,gamEnergy1,Z,A);
+  return dSigmadEprod;	  
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+//
+G4double G4AdjointComptonModel::DiffCrossSectionPerAtomPrimToScatPrim(
+                                      G4double gamEnergy0, 
+                                      G4double gamEnergy1,
+				      G4double Z, 
+                                      G4double )
+{ //Based on Klein Nishina formula
+ //* In the forward case (see G4KleinNishinaModel)  the  cross section is parametrised while the secondaries are sampled from the 
+ // Klein Nishida differential cross section
+ // The used diffrential cross section here is therefore the cross section multiplied by the normalidsed differential Klein Nishida cross section
+ 
+ 
+ //Klein Nishida Cross Section
+ //-----------------------------
+ G4double epsilon = gamEnergy0 / electron_mass_c2 ;
+ G4double one_plus_two_epsi =1.+2.*epsilon;
+ G4double gamEnergy1_max = gamEnergy0;
+ G4double gamEnergy1_min = gamEnergy0/one_plus_two_epsi;
+ if (gamEnergy1 >gamEnergy1_max ||  gamEnergy1<gamEnergy1_min) {
+ 	/*G4cout<<"the differential CS is null"<<std::endl;
+	G4cout<<gamEnergy0<<std::endl;
+	G4cout<<gamEnergy1<<std::endl;
+	G4cout<<gamEnergy1_min<<std::endl;*/
+ 	return 0.;
+ }
+ 	
+ 
+ G4double epsi2 = epsilon *epsilon ;
+ G4double one_plus_two_epsi_2=one_plus_two_epsi*one_plus_two_epsi;
+ 
+ 
+ G4double CS=std::log(one_plus_two_epsi)*(1.- 2.*(1.+epsilon)/epsi2);
+ CS+=4./epsilon +0.5*(1.-1./one_plus_two_epsi_2);
+ CS/=epsilon;
+ //Note that the pi*re2*Z factor is neglected because it is suppresed when computing dCS_dE1/CS;
+ // in the differential cross section
+ 
+ 
+ //Klein Nishida Differential Cross Section
+ //-----------------------------------------
+ G4double epsilon1 = gamEnergy1 / electron_mass_c2 ;
+ G4double v= epsilon1/epsilon;
+ G4double term1 =1.+ 1./epsilon -1/epsilon1;
+ G4double dCS_dE1= 1./v +v + term1*term1 -1.;
+ dCS_dE1 *=1./epsilon/gamEnergy0;
+ 
+ 
+ //Normalised to the CS used in G4
+ //-------------------------------
+ 
+ G4double G4direct_CS = theDirectEMModel->ComputeCrossSectionPerAtom(G4Gamma::Gamma(),
+                                             gamEnergy0,
+                                             Z, 0., 0.,0.);
+ 
+ dCS_dE1 *= G4direct_CS/CS;
+/* G4cout<<"the differential CS is not null"<<std::endl;
+ G4cout<<gamEnergy0<<std::endl;
+ G4cout<<gamEnergy1<<std::endl;*/
+ 
+ return dCS_dE1;
+
+
+}
+////////////////////////////////////////////////////////////////////////////////
+//
+G4double G4AdjointComptonModel::GetSecondAdjEnergyMaxForScatProjToProjCase(G4double PrimAdjEnergy)
+{ G4double inv_e_max =  1./PrimAdjEnergy - 2./electron_mass_c2;
+  G4double e_max = HighEnergyLimit;
+  if (inv_e_max > 0. ) e_max=std::min(1./inv_e_max,HighEnergyLimit);
+  return  e_max; 
+}
+////////////////////////////////////////////////////////////////////////////////
+//
+G4double G4AdjointComptonModel::GetSecondAdjEnergyMinForProdToProjCase(G4double PrimAdjEnergy)
+{ G4double half_e=PrimAdjEnergy/2.;
+  G4double term=std::sqrt(half_e*(electron_mass_c2+half_e));
+  G4double emin=half_e+term;
+  return  emin; 
+}
Index: trunk/source/processes/electromagnetic/adjoint/src/G4AdjointInterpolator.cc
===================================================================
--- trunk/source/processes/electromagnetic/adjoint/src/G4AdjointInterpolator.cc	(revision 966)
+++ trunk/source/processes/electromagnetic/adjoint/src/G4AdjointInterpolator.cc	(revision 966)
@@ -0,0 +1,218 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+#include "G4AdjointCSMatrix.hh"
+#include "G4AdjointInterpolator.hh"
+
+G4AdjointInterpolator* G4AdjointInterpolator::theInstance = 0;
+///////////////////////////////////////////////////////
+//
+G4AdjointInterpolator* G4AdjointInterpolator::GetAdjointInterpolator()
+{ if(theInstance == 0) {
+    static G4AdjointInterpolator interpolator;
+     theInstance = &interpolator;
+  }
+ return theInstance; 
+}
+///////////////////////////////////////////////////////
+//
+G4AdjointInterpolator* G4AdjointInterpolator::GetInstance()
+{ if(theInstance == 0) {
+    static G4AdjointInterpolator interpolator;
+     theInstance = &interpolator;
+  }
+ return theInstance; 
+}
+
+///////////////////////////////////////////////////////
+//
+G4AdjointInterpolator::G4AdjointInterpolator()
+{;
+}
+///////////////////////////////////////////////////////
+//
+G4AdjointInterpolator::~G4AdjointInterpolator()
+{;
+}
+///////////////////////////////////////////////////////
+//
+G4double G4AdjointInterpolator::LinearInterpolation(G4double& x,G4double& x1,G4double& x2,G4double& y1,G4double& y2)
+{ G4double res = y1+ (x-x1)*(y2-y1)/(x2-x1);
+  //G4cout<<"Linear "<<res<<std::endl;
+  return res;	
+}
+///////////////////////////////////////////////////////
+//
+G4double G4AdjointInterpolator::LogarithmicInterpolation(G4double& x,G4double& x1,G4double& x2,G4double& y1,G4double& y2)
+{ if (y1<=0 || y2<=0 || x1<=0) return LinearInterpolation(x,x1,x2,y1,y2);
+  G4double B=std::log(y2/y1)/std::log(x2/x1);
+  //G4cout<<"x1,x2,y1,y2 "<<x1<<'\t'<<x2<<'\t'<<y1<<'\t'<<y2<<'\t'<<std::endl;
+  G4double A=y1/std::pow(x1,B);
+  G4double res=A*std::pow(x,B);
+ // G4cout<<"Log "<<res<<std::endl;
+  return res;
+}
+///////////////////////////////////////////////////////
+//
+G4double G4AdjointInterpolator::ExponentialInterpolation(G4double& x,G4double& x1,G4double& x2,G4double& y1,G4double& y2)
+{ G4double B=(std::log(y2)-std::log(y1));
+  B=B/(x2-x1);
+  G4double A=y1*std::exp(-B*x1);
+  G4double res=A*std::exp(B*x);
+  return res;
+}
+///////////////////////////////////////////////////////
+//
+G4double G4AdjointInterpolator::Interpolation(G4double& x,G4double& x1,G4double& x2,G4double& y1,G4double& y2,G4String InterPolMethod)
+{
+  if (InterPolMethod == "Log" ){
+  	return LogarithmicInterpolation(x,x1,x2,y1,y2);
+  }
+  else if (InterPolMethod == "Lin" ){
+  	return LinearInterpolation(x,x1,x2,y1,y2);
+  }
+  else if (InterPolMethod == "Exp" ){
+  	return ExponentialInterpolation(x,x1,x2,y1,y2);
+  }
+  else {
+  	//G4cout<<"The interpolation method that you invoked does not exist!"<<std::endl; 
+	return -1111111111.;
+  }
+}
+///////////////////////////////////////////////////////
+//
+size_t  G4AdjointInterpolator::FindPosition(G4double& x,std::vector<double>& x_vec,size_t , size_t ) //only valid if x_vec is monotically increasing
+{  //most rapid nethod could be used probably
+   //It is important to put std::vector<double>& such that the vector itself is used and not a copy
+  
+  
+  size_t ndim = x_vec.size();
+  size_t ind1 = 0;
+  size_t ind2 = ndim - 1;
+ /* if (ind_max >= ind_min){
+  	ind1=ind_min;
+	ind2=ind_max;
+	
+  
+  }
+  */
+  
+  
+  if (ndim >1) {
+  	
+	if (x_vec[0] < x_vec[1] ) { //increasing
+		do {
+         		size_t midBin = (ind1 + ind2)/2;
+         		if (x < x_vec[midBin])
+           				ind2 = midBin;
+         		else 
+					ind1 = midBin;
+      		} while (ind2 - ind1 > 1);
+	}
+	else {
+		do {
+         		size_t midBin = (ind1 + ind2)/2;
+         		if (x < x_vec[midBin])
+           				ind1 = midBin;
+         		else 
+					ind2 = midBin;
+      		} while (ind2 - ind1 > 1);
+	}
+  
+  }
+	
+  return ind1;
+}
+
+///////////////////////////////////////////////////////
+//
+size_t  G4AdjointInterpolator::FindPositionForLogVector(G4double& log_x,std::vector<double>& log_x_vec) //only valid if x_vec is monotically increasing
+{  //most rapid nethod could be used probably
+   //It is important to put std::vector<double>& such that the vector itself is used and not a copy
+  
+  if (log_x_vec.size()>3){ 
+  	size_t ind=0;
+  	G4double log_x1=log_x_vec[1];
+  	G4double d_log =log_x_vec[2]-log_x1;
+	G4double dind=(log_x-log_x1)/d_log +1.;
+	if (dind <1.) ind=0;
+	else if (dind >= double(log_x_vec.size())-2.) ind =log_x_vec.size()-2;
+	else ind =size_t(dind);
+	return ind;
+	
+  }
+  else 	return FindPosition(log_x, log_x_vec);
+  
+ 
+}
+///////////////////////////////////////////////////////
+//
+G4double G4AdjointInterpolator::Interpolate(G4double& x,std::vector<double>& x_vec,std::vector<double>& y_vec,G4String InterPolMethod)
+{ size_t i=FindPosition(x,x_vec);
+  //G4cout<<i<<std::endl;
+  //G4cout<<x<<std::endl;
+  //G4cout<<x_vec[i]<<std::endl; 
+  return Interpolation(	x,x_vec[i],x_vec[i+1],y_vec[i],y_vec[i+1],InterPolMethod);
+}
+
+///////////////////////////////////////////////////////
+//
+G4double G4AdjointInterpolator::InterpolateWithIndexVector(G4double& x,std::vector<double>& x_vec,std::vector<double>& y_vec,
+					    std::vector<size_t>& index_vec,G4double x0, G4double dx) //only linear interpolation possible
+{ size_t ind=0;
+  if (x>x0) ind=int((x-x0)/dx);
+  if (ind >= index_vec.size()-1) ind= index_vec.size()-2;
+  size_t ind1 = index_vec[ind];
+  size_t ind2 = index_vec[ind+1];
+  if (ind1 >ind2) {
+  	size_t ind11=ind1;
+  	ind1=ind2;
+	ind2=ind11;
+  
+  }
+  
+  ind=FindPosition(x,x_vec,ind1,ind2);
+  return Interpolation(	x,x_vec[ind],x_vec[ind+1],y_vec[ind],y_vec[ind+1],"Lin");
+  
+}					    
+					      
+
+///////////////////////////////////////////////////////
+//
+G4double G4AdjointInterpolator::InterpolateForLogVector(G4double& log_x,std::vector<double>& log_x_vec,std::vector<double>& log_y_vec)
+{ //size_t i=0;
+  size_t i=FindPositionForLogVector(log_x,log_x_vec);
+  /*G4cout<<"In interpolate "<<std::endl;
+  G4cout<<i<<std::endl;
+  G4cout<<log_x<<std::endl;
+  G4cout<<log_x_vec[i]<<std::endl;
+  G4cout<<log_x_vec[i+1]<<std::endl;
+  G4cout<<log_y_vec[i]<<std::endl;
+  G4cout<<log_y_vec[i+1]<<std::endl;*/
+  
+  G4double log_y=LinearInterpolation(log_x,log_x_vec[i],log_x_vec[i+1],log_y_vec[i],log_y_vec[i+1]);
+  return log_y; 
+ 
+}  
Index: trunk/source/processes/electromagnetic/adjoint/src/G4AdjointPhotoElectricModel.cc
===================================================================
--- trunk/source/processes/electromagnetic/adjoint/src/G4AdjointPhotoElectricModel.cc	(revision 966)
+++ trunk/source/processes/electromagnetic/adjoint/src/G4AdjointPhotoElectricModel.cc	(revision 966)
@@ -0,0 +1,221 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+#include "G4AdjointPhotoElectricModel.hh"
+#include "G4AdjointCSManager.hh"
+
+
+#include "G4Integrator.hh"
+#include "G4TrackStatus.hh"
+#include "G4ParticleChange.hh"
+#include "G4AdjointElectron.hh"
+#include  "G4Gamma.hh"
+#include "G4AdjointGamma.hh"
+
+////////////////////////////////////////////////////////////////////////////////
+//
+G4AdjointPhotoElectricModel::G4AdjointPhotoElectricModel():
+ G4VEmAdjointModel("AdjointPEEffect")
+
+{ SetUseMatrix(false);
+  current_eEnergy =0.;
+  totAdjointCS=0.;
+}
+////////////////////////////////////////////////////////////////////////////////
+//
+G4AdjointPhotoElectricModel::~G4AdjointPhotoElectricModel()
+{;}
+
+////////////////////////////////////////////////////////////////////////////////
+//
+void G4AdjointPhotoElectricModel::SampleSecondaries(const G4Track& aTrack,
+                                G4bool IsScatProjToProjCase,
+				G4ParticleChange* fParticleChange)
+{ if (IsScatProjToProjCase) return ;
+
+  //Compute the totAdjointCS vectors if not already done for the current couple and electron energy
+  const G4MaterialCutsCouple* aCouple = aTrack.GetMaterialCutsCouple();
+  const G4DynamicParticle* aDynPart =  aTrack.GetDynamicParticle() ;
+  G4double electronEnergy = aDynPart->GetKineticEnergy();
+  G4ThreeVector electronDirection= aDynPart->GetMomentumDirection() ;
+  totAdjointCS = AdjointCrossSection(aCouple, electronEnergy,IsScatProjToProjCase);
+				
+ 
+  //Sample gamma energy
+  //-------------
+  	/////////////////////////////////////////////////////////////////////////////////
+//      Module:		G4ContinuousGainOfEnergy.hh
+//	Author:       	L. Desorgher
+//	Date:		1 September 2007
+// 	Organisation: 	SpaceIT GmbH
+// 	Customer:     	ESA/ESTEC
+/////////////////////////////////////////////////////////////////////////////////
+//
+// CHANGE HISTORY
+// --------------
+//      ChangeHistory: 
+//	 	1 September 2007 creation by L. Desorgher  		
+//
+//-------------------------------------------------------------
+//	Documentation:
+//		Modell for the adjoint compton scattering
+//
+
+  //Sample element
+  //-------------
+   const G4ElementVector* theElementVector = currentMaterial->GetElementVector();
+   const G4double* theAtomNumDensityVector = currentMaterial->GetVecNbOfAtomsPerVolume();
+   size_t nelm =  currentMaterial->GetNumberOfElements();
+   G4double rand_CS= totAdjointCS*G4UniformRand();
+   for (index_element=0; index_element<nelm-1; index_element++){
+	if (rand_CS<xsec[index_element]) break;
+   }
+	
+   //Sample shell and binding energy
+   //-------------
+   rand_CS= totAdjointCS*G4UniformRand()/theAtomNumDensityVector[index_element];
+   G4int nShells = (*theElementVector)[index_element]->GetNbOfAtomicShells();
+   G4int i  = 0;  
+   for (i=0; i<nShells-1; i++){
+	if (rand_CS<shell_prob[index_element][i]) break;
+   }
+   G4double gammaEnergy= electronEnergy+(*theElementVector)[index_element]->GetAtomicShell(i);
+	
+  //Sample cos theta
+  //Copy of the G4PEEffectModel cos theta sampling method ElecCosThetaDistribution.   
+  //This method cannot be used directly from G4PEEffectModel because it is a friend method. I should ask Vladimir to change that  
+  //------------------------------------------------------------------------------------------------	
+  //G4double cos_theta = theDirectPEEffectModel->ElecCosThetaDistribution(electronEnergy);
+	
+   G4double  cos_theta = 1.;
+   G4double gamma   = 1. + electronEnergy/electron_mass_c2;
+   if (gamma <= 5.) {
+  	G4double beta  = std::sqrt(gamma*gamma-1.)/gamma;
+ 	G4double b     = 0.5*gamma*(gamma-1.)*(gamma-2);
+
+  	G4double rndm,term,greject,grejsup;
+  	if (gamma < 2.) grejsup = gamma*gamma*(1.+b-beta*b);
+  	else            grejsup = gamma*gamma*(1.+b+beta*b);
+
+  	do {	rndm = 1.-2*G4UniformRand();
+       	 	cos_theta = (rndm+beta)/(rndm*beta+1.);
+       		term = 1.-beta*cos_theta;
+       		greject = (1.-cos_theta*cos_theta)*(1.+b*term)/(term*term);
+  	} while(greject < G4UniformRand()*grejsup);
+  }
+	
+  // direction of the adjoint gamma electron
+  //---------------------------------------
+  
+     
+  G4double sin_theta = std::sqrt(1.-cos_theta*cos_theta);
+  G4double Phi     = twopi * G4UniformRand();
+  G4double dirx = sin_theta*std::cos(Phi),diry = sin_theta*std::sin(Phi),dirz = cos_theta;
+  G4ThreeVector adjoint_gammaDirection(dirx,diry,dirz);
+  adjoint_gammaDirection.rotateUz(electronDirection);
+  
+  
+  
+  //Weight correction
+ //-----------------------					   
+  CorrectPostStepWeight(fParticleChange, aTrack.GetWeight(), electronEnergy,gammaEnergy);	
+ 
+  
+  
+  //Create secondary and modify fParticleChange 
+  //--------------------------------------------
+  G4DynamicParticle* anAdjointGamma = new G4DynamicParticle (
+                       G4AdjointGamma::AdjointGamma(),adjoint_gammaDirection, gammaEnergy);
+  fParticleChange->ProposeTrackStatus(fStopAndKill);
+  fParticleChange->AddSecondary(anAdjointGamma);
+     
+     	
+
+  
+
+}	
+
+////////////////////////////////////////////////////////////////////////////////
+//			
+
+G4double G4AdjointPhotoElectricModel::AdjointCrossSection(const G4MaterialCutsCouple* aCouple,
+				G4double electronEnergy,
+				G4bool IsScatProjToProjCase)
+{ if (IsScatProjToProjCase) return 0.;
+  if (aCouple !=currentCouple || current_eEnergy !=electronEnergy) {
+  	totAdjointCS = 0.;
+	DefineCurrentMaterialAndElectronEnergy(aCouple, electronEnergy);
+  	const G4ElementVector* theElementVector = currentMaterial->GetElementVector();
+  	const G4double* theAtomNumDensityVector = currentMaterial->GetVecNbOfAtomsPerVolume();
+  	size_t nelm =  currentMaterial->GetNumberOfElements();
+  	for (index_element=0;index_element<nelm;index_element++){
+		
+		totAdjointCS +=AdjointCrossSectionPerAtom((*theElementVector)[index_element],electronEnergy)*theAtomNumDensityVector[index_element];
+		xsec[index_element] = totAdjointCS;
+	} 
+  }	
+  return totAdjointCS;
+  
+  
+}
+////////////////////////////////////////////////////////////////////////////////
+//			
+
+G4double G4AdjointPhotoElectricModel::AdjointCrossSectionPerAtom(const G4Element* anElement,G4double electronEnergy)
+{ 
+  G4int nShells = anElement->GetNbOfAtomicShells();
+  G4double Z= anElement->GetZ();
+  G4double N= anElement->GetN();
+  G4int i  = 0;  
+  G4double B0=anElement->GetAtomicShell(0);
+  G4double gammaEnergy = electronEnergy+B0;
+  G4double adjointCS = theDirectPEEffectModel->ComputeCrossSectionPerAtom(G4Gamma::Gamma(),gammaEnergy,Z,N,0.,0.)*electronEnergy/gammaEnergy; 
+  shell_prob[index_element][0] = adjointCS;                                          
+  for (i=1;i<nShells;i++){
+  	//G4cout<<i<<std::endl;
+  	G4double Bi_= anElement->GetAtomicShell(i-1);
+	G4double Bi = anElement->GetAtomicShell(i);
+	//G4cout<<Bi_<<'\t'<<Bi<<std::endl;
+	if (electronEnergy <Bi_-Bi) {
+		gammaEnergy = electronEnergy+Bi;
+		adjointCS +=theDirectPEEffectModel->ComputeCrossSectionPerAtom(G4Gamma::Gamma(),gammaEnergy,anElement->GetZ(),N,0.,0.)*electronEnergy/gammaEnergy;
+	}
+	shell_prob[index_element][i] = adjointCS;	
+  
+  }
+  
+  return adjointCS;
+  
+}				
+////////////////////////////////////////////////////////////////////////////////
+//			
+
+void G4AdjointPhotoElectricModel::DefineCurrentMaterialAndElectronEnergy(const G4MaterialCutsCouple* couple, G4double anEnergy)
+{ currentCouple   = const_cast<G4MaterialCutsCouple*> (couple);
+  currentMaterial = const_cast<G4Material*> (couple->GetMaterial());
+  currentCoupleIndex = couple->GetIndex();
+  currentMaterialIndex = currentMaterial->GetIndex();
+  current_eEnergy = anEnergy;	
+}
Index: trunk/source/processes/electromagnetic/adjoint/src/G4ContinuousGainOfEnergy.cc
===================================================================
--- trunk/source/processes/electromagnetic/adjoint/src/G4ContinuousGainOfEnergy.cc	(revision 966)
+++ trunk/source/processes/electromagnetic/adjoint/src/G4ContinuousGainOfEnergy.cc	(revision 966)
@@ -0,0 +1,169 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+#include "G4ContinuousGainOfEnergy.hh"
+#include "G4Step.hh"
+#include "G4ParticleDefinition.hh"
+#include "G4VEmModel.hh"
+#include "G4VEmFluctuationModel.hh"
+#include "G4VParticleChange.hh"
+#include "G4UnitsTable.hh"
+
+
+///////////////////////////////////////////////////////
+//
+G4ContinuousGainOfEnergy::G4ContinuousGainOfEnergy(const G4String& name, 
+  G4ProcessType type): G4VContinuousProcess(name, type)
+{
+
+  linLossLimit=0.05;
+  lossFluctuationArePossible =true;
+  lossFluctuationFlag=true;
+  is_integral = false;
+  
+}
+
+///////////////////////////////////////////////////////
+//
+G4ContinuousGainOfEnergy::~G4ContinuousGainOfEnergy()
+{
+ 
+}
+///////////////////////////////////////////////////////
+//
+
+void G4ContinuousGainOfEnergy::PreparePhysicsTable(
+     const G4ParticleDefinition& )
+{//theDirectEnergyLossProcess->PreparePhysicsTable(part);
+
+; 
+}
+
+///////////////////////////////////////////////////////
+//
+
+void G4ContinuousGainOfEnergy::BuildPhysicsTable(const G4ParticleDefinition&)
+{//theDirectEnergyLossProcess->BuildPhysicsTable(part);
+;
+}
+
+
+
+
+///////////////////////////////////////////////////////
+//
+// 
+G4VParticleChange* G4ContinuousGainOfEnergy::AlongStepDoIt(const G4Track& track,
+                                                       const G4Step& step)
+{
+   
+  aParticleChange.Initialize(track);
+  
+  // Get the actual (true) Step length
+  //----------------------------------
+  G4double length = step.GetStepLength();
+  G4double degain  = 0.0;
+ 
+ 
+ 
+
+  // Compute this for weight change after continuous energy loss
+  //-------------------------------------------------------------
+  G4double DEDX_before = 
+  		theDirectEnergyLossProcess
+				->GetDEDX(preStepKinEnergy, currentCouple);
+ 
+ 
+  
+  // For the fluctuation we generate a new dynamic particle with energy =preEnergy+egain
+  // and then compute the fluctuation given in  the direct case.
+  //-----------------------------------------------------------------------
+  G4DynamicParticle* dynParticle = new G4DynamicParticle();
+  *dynParticle = *(track.GetDynamicParticle());
+  G4double Tkin = dynParticle->GetKineticEnergy();
+  
+  size_t n=1;
+  if (is_integral ) n=10;
+  G4double dlength= length/n; 
+  for (size_t i=0;i<n;i++) {
+  	G4double r = theDirectEnergyLossProcess->GetRange(Tkin, currentCouple);
+   	if( dlength <= linLossLimit * r ) {
+    		degain = DEDX_before*dlength;
+	} 
+  	else {
+    		G4double x = r + length;
+    		degain = theDirectEnergyLossProcess->GetKineticEnergy(x,currentCouple) - theDirectEnergyLossProcess->GetKineticEnergy(r,currentCouple);
+  	}
+	G4VEmModel* currentModel =  theDirectEnergyLossProcess->SelectModelForMaterial(Tkin+degain,currentMaterialIndex);
+  	G4double tmax = currentModel->MaxSecondaryKinEnergy(dynParticle);
+ 	tmax = std::min(tmax,currentTcut);
+ 
+  
+
+  	// Sample fluctuations
+  	//-------------------
+  	
+	G4double deltaE =0.;
+  	if (lossFluctuationFlag ) {
+      		deltaE = currentModel->GetModelOfFluctuations()->
+      						SampleFluctuations(currentMaterial,dynParticle,tmax,length,degain)-degain;
+  	}
+	Tkin+=degain+deltaE;
+	dynParticle->SetKineticEnergy(Tkin);
+  	
+  }
+ 
+  
+
+  // Corrections, which cannot be tabulated 
+  // probably  this should be also changed
+  // at this time it does nothing so we can leave it
+  //CorrectionsAlongStep(currentCouple, dynParticle, egain, length);
+  
+  delete dynParticle;
+ 
+  
+  G4double DEDX_after = theDirectEnergyLossProcess->GetDEDX(Tkin, currentCouple);
+  G4double weight_correction=DEDX_after/DEDX_before; //probably not needed
+  weight_correction=1.;
+  
+  aParticleChange.ProposeEnergy(Tkin);
+  
+  //we still need to register in the particleChange the modification of the weight of the particle 
+  G4double new_weight=weight_correction*track.GetWeight();
+  aParticleChange.SetParentWeightByProcess(true);
+  aParticleChange.ProposeParentWeight(new_weight);
+  
+
+  return &aParticleChange;
+
+}
+///////////////////////////////////////////////////////
+//
+void G4ContinuousGainOfEnergy::SetLossFluctuations(G4bool val)
+{
+  if(val && !lossFluctuationArePossible) return;
+  lossFluctuationFlag = val;
+}
Index: trunk/source/processes/electromagnetic/adjoint/src/G4InversePEEffect.cc
===================================================================
--- trunk/source/processes/electromagnetic/adjoint/src/G4InversePEEffect.cc	(revision 966)
+++ trunk/source/processes/electromagnetic/adjoint/src/G4InversePEEffect.cc	(revision 966)
@@ -0,0 +1,40 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+#include "G4InversePEEffect.hh"
+#include "G4VEmAdjointModel.hh"
+#include "G4AdjointPhotoElectricModel.hh"
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+G4InversePEEffect::G4InversePEEffect(G4String process_name,G4AdjointPhotoElectricModel* aModel):
+				G4VAdjointInverseScattering(process_name,false)
+{theAdjointEMModel = aModel;
+ theAdjointEMModel->SetSecondPartOfSameType(false); 
+}
+/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+G4InversePEEffect::~G4InversePEEffect(){
+}
Index: trunk/source/processes/electromagnetic/adjoint/src/G4VAdjointInverseScattering.cc
===================================================================
--- trunk/source/processes/electromagnetic/adjoint/src/G4VAdjointInverseScattering.cc	(revision 966)
+++ trunk/source/processes/electromagnetic/adjoint/src/G4VAdjointInverseScattering.cc	(revision 966)
@@ -0,0 +1,103 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+#include "G4VAdjointInverseScattering.hh"
+#include "G4AdjointCSManager.hh"
+#include "G4AdjointCSMatrix.hh"
+#include "G4AdjointInterpolator.hh"
+#include "G4AdjointCSMatrix.hh"
+#include "G4VEmAdjointModel.hh"
+#include "G4ElementTable.hh"
+#include "G4Element.hh"
+#include "G4Material.hh"
+#include "G4MaterialCutsCouple.hh"
+#include "G4AdjointCSManager.hh"
+#include "G4ParticleChange.hh"
+#include "G4AdjointElectron.hh"
+
+
+G4VAdjointInverseScattering::
+	G4VAdjointInverseScattering(G4String process_name, G4bool whichScatCase):
+			G4VDiscreteProcess(process_name)
+{theAdjointCSManager = G4AdjointCSManager::GetAdjointCSManager();
+ IsScatProjToProjCase=whichScatCase;
+ /*theAdjointEMModel=aModel;
+ IsScatProjToProjCase=whichScatCase;*/
+ fParticleChange=new G4ParticleChange();
+ 
+}
+//////////////////////////////////////////////////////////////////////////////
+//
+G4VAdjointInverseScattering::
+	~G4VAdjointInverseScattering()
+{;
+}			
+//////////////////////////////////////////////////////////////////////////////
+//
+void G4VAdjointInverseScattering::PreparePhysicsTable(const G4ParticleDefinition&)
+{;
+}
+//////////////////////////////////////////////////////////////////////////////
+//
+void G4VAdjointInverseScattering::BuildPhysicsTable(const G4ParticleDefinition&)
+{
+
+ theAdjointCSManager->BuildCrossSectionMatrices(); //do not worry it will be done just once
+ theAdjointCSManager->BuildTotalSigmaTables();
+
+}
+//////////////////////////////////////////////////////////////////////////////
+//
+G4VParticleChange* G4VAdjointInverseScattering::PostStepDoIt(const G4Track& track, const G4Step& )
+{ 
+  fParticleChange->Initialize(track);
+ 
+  theAdjointEMModel->SampleSecondaries(track,
+                                       IsScatProjToProjCase,
+					fParticleChange);
+  
+  ClearNumberOfInteractionLengthLeft();
+  return fParticleChange;
+  			
+   
+  
+}
+//////////////////////////////////////////////////////////////////////////////
+//
+G4double G4VAdjointInverseScattering::GetMeanFreePath(const G4Track& track,
+                                         					     G4double ,
+                                         					     G4ForceCondition* condition)
+{ *condition = NotForced;
+  G4double preStepKinEnergy = track.GetKineticEnergy();
+  
+  G4double Sigma =
+  		theAdjointEMModel->AdjointCrossSection(track.GetMaterialCutsCouple(),preStepKinEnergy,IsScatProjToProjCase);
+  		
+
+  G4double mean_free_path = 1./Sigma;
+  //G4cout<<"mean_free_path [mm] "<<mean_free_path/mm<<std::endl;
+  return mean_free_path;
+}					 
+				 
Index: trunk/source/processes/electromagnetic/adjoint/src/G4VEmAdjointModel.cc
===================================================================
--- trunk/source/processes/electromagnetic/adjoint/src/G4VEmAdjointModel.cc	(revision 966)
+++ trunk/source/processes/electromagnetic/adjoint/src/G4VEmAdjointModel.cc	(revision 966)
@@ -0,0 +1,878 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+#include "G4VEmAdjointModel.hh"
+#include "G4AdjointCSManager.hh"
+
+
+#include "G4Integrator.hh"
+#include "G4TrackStatus.hh"
+#include "G4ParticleChange.hh"
+#include "G4AdjointElectron.hh"
+#include "G4AdjointInterpolator.hh"
+
+////////////////////////////////////////////////////////////////////////////////
+//
+G4VEmAdjointModel::G4VEmAdjointModel(const G4String& nam):
+name(nam)
+// lowLimit(0.1*keV), highLimit(100.0*TeV), fluc(0), name(nam), pParticleChange(0)
+{ G4AdjointCSManager::GetAdjointCSManager()->RegisterEmAdjointModel(this);
+  CorrectWeightMode =true;
+  UseMatrix =true;
+  UseMatrixPerElement = true;
+  ApplyCutInRange = true;
+  ApplyBiasing = true;
+  UseOnlyOneMatrixForAllElements = true;
+  IsIonisation =true; 
+  CS_biasing_factor =1.;
+  //ApplyBiasing = false;
+}
+////////////////////////////////////////////////////////////////////////////////
+//
+G4VEmAdjointModel::~G4VEmAdjointModel()
+{;}
+////////////////////////////////////////////////////////////////////////////////
+//
+void G4VEmAdjointModel::SampleSecondaries(const G4Track& aTrack,
+                       G4bool IsScatProjToProjCase,
+	               G4ParticleChange* fParticleChange)
+{ 
+
+  const G4DynamicParticle* theAdjointPrimary =aTrack.GetDynamicParticle();
+  //DefineCurrentMaterial(aTrack->GetMaterialCutsCouple());
+  size_t ind=0;
+  if (!UseMatrixPerElement) ind = currentMaterialIndex;
+  //G4cout<<theAdjointPrimary<<std::endl;
+  else if (!UseOnlyOneMatrixForAllElements) { //Select Material
+   	std::vector<double>* CS_Vs_Element = &CS_Vs_ElementForScatProjToProjCase;
+  	if ( !IsScatProjToProjCase) CS_Vs_Element = &CS_Vs_ElementForProdToProjCase;
+  	G4double rand_var= G4UniformRand();
+  	G4double SumCS=0.;
+  	for (size_t i=0;i<CS_Vs_Element->size();i++){
+ 		SumCS+=(*CS_Vs_Element)[i];
+		if (rand_var<=SumCS/lastCS){
+			ind=i;
+			break;
+		}
+  	}
+	ind = currentMaterial->GetElement(ind)->GetIndex();
+  }
+  
+ 
+ 
+ //Elastic inverse scattering //not correct in all the cases 
+ //---------------------------------------------------------
+ G4double adjointPrimKinEnergy = theAdjointPrimary->GetKineticEnergy();
+ G4double adjointPrimTotalEnergy = theAdjointPrimary->GetTotalEnergy();
+ G4double adjointPrimP =theAdjointPrimary->GetTotalMomentum();
+ //G4cout<<adjointPrimKinEnergy<<std::endl;
+ if (adjointPrimKinEnergy>HighEnergyLimit*0.999){
+ 	return;
+ }
+ 
+ //Sample secondary energy
+ //-----------------------
+ G4double projectileKinEnergy;
+// if (!IsIonisation  ) {
+ 	projectileKinEnergy = SampleAdjSecEnergyFromCSMatrix(ind,
+ 						  adjointPrimKinEnergy,
+						  IsScatProjToProjCase);
+ //}
+ /*else {
+	projectileKinEnergy = 	SampleAdjSecEnergyFromDiffCrossSectionPerAtom(adjointPrimKinEnergy,IsScatProjToProjCase);
+ 	//G4cout<<projectileKinEnergy<<std::endl;
+ }*/	
+ //Weight correction
+ //-----------------------
+ 
+ CorrectPostStepWeight(fParticleChange, aTrack.GetWeight(), adjointPrimKinEnergy,projectileKinEnergy);					   
+ 
+ 		 
+ 
+ 
+ 
+ //Kinematic
+ //---------
+ 
+ G4double projectileM0 = theAdjEquivOfDirectPrimPartDef->GetPDGMass();
+ G4double projectileTotalEnergy = projectileM0+projectileKinEnergy;
+ G4double projectileP2 = projectileTotalEnergy*projectileTotalEnergy - projectileM0*projectileM0;	
+ 
+ 
+ 
+ //Companion
+ //-----------
+ G4double companionM0;
+ companionM0=(adjointPrimTotalEnergy-adjointPrimKinEnergy);
+ if (IsScatProjToProjCase) {
+  	companionM0=theAdjEquivOfDirectSecondPartDef->GetPDGMass();
+ } 
+ G4double companionTotalEnergy =companionM0+ projectileKinEnergy-adjointPrimKinEnergy;
+ G4double companionP2 = companionTotalEnergy*companionTotalEnergy - companionM0*companionM0;	
+ 
+ 
+ //Projectile momentum
+ //--------------------
+ G4double  P_parallel = (adjointPrimP*adjointPrimP +  projectileP2 - companionP2)/(2.*adjointPrimP);
+ G4double  P_perp = std::sqrt( projectileP2 -  P_parallel*P_parallel);
+ G4ThreeVector dir_parallel=theAdjointPrimary->GetMomentumDirection();
+ G4double phi =G4UniformRand()*2.*3.1415926;
+ G4ThreeVector projectileMomentum = G4ThreeVector(P_perp*std::cos(phi),P_perp*std::sin(phi),P_parallel);
+ projectileMomentum.rotateUz(dir_parallel);
+ 
+ 
+ 
+ if (!IsScatProjToProjCase && CorrectWeightMode){ //kill the primary and add a secondary
+ 	fParticleChange->ProposeTrackStatus(fStopAndKill);
+ 	fParticleChange->AddSecondary(new G4DynamicParticle(theAdjEquivOfDirectPrimPartDef,projectileMomentum));
+	//G4cout<<"projectileMomentum "<<projectileMomentum<<std::endl;
+ }
+ else {
+ 	fParticleChange->ProposeEnergy(projectileKinEnergy);
+	fParticleChange->ProposeMomentumDirection(projectileMomentum.unit());
+ }	
+}
+////////////////////////////////////////////////////////////////////////////////
+//
+void G4VEmAdjointModel::CorrectPostStepWeight(G4ParticleChange* fParticleChange, G4double old_weight,  G4double , G4double ) 
+{
+ G4double new_weight=old_weight;
+ if (CorrectWeightMode) {
+ 	G4double w_corr =1./CS_biasing_factor;
+	//G4cout<<w_corr<<std::endl;
+	
+	/*G4AdjointCSManager::GetAdjointCSManager()->GetPostStepWeightCorrection(theAdjEquivOfDirectPrimPartDef, 
+									       theAdjEquivOfDirectSecondPartDef,
+					    		 		       adjointPrimKinEnergy,projectileKinEnergy,
+	 		   	     			  		       aTrack.GetMaterialCutsCouple());
+	w_corr = projectileKinEnergy;
+	G4double Emin,Emax;
+	if (IsScatProjToProjCase) {
+		Emax = GetSecondAdjEnergyMaxForScatProjToProjCase(adjointPrimKinEnergy);
+		Emin = GetSecondAdjEnergyMinForScatProjToProjCase(adjointPrimKinEnergy, currentTcutForDirectSecond);
+		
+	}
+	else {
+		Emax = GetSecondAdjEnergyMaxForProdToProjCase(adjointPrimKinEnergy);
+		Emin = GetSecondAdjEnergyMinForProdToProjCase(adjointPrimKinEnergy);	
+	}
+	w_corr *=std::log(Emax/Emin)/(Emax-Emin); */	
+		
+	new_weight*=w_corr;
+ }
+ G4cout<< "new weight"<<new_weight<<std::endl;
+ fParticleChange->SetParentWeightByProcess(false);
+ fParticleChange->SetSecondaryWeightByProcess(false);
+ fParticleChange->ProposeParentWeight(new_weight);	
+}
+////////////////////////////////////////////////////////////////////////////////
+//				
+G4double G4VEmAdjointModel::AdjointCrossSection(const G4MaterialCutsCouple* aCouple,
+				G4double primEnergy,
+				G4bool IsScatProjToProjCase)
+{ 
+  DefineCurrentMaterial(aCouple);
+  //G4double fwdCS = G4AdjointCSManager::GetAdjointCSManager()->GetTotalForwardCS(G4AdjointElectron::AdjointElectron(),primEnergy,aCouple);
+  //G4double adjCS = G4AdjointCSManager::GetAdjointCSManager()->GetTotalAdjointCS(G4AdjointElectron::AdjointElectron(), primEnergy,aCouple);
+  if (IsScatProjToProjCase){
+  	lastCS = G4AdjointCSManager::GetAdjointCSManager()->ComputeAdjointCS(currentMaterial,
+					    		 		this, 
+					    		 		primEnergy,
+					    		 		currentTcutForDirectSecond,
+					    		 		true,
+							 		CS_Vs_ElementForScatProjToProjCase);
+	/*G4double fwdCS = G4AdjointCSManager::GetAdjointCSManager()->GetTotalForwardCS(theAdjEquivOfDirectPrimPartDef,primEnergy,aCouple);
+  	G4double adjCS = G4AdjointCSManager::GetAdjointCSManager()->GetTotalAdjointCS(theAdjEquivOfDirectPrimPartDef, primEnergy,aCouple);
+	*/
+	//if (adjCS >0 )lastCS *=fwdCS/adjCS;
+ 
+  }
+  else {
+  	lastCS = G4AdjointCSManager::GetAdjointCSManager()->ComputeAdjointCS(currentMaterial,
+					    		 		this, 
+					    		 		primEnergy,
+					    		 		currentTcutForDirectSecond,
+					    		 		false,
+									CS_Vs_ElementForProdToProjCase);
+	/*G4double fwdCS = G4AdjointCSManager::GetAdjointCSManager()->GetTotalForwardCS(theAdjEquivOfDirectSecondPartDef,primEnergy,aCouple);
+  	G4double adjCS = G4AdjointCSManager::GetAdjointCSManager()->GetTotalAdjointCS(theAdjEquivOfDirectSecondPartDef, primEnergy,aCouple);
+	*/
+	//if (adjCS >0 )lastCS *=fwdCS/adjCS;						 		
+	//lastCS=0.;								
+  }
+ 
+  
+  return lastCS;
+  									
+}				
+////////////////////////////////////////////////////////////////////////////////
+//
+//The implementation here is correct for energy loss process, for the photoelectric and compton scattering the method should be redefine  
+G4double G4VEmAdjointModel::DiffCrossSectionPerAtomPrimToSecond(
+                                      G4double kinEnergyProj, 
+                                      G4double kinEnergyProd,
+				      G4double Z, 
+                                      G4double A)
+{
+ G4double dSigmadEprod=0;
+ G4double Emax_proj = GetSecondAdjEnergyMaxForProdToProjCase(kinEnergyProd);
+ G4double Emin_proj = GetSecondAdjEnergyMinForProdToProjCase(kinEnergyProd);
+ 
+ 
+ if (kinEnergyProj>Emin_proj && kinEnergyProj<=Emax_proj){ //the produced particle should have a kinetic energy smaller than the projectile 
+	G4double Tmax=kinEnergyProj;
+	if (second_part_of_same_type) Tmax = kinEnergyProj/2.;
+	return Z*DiffCrossSectionMoller(kinEnergyProj,kinEnergyProd);
+	//it could be thta Tmax here should be DBLMAX
+	//Tmax=DBLMAX;
+	
+ 	G4double E1=kinEnergyProd;
+ 	G4double E2=kinEnergyProd*1.000001;
+ 	G4double dE=(E2-E1);
+ 	G4double sigma1=theDirectEMModel->ComputeCrossSectionPerAtom(theDirectPrimaryPartDef,kinEnergyProj,Z,A ,E1,1.e20);
+ 	G4double sigma2=theDirectEMModel->ComputeCrossSectionPerAtom(theDirectPrimaryPartDef,kinEnergyProj,Z,A ,E2,1.e20);
+ 	
+	dSigmadEprod=(sigma1-sigma2)/dE;
+	if (dSigmadEprod>1.) {
+		G4cout<<"sigma1 "<<kinEnergyProj/MeV<<'\t'<<kinEnergyProd/MeV<<'\t'<<sigma1<<std::endl;
+		G4cout<<"sigma2 "<<kinEnergyProj/MeV<<'\t'<<kinEnergyProd/MeV<<'\t'<<sigma2<<std::endl;
+		G4cout<<"dsigma "<<kinEnergyProj/MeV<<'\t'<<kinEnergyProd/MeV<<'\t'<<dSigmadEprod<<std::endl;
+		
+	}
+	
+	
+ 	
+ }
+ 
+ 
+
+ 	
+ return dSigmadEprod;	
+ 
+ 
+ 
+}
+//The implementation here is correct for energy loss process, for the photoelectric and compton scattering the method should be redefine 
+////////////////////////////////////////////////////////////////////////////////
+//
+G4double G4VEmAdjointModel::DiffCrossSectionPerAtomPrimToScatPrim(
+                                      G4double kinEnergyProj, 
+                                      G4double kinEnergyScatProj,
+				      G4double Z, 
+                                      G4double A)
+{ G4double kinEnergyProd = kinEnergyProj - kinEnergyScatProj;
+  G4double dSigmadEprod;
+  if (kinEnergyProd <=0) dSigmadEprod=0;
+  else dSigmadEprod=DiffCrossSectionPerAtomPrimToSecond(kinEnergyProj,kinEnergyProd,Z,A);
+  return dSigmadEprod;	
+
+}
+
+////////////////////////////////////////////////////////////////////////////////
+//
+//The implementation here is correct for energy loss process, for the photoelectric and compton scattering the method should be redefine  
+G4double G4VEmAdjointModel::DiffCrossSectionPerVolumePrimToSecond(
+				      const G4Material* aMaterial,
+                                      G4double kinEnergyProj, 
+                                      G4double kinEnergyProd)
+{
+ G4double dSigmadEprod=0;
+ G4double Emax_proj = GetSecondAdjEnergyMaxForProdToProjCase(kinEnergyProd);
+ G4double Emin_proj = GetSecondAdjEnergyMinForProdToProjCase(kinEnergyProd);
+ 
+ 
+ if (kinEnergyProj>Emin_proj && kinEnergyProj<=Emax_proj){ 
+	G4double Tmax=kinEnergyProj;
+	if (second_part_of_same_type) Tmax = kinEnergyProj/2.;
+	//it could be thta Tmax here should be DBLMAX
+	//Tmax=DBLMAX;
+	
+ 	G4double E1=kinEnergyProd;
+	
+ 	G4double E2=kinEnergyProd*1.0001;
+ 	G4double dE=(E2-E1);
+ 	G4double sigma1=theDirectEMModel->CrossSectionPerVolume(aMaterial,theDirectPrimaryPartDef,kinEnergyProj,E1,E2);
+        
+	//G4double sigma2=theDirectEMModel->CrossSectionPerVolume(aMaterial,theDirectPrimaryPartDef,kinEnergyProj,E2,1.e50);
+ 	dSigmadEprod=sigma1/dE;
+	if (dSigmadEprod <0) { //could happen with bremstrahlung dur to suppression effect
+		G4cout<<"Halllllllllllllllllllllllllllllllllllllllllllllllo "<<kinEnergyProj<<'\t'<<E1<<'\t'<<dSigmadEprod<<std::endl;
+		E1=kinEnergyProd;
+		E2=E1*1.1;
+		dE=E2-E1;
+		sigma1=theDirectEMModel->CrossSectionPerVolume(aMaterial,theDirectPrimaryPartDef,kinEnergyProj,E1,1.e50);
+        	G4double sigma2=theDirectEMModel->CrossSectionPerVolume(aMaterial,theDirectPrimaryPartDef,kinEnergyProj,E2,1.e50);
+		dSigmadEprod=(sigma1-sigma2)/dE;
+		G4cout<<dSigmadEprod<<std::endl;
+	}	
+	
+ 	
+ }
+
+
+ 	
+ return dSigmadEprod;	
+ 
+ 
+ 
+}
+//The implementation here is correct for energy loss process, for the photoelectric and compton scattering the method should be redefine 
+////////////////////////////////////////////////////////////////////////////////
+//
+G4double G4VEmAdjointModel::DiffCrossSectionPerVolumePrimToScatPrim(
+                                      const G4Material* aMaterial,
+				      G4double kinEnergyProj, 
+                                      G4double kinEnergyScatProj)
+{ G4double kinEnergyProd = kinEnergyProj - kinEnergyScatProj;
+  G4double dSigmadEprod;
+  if (kinEnergyProd <=0) dSigmadEprod=0;
+  else dSigmadEprod=DiffCrossSectionPerVolumePrimToSecond(aMaterial,kinEnergyProj,kinEnergyProd);
+  return dSigmadEprod;	
+
+}
+///////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+G4double G4VEmAdjointModel::DiffCrossSectionFunction1(G4double kinEnergyProj){
+  //return kinEnergyProj*kinEnergyProj;
+  //ApplyBiasing=false;
+  G4double bias_factor = CS_biasing_factor*kinEnergyProdForIntegration/kinEnergyProj;	
+  if (!ApplyBiasing) bias_factor =CS_biasing_factor; 
+  //G4cout<<bias_factor<<std::endl;
+  if (UseMatrixPerElement ) {
+  	return DiffCrossSectionPerAtomPrimToSecond(kinEnergyProj,kinEnergyProdForIntegration,ZSelectedNucleus,ASelectedNucleus)*bias_factor;
+  }
+  else {
+  	return DiffCrossSectionPerVolumePrimToSecond(SelectedMaterial,kinEnergyProj,kinEnergyProdForIntegration)*bias_factor;
+  }	
+}
+//////////////////////////////////////////////////////////////////////////////
+//
+G4double G4VEmAdjointModel::DiffCrossSectionMoller(G4double kinEnergyProj,G4double kinEnergyProd){
+  G4double electron_mass_c2=0.51099906*MeV;
+  G4double energy = kinEnergyProj + electron_mass_c2;
+  G4double x   = kinEnergyProd/kinEnergyProj;
+  G4double gam    = energy/electron_mass_c2;
+  G4double gamma2 = gam*gam;
+  G4double beta2  = 1.0 - 1.0/gamma2;
+  
+  G4double g = (2.0*gam - 1.0)/gamma2;
+  G4double y = 1.0 - x;
+  G4double fac=twopi_mc2_rcl2/electron_mass_c2;
+  G4double dCS = fac*( 1.-g + ((1.0 - g*x)/(x*x)) + ((1.0 - g*y)/(y*y)))/(beta2*(gam-1));
+  return dCS/kinEnergyProj;
+  
+ 
+
+}  
+////////////////////////////////////////////////////////////////////////////////
+//
+G4double G4VEmAdjointModel::DiffCrossSectionFunction2(G4double kinEnergyProj){
+  //return kinEnergyProj*kinEnergyProj;	
+  G4double bias_factor =  CS_biasing_factor*kinEnergyScatProjForIntegration/kinEnergyProj;
+  //ApplyBiasing=false;
+ if (!ApplyBiasing) bias_factor = CS_biasing_factor;
+ //G4cout<<bias_factor<<std::endl; 
+ if (UseMatrixPerElement ) {
+  	return DiffCrossSectionPerAtomPrimToScatPrim(kinEnergyProj,kinEnergyScatProjForIntegration,ZSelectedNucleus,ASelectedNucleus)*bias_factor;
+ }	
+ else {
+ 	return DiffCrossSectionPerVolumePrimToScatPrim(SelectedMaterial,kinEnergyProj,kinEnergyScatProjForIntegration)*bias_factor;
+ 
+ }	
+ 		
+}
+////////////////////////////////////////////////////////////////////////////////
+//
+std::vector< std::vector<G4double>* > G4VEmAdjointModel::ComputeAdjointCrossSectionVectorPerAtomForSecond(      
+				G4double kinEnergyProd,
+				G4double Z, 
+                                G4double A ,
+				G4int nbin_pro_decade) //nb bins pro order of magnitude of energy
+{ G4Integrator<G4VEmAdjointModel, G4double(G4VEmAdjointModel::*)(G4double)> integral;
+  ASelectedNucleus= G4int(A);
+  ZSelectedNucleus=G4int(Z);
+  kinEnergyProdForIntegration = kinEnergyProd;
+  
+  //compute the vector of integrated cross sections
+  //-------------------
+  
+  G4double minEProj= GetSecondAdjEnergyMinForProdToProjCase(kinEnergyProd);
+  G4double maxEProj= GetSecondAdjEnergyMaxForProdToProjCase(kinEnergyProd);
+  G4double E1=minEProj;
+  std::vector< G4double >*  log_ESec_vector = new  std::vector< G4double >();
+  std::vector< G4double >*  log_Prob_vector = new  std::vector< G4double >();
+  log_ESec_vector->clear();
+  log_Prob_vector->clear();
+  log_ESec_vector->push_back(std::log(E1));
+  log_Prob_vector->push_back(-50.);
+  
+  G4double E2=std::pow(10.,G4double( G4int(std::log10(minEProj)*nbin_pro_decade)+1)/nbin_pro_decade);
+  G4double fE=std::pow(10.,1./nbin_pro_decade);
+  G4double int_cross_section=0.;
+  
+  if (std::pow(fE,5.)>(maxEProj/minEProj)) fE = std::pow(maxEProj/minEProj,0.2);
+  
+  while (E1 <maxEProj*0.9999999){
+  	//G4cout<<E1<<'\t'<<E2<<std::endl;
+	
+  	int_cross_section +=integral.Simpson(this, &G4VEmAdjointModel::DiffCrossSectionFunction1,E1,std::min(E2,maxEProj*0.99999999), 10);
+	//G4cout<<"int_cross_section 1 "<<'\t'<<int_cross_section<<std::endl;
+	log_ESec_vector->push_back(std::log(std::min(E2,maxEProj)));
+	log_Prob_vector->push_back(std::log(int_cross_section));	
+	E1=E2;
+	E2*=fE;
+  
+  }
+  std::vector< std::vector<G4double>* > res_mat;
+  res_mat.clear();
+  if (int_cross_section >0.) {
+  	res_mat.push_back(log_ESec_vector);
+  	res_mat.push_back(log_Prob_vector);
+  }	
+  
+  return res_mat;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////
+//
+std::vector< std::vector<G4double>* > G4VEmAdjointModel::ComputeAdjointCrossSectionVectorPerAtomForScatProj(
+      				G4double kinEnergyScatProj,
+				G4double Z, 
+                                G4double A ,
+				G4int nbin_pro_decade) //nb bins pro order of magnitude of energy
+{ G4Integrator<G4VEmAdjointModel, G4double(G4VEmAdjointModel::*)(G4double)> integral;
+  ASelectedNucleus=G4int(A);
+  ZSelectedNucleus=G4int(Z);
+  kinEnergyScatProjForIntegration = kinEnergyScatProj;
+  
+  //compute the vector of integrated cross sections
+  //-------------------
+  
+  G4double minEProj= GetSecondAdjEnergyMinForScatProjToProjCase(kinEnergyScatProj); 
+  G4double maxEProj= GetSecondAdjEnergyMaxForScatProjToProjCase(kinEnergyScatProj);
+  G4double dEmax=maxEProj-kinEnergyScatProj;
+  G4double dEmin=GetLowEnergyLimit();
+  G4double dE1=dEmin;
+  G4double dE2=dEmin;
+  
+  
+  std::vector< G4double >*  log_ESec_vector = new std::vector< G4double >();
+  std::vector< G4double >*  log_Prob_vector = new std::vector< G4double >();
+  log_ESec_vector->push_back(std::log(dEmin));
+  log_Prob_vector->push_back(-50.);
+  G4int nbins=std::max( G4int(std::log10(dEmax/dEmin))*nbin_pro_decade,5);
+  G4double fE=std::pow(dEmax/dEmin,1./nbins);
+  
+  G4double int_cross_section=0.;
+  
+  while (dE1 <dEmax*0.9999999999999){
+  	dE2=dE1*fE;
+  	int_cross_section +=integral.Simpson(this,
+	&G4VEmAdjointModel::DiffCrossSectionFunction2,minEProj+dE1,std::min(minEProj+dE2,maxEProj), 20);
+	//G4cout<<"int_cross_section "<<minEProj+dE1<<'\t'<<int_cross_section<<std::endl;
+	log_ESec_vector->push_back(std::log(std::min(dE2,maxEProj)));
+	log_Prob_vector->push_back(std::log(int_cross_section));	
+	dE1=dE2;
+
+  }
+  /*G4cout<<"total int_cross_section"<<'\t'<<int_cross_section<<std::endl;
+  G4cout<<"energy "<<kinEnergyScatProj<<std::endl;*/
+  
+  
+  
+  
+  std::vector< std::vector<G4double> *> res_mat; 
+  res_mat.clear();
+  if (int_cross_section >0.) {
+  	res_mat.push_back(log_ESec_vector);
+  	res_mat.push_back(log_Prob_vector);
+  }	
+  
+  return res_mat;
+}
+////////////////////////////////////////////////////////////////////////////////
+//
+std::vector< std::vector<G4double>* > G4VEmAdjointModel::ComputeAdjointCrossSectionVectorPerVolumeForSecond(      
+				G4Material* aMaterial,
+				G4double kinEnergyProd,
+				G4int nbin_pro_decade) //nb bins pro order of magnitude of energy
+{ G4Integrator<G4VEmAdjointModel, G4double(G4VEmAdjointModel::*)(G4double)> integral;
+  SelectedMaterial= aMaterial;
+  kinEnergyProdForIntegration = kinEnergyProd;
+  //G4cout<<aMaterial->GetName()<<std::endl;
+  //G4cout<<kinEnergyProd/MeV<<std::endl;
+  //compute the vector of integrated cross sections
+  //-------------------
+  
+  G4double minEProj= GetSecondAdjEnergyMinForProdToProjCase(kinEnergyProd);
+  G4double maxEProj= GetSecondAdjEnergyMaxForProdToProjCase(kinEnergyProd);
+  G4double E1=minEProj;
+  std::vector< G4double >*  log_ESec_vector = new  std::vector< G4double >();
+  std::vector< G4double >*  log_Prob_vector = new  std::vector< G4double >();
+  log_ESec_vector->clear();
+  log_Prob_vector->clear();
+  log_ESec_vector->push_back(std::log(E1));
+  log_Prob_vector->push_back(-50.);
+  
+  G4double E2=std::pow(10.,G4double( G4int(std::log10(minEProj)*nbin_pro_decade)+1)/nbin_pro_decade);
+  G4double fE=std::pow(10.,1./nbin_pro_decade);
+  G4double int_cross_section=0.;
+  
+  if (std::pow(fE,5.)>(maxEProj/minEProj)) fE = std::pow(maxEProj/minEProj,0.2);
+  
+  while (E1 <maxEProj*0.9999999){
+  	//G4cout<<E1<<'\t'<<E2<<std::endl;
+	
+  	int_cross_section +=integral.Simpson(this, &G4VEmAdjointModel::DiffCrossSectionFunction1,E1,std::min(E2,maxEProj*0.99999999), 10);
+	//G4cout<<"int_cross_section 1 "<<E1<<'\t'<<int_cross_section<<std::endl;
+	log_ESec_vector->push_back(std::log(std::min(E2,maxEProj)));
+	log_Prob_vector->push_back(std::log(int_cross_section));
+	E1=E2;
+	E2*=fE;
+  
+  }
+  std::vector< std::vector<G4double>* > res_mat;
+  res_mat.clear();
+  
+  //if (int_cross_section >0.) {
+  	res_mat.push_back(log_ESec_vector);
+  	res_mat.push_back(log_Prob_vector);
+  //}	
+  
+  return res_mat;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////
+//
+std::vector< std::vector<G4double>* > G4VEmAdjointModel::ComputeAdjointCrossSectionVectorPerVolumeForScatProj(
+      				G4Material* aMaterial,
+				G4double kinEnergyScatProj,
+				G4int nbin_pro_decade) //nb bins pro order of magnitude of energy
+{ G4Integrator<G4VEmAdjointModel, G4double(G4VEmAdjointModel::*)(G4double)> integral;
+  SelectedMaterial= aMaterial;
+  kinEnergyScatProjForIntegration = kinEnergyScatProj;
+  /*G4cout<<name<<std::endl;
+  G4cout<<aMaterial->GetName()<<std::endl;
+  G4cout<<kinEnergyScatProj/MeV<<std::endl;*/
+  //compute the vector of integrated cross sections
+  //-------------------
+  
+  G4double minEProj= GetSecondAdjEnergyMinForScatProjToProjCase(kinEnergyScatProj);
+  G4double maxEProj= GetSecondAdjEnergyMaxForScatProjToProjCase(kinEnergyScatProj);
+ 
+  
+  G4double dEmax=maxEProj-kinEnergyScatProj;
+  G4double dEmin=GetLowEnergyLimit();
+  G4double dE1=dEmin;
+  G4double dE2=dEmin;
+  
+  
+  std::vector< G4double >*  log_ESec_vector = new std::vector< G4double >();
+  std::vector< G4double >*  log_Prob_vector = new std::vector< G4double >();
+  log_ESec_vector->push_back(std::log(dEmin));
+  log_Prob_vector->push_back(-50.);
+  G4int nbins=std::max( G4int(std::log10(dEmax/dEmin))*nbin_pro_decade,5);
+  G4double fE=std::pow(dEmax/dEmin,1./nbins);
+  
+  G4double int_cross_section=0.;
+  
+  while (dE1 <dEmax*0.9999999999999){
+  	dE2=dE1*fE;
+  	int_cross_section +=integral.Simpson(this,
+	&G4VEmAdjointModel::DiffCrossSectionFunction2,minEProj+dE1,std::min(minEProj+dE2,maxEProj), 20);
+	//G4cout<<"int_cross_section "<<minEProj+dE1<<'\t'<<int_cross_section<<std::endl;
+	log_ESec_vector->push_back(std::log(std::min(dE2,maxEProj)));
+	log_Prob_vector->push_back(std::log(int_cross_section));
+	dE1=dE2;
+
+  }
+  
+  
+  
+  
+  
+  std::vector< std::vector<G4double> *> res_mat;
+  res_mat.clear();
+  if (int_cross_section >0.) {
+  	res_mat.push_back(log_ESec_vector);
+  	res_mat.push_back(log_Prob_vector);
+  }	
+  
+  return res_mat;
+}
+//////////////////////////////////////////////////////////////////////////////
+//				
+G4double G4VEmAdjointModel::SampleAdjSecEnergyFromCSMatrix(size_t MatrixIndex,G4double aPrimEnergy,G4bool IsScatProjToProjCase)
+{ 
+  
+  
+  G4AdjointCSMatrix* theMatrix= (*pOnCSMatrixForProdToProjBackwardScattering)[MatrixIndex];
+  if (IsScatProjToProjCase) theMatrix= (*pOnCSMatrixForScatProjToProjBackwardScattering)[MatrixIndex];
+  std::vector< G4double >* theLogPrimEnergyVector = theMatrix->GetLogPrimEnergyVector();
+  //G4double dLog = theMatrix->GetDlog();
+  
+  
+  
+  if (theLogPrimEnergyVector->size() ==0){
+ 	G4cout<<"No data are contained in the given AdjointCSMatrix!"<<std::endl;
+	G4cout<<"The sampling procedure will be stopped."<<std::endl;
+	return 0.;
+	
+  }
+  
+  G4AdjointInterpolator* theInterpolator=G4AdjointInterpolator::GetInstance();
+  G4double aLogPrimEnergy = std::log(aPrimEnergy);
+  size_t ind =theInterpolator->FindPositionForLogVector(aLogPrimEnergy,*theLogPrimEnergyVector);
+  
+  
+  G4double aLogPrimEnergy1,aLogPrimEnergy2;
+  G4double aLogCS1,aLogCS2;
+   G4double log01,log02;
+  std::vector< G4double>* aLogSecondEnergyVector1 =0;
+  std::vector< G4double>* aLogSecondEnergyVector2  =0;
+  std::vector< G4double>* aLogProbVector1=0;
+  std::vector< G4double>* aLogProbVector2=0; 
+  std::vector< size_t>* aLogProbVectorIndex1=0;
+  std::vector< size_t>* aLogProbVectorIndex2=0;
+	 							     
+  theMatrix->GetData(ind, aLogPrimEnergy1,aLogCS1,log01, aLogSecondEnergyVector1,aLogProbVector1,aLogProbVectorIndex1);
+  theMatrix->GetData(ind+1, aLogPrimEnergy2,aLogCS2,log02, aLogSecondEnergyVector2,aLogProbVector2,aLogProbVectorIndex2);
+  
+  G4double rand_var = G4UniformRand();
+  G4double log_rand_var= std::log(rand_var);
+  G4double log_Tcut =std::log(currentTcutForDirectSecond);
+  G4double Esec=0;
+  G4double log_dE1,log_dE2;
+  G4double log_rand_var1,log_rand_var2;
+  G4double log_E1,log_E2;
+  log_rand_var1=log_rand_var;
+  log_rand_var2=log_rand_var;
+  
+  G4double Emin=0.;
+  G4double Emax=0.;
+  if (theMatrix->IsScatProjToProjCase()){ //case where Tcut plays a role
+ 	//G4cout<<"Here "<<std::endl;
+	if (ApplyCutInRange) {
+		if (second_part_of_same_type && currentTcutForDirectSecond>aPrimEnergy) return aPrimEnergy;
+		/*if (IsIonisation){
+			G4double inv_Tcut= 1./currentTcutForDirectSecond;
+			G4double inv_dE=inv_Tcut-rand_var*(inv_Tcut-1./aPrimEnergy);
+			Esec= aPrimEnergy+1./inv_dE;
+			//return Esec;
+			G4double dE1=currentTcutForDirectSecond;
+			G4double dE2=currentTcutForDirectSecond*1.00001;
+			G4double dCS1=DiffCrossSectionMoller(aPrimEnergy+dE1,dE1);
+			G4double dCS2=DiffCrossSectionMoller(aPrimEnergy+dE2,dE2);
+			G4double alpha1=std::log(dCS1/dCS2)/std::log(dE1/dE2);
+			G4double a1=dCS1/std::pow(dE1,alpha1);
+			dCS1=DiffCrossSectionMoller(aPrimEnergy+dE1,dE1);
+			dCS2=DiffCrossSectionMoller(aPrimEnergy+dE2,dE2);
+			
+			return Esec;
+			
+			
+			
+			dE1=aPrimEnergy/1.00001;
+			dE2=aPrimEnergy;
+			dCS1=DiffCrossSectionMoller(aPrimEnergy+dE1,dE1);
+			dCS2=DiffCrossSectionMoller(aPrimEnergy+dE2,dE2);
+			G4double alpha2=std::log(dCS1/dCS2)/std::log(dE1/dE2);
+			G4double a2=dCS1/std::pow(dE1,alpha1);
+			return Esec;
+			
+			
+			
+			
+		}*/	
+		log_rand_var1=log_rand_var+theInterpolator->InterpolateForLogVector(log_Tcut,*aLogSecondEnergyVector1,*aLogProbVector1);
+		log_rand_var2=log_rand_var+theInterpolator->InterpolateForLogVector(log_Tcut,*aLogSecondEnergyVector2,*aLogProbVector2);
+		
+	}	
+	log_dE1 = theInterpolator->Interpolate(log_rand_var1,*aLogProbVector1,*aLogSecondEnergyVector1,"Lin");
+ 	log_dE2 = theInterpolator->Interpolate(log_rand_var2,*aLogProbVector2,*aLogSecondEnergyVector2,"Lin");
+	
+	/*log_dE1 = theInterpolator->InterpolateWithIndexVector(log_rand_var1,*aLogProbVector1,*aLogSecondEnergyVector1,*aLogProbVectorIndex1,log01,dLog);
+	log_dE2 = theInterpolator->InterpolateWithIndexVector(log_rand_var1,*aLogProbVector1,*aLogSecondEnergyVector1,*aLogProbVectorIndex1,log02,dLog);
+	*/				    
+					    
+	
+	
+	
+	
+	Esec = aPrimEnergy +
+	std::exp(theInterpolator->LinearInterpolation(aLogPrimEnergy,aLogPrimEnergy1,aLogPrimEnergy2,log_dE1,log_dE2));
+	
+	Emin=GetSecondAdjEnergyMinForScatProjToProjCase(aPrimEnergy);
+	Emax=GetSecondAdjEnergyMaxForScatProjToProjCase(aPrimEnergy);
+	Esec=std::max(Esec,Emin);
+	Esec=std::min(Esec,Emax);
+	
+	
+	//G4cout<<"Esec "<<Esec<<std::endl;
+	//if (Esec > 2.*aPrimEnergy && second_part_of_same_type) Esec = 2.*aPrimEnergy; 
+  }
+  else { //Tcut condition is already full-filled
+        /*G4cout<<"Start "<<std::endl;
+  	G4cout<<std::exp((*aLogProbVector1)[0])<<std::endl;
+	G4cout<<std::exp((*aLogProbVector2)[0])<<std::endl;*/
+	/*G4double inv_E1= .5/aPrimEnergy;
+		
+	G4double inv_E=inv_E1-rand_var*(inv_E1-0.00001);
+	Esec= 1./inv_E;
+	return Esec;*/
+ 	log_E1 = theInterpolator->Interpolate(log_rand_var,*aLogProbVector1,*aLogSecondEnergyVector1,"Lin");
+ 	log_E2 = theInterpolator->Interpolate(log_rand_var,*aLogProbVector2,*aLogSecondEnergyVector2,"Lin");
+	/*log_E1 = theInterpolator->InterpolateWithIndexVector(log_rand_var1,*aLogProbVector1,*aLogSecondEnergyVector1,*aLogProbVectorIndex1,log01,dLog);
+	log_E2 = theInterpolator->InterpolateWithIndexVector(log_rand_var1,*aLogProbVector1,*aLogSecondEnergyVector1,*aLogProbVectorIndex1,log02,dLog);
+	*/
+	
+	
+	/*G4cout<<std::exp(log_E1)<<std::endl;
+	G4cout<<std::exp(log_E2)<<std::endl;*/
+	
+	Esec = std::exp(theInterpolator->LinearInterpolation(aLogPrimEnergy,aLogPrimEnergy1,aLogPrimEnergy2,log_E1,log_E2));
+	Emin=GetSecondAdjEnergyMinForProdToProjCase(aPrimEnergy);
+	Emax=GetSecondAdjEnergyMaxForProdToProjCase(aPrimEnergy);
+	Esec=std::max(Esec,Emin);
+	Esec=std::min(Esec,Emax);
+	
+  }
+  	
+  return Esec;
+  
+  
+  
+ 
+										   
+}
+//////////////////////////////////////////////////////////////////////////////
+//				
+G4double G4VEmAdjointModel::SampleAdjSecEnergyFromDiffCrossSectionPerAtom(G4double prim_energy,G4bool IsScatProjToProjCase)
+{  
+  // here we try to use the rejection method 
+  //-----------------------------------------
+  
+  G4double E=0;
+  G4double x,xmin,greject,q;
+  if ( IsScatProjToProjCase){
+  	G4double Emax = GetSecondAdjEnergyMaxForScatProjToProjCase(prim_energy);
+        G4double Emin= prim_energy+currentTcutForDirectSecond;
+	xmin=Emin/Emax;
+	G4double grejmax = DiffCrossSectionPerAtomPrimToScatPrim(Emin,prim_energy,1)*prim_energy; 
+
+	do {
+        	q = G4UniformRand();
+        	x = 1./(q*(1./xmin -1.) +1.);
+		E=x*Emax;
+		greject = DiffCrossSectionPerAtomPrimToScatPrim( E,prim_energy ,1)*prim_energy; 
+		
+	}	
+        
+	while( greject < G4UniformRand()*grejmax );	
+	
+  }
+  else {
+  	G4double Emax = GetSecondAdjEnergyMaxForProdToProjCase(prim_energy);
+        G4double Emin=  GetSecondAdjEnergyMinForProdToProjCase(prim_energy);;
+	xmin=Emin/Emax;
+	G4double grejmax = DiffCrossSectionPerAtomPrimToSecond(Emin,prim_energy,1); 
+	do {
+        	q = G4UniformRand();
+        	x = std::pow(xmin, q);
+		E=x*Emax;
+		greject = DiffCrossSectionPerAtomPrimToSecond( E,prim_energy ,1); 
+		
+	}	
+        
+	while( greject < G4UniformRand()*grejmax );
+  
+  
+  
+  }
+  
+  return E;
+  
+  
+  
+ 
+										   
+}
+//////////////////////////////////////////////////////////////////////////////
+//				
+G4double G4VEmAdjointModel::GetSecondAdjEnergyMaxForScatProjToProjCase(G4double kinEnergyScatProj)
+{ G4double maxEProj= HighEnergyLimit;
+  if (second_part_of_same_type)  maxEProj=std::min(kinEnergyScatProj*2.,HighEnergyLimit);
+  return maxEProj;
+}
+//////////////////////////////////////////////////////////////////////////////
+//
+G4double G4VEmAdjointModel::GetSecondAdjEnergyMinForScatProjToProjCase(G4double PrimAdjEnergy,G4double Tcut)
+{ return PrimAdjEnergy+Tcut;
+}
+//////////////////////////////////////////////////////////////////////////////
+//				
+G4double G4VEmAdjointModel::GetSecondAdjEnergyMaxForProdToProjCase(G4double )
+{ return HighEnergyLimit;
+}
+//////////////////////////////////////////////////////////////////////////////
+//
+G4double G4VEmAdjointModel::GetSecondAdjEnergyMinForProdToProjCase(G4double PrimAdjEnergy)
+{ G4double minEProj=PrimAdjEnergy;
+  if (second_part_of_same_type)  minEProj=PrimAdjEnergy*2.;
+  return minEProj;
+}
+////////////////////////////////////////////////////////////////////////////////////////////
+//
+void  G4VEmAdjointModel::DefineCurrentMaterial(const G4MaterialCutsCouple* couple)
+{ if(couple != currentCouple) {
+    	currentCouple   = const_cast<G4MaterialCutsCouple*> (couple);
+    	currentMaterial = const_cast<G4Material*> (couple->GetMaterial());
+    	currentCoupleIndex = couple->GetIndex();
+    	currentMaterialIndex = currentMaterial->GetIndex();
+   	size_t idx=56;
+    
+   	if (theAdjEquivOfDirectPrimPartDef) {
+    		if (theAdjEquivOfDirectPrimPartDef->GetParticleName() == "adj_gamma") idx = 0;
+   		else if (theAdjEquivOfDirectPrimPartDef->GetParticleName() == "adj_e-") idx = 1;
+    		else if (theAdjEquivOfDirectPrimPartDef->GetParticleName() == "adj_e+") idx = 2;
+    		const std::vector<G4double>* aVec = G4ProductionCutsTable::GetProductionCutsTable()->GetEnergyCutsVector(idx);
+    		currentTcutForDirectPrim=(*aVec)[currentCoupleIndex];
+    	}	
+    
+    
+    	if (theAdjEquivOfDirectPrimPartDef == theAdjEquivOfDirectSecondPartDef) {
+    		currentTcutForDirectSecond = currentTcutForDirectPrim;
+    	}
+   	else { 
+    		if (theAdjEquivOfDirectSecondPartDef){
+			if (theAdjEquivOfDirectSecondPartDef->GetParticleName() == "adj_gamma") idx = 0;
+   			else if (theAdjEquivOfDirectSecondPartDef->GetParticleName() == "adj_e-") idx = 1;
+    			else if (theAdjEquivOfDirectSecondPartDef->GetParticleName() == "adj_e+") idx = 2;
+    			const std::vector<G4double>* aVec = G4ProductionCutsTable::GetProductionCutsTable()->GetEnergyCutsVector(idx);
+    			currentTcutForDirectSecond=(*aVec)[currentCoupleIndex];
+		}
+    	}
+  }
+}
Index: trunk/source/processes/electromagnetic/adjoint/src/G4eInverseBremsstrahlung.cc
===================================================================
--- trunk/source/processes/electromagnetic/adjoint/src/G4eInverseBremsstrahlung.cc	(revision 966)
+++ trunk/source/processes/electromagnetic/adjoint/src/G4eInverseBremsstrahlung.cc	(revision 966)
@@ -0,0 +1,40 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+#include "G4eInverseBremsstrahlung.hh"
+#include "G4VEmAdjointModel.hh"
+#include "G4AdjointBremsstrahlungModel.hh"
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+G4eInverseBremsstrahlung::G4eInverseBremsstrahlung(G4bool whichScatCase,G4String process_name,G4AdjointBremsstrahlungModel* aBremAdjointModel):
+				G4VAdjointInverseScattering(process_name,whichScatCase)
+{theAdjointEMModel = aBremAdjointModel;
+ theAdjointEMModel->SetSecondPartOfSameType(false); 
+}
+/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+G4eInverseBremsstrahlung::~G4eInverseBremsstrahlung(){
+}
Index: trunk/source/processes/electromagnetic/adjoint/src/G4eInverseCompton.cc
===================================================================
--- trunk/source/processes/electromagnetic/adjoint/src/G4eInverseCompton.cc	(revision 966)
+++ trunk/source/processes/electromagnetic/adjoint/src/G4eInverseCompton.cc	(revision 966)
@@ -0,0 +1,48 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+///////////////////////////////////////////////////////
+// File name:     G4eInverseCompton
+//
+// Author:        Laurent Desorgher
+//
+// Creation date: 20.11.2006
+//
+///////////////////////////////////////////////////////
+#include "G4eInverseCompton.hh"
+#include "G4VEmAdjointModel.hh"
+#include "G4AdjointComptonModel.hh"
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+G4eInverseCompton::G4eInverseCompton(G4bool whichScatCase,G4String process_name,G4AdjointComptonModel* aComptonAdjointModel):
+				G4VAdjointInverseScattering(process_name,whichScatCase)
+{theAdjointEMModel = aComptonAdjointModel;
+ theAdjointEMModel->SetSecondPartOfSameType(false); 
+}
+/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+G4eInverseCompton::~G4eInverseCompton(){
+}
Index: trunk/source/processes/electromagnetic/adjoint/src/G4eInverseIonisation.cc
===================================================================
--- trunk/source/processes/electromagnetic/adjoint/src/G4eInverseIonisation.cc	(revision 966)
+++ trunk/source/processes/electromagnetic/adjoint/src/G4eInverseIonisation.cc	(revision 966)
@@ -0,0 +1,47 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+///////////////////////////////////////////////////////
+// File name:     G4eInverseIonisation
+//
+// Author:        Laurent Desorgher
+//
+// Creation date: 20.11.2006
+//
+///////////////////////////////////////////////////////
+#include "G4eInverseIonisation.hh"
+#include "G4VEmAdjointModel.hh"
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+G4eInverseIonisation::G4eInverseIonisation(G4bool whichScatCase,G4String process_name,G4VEmAdjointModel* aEmAdjointModel):
+				G4VAdjointInverseScattering(process_name,whichScatCase)
+{theAdjointEMModel = aEmAdjointModel;
+ theAdjointEMModel->SetSecondPartOfSameType(true); 
+}
+/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+G4eInverseIonisation::~G4eInverseIonisation(){
+}
Index: trunk/source/processes/electromagnetic/highenergy/include/G4ee2KChargedModel.hh
===================================================================
--- trunk/source/processes/electromagnetic/highenergy/include/G4ee2KChargedModel.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/highenergy/include/G4ee2KChargedModel.hh	(revision 966)
@@ -0,0 +1,94 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4ee2KChargedModel.hh,v 1.2 2009/02/20 16:38:33 vnivanch Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+// -------------------------------------------------------------------
+//
+// GEANT4 Class header file
+//
+//
+// File name:     G4ee2KChargedModel
+//
+// Author:        Vladimir Ivanchenko
+//
+// Creation date: 09.07.2008
+//
+// Modifications:
+//
+
+//
+// Class Description:
+//
+
+// -------------------------------------------------------------------
+//
+
+#ifndef G4ee2KChargedModel_h
+#define G4ee2KChargedModel_h 1
+
+#include "G4Vee2hadrons.hh"
+#include "globals.hh"
+#include "G4eeCrossSections.hh"
+
+class G4DynamicParticle;
+class G4PhysicsVector;
+
+class G4ee2KChargedModel : public G4Vee2hadrons
+{
+
+public:
+
+  G4ee2KChargedModel(G4eeCrossSections*);
+
+  virtual ~G4ee2KChargedModel();
+
+  virtual G4double ThresholdEnergy() const;
+
+  virtual G4double PeakEnergy() const;
+
+  virtual G4double ComputeCrossSection(G4double) const;
+
+  virtual G4PhysicsVector* PhysicsVector(G4double, G4double) const;
+
+  virtual void SampleSecondaries(std::vector<G4DynamicParticle*>*,
+              G4double, const G4ThreeVector&);
+
+private:
+
+  // hide assignment operator
+  G4ee2KChargedModel & operator=(const  G4ee2KChargedModel &right);
+  G4ee2KChargedModel(const  G4ee2KChargedModel&);
+
+  G4eeCrossSections* cross;
+
+  G4double massK;
+  G4double massPhi;
+};
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+#endif
Index: trunk/source/processes/electromagnetic/highenergy/include/G4ee2KNeutralModel.hh
===================================================================
--- trunk/source/processes/electromagnetic/highenergy/include/G4ee2KNeutralModel.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/highenergy/include/G4ee2KNeutralModel.hh	(revision 966)
@@ -0,0 +1,94 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4ee2KNeutralModel.hh,v 1.2 2009/02/20 16:38:33 vnivanch Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+// -------------------------------------------------------------------
+//
+// GEANT4 Class header file
+//
+//
+// File name:     G4ee2KNeutralModel
+//
+// Author:        Vladimir Ivanchenko
+//
+// Creation date: 09.07.2008
+//
+// Modifications:
+//
+
+//
+// Class Description:
+//
+
+// -------------------------------------------------------------------
+//
+
+#ifndef G4ee2KNeutralModel_h
+#define G4ee2KNeutralModel_h 1
+
+#include "G4Vee2hadrons.hh"
+#include "globals.hh"
+#include "G4eeCrossSections.hh"
+
+class G4DynamicParticle;
+class G4PhysicsVector;
+
+class G4ee2KNeutralModel : public G4Vee2hadrons
+{
+
+public:
+
+  G4ee2KNeutralModel(G4eeCrossSections*);
+
+  virtual ~G4ee2KNeutralModel();
+
+  virtual G4double ThresholdEnergy() const;
+
+  virtual G4double PeakEnergy() const;
+
+  virtual G4double ComputeCrossSection(G4double) const;
+
+  virtual G4PhysicsVector* PhysicsVector(G4double, G4double) const;
+
+  virtual void SampleSecondaries(std::vector<G4DynamicParticle*>*,
+              G4double, const G4ThreeVector&);
+
+private:
+
+  // hide assignment operator
+  G4ee2KNeutralModel & operator=(const  G4ee2KNeutralModel &right);
+  G4ee2KNeutralModel(const  G4ee2KNeutralModel&);
+
+  G4eeCrossSections* cross;
+
+  G4double massK;
+  G4double massPhi;
+};
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+#endif
Index: trunk/source/processes/electromagnetic/highenergy/include/G4eeTo3PiModel.hh
===================================================================
--- trunk/source/processes/electromagnetic/highenergy/include/G4eeTo3PiModel.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/highenergy/include/G4eeTo3PiModel.hh	(revision 966)
@@ -0,0 +1,98 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4eeTo3PiModel.hh,v 1.2 2009/02/20 16:38:33 vnivanch Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+// -------------------------------------------------------------------
+//
+// GEANT4 Class header file
+//
+//
+// File name:     G4eeTo3PiModel
+//
+// Author:        Vladimir Ivanchenko
+//
+// Creation date: 25.10.2003
+//
+// Modifications:
+//
+
+//
+// Class Description:
+//
+
+// -------------------------------------------------------------------
+//
+
+#ifndef G4eeTo3PiModel_h
+#define G4eeTo3PiModel_h 1
+
+#include "G4Vee2hadrons.hh"
+#include "globals.hh"
+#include "G4eeCrossSections.hh"
+
+class G4DynamicParticle;
+class G4PhysicsVector;
+
+class G4eeTo3PiModel : public G4Vee2hadrons
+{
+
+public:
+
+  G4eeTo3PiModel(G4eeCrossSections*);
+
+  virtual ~G4eeTo3PiModel();
+
+  virtual G4double ThresholdEnergy() const;
+
+  virtual G4double PeakEnergy() const;
+
+  virtual G4double ComputeCrossSection(G4double) const;
+
+  virtual G4PhysicsVector* PhysicsVector(G4double, G4double) const;
+
+  virtual void SampleSecondaries(std::vector<G4DynamicParticle*>*,
+              G4double, const G4ThreeVector&);
+
+private:
+
+  // hide assignment operator
+  G4eeTo3PiModel & operator=(const  G4eeTo3PiModel &right);
+  G4eeTo3PiModel(const  G4eeTo3PiModel&);
+
+  G4eeCrossSections* cross;
+
+  G4double massPi;
+  G4double massPi0;
+  G4double massOm;
+  G4double massPhi;
+  G4double gcash;
+  G4double gmax;
+};
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+#endif
Index: trunk/source/processes/electromagnetic/highenergy/include/G4eeToPGammaModel.hh
===================================================================
--- trunk/source/processes/electromagnetic/highenergy/include/G4eeToPGammaModel.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/highenergy/include/G4eeToPGammaModel.hh	(revision 966)
@@ -0,0 +1,99 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4eeToPGammaModel.hh,v 1.2 2009/02/20 16:38:33 vnivanch Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+// -------------------------------------------------------------------
+//
+// GEANT4 Class header file
+//
+//
+// File name:     G4eeToPGammaModel
+//
+// Author:        Vladimir Ivanchenko
+//
+// Creation date: 10.07.2008
+//
+// Modifications:
+//
+
+//
+// Class Description:
+//
+
+// -------------------------------------------------------------------
+//
+
+#ifndef G4eeToPGammaModel_h
+#define G4eeToPGammaModel_h 1
+
+#include "G4Vee2hadrons.hh"
+#include "globals.hh"
+#include "G4eeCrossSections.hh"
+#include "G4ParticleDefinition.hh"
+
+class G4DynamicParticle;
+class G4PhysicsVector;
+
+class G4eeToPGammaModel : public G4Vee2hadrons
+{
+
+public:
+
+  G4eeToPGammaModel(G4eeCrossSections*, const G4String&);
+
+  virtual ~G4eeToPGammaModel();
+
+  virtual G4double ThresholdEnergy() const;
+
+  virtual G4double PeakEnergy() const;
+
+  virtual G4double ComputeCrossSection(G4double) const;
+
+  virtual G4PhysicsVector* PhysicsVector(G4double, G4double) const;
+
+  virtual void SampleSecondaries(std::vector<G4DynamicParticle*>*,
+              G4double, const G4ThreeVector&);
+
+private:
+
+  // hide assignment operator
+  G4eeToPGammaModel & operator=(const  G4eeToPGammaModel &right);
+  G4eeToPGammaModel(const  G4eeToPGammaModel&);
+
+  G4eeCrossSections* cross;
+
+  G4ParticleDefinition* particle;
+  G4ParticleDefinition* pi0;
+
+  G4double massP;
+  G4double massR;
+
+};
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+#endif
Index: trunk/source/processes/electromagnetic/highenergy/include/G4hBremsstrahlung.hh
===================================================================
--- trunk/source/processes/electromagnetic/highenergy/include/G4hBremsstrahlung.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/highenergy/include/G4hBremsstrahlung.hh	(revision 966)
@@ -0,0 +1,103 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4hBremsstrahlung.hh,v 1.2 2009/02/20 16:38:33 vnivanch Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+// -------------------------------------------------------------------
+//
+// GEANT4 Class header file
+//
+//
+// File name:     G4hBremsstrahlung
+//
+// Author:        Vladimir Ivanchenko on base of model for muons
+//
+// Creation date: 01.03.2008
+//
+// Modifications:
+//
+//
+// Class Description:
+//
+// This class manages the Bremsstrahlung process for hadrons
+// it inherites from G4VContinuousDiscreteProcess via G4VEnergyLossProcess.
+//
+
+// -------------------------------------------------------------------
+//
+
+#ifndef G4hBremsstrahlung_h
+#define G4hBremsstrahlung_h 1
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+#include "globals.hh"
+#include "G4VEnergyLossProcess.hh"
+#include "G4VEmModel.hh"
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+class G4ParticleDefinition;
+
+class G4hBremsstrahlung : public G4VEnergyLossProcess
+
+{
+public:
+
+  G4hBremsstrahlung(const G4String& processName = "hBrems");
+
+  virtual ~G4hBremsstrahlung();
+
+  virtual G4bool IsApplicable(const G4ParticleDefinition& p);
+
+  virtual G4double MinPrimaryEnergy(const G4ParticleDefinition* p,
+				    const G4Material*, 
+				    G4double cut);
+
+  // Print out of the class parameters
+  virtual void PrintInfo();
+
+protected:
+
+  virtual void InitialiseEnergyLossProcess(const G4ParticleDefinition*,
+					   const G4ParticleDefinition*);
+
+private:
+
+  G4hBremsstrahlung & operator=(const G4hBremsstrahlung &right);
+  G4hBremsstrahlung(const G4hBremsstrahlung&);
+
+  const G4ParticleDefinition* theParticle;
+  const G4ParticleDefinition* theBaseParticle;
+
+  G4double  lowestKinEnergy;
+  G4bool    isInitialised;
+
+};
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+#endif
Index: trunk/source/processes/electromagnetic/highenergy/include/G4hBremsstrahlungModel.hh
===================================================================
--- trunk/source/processes/electromagnetic/highenergy/include/G4hBremsstrahlungModel.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/highenergy/include/G4hBremsstrahlungModel.hh	(revision 966)
@@ -0,0 +1,82 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4hBremsstrahlungModel.hh,v 1.2 2008/07/22 16:15:16 vnivanch Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+// -------------------------------------------------------------------
+//
+// GEANT4 Class header file
+//
+//
+// File name:     G4hBremsstrahlungModel
+//
+// Author:        Vladimir Ivanchenko on base of G4MuBremsstrahlungModel
+// 
+// Creation date: 28.02.2008
+//
+// Modifications:
+//
+//
+
+//
+// Class Description:
+//
+// Implementation of energy loss for gamma emission by hadrons
+
+// -------------------------------------------------------------------
+//
+
+#ifndef G4hBremsstrahlungModel_h
+#define G4hBremsstrahlungModel_h 1
+
+#include "G4MuBremsstrahlungModel.hh"
+
+class G4hBremsstrahlungModel : public G4MuBremsstrahlungModel
+{
+
+public:
+
+  G4hBremsstrahlungModel(const G4ParticleDefinition* p = 0,
+			 const G4String& nam = "hBrem");
+
+  virtual ~G4hBremsstrahlungModel();
+
+protected:
+
+  virtual G4double ComputeDMicroscopicCrossSection(G4double tkin,
+						   G4double Z,
+						   G4double gammaEnergy);
+private:
+
+  // hide assignment operator
+  G4hBremsstrahlungModel & operator=(const  G4hBremsstrahlungModel &right);
+  G4hBremsstrahlungModel(const  G4hBremsstrahlungModel&);
+
+};
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+#endif
Index: trunk/source/processes/electromagnetic/highenergy/include/G4hPairProduction.hh
===================================================================
--- trunk/source/processes/electromagnetic/highenergy/include/G4hPairProduction.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/highenergy/include/G4hPairProduction.hh	(revision 966)
@@ -0,0 +1,101 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4hPairProduction.hh,v 1.2 2009/02/20 16:38:33 vnivanch Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+// -------------------------------------------------------------------
+//
+// GEANT4 Class header file
+//
+//
+// File name:     G4hPairProduction
+//
+// Author:        Vladimir Ivanchenko on base of model for muons
+//
+// Creation date: 01.03.2008
+//
+// Modifications:
+//
+//
+// Class Description:
+//
+// This class manages the PairProduction process for hadrons
+// it inherites from G4VContinuousDiscreteProcess via G4VEnergyLossProcess.
+//
+
+// -------------------------------------------------------------------
+//
+
+#ifndef G4hPairProduction_h
+#define G4hPairProduction_h 1
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+#include "globals.hh"
+#include "G4VEnergyLossProcess.hh"
+#include "G4VEmModel.hh"
+
+class G4ParticleChangeForLoss;
+
+class G4hPairProduction : public G4VEnergyLossProcess
+{
+public:
+
+  G4hPairProduction(const G4String& processName = "hPairProd");
+
+  virtual ~G4hPairProduction();
+
+  virtual G4bool IsApplicable(const G4ParticleDefinition& p);
+
+  virtual G4double MinPrimaryEnergy(const G4ParticleDefinition* p,
+				    const G4Material*, G4double cut);
+
+  // Print out of the class parameters
+  virtual void PrintInfo();
+
+protected:
+
+  virtual void InitialiseEnergyLossProcess(const G4ParticleDefinition*,
+					   const G4ParticleDefinition*);
+
+private:
+
+  G4hPairProduction & operator=(const G4hPairProduction &right);
+  G4hPairProduction(const G4hPairProduction&);
+
+  const G4ParticleDefinition* theParticle;
+  const G4ParticleDefinition* theBaseParticle;
+
+  G4ParticleChangeForLoss*    fParticleChange;
+
+  G4double                    lowestKinEnergy;
+  G4bool                      isInitialised;
+
+};
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+#endif
Index: trunk/source/processes/electromagnetic/highenergy/include/G4hPairProductionModel.hh
===================================================================
--- trunk/source/processes/electromagnetic/highenergy/include/G4hPairProductionModel.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/highenergy/include/G4hPairProductionModel.hh	(revision 966)
@@ -0,0 +1,82 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4hPairProductionModel.hh,v 1.2 2008/07/22 16:15:16 vnivanch Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+// -------------------------------------------------------------------
+//
+// GEANT4 Class header file
+//
+//
+// File name:     G4hPairProductionModel
+//
+// Author:        Vladimir Ivanchenko on base of G4MuPairProductionModel
+// 
+// Creation date: 28.02.2008
+//
+// Modifications:
+//
+//
+
+//
+// Class Description:
+//
+// Implementation of e+e- pair production by hadrons
+
+// -------------------------------------------------------------------
+//
+
+#ifndef G4hPairProductionModel_h
+#define G4hPairProductionModel_h 1
+
+#include "G4MuPairProductionModel.hh"
+
+class G4hPairProductionModel : public G4MuPairProductionModel
+{
+
+public:
+
+  G4hPairProductionModel(const G4ParticleDefinition* p = 0,
+			 const G4String& nam = "hPairProd");
+
+  virtual ~G4hPairProductionModel();
+
+protected:
+
+  virtual G4double ComputeDMicroscopicCrossSection(G4double tkin,
+						   G4double Z,
+						   G4double pairEnergy);
+private:
+
+  // hide assignment operator
+  G4hPairProductionModel & operator=(const  G4hPairProductionModel &right);
+  G4hPairProductionModel(const  G4hPairProductionModel&);
+
+};
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+#endif
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4CrossSectionChargeTransferCH.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4CrossSectionChargeTransferCH.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4CrossSectionChargeTransferCH.hh	(revision 966)
@@ -0,0 +1,80 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G4CrossSectionChargeTransferCH.hh,v 1.3 2008/03/25 16:00:20 pia Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+// 
+// Contact Author: Maria Grazia Pia (Maria.Grazia.Pia@cern.ch)
+//
+// History:
+// -----------
+// Date         Name              Modification
+// 28 Dec 2007  M.G. Pia          Created
+//
+// -------------------------------------------------------------------
+
+// Class description:
+
+// Total cross section for charge transfer in hydrocarbons
+// Reference: K. Janev, J. G. Wang and T. Kato, NIFS-DATA (2001)
+//            http://www-cfadc.phy.ornl.gov/astro/ps/data/
+// http://www-pub.iaea.org/MTCD/publications/PDF/APID-VOL10.pdf 
+// Further documentation available from http://www.ge.infn.it/geant4/
+
+// -------------------------------------------------------------------
+
+#ifndef G4CROSSSECTIONCHARGETRANSFERCH_HH
+#define G4CROSSSECTIONCHARGETRANSFERCH_HH 1
+ 
+#include "globals.hh"
+#include <vector>
+#include <map>
+
+class G4Track;
+ 
+class G4CrossSectionChargeTransferCH
+{
+public:
+  
+  G4CrossSectionChargeTransferCH();
+  
+  virtual ~G4CrossSectionChargeTransferCH();
+  
+  G4double CrossSection(const G4Track&);
+  
+  // Copy constructor and assignment operator to be added here
+    
+private:
+   
+  G4String name;  
+  G4double lowEnergyLimit;
+  G4double highEnergyLimit;
+ 
+  std::map<G4String,std::vector<G4double>,std::less<G4String> > crossMap;
+
+};
+
+#endif
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4CrossSectionChargeTransferExp.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4CrossSectionChargeTransferExp.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4CrossSectionChargeTransferExp.hh	(revision 966)
@@ -0,0 +1,83 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G4CrossSectionChargeTransferExp.hh,v 1.2 2008/03/25 16:00:20 pia Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+// 
+// Contact Author: Maria Grazia Pia (Maria.Grazia.Pia@cern.ch)
+//
+// History:
+// -----------
+// Date         Name              Modification
+// 28 Dec 2007  M.G. Pia          Created
+//
+// -------------------------------------------------------------------
+
+// Class description:
+
+// Total cross section for charge transfer from experimental data interpolation
+//            http://www-cfadc.phy.ornl.gov/astro/ps/data/
+// Further documentation available from http://www.ge.infn.it/geant4/
+
+// -------------------------------------------------------------------
+
+#ifndef G4CROSSSECTIONCHARGETRANSFEREXP_HH
+#define G4CROSSSECTIONCHARGETRANSFEREXP_HH 1
+ 
+#include "globals.hh"
+#include <map>
+
+class G4Track;
+class G4VEMDataSet;
+ 
+class G4CrossSectionChargeTransferExp
+{
+public:
+  
+  G4CrossSectionChargeTransferExp();
+  
+  virtual ~G4CrossSectionChargeTransferExp();
+  
+  G4double CrossSection(const G4Track&);
+  
+  // Copy constructor and assignment operator to be added here
+    
+private:
+   
+  G4String name;  
+  G4double lowEnergyLimit;
+  G4double highEnergyLimit;
+  
+  G4double unit1;
+  G4double unit2;
+ 
+  std::map<G4String,G4VEMDataSet*,std::less<G4String> > crossMap;
+
+  G4VEMDataSet* LoadData(const G4String& dataFile);
+
+};
+
+#endif
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4CrossSectionElasticChampion.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4CrossSectionElasticChampion.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4CrossSectionElasticChampion.hh	(revision 966)
@@ -0,0 +1,61 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4CrossSectionElasticChampion.hh,v 1.1 2008/07/15 19:56:50 sincerti Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+// -------------------------------------------------------------------
+
+
+#ifndef G4CROSSSECTIONELASTICCHAMPION_HH
+#define G4CROSSSECTIONELASTICCHAMPION_HH 1
+ 
+#include <map>
+#include "G4DNACrossSectionDataSet.hh"
+#include "G4Electron.hh"
+#include "G4Track.hh"
+#include "G4LogLogInterpolation.hh"
+ 
+class G4CrossSectionElasticChampion
+{
+public:
+  
+  G4CrossSectionElasticChampion();
+  
+  ~G4CrossSectionElasticChampion();
+  
+  G4double CrossSection(const G4Track& track);
+			
+private:
+   
+  G4double lowEnergyLimit;
+  G4double highEnergyLimit;
+
+  typedef std::map<G4String,G4String,std::less<G4String> > MapFile;
+  MapFile tableFile;
+
+  typedef std::map<G4String,G4DNACrossSectionDataSet*,std::less<G4String> > MapData;
+  MapData tableData;
+};
+#endif
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4CrossSectionElasticScreenedRutherfordHE.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4CrossSectionElasticScreenedRutherfordHE.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4CrossSectionElasticScreenedRutherfordHE.hh	(revision 966)
@@ -0,0 +1,54 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4CrossSectionElasticScreenedRutherfordHE.hh,v 1.1 2008/06/27 20:09:54 sincerti Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+
+#ifndef G4CROSSSECTIONELASTICSCREENEDRUTHERFORDHE_HH
+#define G4CROSSSECTIONELASTICSCREENEDRUTHERFORDHE_HH 1
+ 
+#include "G4Track.hh"
+
+class G4CrossSectionElasticScreenedRutherfordHE
+{
+public:
+  
+  G4CrossSectionElasticScreenedRutherfordHE();
+  
+  virtual ~G4CrossSectionElasticScreenedRutherfordHE();
+  
+  G4double CrossSection(const G4Track&);
+    
+private:
+  
+  G4double RutherfordCrossSection(G4double energy, G4double z);
+  
+  G4double ScreeningFactor(G4double energy, G4double z);
+  
+  G4double lowEnergyLimit;
+  G4double highEnergyLimit;
+};
+
+#endif
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4CrossSectionElasticScreenedRutherfordLE.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4CrossSectionElasticScreenedRutherfordLE.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4CrossSectionElasticScreenedRutherfordLE.hh	(revision 966)
@@ -0,0 +1,55 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4CrossSectionElasticScreenedRutherfordLE.hh,v 1.2 2008/07/14 20:47:33 sincerti Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+
+#ifndef G4CROSSSECTIONELASTICSCREENEDRUTHERFORDLE_HH
+#define G4CROSSSECTIONELASTICSCREENEDRUTHERFORDLE_HH 1
+ 
+#include "G4Track.hh"
+ 
+class G4CrossSectionElasticScreenedRutherfordLE
+{
+public:
+  
+  G4CrossSectionElasticScreenedRutherfordLE();
+  
+  virtual ~G4CrossSectionElasticScreenedRutherfordLE();
+  
+  G4double CrossSection(const G4Track&);
+
+private:
+  
+  G4double RutherfordCrossSection(G4double energy, G4double z);
+  
+  G4double ScreeningFactor(G4double energy, G4double z);
+  
+  G4double lowEnergyLimit;
+  G4double highEnergyLimit;
+  
+};
+
+#endif
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4CrossSectionPsCreationChampion.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4CrossSectionPsCreationChampion.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4CrossSectionPsCreationChampion.hh	(revision 966)
@@ -0,0 +1,54 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4CrossSectionPsCreationChampion.hh,v 1.1 2008/07/16 19:01:07 sincerti Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+// -------------------------------------------------------------------
+
+
+#ifndef G4CROSSSECTIONPSCREATIONCHAMPION_HH
+#define G4CROSSSECTIONPSCREATIONCHAMPION_HH 1
+ 
+#include "G4CrossSectionPsCreationChampionPartial.hh"
+#include "G4Track.hh"
+
+class G4CrossSectionPsCreationChampion
+{
+public:
+  
+  G4CrossSectionPsCreationChampion();
+  
+  virtual ~G4CrossSectionPsCreationChampion();
+  
+  G4double CrossSection(const G4Track& track);
+			
+private:
+   
+  G4double lowEnergyLimit;
+  G4double highEnergyLimit;
+
+  G4CrossSectionPsCreationChampionPartial partialCrossSection;
+};
+#endif
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4CrossSectionPsCreationChampionPartial.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4CrossSectionPsCreationChampionPartial.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4CrossSectionPsCreationChampionPartial.hh	(revision 966)
@@ -0,0 +1,67 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4CrossSectionPsCreationChampionPartial.hh,v 1.1 2008/07/16 19:01:07 sincerti Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+// -------------------------------------------------------------------
+
+
+#ifndef G4CROSSSECTIONPSCREATIONCHAMPIONPARTIAL_HH
+#define G4CROSSSECTIONPSCREATIONCHAMPIONPARTIAL_HH 1
+ 
+#include <map>
+#include "G4DNACrossSectionDataSet.hh"
+#include "G4ParticleDefinition.hh"
+#include "G4LogLogInterpolation.hh"
+#include "G4Positron.hh"
+#include "Randomize.hh"
+
+class G4CrossSectionPsCreationChampionPartial
+{
+public:
+  
+  G4CrossSectionPsCreationChampionPartial();
+  
+  virtual ~G4CrossSectionPsCreationChampionPartial();
+  
+  G4double CrossSection(G4double energy, G4int level, const G4ParticleDefinition* particle);
+
+  G4double Sum(G4double energy, const G4ParticleDefinition* particle);
+
+  G4int RandomSelectState(G4double energy, const G4ParticleDefinition* particle);
+
+  G4int RandomSelectShell(G4double energy, const G4ParticleDefinition* particle, G4int state);
+   
+private:
+   
+  G4int numberOfPartialCrossSections;
+
+  typedef std::map<G4String,G4String,std::less<G4String> > MapFile;
+  MapFile tableFile;
+
+  typedef std::map<G4String,G4DNACrossSectionDataSet*,std::less<G4String> > MapData;
+  MapData tableData;
+};
+#endif
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4DNABornExcitationModel.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4DNABornExcitationModel.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4DNABornExcitationModel.hh	(revision 966)
@@ -0,0 +1,103 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4DNABornExcitationModel.hh,v 1.1 2009/01/12 14:26:02 sincerti Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+
+#ifndef G4DNABornExcitationModel_h
+#define G4DNABornExcitationModel_h 1
+
+#include "G4VEmModel.hh"
+#include "G4ParticleChangeForGamma.hh"
+#include "G4ProductionCutsTable.hh"
+
+#include "G4DNACrossSectionDataSet.hh"
+#include "G4LogLogInterpolation.hh"
+#include "G4Proton.hh"
+#include "G4WaterExcitationStructure.hh"
+
+class G4DNABornExcitationModel : public G4VEmModel
+{
+
+public:
+
+  G4DNABornExcitationModel(const G4ParticleDefinition* p = 0, 
+		          const G4String& nam = "DNABornExcitationModel");
+
+  virtual ~G4DNABornExcitationModel();
+
+  virtual void Initialise(const G4ParticleDefinition*, const G4DataVector&);
+
+  virtual G4double CrossSectionPerVolume(const G4Material* material,
+					   const G4ParticleDefinition* p,
+					   G4double ekin,
+					   G4double emin,
+					   G4double emax);
+
+  virtual void SampleSecondaries(std::vector<G4DynamicParticle*>*,
+				 const G4MaterialCutsCouple*,
+				 const G4DynamicParticle*,
+				 G4double tmin,
+				 G4double maxEnergy);
+
+protected:
+
+  G4ParticleChangeForGamma* fParticleChangeForGamma;
+
+private:
+
+  G4double lowEnergyLimit;
+  G4double highEnergyLimit;
+  G4bool isInitialised;
+  G4int verboseLevel;
+  
+  // Cross section
+
+  G4DNACrossSectionDataSet* table;
+
+  // Partial cross section
+  
+  G4int RandomSelect(G4double energy);
+  
+  // Final state
+
+  G4WaterExcitationStructure waterStructure;
+   
+  // Test water material 
+   
+  G4bool flagMaterialIsWater;
+  G4double densityWater;
+   
+  //
+   
+  G4DNABornExcitationModel & operator=(const  G4DNABornExcitationModel &right);
+  G4DNABornExcitationModel(const  G4DNABornExcitationModel&);
+
+};
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+#endif
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4DNABornIonisationModel.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4DNABornIonisationModel.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4DNABornIonisationModel.hh	(revision 966)
@@ -0,0 +1,142 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4DNABornIonisationModel.hh,v 1.1 2009/01/12 14:26:02 sincerti Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+
+#ifndef G4DNABornIonisationModel_h
+#define G4DNABornIonisationModel_h 1
+
+#include "G4VEmModel.hh"
+#include "G4ParticleChangeForGamma.hh"
+#include "G4ProductionCutsTable.hh"
+
+#include "G4DNACrossSectionDataSet.hh"
+#include "G4Electron.hh"
+#include "G4Proton.hh"
+#include "G4LogLogInterpolation.hh"
+
+#include "G4WaterIonisationStructure.hh"
+
+class G4DNABornIonisationModel : public G4VEmModel
+{
+
+public:
+
+  G4DNABornIonisationModel(const G4ParticleDefinition* p = 0, 
+		           const G4String& nam = "DNABornIonisationModel");
+
+  virtual ~G4DNABornIonisationModel();
+
+  virtual void Initialise(const G4ParticleDefinition*, const G4DataVector&);
+
+  virtual G4double CrossSectionPerVolume(  const G4Material* material,
+					   const G4ParticleDefinition* p,
+					   G4double ekin,
+					   G4double emin,
+					   G4double emax);
+
+  virtual void SampleSecondaries(std::vector<G4DynamicParticle*>*,
+				 const G4MaterialCutsCouple*,
+				 const G4DynamicParticle*,
+				 G4double tmin,
+				 G4double maxEnergy);
+
+protected:
+
+  G4ParticleChangeForGamma* fParticleChangeForGamma;
+
+private:
+
+  std::map<G4String,G4double,std::less<G4String> > lowEnergyLimit;
+  std::map<G4String,G4double,std::less<G4String> > highEnergyLimit;
+
+  G4bool isInitialised;
+  G4int verboseLevel;
+  
+  // Cross section
+
+  typedef std::map<G4String,G4String,std::less<G4String> > MapFile;
+  MapFile tableFile;
+
+  typedef std::map<G4String,G4DNACrossSectionDataSet*,std::less<G4String> > MapData;
+  MapData tableData;
+  
+  // Final state
+  
+  G4WaterIonisationStructure waterStructure;
+
+  G4double RandomizeEjectedElectronEnergy(G4ParticleDefinition * aParticleDefinition, G4double incomingParticleEnergy, G4int shell) ;
+
+  void RandomizeEjectedElectronDirection(G4ParticleDefinition * aParticleDefinition, G4double incomingParticleEnergy, G4double
+                                           outgoingParticleEnergy, G4double & cosTheta, G4double & phi );
+   
+  double DifferentialCrossSection(G4ParticleDefinition * aParticleDefinition, G4double k, G4double energyTransfer, G4int shell);
+
+  G4double LogLogInterpolate(G4double e1, G4double e2, G4double e, G4double xs1, G4double xs2);
+   
+  G4double QuadInterpolator( G4double e11, 
+			     G4double e12, 
+			     G4double e21, 
+			     G4double e22, 
+			     G4double x11,
+			     G4double x12, 
+			     G4double x21, 
+			     G4double x22, 
+			     G4double t1, 
+			     G4double t2, 
+			     G4double t, 
+			     G4double e);
+
+  typedef std::map<double, std::map<double, double> > TriDimensionMap;
+  TriDimensionMap eDiffCrossSectionData[6];
+  TriDimensionMap pDiffCrossSectionData[6];
+  std::vector<double> eTdummyVec;
+  std::vector<double> pTdummyVec;
+
+  typedef std::map<double, std::vector<double> > VecMap;
+  VecMap eVecm;
+  VecMap pVecm;
+  
+  // Partial cross section
+  
+  G4int RandomSelect(G4double energy,const G4String& particle );
+
+  // Test water material 
+   
+  G4bool flagMaterialIsWater;
+  G4double densityWater;
+   
+  //
+   
+  G4DNABornIonisationModel & operator=(const  G4DNABornIonisationModel &right);
+  G4DNABornIonisationModel(const  G4DNABornIonisationModel&);
+
+};
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+#endif
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4DNAChampionElasticModel.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4DNAChampionElasticModel.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4DNAChampionElasticModel.hh	(revision 966)
@@ -0,0 +1,131 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4DNAChampionElasticModel.hh,v 1.1 2009/01/12 14:26:02 sincerti Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+
+#ifndef G4DNAChampionElasticModel_h
+#define G4DNAChampionElasticModel_h 1
+
+#include <map>
+#include "G4DNACrossSectionDataSet.hh"
+#include "G4VEmModel.hh"
+#include "G4Electron.hh"
+#include "G4ParticleChangeForGamma.hh"
+#include "G4LogLogInterpolation.hh"
+#include "G4ProductionCutsTable.hh"
+
+class G4DNAChampionElasticModel : public G4VEmModel
+{
+
+public:
+
+  G4DNAChampionElasticModel(const G4ParticleDefinition* p = 0, 
+		          const G4String& nam = "DNAChampionElasticModel");
+
+  virtual ~G4DNAChampionElasticModel();
+
+  virtual void Initialise(const G4ParticleDefinition*, const G4DataVector&);
+
+  virtual G4double CrossSectionPerVolume(const G4Material* material,
+					   const G4ParticleDefinition* p,
+					   G4double ekin,
+					   G4double emin,
+					   G4double emax);
+
+  virtual void SampleSecondaries(std::vector<G4DynamicParticle*>*,
+				 const G4MaterialCutsCouple*,
+				 const G4DynamicParticle*,
+				 G4double tmin,
+				 G4double maxEnergy);
+
+protected:
+
+  G4ParticleChangeForGamma* fParticleChangeForGamma;
+
+private:
+
+  G4double killBelowEnergy;  
+  G4double lowEnergyLimit;  
+  G4double lowEnergyLimitOfModel;  
+  G4double highEnergyLimit; 
+  G4bool isInitialised;
+  G4int verboseLevel;
+  
+  // Cross section
+  
+  typedef std::map<G4String,G4String,std::less<G4String> > MapFile;
+  MapFile tableFile;
+
+  typedef std::map<G4String,G4DNACrossSectionDataSet*,std::less<G4String> > MapData;
+  MapData tableData;
+  
+  // Final state
+
+  G4double DifferentialCrossSection(G4ParticleDefinition * aParticleDefinition, G4double k, G4double theta);
+
+  G4double LogLogInterpolate(G4double e1, G4double e2, G4double e, G4double xs1, G4double xs2);
+   
+  G4double LinLogInterpolate(G4double e1, G4double e2, G4double e, G4double xs1, G4double xs2);
+   
+  G4double QuadInterpolator(G4double e11, 
+ 		            G4double e12, 
+			    G4double e21, 
+			    G4double e22, 
+			    G4double x11,
+			    G4double x12, 
+			    G4double x21, 
+			    G4double x22, 
+			    G4double t1, 
+			    G4double t2, 
+			    G4double t, 
+			    G4double e);
+
+  typedef std::map<double, std::map<double, double> > TriDimensionMap;
+
+  TriDimensionMap eDiffCrossSectionData;
+  std::vector<double> eTdummyVec;
+
+  typedef std::map<double, std::vector<double> > VecMap;
+  VecMap eVecm;
+   
+  G4double RandomizeCosTheta(G4double k);
+   
+  // Test water material 
+   
+  G4bool flagMaterialIsWater;
+  G4double densityWater;
+   
+  //
+   
+  G4DNAChampionElasticModel & operator=(const  G4DNAChampionElasticModel &right);
+  G4DNAChampionElasticModel(const  G4DNAChampionElasticModel&);
+
+};
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+#endif
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4DNAChargeDecrease.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4DNAChargeDecrease.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4DNAChargeDecrease.hh	(revision 966)
@@ -0,0 +1,86 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4DNAChargeDecrease.hh,v 1.1 2009/01/12 14:26:02 sincerti Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+#ifndef G4DNAChargeDecrease_h
+#define G4DNAChargeDecrease_h 1
+
+#include "G4VEmProcess.hh"
+
+#include "G4DNAGenericIonsManager.hh"
+#include "G4Proton.hh"
+
+// Available models
+#include "G4DNADingfelderChargeDecreaseModel.hh"
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+class G4DNAChargeDecrease : public G4VEmProcess
+
+{
+public: 
+
+  G4DNAChargeDecrease(const G4String& processName ="DNAChargeDecrease",
+		     G4ProcessType type = fElectromagnetic);
+
+  virtual ~G4DNAChargeDecrease();
+
+  G4bool IsApplicable(const G4ParticleDefinition&);
+  
+  virtual void PrintInfo();
+
+protected:
+
+  virtual void InitialiseProcess(const G4ParticleDefinition*);
+
+private:
+     
+  G4bool       isInitialised;
+};
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+inline 
+G4bool G4DNAChargeDecrease::IsApplicable(const G4ParticleDefinition& p)
+{
+
+  G4DNAGenericIonsManager *instance;
+  instance = G4DNAGenericIonsManager::Instance();
+
+  return 
+    (
+       &p == G4Proton::ProtonDefinition()
+    || &p == instance->GetIon("alpha++")
+    || &p == instance->GetIon("alpha+")
+    );
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+  
+#endif
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4DNAChargeIncrease.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4DNAChargeIncrease.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4DNAChargeIncrease.hh	(revision 966)
@@ -0,0 +1,84 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4DNAChargeIncrease.hh,v 1.1 2009/01/12 14:26:02 sincerti Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+#ifndef G4DNAChargeIncrease_h
+#define G4DNAChargeIncrease_h 1
+
+#include "G4VEmProcess.hh"
+#include "G4DNAGenericIonsManager.hh"
+
+// Available models
+#include "G4DNADingfelderChargeIncreaseModel.hh"
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+class G4DNAChargeIncrease : public G4VEmProcess
+
+{
+public: 
+
+  G4DNAChargeIncrease(const G4String& processName ="DNAChargeIncrease",
+		     G4ProcessType type = fElectromagnetic);
+
+  virtual ~G4DNAChargeIncrease();
+
+  G4bool IsApplicable(const G4ParticleDefinition&);
+  
+  virtual void PrintInfo();
+
+protected:
+
+  virtual void InitialiseProcess(const G4ParticleDefinition*);
+
+private:
+     
+  G4bool       isInitialised;
+};
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+inline 
+G4bool G4DNAChargeIncrease::IsApplicable(const G4ParticleDefinition& p)
+{
+
+  G4DNAGenericIonsManager *instance;
+  instance = G4DNAGenericIonsManager::Instance();
+
+  return 
+    (
+       &p == instance->GetIon("hydrogen")
+    || &p == instance->GetIon("alpha+")
+    || &p == instance->GetIon("helium")
+    );
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+  
+#endif
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4DNADingfelderChargeDecreaseModel.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4DNADingfelderChargeDecreaseModel.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4DNADingfelderChargeDecreaseModel.hh	(revision 966)
@@ -0,0 +1,120 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4DNADingfelderChargeDecreaseModel.hh,v 1.1 2009/01/12 14:26:02 sincerti Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+
+#ifndef G4DNADingfelderChargeDecreaseModel_h
+#define G4DNADingfelderChargeDecreaseModel_h 1
+
+#include "G4VEmModel.hh"
+#include "G4ParticleChangeForGamma.hh"
+#include "G4ProductionCutsTable.hh"
+
+#include "G4Proton.hh"
+#include "G4DNAGenericIonsManager.hh"
+
+class G4DNADingfelderChargeDecreaseModel : public G4VEmModel
+{
+
+public:
+
+  G4DNADingfelderChargeDecreaseModel(const G4ParticleDefinition* p = 0, 
+		          const G4String& nam = "DNADingfelderChargeDecreaseModel");
+
+  virtual ~G4DNADingfelderChargeDecreaseModel();
+
+  virtual void Initialise(const G4ParticleDefinition*, const G4DataVector&);
+
+  virtual G4double CrossSectionPerVolume(const G4Material* material,
+					   const G4ParticleDefinition* p,
+					   G4double ekin,
+					   G4double emin,
+					   G4double emax);
+
+  virtual void SampleSecondaries(std::vector<G4DynamicParticle*>*,
+				 const G4MaterialCutsCouple*,
+				 const G4DynamicParticle*,
+				 G4double tmin,
+				 G4double maxEnergy);
+
+protected:
+
+  G4ParticleChangeForGamma* fParticleChangeForGamma;
+
+private:
+
+  std::map<G4String,G4double,std::less<G4String> > lowEnergyLimit;
+  std::map<G4String,G4double,std::less<G4String> > highEnergyLimit;
+
+  G4bool isInitialised;
+  G4int verboseLevel;
+  
+  // Partial cross section
+
+  G4double PartialCrossSection(G4double energy, G4int level, const G4ParticleDefinition* particle);
+
+  G4double Sum(G4double energy, const G4ParticleDefinition* particle);
+
+  G4int RandomSelect(G4double energy, const G4ParticleDefinition* particle);
+  
+  G4int numberOfPartialCrossSections[3]; // 3 is the particle type index
+
+  G4double f0[2][3];
+  G4double a0[2][3];
+  G4double a1[2][3];
+  G4double b0[2][3];
+  G4double b1[2][3];
+  G4double c0[2][3];
+  G4double d0[2][3];
+  G4double x0[2][3];
+  G4double x1[2][3];
+
+  // Final state
+
+  G4int NumberOfFinalStates(G4ParticleDefinition* particleDefinition, G4int finalStateIndex);
+   
+  G4ParticleDefinition* OutgoingParticleDefinition(G4ParticleDefinition* particleDefinition, G4int finalStateIndex);
+   
+  G4double WaterBindingEnergyConstant(G4ParticleDefinition* particleDefinition, G4int finalStateIndex);
+   
+  G4double OutgoingParticleBindingEnergyConstant(G4ParticleDefinition* particleDefinition, G4int finalStateIndex);
+  
+  // Test water material 
+   
+  G4bool flagMaterialIsWater;
+  G4double densityWater;
+   
+  //
+   
+  G4DNADingfelderChargeDecreaseModel & operator=(const  G4DNADingfelderChargeDecreaseModel &right);
+  G4DNADingfelderChargeDecreaseModel(const  G4DNADingfelderChargeDecreaseModel&);
+
+};
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+#endif
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4DNADingfelderChargeIncreaseModel.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4DNADingfelderChargeIncreaseModel.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4DNADingfelderChargeIncreaseModel.hh	(revision 966)
@@ -0,0 +1,123 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4DNADingfelderChargeIncreaseModel.hh,v 1.1 2009/01/12 14:26:02 sincerti Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+
+#ifndef G4DNADingfelderChargeIncreaseModel_h
+#define G4DNADingfelderChargeIncreaseModel_h 1
+
+#include "G4VEmModel.hh"
+#include "G4ParticleChangeForGamma.hh"
+#include "G4ProductionCutsTable.hh"
+
+#include "G4Electron.hh"
+#include "G4Proton.hh"
+#include "G4DNAGenericIonsManager.hh"
+
+class G4DNADingfelderChargeIncreaseModel : public G4VEmModel
+{
+
+public:
+
+  G4DNADingfelderChargeIncreaseModel(const G4ParticleDefinition* p = 0, 
+		          const G4String& nam = "DNADingfelderChargeIncreaseModel");
+
+  virtual ~G4DNADingfelderChargeIncreaseModel();
+
+  virtual void Initialise(const G4ParticleDefinition*, const G4DataVector&);
+
+  virtual G4double CrossSectionPerVolume(const G4Material* material,
+					   const G4ParticleDefinition* p,
+					   G4double ekin,
+					   G4double emin,
+					   G4double emax);
+
+  virtual void SampleSecondaries(std::vector<G4DynamicParticle*>*,
+				 const G4MaterialCutsCouple*,
+				 const G4DynamicParticle*,
+				 G4double tmin,
+				 G4double maxEnergy);
+
+protected:
+
+  G4ParticleChangeForGamma* fParticleChangeForGamma;
+
+private:
+
+  std::map<G4String,G4double,std::less<G4String> > lowEnergyLimit;
+  std::map<G4String,G4double,std::less<G4String> > highEnergyLimit;
+
+  G4bool isInitialised;
+  G4int verboseLevel;
+  
+  // Partial cross section
+
+  G4double PartialCrossSection(G4double energy, G4int level, const G4ParticleDefinition* particle);
+
+  G4double Sum(G4double energy, const G4ParticleDefinition* particle);
+
+  G4int RandomSelect(G4double energy, const G4ParticleDefinition* particle);
+  
+  G4int numberOfPartialCrossSections[2]; // 2 is the particle type index
+
+  G4double f0[2][2];
+  G4double a0[2][2];
+  G4double a1[2][2];
+  G4double b0[2][2];
+  G4double b1[2][2];
+  G4double c0[2][2];
+  G4double d0[2][2];
+  G4double x0[2][2];
+  G4double x1[2][2];
+
+  // Final state
+
+  G4int NumberOfFinalStates(G4ParticleDefinition* particleDefinition, G4int finalStateIndex);
+  
+  G4ParticleDefinition* OutgoingParticleDefinition(G4ParticleDefinition* particleDefinition, G4int finalStateIndex);
+  
+  G4double WaterBindingEnergyConstant(G4ParticleDefinition * aParticleDefinition, G4int finalStateIndex);
+  
+  G4double OutgoingParticleBindingEnergyConstant(G4ParticleDefinition* particleDefinition, G4int finalStateIndex);
+  
+  G4double IncomingParticleBindingEnergyConstant(G4ParticleDefinition* particleDefinition, G4int finalStateIndex);
+  
+  // Test water material 
+   
+  G4bool flagMaterialIsWater;
+  G4double densityWater;
+   
+  //
+   
+  G4DNADingfelderChargeIncreaseModel & operator=(const  G4DNADingfelderChargeIncreaseModel &right);
+  G4DNADingfelderChargeIncreaseModel(const  G4DNADingfelderChargeIncreaseModel&);
+
+};
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+#endif
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4DNAElastic.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4DNAElastic.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4DNAElastic.hh	(revision 966)
@@ -0,0 +1,76 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4DNAElastic.hh,v 1.1 2009/01/12 14:26:02 sincerti Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+#ifndef G4DNAElastic_h
+#define G4DNAElastic_h 1
+
+#include "G4VEmProcess.hh"
+#include "G4Electron.hh"
+
+// Available models
+#include "G4DNAChampionElasticModel.hh"
+#include "G4DNAScreenedRutherfordElasticModel.hh"
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+class G4DNAElastic : public G4VEmProcess
+
+{
+public: 
+
+  G4DNAElastic(const G4String& processName ="DNAElastic",
+		     G4ProcessType type = fElectromagnetic);
+
+  virtual ~G4DNAElastic();
+
+  G4bool IsApplicable(const G4ParticleDefinition&);
+  
+  virtual void PrintInfo();
+
+protected:
+
+  virtual void InitialiseProcess(const G4ParticleDefinition*);
+
+private:
+     
+  G4bool       isInitialised;
+};
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+inline 
+G4bool G4DNAElastic::IsApplicable(const G4ParticleDefinition& p)
+{
+  return (&p == G4Electron::Electron());
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+  
+#endif
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4DNAEmfietzoglouExcitationModel.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4DNAEmfietzoglouExcitationModel.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4DNAEmfietzoglouExcitationModel.hh	(revision 966)
@@ -0,0 +1,105 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4DNAEmfietzoglouExcitationModel.hh,v 1.1 2009/01/12 14:26:02 sincerti Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+
+#ifndef G4DNAEmfietzoglouExcitationModel_h
+#define G4DNAEmfietzoglouExcitationModel_h 1
+
+#include "G4VEmModel.hh"
+#include "G4ParticleChangeForGamma.hh"
+#include "G4ProductionCutsTable.hh"
+
+#include "G4WaterExcitationStructure.hh"
+#include <deque>
+#include "Randomize.hh"
+#include "G4Electron.hh"
+
+class G4DNAEmfietzoglouExcitationModel : public G4VEmModel
+{
+
+public:
+
+  G4DNAEmfietzoglouExcitationModel(const G4ParticleDefinition* p = 0, 
+		          const G4String& nam = "DNAEmfietzoglouExcitationModel");
+
+  virtual ~G4DNAEmfietzoglouExcitationModel();
+
+  virtual void Initialise(const G4ParticleDefinition*, const G4DataVector&);
+
+  virtual G4double CrossSectionPerVolume(const G4Material* material,
+					   const G4ParticleDefinition* p,
+					   G4double ekin,
+					   G4double emin,
+					   G4double emax);
+
+  virtual void SampleSecondaries(std::vector<G4DynamicParticle*>*,
+				 const G4MaterialCutsCouple*,
+				 const G4DynamicParticle*,
+				 G4double tmin,
+				 G4double maxEnergy);
+
+  // Cross section
+
+  G4double PartialCrossSection(G4double energy,G4int level);
+
+protected:
+
+  G4ParticleChangeForGamma* fParticleChangeForGamma;
+
+private:
+
+  G4double lowEnergyLimit;  
+  G4double highEnergyLimit; 
+  G4bool isInitialised;
+  G4int verboseLevel;
+  
+  // Cross section
+
+  G4double Sum(G4double energy);
+
+  G4int RandomSelect(G4double energy);
+  
+  G4int nLevels;
+
+  G4WaterExcitationStructure waterExcitation;
+  
+  // Test water material 
+   
+  G4bool flagMaterialIsWater;
+  G4double densityWater;
+   
+  //
+   
+  G4DNAEmfietzoglouExcitationModel & operator=(const  G4DNAEmfietzoglouExcitationModel &right);
+  G4DNAEmfietzoglouExcitationModel(const  G4DNAEmfietzoglouExcitationModel&);
+
+};
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+#endif
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4DNAExcitation.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4DNAExcitation.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4DNAExcitation.hh	(revision 966)
@@ -0,0 +1,90 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4DNAExcitation.hh,v 1.1 2009/01/12 14:26:02 sincerti Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+#ifndef G4DNAExcitation_h
+#define G4DNAExcitation_h 1
+
+#include "G4VEmProcess.hh"
+
+#include "G4DNAGenericIonsManager.hh"
+#include "G4Electron.hh"
+#include "G4Proton.hh"
+
+// Available models
+#include "G4DNAEmfietzoglouExcitationModel.hh"
+#include "G4DNAMillerGreenExcitationModel.hh"
+#include "G4DNABornExcitationModel.hh"
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+class G4DNAExcitation : public G4VEmProcess
+{
+public: 
+
+  G4DNAExcitation(const G4String& processName ="DNAExcitation",
+		     G4ProcessType type = fElectromagnetic);
+
+  virtual ~G4DNAExcitation();
+
+  G4bool IsApplicable(const G4ParticleDefinition&);
+  
+  virtual void PrintInfo();
+
+protected:
+
+  virtual void InitialiseProcess(const G4ParticleDefinition*);
+
+private:
+     
+  G4bool       isInitialised;
+};
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+inline 
+G4bool G4DNAExcitation::IsApplicable(const G4ParticleDefinition& p)
+{
+
+  G4DNAGenericIonsManager *instance;
+  instance = G4DNAGenericIonsManager::Instance();
+
+  return 
+    (
+       &p == G4Electron::Electron() 
+    || &p == G4Proton::ProtonDefinition()
+    || &p == instance->GetIon("alpha++")
+    || &p == instance->GetIon("alpha+")
+    || &p == instance->GetIon("helium")
+    );
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+  
+#endif
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4DNAIonisation.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4DNAIonisation.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4DNAIonisation.hh	(revision 966)
@@ -0,0 +1,89 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4DNAIonisation.hh,v 1.2 2009/02/14 18:04:30 sincerti Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+#ifndef G4DNAIonisation_h
+#define G4DNAIonisation_h 1
+
+#include "G4VEmProcess.hh"
+#include "G4DNAGenericIonsManager.hh"
+#include "G4Electron.hh"
+#include "G4Proton.hh"
+
+// Available models
+#include "G4DNABornIonisationModel.hh"
+#include "G4DNARuddIonisationModel.hh"
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+class G4DNAIonisation : public G4VEmProcess
+
+{
+public: 
+
+  G4DNAIonisation(const G4String& processName ="DNAIonisation",
+		     G4ProcessType type = fElectromagnetic);
+
+  virtual ~G4DNAIonisation();
+
+  G4bool IsApplicable(const G4ParticleDefinition&);
+  
+  virtual void PrintInfo();
+
+protected:
+
+  virtual void InitialiseProcess(const G4ParticleDefinition*);
+
+private:
+     
+  G4bool       isInitialised;
+};
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+inline 
+G4bool G4DNAIonisation::IsApplicable(const G4ParticleDefinition& p)
+{
+  G4DNAGenericIonsManager *instance;
+  instance = G4DNAGenericIonsManager::Instance();
+
+  return 
+  (
+      &p == G4Electron::Electron() 
+   || &p == G4Proton::Proton() 
+   || &p == instance->GetIon("hydrogen")
+   || &p == instance->GetIon("alpha++")
+   || &p == instance->GetIon("alpha+")
+   || &p == instance->GetIon("helium")
+  );
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+  
+#endif
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4DNAMillerGreenExcitationModel.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4DNAMillerGreenExcitationModel.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4DNAMillerGreenExcitationModel.hh	(revision 966)
@@ -0,0 +1,133 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4DNAMillerGreenExcitationModel.hh,v 1.1 2009/01/12 14:26:03 sincerti Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+
+#ifndef G4DNAMillerGreenExcitationModel_h
+#define G4DNAMillerGreenExcitationModel_h 1
+
+#include "G4VEmModel.hh"
+#include "G4ParticleChangeForGamma.hh"
+#include "G4ProductionCutsTable.hh"
+
+#include "G4Proton.hh"
+#include "G4DNAGenericIonsManager.hh"
+#include "G4DNAEmfietzoglouExcitationModel.hh"
+#include "G4WaterExcitationStructure.hh"
+#include "Randomize.hh"
+
+class G4DNAMillerGreenExcitationModel : public G4VEmModel
+{
+
+public:
+
+  G4DNAMillerGreenExcitationModel(const G4ParticleDefinition* p = 0, 
+		          const G4String& nam = "DNAMillerGreenExcitationModel");
+
+  virtual ~G4DNAMillerGreenExcitationModel();
+
+  virtual void Initialise(const G4ParticleDefinition*, const G4DataVector&);
+
+  virtual G4double CrossSectionPerVolume(const G4Material* material,
+					   const G4ParticleDefinition* p,
+					   G4double ekin,
+					   G4double emin,
+					   G4double emax);
+
+  virtual void SampleSecondaries(std::vector<G4DynamicParticle*>*,
+				 const G4MaterialCutsCouple*,
+				 const G4DynamicParticle*,
+				 G4double tmin,
+				 G4double maxEnergy);
+
+protected:
+
+  G4ParticleChangeForGamma* fParticleChangeForGamma;
+
+private:
+
+  std::map<G4String,G4double,std::less<G4String> > lowEnergyLimit;
+  std::map<G4String,G4double,std::less<G4String> > highEnergyLimit;
+
+  G4bool isInitialised;
+  G4int verboseLevel;
+  
+  // Cross section
+
+  // Partial cross section
+  
+  G4double PartialCrossSection(G4double energy,G4int level, const G4ParticleDefinition* particle);
+
+  G4double Sum(G4double energy, const G4ParticleDefinition* particle);
+
+  G4int RandomSelect(G4double energy, const G4ParticleDefinition* particle);
+
+  G4int nLevels;
+
+  G4WaterExcitationStructure waterExcitation;
+  
+  G4double S_1s(G4double t, 
+		G4double energyTransferred, 
+		G4double slaterEffectiveCharge,
+		G4double shellNumber);
+
+  G4double S_2s(G4double t, 
+		G4double energyTransferred,  
+		G4double slaterEffectiveCharge, 
+		G4double shellNumber);
+
+  G4double S_2p(G4double t, 
+		G4double energyTransferred, 
+		G4double slaterEffectiveCharge, 
+		G4double shellNumber);
+
+  G4double R(G4double t, 
+	     G4double energyTransferred, 
+	     G4double slaterEffectiveCharge, 
+	     G4double shellNumber);
+
+  G4double kineticEnergyCorrection[4]; // 4 is the particle type index
+  G4double slaterEffectiveCharge[3][4];
+  G4double sCoefficient[3][4];
+
+  // Final state
+  
+  // Test water material 
+   
+  G4bool flagMaterialIsWater;
+  G4double densityWater;
+   
+  //
+   
+  G4DNAMillerGreenExcitationModel & operator=(const  G4DNAMillerGreenExcitationModel &right);
+  G4DNAMillerGreenExcitationModel(const  G4DNAMillerGreenExcitationModel&);
+
+};
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+#endif
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4DNARuddIonisationModel.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4DNARuddIonisationModel.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4DNARuddIonisationModel.hh	(revision 966)
@@ -0,0 +1,163 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4DNARuddIonisationModel.hh,v 1.1 2009/01/12 14:26:03 sincerti Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+
+#ifndef G4DNARuddIonisationModel_h
+#define G4DNARuddIonisationModel_h 1
+
+#include "G4VEmModel.hh"
+#include "G4ParticleChangeForGamma.hh"
+#include "G4ProductionCutsTable.hh"
+
+#include "G4DNAGenericIonsManager.hh"
+#include "G4DNACrossSectionDataSet.hh"
+#include "G4Electron.hh"
+#include "G4Proton.hh"
+#include "G4LogLogInterpolation.hh"
+
+#include "G4WaterIonisationStructure.hh"
+
+class G4DNARuddIonisationModel : public G4VEmModel
+{
+
+public:
+
+  G4DNARuddIonisationModel(const G4ParticleDefinition* p = 0, 
+		           const G4String& nam = "DNARuddIonisationModel");
+
+  virtual ~G4DNARuddIonisationModel();
+
+  virtual void Initialise(const G4ParticleDefinition*, const G4DataVector&);
+
+  virtual G4double CrossSectionPerVolume(  const G4Material* material,
+					   const G4ParticleDefinition* p,
+					   G4double ekin,
+					   G4double emin,
+					   G4double emax);
+
+  virtual void SampleSecondaries(std::vector<G4DynamicParticle*>*,
+				 const G4MaterialCutsCouple*,
+				 const G4DynamicParticle*,
+				 G4double tmin,
+				 G4double maxEnergy);
+
+protected:
+
+  G4ParticleChangeForGamma* fParticleChangeForGamma;
+
+private:
+
+  std::map<G4String,G4double,std::less<G4String> > lowEnergyLimit;
+  std::map<G4String,G4double,std::less<G4String> > highEnergyLimit;
+
+  G4double lowEnergyLimitForZ1; 
+  G4double lowEnergyLimitForZ2; 
+  G4double lowEnergyLimitOfModelForZ1; 
+  G4double lowEnergyLimitOfModelForZ2; 
+  G4double killBelowEnergyForZ1; 
+  G4double killBelowEnergyForZ2; 
+
+  G4bool isInitialised;
+  G4int verboseLevel;
+  
+  // Cross section
+
+  typedef std::map<G4String,G4String,std::less<G4String> > MapFile;
+  MapFile tableFile;
+
+  typedef std::map<G4String,G4DNACrossSectionDataSet*,std::less<G4String> > MapData;
+  MapData tableData;
+  
+  // Final state
+  
+  G4WaterIonisationStructure waterStructure;
+
+  G4double RandomizeEjectedElectronEnergy(G4ParticleDefinition* particleDefinition, 
+					  G4double incomingParticleEnergy, 
+					  G4int shell);
+
+  void RandomizeEjectedElectronDirection(G4ParticleDefinition* particleDefinition, 
+					 G4double incomingParticleEnergy, 
+					 G4double outgoingParticleEnergy, 
+					 G4double & cosTheta, 
+					 G4double & phi);
+   
+  G4double  DifferentialCrossSection(G4ParticleDefinition* particleDefinition, 
+				   G4double k, 
+				   G4double energyTransfer, 
+				   G4int shell);
+
+  G4double CorrectionFactor(G4ParticleDefinition* particleDefinition, G4double k);
+
+  G4double S_1s(G4double t, 
+		G4double energyTransferred, 
+		G4double slaterEffectiveChg, 
+		G4double shellNumber);
+
+  G4double S_2s(G4double t, 
+		G4double energyTransferred, 
+		G4double slaterEffectiveChg, 
+		G4double shellNumber);
+
+
+  G4double S_2p(G4double t, 
+		G4double energyTransferred, 
+		G4double slaterEffectiveChg, 
+		G4double shellNumber);
+
+  G4double R(G4double t, 
+	     G4double energyTransferred, 
+	     G4double slaterEffectiveChg, 
+	     G4double shellNumber) ;
+
+  G4double slaterEffectiveCharge[3];
+  G4double sCoefficient[3];
+  
+  // Partial cross section
+  
+  G4double PartialCrossSection(const G4Track& track);
+			
+  G4double Sum(G4double energy, const G4String& particle);
+
+  G4int RandomSelect(G4double energy,const G4String& particle );
+  
+  // Test water material 
+   
+  G4bool flagMaterialIsWater;
+  G4double densityWater;
+   
+  //
+   
+  G4DNARuddIonisationModel & operator=(const  G4DNARuddIonisationModel &right);
+  G4DNARuddIonisationModel(const  G4DNARuddIonisationModel&);
+
+};
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+#endif
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4DNAScreenedRutherfordElasticModel.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4DNAScreenedRutherfordElasticModel.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4DNAScreenedRutherfordElasticModel.hh	(revision 966)
@@ -0,0 +1,109 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4DNAScreenedRutherfordElasticModel.hh,v 1.1 2009/01/12 14:26:03 sincerti Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+
+#ifndef G4DNAScreenedRutherfordElasticModel_h
+#define G4DNAScreenedRutherfordElasticModel_h 1
+
+#include "G4VEmModel.hh"
+#include "G4ParticleChangeForGamma.hh"
+#include "G4ProductionCutsTable.hh"
+
+class G4DNAScreenedRutherfordElasticModel : public G4VEmModel
+{
+
+public:
+
+  G4DNAScreenedRutherfordElasticModel(const G4ParticleDefinition* p = 0, 
+		          const G4String& nam = "DNAScreenedRutherfordElasticModel");
+
+  virtual ~G4DNAScreenedRutherfordElasticModel();
+
+  virtual void Initialise(const G4ParticleDefinition*, const G4DataVector&);
+
+  virtual G4double CrossSectionPerVolume(const G4Material* material,
+					   const G4ParticleDefinition* p,
+					   G4double ekin,
+					   G4double emin,
+					   G4double emax);
+
+  virtual void SampleSecondaries(std::vector<G4DynamicParticle*>*,
+				 const G4MaterialCutsCouple*,
+				 const G4DynamicParticle*,
+				 G4double tmin,
+				 G4double maxEnergy);
+
+protected:
+
+  G4ParticleChangeForGamma* fParticleChangeForGamma;
+
+private:
+
+  G4double killBelowEnergy;  
+  G4double lowEnergyLimit;  
+  G4double lowEnergyLimitOfModel;  
+  G4double intermediateEnergyLimit; 
+  G4double highEnergyLimit; 
+  G4bool isInitialised;
+  G4int verboseLevel;
+  
+  // Cross section
+  
+  G4double RutherfordCrossSection(G4double energy, G4double z);
+  
+  G4double ScreeningFactor(G4double energy, G4double z);
+  
+  // Final state according to Brenner & Zaider
+
+  G4double BrennerZaiderRandomizeCosTheta(G4double k);
+  G4double CalculatePolynomial(G4double k, std::vector<G4double>& vec);
+  std::vector<G4double> betaCoeff;
+  std::vector<G4double> deltaCoeff;
+  std::vector<G4double> gamma035_10Coeff;
+  std::vector<G4double> gamma10_100Coeff;
+  std::vector<G4double> gamma100_200Coeff;
+   
+  // Final state according to Screened Rutherford
+
+  G4double ScreenedRutherfordRandomizeCosTheta(G4double k, G4double z);
+
+  // Test water material 
+   
+  G4bool flagMaterialIsWater;
+  G4double densityWater;
+   
+  //
+   
+  G4DNAScreenedRutherfordElasticModel & operator=(const  G4DNAScreenedRutherfordElasticModel &right);
+  G4DNAScreenedRutherfordElasticModel(const  G4DNAScreenedRutherfordElasticModel&);
+
+};
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+#endif
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4DopplerProfile.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4DopplerProfile.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4DopplerProfile.hh	(revision 966)
@@ -0,0 +1,101 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G4DopplerProfile.hh,v 1.2 2008/03/17 13:45:25 pia Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+// Author: Maria Grazia Pia (Maria.Grazia.Pia@cern.ch)
+//
+// History:
+// -----------
+//  6 Aug 2001   MGP        Created
+//
+// -------------------------------------------------------------------
+
+// Class description:
+// Low Energy Electromagnetic Physics
+// Shell data set: shell identifiers and binding energies
+
+// -------------------------------------------------------------------
+
+#ifndef G4DOPPLERPROFILE_HH
+#define G4DOPPLERPROFILE_HH 1
+
+#include "globals.hh"
+#include <vector>
+#include <map>
+
+class G4VEMDataSet;
+
+class G4DopplerProfile 
+{ 
+public:
+
+  G4DopplerProfile(G4int minZ = 1, G4int maxZ = 100);
+
+  ~G4DopplerProfile();
+ 
+  size_t NumberOfProfiles(G4int Z) const;
+
+  const G4VEMDataSet* Profiles(G4int Z) const;
+  const G4VEMDataSet* Profile(G4int Z, G4int ShellIndex) const;
+
+   void PrintData() const;
+
+  // Random select a momentum value based on Doppler profiles
+  G4double RandomSelectMomentum(G4int Z, G4int shellIndex) const;
+ 
+private:
+
+  // Hide copy constructor and assignment operator 
+  G4DopplerProfile& operator=(const G4DopplerProfile& right);
+  G4DopplerProfile(const G4DopplerProfile&);
+
+  std::map<G4int,G4VEMDataSet*,std::less<G4int> > profileMap;
+  std::vector<G4int> nShells;
+
+  G4int zMin;
+  G4int zMax; 
+  
+  size_t nBiggs;
+
+  std::vector<G4double> biggsP;
+
+  void LoadBiggsP(const G4String& fileName);
+  void LoadProfile(const G4String& fileName, G4int Z);
+
+};
+ 
+#endif
+
+
+
+
+
+
+
+
+
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4FinalStateChargeTransferProton.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4FinalStateChargeTransferProton.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4FinalStateChargeTransferProton.hh	(revision 966)
@@ -0,0 +1,87 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G4FinalStateChargeTransferProton.hh,v 1.2 2008/03/25 16:00:20 pia Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+// 
+// Contact Author: Maria Grazia Pia (Maria.Grazia.Pia@cern.ch)
+//
+// History:
+// -----------
+// Date         Name              Modification
+// 28 Apr 2007  M.G. Pia          Created in compliance with design described in TNS paper
+//
+// -------------------------------------------------------------------
+
+// Class description:
+// Final state policy class for proton charge transfer
+// Reference for policy-based design:
+// S. Chauvie et al., Geant4 physics processes for microdosimetry simulation:
+// design foundation and implementation of the first set of models,
+// IEEE Trans. Nucl. Sci., vol. 54, no. 6, Dec. 2007.
+// Reference for implementation:
+// http://www-pub.iaea.org/MTCD/publications/PDF/APID-VOL10.pdf 
+// Further documentation available from http://www.ge.infn.it/geant4/
+
+// -------------------------------------------------------------------
+
+
+#ifndef G4FINALSTATECHARGETRANSFERCH_HH
+#define G4FINALSTATECHARGETRANSFERCH_HH 1
+ 
+#include "globals.hh"
+#include "G4FinalStateProduct.hh"
+#include <map>
+
+class G4Track;
+class G4Step;
+
+ class G4FinalStateChargeTransferProton
+ {
+ public:
+   
+   G4FinalStateChargeTransferProton();
+   
+   ~G4FinalStateChargeTransferProton();
+   
+   const G4FinalStateProduct& GenerateFinalState(const G4Track& track, const G4Step& step);
+   
+ private:
+   
+   // Copy constructor and assignment operator to be added here
+   
+   G4String name;  
+   G4double lowEnergyLimit;
+   G4double highEnergyLimit;
+   G4FinalStateProduct product;
+  
+   G4double protonBinding;
+
+   std::map<G4String,G4double,std::less<G4String> > ioniPotentialMap;
+};
+
+
+#endif
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4FinalStateElasticChampion.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4FinalStateElasticChampion.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4FinalStateElasticChampion.hh	(revision 966)
@@ -0,0 +1,82 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4FinalStateElasticChampion.hh,v 1.1 2008/07/15 19:56:50 sincerti Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+// -------------------------------------------------------------------
+
+#ifndef G4FINALSTATEELASTICCHAMPION_HH
+#define G4FINALSTATEELASTICCHAMPION_HH 1
+
+#include "Randomize.hh"
+#include "G4Electron.hh"
+#include "G4FinalStateProduct.hh"
+
+class G4FinalStateElasticChampion
+{
+ public:
+   
+   G4FinalStateElasticChampion();
+   
+   ~G4FinalStateElasticChampion();
+   
+   const G4FinalStateProduct& GenerateFinalState(const G4Track& track, const G4Step& step);
+   
+ private:
+   
+   G4double lowEnergyLimit;
+   G4double highEnergyLimit;
+   
+   G4FinalStateProduct product;
+
+   G4double DifferentialCrossSection(G4ParticleDefinition * aParticleDefinition, G4double k, G4double theta);
+
+   G4double LogLogInterpolate(G4double e1, G4double e2, G4double e, G4double xs1, G4double xs2);
+   
+   G4double LinLogInterpolate(G4double e1, G4double e2, G4double e, G4double xs1, G4double xs2);
+   
+   G4double QuadInterpolator(G4double e11, 
+			     G4double e12, 
+			     G4double e21, 
+			     G4double e22, 
+			     G4double x11,
+			     G4double x12, 
+			     G4double x21, 
+			     G4double x22, 
+			     G4double t1, 
+			     G4double t2, 
+			     G4double t, 
+			     G4double e);
+
+   typedef std::map<double, std::map<double, double> > TriDimensionMap;
+   TriDimensionMap eDiffCrossSectionData[6];
+   std::vector<double> eTdummyVec;
+
+   typedef std::map<double, std::vector<double> > VecMap;
+   VecMap eVecm;
+   
+   G4double RandomizeCosTheta(G4double k);
+};
+#endif
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4FinalStatePsCreationChampion.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4FinalStatePsCreationChampion.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4FinalStatePsCreationChampion.hh	(revision 966)
@@ -0,0 +1,65 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4FinalStatePsCreationChampion.hh,v 1.1 2008/07/16 19:01:07 sincerti Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+// -------------------------------------------------------------------
+
+
+#ifndef G4FINALSTATEPSCREATIONCHAMPION_HH
+#define G4FINALSTATEPSCREATIONCHAMPION_HH 1
+ 
+#include "G4FinalStateProduct.hh"
+#include "G4WaterIonisationStructure.hh"
+#include "G4CrossSectionPsCreationChampionPartial.hh"
+#include "G4DNAGenericIonsManager.hh"
+
+class G4Track;
+class G4Step;
+class G4ParticleDefinition;
+
+class G4FinalStatePsCreationChampion
+{
+public:
+   
+  G4FinalStatePsCreationChampion();
+   
+  ~G4FinalStatePsCreationChampion();
+   
+  const G4FinalStateProduct& GenerateFinalState(const G4Track& track, const G4Step& step);
+   
+private:
+
+  G4String name;  
+  G4double lowEnergyLimit;
+  G4double highEnergyLimit;
+
+  G4FinalStateProduct product;
+
+  G4WaterIonisationStructure waterStructure;
+
+  G4CrossSectionPsCreationChampionPartial cross;
+};
+#endif
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4IonParametrisedLossModel.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4IonParametrisedLossModel.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4IonParametrisedLossModel.hh	(revision 966)
@@ -0,0 +1,335 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+//
+// ===========================================================================
+// GEANT4 class header file
+//
+// Class:                G4IonParametrisedLossModel
+//
+// Base class:           G4VEmModel (utils)
+// 
+// Author:               Anton Lechner (Anton.Lechner@cern.ch)
+//
+// First implementation: 10. 11. 2008
+//
+// Modifications: 03. 02. 2009 - Bug fix iterators (AL)
+//
+//
+// Class description:
+//    Model for computing the energy loss of ions by employing a 
+//    parameterisation of dE/dx tables (default ICRU 73 tables). For 
+//    ion-material combinations and/or projectile energies not covered 
+//    by this model, the G4BraggIonModel and G4BetheBloch models are
+//    employed.
+//
+// Comments:
+//
+// =========================================================================== 
+
+
+#ifndef G4IONPARAMETRISEDLOSSMODEL_HH
+#define G4IONPARAMETRISEDLOSSMODEL_HH
+
+#include "G4VEmModel.hh"
+#include "G4EmCorrections.hh"
+#include "G4IonParametrisedLossTable.hh"
+#include "G4EmCorrections.hh"
+#include <iomanip>
+#include <list>
+#include <map>
+#include <utility>
+
+class G4BraggIonModel;
+class G4BetheBlochModel;
+class G4ParticleChangeForLoss;
+
+typedef std::list<G4IonLossTableHandle*> LossTableList;
+typedef std::pair<const G4ParticleDefinition*, const G4Material*> IonMatCouple;
+
+
+class G4IonParametrisedLossModel : public G4VEmModel {
+
+ public:
+   G4IonParametrisedLossModel(const G4ParticleDefinition* particle = 0,
+                              const G4String& name = "ParamICRU73");
+
+   virtual ~G4IonParametrisedLossModel();
+
+   virtual void Initialise(
+                           const G4ParticleDefinition*, // Projectile
+                           const G4DataVector&); // Cut energies
+
+   virtual G4double MinEnergyCut(
+                                 const G4ParticleDefinition*,  // Projectile
+		        	 const G4MaterialCutsCouple*);
+
+   virtual G4double ComputeCrossSectionPerAtom(
+                                 const G4ParticleDefinition*, // Projectile
+				 G4double,  // Kinetic energy of projectile
+				 G4double,  // Atomic number
+                                 G4double,  // Mass number
+				 G4double,  // Energy cut for secondary prod.
+				 G4double); // Maximum energy of secondaries
+				 				 
+   virtual G4double CrossSectionPerVolume(
+                                 const G4Material*,  // Target material
+				 const G4ParticleDefinition*, // Projectile
+				 G4double,  // Kinetic energy
+				 G4double,  // Energy cut for secondary prod.
+				 G4double); // Maximum energy of secondaries
+				 
+   virtual G4double ComputeDEDXPerVolume(
+                                 const G4Material*, // Target material
+				 const G4ParticleDefinition*, // Projectile
+				 G4double,  // Kinetic energy of projectile
+				 G4double); // Energy cut for secondary prod.
+
+   // Function, which computes the continuous energy loss (due to electronic
+   // stopping) for a given pre-step energy and step length by using
+   // range vs energy (and energy vs range) tables  
+   G4double ComputeLossForStep(
+                                 const G4Material*, // Target material
+				 const G4ParticleDefinition*, // Projectile
+				 G4double,  // Kinetic energy of projectile
+                                 G4double,  // Energy cut for secondary prod.
+				 G4double); // Length of current step
+
+   // Function, which computes the mean energy transfer rate to delta rays 
+   G4double DeltaRayMeanEnergyTransferRate(
+                                 const G4Material*, // Target Material
+			         const G4ParticleDefinition*, // Projectile
+				 G4double,  // Kinetic energy of projectile
+				 G4double); // Energy cut for secondary prod.
+
+
+   virtual void SampleSecondaries(std::vector<G4DynamicParticle*>*,
+				 const G4MaterialCutsCouple*,
+				 const G4DynamicParticle*,
+				 G4double,  // Energy cut for secondary prod.
+                                 G4double); // Maximum energy of secondaries
+
+   virtual G4double GetChargeSquareRatio(
+                                 const G4ParticleDefinition*, // Projectile
+		 	 	 const G4Material*,  // Target Material
+				 G4double); // Kinetic energy of projectile
+
+   virtual G4double GetParticleCharge(
+                                 const G4ParticleDefinition*, // Projectile
+				 const G4Material*,  // Target Material
+				 G4double); // Kinetic energy of projectile 
+
+   virtual void CorrectionsAlongStep(
+                                 const G4MaterialCutsCouple*,// Mat.-Cut couple
+				 const G4DynamicParticle*,  // Dyn. particle
+				 G4double&, // Energy loss in current step
+				 G4double&, 
+				 G4double); // Length of current step
+
+
+   // Template function which allows to add additional stopping power tables
+   // in combination with a scaling algorithm, which may depend on dynamic
+   // information like the current particle energy (the table and scaling 
+   // algorithm are used via a wrapper class, which performs e.g.caching or
+   // which applies the scaling of energy and dE/dx values)
+   template <class TABLE, class SCALING_ALGO>
+   void AddDEDXTable() {
+       G4IonLossTableHandle* table =
+               new G4IonParametrisedLossTable<TABLE, SCALING_ALGO>;      
+ 
+       lossTableList.push_front(table);
+   }
+
+   // Template function which allows to add additional stopping power tables
+   // (the table itself is used via a wrapper class, which performs e.g.
+   // caching)
+   template <class TABLE>
+   void AddDEDXTable() {
+       G4IonLossTableHandle* table =
+               new G4IonParametrisedLossTable<TABLE>;      
+ 
+       lossTableList.push_front(table);
+   }
+
+   // Function checking the applicability of physics tables to ion-material
+   // combinations (Note: the energy range of tables is not checked)
+   LossTableList::iterator IsApplicable(
+                      const G4ParticleDefinition*,  // Projectile (ion) 
+                      const G4Material*);           // Target material
+
+   // Function printing a dE/dx table for a given ion-material combination
+   // and a specified energy grid 
+   void PrintDEDXTable(
+                      const G4ParticleDefinition*,  // Projectile (ion) 
+                      const G4Material*, // Absorber material
+                      G4double,          // Minimum energy per nucleon
+                      G4double,          // Maximum energy per nucleon
+                      G4int,             // Number of bins
+                      G4bool);           // Logarithmic scaling of energy
+   
+ protected:
+   G4double MaxSecondaryEnergy(const G4ParticleDefinition*,
+			       G4double);   // Kinetic energy of projectile
+
+ private:
+   // Function which updates parameters concerning the dE/dx calculation
+   // (the parameters are only updated if the particle, the material or 
+   // the associated energy cut has changed)
+   void UpdateDEDXCache(
+                  const G4ParticleDefinition*,   // Projectile (ion) 
+                  const G4Material*,             // Target material
+                  G4double cutEnergy);           // Energy cut
+
+   // Function, which updates parameters concering particle properties
+   void UpdateCache(
+                  const G4ParticleDefinition*);  // Projectile (ion) 
+ 
+   // Function, which builds range vs energy (and energy vs range) vectors
+   // for a given particle, material and energy cut   
+   void BuildRangeVector(
+                  const G4ParticleDefinition*,   // Projectile (ion) 
+                  const G4Material*,             // Target material
+                  G4double);                     // Energy cut
+
+   // Assignment operator and copy constructor are hidden:
+   G4IonParametrisedLossModel & operator=(
+                              const G4IonParametrisedLossModel &right);
+   G4IonParametrisedLossModel(const G4IonParametrisedLossModel &);
+   
+   // ######################################################################
+   // # Models and dE/dx tables for computing the energy loss 
+   // # 
+   // ######################################################################
+
+   // G4BraggIonModel and G4BetheBlochModel are used for ion-target
+   // combinations and/or projectile energies not covered by parametrisations
+   // adopted by this model:
+   G4BraggIonModel* braggIonModel;
+   G4BetheBlochModel* betheBlochModel;
+
+   // List of dE/dx tables plugged into the model
+   LossTableList lossTableList;
+
+   // ######################################################################
+   // # Maps of Range vs Energy and Energy vs Range vectors
+   // # 
+   // ######################################################################
+
+   typedef std::map<IonMatCouple, G4LPhysicsFreeVector*> RangeEnergyTable; 
+   RangeEnergyTable r;
+
+   typedef std::map<IonMatCouple, G4LPhysicsFreeVector*> EnergyRangeTable; 
+   EnergyRangeTable E;
+
+   // ######################################################################
+   // # Energy grid definitions (e.g. used for computing range-energy 
+   // # tables)
+   // ######################################################################
+
+   G4double lowerEnergyEdgeIntegr;
+   G4double upperEnergyEdgeIntegr;
+
+   size_t nmbBins;
+   size_t nmbSubBins;
+
+   // ######################################################################
+   // # Particle change for loss
+   // # 
+   // ######################################################################
+
+   // Pointer to particle change object, which is used to set e.g. the
+   // energy loss due to nuclear stopping
+   G4ParticleChangeForLoss* particleChangeLoss;
+
+   // Flag indicating if model is initialized (i.e. if 
+   // G4ParticleChangeForLoss was created)
+   G4bool modelIsInitialised;
+
+   // ######################################################################
+   // # Corrections and energy loss limit
+   // # 
+   // ######################################################################
+   
+   // Pointer to an G4EmCorrections object, which is used to compute the
+   // effective ion charge, and other corrections (like high order corrections
+   // to stopping powers) 
+   G4EmCorrections* corrections;
+
+   // Corrections factor for effective charge, computed for each particle
+   // step
+   G4double corrFactor;
+
+   // Parameter indicating the maximal fraction of kinetic energy, which
+   // a particle may loose along a step, in order that the simple relation
+   // (dE/dx)*l can still be applied to compute the energy loss (l = step 
+   // length)
+   G4double energyLossLimit;
+
+   // ######################################################################
+   // # Cut energies and properties of generic ion
+   // # 
+   // ######################################################################
+
+   // Vector containing the current cut energies (the vector index matches
+   // the material-cuts couple index):
+   G4DataVector cutEnergies;
+
+   // Pointer to generic ion and mass of generic ion
+   G4ParticleDefinition* genericIon;
+   G4double genericIonPDGMass;
+
+   // ######################################################################
+   // # "Most-recently-used" cache parameters
+   // #
+   // ######################################################################
+
+   // Cached key (particle) and value information for a faster 
+   // access of particle-related information
+   const G4ParticleDefinition* cacheParticle; // Key: Current projectile
+   G4double cacheMass;                        // Projectile mass
+   G4double cacheElecMassRatio;               // Electron-mass ratio
+   G4double cacheChargeSquare;                // Charge squared
+
+   // Cached parameters needed during dE/dx computations:
+   const G4ParticleDefinition* dedxCacheParticle; // Key: 1) Current ion,
+   const G4Material* dedxCacheMaterial;           //      2) material and
+   G4double dedxCacheEnergyCut;                   //      3) cut energy 
+   LossTableList::iterator dedxCacheIter;         // Responsible dE/dx table
+   G4PhysicsVector* dedxCacheEnergyRange;         // Energy vs range vector
+   G4PhysicsVector* dedxCacheRangeEnergy;         // Range vs energy vector
+   G4double dedxCacheTransitionEnergy;      // Transition energy between
+                                            // parameterization and 
+                                            // Bethe-Bloch model
+   G4double dedxCacheTransitionFactor;      // Factor for smoothing the dE/dx
+                                            // values in the transition region
+   G4double dedxCacheGenIonMassRatio;       // Ratio of generic ion mass       
+                                            // and current particle mass
+};
+
+
+#include "G4IonParametrisedLossModel.icc"
+
+#endif
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4IonParametrisedLossTable.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4IonParametrisedLossTable.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4IonParametrisedLossTable.hh	(revision 966)
@@ -0,0 +1,273 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+//
+// ===========================================================================
+// GEANT4 class header file
+//
+// Class:                G4IonParametrisedLossTable
+// Helper classes:       G4IonLossTableHandle
+//                       G4DummyScalingAlgorithm
+// 
+// Author:               Anton Lechner (Anton.Lechner@cern.ch)
+//
+// First implementation: 10. 11. 2008
+//
+// Modifications:
+//
+//
+// Class descriptions:
+//    G4IonParametrisedLossTable: Wrapper class for classes of the material
+//    category, which maintain stopping power vectors for ions. This wrapper
+//    class includes a cache for faster access of stopping powers and builds 
+//    stopping power vectors for compounds using Bragg's additivity rule. 
+//    G4IonLossTableHandle: A handle class for G4IonParametrisedLossTable
+//    G4DummyScalingAlgorithm: A dummy algorithm to scale energies and
+//    stopping powers (may be replaced with an algorithm, which relies on 
+//    dynamic information of the particle: This may be required if stopping
+//    power data is scaled using an effective charge approximation).
+//
+// Comments:
+//
+// =========================================================================== 
+
+
+#ifndef G4IONPARAMETRISEDLOSSTABLE_HH
+#define G4IONPARAMETRISEDLOSSTABLE_HH
+
+#include "globals.hh"
+#include "G4hIonEffChargeSquare.hh"
+#include "G4ParticleDefinition.hh"
+#include "G4Material.hh"
+#include "G4LPhysicsFreeVector.hh"
+#include <vector>
+#include <iomanip>
+#include <map>
+#include <list>
+#include <utility>
+
+
+// #########################################################################
+// # Type definitions for a local cache
+// # 
+// #########################################################################
+
+   typedef std::pair<const G4ParticleDefinition*, const G4Material*> G4CacheKey;
+
+   typedef struct CacheValue{
+      G4double energyScaling;         // Scaling factor for kinetic energy
+      G4PhysicsVector* dedx;          // dEdx vector for current projectile-
+                                      // material combination
+      G4int dEdxIndex;                // dE/dx vector index
+   } G4CacheValue;
+
+
+// #########################################################################
+// # Class G4IonLossTableHandle: Handle for table wrappers (to enable
+// # vectors of table wrappers)   
+// #########################################################################
+
+class G4IonLossTableHandle {
+  
+ public:
+   G4IonLossTableHandle() { }
+   virtual ~G4IonLossTableHandle() { }
+
+   virtual G4double GetLowerEnergyEdge(
+              const G4ParticleDefinition*,  // Projectile (ion) 
+              const G4Material*             // Target material 
+	     ) = 0;
+   virtual G4double GetUpperEnergyEdge(
+              const G4ParticleDefinition*,  // Projectile (ion) 
+              const G4Material*             // Target material 
+	     ) = 0; 
+   virtual G4bool IsApplicable(
+              const G4ParticleDefinition*,  // Projectile (ion) 
+              const G4Material*             // Target material 
+             ) = 0; 
+   virtual G4bool IsApplicable(
+              const G4ParticleDefinition*,  // Projectile (ion) 
+              const G4Material*,            // Target material 
+              G4double                      // Kinetic energy of projectile
+             ) = 0; 
+   virtual G4double GetDEDX(
+              const G4ParticleDefinition*,  // Projectile (ion) 
+              const G4Material*,            // Target material 
+              G4double                      // Kinetic energy of projectile
+             ) = 0; 
+   virtual void ClearCache() { }
+};
+
+
+// #########################################################################
+// # Class G4DummyScalingAlgorithm:
+// #########################################################################
+
+class G4DummyScalingAlgorithm {
+
+ public:
+  // No scaling for kinetic energy
+  inline G4double ScalingFactorEnergy(
+            const G4ParticleDefinition*)    // Projectile (ion) 
+                { return 1.0; }
+
+  // No scaling for dE/dx
+  inline G4double ScalingFactorDEDX(
+            const G4ParticleDefinition*,    // Projectile (ion) 
+            const G4Material*,              // Target material
+            G4double)                       // Kinetic energy of projectile 
+                { return 1.0; }
+};
+
+
+// #########################################################################
+// # Class G4IonParametrisedLossTable: Wrapper for classes of the material
+// # category, which maintain ion stopping power vectors
+// #########################################################################
+
+template <
+    class LossTabulation,
+    class ScalingAlgorithm = G4DummyScalingAlgorithm
+>
+class G4IonParametrisedLossTable : public G4IonLossTableHandle,
+                                   public LossTabulation, 
+                                   public ScalingAlgorithm {
+
+ public:
+   G4IonParametrisedLossTable(G4int maxSizeCache = 5,
+                              G4bool splines = true);
+   ~G4IonParametrisedLossTable();
+
+   // Function checking the availability of stopping power values for a 
+   // given ion-target combination and a given kinetic energy 
+   G4bool IsApplicable(
+              const G4ParticleDefinition*,  // Projectile (ion) 
+              const G4Material*,            // Target material 
+              G4double);                    // Kinetic energy of projectile
+
+   // Function checking the availability of stopping power values for a 
+   // given ion-target combination (kinetic energy not considered) 
+   G4bool IsApplicable(
+              const G4ParticleDefinition*,  // Projectile (ion) 
+              const G4Material*);           // Target material             
+
+   // Function returning the stopping power of a given material for a
+   // projectile of specified energy
+   G4double GetDEDX(
+              const G4ParticleDefinition*,  // Projectile (ion) 
+              const G4Material*,            // Target material 
+              G4double);                    // Kinetic energy of projectile
+
+   // Function printing stopping powers for a given ion-material combination
+   // within a specified energy range 
+   void PrintDEDXTable(
+              const G4ParticleDefinition*,  // Projectile (ion) 
+              const G4Material* ,           // Target material
+              G4double,                     // Minimum energy per nucleon
+              G4double,                     // Maximum energy per nucleon
+              G4int,                        // Number of bins
+              G4bool logScaleEnergy = true);// Logarithmic scaling of energy
+
+   // Function returning the lower energy edge of stopping power tables
+   G4double GetLowerEnergyEdge(
+              const G4ParticleDefinition*,  // Projectile (ion) 
+              const G4Material*);           // Target material 
+
+   // Function returning the upper energy edge of stopping power tables 
+   G4double GetUpperEnergyEdge(
+              const G4ParticleDefinition*,  // Projectile (ion) 
+              const G4Material*);           // Target material 
+ 
+ private: 
+
+   // Function for building stopping power vectors according to Bragg's
+   // additivity rule
+   G4PhysicsVector* BuildStoppingPowerVector(
+              const G4ParticleDefinition*,  // Projectile (ion) 
+              const G4Material*);           // Target material 
+
+   // The assignment operator and the copy constructor are hidden
+   G4IonParametrisedLossTable& operator=(const 
+                                           G4IonParametrisedLossTable &right);
+   G4IonParametrisedLossTable(const G4IonParametrisedLossTable&);
+
+   // ######################################################################
+   // # "Most-recently-used" cache, to provide a faster access to physics 
+   // # vectors
+   // ######################################################################
+
+   // A type definition of cache entry containing a key-value pair
+   typedef struct CacheEntry {
+      G4CacheKey key;
+      G4CacheValue value;
+   } G4CacheEntry;
+
+   // A cache entry list, and a map of pointers to list iterators (for faster
+   // searching)
+   typedef std::list<G4CacheEntry> CacheEntryList;
+   CacheEntryList cacheEntries;
+
+   typedef std::map<G4CacheKey, void*> CacheIterPointerMap;
+   CacheIterPointerMap cacheKeyPointers;  
+
+   // Maximum number of cache entries
+   G4int maxCacheEntries;
+
+   // Function for updating the cache
+   G4CacheValue UpdateCacheValue(
+                const G4ParticleDefinition*,  // Projectile (ion) 
+                const G4Material*);           // Target material
+
+   // Function for retrieving cache values
+   G4CacheValue GetCacheValue(
+                const G4ParticleDefinition*,  // Projectile (ion) 
+                const G4Material*);           // Target material
+
+   // Function for clearing the cache
+   void ClearCache();
+
+   // ######################################################################
+   // # Map of stopping power vectors computed according Bragg rule
+   // #
+   // ######################################################################
+
+   typedef std::map<G4CacheKey, G4LPhysicsFreeVector*> StoppingPowerTable; 
+   StoppingPowerTable s;
+
+   // Flag indicating the usage of splines
+   G4bool useSplines;
+
+   // ######################################################################
+   // # Energy boundaries of physics tables
+   // ######################################################################
+
+   G4double lowerEnergyEdge;
+   G4double upperEnergyEdge;
+};
+
+#include "G4IonParametrisedLossTable.icc"
+
+#endif  // G4IONPARAMETRISEDLOSSTABLE_HH
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4LivermoreComptonModel.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4LivermoreComptonModel.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4LivermoreComptonModel.hh	(revision 966)
@@ -0,0 +1,96 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4LivermoreComptonModel.hh,v 1.1 2008/10/30 14:16:34 sincerti Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+
+#ifndef G4LivermoreComptonModel_h
+#define G4LivermoreComptonModel_h 1
+
+#include "G4VEmModel.hh"
+#include "G4Electron.hh"
+#include "G4ParticleChangeForGamma.hh"
+#include "G4CrossSectionHandler.hh"
+#include "G4LogLogInterpolation.hh"
+#include "G4CompositeEMDataSet.hh"
+#include "G4ShellData.hh"
+#include "G4DopplerProfile.hh"
+#include "G4ForceCondition.hh"
+
+class G4LivermoreComptonModel : public G4VEmModel
+{
+
+public:
+
+  G4LivermoreComptonModel(const G4ParticleDefinition* p = 0, 
+		          const G4String& nam = "LivermoreCompton");
+
+  virtual ~G4LivermoreComptonModel();
+
+  virtual void Initialise(const G4ParticleDefinition*, const G4DataVector&);
+
+  virtual G4double ComputeCrossSectionPerAtom( const G4ParticleDefinition*,
+                                               G4double kinEnergy, 
+                                               G4double Z, 
+                                               G4double A=0, 
+                                               G4double cut=0,
+                                               G4double emax=DBL_MAX );
+
+  virtual void SampleSecondaries(std::vector<G4DynamicParticle*>*,
+				 const G4MaterialCutsCouple*,
+				 const G4DynamicParticle*,
+				 G4double tmin,
+				 G4double maxEnergy);
+
+protected:
+
+  G4ParticleChangeForGamma* fParticleChange;
+
+  G4double GetMeanFreePath(const G4Track& track, 
+			   G4double previousStepSize, 
+			   G4ForceCondition* condition);
+private:
+
+  G4double lowEnergyLimit;  
+  G4double highEnergyLimit; 
+  G4bool isInitialised;
+  G4int verboseLevel;
+  
+  G4VEMDataSet* meanFreePathTable;
+  G4VEMDataSet* scatterFunctionData;
+  G4VCrossSectionHandler* crossSectionHandler;
+
+  G4ShellData shellData;
+  G4DopplerProfile profileData;
+
+  G4LivermoreComptonModel & operator=(const  G4LivermoreComptonModel &right);
+  G4LivermoreComptonModel(const  G4LivermoreComptonModel&);
+
+};
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+#endif
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4LivermoreGammaConversionModel.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4LivermoreGammaConversionModel.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4LivermoreGammaConversionModel.hh	(revision 966)
@@ -0,0 +1,96 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4LivermoreGammaConversionModel.hh,v 1.1 2008/10/30 14:16:34 sincerti Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+
+#ifndef G4LivermoreGammaConversionModel_h
+#define G4LivermoreGammaConversionModel_h 1
+
+#include "G4VEmModel.hh"
+#include "G4Electron.hh"
+#include "G4Positron.hh"
+#include "G4ParticleChangeForGamma.hh"
+#include "G4CrossSectionHandler.hh"
+#include "G4ForceCondition.hh"
+#include "G4CompositeEMDataSet.hh"
+
+class G4LivermoreGammaConversionModel : public G4VEmModel
+{
+
+public:
+
+  G4LivermoreGammaConversionModel(const G4ParticleDefinition* p = 0, 
+		     const G4String& nam = "LivermoreGammaConversion");
+
+  virtual ~G4LivermoreGammaConversionModel();
+
+  virtual void Initialise(const G4ParticleDefinition*, const G4DataVector&);
+
+  virtual G4double ComputeCrossSectionPerAtom(
+                                const G4ParticleDefinition*,
+                                      G4double kinEnergy, 
+                                      G4double Z, 
+                                      G4double A=0, 
+                                      G4double cut=0,
+                                      G4double emax=DBL_MAX);
+
+  virtual void SampleSecondaries(std::vector<G4DynamicParticle*>*,
+				 const G4MaterialCutsCouple*,
+				 const G4DynamicParticle*,
+				 G4double tmin,
+				 G4double maxEnergy);
+
+protected:
+
+  G4ParticleChangeForGamma* fParticleChange;
+
+  G4double GetMeanFreePath(const G4Track& aTrack, 
+			   G4double previousStepSize, 
+			   G4ForceCondition* condition);
+private:
+
+  const G4double smallEnergy;
+  G4double lowEnergyLimit;  
+  G4double highEnergyLimit;
+
+  G4int verboseLevel;
+  G4bool isInitialised;
+  
+  G4double ScreenFunction1(G4double screenVariable);
+  G4double ScreenFunction2(G4double screenVariable);
+  G4VCrossSectionHandler* crossSectionHandler;
+  G4VEMDataSet* meanFreePathTable;
+
+  G4LivermoreGammaConversionModel & operator=(const  G4LivermoreGammaConversionModel &right);
+  G4LivermoreGammaConversionModel(const  G4LivermoreGammaConversionModel&);
+
+
+};
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+#endif
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4LivermoreIonisationModel.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4LivermoreIonisationModel.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4LivermoreIonisationModel.hh	(revision 966)
@@ -0,0 +1,133 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4LivermoreIonisationModel.hh,v 1.1 2009/02/10 16:16:17 pandola Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+// Author: Luciano Pandola
+//
+// History:
+// -----------
+// 12 Jan 2009   L. Pandola   1st implementation. Migration from EM process 
+//                            to EM model. Physics is unchanged.
+//
+// -------------------------------------------------------------------
+//
+// Class description:
+// Low Energy Electromagnetic Physics, e- ionisation
+// with Livermore Model
+// -------------------------------------------------------------------
+
+#ifndef G4LIVERMOREIONISATIONMODEL_HH
+#define G4LIVERMOREIONISATIONMODEL_HH 1
+
+#include "globals.hh"
+#include "G4VEmModel.hh"
+#include "G4DataVector.hh"
+#include "G4ParticleChangeForLoss.hh"
+#include "G4eIonisationCrossSectionHandler.hh"
+#include "G4VEnergySpectrum.hh"
+#include "G4AtomicTransitionManager.hh"
+#include "G4AtomicDeexcitation.hh"
+
+class G4ParticleDefinition;
+class G4DynamicParticle;
+class G4MaterialCutsCouple;
+class G4Material;
+class G4ShellVacancy;
+
+class G4LivermoreIonisationModel : public G4VEmModel 
+{
+
+public:
+  
+  G4LivermoreIonisationModel(const G4ParticleDefinition* p=0,
+			 const G4String& processName = "LowEnergyIoni");
+  
+  virtual ~G4LivermoreIonisationModel();
+
+  virtual void Initialise(const G4ParticleDefinition*, const G4DataVector&);
+
+  
+  virtual G4double ComputeCrossSectionPerAtom(const G4ParticleDefinition*,
+                                              G4double kinEnergy,
+                                              G4double Z,
+                                              G4double A=0,
+                                              G4double cut=0,
+                                              G4double emax=DBL_MAX);
+					 
+  virtual void SampleSecondaries(std::vector<G4DynamicParticle*>*,
+				 const G4MaterialCutsCouple*,
+				 const G4DynamicParticle*,
+				 G4double tmin,
+				 G4double maxEnergy);
+				   
+  virtual G4double ComputeDEDXPerVolume(const G4Material*,
+                               const G4ParticleDefinition*,
+                               G4double kineticEnergy,
+                               G4double cutEnergy);
+		
+
+  virtual void SampleDeexcitationAlongStep(const G4Material*,
+                                           const G4Track&,
+                                           G4double& eloss);
+		 
+  void SetVerboseLevel(G4int vl) {verboseLevel = vl;};
+  void SetUseAtomicDeexcitation(G4bool val){fUseAtomicDeexcitation = val;};
+  G4bool GetSetUseAtomicDeexcitation(){return fUseAtomicDeexcitation;};
+
+  void ActivateAuger(G4bool);
+
+protected:
+  G4ParticleChangeForLoss* fParticleChange;
+
+private:
+ 
+  G4LivermoreIonisationModel & operator=(const G4LivermoreIonisationModel &right);
+  G4LivermoreIonisationModel(const G4LivermoreIonisationModel&);
+
+  void InitialiseFluorescence();
+
+  //Intrinsic energy limits of the model: cannot be extended by the parent process
+  G4double fIntrinsicLowEnergyLimit;
+  G4double fIntrinsicHighEnergyLimit;
+  G4int fNBinEnergyLoss;
+
+  G4bool isInitialised;
+  G4bool fUseAtomicDeexcitation;
+ 
+  G4int verboseLevel;
+ 
+  G4eIonisationCrossSectionHandler* crossSectionHandler;
+  G4VEnergySpectrum* energySpectrum;
+  G4ShellVacancy* shellVacancy;
+
+  G4AtomicDeexcitation deexcitationManager;
+  const G4AtomicTransitionManager* transitionManager;
+
+};
+
+#endif
+
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4LivermorePhotoElectricModel.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4LivermorePhotoElectricModel.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4LivermorePhotoElectricModel.hh	(revision 966)
@@ -0,0 +1,123 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4LivermorePhotoElectricModel.hh,v 1.1 2008/10/30 14:16:35 sincerti Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+
+#ifndef G4LivermorePhotoElectricModel_h
+#define G4LivermorePhotoElectricModel_h 1
+
+#include "G4VEmModel.hh"
+#include "G4Electron.hh"
+#include "G4ParticleChangeForGamma.hh"
+#include "G4CrossSectionHandler.hh"
+#include "G4LogLogInterpolation.hh"
+#include "G4CompositeEMDataSet.hh"
+#include "G4ShellData.hh"
+#include "G4DopplerProfile.hh"
+#include "G4AtomicDeexcitation.hh"
+#include "G4VPhotoElectricAngularDistribution.hh"
+#include "G4PhotoElectricAngularGeneratorSimple.hh"
+#include "G4PhotoElectricAngularGeneratorSauterGavrila.hh"
+#include "G4PhotoElectricAngularGeneratorPolarized.hh"
+#include "G4AtomicTransitionManager.hh"
+#include "G4AtomicShell.hh"
+#include "G4ProductionCutsTable.hh"
+#include "G4ForceCondition.hh"
+
+
+class G4LivermorePhotoElectricModel : public G4VEmModel
+{
+
+public:
+
+  G4LivermorePhotoElectricModel(const G4ParticleDefinition* p = 0, 
+		     const G4String& nam = "LivermorePhotoElectric");
+
+  virtual ~G4LivermorePhotoElectricModel();
+
+  virtual void Initialise(const G4ParticleDefinition*, const G4DataVector&);
+
+  virtual G4double ComputeCrossSectionPerAtom(
+                                const G4ParticleDefinition*,
+                                      G4double kinEnergy, 
+                                      G4double Z, 
+                                      G4double A=0, 
+                                      G4double cut=0,
+                                      G4double emax=DBL_MAX);
+
+  virtual void SampleSecondaries(std::vector<G4DynamicParticle*>*,
+				 const G4MaterialCutsCouple*,
+				 const G4DynamicParticle*,
+				 G4double tmin,
+				 G4double maxEnergy);
+
+  void SetCutForLowEnSecPhotons(G4double);
+
+  void SetCutForLowEnSecElectrons(G4double);
+
+  void ActivateAuger(G4bool);
+
+  void SetAngularGenerator(G4VPhotoElectricAngularDistribution* distribution);
+
+  void SetAngularGenerator(const G4String& name);
+
+protected:
+
+  G4ParticleChangeForGamma* fParticleChange;
+
+  G4double GetMeanFreePath(const G4Track& aTrack, 
+			   G4double previousStepSize, 
+			   G4ForceCondition* condition);
+private:
+
+  G4double lowEnergyLimit;  
+  G4double highEnergyLimit; 
+
+  G4int verboseLevel;
+  G4bool isInitialised;
+
+  G4VEMDataSet* meanFreePathTable;
+
+  G4VCrossSectionHandler* crossSectionHandler;
+  G4VCrossSectionHandler* shellCrossSectionHandler;
+
+  G4double cutForLowEnergySecondaryPhotons;
+  G4double cutForLowEnergySecondaryElectrons;
+
+  G4AtomicDeexcitation deexcitationManager;
+
+  G4VPhotoElectricAngularDistribution* ElectronAngularGenerator;
+  G4String generatorName;
+
+  G4LivermorePhotoElectricModel & operator=(const  G4LivermorePhotoElectricModel &right);
+  G4LivermorePhotoElectricModel(const  G4LivermorePhotoElectricModel&);
+
+};
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+#endif
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4LivermorePolarizedComptonModel.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4LivermorePolarizedComptonModel.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4LivermorePolarizedComptonModel.hh	(revision 966)
@@ -0,0 +1,112 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4LivermorePolarizedComptonModel.hh,v 1.1 2008/10/30 14:16:35 sincerti Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+
+#ifndef G4LivermorePolarizedComptonModel_h
+#define G4LivermorePolarizedComptonModel_h 1
+
+#include "G4VEmModel.hh"
+#include "G4Electron.hh"
+#include "G4ParticleChangeForGamma.hh"
+#include "G4CrossSectionHandler.hh"
+#include "G4LogLogInterpolation.hh"
+#include "G4CompositeEMDataSet.hh"
+#include "G4ShellData.hh"
+#include "G4DopplerProfile.hh"
+#include "G4ForceCondition.hh"
+
+class G4LivermorePolarizedComptonModel : public G4VEmModel
+{
+
+public:
+
+  G4LivermorePolarizedComptonModel(const G4ParticleDefinition* p = 0, 
+		                   const G4String& nam = "LivermorePolarizedCompton");
+
+  virtual ~G4LivermorePolarizedComptonModel();
+
+  virtual void Initialise(const G4ParticleDefinition*, const G4DataVector&);
+
+  virtual G4double ComputeCrossSectionPerAtom(
+                                const G4ParticleDefinition*,
+                                      G4double kinEnergy, 
+                                      G4double Z, 
+                                      G4double A=0, 
+                                      G4double cut=0,
+                                      G4double emax=DBL_MAX);
+
+  virtual void SampleSecondaries(std::vector<G4DynamicParticle*>*,
+				 const G4MaterialCutsCouple*,
+				 const G4DynamicParticle*,
+				 G4double tmin,
+				 G4double maxEnergy);
+
+protected:
+
+  G4ParticleChangeForGamma* fParticleChange;
+
+  G4double GetMeanFreePath(const G4Track& aTrack, 
+			   G4double previousStepSize, 
+			   G4ForceCondition* condition);
+private:
+
+  G4double lowEnergyLimit;  
+  G4double highEnergyLimit; 
+  G4bool isInitialised;
+  G4int verboseLevel;
+
+  G4VEMDataSet* meanFreePathTable;
+  G4VEMDataSet* scatterFunctionData;
+  G4VCrossSectionHandler* crossSectionHandler;
+
+  // specific methods for polarization 
+  
+  G4ThreeVector GetRandomPolarization(G4ThreeVector& direction0); // Random Polarization
+  G4ThreeVector GetPerpendicularPolarization(const G4ThreeVector& direction0, const G4ThreeVector& polarization0) const;
+  
+  G4ThreeVector SetPerpendicularVector(G4ThreeVector& a); // temporary
+  G4ThreeVector SetNewPolarization(G4double epsilon, G4double sinSqrTheta, 
+				   G4double phi, G4double cosTheta);
+  G4double SetPhi(G4double, G4double);
+  
+  void SystemOfRefChange(G4ThreeVector& direction0, G4ThreeVector& direction1, 
+			 G4ThreeVector& polarization0, G4ThreeVector& polarization1);
+  
+  // Doppler Broadening
+ 
+  G4ShellData shellData;
+  G4DopplerProfile profileData;
+
+  G4LivermorePolarizedComptonModel & operator=(const  G4LivermorePolarizedComptonModel &right);
+  G4LivermorePolarizedComptonModel(const  G4LivermorePolarizedComptonModel&);
+
+};
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+#endif
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4LivermorePolarizedRayleighModel.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4LivermorePolarizedRayleighModel.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4LivermorePolarizedRayleighModel.hh	(revision 966)
@@ -0,0 +1,104 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4LivermorePolarizedRayleighModel.hh,v 1.1 2008/10/30 14:16:35 sincerti Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+
+#ifndef G4LivermorePolarizedRayleighModel_h
+#define G4LivermorePolarizedRayleighModel_h 1
+
+#include "G4VEmModel.hh"
+#include "G4ParticleChangeForGamma.hh"
+#include "G4CrossSectionHandler.hh"
+#include "G4LogLogInterpolation.hh"
+#include "G4CompositeEMDataSet.hh"
+
+class G4LivermorePolarizedRayleighModel : public G4VEmModel
+{
+
+public:
+
+  G4LivermorePolarizedRayleighModel(const G4ParticleDefinition* p = 0, 
+		     const G4String& nam = "LivermorePolarizedRayleigh");
+
+  virtual ~G4LivermorePolarizedRayleighModel();
+
+  virtual void Initialise(const G4ParticleDefinition*, const G4DataVector&);
+
+  virtual G4double ComputeCrossSectionPerAtom(
+                                const G4ParticleDefinition*,
+                                      G4double kinEnergy, 
+                                      G4double Z, 
+                                      G4double A=0, 
+                                      G4double cut=0,
+                                      G4double emax=DBL_MAX);
+
+  virtual void SampleSecondaries(std::vector<G4DynamicParticle*>*,
+				 const G4MaterialCutsCouple*,
+				 const G4DynamicParticle*,
+				 G4double tmin,
+				 G4double maxEnergy);
+
+protected:
+
+  G4ParticleChangeForGamma* fParticleChange;
+
+private:
+
+  G4double lowEnergyLimit;  
+  G4double highEnergyLimit; 
+  
+  G4int verboseLevel;
+  G4bool isInitialised;
+
+  G4VCrossSectionHandler* crossSectionHandler;
+  G4VEMDataSet* formFactorData;
+
+  //   Generates \f$cos \left ( \theta\right )\f$ of the scattered photon
+  //   incomingPhotonEnergy The energy of the incoming photon
+  //   zAtom Atomic number
+  //   \f$cos \left ( \theta\right )\f$
+  G4double GenerateCosTheta(G4double incomingPhotonEnergy, G4int zAtom) const;
+   
+  //   Generates \f$\phi\f$ of the scattered photon
+  //   cosTheta \f$cos \left ( \theta\right )\f$ of the scattered photon
+  //    \f$\phi\f$
+  G4double GeneratePhi(G4double cosTheta) const;
+
+  //   Generates the polarization direction \f$\beta\f$ in the plane x, y relative to the x direction
+  //   \f$\beta\f$
+  G4double GeneratePolarizationAngle(void) const;
+ 
+  G4ThreeVector GetPhotonPolarization(const G4DynamicParticle&  photon);
+
+  G4LivermorePolarizedRayleighModel & operator=(const  G4LivermorePolarizedRayleighModel &right);
+  G4LivermorePolarizedRayleighModel(const  G4LivermorePolarizedRayleighModel&);
+
+};
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+#endif
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4LivermoreRayleighModel.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4LivermoreRayleighModel.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4LivermoreRayleighModel.hh	(revision 966)
@@ -0,0 +1,92 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4LivermoreRayleighModel.hh,v 1.1 2008/10/30 14:16:35 sincerti Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+
+#ifndef G4LivermoreRayleighModel_h
+#define G4LivermoreRayleighModel_h 1
+
+#include "G4VEmModel.hh"
+#include "G4ParticleChangeForGamma.hh"
+#include "G4CrossSectionHandler.hh"
+#include "G4LogLogInterpolation.hh"
+#include "G4CompositeEMDataSet.hh"
+#include "G4ForceCondition.hh"
+
+class G4LivermoreRayleighModel : public G4VEmModel
+{
+
+public:
+
+  G4LivermoreRayleighModel(const G4ParticleDefinition* p = 0, 
+		     const G4String& nam = "LivermoreRayleigh");
+
+  virtual ~G4LivermoreRayleighModel();
+
+  virtual void Initialise(const G4ParticleDefinition*, const G4DataVector&);
+
+  virtual G4double ComputeCrossSectionPerAtom(
+                                const G4ParticleDefinition*,
+                                      G4double kinEnergy, 
+                                      G4double Z, 
+                                      G4double A=0, 
+                                      G4double cut=0,
+                                      G4double emax=DBL_MAX);
+
+  virtual void SampleSecondaries(std::vector<G4DynamicParticle*>*,
+				 const G4MaterialCutsCouple*,
+				 const G4DynamicParticle*,
+				 G4double tmin,
+				 G4double maxEnergy);
+
+protected:
+
+  G4ParticleChangeForGamma* fParticleChange;
+
+  G4double GetMeanFreePath(const G4Track& aTrack, 
+			   G4double previousStepSize, 
+			   G4ForceCondition* condition);
+private:
+
+  G4double lowEnergyLimit;  
+  G4double highEnergyLimit; 
+
+  G4int verboseLevel;
+  G4bool isInitialised;
+
+  G4VEMDataSet* meanFreePathTable;
+  G4VEMDataSet* formFactorData;
+  G4VCrossSectionHandler* crossSectionHandler;
+
+  G4LivermoreRayleighModel & operator=(const  G4LivermoreRayleighModel &right);
+  G4LivermoreRayleighModel(const  G4LivermoreRayleighModel&);
+
+};
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+#endif
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4OrlicLCrossSection.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4OrlicLCrossSection.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4OrlicLCrossSection.hh	(revision 966)
@@ -0,0 +1,78 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4OrlicLCrossSection.hh,v 1.3 2008/06/03 07:29:15 gcosmo Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+// Author: Haifa Ben Abdelouahed
+//         
+//
+// History:
+// -----------
+//  23 Apr 2008   H. Ben Abdelouahed   1st implementation
+//  28 Apr 2008   MGP        Major revision according to a design iteration
+//
+// -------------------------------------------------------------------
+
+// Class description:
+// Low Energy Electromagnetic Physics, Cross section, proton ionisation, L shell
+// Further documentation available from http://www.ge.infn.it/geant4/lowE
+
+// -------------------------------------------------------------------
+
+
+#ifndef G4ORLICLCROSSSECTION_HH
+#define G4ORLICLCROSSSECTION_HH 1
+
+#include "globals.hh"
+
+
+class G4OrlicLCrossSection 
+
+{
+public:
+
+  G4OrlicLCrossSection();
+
+  virtual ~G4OrlicLCrossSection();
+
+
+//according to I.ORLIC, C.H.SOW and S.M.TANG,International Journal of PIXE.Vol.4(1997) 217-230	
+		     
+  G4double CalculateL1CrossSection(G4int zTarget, G4double energyIncident);
+
+  G4double CalculateL2CrossSection(G4int zTarget, G4double energyIncident);				    
+ 
+  G4double CalculateL3CrossSection(G4int zTarget, G4double energyIncident);
+
+private:
+
+
+  G4OrlicLCrossSection(const G4OrlicLCrossSection&);
+  G4OrlicLCrossSection & operator = (const G4OrlicLCrossSection &right);
+
+};
+
+#endif
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4PaulKCrossSection.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4PaulKCrossSection.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4PaulKCrossSection.hh	(revision 966)
@@ -0,0 +1,58 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// 
+
+
+#ifndef G4PAULKCROSSSECTION_HH
+#define G4PAULKCROSSSECTION_HH 1
+
+#include "globals.hh"
+
+
+class G4PaulKCrossSection 
+
+{
+public:
+
+  G4PaulKCrossSection();
+
+  virtual ~G4PaulKCrossSection();
+			     
+  G4double CalculateKCrossSection(G4int zTarget,G4int zIncident, G4double energyIncident);
+				    
+ 
+
+   
+
+private:
+
+
+  G4PaulKCrossSection(const G4PaulKCrossSection&);
+  G4PaulKCrossSection & operator = (const G4PaulKCrossSection &right);
+
+};
+
+#endif
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4PenelopeAnnihilationModel.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4PenelopeAnnihilationModel.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4PenelopeAnnihilationModel.hh	(revision 966)
@@ -0,0 +1,103 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4PenelopeAnnihilationModel.hh,v 1.1 2008/11/04 10:14:56 pandola Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+// Author: Luciano Pandola
+//
+// History:
+// -----------
+// 29 Oct 2008   L. Pandola   1st implementation. Migration from EM process 
+//                            to EM model
+//
+// -------------------------------------------------------------------
+//
+// Class description:
+// Low Energy Electromagnetic Physics, Positron Annihilation 
+// with Penelope Model
+// -------------------------------------------------------------------
+
+#ifndef G4PENELOPEANNIHILATIONMODEL_HH
+#define G4PENELOPEANNIHILATIONMODEL_HH 1
+
+#include "globals.hh"
+#include "G4VEmModel.hh"
+#include "G4DataVector.hh"
+#include "G4ParticleChangeForGamma.hh"
+
+class G4ParticleDefinition;
+class G4DynamicParticle;
+class G4MaterialCutsCouple;
+class G4Material;
+
+class G4PenelopeAnnihilationModel : public G4VEmModel 
+{
+public:
+  
+  G4PenelopeAnnihilationModel(const G4ParticleDefinition* p=0,
+			 const G4String& processName ="PenAnnih");
+  
+  virtual ~G4PenelopeAnnihilationModel();
+
+  virtual void Initialise(const G4ParticleDefinition*, const G4DataVector&);
+
+  virtual G4double ComputeCrossSectionPerAtom(const G4ParticleDefinition*,
+					      G4double kinEnergy,
+					      G4double Z,
+					      G4double A=0,
+					      G4double cut=0,
+					      G4double emax=DBL_MAX);
+
+  virtual void SampleSecondaries(std::vector<G4DynamicParticle*>*,
+				 const G4MaterialCutsCouple*,
+				 const G4DynamicParticle*,
+				 G4double tmin,
+				 G4double maxEnergy);
+
+  void SetVerbosityLevel(G4int lev){verboseLevel = lev;};
+  G4int GetVerbosityLevel(){return verboseLevel;};
+
+protected:
+  G4ParticleChangeForGamma* fParticleChange;
+
+private:
+  G4double ComputeCrossSectionPerElectron(G4double energy);
+
+  G4PenelopeAnnihilationModel & operator=(const G4PenelopeAnnihilationModel &right);
+  G4PenelopeAnnihilationModel(const G4PenelopeAnnihilationModel&);
+
+  G4int verboseLevel;
+  G4bool isInitialised;
+
+  G4double fIntrinsicLowEnergyLimit;
+  G4double fIntrinsicHighEnergyLimit;
+
+  //Stored here so it is not recalculated every time
+  G4double fPielr2;
+};
+
+#endif
+
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4PenelopeBremsstrahlungModel.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4PenelopeBremsstrahlungModel.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4PenelopeBremsstrahlungModel.hh	(revision 966)
@@ -0,0 +1,134 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4PenelopeBremsstrahlungModel.hh,v 1.1 2008/12/15 09:23:48 pandola Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+// Author: Luciano Pandola
+//
+// History:
+// -----------
+// 05 Dec 2008   L. Pandola   1st implementation. Migration from EM process 
+//                            to EM model. Physics is unchanged.
+//
+// -------------------------------------------------------------------
+//
+// Class description:
+// Low Energy Electromagnetic Physics, e+ and e- bremsstrahlung
+// with Penelope Model
+// -------------------------------------------------------------------
+
+#ifndef G4PENELOPEBREMSSTRAHLUNGMODEL_HH
+#define G4PENELOPEBREMSSTRAHLUNGMODEL_HH 1
+
+#include "globals.hh"
+#include "G4VEmModel.hh"
+#include "G4DataVector.hh"
+#include "G4ParticleChangeForLoss.hh"
+#include "G4VCrossSectionHandler.hh"
+#include "G4PhysicsLogVector.hh"
+#include "G4AtomicDeexcitation.hh"
+
+class G4ParticleDefinition;
+class G4DynamicParticle;
+class G4MaterialCutsCouple;
+class G4Material;
+class G4VEnergySpectrum;
+class G4PenelopeBremsstrahlungAngular;
+class G4PenelopeBremsstrahlungContinuous;
+
+class G4PenelopeBremsstrahlungModel : public G4VEmModel 
+{
+
+public:
+  
+  G4PenelopeBremsstrahlungModel(const G4ParticleDefinition* p=0,
+			 const G4String& processName ="PenelopeBrem");
+  
+  virtual ~G4PenelopeBremsstrahlungModel();
+
+  virtual void Initialise(const G4ParticleDefinition*, const G4DataVector&);
+
+  virtual G4double ComputeCrossSectionPerAtom(const G4ParticleDefinition*,
+                                              G4double kinEnergy,
+                                              G4double Z,
+                                              G4double A=0,
+                                              G4double cut=0,
+                                              G4double emax=DBL_MAX);
+					 
+  virtual void SampleSecondaries(std::vector<G4DynamicParticle*>*,
+				 const G4MaterialCutsCouple*,
+				 const G4DynamicParticle*,
+				 G4double tmin,
+				 G4double maxEnergy);
+				   
+  virtual G4double ComputeDEDXPerVolume(const G4Material*,
+                               const G4ParticleDefinition*,
+                               G4double kineticEnergy,
+                               G4double cutEnergy);
+				 
+
+  void SetVerbosityLevel(G4int lev){verboseLevel = lev;};
+  G4int GetVerbosityLevel(){return verboseLevel;};
+
+
+protected:
+  G4ParticleChangeForLoss* fParticleChange;
+
+private:
+ 
+  G4PenelopeBremsstrahlungModel & operator=(const G4PenelopeBremsstrahlungModel &right);
+  G4PenelopeBremsstrahlungModel(const G4PenelopeBremsstrahlungModel&);
+
+ 
+  //Intrinsic energy limits of the model: cannot be extended by the parent 
+  // process
+  G4double fIntrinsicLowEnergyLimit;
+  G4double fIntrinsicHighEnergyLimit;
+
+  G4int verboseLevel;
+
+  G4bool isInitialised;
+
+  G4VEnergySpectrum* energySpectrum;
+ 
+
+  G4PenelopeBremsstrahlungAngular* GetAngularDataForZ(G4int iZ);
+  // Map to the objects containing tha angular data
+  std::map<G4int,G4PenelopeBremsstrahlungAngular*> *angularData;
+
+  G4PenelopeBremsstrahlungContinuous* GetStoppingPowerData(G4int iZ,G4double energyCut,
+							   const G4ParticleDefinition*);
+  std::map<std::pair<G4int,G4double>,G4PenelopeBremsstrahlungContinuous*> *stoppingPowerData;
+
+
+  G4int SampleRandomAtom(const G4MaterialCutsCouple*,G4double energy) const;
+  G4VCrossSectionHandler* crossSectionHandler;
+
+ 
+};
+
+#endif
+
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4PenelopeComptonModel.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4PenelopeComptonModel.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4PenelopeComptonModel.hh	(revision 966)
@@ -0,0 +1,126 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4PenelopeComptonModel.hh,v 1.1 2008/10/28 08:50:21 pandola Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+// Author: Luciano Pandola
+//
+// History:
+// -----------
+// 02 Oct 2008   L. Pandola   1st implementation. Migration from EM process 
+//                            to EM model
+//
+// -------------------------------------------------------------------
+//
+// Class description:
+// Low Energy Electromagnetic Physics, Compton Scattering
+// with Penelope Model
+// -------------------------------------------------------------------
+
+#ifndef G4PENELOPECOMPTONMODEL_HH
+#define G4PENELOPECOMPTONMODEL_HH 1
+
+#include "globals.hh"
+#include "G4VEmModel.hh"
+#include "G4DataVector.hh"
+#include "G4ParticleChangeForGamma.hh"
+
+class G4ParticleDefinition;
+class G4DynamicParticle;
+class G4MaterialCutsCouple;
+class G4Material;
+//class G4PhysicsTable;
+
+class G4PenelopeComptonModel : public G4VEmModel 
+{
+
+public:
+  
+  G4PenelopeComptonModel(const G4ParticleDefinition* p=0,
+			 const G4String& processName ="PenCompton");
+  
+  virtual ~G4PenelopeComptonModel();
+
+  virtual void Initialise(const G4ParticleDefinition*, const G4DataVector&);
+
+  virtual G4double ComputeCrossSectionPerAtom(
+					      const G4ParticleDefinition*,
+					      G4double kinEnergy,
+					      G4double Z,
+					      G4double A=0,
+					      G4double cut=0,
+					      G4double emax=DBL_MAX);
+
+  virtual void SampleSecondaries(std::vector<G4DynamicParticle*>*,
+				 const G4MaterialCutsCouple*,
+				 const G4DynamicParticle*,
+				 G4double tmin,
+				 G4double maxEnergy);
+
+  void SetUseAtomicDeexcitation(G4bool value){fUseAtomicDeexcitation = value;};		 
+  G4bool GetUseAtomicDeexcitation(){return fUseAtomicDeexcitation;};
+
+  void SetVerbosityLevel(G4int lev){verboseLevel = lev;};
+  G4int GetVerbosityLevel(){return verboseLevel;};
+
+protected:
+  G4ParticleChangeForGamma* fParticleChange;
+
+private:
+  //Reads data of atomic shells from database file
+  void ReadData();
+
+  //Differential cross section which is numerically integrated
+  G4double DifferentialCrossSection (G4double cdt);
+
+  G4PenelopeComptonModel & operator=(const G4PenelopeComptonModel &right);
+  G4PenelopeComptonModel(const G4PenelopeComptonModel&);
+
+  //Parameter for the numerical integration of analytical cross section
+  G4double energyForIntegration; 
+  G4int ZForIntegration;
+
+  //Parameters of atomic shells
+  std::map<G4int,G4DataVector*> *ionizationEnergy;
+  std::map<G4int,G4DataVector*> *hartreeFunction;
+  std::map<G4int,G4DataVector*> *occupationNumber;
+
+  //Intrinsic energy limits of the model: cannot be extended by the parent process
+  G4double fIntrinsicLowEnergyLimit;
+  G4double fIntrinsicHighEnergyLimit;
+
+  G4bool fUseAtomicDeexcitation;
+
+  G4int verboseLevel;
+
+  G4bool isInitialised;
+
+  
+
+};
+
+#endif
+
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4PenelopeGammaConversionModel.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4PenelopeGammaConversionModel.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4PenelopeGammaConversionModel.hh	(revision 966)
@@ -0,0 +1,115 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4PenelopeGammaConversionModel.hh,v 1.1 2008/10/28 08:50:21 pandola Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+// Author: Luciano Pandola
+//
+// History:
+// -----------
+// 06 Oct 2008   L. Pandola   1st implementation. Migration from EM process 
+//                            to EM model
+//
+// -------------------------------------------------------------------
+//
+// Class description:
+// Low Energy Electromagnetic Physics, Gamma Conversion 
+// with Penelope Model
+// -------------------------------------------------------------------
+
+#ifndef G4PENELOPEGAMMACONVERSIONMODEL_HH
+#define G4PENELOPEGAMMACONVERSIONMODEL_HH 1
+
+#include "globals.hh"
+#include "G4VEmModel.hh"
+#include "G4DataVector.hh"
+#include "G4ParticleChangeForGamma.hh"
+
+class G4ParticleDefinition;
+class G4DynamicParticle;
+class G4MaterialCutsCouple;
+class G4Material;
+class G4VCrossSectionHandler;
+
+class G4PenelopeGammaConversionModel : public G4VEmModel 
+{
+
+public:
+  
+  G4PenelopeGammaConversionModel(const G4ParticleDefinition* p=0,
+			 const G4String& processName ="PenConversion");
+  
+  virtual ~G4PenelopeGammaConversionModel();
+
+  virtual void Initialise(const G4ParticleDefinition*, const G4DataVector&);
+
+  virtual G4double ComputeCrossSectionPerAtom(
+					      const G4ParticleDefinition*,
+					      G4double kinEnergy,
+					      G4double Z,
+					      G4double A=0,
+					      G4double cut=0,
+					      G4double emax=DBL_MAX);
+
+  virtual void SampleSecondaries(std::vector<G4DynamicParticle*>*,
+				 const G4MaterialCutsCouple*,
+				 const G4DynamicParticle*,
+				 G4double tmin,
+				 G4double maxEnergy);
+
+  void SetVerbosityLevel(G4int lev){verboseLevel = lev;};
+  G4int GetVerbosityLevel(){return verboseLevel;};
+
+protected:
+  G4ParticleChangeForGamma* fParticleChange;
+
+private:
+  G4PenelopeGammaConversionModel & operator=(const G4PenelopeGammaConversionModel &right);
+  G4PenelopeGammaConversionModel(const G4PenelopeGammaConversionModel&);
+
+  G4double GetScreeningRadius(G4double Z);
+  std::vector<G4double>  ScreenFunction(G4double screenVariable);
+  G4double CoulombCorrection(G4double ZAlpha);
+  G4double LowEnergyCorrection(G4double ZAlpha,G4double eki);
+
+  std::map<G4int,G4double>* fTheScreeningRadii;
+
+
+  //Intrinsic energy limits of the model: cannot be extended by the parent process
+  G4double fIntrinsicLowEnergyLimit;
+  G4double fIntrinsicHighEnergyLimit;
+
+  //Use a quicker sampling algorithm if E < smallEnergy
+  G4double fSmallEnergy; 
+
+  G4VCrossSectionHandler* crossSectionHandler;
+
+  G4int verboseLevel;
+  G4bool isInitialised;
+};
+
+#endif
+
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4PenelopeIonisationModel.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4PenelopeIonisationModel.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4PenelopeIonisationModel.hh	(revision 966)
@@ -0,0 +1,183 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4PenelopeIonisationModel.hh,v 1.1 2008/12/04 14:12:09 pandola Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+// Author: Luciano Pandola
+//
+// History:
+// -----------
+// 26 Nov 2008   L. Pandola   1st implementation. Migration from EM process 
+//                            to EM model. Physics is unchanged.
+//
+// -------------------------------------------------------------------
+//
+// Class description:
+// Low Energy Electromagnetic Physics, e+ and e- ionisation
+// with Penelope Model
+// -------------------------------------------------------------------
+
+#ifndef G4PENELOPEIONISATIONMODEL_HH
+#define G4PENELOPEIONISATIONMODEL_HH 1
+
+#include "globals.hh"
+#include "G4VEmModel.hh"
+#include "G4DataVector.hh"
+#include "G4ParticleChangeForLoss.hh"
+#include "G4VCrossSectionHandler.hh"
+#include "G4PhysicsLogVector.hh"
+#include "G4AtomicDeexcitation.hh"
+
+class G4ParticleDefinition;
+class G4DynamicParticle;
+class G4MaterialCutsCouple;
+class G4Material;
+class G4VEMDataSet;
+
+class G4PenelopeIonisationModel : public G4VEmModel 
+{
+
+public:
+  
+  G4PenelopeIonisationModel(const G4ParticleDefinition* p=0,
+			 const G4String& processName ="PenelopeIoni");
+  
+  virtual ~G4PenelopeIonisationModel();
+
+  virtual void Initialise(const G4ParticleDefinition*, const G4DataVector&);
+
+  virtual G4double CrossSectionPerVolume(const G4Material* material,
+                                         const G4ParticleDefinition* theParticle,
+                                         G4double kineticEnergy,
+                                         G4double cutEnergy,
+                                         G4double maxEnergy = DBL_MAX);
+					 
+  virtual void SampleSecondaries(std::vector<G4DynamicParticle*>*,
+				 const G4MaterialCutsCouple*,
+				 const G4DynamicParticle*,
+				 G4double tmin,
+				 G4double maxEnergy);
+				   
+  virtual G4double ComputeDEDXPerVolume(const G4Material*,
+                               const G4ParticleDefinition*,
+                               G4double kineticEnergy,
+                               G4double cutEnergy);
+				 
+
+  void SetUseAtomicDeexcitation(G4bool value){fUseAtomicDeexcitation = value;};		 
+  G4bool GetUseAtomicDeexcitation(){return fUseAtomicDeexcitation;};
+
+  void SetVerbosityLevel(G4int lev){verboseLevel = lev;};
+  G4int GetVerbosityLevel(){return verboseLevel;};
+
+
+protected:
+  G4ParticleChangeForLoss* fParticleChange;
+
+private:
+ 
+  G4PenelopeIonisationModel & operator=(const G4PenelopeIonisationModel &right);
+  G4PenelopeIonisationModel(const G4PenelopeIonisationModel&);
+
+ 
+  //Intrinsic energy limits of the model: cannot be extended by the parent process
+  G4double fIntrinsicLowEnergyLimit;
+  G4double fIntrinsicHighEnergyLimit;
+
+  G4bool fUseAtomicDeexcitation;
+
+  G4int verboseLevel;
+
+  G4bool isInitialised;
+ 
+  G4double CalculateDeltaFermi(G4double kinEnergy ,G4int Z,
+			       G4double electronVolumeDensity);
+  	
+  //Methods and variables to calculate final state
+  void CalculateDiscreteForElectrons(G4double kinEnergy,G4double cutoffEnergy,
+				     G4int Z,G4double electronVolumeDensity);
+  void CalculateDiscreteForPositrons(G4double kinEnergy,G4double cutoffEnergy,
+				     G4int Z,G4double electronVolumeDensity);
+
+  G4AtomicDeexcitation deexcitationManager;
+  G4double kineticEnergy1;
+  G4double cosThetaPrimary;
+  G4double energySecondary;
+  G4double cosThetaSecondary;
+  G4int iOsc;				   
+
+  //These methods are used to calculate the hard-cross section (namely they 
+  //return the hard/total cross section)
+  G4double CalculateCrossSectionsRatio(G4double kinEnergy,
+				       G4double cutoffEnergy,
+				       G4int Z, 
+				       G4double electronVolumeDensity,
+				       const G4ParticleDefinition*);
+  //In fact the total cross section (hard+soft) is read from file
+  //The following methods give the cross section contribution (hard and soft) from each 
+  //individual oscillator
+  std::pair<G4double,G4double> CrossSectionsRatioForElectrons(G4double kineticEnergy,
+							      G4double resEnergy,
+							      G4double densityCorrection,
+							      G4double cutoffEnergy);
+
+  std::pair<G4double,G4double> CrossSectionsRatioForPositrons(G4double kineticEnergy,
+							      G4double resEnergy,
+							      G4double densityCorrection,
+							      G4double cutoffEnergy);
+  
+  G4VCrossSectionHandler* crossSectionHandler;
+  
+  //These methods are used to calculate the stopping power up to the cutoff
+  //for each individual oscillator
+  G4double ComputeStoppingPowerForElectrons(G4double kinEnergy,
+					    G4double cutEnergy,
+					    G4double deltaFermi,
+					    G4double resEnergy);
+
+  G4double ComputeStoppingPowerForPositrons(G4double kinEnergy,
+					    G4double cutEnergy,
+					    G4double deltaFermi,
+					    G4double resEnergy);
+  
+  
+  //Parameters of atomic shells
+  void ReadData();
+  std::map<G4int,G4DataVector*> *ionizationEnergy;
+  std::map<G4int,G4DataVector*> *resonanceEnergy;
+  std::map<G4int,G4DataVector*> *occupationNumber;
+  std::map<G4int,G4DataVector*> *shellFlag;
+  
+  //Mean free path table. This will become obsolete! For now I need something to store 
+  //cross sections and to sample a random atom
+  std::vector<G4VEMDataSet*>* theXSTable;
+  std::vector<G4VEMDataSet*>* BuildCrossSectionTable(const G4ParticleDefinition*);
+  G4int SampleRandomAtom(const G4MaterialCutsCouple*,G4double energy) const;
+
+};
+
+#endif
+
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4PenelopePhotoElectricModel.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4PenelopePhotoElectricModel.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4PenelopePhotoElectricModel.hh	(revision 966)
@@ -0,0 +1,117 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4PenelopePhotoElectricModel.hh,v 1.1 2008/10/28 08:50:21 pandola Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+// Author: Luciano Pandola
+//
+// History:
+// -----------
+// 08 Oct 2008   L. Pandola   1st implementation. Migration from EM process 
+//                            to EM model
+//
+// -------------------------------------------------------------------
+//
+// Class description:
+// Low Energy Electromagnetic Physics, Photo-electric effect
+// with Penelope Model
+// -------------------------------------------------------------------
+
+#ifndef G4PENELOPEPHOTOELECTRICMODEL_HH
+#define G4PENELOPEPHOTOELECTRICMODEL_HH 1
+
+#include "globals.hh"
+#include "G4VEmModel.hh"
+#include "G4DataVector.hh"
+#include "G4ParticleChangeForGamma.hh"
+#include "G4AtomicDeexcitation.hh"
+
+class G4ParticleDefinition;
+class G4DynamicParticle;
+class G4MaterialCutsCouple;
+class G4Material;
+class G4VCrossSectionHandler;
+
+class G4PenelopePhotoElectricModel : public G4VEmModel 
+{
+
+public:
+  
+  G4PenelopePhotoElectricModel(const G4ParticleDefinition* p=0,
+			 const G4String& processName ="PenPhotoElec");
+  
+  virtual ~G4PenelopePhotoElectricModel();
+
+  virtual void Initialise(const G4ParticleDefinition*, const G4DataVector&);
+
+  virtual G4double ComputeCrossSectionPerAtom(
+					      const G4ParticleDefinition*,
+					      G4double kinEnergy,
+					      G4double Z,
+					      G4double A=0,
+					      G4double cut=0,
+					      G4double emax=DBL_MAX);
+
+  virtual void SampleSecondaries(std::vector<G4DynamicParticle*>*,
+				 const G4MaterialCutsCouple*,
+				 const G4DynamicParticle*,
+				 G4double tmin,
+				 G4double maxEnergy);
+
+  void SetUseAtomicDeexcitation(G4bool value){fUseAtomicDeexcitation = value;};		 
+  G4bool GetUseAtomicDeexcitation(){return fUseAtomicDeexcitation;};
+
+  void SetVerbosityLevel(G4int lev){verboseLevel = lev;};
+  G4int GetVerbosityLevel(){return verboseLevel;};
+
+  void ActivateAuger(G4bool);
+
+protected:
+  G4ParticleChangeForGamma* fParticleChange;
+
+private:
+  G4PenelopePhotoElectricModel & operator=(const G4PenelopePhotoElectricModel &right);
+  G4PenelopePhotoElectricModel(const G4PenelopePhotoElectricModel&);
+
+  G4double SampleElectronDirection(G4double ene);
+
+  //Intrinsic energy limits of the model: cannot be extended by the parent process
+  G4double fIntrinsicLowEnergyLimit;
+  G4double fIntrinsicHighEnergyLimit;
+
+  G4bool fUseAtomicDeexcitation;
+  G4int verboseLevel;
+  G4bool isInitialised;
+
+  G4VCrossSectionHandler* crossSectionHandler;
+  G4VCrossSectionHandler* shellCrossSectionHandler;
+
+  G4AtomicDeexcitation deexcitationManager;
+
+};
+
+#endif
+
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4PenelopeRayleighModel.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4PenelopeRayleighModel.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4PenelopeRayleighModel.hh	(revision 966)
@@ -0,0 +1,122 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4PenelopeRayleighModel.hh,v 1.1 2008/10/28 08:50:21 pandola Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+// Author: Luciano Pandola
+//
+// History:
+// -----------
+// 13 Oct 2008   L. Pandola   1st implementation. Migration from EM process 
+//                            to EM model
+//
+// -------------------------------------------------------------------
+//
+// Class description:
+// Low Energy Electromagnetic Physics, Rayleigh Scattering
+// with Penelope Model
+// -------------------------------------------------------------------
+
+#ifndef G4PENELOPERAYLEIGHMODEL_HH
+#define G4PENELOPERAYLEIGHMODEL_HH 1
+
+#include "globals.hh"
+#include "G4VEmModel.hh"
+#include "G4DataVector.hh"
+#include "G4ParticleChangeForGamma.hh"
+
+class G4ParticleDefinition;
+class G4DynamicParticle;
+class G4MaterialCutsCouple;
+class G4Material;
+
+class G4PenelopeRayleighModel : public G4VEmModel 
+{
+
+public:  
+  G4PenelopeRayleighModel(const G4ParticleDefinition* p=0,
+			  const G4String& processName ="PenRayleigh");
+  
+  virtual ~G4PenelopeRayleighModel();
+  
+  virtual void Initialise(const G4ParticleDefinition*, const G4DataVector&);
+  
+  virtual G4double CrossSectionPerVolume(const G4Material*,
+                                         const G4ParticleDefinition*,
+                                         G4double kineticEnergy,
+                                         G4double cutEnergy = 0.0,
+                                         G4double maxEnergy = DBL_MAX);
+  
+  virtual void SampleSecondaries(std::vector<G4DynamicParticle*>*,
+				 const G4MaterialCutsCouple*,
+				 const G4DynamicParticle*,
+				 G4double tmin,
+				 G4double maxEnergy);
+    
+  void SetVerbosityLevel(G4int lev){verboseLevel = lev;};
+  G4int GetVerbosityLevel(){return verboseLevel;};
+  
+protected:
+  G4ParticleChangeForGamma* fParticleChange;
+  
+private:
+  G4PenelopeRayleighModel & operator=(const G4PenelopeRayleighModel &right);
+  G4PenelopeRayleighModel(const G4PenelopeRayleighModel&);
+  
+  //Method to initialize sampling 
+  void InitialiseSampling();
+  std::map <const G4Material*,G4DataVector*> SamplingTable;
+  G4DataVector* samplingFunction_x;
+  G4DataVector* samplingFunction_xNoLog;
+
+  //Parameters for building the sampling tables
+  G4int nPoints; 
+  G4double Xhigh;
+  G4double Xlow;
+
+  void PrepareConstants();
+  
+  //Parameters that must be in common between methods
+  const G4Material* theMaterial;
+  
+  //Cross section calculation
+  G4double MolecularFormFactor(G4double x);
+  G4double DifferentialCrossSection(G4double cosTheta);
+
+  // Energy dependent factor in the differential cross section
+  G4double factorE;
+  
+  //Intrinsic energy limits of the model: cannot be extended by the parent process
+  G4double fIntrinsicLowEnergyLimit;
+  G4double fIntrinsicHighEnergyLimit;
+  
+  G4int verboseLevel;
+  G4bool isInitialised;
+};
+
+
+#endif
+
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4RayleighScattering.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4RayleighScattering.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4RayleighScattering.hh	(revision 966)
@@ -0,0 +1,95 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G4RayleighScattering.hh,v 1.1 2008/12/19 14:23:04 pandola Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+//------------------ G4RayleighScattering physics process -----------------------
+//
+// 19-12-2008, first implementation, Luciano Pandola 
+// -----------------------------------------------------------------------------
+
+// class description
+//
+// Class to implement Rayleigh scattering as a physics process. The default model 
+// used for the process is G4LivermoreRayleighModel
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+#ifndef G4RayleighScattering_h
+#define G4RayleighScattering_h 1
+
+#include "globals.hh"
+#include "G4VEmProcess.hh"
+#include "G4Gamma.hh"
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+class G4ParticleDefinition;
+class G4VEmModel;
+class G4MaterialCutsCouple;
+class G4DynamicParticle;
+
+class G4RayleighScattering : public G4VEmProcess
+
+{
+public:  // with description
+
+  G4RayleighScattering(const G4String& processName ="rayl",
+		      G4ProcessType type = fElectromagnetic);
+
+  virtual ~G4RayleighScattering();
+
+  // true for Gamma only.  
+  G4bool IsApplicable(const G4ParticleDefinition&);
+  
+  // Print few lines of informations about the process: validity range,
+  virtual void PrintInfo();
+
+
+protected:
+
+  virtual void InitialiseProcess(const G4ParticleDefinition*);
+
+private:
+     
+  G4bool       isInitialised;
+};
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+inline 
+G4bool G4RayleighScattering::IsApplicable(const G4ParticleDefinition& p)
+{
+  return (&p == G4Gamma::Gamma());
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+  
+#endif
+ 
Index: trunk/source/processes/electromagnetic/lowenergy/include/G4ecpssrCrossSection.hh
===================================================================
--- trunk/source/processes/electromagnetic/lowenergy/include/G4ecpssrCrossSection.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/lowenergy/include/G4ecpssrCrossSection.hh	(revision 966)
@@ -0,0 +1,77 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4ecpssrCrossSection.hh,v 1.3 2008/06/03 07:29:15 gcosmo Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+// Author: Haifa Ben Abdelouahed
+//         
+//
+// History:
+// -----------
+//  21 Apr 2008   H. Ben Abdelouahed   1st implementation
+//  21 Apr 2008   MGP        Major revision according to a design iteration
+//
+// -------------------------------------------------------------------
+
+// Class description:
+// Low Energy Electromagnetic Physics, Cross section, p ionisation, K shell
+// Further documentation available from http://www.ge.infn.it/geant4/lowE
+
+// -------------------------------------------------------------------
+
+
+#ifndef G4ECPSSRCROSSSECTION_HH
+#define G4ECPSSRCROSSSECTION_HH 1
+
+#include "globals.hh"
+
+
+class G4ecpssrCrossSection 
+
+{
+public:
+
+  G4ecpssrCrossSection();
+
+  virtual ~G4ecpssrCrossSection();
+			     
+  G4double CalculateCrossSection(G4int zTarget,G4int zIncident, G4double energyIncident);//according to W.Brandt and G.Lapicki, Phys.Rev.A23(1981)
+				    
+  G4double CalculateVelocity(G4int zTarget,G4int zIncident, G4double energyIncident); 
+			      
+  G4double  ExpIntFunction(G4int n,G4double x);//Exponential Integral Function
+
+   
+
+private:
+
+
+  G4ecpssrCrossSection(const G4ecpssrCrossSection&);
+  G4ecpssrCrossSection & operator = (const G4ecpssrCrossSection &right);
+
+};
+
+#endif
Index: trunk/source/processes/electromagnetic/standard/include/G4UrbanMscModel2.hh
===================================================================
--- trunk/source/processes/electromagnetic/standard/include/G4UrbanMscModel2.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/standard/include/G4UrbanMscModel2.hh	(revision 966)
@@ -0,0 +1,238 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4UrbanMscModel2.hh,v 1.11 2008/12/18 13:01:34 gunter Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+// -------------------------------------------------------------------
+//
+//
+// GEANT4 Class header file
+//
+//
+// File name:     G4UrbanMscModel2
+//
+// Author:        Laszlo Urban
+//
+// Creation date: 06.03.2008
+//
+// Modifications:
+//
+//
+//
+// Class Description:
+//
+// Implementation of the model of multiple scattering based on
+// H.W.Lewis Phys Rev 78 (1950) 526 and L.Urban model
+
+// -------------------------------------------------------------------
+//
+
+#ifndef G4UrbanMscModel2_h
+#define G4UrbanMscModel2_h 1
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+#include "G4VMscModel.hh"
+#include "G4PhysicsTable.hh"
+#include "G4MscStepLimitType.hh"
+
+class G4ParticleChangeForMSC;
+class G4SafetyHelper;
+class G4LossTableManager;
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+class G4UrbanMscModel2 : public G4VMscModel
+{
+
+public:
+
+  G4UrbanMscModel2(const G4String& nam = "UrbanMscUni2");
+
+  virtual ~G4UrbanMscModel2();
+
+  void Initialise(const G4ParticleDefinition*, const G4DataVector&);
+
+  G4double ComputeCrossSectionPerAtom(const G4ParticleDefinition* particle,
+				      G4double KineticEnergy,
+				      G4double AtomicNumber,
+				      G4double AtomicWeight=0., 
+				      G4double cut =0.,
+				      G4double emax=DBL_MAX);
+
+  void SampleSecondaries(std::vector<G4DynamicParticle*>*, 
+			 const G4MaterialCutsCouple*,
+			 const G4DynamicParticle*,
+			 G4double,
+			 G4double);
+
+  void SampleScattering(const G4DynamicParticle*,
+			G4double safety);
+
+  G4double ComputeTruePathLengthLimit(const G4Track& track,
+				      G4PhysicsTable* theLambdaTable,
+				      G4double currentMinimalStep);
+
+  G4double ComputeGeomPathLength(G4double truePathLength);
+
+  G4double ComputeTrueStepLength(G4double geomStepLength);
+
+  G4double ComputeTheta0(G4double truePathLength,
+                         G4double KineticEnergy);
+
+private:
+
+  G4double SimpleScattering(G4double xmeanth, G4double x2meanth);
+
+  G4double SampleCosineTheta(G4double trueStepLength, G4double KineticEnergy);
+
+  G4double SampleDisplacement();
+
+  G4double LatCorrelation();
+
+  void GeomLimit(const G4Track& track);
+
+  inline G4double GetLambda(G4double kinEnergy);
+
+  inline void SetParticle(const G4ParticleDefinition*);
+
+  inline void UpdateCache();
+
+  //  hide assignment operator
+  G4UrbanMscModel2 & operator=(const  G4UrbanMscModel2 &right);
+  G4UrbanMscModel2(const  G4UrbanMscModel2&);
+
+  const G4ParticleDefinition* particle;
+  G4ParticleChangeForMSC*     fParticleChange;
+
+  G4SafetyHelper*             safetyHelper;
+  G4PhysicsTable*             theLambdaTable;
+  const G4MaterialCutsCouple* couple;
+  G4LossTableManager*         theManager;
+
+
+  G4double mass;
+  G4double charge,ChargeSquare;
+  G4double masslimite,lambdalimit,fr;
+
+  G4double taubig;
+  G4double tausmall;
+  G4double taulim;
+  G4double currentTau;
+  G4double tlimit;
+  G4double tlimitmin;
+  G4double tlimitminfix;
+  G4double tgeom;
+
+  G4double geombig;
+  G4double geommin;
+  G4double geomlimit;
+  G4double skindepth;
+  G4double smallstep;
+
+  G4double presafety;
+
+  G4double lambda0;
+  G4double lambdaeff;
+  G4double tPathLength;
+  G4double zPathLength;
+  G4double par1,par2,par3;
+
+  G4double stepmin;
+
+  G4double currentKinEnergy;
+  G4double currentRange; 
+  G4double rangeinit;
+  G4double currentRadLength;
+
+  G4double theta0max,rellossmax;
+  G4double third;
+
+  G4int    currentMaterialIndex;
+
+  G4double y;
+  G4double Zold;
+  G4double Zeff,Z2,Z23,lnZ;
+  G4double coeffth1,coeffth2;
+  G4double coeffc1,coeffc2;
+  G4double scr1ini,scr2ini,scr1,scr2;
+
+  G4bool   isInitialized;
+  G4bool   inside;
+  G4bool   insideskin;
+};
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+inline
+G4double G4UrbanMscModel2::GetLambda(G4double e)
+{
+  G4double x;
+  if(theLambdaTable) {
+    G4bool b;
+    x = ((*theLambdaTable)[currentMaterialIndex])->GetValue(e, b);
+  } else {
+    x = CrossSection(couple,particle,e);
+  }
+  if(x > DBL_MIN) x = 1./x;
+  else            x = DBL_MAX;
+  return x;
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+inline
+void G4UrbanMscModel2::SetParticle(const G4ParticleDefinition* p)
+{
+  if (p != particle) {
+    particle = p;
+    mass = p->GetPDGMass();
+    charge = p->GetPDGCharge()/eplus;
+    ChargeSquare = charge*charge;
+  }
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+inline
+void G4UrbanMscModel2::UpdateCache()                                   
+{
+    lnZ = std::log(Zeff);
+    coeffth1 = 0.885+lnZ*(0.104-0.0170*lnZ);
+    coeffth2 = 0.028+lnZ*(0.012-0.00125*lnZ);
+    coeffc1  = 2.134-lnZ*(0.1045-0.00602*lnZ);
+    coeffc2  = 0.001126-lnZ*(0.0001089+0.0000247*lnZ);
+    Z2 = Zeff*Zeff;
+    Z23 = std::exp(2.*lnZ/3.);
+    scr1     = scr1ini*Z23;
+    scr2     = scr2ini*Z2*ChargeSquare;
+  //  lastMaterial = couple->GetMaterial();
+    Zold = Zeff;
+}
+
+#endif
+
Index: trunk/source/processes/electromagnetic/standard/include/G4WentzelVIModel.hh
===================================================================
--- trunk/source/processes/electromagnetic/standard/include/G4WentzelVIModel.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/standard/include/G4WentzelVIModel.hh	(revision 966)
@@ -0,0 +1,309 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4WentzelVIModel.hh,v 1.8 2009/02/19 19:17:15 vnivanch Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+// -------------------------------------------------------------------
+//
+//
+// GEANT4 Class header file
+//
+//
+// File name:     G4WentzelVIModel
+//
+// Author:        V.Ivanchenko 
+//
+// Creation date: 09.04.2008 from G4MuMscModel
+//
+// Modifications:
+//
+//
+// Class Description:
+//
+// Implementation of the model of multiple scattering based on
+// G.Wentzel, Z. Phys. 40 (1927) 590.
+// H.W.Lewis, Phys Rev 78 (1950) 526.
+// J.M. Fernandez-Varea et al., NIM B73 (1993) 447.
+// L.Urban, CERN-OPEN-2006-077.
+
+// -------------------------------------------------------------------
+//
+
+#ifndef G4WentzelVIModel_h
+#define G4WentzelVIModel_h 1
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+#include "G4VMscModel.hh"
+#include "G4PhysicsTable.hh"
+#include "G4MscStepLimitType.hh"
+#include "G4MaterialCutsCouple.hh"
+#include "G4NistManager.hh"
+
+class G4LossTableManager;
+class G4ParticleChangeForMSC;
+//class G4SafetyHelper;
+class G4ParticleDefinition;
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+class G4WentzelVIModel : public G4VMscModel
+{
+
+public:
+
+  G4WentzelVIModel(const G4String& nam = "WentzelVIUni");
+
+  virtual ~G4WentzelVIModel();
+
+  void Initialise(const G4ParticleDefinition*, const G4DataVector&);
+
+  G4double ComputeCrossSectionPerAtom(const G4ParticleDefinition*,
+				      G4double KineticEnergy,
+				      G4double AtomicNumber,
+				      G4double AtomicWeight=0., 
+				      G4double cut = DBL_MAX,
+				      G4double emax= DBL_MAX);
+
+  void SampleScattering(const G4DynamicParticle*, G4double safety);
+
+  void SampleSecondaries(std::vector<G4DynamicParticle*>*, 
+			 const G4MaterialCutsCouple*,
+			 const G4DynamicParticle*,
+			 G4double,
+			 G4double);
+
+  G4double ComputeTruePathLengthLimit(const G4Track& track,
+				      G4PhysicsTable* theLambdaTable,
+				      G4double currentMinimalStep);
+
+  G4double ComputeGeomPathLength(G4double truePathLength);
+
+  G4double ComputeTrueStepLength(G4double geomStepLength);
+
+private:
+
+  G4double ComputeTransportXSectionPerVolume();
+
+  G4double ComputeXSectionPerVolume();
+
+  void ComputeMaxElectronScattering(G4double cut);
+
+  inline G4double GetLambda(G4double kinEnergy);
+
+  inline void SetupParticle(const G4ParticleDefinition*);
+
+  inline void SetupKinematic(G4double kinEnergy, G4double cut);
+  
+  inline void SetupTarget(G4double Z, G4double kinEnergy);
+
+  inline void DefineMaterial(const G4MaterialCutsCouple*);
+
+  //  hide assignment operator
+  G4WentzelVIModel & operator=(const  G4WentzelVIModel &right);
+  G4WentzelVIModel(const  G4WentzelVIModel&);
+
+  const G4ParticleDefinition* theProton;
+  const G4ParticleDefinition* theElectron;
+  const G4ParticleDefinition* thePositron;
+
+  G4ParticleChangeForMSC*   fParticleChange;
+
+  //  G4SafetyHelper*           safetyHelper;
+  G4PhysicsTable*           theLambdaTable;
+  G4PhysicsTable*           theLambda2Table;
+  G4LossTableManager*       theManager;
+  const G4DataVector*       currentCuts;
+
+  G4NistManager*            fNistManager;
+
+  G4double numlimit;
+  G4double tlimitminfix;
+  G4double invsqrt12;
+
+  // cash
+  G4double preKinEnergy;
+  G4double ecut;
+  G4double lambda0;
+  G4double tPathLength;
+  G4double zPathLength;
+  G4double lambdaeff;
+  G4double currentRange; 
+  G4double par1;
+  G4double par2;
+  G4double par3;
+
+  G4double xtsec;
+  std::vector<G4double> xsecn;
+  std::vector<G4double> prob;
+  G4int    nelments;
+
+  G4int    nbins;
+  G4int    nwarnings;
+  G4int    nwarnlimit;
+
+  G4int    currentMaterialIndex;
+
+  const G4MaterialCutsCouple* currentCouple;
+  const G4Material* currentMaterial;
+
+  // single scattering parameters
+  G4double coeff;
+  G4double constn;
+  G4double cosThetaMin;
+  G4double cosThetaMax;
+  G4double cosTetMaxNuc;
+  G4double cosTetMaxNuc2;
+  G4double cosTetMaxElec;
+  G4double cosTetMaxElec2;
+  G4double q2Limit;
+  G4double alpha2;
+  G4double a0;
+
+  // projectile
+  const G4ParticleDefinition* particle;
+
+  G4double chargeSquare;
+  G4double spin;
+  G4double mass;
+  G4double tkin;
+  G4double mom2;
+  G4double invbeta2;
+  G4double etag;
+  G4double lowEnergyLimit;
+
+  // target
+  G4double targetZ;
+  G4double screenZ;
+  G4double formfactA;
+  G4double FF[100];
+
+  // flags
+  G4bool   isInitialized;
+  G4bool   inside;
+};
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+inline
+void G4WentzelVIModel::DefineMaterial(const G4MaterialCutsCouple* cup) 
+{ 
+  if(cup != currentCouple) {
+    currentCouple = cup;
+    currentMaterial = cup->GetMaterial();
+    currentMaterialIndex = currentCouple->GetIndex(); 
+  }
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+inline
+G4double G4WentzelVIModel::GetLambda(G4double e)
+{
+  G4double x;
+  if(theLambdaTable) {
+    G4bool b;
+    x = ((*theLambdaTable)[currentMaterialIndex])->GetValue(e, b);
+  } else {
+    x = CrossSection(currentCouple,particle,e,
+		     (*currentCuts)[currentMaterialIndex]);
+  }
+  if(x > DBL_MIN) x = 1./x;
+  else            x = DBL_MAX;
+  return x;
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+inline 
+void G4WentzelVIModel::SetupParticle(const G4ParticleDefinition* p)
+{
+  // Initialise mass and charge
+  if(p != particle) {
+    particle = p;
+    mass = particle->GetPDGMass();
+    spin = particle->GetPDGSpin();
+    G4double q = particle->GetPDGCharge()/eplus;
+    chargeSquare = q*q;
+    tkin = 0.0;
+    lowEnergyLimit = keV*mass/electron_mass_c2;
+  }
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+inline void G4WentzelVIModel::SetupKinematic(G4double ekin, G4double cut)
+{
+  if(ekin != tkin || ecut != cut) {
+    tkin  = ekin;
+    mom2  = tkin*(tkin + 2.0*mass);
+    invbeta2 = 1.0 +  mass*mass/mom2;
+    cosTetMaxNuc = cosThetaMax;
+    if(ekin <= 10.*cut && mass < MeV) {
+      cosTetMaxNuc = ekin*(cosThetaMax + 1.0)/(10.*cut) - 1.0;
+    }
+    ComputeMaxElectronScattering(cut);
+  } 
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+  
+inline void G4WentzelVIModel::SetupTarget(G4double Z, G4double e)
+{
+  if(Z != targetZ || e != etag) {
+    etag    = e; 
+    targetZ = Z;
+    G4int iz= G4int(Z);
+    if(iz > 99) iz = 99;
+    G4double x = fNistManager->GetZ13(iz);
+    screenZ = a0*x*x/mom2;
+    if(iz > 1) screenZ *=(1.13 + 3.76*invbeta2*Z*Z*chargeSquare*alpha2);
+    //    screenZ = a0*x*x*(1.13 + 3.76*Z*Z*chargeSquare*alpha2)/mom2;
+    // A.V. Butkevich et al., NIM A 488 (2002) 282
+    formfactA = FF[iz];
+    if(formfactA == 0.0) {
+      x = fNistManager->GetA27(iz); 
+      formfactA = constn*x*x;
+      FF[iz] = formfactA;
+    }
+    formfactA *= mom2;
+    cosTetMaxNuc2 = cosTetMaxNuc;
+    /*
+    G4double ee = 10.*eV*Z;
+    if(1 == iz) ee *= 2.0;
+    G4double z = std::min(cosTetMaxElec, 1.0 - std::max(ecut,ee)*amu_c2
+			  *fNistManager->GetAtomicMassAmu(iz)/mom2);
+    cosTetMaxElec2 = std::max(cosTetMaxNuc2, z);
+    */
+    cosTetMaxElec2 = cosTetMaxElec;
+  } 
+} 
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+#endif
+
Index: trunk/source/processes/electromagnetic/standard/include/G4eBremsstrahlungRelModel.hh
===================================================================
--- trunk/source/processes/electromagnetic/standard/include/G4eBremsstrahlungRelModel.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/standard/include/G4eBremsstrahlungRelModel.hh	(revision 966)
@@ -0,0 +1,251 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4eBremsstrahlungRelModel.hh,v 1.11 2009/02/20 12:06:37 vnivanch Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+// -------------------------------------------------------------------
+//
+// GEANT4 Class header file
+//
+//
+// File name:     G4eBremsstrahlungRelModel
+//                extention of standard G4eBremsstrahlungModel
+//
+// Author:        Andreas Schaelicke 
+//
+// Creation date: 28.03.2008
+//
+// Modifications:
+//
+//
+// Class Description:
+//
+// Implementation of energy loss for gamma emission by electrons and
+// positrons including an improved version of the LPM effect
+
+// -------------------------------------------------------------------
+//
+
+#ifndef G4eBremsstrahlungRelModel_h
+#define G4eBremsstrahlungRelModel_h 1
+
+#include "G4VEmModel.hh"
+#include "G4NistManager.hh"
+
+class G4ParticleChangeForLoss;
+class G4PhysicsVector;
+
+class G4eBremsstrahlungRelModel : public G4VEmModel
+{
+
+public:
+
+  G4eBremsstrahlungRelModel(const G4ParticleDefinition* p = 0, 
+			    const G4String& nam = "eBremRel");
+
+  virtual ~G4eBremsstrahlungRelModel();
+
+  virtual void Initialise(const G4ParticleDefinition*, const G4DataVector&);
+
+  virtual G4double MinEnergyCut(const G4ParticleDefinition*, 
+				const G4MaterialCutsCouple*);
+
+  virtual G4double ComputeDEDXPerVolume(const G4Material*,
+					const G4ParticleDefinition*,
+					G4double kineticEnergy,
+					G4double cutEnergy);
+					
+  virtual G4double ComputeCrossSectionPerAtom(const G4ParticleDefinition*,
+					      G4double tkin, 
+					      G4double Z,   G4double,
+					      G4double cutEnergy,
+					      G4double maxEnergy = DBL_MAX);
+  
+  virtual void SampleSecondaries(std::vector<G4DynamicParticle*>*,
+				 const G4MaterialCutsCouple*,
+				 const G4DynamicParticle*,
+				 G4double cutEnergy,
+				 G4double maxEnergy);
+
+  virtual void SetupForMaterial(const G4ParticleDefinition*,
+                                const G4Material*,G4double);
+
+  inline void SetLPMconstant(G4double val);
+  inline G4double LPMconstant() const;
+
+private:
+
+  void InitialiseConstants();
+
+  void CalcLPMFunctions(G4double gammaEnergy);
+
+  G4double ComputeBremLoss(G4double cutEnergy);
+
+  G4double ComputeXSectionPerAtom(G4double cutEnergy);
+
+  G4double ComputeDXSectionPerAtom(G4double gammaEnergy);
+
+  G4double ComputeRelDXSectionPerAtom(G4double gammaEnergy);
+
+  void SetParticle(const G4ParticleDefinition* p);
+
+  // * fast inline functions *
+  inline void SetCurrentElement(const G4double);
+
+  inline G4double Phi1(G4double,G4double);
+  inline G4double Phi1M2(G4double,G4double);
+  inline G4double Psi1(G4double,G4double);
+  inline G4double Psi1M2(G4double,G4double);
+
+  // hide assignment operator
+  G4eBremsstrahlungRelModel & operator=(const  G4eBremsstrahlungRelModel &right);
+  G4eBremsstrahlungRelModel(const  G4eBremsstrahlungRelModel&);
+
+protected:
+
+  G4NistManager*              nist;
+  const G4ParticleDefinition* particle;
+  G4ParticleDefinition*       theGamma;
+  G4ParticleChangeForLoss*    fParticleChange;
+
+  static const G4double xgi[8], wgi[8];
+  static const G4double Fel_light[5];
+  static const G4double Finel_light[5];
+
+  G4double minThreshold;
+
+  // cash
+  G4double particleMass;
+  G4double kinEnergy;
+  G4double totalEnergy;
+  G4double currentZ;
+  G4double z13, z23, lnZ;
+  G4double Fel, Finel, fCoulomb, fMax; 
+  G4double densityFactor;
+  G4double densityCorr;
+
+  // LPM effect
+  G4double lpmEnergy;
+  G4PhysicsVector  *fXiLPM, *fPhiLPM, *fGLPM;
+  G4double xiLPM, phiLPM, gLPM;
+
+  // critical gamma energies
+  G4double klpm, kp;
+
+  G4bool   isElectron;
+
+private:
+  // consts
+  G4double highKinEnergy;
+  G4double lowKinEnergy;
+  G4double fMigdalConstant;
+  G4double fLPMconstant;
+  G4double bremFactor;
+  G4double energyThresholdLPM;
+  G4double facFel, facFinel;
+  G4double preS1,logTwo;
+
+  G4bool   use_completescreening;
+
+  G4bool   isInitialised;
+};
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+inline void G4eBremsstrahlungRelModel::SetCurrentElement(const G4double Z)
+{
+  if(Z != currentZ) {
+    currentZ = Z;
+
+    G4int iz = G4int(Z);
+    z13 = nist->GetZ13(iz);
+    z23 = z13*z13;
+    lnZ = nist->GetLOGZ(iz);
+
+    if (iz <= 4) {
+      Fel = Fel_light[iz];  
+      Finel = Finel_light[iz] ; 
+    }
+    else {
+      Fel = facFel - lnZ/3. ;
+      Finel = facFinel - 2.*lnZ/3. ;
+    }
+
+    fCoulomb=GetCurrentElement()->GetfCoulomb();
+    fMax   =  Fel-fCoulomb + Finel/currentZ  +  (1.+1./currentZ)/12.;
+  }
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+
+inline G4double G4eBremsstrahlungRelModel::Phi1(G4double gg, G4double)
+{
+  //       Thomas-Fermi FF from Tsai, eq.(3.38) for Z>=5
+  return 20.863 - 2.*std::log(1. + sqr(0.55846*gg) )
+    - 4.*( 1. - 0.6*std::exp(-0.9*gg) - 0.4*std::exp(-1.5*gg) );
+}
+
+inline G4double G4eBremsstrahlungRelModel::Phi1M2(G4double gg, G4double)
+{
+  //       Thomas-Fermi FF from Tsai, eq. (3.39) for Z>=5
+  // return Phi1(gg,Z) - 
+  return 2./(3.*(1. + 6.5*gg +6.*gg*gg) );
+}
+
+inline G4double G4eBremsstrahlungRelModel::Psi1(G4double eps, G4double)
+{
+  //       Thomas-Fermi FF from Tsai, eq.(3.40) for Z>=5 
+  return 28.340 - 2.*std::log(1. + sqr(3.621*eps) )
+    - 4.*( 1. - 0.7*std::exp(-8*eps) - 0.3*std::exp(-29.*eps) );
+}
+
+inline G4double G4eBremsstrahlungRelModel::Psi1M2(G4double eps, G4double)
+{
+  //       Thomas-Fermi FF from Tsai, eq. (3.41) for Z>=5
+  return  2./(3.*(1. + 40.*eps +400.*eps*eps) );
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+inline 
+void G4eBremsstrahlungRelModel::SetLPMconstant(G4double val) 
+{
+  fLPMconstant = val;
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+inline 
+G4double G4eBremsstrahlungRelModel::LPMconstant() const 
+{
+  return fLPMconstant;
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+
+#endif
Index: trunk/source/processes/electromagnetic/standard/include/G4eMultipleScattering.hh
===================================================================
--- trunk/source/processes/electromagnetic/standard/include/G4eMultipleScattering.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/standard/include/G4eMultipleScattering.hh	(revision 966)
@@ -0,0 +1,106 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4eMultipleScattering.hh,v 1.2 2008/03/11 12:03:43 vnivanch Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+// -----------------------------------------------------------------------------
+//
+// GEANT4 Class header file
+//
+// File name:     G4eMultipleScattering
+//
+// Author:        Vladimir Ivanchenko
+//
+// Creation date: 10 March 2001
+// 
+// Modifications:
+//
+//
+//------------------------------------------------------------------------------
+//
+
+// class description
+//
+//  The class simulates the multiple scattering for e+ and e-
+//
+// class description - end
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+#ifndef G4eMultipleScattering_h
+#define G4eMultipleScattering_h 1
+
+#include "G4VMultipleScattering.hh"
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+class G4VMscModel;
+
+class G4eMultipleScattering : public G4VMultipleScattering
+
+{
+public:    // with description
+
+  G4eMultipleScattering(const G4String& processName="msc");
+
+  virtual ~G4eMultipleScattering();
+
+  // returns true for charged particles, false otherwise
+  G4bool IsApplicable (const G4ParticleDefinition& p);
+
+  // Print few lines of informations about the process: validity range,
+  void PrintInfo();
+
+  // geom. step length distribution should be sampled or not
+  void Setsamplez(G4bool value) { samplez = value;};
+
+  // to reduce the energy/step dependence
+  void Setdtrl(G4double value) { dtrl = value;};
+
+  // 'soften' step limitation above lambdalimit
+  void SetLambdalimit(G4double value) { lambdalimit = value;};
+
+protected:
+
+  // This function initialise models
+  void InitialiseProcess(const G4ParticleDefinition*);
+
+private:        // data members
+
+  G4VMscModel* mscUrban;
+
+  G4double lambdalimit;
+  G4double dtrl;
+
+  G4bool   samplez;
+  G4bool   isInitialized;
+
+};
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+#endif
Index: trunk/source/processes/electromagnetic/utils/include/G4ElectronIonPair.hh
===================================================================
--- trunk/source/processes/electromagnetic/utils/include/G4ElectronIonPair.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/utils/include/G4ElectronIonPair.hh	(revision 966)
@@ -0,0 +1,174 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4ElectronIonPair.hh,v 1.2 2008/10/17 14:46:16 vnivanch Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+//
+#ifndef G4ElectronIonPair_h
+#define G4ElectronIonPair_h 1
+
+// -------------------------------------------------------------
+//
+// GEANT4 Class header file
+//
+//
+// File name:     G4ElectronIonPair
+//
+// Author:        Vladimir Ivanchenko
+//
+// Creation date: 08.07.2008
+//
+// Modifications:
+//
+//
+// Class Description:
+//   Compution on number of electon-ion or electorn-hole pairs
+//   at the step of a particle and sampling ionisation points 
+//   in space
+//
+// Based on ICRU Report 31, 1979
+// "Average Energy Required to Produce an Ion Pair"  
+// 
+// -------------------------------------------------------------
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+#include "globals.hh"
+#include "G4Step.hh"
+#include "G4ParticleDefinition.hh"
+#include "G4ThreeVector.hh"
+#include "G4TrackVector.hh"
+#include "G4VProcess.hh"
+#include <vector>
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+class G4Material;
+
+class G4ElectronIonPair
+{
+public: 
+
+  G4ElectronIonPair();
+
+  virtual ~G4ElectronIonPair();
+
+  // compute mean number of ionisation points at a step
+  G4double MeanNumberOfIonsAlongStep(const G4ParticleDefinition*, 
+				     const G4Material*,
+				     G4double edepTotal,
+				     G4double edepNIEL = 0.0);
+
+  inline G4double MeanNumberOfIonsAlongStep(const G4Step*); 
+
+  // returns pointer to the new vector of positions of
+  // ionisation points in the World coordinate system 
+  std::vector<G4ThreeVector>* 
+  SampleIonsAlongStep(const G4ThreeVector& prePosition,
+		      const G4ThreeVector& postPosition,
+		      G4double numberOfIonisations);
+
+  std::vector<G4ThreeVector>* SampleIonsAlongStep(const G4Step*);
+
+  // compute number of holes in the atom after PostStep interaction
+  G4int ResidualeChargePostStep(const G4ParticleDefinition*,
+				const G4TrackVector* secondary = 0,
+				G4int processSubType = -1);
+
+  inline G4int ResidualeChargePostStep(const G4Step*);
+
+  // find mean energies per ionisation 
+  G4double FindG4MeanEnergyPerIonPair(const G4Material*);
+
+  // dump mean energies per ionisation used in run time
+  void DumpMeanEnergyPerIonPair();
+
+  // dump G4 list
+  void DumpG4MeanEnergyPerIonPair();
+
+  inline void SetVerbose(G4int);
+
+private:
+
+  // hide assignment operator
+  G4ElectronIonPair & operator=(const G4ElectronIonPair &right);
+  G4ElectronIonPair(const G4ElectronIonPair&);
+
+  G4double FindMeanEnergyPerIonPair(const G4Material*);
+
+  void Initialise();
+
+  const G4ParticleDefinition* gamma;
+
+  // cash
+  const G4Material*           curMaterial;
+  G4double                    curMeanEnergy;
+
+  G4int    verbose;             
+  G4int    nMaterials;
+
+  // list of G4 NIST materials with mean energy per ion defined 
+  std::vector<G4double>       g4MatData;
+  std::vector<G4String>       g4MatNames;
+
+};
+
+inline G4double 
+G4ElectronIonPair::MeanNumberOfIonsAlongStep(const G4Step* step)
+{
+  return MeanNumberOfIonsAlongStep(step->GetTrack()->GetDefinition(),
+				   step->GetPreStepPoint()->GetMaterial(),
+				   step->GetTotalEnergyDeposit(),
+				   step->GetNonIonizingEnergyDeposit());
+}
+
+inline std::vector<G4ThreeVector>* 
+G4ElectronIonPair::SampleIonsAlongStep(const G4Step* step)
+{
+  return SampleIonsAlongStep(step->GetPreStepPoint()->GetPosition(),
+			     step->GetPostStepPoint()->GetPosition(),
+			     MeanNumberOfIonsAlongStep(step));
+}
+
+inline 
+G4int G4ElectronIonPair::ResidualeChargePostStep(const G4Step* step)
+{
+  G4int subtype = -1;
+  const G4VProcess* proc = step->GetPostStepPoint()->GetProcessDefinedStep();
+  if(proc) subtype = proc->GetProcessSubType();
+  return ResidualeChargePostStep(step->GetTrack()->GetDefinition(),
+				 step->GetSecondary(),
+				 subtype);
+}
+
+inline void G4ElectronIonPair::SetVerbose(G4int val)
+{
+  verbose = val;
+}
+
+#endif
+
Index: trunk/source/processes/electromagnetic/utils/include/G4EmConfigurator.hh
===================================================================
--- trunk/source/processes/electromagnetic/utils/include/G4EmConfigurator.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/utils/include/G4EmConfigurator.hh	(revision 966)
@@ -0,0 +1,140 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4EmConfigurator.hh,v 1.2 2008/11/21 12:30:29 vnivanch Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+// -------------------------------------------------------------------
+//
+// GEANT4 Class header file
+//
+// File name:     G4EmConfigurator
+//
+// Author:        Vladimir Ivanchenko
+//
+// Creation date: 14.07.2008
+//
+// Modifications:
+//
+// Class Description:
+//
+// This class provides configuration EM models for 
+// particles/processes/regions
+//
+
+// -------------------------------------------------------------------
+//
+
+#ifndef G4EmConfigurator_h
+#define G4EmConfigurator_h 1
+
+#include "globals.hh"
+#include "G4VEmModel.hh"
+#include "G4VEmFluctuationModel.hh"
+#include <vector>
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+class G4EmConfigurator 
+{
+public: 
+  
+  G4EmConfigurator();
+ 
+  ~G4EmConfigurator();
+
+  // Add EM model to the list of extra models potentially to be 
+  // declared for the G4Region and energy interval
+  // 
+  void AddExtraEmModel(const G4String& particleName,
+		       G4VEmModel*, G4VEmFluctuationModel* fm = 0); 
+
+  // Declare EM model for particle type and process to 
+  // be active for the G4Region and energy interval
+  // The model should be previously added to the configurator 
+  // or be "dummy"
+  // 
+  void AddModelForRegion(const G4String& particleName,
+                         const G4String& processName,
+                         const G4String& modelName,
+                         const G4String& regionName = "",
+                         G4double emin = 0.0,
+                         G4double emax = DBL_MAX,
+                         const G4String& flucModelName = "");
+
+  // Set EM model for particle type and process to 
+  // be active for the G4Region and energy interval
+  //
+  void SetExtraEmModel(const G4String& particleName,
+		       const G4String& processName,
+		       G4VEmModel*,
+		       const G4String& regionName = "",
+		       G4double emin = 0.0,
+		       G4double emax = DBL_MAX,
+		       G4VEmFluctuationModel* fm = 0); 
+
+  // Add all previously declared models to corresponding processes
+  void AddModels();
+
+private:
+
+  void SetModelForRegion(const G4String& particleName,
+                         const G4String& processName,
+                         const G4String& modelName,
+                         const G4String& regionName,
+                         const G4String& flucModelName,
+                         G4double emin,
+                         G4double emax);
+
+  // hide assignment operator
+  G4EmConfigurator & operator=(const G4EmConfigurator &right);
+  G4EmConfigurator(const G4EmConfigurator&);
+
+  std::vector<G4String> particles;  
+  std::vector<G4String> processes;  
+  std::vector<G4String> models;  
+  std::vector<G4String> regions;  
+  std::vector<G4String> flucModels;  
+  std::vector<G4double> lowEnergy;
+  std::vector<G4double> highEnergy;
+  
+  std::vector<G4String> particleList;  
+  std::vector<G4VEmModel*> modelList;
+  std::vector<G4VEmFluctuationModel*> flucModelList;
+
+  G4int index;
+};
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+#endif
+
+
+
+
+
+
+
+
Index: trunk/source/processes/electromagnetic/utils/include/G4EmElementSelector.hh
===================================================================
--- trunk/source/processes/electromagnetic/utils/include/G4EmElementSelector.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/utils/include/G4EmElementSelector.hh	(revision 966)
@@ -0,0 +1,131 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4EmElementSelector.hh,v 1.2 2008/07/22 15:55:15 vnivanch Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+// -------------------------------------------------------------------
+//
+// GEANT4 Class header file
+//
+//
+// File name:     G4EmElementSelector
+//
+// Author:        Vladimir Ivanchenko
+//
+// Creation date: 29.05.2008
+//
+// Modifications:
+//
+//
+// Class Description:
+//
+// Generic helper class for the random selection of an element
+
+// -------------------------------------------------------------------
+//
+
+#ifndef G4EmElementSelector_h
+#define G4EmElementSelector_h 1
+
+#include "globals.hh"
+#include "G4ParticleDefinition.hh"
+#include "G4Material.hh"
+#include "G4Element.hh"
+#include "G4ElementVector.hh"
+#include "G4PhysicsLogVector.hh"
+#include "Randomize.hh"
+#include <vector>
+
+class G4VEmModel;
+
+class G4EmElementSelector
+{
+
+public:
+
+  G4EmElementSelector(G4VEmModel*, const G4Material*, G4int bins, 
+		      G4double emin, G4double emax, 
+		      G4bool spline = true);
+
+  ~G4EmElementSelector();
+
+  void Initialise(const G4ParticleDefinition*, G4double cut = 0.0);
+
+  void Dump(const G4ParticleDefinition* p = 0);
+
+  inline const G4Element* SelectRandomAtom(G4double kineticEnergy);
+
+  inline const G4Material* GetMaterial() const;
+
+private:
+
+  //  hide assignment operator
+  G4EmElementSelector & operator=(const  G4EmElementSelector &right);
+  G4EmElementSelector(const  G4EmElementSelector&);
+
+  G4VEmModel*       model;
+  const G4Material* material;
+  const G4ElementVector* theElementVector;
+
+  G4int    nElmMinusOne;
+  G4int    nbins;
+
+  G4double cutEnergy;
+  G4double lowEnergy;
+  G4double highEnergy;
+
+  std::vector<G4PhysicsLogVector*> xSections;
+  
+};
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
+
+inline const G4Element* G4EmElementSelector::SelectRandomAtom(G4double e)
+{
+  const G4Element* elm = (*theElementVector)[nElmMinusOne];
+  if (nElmMinusOne > 0) {
+    G4bool b;
+    G4double x = G4UniformRand();
+    for(G4int i=0; i<nElmMinusOne; i++) {
+      if (x <= (xSections[i])->GetValue(e,b)) {
+	elm = (*theElementVector)[i];
+	break;
+      }
+    }
+  }
+  return elm;
+}
+
+inline const G4Material* G4EmElementSelector::GetMaterial() const
+{
+  return material;
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
+
+#endif
+
Index: trunk/source/processes/electromagnetic/utils/include/G4EmProcessSubType.hh
===================================================================
--- trunk/source/processes/electromagnetic/utils/include/G4EmProcessSubType.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/utils/include/G4EmProcessSubType.hh	(revision 966)
@@ -0,0 +1,70 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+//
+// $Id: G4EmProcessSubType.hh,v 1.9 2008/12/18 13:01:42 gunter Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+//---------------------------------------------------------------
+//
+// G4EmProcessSubType.hh
+//
+// Class Description:
+//   This is an enumerator to define sub-type of electro-magnetic
+//   processes
+//
+// Creation date: 23.09.2008
+// Modifications:
+//
+//---------------------------------------------------------------
+
+#ifndef G4EmProcessSubType_h
+#define G4EmProcessSubType_h 1
+
+enum G4EmProcessSubType 
+{ 
+  fCoulombScattering = 1, 
+  fIonisation = 2, 
+  fBremsstrahlung = 3, 
+  fPairProdByCharged = 4,
+  fAnnihilation = 5, 
+  fAnnihilationToMuMu = 6,
+  fAnnihilationToHadrons = 7,
+
+  fMultipleScattering = 10, 
+  
+  fRayleigh = 11,
+  fPhotoElectricEffect = 12,
+  fComptonScattering = 13,
+  fGammaConversion = 14,
+  fGammaConversionToMuMu = 15,
+ 
+  fCerenkov = 21,
+  fScintillation = 22,
+  fSynchrotronRadiation = 23,
+  fTransitionRadiation = 24  
+};
+
+#endif
Index: trunk/source/processes/electromagnetic/utils/include/G4EmSaturation.hh
===================================================================
--- trunk/source/processes/electromagnetic/utils/include/G4EmSaturation.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/utils/include/G4EmSaturation.hh	(revision 966)
@@ -0,0 +1,152 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4EmSaturation.hh,v 1.6 2008/03/17 11:27:32 vnivanch Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+//
+#ifndef G4EmSaturation_h
+#define G4EmSaturation_h 1
+
+// -------------------------------------------------------------
+//
+// GEANT4 Class header file
+//
+//
+// File name:     G4EmSaturation
+//
+// Author:        Vladimir Ivanchenko
+//
+// Creation date: 18.02.2008
+//
+// Modifications:
+//
+//
+// Class Description:
+//   Compution on saturation effect, which reduce visible energy 
+//   deposition at the step. Default implementation takes into 
+//   account Birks effect. Birks coefficients for some materials
+//   from G4 database on materials are provided
+// 
+// -------------------------------------------------------------
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+#include "globals.hh"
+#include "G4Step.hh"
+#include "G4ParticleDefinition.hh"
+#include <vector>
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+class G4LossTableManager;
+class G4NistManager;
+class G4MaterialCutsCouple;
+class G4Material;
+
+class G4EmSaturation
+{
+public: 
+
+  G4EmSaturation();
+  virtual ~G4EmSaturation();
+
+  G4double VisibleEnergyDeposition(const G4ParticleDefinition*, 
+				   const G4MaterialCutsCouple*,
+				   G4double length, 
+				   G4double edepTotal,
+				   G4double edepNIEL = 0.0);
+
+  inline G4double VisibleEnergyDeposition(const G4Step*); 
+
+  // find and Birks coefficient 
+  G4double FindG4BirksCoefficient(const G4Material*);
+
+  inline void SetVerbose(G4int);
+
+  // dump coeffitients used in run time
+  void DumpBirksCoefficients();
+
+  // dump G4 list
+  void DumpG4BirksCoefficients();
+
+private:
+
+  // hide assignment operator
+  G4EmSaturation & operator=(const G4EmSaturation &right);
+  G4EmSaturation(const G4EmSaturation&);
+
+  G4double FindBirksCoefficient(const G4Material*);
+
+  void Initialise();
+
+  const G4ParticleDefinition* gamma;
+  const G4ParticleDefinition* electron;
+  const G4ParticleDefinition* neutron;
+  const G4ParticleDefinition* proton;
+  G4LossTableManager*         manager;
+  G4NistManager*              nist;
+
+  // cash
+  const G4Material*           curMaterial;
+  G4double                    curBirks;
+  G4double                    curRatio;
+  G4double                    curChargeSq;
+
+  G4int    verbose;             
+  G4int    nMaterials;
+  G4int    nG4Birks;
+
+  // list of materials used in run time
+  std::vector<const G4Material*>    matPointers;
+  std::vector<G4String>             matNames;
+  std::vector<G4double>             massFactors;
+  std::vector<G4double>             effCharges;
+
+  // list of G4 materials 
+  std::vector<G4double>             g4MatData;
+  std::vector<G4String>             g4MatNames;
+
+};
+
+inline void G4EmSaturation::SetVerbose(G4int val)
+{
+  verbose = val;
+}
+
+inline G4double G4EmSaturation::VisibleEnergyDeposition(
+                const G4Step* step)
+{
+  G4Track* track = step->GetTrack();
+  return VisibleEnergyDeposition(track->GetDefinition(),
+                                 track->GetMaterialCutsCouple(),
+				 step->GetStepLength(),
+                                 step->GetTotalEnergyDeposit(),
+                                 step->GetNonIonizingEnergyDeposit());
+}
+
+#endif
+
Index: trunk/source/processes/electromagnetic/utils/include/G4VMscModel.hh
===================================================================
--- trunk/source/processes/electromagnetic/utils/include/G4VMscModel.hh	(revision 966)
+++ trunk/source/processes/electromagnetic/utils/include/G4VMscModel.hh	(revision 966)
@@ -0,0 +1,207 @@
+//
+// ********************************************************************
+// * License and Disclaimer                                           *
+// *                                                                  *
+// * The  Geant4 software  is  copyright of the Copyright Holders  of *
+// * the Geant4 Collaboration.  It is provided  under  the terms  and *
+// * conditions of the Geant4 Software License,  included in the file *
+// * LICENSE and available at  http://cern.ch/geant4/license .  These *
+// * include a list of copyright holders.                             *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.  Please see the license in the file  LICENSE  and URL above *
+// * for the full disclaimer and the limitation of liability.         *
+// *                                                                  *
+// * This  code  implementation is the result of  the  scientific and *
+// * technical work of the GEANT4 collaboration.                      *
+// * By using,  copying,  modifying or  distributing the software (or *
+// * any work based  on the software)  you  agree  to acknowledge its *
+// * use  in  resulting  scientific  publications,  and indicate your *
+// * acceptance of all terms of the Geant4 Software license.          *
+// ********************************************************************
+//
+// $Id: G4VMscModel.hh,v 1.8 2009/02/24 09:56:03 vnivanch Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
+//
+// -------------------------------------------------------------------
+//
+// GEANT4 Class header file
+//
+//
+// File name:     G4VMscModel
+//
+// Author:        Vladimir Ivanchenko
+//
+// Creation date: 07.03.2008
+//
+// Modifications:
+//
+//
+// Class Description:
+//
+// General interface to msc models
+
+// -------------------------------------------------------------------
+//
+
+#ifndef G4VMscModel_h
+#define G4VMscModel_h 1
+
+#include "G4VEmModel.hh"
+#include "G4MscStepLimitType.hh"
+#include "globals.hh"
+#include "G4ThreeVector.hh"
+#include "G4Track.hh"
+#include "G4SafetyHelper.hh"
+
+class G4ParticleChangeForMSC;
+
+class G4VMscModel : public G4VEmModel
+{
+
+public:
+
+  G4VMscModel(const G4String& nam);
+
+  virtual ~G4VMscModel();
+
+  // empty 
+  virtual void SampleSecondaries(std::vector<G4DynamicParticle*>*,
+				 const G4MaterialCutsCouple*,
+				 const G4DynamicParticle*,
+				 G4double tmin,
+				 G4double tmax);
+
+  //================================================================
+  //  Set parameters of multiple scattering models
+  //================================================================
+ 
+  inline void SetStepLimitType(G4MscStepLimitType);
+
+  inline void SetLateralDisplasmentFlag(G4bool val);
+
+  inline void SetRangeFactor(G4double);
+
+  inline void SetGeomFactor(G4double);
+
+  inline void SetSkin(G4double);
+
+  inline void SetSampleZ(G4bool);
+
+protected:
+
+  // initialisation of interface with geometry
+  void InitialiseSafetyHelper();
+
+  // shift point of the track PostStep 
+  void ComputeDisplacement(G4ParticleChangeForMSC*,  
+			   const G4ThreeVector& displDir,
+                           G4double displacement,
+			   G4double postsafety);
+
+  // compute safety
+  inline G4double ComputeSafety(const G4ThreeVector& position, G4double limit);
+
+  // compute linear distance to a geometry boundary
+  inline G4double ComputeGeomLimit(const G4Track& position, G4double& presafety, 
+				   G4double limit);
+
+private:
+
+  //  hide assignment operator
+  G4VMscModel & operator=(const  G4VMscModel &right);
+  G4VMscModel(const  G4VMscModel&);
+
+  G4SafetyHelper* safetyHelper;
+
+protected:
+
+  G4double facrange;
+  G4double facgeom;
+  G4double facsafety;
+  G4double skin;
+  G4double dtrl;
+  G4double lambdalimit;
+  G4double geommax;
+
+  G4MscStepLimitType steppingAlgorithm;
+
+  G4bool   samplez;
+  G4bool   latDisplasment;
+
+};
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+inline void G4VMscModel::SetLateralDisplasmentFlag(G4bool val)
+{
+  latDisplasment = val;
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+inline void G4VMscModel::SetSkin(G4double val)
+{
+  skin = val;
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+inline void G4VMscModel::SetRangeFactor(G4double val)
+{
+  facrange = val;
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+inline void G4VMscModel::SetGeomFactor(G4double val)
+{
+  facgeom = val;
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+inline void G4VMscModel::SetStepLimitType(G4MscStepLimitType val)
+{
+  steppingAlgorithm = val;
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+inline void G4VMscModel::SetSampleZ(G4bool val)
+{
+  samplez = val;
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+inline G4double G4VMscModel::ComputeSafety(const G4ThreeVector& position, 
+					   G4double)
+{
+  return safetyHelper->ComputeSafety(position);
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+inline G4double G4VMscModel::ComputeGeomLimit(const G4Track& track, 
+					      G4double& presafety, 
+					      G4double limit)
+{
+  G4double res = geommax;
+  if(track.GetVolume() != safetyHelper->GetWorldVolume()) {
+    res = safetyHelper->CheckNextStep(
+          track.GetStep()->GetPreStepPoint()->GetPosition(),
+	  track.GetMomentumDirection(),
+	  limit, presafety);
+  }
+  return res;
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+
+#endif
+
