Index: trunk/source/processes/hadronic/models/radioactive_decay/History
===================================================================
--- trunk/source/processes/hadronic/models/radioactive_decay/History	(revision 819)
+++ trunk/source/processes/hadronic/models/radioactive_decay/History	(revision 962)
@@ -14,4 +14,21 @@
      * Reverse chronological order (last date on top), please *
      ----------------------------------------------------------
+
+09 July 2008 Dennis Wright (radioactive_decay-V09-01-02)
+- replace exit() with G4Exception in G4RadioactiveDecay and G4NuclearDecayChannel
+
+17 June 2008 Fan Lei (radioactive_decay-V09-01-01)
+- GRIsotopeTable.cc
+	i) change default verbosity level to 1
+	ii) correct use G4cout instead of G4cerr  
+
+01 May 2008 Fan Lei (radioactive_decay-V09-01-00)
+- G4NuclearDecayChannel.cc
+	i) ARM is no longer applied in photon-evaporation for IT mode and 
+	is now applied at the end in DecayIt() 
+	ii) use the correct shell index in appling ARM and switch on Auger 
+	electron production
+        iii) check the residual kinetic energy after ARM and add it to the atom
+
 21 June 2007 Fan Lei (radioactive_decay-V08-03-00)
 - Minor changes to remove compilation warnings on Windows
Index: trunk/source/processes/hadronic/models/radioactive_decay/src/G4NuclearDecayChannel.cc
===================================================================
--- trunk/source/processes/hadronic/models/radioactive_decay/src/G4NuclearDecayChannel.cc	(revision 819)
+++ trunk/source/processes/hadronic/models/radioactive_decay/src/G4NuclearDecayChannel.cc	(revision 962)
@@ -66,6 +66,7 @@
 #include "G4BetaFermiFunction.hh"
 #include "G4PhotonEvaporation.hh"
+#include "G4AtomicTransitionManager.hh"
+#include "G4AtomicShell.hh"
 #include "G4AtomicDeexcitation.hh"
-
 
 const G4double G4NuclearDecayChannel:: pTolerance = 0.001;
@@ -241,8 +242,10 @@
   if (decayMode == 2) theParentMass -= 2*0.511 * MeV;
   //
+#ifdef G4VERBOSE
   if (GetVerboseLevel()>1) {
-    G4cout << "G4NuclearDecayChannel::DecayIt ";
+    G4cout << "G4NuclearDecayChannel::DecayIt "<< G4endl;
     G4cout << "the decay mass = " << theParentMass << G4endl;
   }
+#endif
 
   SetParentMass (theParentMass);
@@ -261,9 +264,6 @@
     {
     case 0:
-      if (GetVerboseLevel()>0)
-	{
-	  G4cout << "G4NuclearDecayChannel::DecayIt ";
-	  G4cout << " daughters not defined " <<G4endl;
-	}
+      G4cerr << "G4NuclearDecayChannel::DecayIt ";
+      G4cerr << " daughters not defined " <<G4endl;
       break;
     case 1:
@@ -281,14 +281,98 @@
       G4Exception(__FILE__, G4inttostring(__LINE__), FatalException,  "G4NuclearDecayChannel::DecayIt");
     }
