From cb47e3474db21e83584723493dc015e9baa3de41 Mon Sep 17 00:00:00 2001
From: adrien-matta <a.matta@surrey.ac.uk>
Date: Wed, 5 Nov 2014 09:21:08 +0000
Subject: [PATCH] * Hyball is now functionnal * Adding creation of small sample
 cube by the material manager to ensure * every declared material are used, so
 no crash when writting the DEDX * tables

---
 Inputs/DetectorConfiguration/Tiara.detector |  31 ++-
 Inputs/DetectorConfiguration/e628.detector  |  23 ++-
 NPSimulation/Tiara/Tiara.cc                 | 215 ++++++++++++++++++--
 NPSimulation/Tiara/Tiara.hh                 |  14 +-
 NPSimulation/include/MaterialManager.hh     |   6 +-
 NPSimulation/src/DetectorConstruction.cc    |  35 +---
 NPSimulation/src/MaterialManager.cc         |  24 ++-
 NPSimulation/src/SiliconScorers.cc          |   2 +-
 NPSimulation/vis.mac                        |   2 +-
 9 files changed, 291 insertions(+), 61 deletions(-)

diff --git a/Inputs/DetectorConfiguration/Tiara.detector b/Inputs/DetectorConfiguration/Tiara.detector
index 9f36bb48c..5ed97fb72 100644
--- a/Inputs/DetectorConfiguration/Tiara.detector
+++ b/Inputs/DetectorConfiguration/Tiara.detector
@@ -14,7 +14,32 @@ Target
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 Tiara
-  TiaraInnerBarrel= 1
-  TiaraOuterBarrel= 1
-  TiaraChamber= 1
+  TiaraInnerBarrel= 0
+  TiaraOuterBarrel= 0
+ TiaraChamber= 0
+  TiaraHyballWedge
+    Z= -147
+    R= 0
+    Phi= 0
+  TiaraHyballWedge
+    Z= -147
+    R= 0
+    Phi= 60
+  TiaraHyballWedge
+    Z= -147
+    R= 0
+    Phi= 120
+  TiaraHyballWedge
+    Z= -147
+    R= 0
+    Phi= 180
+  TiaraHyballWedge
+    Z= -147
+    R= 0
+    Phi= 240
+  TiaraHyballWedge
+    Z= -147
+    R= 0
+    Phi= 300
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
diff --git a/Inputs/DetectorConfiguration/e628.detector b/Inputs/DetectorConfiguration/e628.detector
index aae591bee..01425b31a 100644
--- a/Inputs/DetectorConfiguration/e628.detector
+++ b/Inputs/DetectorConfiguration/e628.detector
@@ -1,3 +1,17 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+GeneralTarget
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%0.5mg/cm2
+Target
+	THICKNESS= 4.8
+	RADIUS=	5
+	MATERIAL= CD2
+	ANGLE= 0
+	X= 0
+	Y= 0
+	Z= 0
+
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 CATSArray
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -88,9 +102,6 @@ TiaraHyballWedge
    R= 0
    Phi= 300
 %%%%%%%%%%%%%%%%%%%%%%%%%%%         
-TiaraBarrel
-   X= 0
-   Y= 0
-   Z= 0
-   OuterBarrel= 1
-   InnerBarrel= 1
+TiaraInnerBarrel= 1
+TiaraOuterBarrel= 1
+TiaraChamber= 1
diff --git a/NPSimulation/Tiara/Tiara.cc b/NPSimulation/Tiara/Tiara.cc
index d1c1e7e46..f93e53da2 100644
--- a/NPSimulation/Tiara/Tiara.cc
+++ b/NPSimulation/Tiara/Tiara.cc
@@ -73,7 +73,7 @@ Tiara::Tiara(){
   // Light Grey
   FrameVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)) ;
   // Light Blue
-  GuardRingVisAtt = new G4VisAttributes(G4Colour(0.0, 0.8, 0.9)) ;  
+  GuardRingVisAtt = new G4VisAttributes(G4Colour(0.1, 0.1, 0.1)) ;  
 
   m_boolChamber = false;
   m_boolInner = false;
