Index: trunk/source/processes/hadronic/models/photolepton_hadron/muon_nuclear/History
===================================================================
--- trunk/source/processes/hadronic/models/photolepton_hadron/muon_nuclear/History	(revision 819)
+++ trunk/source/processes/hadronic/models/photolepton_hadron/muon_nuclear/History	(revision 962)
@@ -1,3 +1,3 @@
-$Id: History,v 1.3 2006/11/04 22:21:09 dennis Exp $
+$Id: History,v 1.8 2009/02/06 08:58:20 vnivanch Exp $
 -------------------------------------------------------------------
 
@@ -16,5 +16,23 @@
      ---------------------------------------------------------------
 
- 4 Nov 2006 Dennis Wright for V. Ivantchenko (hadr-munuclear-V08-01-00)
+06 Feb 2009 V.Ivantchenko (hadr-munuclear-V09-02-01)
+----------------------------------------------------
+
+24 Jan 2009 V.Ivantchenko (hadr-munuclear-V09-02-00)
+----------------------------------------------------
+- G4MuNuclearInteraction added deregistration of the process 
+
+ 4 Oct 2008 Dennis Wright (hadr-munuclear-V09-01-01)
+----------------------------------------------------
+- G4MuNuclearInteraction - include process type enum and change type from
+  12 to fHadronInelastic
+
+ 2 Sep 2008 V.Ivanchenko (hadr-munuclear-V09-01-00)
+---------------------------------------------------
+- G4MuNuclearInteraction added SubType and registration in the 
+                         G4HadronicProcessStore; added PreparePhysicsTable
+                         method and cleanup for readability 
+
+ 4 Nov 2006 Dennis Wright for V.Ivanchenko (hadr-munuclear-V08-01-00)
 -----------------------------------------------------------------------
 - G4MuNuclearInteraction::ComputeMicroscopicCrossSection: prevent NaN
Index: trunk/source/processes/hadronic/models/photolepton_hadron/muon_nuclear/include/G4MuNuclearInteraction.hh
===================================================================
--- trunk/source/processes/hadronic/models/photolepton_hadron/muon_nuclear/include/G4MuNuclearInteraction.hh	(revision 819)
+++ trunk/source/processes/hadronic/models/photolepton_hadron/muon_nuclear/include/G4MuNuclearInteraction.hh	(revision 962)
@@ -25,6 +25,6 @@
 //
 //
-// $Id: G4MuNuclearInteraction.hh,v 1.4 2006/06/29 20:57:20 gunter Exp $
-// GEANT4 tag $Name:  $
+// $Id: G4MuNuclearInteraction.hh,v 1.6 2008/10/02 21:04:35 dennis Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
 //
 // $Id: 
@@ -55,88 +55,90 @@
 #include "G4PhysicsLogVector.hh"
 #include "G4ParametrizedHadronicVertex.hh"