-  if ((products == 0) && (GetVerboseLevel()>0)) {
+  if (products == 0) {
     G4cerr << "G4NuclearDecayChannel::DecayIt ";
     G4cerr << *parent_name << " can not decay " << G4endl;
     DumpInfo();
   }
-
-  //
-  // now we have to take care of the EC product which have go through the ARM
+  //
+  // If the decay is to an excited state of the daughter nuclide, we need
+  // to apply the photo-evaporation process.
+  //
+  // needed to hold the shell idex after ICM
+  G4int shellIndex = -1;
+  //
+  if (daughterExcitation > 0.0)
+    {
+      //
+      // Pop the daughter nucleus off the product vector - we need to retain
+      // the momentum of this particle.
+      //
+      dynamicDaughter = products->PopProducts();
+      G4LorentzVector daughterMomentum = dynamicDaughter->Get4Momentum();
+      G4ThreeVector const daughterMomentum1(static_cast<const G4LorentzVector> (daughterMomentum));
+      //
+      //
+      // Now define a G4Fragment with the correct A, Z and excitation, and declare and
+      // initialise a G4PhotonEvaporation object.
+      //    
+      G4Fragment nucleus(daughterA, daughterZ, daughterMomentum);
+      G4PhotonEvaporation* deexcitation = new G4PhotonEvaporation;
+      deexcitation->SetVerboseLevel(GetVerboseLevel());
+      // switch on/off internal electron conversion
+      deexcitation->SetICM(true);
+      // set the maximum life-time for a level that will be treated. Level with life-time longer than this
+      // will be outputed as meta-stable isotope
+      //
+      deexcitation->SetMaxHalfLife(1e-6*second);
+      // but in IT mode, we need to force the transition 
+      if (decayMode == 0) {
+	deexcitation->RDMForced(true);
+      } else {
+	deexcitation->RDMForced(false);
+      }
+      //
+      // Get the gammas by deexciting the nucleus.
+      //
+      G4FragmentVector* gammas = deexcitation->BreakItUp(nucleus);
+      // in the case of BreakItUp(nucleus), the returned G4FragmentVector contains the residual nuclide
+      // as its last entry.
+      G4int nGammas=gammas->size()-1;
+      //
+      // Go through each gamma/e- and add it to the decay product.  The angular distribution
+      // of the gammas is isotropic, and the residual nucleus is assumed not to have suffered
+      // any recoil as a result of this de-excitation.
+      //
+      for (G4int ig=0; ig<nGammas; ig++)
+	{
+	  G4DynamicParticle *theGammaRay = new
+	    G4DynamicParticle (gammas->operator[](ig)->GetParticleDefinition(),
+			       gammas->operator[](ig)->GetMomentum());
+	  theGammaRay -> SetProperTime(gammas->operator[](ig)->GetCreationTime());
+	  products->PushProducts (theGammaRay);
+	}
+      //
+      //      now the nucleus
+      G4double finalDaughterExcitation = gammas->operator[](nGammas)->GetExcitationEnergy();
+      // f.lei (03/01/03) this is needed to fix the crach in test18 
+      if (finalDaughterExcitation <= 1.0*keV) finalDaughterExcitation = 0 ;
+      
+      // f.lei (07/03/05) added the delete to fix bug#711
+      if (dynamicDaughter) delete dynamicDaughter;
+      
+      G4IonTable *theIonTable =  (G4IonTable*)(G4ParticleTable::GetParticleTable()->GetIonTable());      
+      dynamicDaughter = new G4DynamicParticle
+	(theIonTable->GetIon(daughterZ,daughterA,finalDaughterExcitation),
+	 daughterMomentum1);
+      products->PushProducts (dynamicDaughter); 
+      // retrive the ICM shell index
+      shellIndex = deexcitation->GetVacantShellNumber();
+      
+      //
+      // Delete/reset variables associated with the gammas.
+      //
+      while (!gammas->empty()) {
+	delete *(gammas->end()-1);
+	gammas->pop_back();
+      }
+      //    gammas->clearAndDestroy();
+      delete gammas;
+      delete deexcitation;
+    }
+  //
+  // now we have to take care of the EC product which have to go through the ARM
+  // 
+  G4int eShell = -1;
   if (decayMode == 3 || decayMode == 4 || decayMode == 5) {
-    G4int eShell = 0;
     switch (decayMode)
       {
@@ -296,5 +380,5 @@
 	//
 	{
-	  eShell = 1;
+	  eShell = 0; // --> 0 from 1 (f.lei 30/4/2008)
 	}
 	break;
@@ -313,121 +397,60 @@
       case ERROR:
       default:
-	G4cout << " There is an  error in decay mode selection! exit RDM now" << G4endl;
-	exit(0);		      
+        G4Exception("G4NuclearDecayChannel::DecayIt()", "601",
+                    FatalException, "Error in decay mode selection");
       }
+  }
+  // now deal with the IT case where ICM may have been applied
+  //
+  if (decayMode == 0) {
+    eShell = shellIndex;
+  }
+  // now apply ARM if there is a vaccancy
+  //
+  if (eShell != -1) {
     G4int aZ = daughterZ;
-    if (aZ > 5 && aZ < 101) {  // only applies to 5< Z <101 
-      G4AtomicDeexcitation* atomDeex = new G4AtomicDeexcitation();
-      //no Auger electron generation 
-      // atomDeex->ActivateAugerElectronProduction(0);
-      std::vector<G4DynamicParticle*>* armProducts = atomDeex->GenerateParticles(aZ,eShell);
-
-      // pop up the daughter before insertion
+    if (aZ > 5 && aZ < 100) {  // only applies to 5< Z <100 
+      // Retrieve the corresponding identifier and binding energy of the selected shell
+      const G4AtomicTransitionManager* transitionManager = G4AtomicTransitionManager::Instance();
+      const G4AtomicShell* shell = transitionManager->Shell(aZ, eShell);
+      G4double bindingEnergy = shell->BindingEnergy();
+      G4int shellId = shell->ShellId();
+
+      G4AtomicDeexcitation* atomDeex = new G4AtomicDeexcitation();  
+      //the default is no Auger electron generation. 
+      // Switch it on/off here! 
+      atomDeex->ActivateAugerElectronProduction(true);
+      std::vector<G4DynamicParticle*>* armProducts = atomDeex->GenerateParticles(aZ,shellId);
+
+      // pop up the daughter before insertion; 
+      // f.lei (30/04/2008) check if the total kinetic energy is less than 
+      // the shell binding energy; if true add the difference to the daughter to conserve the energy 
       dynamicDaughter = products->PopProducts();
-      for (size_t i = 0;  i < armProducts->size(); i++)
+      G4double tARMEnergy = 0.0; 
+      for (size_t i = 0;  i < armProducts->size(); i++) {
 	products->PushProducts ((*armProducts)[i]);
+	tARMEnergy += (*armProducts)[i]->GetKineticEnergy();
+      }
+      if ((bindingEnergy - tARMEnergy) > 0.1*keV){
+	G4double dEnergy = dynamicDaughter->GetKineticEnergy() + (bindingEnergy - tARMEnergy);
+	dynamicDaughter->SetKineticEnergy(dEnergy);
+      }
+      products->PushProducts(dynamicDaughter); 
+
+#ifdef G4VERBOSE
+      if (GetVerboseLevel()>0)
+	{
+      	  G4cout <<"G4NuclearDecayChannel::Selected shell number for ARM =  " <<shellId <<G4endl;
+	  G4cout <<"G4NuclearDecayChannel::ARM products =  " <<armProducts->size()<<G4endl;
+	  G4cout <<"                 The binding energy =  " << bindingEnergy << G4endl;              
+	  G4cout <<"  Total ARM particle kinetic energy =  " << tARMEnergy << G4endl;              
+	}
+#endif   
+
       delete armProducts;
       delete atomDeex;
-      products->PushProducts (dynamicDaughter); 
-    }
-  }
-
-  //
-  // If the decay is to an excited state of the daughter nuclide, we need
-  // to apply the photo-evaporation process.
-  //
-  if (daughterExcitation > 0.0)
-    {
-      //
-      //
-      // Pop the daughter nucleus off the product vector - we need to retain
-      // the momentum of this particle.
-      //
-      dynamicDaughter = products->PopProducts();
-      G4LorentzVector daughterMomentum = dynamicDaughter->Get4Momentum();
-      G4ThreeVector const daughterMomentum1(static_cast<const G4LorentzVector> (daughterMomentum));
-      //
-      //
-      // Now define a G4Fragment with the correct A, Z and excitation, and declare and
-      // initialise a G4DiscreteGammaDeexcitation object.
-      //
-    
-      //  daughterMomentum.setT(daughterMomentum.t()+G4ParticleTable::GetParticleTable()->GetIonTable()->GetIonMass( daughterZ, daughterA )+daughterExcitation);
-    
-      //    daughterMomentum.setT(daughterMomentum.t()+daughterExcitation);
-      G4Fragment nucleus(daughterA, daughterZ, daughterMomentum);
-      //G4LorentzVector p4(0.,0.,0.,G4NucleiProperties::GetNuclearMass(daughterA,daughterZ)
-      //	       +daughterExcitation);
-      //G4Fragment nucleus(daughterA, daughterZ, p4);
-      //    nucleus.SetExcitationEnergy(daughterExcitation);
- 
-      // G4VGammaDeexcitation* deexcitation = new G4DiscreteGammaDeexcitation;
-      G4PhotonEvaporation* deexcitation = new G4PhotonEvaporation;
-      deexcitation->SetVerboseLevel(GetVerboseLevel());
-      //    deexcitation->Initialize(nucleus);
-      deexcitation->SetICM(true);
-      if (decayMode == 0) {
-	deexcitation->RDMForced(true);
-      } else {
-	deexcitation->RDMForced(false);
-      }
-      // ARM in G4 is applied but no auger electrons!
-      deexcitation->SetARM(true);
-      // not applied 
-      //deexcitation->SetARM(false);
-      //
-      deexcitation->SetMaxHalfLife(1e-6*second);
-      //
-      // Get the gammas by deexciting the nucleus.
-      //
-      G4FragmentVector* gammas = deexcitation->BreakItUp(nucleus);
-      // in the case of BreakItUp(nucleus), the returned G4FragmentVector contains the residual nuclide
-      // as its last entry.
-      G4int nGammas=gammas->size()-1;
-      //
-      //
-      // Go through each gamma/e- and add it to the decay product.  The angular distribution
-      // of the gammas is isotropic, and the residual nucleus is assumed not to suffer
-      // any recoil as a result of this de-excitation.
-      //
-      for (G4int ig=0; ig<nGammas; ig++)
-	{
-	  //	  G4double costheta = 2.0*G4UniformRand() - 1.0;
-	  //	  G4double sintheta = std::sqrt((1.0 - costheta) * (1.0+costheta));
-	  //	  G4double phi      = twopi * G4UniformRand();
-	  // G4ParticleMomentum gDirection
-	  //  (sintheta*std::cos(phi),sintheta*std::sin(phi),costheta);
-	  //G4double gEnergy = gammas->operator[](ig)->GetMomentum().e() 
-	  //  - gammas->operator[](ig)->GetParticleDefinition()->GetPDGMass() ;
-	  G4DynamicParticle *theGammaRay = new
-	    G4DynamicParticle (gammas->operator[](ig)->GetParticleDefinition(),
-			       gammas->operator[](ig)->GetMomentum());
-	  theGammaRay -> SetProperTime(gammas->operator[](ig)->GetCreationTime());
-	  products->PushProducts (theGammaRay);
-	}
-      //
-      //      now the nucleus
-      G4double finalDaughterExcitation = gammas->operator[](nGammas)->GetExcitationEnergy();
-      // f.lei (03/01/03) this is needed to fix the crach in test18 
-      if (finalDaughterExcitation <= 1.0*keV) finalDaughterExcitation = 0 ;
-      G4IonTable *theIonTable =  (G4IonTable*)(G4ParticleTable::GetParticleTable()->GetIonTable());
-      // f.lei (07/03/05) added the delete to fix bug#711
-      if (dynamicDaughter) delete dynamicDaughter;
-      dynamicDaughter = new G4DynamicParticle
-	(theIonTable->GetIon(daughterZ,daughterA,finalDaughterExcitation),
-	 daughterMomentum1);
-      products->PushProducts (dynamicDaughter); 
-      //
-      // Delete/reset variables associated with the gammas.
-      //
-      //    if (nGammas != 0) gammas->clearAndDestroy();
-      while (!gammas->empty()) {
-	delete *(gammas->end()-1);
-	gammas->pop_back();
-      }
-      //    gammas->clearAndDestroy();
-      delete gammas;
-      delete deexcitation;
-    }
+    }
+  }
+
   return products;
 }
