Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/examples/advanced/hadrontherapy/src/HadrontherapyDetectorROGeometry.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /examples/advanced/hadrontherapy/src/HadrontherapyDetectorROGeometry.cc (Version 11.3.0) and /examples/advanced/hadrontherapy/src/HadrontherapyDetectorROGeometry.cc (Version 10.0.p1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 // Hadrontherapy advanced example for Geant4   <<  26 // This is the *BASIC* version of Hadrontherapy, a Geant4-based application
 27 // See more at: https://twiki.cern.ch/twiki/bi <<  27 // See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy
 28                                                <<  28 //
                                                   >>  29 // Visit the Hadrontherapy web site (http://www.lns.infn.it/link/Hadrontherapy) to request 
                                                   >>  30 // the *COMPLETE* version of this program, together with its documentation;
                                                   >>  31 // Hadrontherapy (both basic and full version) are supported by the Italian INFN
                                                   >>  32 // Institute in the framework of the MC-INFN Group
                                                   >>  33 //
 29 #include "G4UnitsTable.hh"                         34 #include "G4UnitsTable.hh"
 30 #include "G4SystemOfUnits.hh"                      35 #include "G4SystemOfUnits.hh"
 31 #include "G4LogicalVolume.hh"                      36 #include "G4LogicalVolume.hh"
 32 #include "G4VPhysicalVolume.hh"                    37 #include "G4VPhysicalVolume.hh"
 33 #include "G4PVPlacement.hh"                        38 #include "G4PVPlacement.hh"
 34 #include "G4PVReplica.hh"                          39 #include "G4PVReplica.hh"
 35 #include "G4Box.hh"                                40 #include "G4Box.hh"
 36 #include "G4ThreeVector.hh"                        41 #include "G4ThreeVector.hh"
 37 #include "G4Material.hh"                           42 #include "G4Material.hh"
 38 #include "G4NistManager.hh"                        43 #include "G4NistManager.hh"
 39 #include "G4GeometryManager.hh"                    44 #include "G4GeometryManager.hh"
 40 #include "G4SolidStore.hh"                         45 #include "G4SolidStore.hh"
 41 #include "G4LogicalVolumeStore.hh"                 46 #include "G4LogicalVolumeStore.hh"
 42                                                    47 
 43                                                    48 
 44                                                    49 
 45 #include "G4SDManager.hh"                          50 #include "G4SDManager.hh"
 46 #include "G4RunManager.hh"                         51 #include "G4RunManager.hh"
 47                                                    52 
 48 #include "G4PhysicalVolumeStore.hh"                53 #include "G4PhysicalVolumeStore.hh"
 49                                                    54 
 50 #include "G4ThreeVector.hh"                        55 #include "G4ThreeVector.hh"
 51                                                    56 
 52 #include "globals.hh"                              57 #include "globals.hh"
 53 #include "G4Transform3D.hh"                        58 #include "G4Transform3D.hh"
 54 #include "G4RotationMatrix.hh"                     59 #include "G4RotationMatrix.hh"
 55 #include "G4Colour.hh"                             60 #include "G4Colour.hh"
 56 #include "G4UserLimits.hh"                         61 #include "G4UserLimits.hh"
 57                                                    62 
 58 #include "G4VisAttributes.hh"                      63 #include "G4VisAttributes.hh"
 59                                                    64 
 60 #include "HadrontherapyDetectorROGeometry.hh"      65 #include "HadrontherapyDetectorROGeometry.hh"
 61 #include "HadrontherapyDummySD.hh"                 66 #include "HadrontherapyDummySD.hh"
 62 #include "HadrontherapyDetectorSD.hh"              67 #include "HadrontherapyDetectorSD.hh"
 63                                                    68 
 64 //////////////////////////////////////////////     69 /////////////////////////////////////////////////////////////////////////////
 65 HadrontherapyDetectorROGeometry::Hadrontherapy     70 HadrontherapyDetectorROGeometry::HadrontherapyDetectorROGeometry(G4String aString)
 66   : G4VUserParallelWorld(aString),RODetector(0     71   : G4VUserParallelWorld(aString),RODetector(0),RODetectorXDivision(0),
 67     RODetectorYDivision(0),RODetectorZDivision     72     RODetectorYDivision(0),RODetectorZDivision(0),worldLogical(0),RODetectorLog(0),
 68     RODetectorXDivisionLog(0),RODetectorYDivis     73     RODetectorXDivisionLog(0),RODetectorYDivisionLog(0),RODetectorZDivisionLog(0),
 69     sensitiveLogicalVolume(0)                      74     sensitiveLogicalVolume(0)
 70 {                                                  75 {
 71   isBuilt = false;                                 76   isBuilt = false;
 72   isInitialized = false;                           77   isInitialized = false;
 73 }                                                  78 }
 74                                                    79 
 75 //////////////////////////////////////////////     80 /////////////////////////////////////////////////////////////////////////////
 76                                                    81 
 77 void HadrontherapyDetectorROGeometry::Initiali     82 void HadrontherapyDetectorROGeometry::Initialize(G4ThreeVector pos,
 78              G4double detectorDimX,                83              G4double detectorDimX,
 79              G4double detectorDimY,                84              G4double detectorDimY,
 80              G4double detectorDimZ,                85              G4double detectorDimZ,
 81              G4int numberOfVoxelsX,                86              G4int numberOfVoxelsX,
 82              G4int numberOfVoxelsY,                87              G4int numberOfVoxelsY,
 83              G4int numberOfVoxelsZ)                88              G4int numberOfVoxelsZ)
 84 {                                                  89 {  
 85   detectorToWorldPosition = pos;                   90   detectorToWorldPosition = pos;
 86   detectorSizeX = detectorDimX;                    91   detectorSizeX = detectorDimX;
 87   detectorSizeY= detectorDimY;                     92   detectorSizeY= detectorDimY;
 88   detectorSizeZ=detectorDimZ;                      93   detectorSizeZ=detectorDimZ;
 89   numberOfVoxelsAlongX=numberOfVoxelsX;            94   numberOfVoxelsAlongX=numberOfVoxelsX;
 90   numberOfVoxelsAlongY=numberOfVoxelsY;            95   numberOfVoxelsAlongY=numberOfVoxelsY;
 91   numberOfVoxelsAlongZ=numberOfVoxelsZ;            96   numberOfVoxelsAlongZ=numberOfVoxelsZ;
 92                                                    97 
 93   isInitialized = true;                            98   isInitialized = true;
 94                                                    99 
 95                                                   100 
 96                                                   101   
 97 }                                                 102 }
 98                                                   103 
 99 void HadrontherapyDetectorROGeometry::UpdateRO    104 void HadrontherapyDetectorROGeometry::UpdateROGeometry()
100 {                                                 105 {
101   //Nothing happens if the RO geometry is not     106   //Nothing happens if the RO geometry is not built. But parameters are properly set.
102   if (!isBuilt)                                   107   if (!isBuilt)
103     {                                             108     {
104       //G4Exception("HadrontherapyDetectorROGe    109       //G4Exception("HadrontherapyDetectorROGeometry::UpdateROGeometry","had001",
105       //      JustWarning,"Cannot update geome    110       //      JustWarning,"Cannot update geometry before it is built");
106       return;                                     111       return;
107     }                                             112     }
108                                                   113  
109   //1) Update the dimensions of the G4Boxes       114   //1) Update the dimensions of the G4Boxes
110   G4double halfDetectorSizeX = detectorSizeX;     115   G4double halfDetectorSizeX = detectorSizeX;
111   G4double halfDetectorSizeY = detectorSizeY;     116   G4double halfDetectorSizeY = detectorSizeY;
112   G4double halfDetectorSizeZ = detectorSizeZ;     117   G4double halfDetectorSizeZ = detectorSizeZ;
113                                                   118 
114   RODetector->SetXHalfLength(halfDetectorSizeX    119   RODetector->SetXHalfLength(halfDetectorSizeX);
115   RODetector->SetYHalfLength(halfDetectorSizeY    120   RODetector->SetYHalfLength(halfDetectorSizeY);
116   RODetector->SetZHalfLength(halfDetectorSizeZ    121   RODetector->SetZHalfLength(halfDetectorSizeZ);
117                                                   122 
118   G4double halfXVoxelSizeX = halfDetectorSizeX    123   G4double halfXVoxelSizeX = halfDetectorSizeX/numberOfVoxelsAlongX;
119   G4double halfXVoxelSizeY = halfDetectorSizeY    124   G4double halfXVoxelSizeY = halfDetectorSizeY;
120   G4double halfXVoxelSizeZ = halfDetectorSizeZ    125   G4double halfXVoxelSizeZ = halfDetectorSizeZ;
121   G4double voxelXThickness = 2*halfXVoxelSizeX    126   G4double voxelXThickness = 2*halfXVoxelSizeX;
122                                                   127   
123   RODetectorXDivision->SetXHalfLength(halfXVox    128   RODetectorXDivision->SetXHalfLength(halfXVoxelSizeX);
124   RODetectorXDivision->SetYHalfLength(halfXVox    129   RODetectorXDivision->SetYHalfLength(halfXVoxelSizeY);
125   RODetectorXDivision->SetZHalfLength(halfXVox    130   RODetectorXDivision->SetZHalfLength(halfXVoxelSizeZ);
126                                                   131 
127   G4double halfYVoxelSizeX = halfXVoxelSizeX;     132   G4double halfYVoxelSizeX = halfXVoxelSizeX;
128   G4double halfYVoxelSizeY = halfDetectorSizeY    133   G4double halfYVoxelSizeY = halfDetectorSizeY/numberOfVoxelsAlongY;
129   G4double halfYVoxelSizeZ = halfDetectorSizeZ    134   G4double halfYVoxelSizeZ = halfDetectorSizeZ;
130   G4double voxelYThickness = 2*halfYVoxelSizeY    135   G4double voxelYThickness = 2*halfYVoxelSizeY;
131                                                   136 
132   RODetectorYDivision->SetXHalfLength(halfYVox    137   RODetectorYDivision->SetXHalfLength(halfYVoxelSizeX);
133   RODetectorYDivision->SetYHalfLength(halfYVox    138   RODetectorYDivision->SetYHalfLength(halfYVoxelSizeY);
134   RODetectorYDivision->SetZHalfLength(halfYVox    139   RODetectorYDivision->SetZHalfLength(halfYVoxelSizeZ);
135                                                   140 
136   G4double halfZVoxelSizeX = halfXVoxelSizeX;     141   G4double halfZVoxelSizeX = halfXVoxelSizeX;
137   G4double halfZVoxelSizeY = halfYVoxelSizeY;     142   G4double halfZVoxelSizeY = halfYVoxelSizeY;
138   G4double halfZVoxelSizeZ = halfDetectorSizeZ    143   G4double halfZVoxelSizeZ = halfDetectorSizeZ/numberOfVoxelsAlongZ;
139   G4double voxelZThickness = 2*halfZVoxelSizeZ    144   G4double voxelZThickness = 2*halfZVoxelSizeZ;
140                                                   145 
141   RODetectorZDivision->SetXHalfLength(halfZVox    146   RODetectorZDivision->SetXHalfLength(halfZVoxelSizeX);
142   RODetectorZDivision->SetYHalfLength(halfZVox    147   RODetectorZDivision->SetYHalfLength(halfZVoxelSizeY);
143   RODetectorZDivision->SetZHalfLength(halfZVox    148   RODetectorZDivision->SetZHalfLength(halfZVoxelSizeZ);
144                                                   149 
145   //Delete and re-build the relevant physical     150   //Delete and re-build the relevant physical volumes
146   G4PhysicalVolumeStore* store =                  151   G4PhysicalVolumeStore* store =
147     G4PhysicalVolumeStore::GetInstance();         152     G4PhysicalVolumeStore::GetInstance();
148                                                   153 
149   //Delete...                                     154   //Delete...
150   G4VPhysicalVolume* myVol = store->GetVolume(    155   G4VPhysicalVolume* myVol = store->GetVolume("RODetectorPhys");
151   store->DeRegister(myVol);                       156   store->DeRegister(myVol);
152   //..and rebuild                                 157   //..and rebuild
153   G4VPhysicalVolume *RODetectorPhys = new G4PV    158   G4VPhysicalVolume *RODetectorPhys = new G4PVPlacement(0,
154               detectorToWorldPosition,            159               detectorToWorldPosition,
155               RODetectorLog,                      160               RODetectorLog,
156               "RODetectorPhys",                   161               "RODetectorPhys",
157               worldLogical,                       162               worldLogical,             
158               false,0);                           163               false,0);
159                                                   164 
160   myVol = store->GetVolume("RODetectorXDivisio    165   myVol = store->GetVolume("RODetectorXDivisionPhys");
161   store->DeRegister(myVol);                       166   store->DeRegister(myVol);
162   G4VPhysicalVolume *RODetectorXDivisionPhys =    167   G4VPhysicalVolume *RODetectorXDivisionPhys = new G4PVReplica("RODetectorXDivisionPhys",
163                      RODetectorXDivisionLog,      168                      RODetectorXDivisionLog,
164                      RODetectorPhys,              169                      RODetectorPhys,
165                      kXAxis,                      170                      kXAxis,
166                      numberOfVoxelsAlongX,        171                      numberOfVoxelsAlongX,
167                      voxelXThickness);            172                      voxelXThickness);
168   myVol = store->GetVolume("RODetectorYDivisio    173   myVol = store->GetVolume("RODetectorYDivisionPhys");
169   store->DeRegister(myVol);                       174   store->DeRegister(myVol);
170   G4VPhysicalVolume *RODetectorYDivisionPhys =    175   G4VPhysicalVolume *RODetectorYDivisionPhys = new G4PVReplica("RODetectorYDivisionPhys",
171                      RODetectorYDivisionLog,      176                      RODetectorYDivisionLog,
172                      RODetectorXDivisionPhys,     177                      RODetectorXDivisionPhys,
173                      kYAxis,                      178                      kYAxis,
174                      numberOfVoxelsAlongY,        179                      numberOfVoxelsAlongY,
175                      voxelYThickness);            180                      voxelYThickness);
176                                                   181   
177   myVol = store->GetVolume("RODetectorZDivisio    182   myVol = store->GetVolume("RODetectorZDivisionPhys");
178   store->DeRegister(myVol);                       183   store->DeRegister(myVol);
179   new G4PVReplica("RODetectorZDivisionPhys",      184   new G4PVReplica("RODetectorZDivisionPhys",
180       RODetectorZDivisionLog,                     185       RODetectorZDivisionLog,
181       RODetectorYDivisionPhys,                    186       RODetectorYDivisionPhys,
182       kZAxis,                                     187       kZAxis,
183       numberOfVoxelsAlongZ,                       188       numberOfVoxelsAlongZ,
184       voxelZThickness);                           189       voxelZThickness);
185                                                   190 
186   return;                                         191   return;
187                                                   192 
188 }                                                 193 }
189                                                   194 
190 //////////////////////////////////////////////    195 /////////////////////////////////////////////////////////////////////////////
191 HadrontherapyDetectorROGeometry::~Hadrontherap    196 HadrontherapyDetectorROGeometry::~HadrontherapyDetectorROGeometry()
192 {;}                                               197 {;}
193                                                   198 
194 //////////////////////////////////////////////    199 /////////////////////////////////////////////////////////////////////////////
195 void HadrontherapyDetectorROGeometry::Construc    200 void HadrontherapyDetectorROGeometry::Construct()
196 {                                                 201 {
197   // A dummy material is used to fill the volu    202   // A dummy material is used to fill the volumes of the readout geometry.
198   // (It will be allowed to set a NULL pointer    203   // (It will be allowed to set a NULL pointer in volumes of such virtual
199   // division in future, since this material i    204   // division in future, since this material is irrelevant for tracking.)
200                                                   205   
201                                                   206 
202   //                                              207   //
203   // World                                        208   // World
204   //                                              209   //
205   G4VPhysicalVolume* ghostWorld = GetWorld();     210   G4VPhysicalVolume* ghostWorld = GetWorld();
206   worldLogical = ghostWorld->GetLogicalVolume(    211   worldLogical = ghostWorld->GetLogicalVolume();
207                                                   212   
208   if (!isInitialized)                             213   if (!isInitialized)
209     {                                             214     {
210       G4Exception("HadrontherapyDetectorROGeom    215       G4Exception("HadrontherapyDetectorROGeometry::Construct","had001",
211       FatalException,"Parameters of the RO geo    216       FatalException,"Parameters of the RO geometry are not initialized");
212       return;                                     217       return;
213     }                                             218     }
214                                                   219 
215                                                   220   
216   G4double halfDetectorSizeX = detectorSizeX;     221   G4double halfDetectorSizeX = detectorSizeX;
217   G4double halfDetectorSizeY = detectorSizeY;     222   G4double halfDetectorSizeY = detectorSizeY;
218   G4double halfDetectorSizeZ = detectorSizeZ;     223   G4double halfDetectorSizeZ = detectorSizeZ;
219                                                   224     
220     // World volume of ROGeometry ... SERVE SO    225     // World volume of ROGeometry ... SERVE SOLO PER LA ROG
221                                                   226 
222   // Detector ROGeometry                          227   // Detector ROGeometry 
223   RODetector = new G4Box("RODetector",            228   RODetector = new G4Box("RODetector", 
224        halfDetectorSizeX,                         229        halfDetectorSizeX, 
225        halfDetectorSizeY,                         230        halfDetectorSizeY, 
226        halfDetectorSizeZ);                        231        halfDetectorSizeZ);
227                                                   232   
228   RODetectorLog = new G4LogicalVolume(RODetect    233   RODetectorLog = new G4LogicalVolume(RODetector,
229               0,                                  234               0,
230               "RODetectorLog",                    235               "RODetectorLog",
231               0,0,0);                             236               0,0,0);
232                                                   237   
233                                                   238   
234                                                   239   
235   G4VPhysicalVolume *RODetectorPhys = new G4PV    240   G4VPhysicalVolume *RODetectorPhys = new G4PVPlacement(0,
236               detectorToWorldPosition,RODetect    241               detectorToWorldPosition,RODetectorLog,
237               "RODetectorPhys",                   242               "RODetectorPhys",
238               worldLogical,                       243               worldLogical,             
239               false,0);                           244               false,0);
240                                                   245 
241                                                   246 
242                                                   247 
243                                                   248   
244   // Division along X axis: the detector is di    249   // Division along X axis: the detector is divided in slices along the X axis
245                                                   250   
246   G4double halfXVoxelSizeX = halfDetectorSizeX    251   G4double halfXVoxelSizeX = halfDetectorSizeX/numberOfVoxelsAlongX;
247   G4double halfXVoxelSizeY = halfDetectorSizeY    252   G4double halfXVoxelSizeY = halfDetectorSizeY;
248   G4double halfXVoxelSizeZ = halfDetectorSizeZ    253   G4double halfXVoxelSizeZ = halfDetectorSizeZ;
249   G4double voxelXThickness = 2*halfXVoxelSizeX    254   G4double voxelXThickness = 2*halfXVoxelSizeX;
250                                                   255   
251                                                   256 
252   RODetectorXDivision = new G4Box("RODetectorX    257   RODetectorXDivision = new G4Box("RODetectorXDivision",
253           halfXVoxelSizeX,                        258           halfXVoxelSizeX,
254           halfXVoxelSizeY,                        259           halfXVoxelSizeY,
255           halfXVoxelSizeZ);                       260           halfXVoxelSizeZ);
256                                                   261   
257   RODetectorXDivisionLog = new G4LogicalVolume    262   RODetectorXDivisionLog = new G4LogicalVolume(RODetectorXDivision,
258                  0,                               263                  0,
259                  "RODetectorXDivisionLog",        264                  "RODetectorXDivisionLog",
260                  0,0,0);                          265                  0,0,0);
261                                                   266 
262   G4VPhysicalVolume *RODetectorXDivisionPhys =    267   G4VPhysicalVolume *RODetectorXDivisionPhys = new G4PVReplica("RODetectorXDivisionPhys",
263                                                   268                                                               RODetectorXDivisionLog,
264                                                   269                                                               RODetectorPhys,
265                                                   270                                                               kXAxis,
266                                                   271                                                               numberOfVoxelsAlongX,
267                                                   272                                                               voxelXThickness);
268                                                   273 
269   // Division along Y axis: the slices along t    274   // Division along Y axis: the slices along the X axis are divided along the Y axis
270                                                   275 
271   G4double halfYVoxelSizeX = halfXVoxelSizeX;     276   G4double halfYVoxelSizeX = halfXVoxelSizeX;
272   G4double halfYVoxelSizeY = halfDetectorSizeY    277   G4double halfYVoxelSizeY = halfDetectorSizeY/numberOfVoxelsAlongY;
273   G4double halfYVoxelSizeZ = halfDetectorSizeZ    278   G4double halfYVoxelSizeZ = halfDetectorSizeZ;
274   G4double voxelYThickness = 2*halfYVoxelSizeY    279   G4double voxelYThickness = 2*halfYVoxelSizeY;
275                                                   280 
276   RODetectorYDivision = new G4Box("RODetectorY    281   RODetectorYDivision = new G4Box("RODetectorYDivision",
277           halfYVoxelSizeX,                        282           halfYVoxelSizeX, 
278           halfYVoxelSizeY,                        283           halfYVoxelSizeY,
279           halfYVoxelSizeZ);                       284           halfYVoxelSizeZ);
280                                                   285 
281   RODetectorYDivisionLog = new G4LogicalVolume    286   RODetectorYDivisionLog = new G4LogicalVolume(RODetectorYDivision,
282                  0,                               287                  0,
283                  "RODetectorYDivisionLog",        288                  "RODetectorYDivisionLog",
284                  0,0,0);                          289                  0,0,0);
285                                                   290  
286   G4VPhysicalVolume *RODetectorYDivisionPhys =    291   G4VPhysicalVolume *RODetectorYDivisionPhys = new G4PVReplica("RODetectorYDivisionPhys",
287                     RODetectorYDivisionLog,       292                     RODetectorYDivisionLog,
288                     RODetectorXDivisionPhys,      293                     RODetectorXDivisionPhys,
289                     kYAxis,                       294                     kYAxis,
290                     numberOfVoxelsAlongY,         295                     numberOfVoxelsAlongY,
291                     voxelYThickness);             296                     voxelYThickness);
292                                                   297   
293   // Division along Z axis: the slices along t    298   // Division along Z axis: the slices along the Y axis are divided along the Z axis
294                                                   299 
295   G4double halfZVoxelSizeX = halfXVoxelSizeX;     300   G4double halfZVoxelSizeX = halfXVoxelSizeX;
296   G4double halfZVoxelSizeY = halfYVoxelSizeY;     301   G4double halfZVoxelSizeY = halfYVoxelSizeY;
297   G4double halfZVoxelSizeZ = halfDetectorSizeZ    302   G4double halfZVoxelSizeZ = halfDetectorSizeZ/numberOfVoxelsAlongZ;
298   G4double voxelZThickness = 2*halfZVoxelSizeZ    303   G4double voxelZThickness = 2*halfZVoxelSizeZ;
299                                                   304  
300   RODetectorZDivision = new G4Box("RODetectorZ    305   RODetectorZDivision = new G4Box("RODetectorZDivision",
301           halfZVoxelSizeX,                        306           halfZVoxelSizeX,
302           halfZVoxelSizeY,                        307           halfZVoxelSizeY, 
303           halfZVoxelSizeZ);                       308           halfZVoxelSizeZ);
304                                                   309  
305   RODetectorZDivisionLog = new G4LogicalVolume    310   RODetectorZDivisionLog = new G4LogicalVolume(RODetectorZDivision,
306                  0,                               311                  0,
307                  "RODetectorZDivisionLog",        312                  "RODetectorZDivisionLog",
308                  0,0,0);                          313                  0,0,0);
309                                                   314  
310   new G4PVReplica("RODetectorZDivisionPhys",      315   new G4PVReplica("RODetectorZDivisionPhys",
311       RODetectorZDivisionLog,                     316       RODetectorZDivisionLog,
312       RODetectorYDivisionPhys,                    317       RODetectorYDivisionPhys,
313       kZAxis,                                     318       kZAxis,
314       numberOfVoxelsAlongZ,                       319       numberOfVoxelsAlongZ,
315       voxelZThickness);                           320       voxelZThickness);
316                                                   321 
317   sensitiveLogicalVolume = RODetectorZDivision    322   sensitiveLogicalVolume = RODetectorZDivisionLog;
318   isBuilt = true;                                 323   isBuilt = true;
319 }                                                 324 }
320                                                   325 
321 void HadrontherapyDetectorROGeometry::Construc    326 void HadrontherapyDetectorROGeometry::ConstructSD()
322 {                                                 327 {
                                                   >> 328  
323  G4String sensitiveDetectorName = "RODetector"    329  G4String sensitiveDetectorName = "RODetector";
324                                                   330  
325  HadrontherapyDetectorSD* detectorSD = new Had    331  HadrontherapyDetectorSD* detectorSD = new HadrontherapyDetectorSD(sensitiveDetectorName);
326  G4SDManager::GetSDMpointer()->AddNewDetector( << 
327  sensitiveLogicalVolume->SetSensitiveDetector( << 
328                                                   332 
329  // SetSensitiveDetector(sensitiveLogicalVolum << 333  SetSensitiveDetector(sensitiveLogicalVolume,detectorSD);
330                                                   334 
331                                                   335 
332 }                                                 336 }
333                                                   337 
334                                                   338