@@ -98,7 +98,7 @@ void Tiara::ReadConfiguration(string Path){
   int VerboseLevel = NPOptionManager::getInstance()->GetVerboseLevel();
 
   while (getline(ConfigFile, LineBuffer)){
-    
+
     if (LineBuffer.compare(0, 5, "Tiara") == 0)
       ReadingStatus = true;
 
@@ -125,8 +125,49 @@ void Tiara::ReadConfiguration(string Path){
       }
 
       // Hyball case
-      else if (DataBuffer=="TiaraHyball") { 
-        if(VerboseLevel==1) G4cout << "Hyball  found: " << G4endl   ;
+      else if (DataBuffer=="TiaraHyballWedge") { 
+        if(VerboseLevel==1) G4cout << "// \n Hyball  found: " << G4endl   ;
+        bool ReadingHyball = true;
+        double Z,R,Phi;
+        bool  boolZ= false;
+        bool  boolR= false;
+        bool  boolPhi= false;
+        while(ReadingHyball && ConfigFile >> DataBuffer){
+          if (DataBuffer.compare(0, 1, "%") == 0) { 
+            ConfigFile.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );
+          }
+
+          else if(DataBuffer == "Z="){
+            ConfigFile >> Z ;
+            boolZ = true;
+            if(VerboseLevel==1) G4cout << "\t" << DataBuffer << Z << endl;
+
+          }
+
+          else if(DataBuffer == "R="){
+            ConfigFile >> R ;
+            boolR = true; 
+            if(VerboseLevel==1) G4cout <<"\t" << DataBuffer << R << endl;
+          }
+
+          else if(DataBuffer == "Phi="){
+            ConfigFile >> Phi ;
+            boolPhi = true;
+            if(VerboseLevel==1) G4cout <<"\t" <<  DataBuffer << Phi << endl;
+          }
+
+          else{
+            cout << "Error: Wrong Token Sequence for Tiara Hyball : Getting out " << DataBuffer << endl;
+            exit(1);
+          }
+
+          if(boolPhi && boolR && boolZ){
+            ReadingHyball = false;
+            m_HyballZ.push_back(Z*mm);
+            m_HyballR.push_back(R*mm);
+            m_HyballPhi.push_back(Phi*deg);
+          }
+        }
       }
     }
   }
@@ -142,14 +183,15 @@ void Tiara::ConstructDetector(G4LogicalVolume* world){
 
   if(m_boolChamber)
     ConstructChamber(world);
-  
+
   if(m_boolInner)
     ConstructInnerBarrel(world);
-  
+
   if(m_boolOuter)
     ConstructOuterBarrel(world);
-  
-  ConstructHyball(world);
+
+  if(m_HyballZ.size())
+    ConstructHyball(world);
 }
 // Read sensitive part and fill the Root tree.
 // Called at in the EventAction::EndOfEventAvtion
