Index: trunk/examples/extended/electromagnetic/TestEm7/src/PhysListEmStandardNR.cc
===================================================================
--- trunk/examples/extended/electromagnetic/TestEm7/src/PhysListEmStandardNR.cc	(revision 1337)
+++ trunk/examples/extended/electromagnetic/TestEm7/src/PhysListEmStandardNR.cc	(revision 1342)
@@ -24,6 +24,6 @@
 // ********************************************************************
 //
-// $Id: PhysListEmStandardNR.cc,v 1.4 2009/11/21 22:02:51 maire Exp $
-// GEANT4 tag $Name: geant4-09-04-beta-01 $
+// $Id: PhysListEmStandardNR.cc,v 1.5 2010/10/13 12:21:56 vnivanch Exp $
+// GEANT4 tag $Name: examples-V09-03-09 $
 //
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -122,5 +122,4 @@
 
       G4ionIonisation* ion = new G4ionIonisation();
-      ion->ActivateNuclearStopping(false);
       pmanager->AddProcess(ion, -1, 2, 2);
 
@@ -136,5 +135,4 @@
 
       G4ionIonisation* ion = new G4ionIonisation();
-      ion->ActivateNuclearStopping(false);
       ion->SetStepFunction(0.1, um);
       pmanager->AddProcess(ion, -1, 2, 2);
Index: trunk/examples/extended/electromagnetic/TestEm7/src/RunAction.cc
===================================================================
--- trunk/examples/extended/electromagnetic/TestEm7/src/RunAction.cc	(revision 1337)
+++ trunk/examples/extended/electromagnetic/TestEm7/src/RunAction.cc	(revision 1342)
@@ -24,6 +24,6 @@
 // ********************************************************************
 //
-// $Id: RunAction.cc,v 1.24 2008/08/22 18:30:27 vnivanch Exp $
-// GEANT4 tag $Name: geant4-09-04-beta-01 $
+// $Id: RunAction.cc,v 1.25 2010/09/17 18:45:43 maire Exp $
+// GEANT4 tag $Name: examples-V09-03-09 $
 // 
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -34,4 +34,5 @@
 #include "PhysicsList.hh"
 #include "StepMax.hh"
+#include "HistoManager.hh"
 #include "PrimaryGeneratorAction.hh"
 
@@ -42,19 +43,12 @@
 
 #include "Randomize.hh"
-#include "Histo.hh"
 
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 
 RunAction::RunAction(DetectorConstruction* det, PhysicsList* phys,
-                     PrimaryGeneratorAction* kin)
-:detector(det), physics(phys), kinematic(kin)
+                     HistoManager* histo, PrimaryGeneratorAction* kin)
+:detector(det), physics(phys),histoManager(histo), kinematic(kin)
 { 
   tallyEdep = new G4double[MaxTally];
-  binLength = offsetX = 0.;
-  histo = new Histo();
-  histo->setFileName("testem7");
-  histo->add1D("1","Edep (MeV/mm) along absorber (mm)", 100, 0, 100);
-  histo->add1D("2","Edep (MeV/mm) along absorber zoomed (mm)", 100, 0, 100);
-  histo->add1D("3","Projectile range (mm)", 100, 0, 100);
 }
 
@@ -64,12 +58,4 @@
 {
   delete [] tallyEdep;
-  delete histo;  
-}
-
-//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
-
-void RunAction::FillHisto(G4int ih, G4double x, G4double weight)
-{
-  histo->fill(ih, x, weight);
 }
 
@@ -94,17 +80,14 @@
 
   // define "1" histogram binning
-  length  = detector->GetAbsorSizeX();
+  // histogram "1" is defined by the length of the target
+  // zoomed histograms are defined by UI command  
+  G4double length  = detector->GetAbsorSizeX();
   G4double stepMax = physics->GetStepMaxProcess()->GetMaxStep();
-  const G4int nbmin = 100;
+  G4int nbmin = 100;
   G4int nbBins = (G4int)(0.5 + length/stepMax);
   if (nbBins < nbmin) nbBins = nbmin;
-  binLength = length/nbBins;
-  offsetX   = 0.5*length;
-   
-  // histogram "1" is defined by the length of the target
-  // zoomed histograms are defined by UI command
-  histo->setHisto1D(0, nbBins, 0, length, mm);
+  histoManager->SetHisto(1, nbBins, 0., length, "mm");
  
-  histo->book();
+  histoManager->book();
 }
 
@@ -147,5 +130,5 @@
   G4cout << " Mean number of primary steps = "<< nstep << G4endl;
 
-  //compute energy deposition and NIEL
+  //compute energy deposition and niel
   //
   edeptot /= NbofEvents; 
@@ -153,5 +136,5 @@
          << G4endl;
   eniel /= NbofEvents; 
-  G4cout << " NIEL energy deposit = "<< G4BestUnit(eniel,"Energy")
+  G4cout << " niel energy deposit = "<< G4BestUnit(eniel,"Energy")
          << G4endl;
      
@@ -176,10 +159,14 @@
   }
 
-  // normalize histogram
-  G4double fac = (mm/MeV)/(NbofEvents *  binLength);
-  for (G4int j=0; j<3; j++) {histo->scale(j, fac);}
+  // normalize histograms
+  for (G4int j=1; j<3; j++) {  
+    G4double binWidth = histoManager->GetBinWidth(j);
+    G4double fac = (mm/MeV)/(NbofEvents * binWidth);
+    histoManager->Scale(j, fac);
+  }
+  histoManager->Scale(3, 1./NbofEvents);
  
   // save and clean histo
