Index: trunk/source/processes/hadronic/models/util/src/G4Fragment.cc
===================================================================
--- trunk/source/processes/hadronic/models/util/src/G4Fragment.cc	(revision 819)
+++ trunk/source/processes/hadronic/models/util/src/G4Fragment.cc	(revision 1315)
@@ -24,13 +24,26 @@
 // ********************************************************************
 //
-//
+// $Id: G4Fragment.cc,v 1.16 2010/05/18 18:52:07 vnivanch Exp $
+// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
+//
+//---------------------------------------------------------------------
+//
+// Geant4 class G4Fragment
 //
 // Hadronic Process: Nuclear De-excitations
 // by V. Lara (May 1998)
+//
+// Modifications:
+// 03.05.2010 V.Ivanchenko General cleanup; moved obsolete methods from
+//            inline to source 
+//
 
 #include "G4Fragment.hh"
 #include "G4HadronicException.hh"
 #include "G4HadTmpUtil.hh"
-
+#include "G4Gamma.hh"
+#include "G4Electron.hh"
+
+G4int G4Fragment::errCount = 0;
 
 // Default constructor
@@ -39,4 +52,5 @@
   theZ(0),
   theExcitationEnergy(0.0),
+  theGroundStateMass(0.0),
   theMomentum(0),
   theAngularMomentum(0),
@@ -57,4 +71,5 @@
    theZ = right.theZ;
    theExcitationEnergy = right.theExcitationEnergy;
+   theGroundStateMass = right.theGroundStateMass;
    theMomentum  = right.theMomentum;
    theAngularMomentum = right.theAngularMomentum;
@@ -69,11 +84,8 @@
 }
 
-
 G4Fragment::~G4Fragment()
-{
-}
-
-
-G4Fragment::G4Fragment(const G4int A, const G4int Z, const G4LorentzVector aMomentum) :
+{}
+
+G4Fragment::G4Fragment(const G4int A, const G4int Z, const G4LorentzVector& aMomentum) :
   theA(A),
   theZ(Z),
@@ -89,4 +101,11 @@
 #endif
 {
+  theExcitationEnergy = 0.0;
+  theGroundStateMass = 0.0;
+  if(theA > 0) { 
+    CalculateGroundStateMass();
+    CalculateExcitationEnergy(); 
+  }
+  /*
   theExcitationEnergy = theMomentum.mag() - 
                         G4ParticleTable::GetParticleTable()->GetIonTable()
@@ -102,9 +121,11 @@
     }
   }
-}
-
-
-// This constructor is for initialize photons
-G4Fragment::G4Fragment(const G4LorentzVector aMomentum, G4ParticleDefinition * aParticleDefinition) :
+  */
+}
+
+
+// This constructor is for initialize photons or electrons
+G4Fragment::G4Fragment(const G4LorentzVector& aMomentum, 
+		       G4ParticleDefinition * aParticleDefinition) :
   theA(0),
   theZ(0),
@@ -120,8 +141,13 @@
 #endif
 {
-  theExcitationEnergy = CalculateExcitationEnergy(aMomentum);
-}
-
-
+  theExcitationEnergy = 0.0;
+  if(aParticleDefinition != G4Gamma::Gamma() && 
+     aParticleDefinition != G4Electron::Electron()) {
+    G4String text = "G4Fragment::G4Fragment constructor for gamma used for "
+      + aParticleDefinition->GetParticleName();  
+    throw G4HadronicException(__FILE__, __LINE__, text);
+  }
+  theGroundStateMass = aParticleDefinition->GetPDGMass();
+}
 
 const G4Fragment & G4Fragment::operator=(const G4Fragment &right)
@@ -131,4 +157,5 @@
     theZ = right.theZ;
     theExcitationEnergy = right.theExcitationEnergy;
+    theGroundStateMass = right.theGroundStateMass;
     theMomentum  = right.theMomentum;
     theAngularMomentum = right.theAngularMomentum;
@@ -145,5 +172,4 @@
 }
 
-
 G4bool G4Fragment::operator==(const G4Fragment &right) const
 {
@@ -155,5 +181,4 @@
   return (this != (G4Fragment *) &right);
 }
-
 
 std::ostream& operator << (std::ostream &out, const G4Fragment *theFragment)
@@ -197,28 +222,19 @@
 }
 
-
-
-G4double G4Fragment::CalculateExcitationEnergy(const G4LorentzVector value) const
-{
-  static G4int errCount(0);
-  G4double theMaxGroundStateMass = theZ*G4Proton::Proton()->GetPDGMass()+
-	                       (theA-theZ)*G4Neutron::Neutron()->GetPDGMass();
-  G4double U = value.m() - std::min(theMaxGroundStateMass, GetGroundStateMass());
-  if( U < 0.0 ) {
-     if( U > -10.0 * eV || 0==G4lrint(theA)){
-	U = 0.0;
-     } else {
-	if ( errCount < 10 ) {
-	    G4cerr << "G4Fragment::CalculateExcitationEnergy(): Excitation Energy ="
-	       <<U << " for A = "<<theA<<" and Z= "<<theZ<<G4endl
-	       << ", mass= " << GetGroundStateMass() << " maxMass= "<<theMaxGroundStateMass<<G4endl; ;
-	    errCount++;
-	    if (errCount == 10 ) G4cerr << "G4Fragment::CalculateExcitationEnergy():" 
-				<< " further warnings on negative excitation will be supressed" << G4endl;
-	}
-	U=0.0;
-     }
-  }
-  return U;
+void G4Fragment::ExcitationEnegryWarning()
+{
+  if (theExcitationEnergy < -10.0 * eV) {
+    ++errCount;
+    if ( errCount <= 10 ) {
+      G4cout << "G4Fragment::CalculateExcitationEnergy(): Excitation Energy = "
+	     << theExcitationEnergy/MeV << " MeV for A = " 
+	     <<theA << " and Z= " << theZ << G4endl;
+      if( errCount == 10 ) {
+	G4String text = "G4Fragment::G4Fragment Excitation Energy < 0.0!";
+	throw G4HadronicException(__FILE__, __LINE__, text);
+      }
+    }
+  }
+  theExcitationEnergy = 0.0;
 }
 
@@ -226,5 +242,4 @@
   // Create a unit vector with a random direction isotropically distributed
 {
-
   G4double CosTheta = 1.0 - 2.0*G4UniformRand();
   G4double SinTheta = std::sqrt(1.0 - CosTheta*CosTheta);
@@ -234,5 +249,22 @@
                        Magnitude*CosTheta);
 
-  return Vector;
-		
-}
+  return Vector;		
+}
+
+void G4Fragment::SetExcitationEnergy(const G4double )
+{
+  //   theExcitationEnergy = value;
+  G4cout << "Warning: G4Fragment::SetExcitationEnergy() is a dummy method. Please, avoid to use it." << G4endl;
+}
+
+#ifdef PRECOMPOUND_TEST 
+G4String G4Fragment::GetCreatorModel() const 
+{ 
+  return theCreatorModel; 
+}
+
+void G4Fragment::SetCreatorModel(const G4String & aModel) 
+{ 
+  theCreatorModel = aModel; 
+}
+#endif