+#include "G4HadronicProcessType.hh"
  
 class G4MuNuclearInteraction : public G4VDiscreteProcess
  
 { 
-  public:
+public:
  
-     G4MuNuclearInteraction(const G4String& processName = "muNuclear");
+  G4MuNuclearInteraction(const G4String& processName = "muNuclear");
  
-    ~G4MuNuclearInteraction();
+  virtual ~G4MuNuclearInteraction();
 
-     G4bool IsApplicable(const G4ParticleDefinition&);
+  virtual G4bool IsApplicable(const G4ParticleDefinition&);
 
-     void SetPhysicsTableBining(G4double lowE, G4double highE, G4int nBins);
+  void SetPhysicsTableBining(G4double lowE, G4double highE, G4int nBins);
 
-     void BuildPhysicsTable(const G4ParticleDefinition& ParticleType);
+  virtual void PreparePhysicsTable(const G4ParticleDefinition& ParticleType);
 
-     void PrintInfoDefinition() ;
+  virtual void BuildPhysicsTable(const G4ParticleDefinition& ParticleType);
 
-     G4double GetMeanFreePath(const G4Track& track,
-                              G4double previousStepSize,
-                              G4ForceCondition* condition ) ;
+  virtual void PrintInfoDefinition() ;
+
+  virtual G4double GetMeanFreePath(const G4Track& track,
+				   G4double previousStepSize,
+				   G4ForceCondition* condition ) ;
  
-     G4VParticleChange *PostStepDoIt(const G4Track& track,
-                                     const G4Step& Step  ) ;
+  virtual G4VParticleChange *PostStepDoIt(const G4Track& track,
+					  const G4Step& Step  ) ;
 
-  protected:
+protected:
 
-     G4double ComputeMeanFreePath( const G4ParticleDefinition* ParticleType,
-                                           G4double KineticEnergy,
-                                           const G4Material* aMaterial);
+  virtual G4double ComputeMeanFreePath( const G4ParticleDefinition* ParticleType,
+					G4double KineticEnergy,
+					const G4Material* aMaterial);
 
-     void ComputePartialSumSigma(  const G4ParticleDefinition* ParticleType,
-                                           G4double KineticEnergy,
-                                           const G4Material* aMaterial);
+  void ComputePartialSumSigma(  const G4ParticleDefinition* ParticleType,
+				G4double KineticEnergy,
+				const G4Material* aMaterial);
 
-     virtual G4double ComputeMicroscopicCrossSection(
-                                      const G4ParticleDefinition* ParticleType,
-                                            G4double KineticEnergy,
-                                            G4double AtomicNumber,
-                                            G4double AtomicMass);
+  virtual G4double ComputeMicroscopicCrossSection(
+				const G4ParticleDefinition* ParticleType,
+				G4double KineticEnergy,
+				G4double AtomicNumber,
+				G4double AtomicMass);
 
-     virtual G4double ComputeDMicroscopicCrossSection(
-                                      const G4ParticleDefinition* ParticleType,
-                                            G4double KineticEnergy,
-                                            G4double AtomicNumber,
-                                            G4double AtomicMass,
-                                            G4double epsilon);
+  virtual G4double ComputeDMicroscopicCrossSection(
+                                const G4ParticleDefinition* ParticleType,
+				G4double KineticEnergy,
+				G4double AtomicNumber,
+				G4double AtomicMass,
+				G4double epsilon);
 
-  private:
+private:
 
-     G4MuNuclearInteraction & operator=(const G4MuNuclearInteraction &right);
-     G4MuNuclearInteraction(const G4MuNuclearInteraction&);
+  G4MuNuclearInteraction & operator=(const G4MuNuclearInteraction &right);
+  G4MuNuclearInteraction(const G4MuNuclearInteraction&);
 
-     G4Element* SelectRandomAtom(G4Material* aMaterial) const;
+  G4Element* SelectRandomAtom(G4Material* aMaterial) const;
 
-     void MakeSamplingTables( const G4ParticleDefinition* ParticleType );
+  void MakeSamplingTables( const G4ParticleDefinition* ParticleType );
 
-  private:
+private:
 
-     G4PhysicsTable* theMeanFreePathTable;
-     G4PhysicsTable* theCrossSectionTable ;        
+  G4PhysicsTable* theMeanFreePathTable;
+  G4PhysicsTable* theCrossSectionTable ;        
 
-     G4OrderedTable PartialSumSigma;     
+  G4OrderedTable PartialSumSigma;     
 
-     G4double LowestKineticEnergy;  
-     G4double HighestKineticEnergy;   
-     G4int TotBin;      
+  G4double LowestKineticEnergy;  
+  G4double HighestKineticEnergy;   
+  G4int TotBin;      
 
-     //cut from R.P. Kokoulin
-     const G4double CutFixed ;
-     // for the atomic weight conversion
-     G4double GramPerMole ;
+  //cut from R.P. Kokoulin
+  const G4double CutFixed ;
+  // for the atomic weight conversion
+  G4double GramPerMole ;
 
-     const G4MuonMinus* theMuonMinus;
-     const G4MuonPlus* theMuonPlus;
-     const G4PionZero* thePionZero;
+  const G4MuonMinus* theMuonMinus;
+  const G4MuonPlus* theMuonPlus;
+  const G4PionZero* thePionZero;
 
-     // tables for sampling ..............
-     static G4int nzdat,ntdat,NBIN ;
-     static G4double zdat[5],adat[5],tdat[8] ;
-     static G4double ya[1001],proba[5][8][1001] ;
+  // tables for sampling ..............
+  static G4int nzdat,ntdat,NBIN ;
+  static G4double zdat[5],adat[5],tdat[8] ;
+  static G4double ya[1001],proba[5][8][1001] ;
      
-     // for the hadronic final state; use base cass * in next release
-     G4ParametrizedHadronicVertex theHadronicVertex;
+  G4ParametrizedHadronicVertex theHadronicVertex;
 };
 
Index: trunk/source/processes/hadronic/models/photolepton_hadron/muon_nuclear/include/G4MuNuclearInteraction.icc
===================================================================
--- trunk/source/processes/hadronic/models/photolepton_hadron/muon_nuclear/include/G4MuNuclearInteraction.icc	(revision 819)
+++ trunk/source/processes/hadronic/models/photolepton_hadron/muon_nuclear/include/G4MuNuclearInteraction.icc	(revision 962)
@@ -26,5 +26,5 @@
 //
 // $Id: G4MuNuclearInteraction.icc,v 1.3 2006/06/29 20:57:22 gunter Exp $
-// GEANT4 tag $Name:  $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
 //
 // $Id: 