-  histo->save();
+  histoManager->save();
  
   // show Rndm status
Index: trunk/examples/extended/electromagnetic/TestEm7/src/SteppingAction.cc
===================================================================
--- trunk/examples/extended/electromagnetic/TestEm7/src/SteppingAction.cc	(revision 1337)
+++ trunk/examples/extended/electromagnetic/TestEm7/src/SteppingAction.cc	(revision 1342)
@@ -24,6 +24,6 @@
 // ********************************************************************
 //
-// $Id: SteppingAction.cc,v 1.14 2008/08/22 18:30:27 vnivanch Exp $
-// GEANT4 tag $Name: geant4-09-04-beta-01 $
+// $Id: SteppingAction.cc,v 1.15 2010/09/17 18:45:43 maire Exp $
+// GEANT4 tag $Name: examples-V09-03-09 $
 //
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -32,4 +32,5 @@
 #include "SteppingAction.hh"
 #include "DetectorConstruction.hh"
+#include "HistoManager.hh"
 #include "RunAction.hh"
 #include "G4SteppingManager.hh"
@@ -38,6 +39,7 @@
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 
-SteppingAction::SteppingAction(DetectorConstruction* det,RunAction* RuAct)
-:detector(det),runAction(RuAct)
+SteppingAction::SteppingAction(DetectorConstruction* det, HistoManager* histo,
+                                RunAction* RuAct)
+:detector(det), histoManager(histo), runAction(RuAct)
 { }
 
@@ -49,24 +51,25 @@
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 
-void SteppingAction::UserSteppingAction(const G4Step* aStep)
+void SteppingAction::UserSteppingAction(const G4Step* step)
 {
-  G4double edep = aStep->GetTotalEnergyDeposit();
+  G4double edep = step->GetTotalEnergyDeposit();
   if (edep <= 0.) return;
+  
+  G4double niel = step->GetNonIonizingEnergyDeposit();
 
-  // G4cout << "edep= " << edep << "NIEL= " << aStep->GetNonIonizingEnergyDeposit()<<G4endl;
+  runAction->FillEdep(edep, niel);
 
-  runAction->FillEdep(edep,aStep->GetNonIonizingEnergyDeposit());
-
-  if(aStep->GetTrack()->GetTrackID() == 1) runAction->AddPrimaryStep();  
+  if (step->GetTrack()->GetTrackID() == 1) runAction->AddPrimaryStep();  
  
   //Bragg curve
   //	
-  G4StepPoint* prePoint  = aStep->GetPreStepPoint();
-  G4StepPoint* postPoint = aStep->GetPostStepPoint();
+  G4StepPoint* prePoint  = step->GetPreStepPoint();
+  G4StepPoint* postPoint = step->GetPostStepPoint();
    
-  G4double x1 = prePoint->GetPosition().x(), x2 = postPoint->GetPosition().x();  
-  G4double x = runAction->GetOffsetX() + x1 + G4UniformRand()*(x2-x1);
-  runAction->FillHisto(0, x/mm , edep);
-  runAction->FillHisto(1, x/mm , edep);
+  G4double x1 = prePoint->GetPosition().x();
+  G4double x2 = postPoint->GetPosition().x();  
+  G4double x  = x1 + G4UniformRand()*(x2-x1) + 0.5*(detector->GetAbsorSizeX());
+  histoManager->FillHisto(1, x, edep);
+  histoManager->FillHisto(2, x, edep);
 
   //fill tallies
Index: trunk/examples/extended/electromagnetic/TestEm7/src/TrackingAction.cc
===================================================================
--- trunk/examples/extended/electromagnetic/TestEm7/src/TrackingAction.cc	(revision 1337)
+++ trunk/examples/extended/electromagnetic/TestEm7/src/TrackingAction.cc	(revision 1342)
@@ -24,6 +24,6 @@
 // ********************************************************************
 //
-// $Id: TrackingAction.cc,v 1.5 2008/08/22 18:30:27 vnivanch Exp $
-// GEANT4 tag $Name: geant4-09-04-beta-01 $
+// $Id: TrackingAction.cc,v 1.6 2010/09/17 18:45:43 maire Exp $
+// GEANT4 tag $Name: examples-V09-03-09 $
 //
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -32,4 +32,6 @@
 #include "TrackingAction.hh"
 
+#include "DetectorConstruction.hh"
+#include "HistoManager.hh"
 #include "RunAction.hh"
 
@@ -38,20 +40,18 @@
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 
-TrackingAction::TrackingAction(RunAction* run)
-:runAction(run)
+TrackingAction::TrackingAction(DetectorConstruction* det, HistoManager* histo,
+                               RunAction* run)
+:detector(det), histoManager(histo), runAction(run)
 { }
 
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 
-void TrackingAction::PostUserTrackingAction(const G4Track* aTrack)
+void TrackingAction::PostUserTrackingAction(const G4Track* track)
 {
   // extract Projected Range of primary particle
-  if (aTrack->GetTrackID() == 1) {
-    G4double x = aTrack->GetPosition().x() + runAction->GetOffsetX();
-    if(x > runAction->GetLength()) x = runAction->GetLength(); 
-    //G4cout << " range= " << x << " x= " << aTrack->GetPosition().x()
-    //	   << " ofset= " << runAction->GetOffsetX() << G4endl;
+  if (track->GetTrackID() == 1) {
+    G4double x = track->GetPosition().x() + 0.5*detector->GetAbsorSizeX();
     if(x > 0.0) runAction->AddProjRange(x);
-    runAction->FillHisto(2, x/mm, 1.0);
+    histoManager->FillHisto(3, x);
   }  
 }