@@ -183,7 +225,7 @@ void Tiara::ReadSensitive(const G4Event* event){
 
     // Back Energy
     double EB = RandGauss::shoot(Info[1]+Info[0],ResoEnergy);
-    if(ED>EnergyThreshold){
+    if(EB>EnergyThreshold){
       m_EventBarrel->SetBackE(Info[3],EB);
       m_EventBarrel->SetBackT(Info[3],Info[2]); 
     }
@@ -210,6 +252,38 @@ void Tiara::ReadSensitive(const G4Event* event){
   }
   // Clear Map for next event
   OuterBarrelHitMap->clear();
+
+
+  // Hyball //
+  G4THitsMap<G4double*>* HyballHitMap;
+  std::map<G4int, G4double**>::iterator Hyball_itr;
+  G4int HyballCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("Tiara_HyballScorer/Hyball");
+  HyballHitMap = (G4THitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(HyballCollectionID));
+
+  // Loop on the Hyball map 
+  for (Hyball_itr = HyballHitMap->GetMap()->begin() ; Hyball_itr != HyballHitMap->GetMap()->end() ; Hyball_itr++){
+    G4double* Info = *(Hyball_itr->second); 
+
+    // Front Energy
+    double EF = RandGauss::shoot(Info[0],ResoEnergy);
+    if(EF>EnergyThreshold){
+      m_EventHyball->SetRingE(Info[7],Info[8],EF);
+      m_EventHyball->SetRingT(Info[7],Info[8],Info[1]); 
+    }
+
+    // Back Energy
+    double EB = RandGauss::shoot(Info[1]+Info[0],ResoEnergy);
+    if(EB>EnergyThreshold){
+      m_EventHyball->SetSectorE(Info[7],Info[9],EF);
+      m_EventHyball->SetSectorT(Info[7],Info[9],Info[1]); 
+    }
+
+  }
+  // Clear Map for next event
+  HyballHitMap->clear();
+
+
+
 }
 
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -217,7 +291,8 @@ void Tiara::InitializeScorers(){
 
   m_InnerBarrelScorer = new G4MultiFunctionalDetector("Tiara_InnerBarrelScorer");
   m_OuterBarrelScorer = new G4MultiFunctionalDetector("Tiara_OuterBarrelScorer");
-
+  m_HyballScorer      = new G4MultiFunctionalDetector("Tiara_HyballScorer"); 
+ 
   G4VPrimitiveScorer* InnerBarrel = new SILICONSCORERS::PS_Silicon_Resistive("InnerBarrel",
       INNERBARREL_ActiveWafer_Length,
       INNERBARREL_ActiveWafer_Width,
@@ -232,11 +307,20 @@ void Tiara::InitializeScorers(){
       OUTERBARREL_NumberOfStrip);
 
   m_OuterBarrelScorer->RegisterPrimitive(OuterBarrel);
-
-
+  
+  G4VPrimitiveScorer* Hyball= new SILICONSCORERS::PS_Silicon_Annular("Hyball", 
+      HYBALL_ActiveWafer_InnerRadius, 
+      HYBALL_ActiveWafer_OuterRadius, 
+      -0.5*HYBALL_ActiveWafer_Angle,HYBALL_ActiveWafer_Angle, 
+      HYBALL_NumberOfAnnularStrip,
+      HYBALL_NumberOfRadialStrip);
+  
+  m_HyballScorer->RegisterPrimitive(Hyball);
+  
   //   Add All Scorer to the Global Scorer Manager 
   G4SDManager::GetSDMpointer()->AddNewDetector(m_InnerBarrelScorer) ;
   G4SDManager::GetSDMpointer()->AddNewDetector(m_OuterBarrelScorer) ;  
+  G4SDManager::GetSDMpointer()->AddNewDetector(m_HyballScorer) ;
 }
 
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -540,12 +624,111 @@ void Tiara::ConstructOuterBarrel(G4LogicalVolume* world){
 }
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 void Tiara::ConstructHyball(G4LogicalVolume* world){
+  vector<G4TwoVector> PCBCrossSection;
+  PCBCrossSection.push_back(G4TwoVector(28.108*mm ,-14.551*mm));
+  PCBCrossSection.push_back(G4TwoVector(128.808*mm,-66.683*mm));
+  PCBCrossSection.push_back(G4TwoVector(163.618*mm,-30.343*mm));
+  PCBCrossSection.push_back(G4TwoVector(163.618*mm, 30.941*mm));
+  PCBCrossSection.push_back(G4TwoVector(125.718*mm, 73.677*mm));
+  PCBCrossSection.push_back(G4TwoVector(28.108*mm , 16.473*mm));
+
+  G4ExtrudedSolid* PCBFull = 
+    new G4ExtrudedSolid("PCBFull",
+        PCBCrossSection,
+        0.5*HYBALL_PCB_THICKNESS,
+        G4TwoVector(0,0),1,
+        G4TwoVector(0,0),1);
+
+  vector<G4TwoVector> WaferCrossSection;
+  WaferCrossSection.push_back(G4TwoVector(29.108*mm ,-13.943*mm ));
+  WaferCrossSection.push_back(G4TwoVector(123.022*mm,-62.561*mm ));
+  WaferCrossSection.push_back(G4TwoVector(137.00*mm ,-24.157*mm ));
+  WaferCrossSection.push_back(G4TwoVector(137.00*mm , 24.157*mm ));
+  WaferCrossSection.push_back(G4TwoVector(122.677*mm, 63.508*mm ));
+  WaferCrossSection.push_back(G4TwoVector(29.108*mm , 15.069*mm));
+
+  G4ExtrudedSolid* WaferFull = 
+    new G4ExtrudedSolid("WaferFull",
+        WaferCrossSection,
+        0.5*HYBALL_ActiveWafer_Thickness,
+        G4TwoVector(0,0),1,
+        G4TwoVector(0,0),1);
+
+  G4ExtrudedSolid* WaferShape = 
+    new G4ExtrudedSolid("WaferShape",
+        WaferCrossSection,
+        0.6*HYBALL_PCB_THICKNESS,
+        G4TwoVector(0,0),1,
+        G4TwoVector(0,0),1);
+
+  // Active Wafer
+  G4Tubs* ActiveWafer = 
+    new G4Tubs("HyballActiveWafer",HYBALL_ActiveWafer_InnerRadius,
+        HYBALL_ActiveWafer_OuterRadius,0.5*HYBALL_ActiveWafer_Thickness,
+          -0.5*HYBALL_ActiveWafer_Angle,HYBALL_ActiveWafer_Angle);
+
+  G4Tubs* ActiveWaferShape = 
+    new G4Tubs("HyballActiveWaferShape",HYBALL_ActiveWafer_InnerRadius,
+        HYBALL_ActiveWafer_OuterRadius,0.6*HYBALL_ActiveWafer_Thickness,
+        -0.5*HYBALL_ActiveWafer_Angle,HYBALL_ActiveWafer_Angle);
+
+
+  // Substract Active Wafer from Wafer
+  G4SubtractionSolid* InertWafer = new G4SubtractionSolid("Hyball_InertWafer", WaferFull, ActiveWaferShape,
+      new G4RotationMatrix(0,0,0),G4ThreeVector(0,0,0));
 
-  // TO BE DONE //
 
-  // Put the needed geometry parameter definition here instead of the namespace
-  // to facilitate the merge
-  // Respect Naming convention: example HYBALL_PCB_Radius / HYBALL_ActiveWafer_Radius
+  // Substract Wafer shape from PCB
+  G4SubtractionSolid* PCB = new G4SubtractionSolid("Hyball_PCB", PCBFull, WaferShape,
+      new G4RotationMatrix,G4ThreeVector(0,0,0));
+
+  // Logic Volume //
+  // Logic Mother Volume
+  G4LogicalVolume* logicHyball =
+    new G4LogicalVolume(PCBFull,m_MaterialVacuum,"logicHyball", 0, 0, 0);
+  logicHyball->SetVisAttributes(G4VisAttributes::Invisible);
+
+  //  logic PCB
+  G4LogicalVolume* logicPCB =
+    new G4LogicalVolume(PCB,m_MaterialPCB,"logicPCB", 0, 0, 0);
+  logicPCB->SetVisAttributes(PCBVisAtt);
+
+  // logic Inert Wafer
+  G4LogicalVolume* logicIW =
+    new G4LogicalVolume(InertWafer,m_MaterialSilicon,"logicIW", 0, 0, 0);
+  logicIW->SetVisAttributes(GuardRingVisAtt);
+
+  // logic Active Wafer
+  G4LogicalVolume* logicAW =
+    new G4LogicalVolume(ActiveWafer,m_MaterialSilicon,"logicAW", 0, 0, 0);
+  logicAW->SetVisAttributes(SiliconVisAtt);
+  logicAW->SetSensitiveDetector(m_HyballScorer);
+
+  // Place all the Piece in the mother volume
+  new G4PVPlacement(new G4RotationMatrix(0,0,0),
+      G4ThreeVector(0,0,0),
+      logicPCB,"Hyball_PCB",
+      logicHyball,false,0);
+
+  new G4PVPlacement(new G4RotationMatrix(0,0,0),
+      G4ThreeVector(0,0,0),
+      logicIW,"Hyball_InertWafer",
+      logicHyball,false,0);
+
+  new G4PVPlacement(new G4RotationMatrix(0,0,0),
+      G4ThreeVector(0,0,0),
+      logicAW,"Hyball_ActiveWafer",
+      logicHyball,false,0);
+
+
+
+  for(unsigned int i = 0 ; i < m_HyballZ.size() ; i++){
+    // Place mother volume
+    new G4PVPlacement(new G4RotationMatrix(0,0,m_HyballPhi[i]),
+        G4ThreeVector(0,0,m_HyballZ[i]),
+        logicHyball,"Hyball",
+        world,false,i+1);
+  }
 }
 
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
diff --git a/NPSimulation/Tiara/Tiara.hh b/NPSimulation/Tiara/Tiara.hh
index 5d8c7dc89..4639241d6 100644
--- a/NPSimulation/Tiara/Tiara.hh
+++ b/NPSimulation/Tiara/Tiara.hh
@@ -104,7 +104,14 @@ namespace TIARA
   const G4double OUTERBARREL_InertWafer_Width = 30.2*mm;
   const G4int    OUTERBARREL_NumberOfStrip = 4;
 
-
+  // Hyball //
+  const G4double HYBALL_PCB_THICKNESS = 1.6*mm;
+  const G4double HYBALL_ActiveWafer_InnerRadius = 32.6*mm;
+  const G4double HYBALL_ActiveWafer_OuterRadius = 135.1*mm;
+  const G4double HYBALL_ActiveWafer_Thickness = 400*um;
+  const G4double HYBALL_ActiveWafer_Angle = 54.8*deg;
+  const G4double HYBALL_NumberOfAnnularStrip = 16;
+  const G4double HYBALL_NumberOfRadialStrip = 8 ;
 }
 
 
@@ -182,7 +189,7 @@ private:
   //   Scorer Associate with the Silicon
   G4MultiFunctionalDetector*   m_InnerBarrelScorer ;
   G4MultiFunctionalDetector*   m_OuterBarrelScorer ;
-//  G4MultiFunctionalDetector*   m_HyballScorer ;
+  G4MultiFunctionalDetector*   m_HyballScorer ;
  
   ////////////////////////////////////////////////////
   ///////////////Private intern Data//////////////////
@@ -192,6 +199,9 @@ private:
   bool m_boolInner;
   bool m_boolOuter;
 
+  vector<double> m_HyballZ;
+  vector<double> m_HyballR;
+  vector<double> m_HyballPhi;
 
 private:/// Visualisation Attribute:
   // Dark Grey
diff --git a/NPSimulation/include/MaterialManager.hh b/NPSimulation/include/MaterialManager.hh
index 16b9b701c..a145b8559 100644
--- a/NPSimulation/include/MaterialManager.hh
+++ b/NPSimulation/include/MaterialManager.hh
@@ -27,7 +27,7 @@
 #include"G4Material.hh"
 #include"G4Element.hh"
 #include"G4ParticleDefinition.hh"
-
+#include"G4LogicalVolume.hh"
 // STL
 #include<map>
 using namespace std;
@@ -73,6 +73,10 @@ public:
   // It is howver overwritting existing material having the same name
   void AddMaterialToLibrary(G4Material*);
 
+  // Create tiny block of active material so the DEDX tables are generated 
+  // prevent crash if the user define material but don't use it
+  void CreateSampleVolumes(G4LogicalVolume* world_log);
+
   // Write the DEDx table for all material instantiate in the MaterialManager
   // for a given particle
   void WriteDEDXTable(G4ParticleDefinition* Particle ,G4double Emin,G4double Emax);
diff --git a/NPSimulation/src/DetectorConstruction.cc b/NPSimulation/src/DetectorConstruction.cc
index a6a14717d..b46335624 100644
--- a/NPSimulation/src/DetectorConstruction.cc
+++ b/NPSimulation/src/DetectorConstruction.cc
@@ -127,13 +127,11 @@
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 DetectorConstruction::DetectorConstruction():  world_log(0), world_phys(0){
   m_Target   = 0;
-  m_Chamber  = 0;
+  m_Chamber  = 0 ;
 }
 
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 DetectorConstruction::~DetectorConstruction(){
-  delete m_Target;
-  delete m_Chamber;
 }
 
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -151,36 +149,13 @@ G4VPhysicalVolume* DetectorConstruction::Construct(){
   world_log = new G4LogicalVolume(world_box, Vacuum, "world_log", 0, 0, 0);
   world_phys = new G4PVPlacement(0, G4ThreeVector(), world_log, "world", 0, false, 0);
   
-  //G4VisAttributes* VisAtt = new G4VisAttributes(G4Colour(0.2, 0.2, 0.2));
   G4VisAttributes* VisAtt = new G4VisAttributes(G4VisAttributes::Invisible);
   world_log->SetVisAttributes(VisAtt);
   
   //------------------------------------------------------------------
   
-  //------------------------------Reaction Chamber volume
-  /*
-   G4double Chamber_Rmin = 20.0 * cm;
-   G4double Chamber_Rmax = 20.2 * cm;
-   G4double Chamber_ThetaMin = 0.0 * rad;
-   G4double Chamber_ThetaMax = 3.14 * rad;
-   G4double Chamber_PhiMin = 0.0 * rad;
-   G4double Chamber_PhiMax = 6.26 * rad;
-   
-   G4Sphere* Chamber_sphere
-   = new G4Sphere("Chamber_sphere", Chamber_Rmin, Chamber_Rmax, Chamber_PhiMin, Chamber_PhiMax, Chamber_ThetaMin, Chamber_ThetaMax );
-   
-   Chamber_log = new G4LogicalVolume(Chamber_sphere, Vacuum, "Chamber_log", 0, 0, 0);
-   
-   Chamber_phys = new G4PVPlacement(0, G4ThreeVector(), Chamber_log, "Chamber", world_log, false, 0);
-   
-   G4VisAttributes* VisAttChamber = new G4VisAttributes(G4Colour(0.2, 0.2, 0.2));
-   //G4VisAttributes* VisAtt = new G4VisAttributes(G4VisAttributes::Invisible);
-   Chamber_log->SetVisAttributes(VisAttChamber);
-   */
   //------------------------------------------------------------------
   
-  
-  
   return world_phys;
 }
 
@@ -741,8 +716,11 @@ void DetectorConstruction::ReadConfigurationFile(string Path){
     cout << "ERROR: No target define in detector file. Cannot perform simulation without target" << endl ;
     exit(1);
   }
+
+  // Create the Material sample for DEDX tables
+  MaterialManager::getInstance()->CreateSampleVolumes(world_log);
   
-  return   ;
+  return;
 }
 
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -761,7 +739,6 @@ void DetectorConstruction::ReadAllSensitive(const G4Event* event){
 }
 
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
-G4LogicalVolume* DetectorConstruction::GetWorldLogic()
-{
+G4LogicalVolume* DetectorConstruction::GetWorldLogic(){
   return world_log;
 }
diff --git a/NPSimulation/src/MaterialManager.cc b/NPSimulation/src/MaterialManager.cc
index 2a5a22320..821650c64 100644
--- a/NPSimulation/src/MaterialManager.cc
+++ b/NPSimulation/src/MaterialManager.cc
@@ -26,7 +26,9 @@
 
 // Geant4
 #include "G4EmCalculator.hh"
-
+#include "G4Box.hh"
+#include "G4PVPlacement.hh"
+#include "G4VisAttributes.hh"
 // STL
 #include<iostream>
 using namespace std;
@@ -453,4 +455,22 @@ void MaterialManager::WriteDEDXTable(G4ParticleDefinition* Particle ,G4double Em
     File.close();
   }
 }