Index: trunk/source/processes/hadronic/models/radioactive_decay/src/G4RIsotopeTable.cc
===================================================================
--- trunk/source/processes/hadronic/models/radioactive_decay/src/G4RIsotopeTable.cc	(revision 819)
+++ trunk/source/processes/hadronic/models/radioactive_decay/src/G4RIsotopeTable.cc	(revision 962)
@@ -115,5 +115,5 @@
     if(fIsotopeNameList[i] == fname) j = i;}
   if (j >=0) {
-    if (GetVerboseLevel()>0) {
+    if (GetVerboseLevel()>1) {
     G4cout <<"G4RIsotopeTable::GetIsotope No. : ";
     G4cout <<j<<G4endl;   
@@ -144,5 +144,5 @@
     fname = GetIsotopeName(Z, A, E);
     fIsotopeNameList.push_back(fname);
-    if (GetVerboseLevel()>0) {
+    if (GetVerboseLevel()>1) {
       G4cout <<"G4RIsotopeTable::GetIsotope create: ";
       G4cout <<fname <<G4endl;  
@@ -160,7 +160,7 @@
   os <<"A"<< A << "Z" << Z <<'[' << std::setprecision(1) << E/keV << ']';
   G4String name = os.str();
-  if (GetVerboseLevel()>0) {
-    G4cerr <<"G4RIsotopeTable::GetIsotope Name: ";
-    G4cerr <<name <<G4endl;   
+  if (GetVerboseLevel()>1) {
+    G4cout <<"G4RIsotopeTable::GetIsotope Name: ";
+    G4cout <<name <<G4endl;   
   }
   return name;
@@ -186,5 +186,5 @@
   if (!DecaySchemeFile )
   {
-    if (GetVerboseLevel()>0) {
+    if (GetVerboseLevel()>1) {
       G4cout <<"G4RIsotopeTable::GetMeanLife() : "
 	     <<"cannot find ion radioactive decay file: " 
@@ -230,5 +230,5 @@
     if (!found && aE )
       {
-	if (GetVerboseLevel()>0) {
+	if (GetVerboseLevel()>1) {
 	  G4cout <<"G4RIsotopeTable::GetMeanLife() : ";
 	  G4cout <<"cannot find ion of required excitation E = " << aE << G4endl;
@@ -241,5 +241,5 @@
     if (!found && !aE )
       {
-	if (GetVerboseLevel()>0) {
+	if (GetVerboseLevel()>1) {
 	  G4cout <<"G4RIsotopeTable::GetMeanLife() : ";
 	  G4cout <<"cannot find ion of required excitation E = " << aE << G4endl;
@@ -251,5 +251,5 @@
     DecaySchemeFile.close();
   }
-  if (GetVerboseLevel()>0) {
+  if (GetVerboseLevel()>1) {
     G4cout <<"G4RIsotopeTable::GetMeanLifeTime: ";
     G4cout <<lifetime << " for " << GetIsotopeName(Z, A, aE) <<G4endl;   
Index: trunk/source/processes/hadronic/models/radioactive_decay/src/G4RadioactiveDecay.cc
===================================================================
--- trunk/source/processes/hadronic/models/radioactive_decay/src/G4RadioactiveDecay.cc	(revision 819)
+++ trunk/source/processes/hadronic/models/radioactive_decay/src/G4RadioactiveDecay.cc	(revision 962)
@@ -902,8 +902,6 @@
 		    case ERROR:
 		    default:
-		      // 
-		      // 
-		      G4cout << " There is an  error in decay mode selection! exit RDM now" << G4endl;
-		      exit(0);
+                      G4Exception("G4RadioactiveDecay::LoadDecayTable()", "601",
+                                  FatalException, "Error in decay mode selection");
 		      
 		    }
