| 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 | // $Id: TiaraGeometry.cc,v 1.5 2006/06/29 15:45:03 gunter Exp $
|
|---|
| 27 | // GEANT4 tag $Name: $
|
|---|
| 28 | //
|
|---|
| 29 |
|
|---|
| 30 | #include "TiaraGeometry.hh"
|
|---|
| 31 | #include "TiaraDimensions.hh"
|
|---|
| 32 | #include "G4LogicalVolume.hh"
|
|---|
| 33 | #include "G4Box.hh"
|
|---|
| 34 | #include "G4Tubs.hh"
|
|---|
| 35 | #include "TiaraMaterials.hh"
|
|---|
| 36 | #include "G4PVPlacement.hh"
|
|---|
| 37 | #include "TiaraConcreteShieldA.hh"
|
|---|
| 38 | #include "TiaraIronShieldA.hh"
|
|---|
| 39 | #include "TiaraConcreteShieldB.hh"
|
|---|
| 40 | #include "TiaraIronShieldB.hh"
|
|---|
| 41 | #include "TiaraPart.hh"
|
|---|
| 42 | #include "G4Colour.hh"
|
|---|
| 43 | #include "G4VisAttributes.hh"
|
|---|
| 44 |
|
|---|
| 45 | TiaraGeometry::TiaraGeometry(TiaraMaterials &matfac) :
|
|---|
| 46 | fLogicalWorld(0),
|
|---|
| 47 | fWorldVolume(0),
|
|---|
| 48 | fMaterials(matfac),
|
|---|
| 49 | fShieldWidth(0),
|
|---|
| 50 | fColimatorWidth(0),
|
|---|
| 51 | fColliPipeLogVol(0),
|
|---|
| 52 | fTiaraDimensions(TiaraDimensions())
|
|---|
| 53 | {}
|
|---|
| 54 |
|
|---|
| 55 | TiaraGeometry::~TiaraGeometry()
|
|---|
| 56 | {}
|
|---|
| 57 |
|
|---|
| 58 | G4VPhysicalVolume* TiaraGeometry::Construct(){
|
|---|
| 59 | PlaceComponents();
|
|---|
| 60 | return fWorldVolume;
|
|---|
| 61 | }
|
|---|
| 62 |
|
|---|
| 63 | G4Material *TiaraGeometry::GetWorldMaterial() {
|
|---|
| 64 | return fMaterials.GetMaterial("vacuum");
|
|---|
| 65 | }
|
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 | void TiaraGeometry::ConstHall(){
|
|---|
| 69 | G4VSolid *worldSolid = new G4Box("worldBox",
|
|---|
| 70 | fTiaraDimensions.worldHalfWidth,
|
|---|
| 71 | fTiaraDimensions.worldHalfWidth,
|
|---|
| 72 | fTiaraDimensions.worldHalfLength);
|
|---|
| 73 | fLogicalWorld =
|
|---|
| 74 | new G4LogicalVolume(worldSolid, GetWorldMaterial(), "LogicalWorld");
|
|---|
| 75 | G4String name("Hall");
|
|---|
| 76 | fWorldVolume = new
|
|---|
| 77 | G4PVPlacement(0, G4ThreeVector(0,0,0), fLogicalWorld,
|
|---|
| 78 | name, 0, false, 0);
|
|---|
| 79 | }
|
|---|
| 80 |
|
|---|
| 81 | void TiaraGeometry::CreateComponents(){
|
|---|
| 82 |
|
|---|
| 83 | fTiaraComponents.
|
|---|
| 84 | insert(new TiaraConcreteShieldA(fMaterials, fTiaraDimensions));
|
|---|
| 85 |
|
|---|
| 86 | fTiaraComponents.
|
|---|
| 87 | insert(new TiaraIronShieldA(fMaterials, fTiaraDimensions));
|
|---|
| 88 |
|
|---|
| 89 | fTiaraComponents.
|
|---|
| 90 | insert(new TiaraConcreteShieldB(fMaterials, fTiaraDimensions));
|
|---|
| 91 |
|
|---|
| 92 | fTiaraComponents.
|
|---|
| 93 | insert(new TiaraIronShieldB(fMaterials, fTiaraDimensions));
|
|---|
| 94 |
|
|---|
| 95 | }
|
|---|
| 96 |
|
|---|
| 97 | G4VPhysicalVolume *TiaraGeometry::
|
|---|
| 98 | AddPhysicalDetector(G4double xDist,
|
|---|
| 99 | const G4String &physName) {
|
|---|
| 100 | G4Tubs *tub = new G4Tubs("detectorTub",
|
|---|
| 101 | 0,
|
|---|
| 102 | fTiaraDimensions.detectorRadius,
|
|---|
| 103 | fTiaraDimensions.detectorHalfHight,
|
|---|
| 104 | 0,
|
|---|
| 105 | 360 * deg);
|
|---|
| 106 |
|
|---|
| 107 | G4ThreeVector pos(xDist, 0, fTiaraDimensions.targetPosZ +
|
|---|
| 108 | fTiaraDimensions.distTargetExperiment +
|
|---|
| 109 | fShieldWidth + fColimatorWidth +
|
|---|
| 110 | fTiaraDimensions.detectorHalfHight);
|
|---|
| 111 |
|
|---|
| 112 | G4Material *mat = fMaterials.GetMaterial("vacuum");
|
|---|
| 113 | G4LogicalVolume *logVol =
|
|---|
| 114 | new G4LogicalVolume(tub, mat, "logDetectorTub");
|
|---|
| 115 | G4VisAttributes* pVis = new
|
|---|
| 116 | G4VisAttributes(G4Colour(1, 0, 0));
|
|---|
| 117 | logVol->SetVisAttributes(pVis);
|
|---|
| 118 |
|
|---|
| 119 |
|
|---|
| 120 | return PlaceExpComponent(pos, logVol, physName);
|
|---|
| 121 |
|
|---|
| 122 | }
|
|---|
| 123 |
|
|---|
| 124 | G4VPhysicalVolume *TiaraGeometry::
|
|---|
| 125 | AddPhysicalRingDetector(G4double xDist,
|
|---|
| 126 | const G4String &physName){
|
|---|
| 127 | if (xDist < fTiaraDimensions.detectorRadius) {
|
|---|
| 128 | G4cout << "TiaraGeometry::AddPhysicalRingDetector: (xDist < fTiaraDimensions.detectorRadius" << G4endl;
|
|---|
| 129 | return 0;
|
|---|
| 130 | }
|
|---|
| 131 | G4Tubs *tub = new G4Tubs("detectorTub",
|
|---|
| 132 | xDist - fTiaraDimensions.detectorRadius,
|
|---|
| 133 | xDist + fTiaraDimensions.detectorRadius,
|
|---|
| 134 | fTiaraDimensions.detectorHalfHight,
|
|---|
| 135 | 0,
|
|---|
| 136 | 360 * deg);
|
|---|
| 137 | G4ThreeVector pos(0, 0, fTiaraDimensions.targetPosZ +
|
|---|
| 138 | fTiaraDimensions.distTargetExperiment +
|
|---|
| 139 | fShieldWidth + fColimatorWidth +
|
|---|
| 140 | fTiaraDimensions.detectorHalfHight);
|
|---|
| 141 |
|
|---|
| 142 | G4Material *mat = fMaterials.GetMaterial("vacuum");
|
|---|
| 143 | G4LogicalVolume *logVol =
|
|---|
| 144 | new G4LogicalVolume(tub, mat, "logRingDetectorTub");
|
|---|
| 145 | G4VisAttributes* pVis = new
|
|---|
| 146 | G4VisAttributes(G4Colour(1, 0, 0));
|
|---|
| 147 | logVol->SetVisAttributes(pVis);
|
|---|
| 148 |
|
|---|
| 149 | return PlaceExpComponent(pos, logVol, physName);
|
|---|
| 150 |
|
|---|
| 151 | }
|
|---|
| 152 |
|
|---|
| 153 | G4VPhysicalVolume *TiaraGeometry::
|
|---|
| 154 | AddDetectorSlab( const G4String &physName) {
|
|---|
| 155 | G4Tubs *tub = new G4Tubs("detectorTub",
|
|---|
| 156 | 0,
|
|---|
| 157 | 0.5*fTiaraDimensions.widthExperiment,
|
|---|
| 158 | fTiaraDimensions.detectorHalfHight,
|
|---|
| 159 | 0,
|
|---|
| 160 | 360 * deg);
|
|---|
| 161 | G4ThreeVector pos(0, 0, fTiaraDimensions.targetPosZ +
|
|---|
| 162 | fTiaraDimensions.distTargetExperiment +
|
|---|
| 163 | fShieldWidth + fColimatorWidth +
|
|---|
| 164 | fTiaraDimensions.detectorHalfHight);
|
|---|
| 165 |
|
|---|
| 166 | G4Material *mat = fMaterials.GetMaterial("vacuum");
|
|---|
| 167 | G4LogicalVolume *logVol =
|
|---|
| 168 | new G4LogicalVolume(tub, mat, "logSlabDetectorTub");
|
|---|
| 169 | G4VisAttributes* pVis = new
|
|---|
| 170 | G4VisAttributes(G4Colour(1, 0, 0));
|
|---|
| 171 | logVol->SetVisAttributes(pVis);
|
|---|
| 172 |
|
|---|
| 173 | return PlaceExpComponent(pos, logVol, physName);
|
|---|
| 174 |
|
|---|
| 175 | }
|
|---|
| 176 |
|
|---|
| 177 | G4VPhysicalVolume *TiaraGeometry::
|
|---|
| 178 | AddSourceDetector() {
|
|---|
| 179 | G4Tubs *tub = new G4Tubs("srcTub",
|
|---|
| 180 | 0,
|
|---|
| 181 | fTiaraDimensions.pipeRadius,
|
|---|
| 182 | fTiaraDimensions.srcDetectorWidth / 2,
|
|---|
| 183 | 0,
|
|---|
| 184 | 360 * deg);
|
|---|
| 185 | G4Material *mat = fMaterials.GetMaterial("vacuum");
|
|---|
| 186 | G4LogicalVolume *logVol =
|
|---|
| 187 | new G4LogicalVolume(tub, mat, "logSrcDetector");
|
|---|
| 188 |
|
|---|
| 189 | G4VisAttributes* pVis = new
|
|---|
| 190 | G4VisAttributes(G4Colour(1, 0, 0));
|
|---|
| 191 | logVol->SetVisAttributes(pVis);
|
|---|
| 192 |
|
|---|
| 193 | G4VPhysicalVolume *physVol = 0;
|
|---|
| 194 | if (fColliPipeLogVol) {
|
|---|
| 195 | G4ThreeVector pos(0, 0, fColimatorWidth/2 -
|
|---|
| 196 | fTiaraDimensions.srcDetectorWidth / 2);
|
|---|
| 197 | physVol = new G4PVPlacement(0,
|
|---|
| 198 | pos,
|
|---|
| 199 | logVol,
|
|---|
| 200 | "sourceDetector",
|
|---|
| 201 | fColliPipeLogVol,
|
|---|
| 202 | false,
|
|---|
| 203 | 0);
|
|---|
| 204 | }
|
|---|
| 205 | else {
|
|---|
| 206 | G4ThreeVector pos(0, 0, fTiaraDimensions.targetPosZ +
|
|---|
| 207 | fTiaraDimensions.distTargetExperiment +
|
|---|
| 208 | fColimatorWidth -
|
|---|
| 209 | fTiaraDimensions.srcDetectorWidth / 2);
|
|---|
| 210 | physVol = PlaceExpComponent(pos, logVol, "sourceDetector");
|
|---|
| 211 | }
|
|---|
| 212 |
|
|---|
| 213 | return physVol;
|
|---|
| 214 | }
|
|---|
| 215 |
|
|---|
| 216 |
|
|---|
| 217 | void TiaraGeometry::PlaceComponents(){
|
|---|
| 218 | for (TiaraComponents::iterator it = fTiaraComponents.begin();
|
|---|
| 219 | it != fTiaraComponents.end(); ++it) {
|
|---|
| 220 | TiaraParts tiaraParts = (*it)->GetParts();
|
|---|
| 221 | for (TiaraParts::iterator ip = tiaraParts.begin();
|
|---|
| 222 | ip != tiaraParts.end(); ++ip){
|
|---|
| 223 | TiaraPart tiaraPart = *ip;
|
|---|
| 224 | G4LogicalVolume *logVol = ip->logVol;
|
|---|
| 225 | G4cout << logVol->GetName()
|
|---|
| 226 | << ", pos: " << ip->pos << G4endl;
|
|---|
| 227 | G4String name(logVol->GetName());
|
|---|
| 228 | name += "_placed";
|
|---|
| 229 | new G4PVPlacement(ip->rot,
|
|---|
| 230 | ip->pos,
|
|---|
| 231 | logVol,
|
|---|
| 232 | name,
|
|---|
| 233 | fLogicalWorld,
|
|---|
| 234 | false,
|
|---|
| 235 | 0);
|
|---|
| 236 | }
|
|---|
| 237 | }
|
|---|
| 238 | }
|
|---|
| 239 |
|
|---|
| 240 |
|
|---|
| 241 | void TiaraGeometry::BuildGeometry(const TiaraDimensions &td){
|
|---|
| 242 | fTiaraDimensions = td;
|
|---|
| 243 | ConstHall();
|
|---|
| 244 | }
|
|---|
| 245 |
|
|---|
| 246 | G4LogicalVolume *TiaraGeometry::BuildShield(G4double width,
|
|---|
| 247 | const G4String &matName){
|
|---|
| 248 |
|
|---|
| 249 | fShieldWidth = width;
|
|---|
| 250 |
|
|---|
| 251 | G4LogicalVolume *logVol = 0;
|
|---|
| 252 | if (! (width > 0)) {
|
|---|
| 253 | G4cout << "TiaraGeometry::BuildShield width must be > 0"
|
|---|
| 254 | << G4endl;
|
|---|
| 255 | }
|
|---|
| 256 | else {
|
|---|
| 257 | G4Material *mat = 0;
|
|---|
| 258 | mat = fMaterials.GetMaterial(matName);
|
|---|
| 259 | if (!mat) {
|
|---|
| 260 | G4cout << "TiaraGeometry::BuildShield no valid material"
|
|---|
| 261 | << G4endl;
|
|---|
| 262 | }
|
|---|
| 263 | else {
|
|---|
| 264 | G4Box *box = new G4Box("box",
|
|---|
| 265 | fTiaraDimensions.widthExperiment/2,
|
|---|
| 266 | fTiaraDimensions.widthExperiment/2,
|
|---|
| 267 | width/2);
|
|---|
| 268 | logVol = new G4LogicalVolume(box, mat, "logShieldBox");
|
|---|
| 269 | G4VisAttributes* pVis = new
|
|---|
| 270 | G4VisAttributes(G4Colour(1, 1, 0));
|
|---|
| 271 | logVol->SetVisAttributes(pVis);
|
|---|
| 272 | }
|
|---|
| 273 | }
|
|---|
| 274 | return logVol;
|
|---|
| 275 | }
|
|---|
| 276 |
|
|---|
| 277 | G4LogicalVolume *TiaraGeometry::
|
|---|
| 278 | BuildCollimator(G4double width,
|
|---|
| 279 | const G4String &outerMatName,
|
|---|
| 280 | const G4String &innerMatName) {
|
|---|
| 281 | fColimatorWidth = width;
|
|---|
| 282 |
|
|---|
| 283 | G4LogicalVolume *logVol = 0;
|
|---|
| 284 | if (! (width > 0)) {
|
|---|
| 285 | G4cout << "TiaraGeometry::BuildCollimator witdth must be > 0"
|
|---|
| 286 | << G4endl;
|
|---|
| 287 | }
|
|---|
| 288 | else {
|
|---|
| 289 | G4Material *matOuter = 0;
|
|---|
| 290 | matOuter = fMaterials.GetMaterial(outerMatName);
|
|---|
| 291 | G4Material *matInner = 0;
|
|---|
| 292 | matInner = fMaterials.GetMaterial(innerMatName);
|
|---|
| 293 | if (!matOuter || !matInner) {
|
|---|
| 294 | G4cout << "TiaraGeometry::BuildCollimator no valid material"
|
|---|
| 295 | << G4endl;
|
|---|
| 296 | }
|
|---|
| 297 | else {
|
|---|
| 298 | G4Box *box = new G4Box("box",
|
|---|
| 299 | fTiaraDimensions.widthExperiment/2,
|
|---|
| 300 | fTiaraDimensions.widthExperiment/2,
|
|---|
| 301 | width/2);
|
|---|
| 302 | logVol = new G4LogicalVolume(box, matOuter, "logColimatorBox");
|
|---|
| 303 | G4VisAttributes* pVis = new
|
|---|
| 304 | G4VisAttributes(G4Colour(0.0, 1.0, 0.0));
|
|---|
| 305 | logVol->SetVisAttributes(pVis);
|
|---|
| 306 |
|
|---|
| 307 | G4Tubs *tub = new G4Tubs("tub",
|
|---|
| 308 | 0,
|
|---|
| 309 | fTiaraDimensions.pipeRadius,
|
|---|
| 310 | width/2,
|
|---|
| 311 | 0,
|
|---|
| 312 | 360 * deg);
|
|---|
| 313 |
|
|---|
| 314 | fColliPipeLogVol = new G4LogicalVolume(tub, matInner,
|
|---|
| 315 | "logColimatorTub");
|
|---|
| 316 |
|
|---|
| 317 | new G4PVPlacement(0,
|
|---|
| 318 | G4ThreeVector(0, 0, 0),
|
|---|
| 319 | fColliPipeLogVol,
|
|---|
| 320 | "pipeInCollimator",
|
|---|
| 321 | logVol,
|
|---|
| 322 | false,
|
|---|
| 323 | 0);
|
|---|
| 324 | }
|
|---|
| 325 | }
|
|---|
| 326 | return logVol;
|
|---|
| 327 | }
|
|---|
| 328 |
|
|---|
| 329 | G4VPhysicalVolume *TiaraGeometry::
|
|---|
| 330 | PlaceExpComponent(const G4ThreeVector &pos,
|
|---|
| 331 | G4LogicalVolume *logVol,
|
|---|
| 332 | const G4String &physName){
|
|---|
| 333 |
|
|---|
| 334 | return new G4PVPlacement(0,
|
|---|
| 335 | pos,
|
|---|
| 336 | logVol,
|
|---|
| 337 | physName,
|
|---|
| 338 | fLogicalWorld,
|
|---|
| 339 | false,
|
|---|
| 340 | 0);
|
|---|
| 341 |
|
|---|
| 342 | }
|
|---|
| 343 |
|
|---|