-
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+void MaterialManager::CreateSampleVolumes(G4LogicalVolume* world_log){
+
+// Crate a micrometer big cube for each material
+  G4double SampleSize = 10 * cm;
+  G4double WorldSize = 10.0 * m ;
+  G4Box* sample_box = new G4Box("sample_box",SampleSize ,SampleSize ,SampleSize);  
+  G4int i = 1;
+  G4double Coord1 = WorldSize-SampleSize;
+  G4double Coord2 = 0 ;
+  map<string,G4Material*>::iterator it;
+  for(it = m_Material.begin() ; it != m_Material.end() ; it++){
+    G4LogicalVolume* sample_log = new G4LogicalVolume(sample_box, it->second, "sample_log", 0, 0, 0);
+    sample_log->SetVisAttributes(G4VisAttributes::Invisible); 
+    Coord2 = WorldSize-i*SampleSize;
+    i++;
+    new G4PVPlacement(0, G4ThreeVector(Coord1,Coord2,-Coord1), sample_log, "sample", world_log, false, 0);
+  }
+} 
diff --git a/NPSimulation/src/SiliconScorers.cc b/NPSimulation/src/SiliconScorers.cc
index 60edc4907..bb08e7766 100644
--- a/NPSimulation/src/SiliconScorers.cc
+++ b/NPSimulation/src/SiliconScorers.cc
@@ -163,7 +163,7 @@ G4bool PS_Silicon_Annular::ProcessHits(G4Step* aStep, G4TouchableHistory*){
   
   Infos[1] = aStep->GetPreStepPoint()->GetGlobalTime();
   
-  m_DetectorNumber = aStep->GetPreStepPoint()->GetTouchableHandle()->GetCopyNumber(0);
+  m_DetectorNumber = aStep->GetPreStepPoint()->GetTouchableHandle()->GetCopyNumber(1);
   m_Position = aStep->GetPreStepPoint()->GetPosition();
  
   // Interaction coordinates (used to fill the InteractionCoordinates branch)
diff --git a/NPSimulation/vis.mac b/NPSimulation/vis.mac
index 9e1aedace..33d6932b1 100644
--- a/NPSimulation/vis.mac
+++ b/NPSimulation/vis.mac
@@ -40,7 +40,7 @@
 /vis/viewer/set/style surface
 #
 # Draw coordinate axes:
-#/vis/scene/add/axes 0 0 0 20 cm
+/vis/scene/add/axes 0 0 0 20 cm
 #
 # Draw smooth trajectories at end of event, showing trajectory points
 # as markers 2 pixels wide:
-- 
GitLab