Index: trunk/source/processes/electromagnetic/standard/src/G4ionIonisation.cc
===================================================================
--- trunk/source/processes/electromagnetic/standard/src/G4ionIonisation.cc	(revision 819)
+++ trunk/source/processes/electromagnetic/standard/src/G4ionIonisation.cc	(revision 961)
@@ -24,6 +24,6 @@
 // ********************************************************************
 //
-// $Id: G4ionIonisation.cc,v 1.45.2.2 2008/04/25 00:34:55 vnivanch Exp $
-// GEANT4 tag $Name: geant4-09-01-patch-02 $
+// $Id: G4ionIonisation.cc,v 1.66 2009/02/20 12:06:37 vnivanch Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
 //
 // -------------------------------------------------------------------
@@ -55,4 +55,5 @@
 // 16-05-07 Add data for light ion stopping only for GenericIon (V.Ivantchenko)
 // 07-11-07 Fill non-ionizing energy loss (V.Ivantchenko)
+// 12-09-08 Removed InitialiseMassCharge and CorrectionsAlongStep (VI)
 //
 //
@@ -65,12 +66,14 @@
 #include "G4Electron.hh"
 #include "G4Proton.hh"
+//#include "G4Alpha.hh"
 #include "G4GenericIon.hh"
 #include "G4BraggModel.hh"
 #include "G4BraggIonModel.hh"
 #include "G4BetheBlochModel.hh"
-#include "G4IonFluctuations.hh"
 #include "G4UnitsTable.hh"
 #include "G4LossTableManager.hh"
 #include "G4WaterStopping.hh"
+#include "G4EmCorrections.hh"
+#include "G4IonFluctuations.hh"
 
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -80,6 +83,6 @@
 G4ionIonisation::G4ionIonisation(const G4String& name)
   : G4VEnergyLossProcess(name),
+    corr(0),
     theParticle(0),
-    theBaseParticle(0),
     isInitialised(false),
     stopDataActive(true),
@@ -89,5 +92,6 @@
   SetStepFunction(0.1, 0.1*mm);
   SetIntegral(true);
-  SetVerboseLevel(1);
+  SetProcessSubType(fIonisation);
+  //  SetVerboseLevel(1);
   corr = G4LossTableManager::Instance()->EmCorrections();
 }
