Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // 26 // Hadrontherapy advanced example for Geant4 << 23 // $Id: HadrontherapyDetectorConstruction.hh 27 // See more at: https://twiki.cern.ch/twiki/bi << 24 // 28 << 25 // -------------------------------------------------------------- 29 #ifndef HadrontherapyDetectorConstruction_H << 26 // GEANT 4 - Hadrontherapy example 30 #define HadrontherapyDetectorConstruction_H 1 << 27 // -------------------------------------------------------------- >> 28 // Code developed by: >> 29 // >> 30 // G.A.P. Cirrone, G. Russo >> 31 // Laboratori Nazionali del Sud - INFN, Catania, Italy >> 32 // >> 33 // >> 34 // >> 35 #ifndef HadrontherapyDetectorConstruction_h >> 36 #define HadrontherapyDetectorConstruction_h 1 31 37 32 #include "G4Box.hh" << 38 #include "G4VUserDetectorConstruction.hh" 33 #include "globals.hh" 39 #include "globals.hh" 34 #include "G4VisAttributes.hh" << 35 #include "G4LogicalVolume.hh" << 36 #include "G4UnitsTable.hh" 40 #include "G4UnitsTable.hh" 37 #include "HadrontherapyDetectorROGeometry.hh" << 41 #include "G4ios.hh" >> 42 #include "G4Region.hh" >> 43 #include "G4RegionStore.hh" 38 44 39 class G4VPhysicalVolume; << 45 class G4Text; >> 46 class G4Box; >> 47 class G4Tubs; 40 class G4LogicalVolume; 48 class G4LogicalVolume; 41 class G4PVPlacement; << 49 class G4VPhysicalVolume; 42 class HadrontherapyDetectorROGeometry; << 50 class G4Material; 43 class HadrontherapyDetectorMessenger; 51 class HadrontherapyDetectorMessenger; 44 class HadrontherapyDetectorSD; << 52 class HadrontherapyCalorimeterSD; 45 class HadrontherapyMatrix; << 46 class HadrontherapyLet; << 47 53 48 class HadrontherapyDetectorConstruction << 54 class HadrontherapyDetectorConstruction : public G4VUserDetectorConstruction 49 { 55 { 50 public: << 56 51 << 57 public: 52 HadrontherapyDetectorConstruction(G4VPhysi << 58 HadrontherapyDetectorConstruction(); 53 << 59 ~HadrontherapyDetectorConstruction(); 54 ~HadrontherapyDetectorConstruction(); << 60 55 << 61 public: 56 public: << 62 void SetModulatorAngle (G4double); 57 static HadrontherapyDetectorConstruction* << 63 void SetDosemeterMaterial (G4String); 58 void InitializeDetectorROGeometry(Hadronth << 64 G4VPhysicalVolume* Construct(); 59 G4ThreeV << 65 60 G4VPhysicalVolume* motherPhys; << 66 public: 61 HadrontherapyDetectorSD* detectorS << 67 G4double GetModulatorAngle() {return ModulatorAngle;}; 62 << 68 G4double ModulatorAngle; 63 ////////////////////////// << 69 G4int NbOfLayer; 64 void VirtualLayer(G4bool Varbool); << 70 G4double hightDosemeter; 65 G4bool NewSource; << 71 G4double DosemeterPosition_x; 66 void SetVirtualLayerPosition(G4ThreeVector << 72 G4Material* GetDosemeterMaterial() {return DosemeterMaterial;}; 67 G4ThreeVector VirtualLayerPosition; << 73 G4Material* GetWorldMaterial() {return WorldMaterial;}; 68 << 74 69 ////////////////////////// << 75 const G4VPhysicalVolume* GetTreatmentRoom() {return physiTreatmentRoom;}; >> 76 const G4VPhysicalVolume* GetDosemeter() {return physiDosemeter;}; >> 77 70 private: 78 private: 71 << 79 G4Material* DosemeterMaterial; 72 void ConstructPhantom(); << 80 G4Material* WorldMaterial; 73 void ConstructDetector(); << 81 74 void ParametersCheck(); << 82 // TREATMENT ROOM 75 void CheckOverlaps(); << 83 76 << 84 G4Box* solidTreatmentRoom; 77 public: << 85 G4LogicalVolume* logicTreatmentRoom; 78 // Get detector position relative to WORLD << 86 G4VPhysicalVolume* physiTreatmentRoom; 79 inline G4ThreeVector GetDetectorToWorldPos << 87 80 { << 88 // BEAM LINE SUPPORT 81 return phantomPosition + detectorPosit << 89 82 } << 90 G4Box* solidBeamLineSupport; 83 ////////////////////////////////////////// << 91 G4LogicalVolume* logicBeamLineSupport; 84 // Get displacement between phantom and de << 92 G4VPhysicalVolume* physiBeamLineSupport; 85 inline G4ThreeVector GetDetectorToPhantomP << 93 86 { << 94 // BEAM LINE COVER 1 (left panel) 87 return G4ThreeVector(phantomSizeX/2 - << 95 88 phantomSizeY/2 - << 96 G4Box* solidBeamLineCover; 89 phantomSizeZ/2 - << 97 G4LogicalVolume* logicBeamLineCover; 90 ); << 98 G4VPhysicalVolume* physiBeamLineCover; 91 } << 99 92 << 100 // BEAM LINE COVER 2 (rigth panel) 93 ////////////////////////////////////////// << 101 94 // Calculate (and set) detector position b << 102 G4Box* solidBeamLineCover2; 95 inline void SetDetectorPosition() << 103 G4LogicalVolume* logicBeamLineCover2; 96 { << 104 G4VPhysicalVolume* physiBeamLineCover2; 97 // Adjust detector position << 105 98 detectorPosition.setX(detectorToPhanto << 106 99 detectorPosition.setY(detectorToPhanto << 107 // VACUUM ZONE 100 detectorPosition.setZ(detectorToPhanto << 108 101 << 109 G4Box* solidVacuumZone; 102 << 110 G4LogicalVolume* logicVacuumZone; 103 } << 111 G4VPhysicalVolume* physiVacuumZone; 104 ////////////////////////////////////////// << 112 105 // Check whether detector is inside phanto << 113 // FIRST SCATTERING FOIL 106 inline bool IsInside(G4double detectorX, << 114 107 G4double detectorY, << 115 G4Box* solidFirstScatteringFoil; 108 G4double detectorZ, << 116 G4LogicalVolume* logicFirstScatteringFoil; 109 G4double phantomX, << 117 G4VPhysicalVolume* physiFirstScatteringFoil; 110 G4double phantomY, << 118 111 G4double phantomZ, << 119 // KAPTON WINDOW 112 G4ThreeVector pos) << 120 113 { << 121 G4Box* solidKaptonWindow; 114 // Dimensions check... X Y and Z << 122 G4LogicalVolume* logicKaptonWindow; 115 // Firstly check what dimension we are << 123 G4VPhysicalVolume* physiKaptonWindow; 116 { << 124 117 if (detectorX > phantomX) << 125 // BEAM STOPPER 118 { << 126 119 G4cout << "Error: Detector X d << 127 G4Tubs* solidStopper; 120 return false; << 128 G4LogicalVolume* logicStopper; 121 } << 129 G4VPhysicalVolume* physiStopper; 122 if ( (phantomX - detectorX) < pos. << 130 123 { << 131 // SECOND SCATTERING FOIL 124 G4cout << "Error: X dimension << 132 125 return false; << 133 G4Box* solidSecondScatteringFoil; 126 } << 134 G4LogicalVolume* logicSecondScatteringFoil; 127 } << 135 G4VPhysicalVolume* physiSecondScatteringFoil; 128 << 136 129 { << 137 // FIRST COLLIMATOR 130 if (detectorY > phantomY) << 138 131 { << 139 G4Box* solidFirstCollimator; 132 G4cout << "Error: Detector Y d << 140 G4LogicalVolume* logicFirstCollimator; 133 return false; << 141 G4VPhysicalVolume* physiFirstCollimator; 134 } << 142 135 if ( (phantomY - detectorY) < pos. << 143 G4Tubs* solidHoleFirstCollimator; 136 { << 144 G4LogicalVolume* logicHoleFirstCollimator; 137 G4cout << "Error: Y dimension << 145 G4VPhysicalVolume* physiHoleFirstCollimator; 138 return false; << 146 139 } << 147 140 } << 148 //FIRST MODULATOR COLLIMATOR 141 << 149 142 { << 150 G4Box* solidFirstCollimatorModulatorBox; 143 if (detectorZ > phantomZ) << 151 G4LogicalVolume* logicFirstCollimatorModulatorBox; 144 { << 152 G4VPhysicalVolume* physiFirstCollimatorModulatorBox; 145 G4cout << "Error: Detector Z d << 153 146 return false; << 154 G4Tubs* solidHoleFirstCollimatorModulatorBox; 147 } << 155 G4LogicalVolume* logicHoleFirstCollimatorModulatorBox; 148 if ( (phantomZ - detectorZ) < pos. << 156 G4VPhysicalVolume* physiHoleFirstCollimatorModulatorBox; 149 { << 157 150 G4cout << "Error: Z dimension << 158 151 return false; << 159 152 } << 160 G4Box* solidMotherMod; // pointer to the solid 153 } << 161 G4LogicalVolume* logicMotherMod; // pointer to the logical Target 154 << 162 G4VPhysicalVolume* physiMotherMod; 155 return true; << 163 156 } << 164 G4Material* MotherModMater; 157 ////////////////////////////////////////// << 165 G4Material* Mod0Mater; 158 << 166 G4Material* ModMater; 159 G4bool SetPhantomMaterial(G4String materi << 167 160 void SetVoxelSize(G4double sizeX, G4double << 168 161 void SetDetectorSize(G4double sizeX, G4dou << 169 G4Tubs* solidMod0; // pointer to the 162 void SetPhantomSize(G4double sizeX, G4doub << 170 G4LogicalVolume* logicMod0; // pointer to the 163 void SetPhantomPosition(G4ThreeVector); << 171 G4VPhysicalVolume* physiMod0; 164 void SetDetectorToPhantomPosition(G4ThreeV << 172 165 void UpdateGeometry(); << 173 166 void PrintParameters(); << 174 G4Tubs* solidMod1; // pointer to the 167 G4LogicalVolume* GetDetectorLogicalVolume( << 175 G4LogicalVolume* logicMod1; // pointer to the 168 << 176 G4VPhysicalVolume* physiMod1; >> 177 >> 178 G4Tubs* solidMod2; // pointer to the >> 179 G4LogicalVolume* logicMod2; // pointer to the >> 180 G4VPhysicalVolume* physiMod2; >> 181 >> 182 G4Tubs* solidMod3; // pointer to the >> 183 G4LogicalVolume* logicMod3; // pointer to the >> 184 G4VPhysicalVolume* physiMod3; >> 185 >> 186 G4Tubs* solidMod4; // pointer to the >> 187 G4LogicalVolume* logicMod4; // pointer to the >> 188 G4VPhysicalVolume* physiMod4; >> 189 >> 190 G4Tubs* solidMod5; // pointer to the >> 191 G4LogicalVolume* logicMod5; // pointer to the >> 192 G4VPhysicalVolume* physiMod5; >> 193 >> 194 G4Tubs* solidMod6; // pointer to the >> 195 G4LogicalVolume* logicMod6; // pointer to the >> 196 G4VPhysicalVolume* physiMod6; >> 197 >> 198 G4Tubs* solidMod7; // pointer to the >> 199 G4LogicalVolume* logicMod7; // pointer to the >> 200 G4VPhysicalVolume* physiMod7; >> 201 >> 202 G4Tubs* solidMod8; // pointer to the >> 203 G4LogicalVolume* logicMod8; // pointer to the >> 204 G4VPhysicalVolume* physiMod8; >> 205 >> 206 G4Tubs* solidMod9; // pointer to the >> 207 G4LogicalVolume* logicMod9; // pointer to the >> 208 G4VPhysicalVolume* physiMod9; >> 209 >> 210 G4Tubs* solidMod10; // pointer to the >> 211 G4LogicalVolume* logicMod10; // pointer to the >> 212 G4VPhysicalVolume* physiMod10; >> 213 >> 214 G4Tubs* solidMod11; // pointer to the >> 215 G4LogicalVolume* logicMod11; // pointer to the >> 216 G4VPhysicalVolume* physiMod11; >> 217 >> 218 G4Tubs* solidMod12; // pointer to the >> 219 G4LogicalVolume* logicMod12; // pointer to the >> 220 G4VPhysicalVolume* physiMod12; >> 221 >> 222 G4Tubs* solidMod13; // pointer to the >> 223 G4LogicalVolume* logicMod13; // pointer to the >> 224 G4VPhysicalVolume* physiMod13; >> 225 >> 226 G4Tubs* solidMod14; // pointer to the >> 227 G4LogicalVolume* logicMod14; // pointer to the >> 228 G4VPhysicalVolume* physiMod14; >> 229 >> 230 G4Tubs* solidMod15; // pointer to the >> 231 G4LogicalVolume* logicMod15; // pointer to the >> 232 G4VPhysicalVolume* physiMod15; >> 233 >> 234 G4Tubs* solidMod16; // pointer to the >> 235 G4LogicalVolume* logicMod16; // pointer to the >> 236 G4VPhysicalVolume* physiMod16; >> 237 >> 238 G4Tubs* solidMod17; // pointer to the >> 239 G4LogicalVolume* logicMod17; // pointer to the >> 240 G4VPhysicalVolume* physiMod17; >> 241 >> 242 G4Tubs* solidMod18; // pointer to the >> 243 G4LogicalVolume* logicMod18; // pointer to the >> 244 G4VPhysicalVolume* physiMod18; >> 245 >> 246 G4Tubs* solidMod20; // pointer to the >> 247 G4LogicalVolume* logicMod20; // pointer to the >> 248 G4VPhysicalVolume* physiMod20; >> 249 >> 250 //SECOND MODULATOR COLLIMATOR >> 251 >> 252 G4Box* solidSecondCollimatorModulatorBox; >> 253 G4LogicalVolume* logicSecondCollimatorModulatorBox; >> 254 G4VPhysicalVolume* physiSecondCollimatorModulatorBox; >> 255 >> 256 G4Tubs* solidHoleSecondCollimatorModulatorBox; >> 257 G4LogicalVolume* logicHoleSecondCollimatorModulatorBox; >> 258 G4VPhysicalVolume* physiHoleSecondCollimatorModulatorBox; >> 259 >> 260 //SECOND COLLIMATOR >> 261 >> 262 G4Box* solidSecondCollimator; >> 263 G4LogicalVolume* logicSecondCollimator; >> 264 G4VPhysicalVolume* physiSecondCollimator; >> 265 >> 266 G4Tubs* solidHoleSecondCollimator; >> 267 G4LogicalVolume* logicHoleSecondCollimator; >> 268 G4VPhysicalVolume* physiHoleSecondCollimator; >> 269 >> 270 // FIRST MONITOR CHAMBER >> 271 >> 272 G4Box* solidFirstMonitorLayer1; >> 273 G4LogicalVolume* logicFirstMonitorLayer1; >> 274 G4VPhysicalVolume* physiFirstMonitorLayer1; >> 275 >> 276 G4Box* solidFirstMonitorLayer2; >> 277 G4LogicalVolume* logicFirstMonitorLayer2; >> 278 G4VPhysicalVolume* physiFirstMonitorLayer2; >> 279 >> 280 G4Box* solidFirstMonitorLayer3; >> 281 G4LogicalVolume* logicFirstMonitorLayer3; >> 282 G4VPhysicalVolume* physiFirstMonitorLayer3; >> 283 >> 284 G4Box* solidFirstMonitorLayer4; >> 285 G4LogicalVolume* logicFirstMonitorLayer4; >> 286 G4VPhysicalVolume* physiFirstMonitorLayer4; >> 287 >> 288 //SECODN MONITOR CHAMBER >> 289 >> 290 G4Box* solidSecondMonitorLayer1; >> 291 G4LogicalVolume* logicSecondMonitorLayer1; >> 292 G4VPhysicalVolume* physiSecondMonitorLayer1; >> 293 >> 294 G4Box* solidSecondMonitorLayer2; >> 295 G4LogicalVolume* logicSecondMonitorLayer2; >> 296 G4VPhysicalVolume* physiSecondMonitorLayer2; >> 297 >> 298 G4Box* solidSecondMonitorLayer3; >> 299 G4LogicalVolume* logicSecondMonitorLayer3; >> 300 G4VPhysicalVolume* physiSecondMonitorLayer3; >> 301 >> 302 G4Box* solidSecondMonitorLayer4; >> 303 G4LogicalVolume* logicSecondMonitorLayer4; >> 304 G4VPhysicalVolume* physiSecondMonitorLayer4; >> 305 >> 306 // THIRD MONITOR CHAMBER >> 307 >> 308 G4Box* solidThirdMonitorLayer1; >> 309 G4LogicalVolume* logicThirdMonitorLayer1; >> 310 G4VPhysicalVolume* physiThirdMonitorLayer1; >> 311 >> 312 G4Box* solidThirdMonitorLayer2; >> 313 G4LogicalVolume* logicThirdMonitorLayer2; >> 314 G4VPhysicalVolume* physiThirdMonitorLayer2; >> 315 >> 316 >> 317 G4Box* solidThirdMonitorLayer3; >> 318 G4LogicalVolume* logicThirdMonitorLayer3; >> 319 G4VPhysicalVolume* physiThirdMonitorLayer3; >> 320 >> 321 G4Box* solidThirdMonitorLayer4; >> 322 G4LogicalVolume* logicThirdMonitorLayer4; >> 323 G4VPhysicalVolume* physiThirdMonitorLayer4; >> 324 >> 325 //NOZZLE >> 326 >> 327 G4Box* solidNozzleSupport; >> 328 G4LogicalVolume* logicNozzleSupport; >> 329 G4VPhysicalVolume* physiNozzleSupport; >> 330 >> 331 G4Tubs* solidHoleNozzleSupport; >> 332 G4LogicalVolume* logicHoleNozzleSupport; >> 333 G4VPhysicalVolume* physiHoleNozzleSupport; >> 334 >> 335 G4Tubs* solidSecondHoleNozzleSupport; >> 336 G4LogicalVolume* logicSecondHoleNozzleSupport; >> 337 G4VPhysicalVolume* physiSecondHoleNozzleSupport; >> 338 >> 339 //FINAL COLLIMATOR >> 340 >> 341 G4Tubs* solidFinalCollimator; >> 342 G4LogicalVolume* logicFinalCollimator; >> 343 G4VPhysicalVolume* physiFinalCollimator; >> 344 >> 345 // WATER PHANTOM >> 346 >> 347 G4Box* solidWaterPhantom; >> 348 G4LogicalVolume* logicWaterPhantom; >> 349 G4VPhysicalVolume* physiWaterPhantom; >> 350 >> 351 //DOSEMETER (sensitive detector) >> 352 >> 353 G4Tubs* solidDosemeter; >> 354 G4LogicalVolume* logicDosemeter; >> 355 G4VPhysicalVolume* physiDosemeter; >> 356 HadrontherapyDetectorMessenger* detectorMessenger; >> 357 >> 358 HadrontherapyCalorimeterSD* calorimeterSD; //pointer to the sensitive detector >> 359 169 private: 360 private: 170 static HadrontherapyDetectorConstruction* << 361 G4VPhysicalVolume* ConstructCalorimeter(); 171 HadrontherapyDetectorMessenger* detectorMe << 172 << 173 G4VisAttributes* skyBlue; << 174 G4VisAttributes* red; << 175 << 176 HadrontherapyDetectorROGeometry* detectorR << 177 HadrontherapyMatrix* matrix; << 178 HadrontherapyLet* let; << 179 << 180 G4Box *phantom , *detector; << 181 G4LogicalVolume *phantomLogicalVolume, *de << 182 G4VPhysicalVolume *phantomPhysicalVolume, << 183 << 184 G4Box* solidVirtualLayer; << 185 G4LogicalVolume* logicVirtualLayer; << 186 G4VPhysicalVolume* physVirtualLayer; << 187 << 188 G4double phantomSizeX; << 189 G4double phantomSizeY; << 190 G4double phantomSizeZ; << 191 << 192 G4double detectorSizeX; << 193 G4double detectorSizeY; << 194 G4double detectorSizeZ; << 195 << 196 G4ThreeVector phantomPosition, detectorPos << 197 << 198 G4double sizeOfVoxelAlongX; << 199 G4double sizeOfVoxelAlongY; << 200 G4double sizeOfVoxelAlongZ; << 201 << 202 G4int numberOfVoxelsAlongX; << 203 G4int numberOfVoxelsAlongY; << 204 G4int numberOfVoxelsAlongZ; << 205 << 206 G4double volumeOfVoxel, massOfVoxel; << 207 << 208 G4Material *phantomMaterial, *detectorMate << 209 G4Region* aRegion; << 210 }; 362 }; 211 #endif 363 #endif >> 364 212 365