Index: trunk/source/processes/hadronic/models/photolepton_hadron/muon_nuclear/src/G4MuNuclearInteraction.cc
===================================================================
--- trunk/source/processes/hadronic/models/photolepton_hadron/muon_nuclear/src/G4MuNuclearInteraction.cc	(revision 819)
+++ trunk/source/processes/hadronic/models/photolepton_hadron/muon_nuclear/src/G4MuNuclearInteraction.cc	(revision 962)
@@ -24,7 +24,6 @@
 // ********************************************************************
 //
-//
-// $Id: G4MuNuclearInteraction.cc,v 1.7 2006/11/04 02:15:05 vnivanch Exp $
-// GEANT4 tag $Name:  $
+// $Id: G4MuNuclearInteraction.cc,v 1.12 2009/01/24 11:59:37 vnivanch Exp $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
 //
 // $Id: 
@@ -38,8 +37,11 @@
 //      added simple model for hadronic vertex, J.P. Wellisch, November 1998
 // --------------------------------------------------------------
-// 26/10/98: new corr.s from R.Kokoulin + cleanup , L.Urban
+// 26/10/1998: new corr.s from R.Kokoulin + cleanup , L.Urban
+// 23/01/2009  V.Ivanchenko Add deregistration
 //
+
 #include "G4MuNuclearInteraction.hh"
 #include "G4UnitsTable.hh"
+#include "G4HadronicProcessStore.hh"
 
 // static members ........
@@ -66,26 +68,38 @@
     theMuonPlus ( G4MuonPlus::MuonPlus() ),
     thePionZero (G4PionZero::PionZero() )
-{  }
+{  
+  SetProcessSubType(fHadronInelastic);
+  G4HadronicProcessStore::Instance()->RegisterExtraProcess(this);
+}
  
 G4MuNuclearInteraction::~G4MuNuclearInteraction()
 {
-   if (theMeanFreePathTable) {
-      theMeanFreePathTable->clearAndDestroy();
-      delete theMeanFreePathTable;
-   }
-   if (theCrossSectionTable) {
-      theCrossSectionTable->clearAndDestroy();
-      delete theCrossSectionTable;
-   }
-
-   if (&PartialSumSigma) {
-      PartialSumSigma.clearAndDestroy();
-   }
+  G4HadronicProcessStore::Instance()->DeRegisterExtraProcess(this);
+
+  if (theMeanFreePathTable) {
+    theMeanFreePathTable->clearAndDestroy();
+    delete theMeanFreePathTable;
+  }
+  if (theCrossSectionTable) {
+    theCrossSectionTable->clearAndDestroy();
+    delete theCrossSectionTable;
+  }
+
+  if (&PartialSumSigma) {
+    PartialSumSigma.clearAndDestroy();
+  }
 }
  
 void G4MuNuclearInteraction::SetPhysicsTableBining(G4double lowE,
-                                                  G4double highE, G4int nBins)
+						   G4double highE, G4int nBins)
 {
   LowestKineticEnergy = lowE; HighestKineticEnergy = highE ; TotBin = nBins ;
+}
+
+void G4MuNuclearInteraction::PreparePhysicsTable(
+                                    const G4ParticleDefinition& aParticleType)
+{
+  G4HadronicProcessStore::Instance()
+    ->RegisterParticleForExtraProcess(this, &aParticleType);
 }
 
@@ -93,10 +107,12 @@
                                     const G4ParticleDefinition& aParticleType)
 {
+  G4HadronicProcessStore::Instance()->PrintInfo(&aParticleType);
+
   G4double LowEdgeEnergy , Value;
   G4PhysicsLogVector* ptrVector;
    
   if (theCrossSectionTable) {
-      theCrossSectionTable->clearAndDestroy() ;
-      delete theCrossSectionTable ;
+    theCrossSectionTable->clearAndDestroy() ;
+    delete theCrossSectionTable ;
   }
 
@@ -111,5 +127,5 @@
   {
     ptrVector = new G4PhysicsLogVector(LowestKineticEnergy,
-                                         HighestKineticEnergy,TotBin) ;
+				       HighestKineticEnergy,TotBin) ;
     AtomicNumber = (*theElementTable )[J]->GetZ() ;
     AtomicWeight = (*theElementTable )[J]->GetA() ;
@@ -119,6 +135,6 @@
       LowEdgeEnergy = ptrVector->GetLowEdgeEnergy(i) ;
       Value = ComputeMicroscopicCrossSection(&aParticleType,
-                                                 LowEdgeEnergy,
-                                                 AtomicNumber,AtomicWeight) ;
+					     LowEdgeEnergy,
+					     AtomicNumber,AtomicWeight) ;
       ptrVector->PutValue(i,Value) ;
     }
