Index: trunk/examples/extended/medical/DICOM/src/DicomDetectorConstruction.cc
===================================================================
--- trunk/examples/extended/medical/DICOM/src/DicomDetectorConstruction.cc	(revision 812)
+++ trunk/examples/extended/medical/DICOM/src/DicomDetectorConstruction.cc	(revision 1230)
@@ -451,2 +451,31 @@
 }
 
+
+#include "G4SDManager.hh"
+#include "G4MultiFunctionalDetector.hh"
+#include "G4PSDoseDeposit_RegNav.hh"
+
+//-------------------------------------------------------------
+void DicomDetectorConstruction::SetScorer(G4LogicalVolume* voxel_logic)
+{
+
+  G4SDManager* SDman = G4SDManager::GetSDMpointer();
+  //
+  // Sensitive Detector Name
+  G4String concreteSDname = "PatientSD";
+
+  //------------------------
+  // MultiFunctionalDetector
+  //------------------------
+  //
+  // Define MultiFunctionalDetector with name.
+  G4MultiFunctionalDetector* MFDet = new G4MultiFunctionalDetector(concreteSDname);
+  SDman->AddNewDetector( MFDet );                 // Register SD to SDManager
+
+  voxel_logic->SetSensitiveDetector(MFDet);
+
+  G4PSDoseDeposit_RegNav*   scorer = new G4PSDoseDeposit_RegNav("DoseDeposit");  
+  MFDet->RegisterPrimitive(scorer);
+
+}
+
Index: trunk/examples/extended/medical/DICOM/src/DicomNestedPhantomParameterisation.cc
===================================================================
--- trunk/examples/extended/medical/DICOM/src/DicomNestedPhantomParameterisation.cc	(revision 812)
+++ trunk/examples/extended/medical/DICOM/src/DicomNestedPhantomParameterisation.cc	(revision 1230)
@@ -24,5 +24,8 @@
 // ********************************************************************
 //
-///////////////////////////////////////////////////////////////////////////////
+// $Id: DicomNestedPhantomParameterisation.cc,v 1.5 2009/01/27 10:44:58 gcosmo Exp $
+// GEANT4 tag $Name: geant4-09-03-cand-01 $
+//
+// --------------------------------------------------------------------
 #include "DicomNestedPhantomParameterisation.hh"
 
@@ -34,12 +37,13 @@
 #include "G4Material.hh"
 
-DicomNestedPhantomParameterisation::DicomNestedPhantomParameterisation(
-						     const G4ThreeVector& voxelSize,
-						     std::vector<G4Material*>& mat):
-  G4VNestedParameterisation(),fdX(voxelSize.x()),fdY(voxelSize.y()),fdZ(voxelSize.z()),fMaterials(mat)
+DicomNestedPhantomParameterisation::
+DicomNestedPhantomParameterisation(const G4ThreeVector& voxelSize,
+                                         std::vector<G4Material*>& mat):
+  G4VNestedParameterisation(), fdX(voxelSize.x()),
+  fdY(voxelSize.y()), fdZ(voxelSize.z()), fMaterials(mat)
 {
   // Position of voxels. 
-  // x and y positions are already defined in DetectorConstruction 
-  // by using replicated volume. Here only we need to define is z positions of voxes.
+  // x and y positions are already defined in DetectorConstruction by using
+  // replicated volume. Here only we need to define is z positions of voxels.
 }
 
@@ -48,5 +52,6 @@
 }
 
