ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ML2Ph_FullWater.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ML2Ph_FullWater.cc
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // The code was written by :
27 // ^Claudio Andenna claudio.andenna@ispesl.it, claudio.andenna@iss.infn.it
28 // *Barbara Caccia barbara.caccia@iss.it
29 // with the support of Pablo Cirrone (LNS, INFN Catania Italy)
30 // with the contribute of Alessandro Occhigrossi*
31 //
32 // ^INAIL DIPIA - ex ISPESL and INFN Roma, gruppo collegato Sanità, Italy
33 // *Istituto Superiore di Sanità and INFN Roma, gruppo collegato Sanità, Italy
34 // Viale Regina Elena 299, 00161 Roma (Italy)
35 // tel (39) 06 49902246
36 // fax (39) 06 49387075
37 //
38 // more information:
39 // http://g4advancedexamples.lngs.infn.it/Examples/medical-linac
40 //
41 //*******************************************************//
42 
43 #include "ML2Ph_FullWater.hh"
45 
46 #include "G4SystemOfUnits.hh"
47 #include "G4LogicalVolume.hh"
48 #include "G4PVPlacement.hh"
49 #include "G4SDManager.hh"
50 #include "G4PVReplica.hh"
51 
52 
54 {
55  // phantom size and position
56  halfSize.set(150.*mm,150.*mm,150.*mm);
57  // phantom position
58  centre.set(0.,0.,0.);
59 
60  fPhantomSize.setX(300.*mm);
61  fPhantomSize.setY(300.*mm);
62  fPhantomSize.setZ(300.*mm);
64 }
65 
67 {
68 }
69 
71 {
72  G4cout<<"\n\n\tcentre of the phantom: " <<centre/mm<<" [mm]"<< G4endl;
73  G4cout<<"\thalf thickness of the phantom: " <<halfSize/mm<<" [mm]\n"<< G4endl;
74 }
76 {
77 
78  PVWorld=PWorld;
79 
80  bool bCreated=false;
82  G4Box *fullWaterPhantomBox = new G4Box("fullWaterPhantomBox", halfSize.getX(), halfSize.getY(), halfSize.getZ());
83  G4LogicalVolume *fullWaterPhantomLV = new G4LogicalVolume(fullWaterPhantomBox, WATER, "fullWaterPhantomLV", 0, 0, 0);
84  fullWaterPhantomPV = new G4PVPlacement(0, centre, "fullWaterPhantomPV", fullWaterPhantomLV, PVWorld, false, 0);
85 
86 
87  G4int nxCells = nx;
88  G4int nyCells = ny;
89  G4int nzCells = nz;
90 
91  G4cout << "VoxelX, voxelY, Voxelz = " << nx << ", " << ny << ", " << nz << "; " << G4endl;
92 
93  G4ThreeVector sensSize;
94  sensSize.setX(fPhantomSize.x()/(G4double)nxCells);
95  sensSize.setY(fPhantomSize.y()/(G4double)nyCells);
96  sensSize.setZ(fPhantomSize.z()/(G4double)nzCells);
97 
98  // The phantom is voxelised in 3D
99 
100  G4String yRepName("RepY");
101 
102  G4VSolid* solYRep = new G4Box(yRepName,fPhantomSize.x()/2.,sensSize.y()/2.,fPhantomSize.z()/2.);
103 
104  G4LogicalVolume* logYRep = new G4LogicalVolume(solYRep,WATER,yRepName);
105 
106  new G4PVReplica(yRepName,logYRep,fullWaterPhantomLV,kYAxis,ny,sensSize.y());
107 
108  G4String xRepName("RepX");
109 
110  G4VSolid* solXRep = new G4Box(xRepName,sensSize.x()/2.,sensSize.y()/2.,fPhantomSize.z()/2.);
111 
112  G4LogicalVolume* logXRep = new G4LogicalVolume(solXRep,WATER,xRepName);
113 
114  new G4PVReplica(xRepName,logXRep,logYRep,kXAxis,nx,sensSize.x());
115 
116  G4String zVoxName("phantomSens");
117 
118  G4VSolid* solVoxel = new G4Box(zVoxName,sensSize.x()/2.,sensSize.y()/2.,sensSize.z()/2.);
119 
120  G4LogicalVolume* LVPhantomSens = new G4LogicalVolume(solVoxel,WATER,zVoxName); // This is the Sensitive Volume
121 
122  new G4PVReplica(zVoxName,LVPhantomSens,logXRep,kZAxis,nz,sensSize.z());
123 //..............................................
124  // Phantom segmentation using Parameterisation
125  //..............................................
126 
127  G4cout << " Water Phantom Size " << fPhantomSize/mm << G4endl;
128  G4cout << " Segmentation ("<< nx<<","<<ny<<","<<nz<<")"<< G4endl;
129 
130  // Region for cuts
131  G4Region *regVol= new G4Region("fullWaterPhantomR");
133  cuts->SetProductionCut(0.1*mm);
134  regVol->SetProductionCuts(cuts);
135 
136  fullWaterPhantomLV->SetRegion(regVol);
137  regVol->AddRootLogicalVolume(fullWaterPhantomLV);
138 
139  // Visibility
140  G4VisAttributes* simpleAlSVisAtt= new G4VisAttributes(G4Colour::Red());
141  simpleAlSVisAtt->SetVisibility(true);
142 // simpleAlSVisAtt->SetForceSolid(true);
143  fullWaterPhantomLV->SetVisAttributes(simpleAlSVisAtt);
144 
145  G4MultiFunctionalDetector* myScorer = new G4MultiFunctionalDetector("PhantomSD");
147  LVPhantomSens->SetSensitiveDetector(myScorer);
148 
149  G4VPrimitiveScorer * totalDose = new G4PSDoseDeposit3D("TotalDose", nx,ny,nz);
150  myScorer->RegisterPrimitive(totalDose);
151  G4cout << "scorer registered: totalDose" << G4endl;
152 
153  bCreated=true;
154  return bCreated;
155 }
156