@@ -130,6 +146,6 @@
   const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable() ;
   if (theMeanFreePathTable) {
-     theMeanFreePathTable->clearAndDestroy();
-     delete theMeanFreePathTable;
+    theMeanFreePathTable->clearAndDestroy();
+    delete theMeanFreePathTable;
   }
   theMeanFreePathTable = new G4PhysicsTable(G4Material::GetNumberOfMaterials());
@@ -142,6 +158,6 @@
   { 
     ptrVector = new G4PhysicsLogVector(LowestKineticEnergy,
-                                         HighestKineticEnergy,
-                                         TotBin ) ;
+				       HighestKineticEnergy,
+				       TotBin ) ;
 
     const G4Material* material= (*theMaterialTable)[K];
@@ -167,6 +183,6 @@
 void G4MuNuclearInteraction::ComputePartialSumSigma(
                                    const G4ParticleDefinition* ParticleType,
-                                               G4double KineticEnergy,
-                                               const G4Material* aMaterial)
+				   G4double KineticEnergy,
+				   const G4Material* aMaterial)
 
 // Build the table of cross section per element. The table is built for MATERIALS.
@@ -183,11 +199,11 @@
 
    for ( G4int Ielem=0 ; Ielem < NbOfElements ; Ielem++ )
-      {             
-        SIGMA += theAtomNumDensityVector[Ielem] * 
-               ComputeMicroscopicCrossSection( ParticleType, KineticEnergy,
-                                        (*theElementVector)[Ielem]->GetZ(),
-                                        (*theElementVector)[Ielem]->GetA()) ;
-        PartialSumSigma[Imate]->push_back(SIGMA);
-      }
+     {             
+       SIGMA += theAtomNumDensityVector[Ielem] * 
+	 ComputeMicroscopicCrossSection( ParticleType, KineticEnergy,
+					 (*theElementVector)[Ielem]->GetZ(),
+					 (*theElementVector)[Ielem]->GetA()) ;
+       PartialSumSigma[Imate]->push_back(SIGMA);
+     }
 }
 
@@ -529,15 +545,19 @@
   // select randomly 1 element within the material
 
-  const G4int Index = aMaterial->GetIndex();
-  const G4int NumberOfElements = aMaterial->GetNumberOfElements();
+  G4int Index = aMaterial->GetIndex();
+  G4int NumberOfElements = aMaterial->GetNumberOfElements();
   const G4ElementVector* theElementVector = aMaterial->GetElementVector();
+  if(1 == NumberOfElements) return ((*theElementVector)[0]);
 
   G4double rval = G4UniformRand()*((*PartialSumSigma[Index])[NumberOfElements-1]);
-  for ( G4int i=0; i < NumberOfElements; i++ )
+  for ( G4int i=0; i < NumberOfElements; i++ ) {
     if (rval <= (*PartialSumSigma[Index])[i]) return ((*theElementVector)[i]);
-  G4cout << " WARNING !!! - The Material '"<< aMaterial->GetName()
-       << "' has no elements, NULL pointer returned." << G4endl;
-  return 0;
-}
+  }
+  G4cout << "G4MuNuclearInteraction WARNING !!! no element selected for '"
+	 << aMaterial->GetName()
+	 << " 1st element returned." << G4endl;
+  return ((*theElementVector)[0]);
+}
+
 void G4MuNuclearInteraction::PrintInfoDefinition()
 {
Index: trunk/source/processes/hadronic/models/photolepton_hadron/muon_nuclear/src/G4MuonNucleusInteractionModel.cc
===================================================================
--- trunk/source/processes/hadronic/models/photolepton_hadron/muon_nuclear/src/G4MuonNucleusInteractionModel.cc	(revision 819)
+++ trunk/source/processes/hadronic/models/photolepton_hadron/muon_nuclear/src/G4MuonNucleusInteractionModel.cc	(revision 962)
@@ -26,5 +26,5 @@
 //
 // $Id: G4MuonNucleusInteractionModel.cc,v 1.6 2006/06/29 20:57:36 gunter Exp $
-// GEANT4 tag $Name:  $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
 //
 // --------------------------------------------------------------
Index: trunk/source/processes/hadronic/models/photolepton_hadron/muon_nuclear/src/G4ParametrizedHadronicVertex.cc
===================================================================
--- trunk/source/processes/hadronic/models/photolepton_hadron/muon_nuclear/src/G4ParametrizedHadronicVertex.cc	(revision 819)
+++ trunk/source/processes/hadronic/models/photolepton_hadron/muon_nuclear/src/G4ParametrizedHadronicVertex.cc	(revision 962)
@@ -26,5 +26,5 @@
 //
 // $Id: G4ParametrizedHadronicVertex.cc,v 1.6 2006/06/29 20:57:40 gunter Exp $
-// GEANT4 tag $Name:  $
+// GEANT4 tag $Name: geant4-09-02-ref-02 $
 //
 // --------------------------------------------------------------