@@ -100,43 +104,69 @@
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 
+G4bool G4ionIonisation::IsApplicable(const G4ParticleDefinition& p)
+{
+  return (p.GetPDGCharge() != 0.0 && !p.IsShortLived() &&
+          p.GetParticleType() == "nucleus");
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+G4double G4ionIonisation::MinPrimaryEnergy(const G4ParticleDefinition* p, 
+					   const G4Material*, 
+					   G4double cut)
+{
+  return 
+    p->GetPDGMass()*(std::sqrt(1. + 0.5*cut/CLHEP::electron_mass_c2) - 1.0);
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
 void G4ionIonisation::InitialiseEnergyLossProcess(
 		      const G4ParticleDefinition* part,
 		      const G4ParticleDefinition* bpart)
 {
-  if(isInitialised) return;
+  const G4ParticleDefinition* ion = G4GenericIon::GenericIon();
 
-  theParticle = part;
+  if(!isInitialised) {
 
-  if(part == bpart || part == G4GenericIon::GenericIon()) theBaseParticle = 0;
-  else if(bpart == 0) theBaseParticle = G4GenericIon::GenericIon();
-  else                theBaseParticle = bpart;
+    theParticle = part;
+    //G4String pname = part->GetParticleName();
 
-  SetBaseParticle(theBaseParticle);
-  SetSecondaryParticle(G4Electron::Electron());
+    // define base particle
+    const G4ParticleDefinition* theBaseParticle = 0;
 
-  if(theBaseParticle) baseMass = theBaseParticle->GetPDGMass();
-  else                baseMass = theParticle->GetPDGMass();
-  
-  if (!EmModel(1)) SetEmModel(new G4BraggIonModel(),1);
-  EmModel(1)->SetLowEnergyLimit(100*eV);
-  eth = 2.0*MeV;  
-  EmModel(1)->SetHighEnergyLimit(eth);
-  if (!FluctModel()) SetFluctModel(new G4IonFluctuations());
-  AddEmModel(1, EmModel(1), FluctModel());
+    if(part == ion)     theBaseParticle = 0;
+    else if(bpart == 0) theBaseParticle = ion;
+    else                theBaseParticle = bpart;
 
-  if (!EmModel(2)) SetEmModel(new G4BetheBlochModel(),2);  
-  EmModel(2)->SetLowEnergyLimit(eth);
-  EmModel(2)->SetHighEnergyLimit(100*TeV);
-  AddEmModel(2, EmModel(2), FluctModel());    
+    SetBaseParticle(theBaseParticle);
+    SetSecondaryParticle(G4Electron::Electron());
 
-  // Add ion stoping tables for Generic Ion
-  if(part == G4GenericIon::GenericIon()) {
-    G4WaterStopping  ws(corr);
-    effCharge = corr->GetIonEffectiveCharge(EmModel(1));
-  } else {
-    effCharge = corr->GetIonEffectiveCharge(0);
+    if (!EmModel(1)) SetEmModel(new G4BraggIonModel(), 1);
+    EmModel(1)->SetLowEnergyLimit(MinKinEnergy());
+
+    // model limit defined for protons
+    eth = (EmModel(1)->HighEnergyLimit())*part->GetPDGMass()/proton_mass_c2;
+    EmModel(1)->SetHighEnergyLimit(eth);
+
+    if (!FluctModel()) SetFluctModel(new G4IonFluctuations());
+    AddEmModel(1, EmModel(1), FluctModel());
+
+    if (!EmModel(2)) SetEmModel(new G4BetheBlochModel(),2);  
+    EmModel(2)->SetLowEnergyLimit(eth);
+    EmModel(2)->SetHighEnergyLimit(MaxKinEnergy());
+    AddEmModel(2, EmModel(2), FluctModel());    
+
+    // Add ion stoping tables for Generic Ion
+    if(part == ion) {
+      G4WaterStopping  ws(corr);
+      corr->SetIonisationModels(EmModel(1),EmModel(2));
+    }
+    isInitialised = true;
   }
-
-  isInitialised = true;
+  // reinitialisation of corrections for the new run
+  EmModel(1)->ActivateNuclearStopping(nuclearStopping);
+  EmModel(2)->ActivateNuclearStopping(nuclearStopping);
+  if(part == ion) corr->InitialiseForNewRun();
 }
 
@@ -145,18 +175,10 @@
 void G4ionIonisation::PrintInfo()
 {
-  if(EmModel(1) && EmModel(2))
-    G4cout << "      Scaling relation is used from proton dE/dx and range."
-	   << "\n      Delta cross sections and sampling from " 
-	   << EmModel(2)->GetName() << " model for scaled energy > "
-	   << eth/MeV << " MeV"
-	   << "\n      Parametrisation from "
-	   << EmModel(1)->GetName() << " for protons below."
-	   << " NuclearStopping= " << nuclearStopping
-	   << G4endl;	 
-  if (stopDataActive)
-    G4cout << "\n      Stopping Power data for " 
+  if (stopDataActive && G4GenericIon::GenericIon() == theParticle) {
+    G4cout << "      Stopping Power data for " 
            << corr->GetNumberOfStoppingVectors()
-	   << " ion/material pairs are used."
+	   << " ion/material pairs, nuclearStopping: " << nuclearStopping
            << G4endl;
+  }
 }
 
@@ -165,5 +187,5 @@
 void G4ionIonisation::AddStoppingData(G4int Z, G4int A,
 				      const G4String& mname,
-				      G4PhysicsVector& dVector)
+				      G4PhysicsVector* dVector)
 {
   corr->AddStoppingData(Z, A, mname, dVector);
@@ -171,33 +193,2 @@
 
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
-
-void G4ionIonisation::CorrectionsAlongStep(const G4MaterialCutsCouple* couple,
-					   const G4DynamicParticle* dp,
-					   G4double& eloss,
-					   G4double& s)
-{
-  const G4ParticleDefinition* part = dp->GetDefinition();
-  const G4Material* mat = couple->GetMaterial();
-  if(eloss < preKinEnergy) {
-    //    G4cout << "e= " << preKinEnergy << " ratio= " << massRatio << " eth= " << eth<<  G4endl;
-    if(preKinEnergy*massRatio > eth)
-      eloss += s*corr->HighOrderCorrections(part,mat,preKinEnergy);
-    else {
-
-      if(stopDataActive)
-	eloss *= corr->EffectiveChargeCorrection(part,mat,preKinEnergy);
-
-    }
-    fParticleChange.SetProposedCharge(effCharge->EffectiveCharge(part,
-                                      mat,preKinEnergy-eloss));
-  }
-  if(nuclearStopping && preKinEnergy*massRatio < 50.*eth*charge2) {
-    G4double nloss = s*corr->NuclearDEDX(part,mat,preKinEnergy - eloss*0.5);
-    eloss += nloss;
-    //  G4cout << "G4ionIonisation::CorrectionsAlongStep: e= " << preKinEnergy
-    //	   << " de= " << eloss << " NIEL= " << nloss << G4endl;
-    fParticleChange.ProposeNonIonizingEnergyDeposit(nloss);
-  }
-}
-
-//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