-void DicomNestedPhantomParameterisation::SetNoVoxel( size_t nx, size_t ny, size_t nz )
+void DicomNestedPhantomParameterisation::
+SetNoVoxel( size_t nx, size_t ny, size_t nz )
 {
   fnX = nx;
@@ -58,9 +63,12 @@
 // Material assignment to geometry.
 //
-G4Material* DicomNestedPhantomParameterisation::ComputeMaterial(G4VPhysicalVolume* ,
-							 const G4int copyNoZ, 
-							 const G4VTouchable* parentTouch)
+G4Material* DicomNestedPhantomParameterisation::
+ComputeMaterial(G4VPhysicalVolume*, const G4int copyNoZ, 
+                                    const G4VTouchable* parentTouch)
 {
-  if(parentTouch==0) return fMaterials[0]; // protection for initialization and vis at idle state
+  // protection for initialization and vis at idle state
+  //
+  if(parentTouch==0) return fMaterials[0];
+
   // Copy number of voxels. 
   // Copy number of X and Y are obtained from replication number.
@@ -70,10 +78,9 @@
   G4int iz = copyNoZ;
 
-  G4int copyNo = ix + fnZ*iy + fnX*fnY*iz;
+  G4int copyNo = ix + fnX*iy + fnX*fnY*iz;
 
   size_t matIndex = GetMaterialIndex(copyNo);
 
   return fMaterials[ matIndex ];
-
 }
 
@@ -86,8 +93,10 @@
 
 //
-//  Number of Materials
-//  Material scanner is required for preparing physics tables and so on before 
-//  stating simulation, so that G4 has to know number of materials.
-G4int       DicomNestedPhantomParameterisation::GetNumberOfMaterials() const{
+// Number of Materials
+// Material scanner is required for preparing physics tables and so on before 
+// starting simulation, so that G4 has to know number of materials.
+//
+G4int DicomNestedPhantomParameterisation::GetNumberOfMaterials() const
+{
   return fMaterials.size();
 }
@@ -97,5 +106,6 @@
 //  This is needed for material scanner and realizing geometry.
 //
-G4Material* DicomNestedPhantomParameterisation::GetMaterial(G4int i) const{
+G4Material* DicomNestedPhantomParameterisation::GetMaterial(G4int i) const
+{
   return fMaterials[i];
 }
@@ -104,8 +114,8 @@
 // Transformation of voxels.
 //
-void DicomNestedPhantomParameterisation::ComputeTransformation(const G4int copyNo, 
-						  G4VPhysicalVolume* physVol)const{
+void DicomNestedPhantomParameterisation::
+ComputeTransformation(const G4int copyNo, G4VPhysicalVolume* physVol) const
+{
   G4ThreeVector position(0.,0.,(2*copyNo+1)*fdZ - fdZ*fnZ);
-
   physVol->SetTranslation(position);
 }
@@ -114,7 +124,7 @@
 // Dimensions are always same in this RE02 example.
 //
-void DicomNestedPhantomParameterisation::ComputeDimensions(G4Box& box, 
-					       const G4int ,
-					       const G4VPhysicalVolume* ) const{
+void DicomNestedPhantomParameterisation::
+ComputeDimensions( G4Box& box, const G4int, const G4VPhysicalVolume* ) const
+{
   box.SetXHalfLength(fdX);
   box.SetYHalfLength(fdY);
Index: trunk/examples/extended/medical/DICOM/src/DicomPhysicsList.cc
===================================================================
--- trunk/examples/extended/medical/DICOM/src/DicomPhysicsList.cc	(revision 812)
+++ trunk/examples/extended/medical/DICOM/src/DicomPhysicsList.cc	(revision 1230)
@@ -54,6 +54,6 @@
 DicomPhysicsList::DicomPhysicsList():  G4VUserPhysicsList()
 {
-  defaultCutValue = 1.e-3*mm;
-  cutForGamma     = 1.e-3*mm;
+  defaultCutValue = 1.*mm;
+  cutForGamma     = 1.*mm;
   cutForElectron  = defaultCutValue;
   cutForPositron  = defaultCutValue;
Index: trunk/examples/extended/medical/DICOM/src/DicomPrimaryGeneratorAction.cc
===================================================================
--- trunk/examples/extended/medical/DICOM/src/DicomPrimaryGeneratorAction.cc	(revision 812)
+++ trunk/examples/extended/medical/DICOM/src/DicomPrimaryGeneratorAction.cc	(revision 1230)
@@ -65,11 +65,15 @@
   G4String particleName;
   G4ParticleDefinition* particle
-    = particleTable->FindParticle(particleName="gamma");
+    = particleTable->FindParticle(particleName="e-");
   particleGun->SetParticleDefinition(particle);
-  G4ThreeVector dir(2.*CLHEP::RandFlat::shoot()-1.,2.*CLHEP::RandFlat::shoot()-1.,2.*CLHEP::RandFlat::shoot()-1);
+  // put the e- in the x direction of the patient (z in the accelerator axs) to hit patient in the central slice of the phantom
+  G4ThreeVector dir(0,1,0);
+  //G4ThreeVector dir(2.*CLHEP::RandFlat::shoot()-1.,2.*CLHEP::RandFlat::shoot()-1.,-CLHEP::RandFlat::shoot());
   dir /= dir.mag();
   particleGun->SetParticleMomentumDirection(dir);       
   particleGun->SetParticleEnergy(5.*MeV);
-  particleGun->SetParticlePosition(G4ThreeVector(0.,0.,-20.)); // put it close to the patient voxels
+  //put it at SAD = 1 m on xy plane of central slice
+  particleGun->SetParticlePosition(G4ThreeVector(0.,-99.9*cm,-27.));
+  //particleGun->SetParticlePosition(G4ThreeVector(0.,0.,-22.));
   particleGun->GeneratePrimaryVertex(anEvent);
 }
Index: trunk/examples/extended/medical/DICOM/src/RegularDicomDetectorConstruction.cc
===================================================================
--- trunk/examples/extended/medical/DICOM/src/RegularDicomDetectorConstruction.cc	(revision 812)
+++ trunk/examples/extended/medical/DICOM/src/RegularDicomDetectorConstruction.cc	(revision 1230)
@@ -95,4 +95,6 @@
   //----- Set this physical volume as having a regular structure of type 1, so that G4RegularNavigation is used
   patient_phys->SetRegularStructureId(1); // if not set, G4VoxelNavigation will be used instead 
+
+  SetScorer(voxel_logic);
 }
 
