Changeset 1313 for trunk/examples/advanced/hadrontherapy/include/HadrontherapyDetectorConstruction.hh
- Timestamp:
- Jun 14, 2010, 3:54:58 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/examples/advanced/hadrontherapy/include/HadrontherapyDetectorConstruction.hh
r1230 r1313 56 56 void ConstructPhantom(); 57 57 void ConstructDetector(); 58 void ConstructSensitiveDetector(G4ThreeVector position_respect_to_WORLD); 59 58 void ConstructSensitiveDetector(G4ThreeVector positionToWORLD); 59 void ParametersCheck(); 60 60 61 public: 61 62 // Get detector position relative to WORLD … … 65 66 } 66 67 ///////////////////////////////////////////////////////////////////////////// 67 // Get displacement between phantom and detector by detector position , phantomand detector sizes68 // Get displacement between phantom and detector by detector position (center of), phantom (center of) and detector sizes 68 69 inline G4ThreeVector GetDetectorToPhantomPosition() 69 70 { 70 return G4ThreeVector(phantomSizeX - detectorSizeX+ detectorPosition.getX(),71 phantomSizeY - detectorSizeY+ detectorPosition.getY(),72 phantomSizeZ - detectorSizeZ+ detectorPosition.getZ()71 return G4ThreeVector(phantomSizeX/2 - detectorSizeX/2 + detectorPosition.getX(), 72 phantomSizeY/2 - detectorSizeY/2 + detectorPosition.getY(), 73 phantomSizeZ/2 - detectorSizeZ/2 + detectorPosition.getZ() 73 74 ); 74 75 } … … 79 80 { 80 81 // Adjust detector position 81 detectorPosition.setX(detectorToPhantomPosition.getX() - phantomSizeX + detectorSizeX);82 detectorPosition.setY(detectorToPhantomPosition.getY() - phantomSizeY + detectorSizeY);83 detectorPosition.setZ(detectorToPhantomPosition.getZ() - phantomSizeZ + detectorSizeZ);82 detectorPosition.setX(detectorToPhantomPosition.getX() - phantomSizeX/2 + detectorSizeX/2); 83 detectorPosition.setY(detectorToPhantomPosition.getY() - phantomSizeY/2 + detectorSizeY/2); 84 detectorPosition.setZ(detectorToPhantomPosition.getZ() - phantomSizeZ/2 + detectorSizeZ/2); 84 85 85 if (detectorPhysicalVolume) detectorPhysicalVolume -> SetTranslation(detectorPosition); 86 //G4cout << "*************** DetectorToPhantomPosition " << detectorToPhantomPosition/cm << "\n"; 87 //G4cout << "*************** DetectorPosition " << detectorPosition/cm << "\n"; 86 88 } 87 89 ///////////////////////////////////////////////////////////////////////////// 88 90 // Check whether detector is inside phantom 89 inline bool IsInside(G4double detector HalfX,90 G4double detector HalfY,91 G4double detector HalfZ,92 G4double phantom HalfX,93 G4double phantom HalfY,94 G4double phantom HalfZ,91 inline bool IsInside(G4double detectorX, 92 G4double detectorY, 93 G4double detectorZ, 94 G4double phantomX, 95 G4double phantomY, 96 G4double phantomZ, 95 97 G4ThreeVector detectorToPhantomPosition) 96 98 { 97 99 // Dimensions check... X Y and Z 98 100 // Firstly check what dimension we are modifying 99 if (detectorHalfX > 0. && phantomHalfX > 0. && detectorToPhantomPosition.getX() >=0.)100 101 { 101 if (detector HalfX > phantomHalfX)102 if (detectorX > phantomX) 102 103 { 103 104 G4cout << "Error: Detector X dimension must be smaller or equal to the corrispondent of the phantom" << G4endl; 104 105 return false; 105 106 } 106 if ( 2*(phantomHalfX - detectorHalfX) < detectorToPhantomPosition.getX())107 if ( (phantomX - detectorX) < detectorToPhantomPosition.getX()) 107 108 { 108 109 G4cout << "Error: X dimension doesn't fit with detector to phantom relative position" << G4endl; … … 111 112 } 112 113 113 if (detectorHalfY > 0. && phantomHalfY > 0.&& detectorToPhantomPosition.getY() >=0.)114 114 { 115 if (detector HalfY > phantomHalfY)115 if (detectorY > phantomY) 116 116 { 117 117 G4cout << "Error: Detector Y dimension must be smaller or equal to the corrispondent of the phantom" << G4endl; 118 118 return false; 119 119 } 120 if ( 2*(phantomHalfY - detectorHalfY) < detectorToPhantomPosition.getY())120 if ( (phantomY - detectorY) < detectorToPhantomPosition.getY()) 121 121 { 122 122 G4cout << "Error: Y dimension doesn't fit with detector to phantom relative position" << G4endl; … … 125 125 } 126 126 127 if (detectorHalfZ > 0. && phantomHalfZ > 0.&& detectorToPhantomPosition.getZ() >=0.)128 127 { 129 if (detector HalfZ > phantomHalfZ)128 if (detectorZ > phantomZ) 130 129 { 131 130 G4cout << "Error: Detector Z dimension must be smaller or equal to the corrispondent of the phantom" << G4endl; 132 131 return false; 133 132 } 134 if ( 2*(phantomHalfZ - detectorHalfZ) < detectorToPhantomPosition.getZ())133 if ( (phantomZ - detectorZ) < detectorToPhantomPosition.getZ()) 135 134 { 136 135 G4cout << "Error: Z dimension doesn't fit with detector to phantom relative position" << G4endl; … … 138 137 } 139 138 } 140 /* 141 G4cout << "Displacement between Phantom and Detector is: "; 142 G4cout << "DX= "<< G4BestUnit(detectorToPhantomPosition.getX(),"Length") << 143 "DY= "<< G4BestUnit(detectorToPhantomPosition.getY(),"Length") << 144 "DZ= "<< G4BestUnit(detectorToPhantomPosition.getZ(),"Length") << G4endl; 145 */ 139 146 140 return true; 147 141 } 148 142 ///////////////////////////////////////////////////////////////////////////// 149 143 150 G4bool SetNumberOfVoxelBySize(G4double sizeX, G4double sizeY, G4double sizeZ); 151 G4bool SetDetectorSize(G4double sizeX, G4double sizeY, G4double sizeZ); 152 G4bool SetPhantomSize(G4double sizeX, G4double sizeY, G4double sizeZ); 153 G4bool SetPhantomPosition(G4ThreeVector); 154 G4bool SetDetectorToPhantomPosition(G4ThreeVector DetectorToPhantomPosition); 144 G4bool SetPhantomMaterial(G4String material); 145 void SetVoxelSize(G4double sizeX, G4double sizeY, G4double sizeZ); 146 void SetDetectorSize(G4double sizeX, G4double sizeY, G4double sizeZ); 147 void SetPhantomSize(G4double sizeX, G4double sizeY, G4double sizeZ); 148 void SetPhantomPosition(G4ThreeVector); 149 void SetDetectorToPhantomPosition(G4ThreeVector DetectorToPhantomPosition); 150 void UpdateGeometry(); 151 void PrintParameters(); 155 152 G4LogicalVolume* GetDetectorLogicalVolume(){ return detectorLogicalVolume;} 156 153 … … 169 166 HadrontherapyMatrix* matrix; 170 167 171 G4VPhysicalVolume* phantomPhysicalVolume; 172 G4LogicalVolume* phantomLogicalVolume; 173 G4LogicalVolume* detectorLogicalVolume; 174 G4VPhysicalVolume* detectorPhysicalVolume; 168 G4Box *phantom , *detector; 169 G4LogicalVolume *phantomLogicalVolume, *detectorLogicalVolume; 170 G4VPhysicalVolume *phantomPhysicalVolume, *detectorPhysicalVolume; 175 171 176 172 G4double phantomSizeX; … … 192 188 G4int numberOfVoxelsAlongZ; 193 189 194 G4Box* phantom; 195 G4Box* detector; 190 G4double volumeOfVoxel, massOfVoxel; 196 191 192 G4Material *phantomMaterial, *detectorMaterial; 193 G4Region* aRegion; 197 194 }; 198 195 #endif
Note: See TracChangeset
for help on using the changeset viewer.