Geant4 Cross Reference |
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 // 27 // 28 // Author: Alfonso Mantero (Alfonso.Mantero@ge.infn.it) 29 // 30 // History: 31 // ----------- 32 // 28 Nov 2001 Elena Guardincerri Created 33 // Nov 2002 Alfonso Mantero materials added, 34 // Material selection implementation 35 // 16 Jul 2003 Alfonso Mantero Detector type selection added + minor fixes 36 // ------------------------------------------------------------------- 37 38 #include "XrayFluoDetectorConstruction.hh" 39 #include "XrayFluoDetectorMessenger.hh" 40 #include "XrayFluoSD.hh" 41 #include "G4PhysicalConstants.hh" 42 #include "G4SystemOfUnits.hh" 43 #include "G4Material.hh" 44 #include "G4ThreeVector.hh" 45 #include "G4Box.hh" 46 #include "G4Sphere.hh" 47 #include "G4Tubs.hh" 48 #include "G4LogicalVolume.hh" 49 #include "G4PVPlacement.hh" 50 #include "G4TransportationManager.hh" 51 #include "G4SDManager.hh" 52 #include "G4RunManager.hh" 53 #include "G4VisAttributes.hh" 54 #include "G4Colour.hh" 55 #include "G4ios.hh" 56 #include "G4PVReplica.hh" 57 #include "G4UserLimits.hh" 58 #include "G4GeometryManager.hh" 59 #include "G4PhysicalVolumeStore.hh" 60 #include "G4LogicalVolumeStore.hh" 61 #include "G4SolidStore.hh" 62 #include "XrayFluoNistMaterials.hh" 63 #include "G4SDManager.hh" 64 65 // #include "G4Region.hh" 66 // #include "G4RegionStore.hh" 67 68 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 69 70 71 XrayFluoDetectorConstruction::XrayFluoDetectorConstruction() 72 : aNavigator(0), detectorType(0),sampleGranularity(false), phaseSpaceFlag(false), 73 DeviceSizeX(0), DeviceSizeY(0),DeviceThickness(0), 74 solidWorld(0),logicWorld(0),physiWorld(0), 75 solidHPGe(0),logicHPGe(0),physiHPGe(0), 76 solidSample (0),logicSample(0),physiSample (0), 77 solidDia1(0),logicDia1(0),physiDia1(0), 78 solidDia3(0),logicDia3(0),physiDia3(0), 79 solidOhmicPos(0),logicOhmicPos(0), physiOhmicPos(0), 80 solidWindow(0), logicWindow(0), physiWindow(0), 81 solidOhmicNeg(0),logicOhmicNeg(0), physiOhmicNeg(0), 82 solidPixel(0),logicPixel(0), physiPixel(0), 83 OhmicPosMaterial(0), OhmicNegMaterial(0), 84 pixelMaterial(0),sampleMaterial(0), 85 Dia1Material(0),Dia3Material(0), 86 defaultMaterial(0), windowMaterial (0) 87 { 88 materials = XrayFluoNistMaterials::GetInstance(); 89 90 HPGeSD.Put(0); 91 92 aNavigator = new G4Navigator(); 93 94 DefineDefaultMaterials(); 95 96 NbOfPixelRows = 1; // should be 1 97 NbOfPixelColumns = 1; // should be 1 98 NbOfPixels = NbOfPixelRows*NbOfPixelColumns; 99 PixelSizeXY = std::sqrt(40.) * mm; 100 PixelThickness = 2.7 * mm; //should be 3.5 mm 101 102 G4cout << "PixelThickness(mm): "<< PixelThickness/mm << G4endl; 103 G4cout << "PixelSizeXY(cm): "<< PixelSizeXY/cm << G4endl; 104 105 ContactSizeXY = PixelSizeXY; //std::sqrt(40) * mm; //should be the same as PixelSizeXY 106 SampleThickness = 4 * mm; 107 SampleSizeXY = 3. * cm; 108 Dia1Thickness = 1. *mm; 109 Dia3Thickness = 1. *mm; 110 Dia1SizeXY = 3. *cm; 111 Dia3SizeXY = 3. *cm; 112 113 114 DiaInnerSize = 2.9 * cm; //(Hole in the detector's diaphragm) it was 1 mm 115 116 117 OhmicNegThickness = 1e-6*cm;// 0.005 118 OhmicPosThickness = 1e-6*cm;// 0.005 119 windowThickness = 0.008 * cm; //value for aif detector 120 ThetaHPGe = 135. * deg; 121 PhiHPGe = 225. * deg; 122 123 ThetaDia1 = 135. * deg; 124 PhiDia1 = 90. * deg; 125 AlphaDia1 = 225. * deg; 126 127 AlphaDia3 = 180. * deg; 128 Dia3Dist = 66.5 * mm; 129 Dia3InnerSize = 1. * mm; 130 ThetaDia3 = 180. * deg; 131 PhiDia3 = 90. * deg; 132 133 DistDia = 66.5 * mm; 134 DistDe =DistDia+ (Dia1Thickness 135 +PixelThickness)/2+OhmicPosThickness+windowThickness ; 136 137 grainDia = 1 * mm; 138 PixelCopyNb=0; 139 grainCopyNb=0; 140 G4String defaultDetectorType = "sili"; 141 ComputeApparateParameters(); 142 143 // G4String regName = "SampleRegion"; 144 // sampleRegion = new G4Region(regName); 145 146 if (!phaseSpaceFlag) SetDetectorType(defaultDetectorType); 147 148 // create commands for interactive definition of the apparate 149 150 detectorMessenger = new XrayFluoDetectorMessenger(this); 151 152 G4cout << "XrayFluoDetectorConstruction created" << G4endl; 153 } 154 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 155 156 157 XrayFluoDetectorConstruction* XrayFluoDetectorConstruction::instance = 0; 158 159 XrayFluoDetectorConstruction* XrayFluoDetectorConstruction::GetInstance() 160 { 161 if (instance == 0) 162 { 163 instance = new XrayFluoDetectorConstruction; 164 165 } 166 return instance; 167 } 168 169 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 170 171 void XrayFluoDetectorConstruction::SetDetectorType(G4String type) 172 { 173 if (type=="sili") 174 { 175 detectorType = XrayFluoSiLiDetectorType::GetInstance(); 176 } 177 else if (type=="hpge") 178 { 179 detectorType = XrayFluoHPGeDetectorType::GetInstance(); 180 }/* 181 else if (type=="aifira") 182 { 183 detectorType = XrayFluoAifSiLi::GetInstance(); 184 }*/ 185 else 186 { 187 G4ExceptionDescription execp; 188 execp << type + "detector type unknown"; 189 G4Exception("XrayFluoDataSet::LoadData()","example-xray_fluorescence06", 190 FatalException, execp); 191 } 192 //GeometryHasBeenModified invoked by the messenger 193 194 } 195 196 XrayFluoVDetectorType* XrayFluoDetectorConstruction::GetDetectorType() const 197 { 198 return detectorType; 199 } 200 201 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 202 203 XrayFluoDetectorConstruction::~XrayFluoDetectorConstruction() 204 205 { 206 delete detectorMessenger; 207 delete detectorType; 208 G4cout << "XrayFluoDetectorConstruction deleted" << G4endl; 209 } 210 211 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 212 213 G4VPhysicalVolume* XrayFluoDetectorConstruction::Construct() 214 { 215 return ConstructApparate(); 216 } 217 218 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 219 220 void XrayFluoDetectorConstruction::DefineDefaultMaterials() 221 { 222 223 224 //define materials of the apparate 225 226 sampleMaterial = materials->GetMaterial("Dolorite"); 227 Dia1Material = materials->GetMaterial("G4_Pb"); 228 Dia3Material = materials->GetMaterial("G4_Galactic"); 229 pixelMaterial = materials->GetMaterial("SiLi"); 230 //OhmicPosMaterial = materials->GetMaterial("G4_Cu"); 231 OhmicPosMaterial = materials->GetMaterial("G4_Ni"); 232 OhmicNegMaterial = materials->GetMaterial("G4_Pb"); 233 defaultMaterial = materials->GetMaterial("G4_Galactic"); 234 windowMaterial = materials->GetMaterial("G4_Be"); 235 } 236 237 void XrayFluoDetectorConstruction::SetOhmicPosThickness(G4double val) 238 { 239 240 if (!phaseSpaceFlag) { 241 242 243 if (val == 0.0) { 244 OhmicPosMaterial = materials->GetMaterial("G4_Galactic"); 245 } 246 else { 247 OhmicPosThickness = val; 248 //OhmicPosMaterial = materials->GetMaterial("G4_Cu"); 249 OhmicPosMaterial = materials->GetMaterial("G4_Ni"); 250 } 251 252 } 253 else{ 254 G4cout << "Not available in this configuration" << G4endl; 255 } 256 257 } 258 259 260 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 261 262 G4VPhysicalVolume* XrayFluoDetectorConstruction::ConstructApparate() 263 { 264 // complete the apparate parameters definition 265 266 //ComputeApparateParameters(); 267 268 //world and associated navigator 269 270 solidWorld = new G4Box("World", //its name 271 WorldSizeXY/2,WorldSizeXY/2,WorldSizeZ/2); //its size 272 273 logicWorld = new G4LogicalVolume(solidWorld, //its solid 274 defaultMaterial, //its material 275 "World"); //its name 276 physiWorld = new G4PVPlacement(0, //no rotation 277 G4ThreeVector(), //at (0,0,0) 278 "World", //its name 279 logicWorld, //its logical volume 280 0, //its mother volume 281 false, //no boolean operation 282 0); //copy number 283 284 aNavigator->SetWorldVolume(physiWorld); 285 286 287 //HPGeDetector 288 289 if (!phaseSpaceFlag) { 290 291 solidHPGe = 0; physiHPGe = 0; logicHPGe=0; 292 solidPixel=0; logicPixel=0; physiPixel=0; 293 294 if (DeviceThickness > 0.) 295 { 296 solidHPGe = new G4Box("HPGeDetector", //its name 297 DeviceSizeX/2,DeviceSizeY/2,DeviceThickness/2);//size 298 299 300 logicHPGe = new G4LogicalVolume(solidHPGe, //its solid 301 defaultMaterial, //its material 302 "HPGeDetector"); //its name 303 304 zRotPhiHPGe.rotateX(PhiHPGe); 305 G4double x,y,z; 306 z = DistDe * std::cos(ThetaHPGe); 307 y =DistDe * std::sin(ThetaHPGe); 308 x = 0.*cm; 309 physiHPGe = new G4PVPlacement(G4Transform3D(zRotPhiHPGe,G4ThreeVector(x,y,z)), 310 "HPGeDetector", //its name 311 logicHPGe, //its logical volume 312 physiWorld, //its mother volume 313 false, //no boolean operation 314 0); //copy number 315 } 316 // Pixel 317 318 319 320 321 for ( G4int j=0; j < NbOfPixelColumns ; j++ ) 322 { for ( G4int i=0; i < NbOfPixelRows ; i++ ) 323 { 324 solidPixel=0; logicPixel=0; physiPixel=0; 325 if (PixelThickness > 0.) 326 solidPixel = new G4Box("Pixel", 327 PixelSizeXY/2,PixelSizeXY/2, PixelThickness/2); 328 329 logicPixel = new G4LogicalVolume(solidPixel, 330 pixelMaterial, //its material 331 "Pixel"); //its name 332 333 /* 334 zRotPhiHPGe.rotateX(PhiHPGe); 335 G4double x,y,z; 336 z = DistDe * std::cos(ThetaHPGe); 337 y =DistDe * std::sin(ThetaHPGe); 338 x = 0.*cm;*/ 339 physiPixel = new G4PVPlacement(0, 340 G4ThreeVector(0, 341 i*PixelSizeXY, 342 j*PixelSizeXY ), 343 "Pixel", 344 logicPixel, //its logical volume 345 physiHPGe, //its mother volume 346 false, //no boolean operation 347 PixelCopyNb);//copy number 348 349 350 351 352 353 354 // OhmicNeg 355 356 solidOhmicNeg=0; logicOhmicNeg=0; physiOhmicNeg=0; 357 358 if (OhmicNegThickness > 0.) 359 { solidOhmicNeg = new G4Box("OhmicNeg", //its name 360 PixelSizeXY/2,PixelSizeXY/2,OhmicNegThickness/2); 361 362 logicOhmicNeg = new G4LogicalVolume(solidOhmicNeg, //its solid 363 OhmicNegMaterial, //its material 364 "OhmicNeg"); //its name 365 366 physiOhmicNeg = new G4PVPlacement(0, 367 G4ThreeVector 368 (0., 369 0., 370 (PixelThickness+OhmicNegThickness)/2), 371 "OhmicNeg", //its name 372 logicOhmicNeg, //its logical volume 373 physiHPGe, //its mother 374 false, //no boulean operat 375 PixelCopyNb); //copy number 376 377 } 378 // OhmicPos 379 solidOhmicPos=0; logicOhmicPos=0; physiOhmicPos=0; 380 381 if (OhmicPosThickness > 0.) 382 { solidOhmicPos = new G4Box("OhmicPos", //its name 383 PixelSizeXY/2,PixelSizeXY/2,OhmicPosThickness/2); 384 385 logicOhmicPos = new G4LogicalVolume(solidOhmicPos, //its solid 386 OhmicPosMaterial, //its material 387 "OhmicPos"); //its name 388 389 physiOhmicPos = new G4PVPlacement(0, 390 G4ThreeVector(0., 391 0., 392 (-PixelThickness-OhmicPosThickness)/2), 393 "OhmicPos", 394 logicOhmicPos, 395 physiHPGe, 396 false, 397 PixelCopyNb); 398 399 } 400 401 /////////// widow place here! //////////////// 402 // OhmicPos 403 solidWindow=0; logicWindow=0; physiWindow=0; 404 405 if (windowThickness > 0.) 406 { solidWindow = new G4Box("Window", //its name 407 PixelSizeXY/2,PixelSizeXY/2,windowThickness/2); 408 409 logicWindow = new G4LogicalVolume(solidWindow, //its solid 410 windowMaterial, //its material 411 "Window"); //its name 412 413 physiWindow = new G4PVPlacement(0, 414 G4ThreeVector(0., 415 0., 416 ((-PixelThickness-windowThickness)/2) 417 -OhmicPosThickness), 418 "OhmicWindow", 419 logicWindow, 420 physiHPGe, 421 false, 422 PixelCopyNb); 423 424 } 425 426 427 428 PixelCopyNb += PixelCopyNb; 429 G4cout << "PixelCopyNb: " << PixelCopyNb << G4endl; 430 } 431 432 } 433 434 } 435 436 //Sample 437 438 if (sampleGranularity) { 439 440 solidSample=0; logicSample=0; physiSample=0; 441 if (SampleThickness > 0.) 442 { 443 solidSample = new G4Box("Sample", //its name 444 SampleSizeXY/2,SampleSizeXY/2,SampleThickness/2);//size 445 446 logicSample= new G4LogicalVolume(solidSample, //its solid 447 defaultMaterial, //its material 448 "Sample"); //its name 449 450 physiSample = new G4PVPlacement(0, //no rotation 451 G4ThreeVector(), //at (0,0,0) 452 "Sample", //its name 453 logicSample, //its logical volume 454 physiWorld, //its mother volume 455 false, //no boolean operation 456 0); //copy number 457 458 } 459 460 461 462 463 G4int nbOfGrainsX = ((G4int)(SampleSizeXY/grainDia)) -1 ; 464 465 // y dim of a max density plane is 2rn-(n-1)ar, wehere a = (1-(std::sqrt(3)/2)), n is 466 // number of rows and r the radius of the grain. so the Y-dim of the sample must 467 // be greater or equal to this. It results that nmust be <= (SampleY-a)/(1-a). 468 // Max Y shift of the planes superimposing along Z axis is minor (2/std::sqrt(3)r) 469 470 G4double a = (1.-(std::sqrt(3.)/2.)); 471 G4int nbOfGrainsY = (G4int) ( ((SampleSizeXY/(grainDia/2.)) -a)/(2.-a) ) -1; 472 473 // same for the z axis, but a = 2 * (std::sqrt(3) - std::sqrt(2))/std::sqrt(3) 474 475 G4double b = 2. * (std::sqrt(3.) - std::sqrt(2.))/std::sqrt(3.); 476 G4int nbOfGrainsZ = (G4int) ( ((SampleThickness/(grainDia/2.)) -b)/(2.-b) )-1; 477 478 if (SampleThickness > 0.){ 479 480 solidGrain=0; logicGrain=0; physiGrain=0; 481 solidGrain = new G4Sphere("Grain",0., 482 grainDia/2,0., twopi, 0., pi); 483 484 logicGrain = new G4LogicalVolume(solidGrain, 485 sampleMaterial, //its material 486 "Grain"); //its name 487 G4ThreeVector grainPosition; 488 G4double grainInitPositionX = 0; 489 G4double grainInitPositionY = 0; 490 G4double grainInitPositionZ = (-1.*SampleThickness/2.+grainDia/2.); 491 G4double grainStepX = grainDia = 0; 492 G4double grainStepY = grainDia*(1.-(0.5-(std::sqrt(3.)/4.))); 493 G4double grainStepZ = grainDia*std::sqrt(2./3.); 494 495 for ( G4int k=0; k < nbOfGrainsZ ; k++ ) { 496 for ( G4int j=0; j < nbOfGrainsY ; j++ ) { 497 for ( G4int i=0; i < nbOfGrainsX ; i++ ) { 498 499 // Now we identify the layer and the row where the grain is , to place it in the right position 500 501 502 503 if (k%3 == 0) { // first or (4-multiple)th layer: structure is ABCABC 504 grainInitPositionY = (-1.*SampleSizeXY/2.+grainDia/2.); 505 if (j%2 ==0) { //first or (3-multiple)th row 506 grainInitPositionX = (-1.*SampleSizeXY/2.+grainDia/2.); 507 } 508 509 else if ( ((j+1) % 2) == 0 ) { 510 grainInitPositionX = (-1.*SampleSizeXY/2.+ grainDia); 511 } 512 513 } 514 else if ( ((k+2) % 3) == 0 ) { // B-layer 515 516 grainInitPositionY = ( (-1.*SampleSizeXY/2.) + (grainDia/2.)*(1. + (1./std::sqrt(3.)) ) ); 517 518 if (j%2 ==0) { //first or (3-multiple)th row 519 grainInitPositionX = (-1.*SampleSizeXY/2.+grainDia); 520 } 521 522 else if ( (j+1)%2 == 0 ) { 523 grainInitPositionX = (-1.*SampleSizeXY/2.+grainDia/2); 524 } 525 526 } 527 528 else if ( (k+1)%3 == 0 ) { // B-layer 529 530 grainInitPositionY = (-1.*SampleSizeXY/2.+(grainDia/2.)*(1.+2./std::sqrt(3.)) ); 531 532 if (j%2 ==0) { //first or (3-multiple)th row 533 grainInitPositionX = (-1.*SampleSizeXY/2.+grainDia/2.); 534 } 535 536 else if ( (j+1)%2 == 0 ) { 537 grainInitPositionX = (-1.*SampleSizeXY/2.+grainDia); 538 } 539 540 } 541 542 physiGrain = new G4PVPlacement(0, 543 G4ThreeVector( grainInitPositionX + i*grainStepX, 544 grainInitPositionY + j*grainStepY, 545 grainInitPositionZ + k*grainStepZ), 546 "Grain", 547 logicGrain, //its logical volume 548 physiSample, //its mother volume 549 false, //no boolean operation 550 grainCopyNb);//copy number 551 552 grainCopyNb = grainCopyNb +1; 553 } 554 } 555 } 556 } 557 } 558 else { 559 560 solidSample=0; logicSample=0; physiSample=0; 561 if (SampleThickness > 0.) 562 { 563 solidSample = new G4Box("Sample", //its name 564 SampleSizeXY/2,SampleSizeXY/2,SampleThickness/2);//size 565 566 logicSample= new G4LogicalVolume(solidSample, //its solid 567 sampleMaterial, //its material 568 "Sample"); //its name 569 570 physiSample = new G4PVPlacement(0, //no rotation 571 G4ThreeVector(), //at (0,0,0) 572 "Sample", //its name 573 logicSample, //its logical volume 574 physiWorld, //its mother volume 575 false, //no boolean operation 576 0); //copy number 577 578 } 579 } 580 581 if (!phaseSpaceFlag) { 582 //Diaphragm1 583 584 solidDia1 = 0; physiDia1 = 0; logicDia1=0; 585 586 if (Dia1Thickness > 0.) 587 { 588 solidDia1 = new G4Tubs("Diaphragm1", //its name 589 DiaInnerSize/2, 590 Dia1SizeXY/2, 591 Dia1Thickness/2, 592 0, 593 360*deg);//size 594 595 596 logicDia1 = new G4LogicalVolume(solidDia1, //its solid 597 Dia1Material, //its material 598 "Diaphragm1"); //its name 599 600 zRotPhiDia1.rotateX(AlphaDia1); 601 G4double x,y,z; 602 z = DistDia * std::cos(ThetaDia1); 603 y =DistDia * std::sin(ThetaDia1); 604 x = 0.*cm; 605 physiDia1 = new G4PVPlacement(G4Transform3D(zRotPhiDia1,G4ThreeVector(x,y,z)), 606 "Diaphragm1", //its name 607 logicDia1, //its logical volume 608 physiWorld, //its mother volume 609 false, //no boolean operation 610 0); //copy number 611 } 612 613 //Diaphragm3 614 615 solidDia3 = 0; physiDia3 = 0; logicDia3 =0; 616 617 if (Dia3Thickness > 0.) 618 { 619 solidDia3 = new G4Tubs("Diaphragm3", 620 Dia3InnerSize/2, 621 Dia3SizeXY/2, 622 Dia3Thickness/2, 623 0, 624 360*deg); 625 626 627 logicDia3 = new G4LogicalVolume(solidDia3, //its solid 628 Dia3Material, //its material 629 "Diaphragm3"); //its name 630 631 zRotPhiDia3.rotateX(AlphaDia3); 632 G4double x,y,z; 633 z = Dia3Dist * std::cos(ThetaDia3); 634 y =Dia3Dist * std::sin(ThetaDia3); 635 x = 0.*cm; 636 physiDia3 = new G4PVPlacement(G4Transform3D(zRotPhiDia3,G4ThreeVector(x,y,z)), "Diaphragm3", //its name 637 logicDia3, //its logical volume 638 physiWorld, //its mother volume 639 false, //no boolean operation 640 0); //copy number 641 } 642 } 643 644 645 646 // Visualization attributes 647 648 logicWorld->SetVisAttributes (G4VisAttributes::GetInvisible()); 649 G4VisAttributes* simpleBoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0)); 650 G4VisAttributes * yellow= new G4VisAttributes( G4Colour(255/255. ,255/255. ,51/255. )); 651 G4VisAttributes * red= new G4VisAttributes( G4Colour(255/255. , 0/255. , 0/255. )); 652 G4VisAttributes * blue= new G4VisAttributes( G4Colour(0/255. , 0/255. , 255/255. )); 653 G4VisAttributes * grayc= new G4VisAttributes( G4Colour(128/255. , 128/255. , 128/255. )); 654 G4VisAttributes * lightGray= new G4VisAttributes( G4Colour(178/255. , 178/255. , 178/255. )); 655 G4VisAttributes * green= new G4VisAttributes( G4Colour(0/255. , 255/255. , 0/255. )); 656 657 yellow->SetVisibility(true); 658 yellow->SetForceSolid(true); 659 red->SetVisibility(true); 660 red->SetForceSolid(true); 661 blue->SetVisibility(true); 662 green->SetVisibility(true); 663 green->SetForceSolid(true); 664 grayc->SetVisibility(true); 665 grayc->SetForceSolid(true); 666 lightGray->SetVisibility(true); 667 lightGray->SetForceSolid(true); 668 simpleBoxVisAtt->SetVisibility(true); 669 if (!phaseSpaceFlag) { 670 logicPixel->SetVisAttributes(red); //modified!!! 671 logicHPGe->SetVisAttributes(blue); 672 673 logicDia1->SetVisAttributes(lightGray); 674 logicDia3->SetVisAttributes(lightGray); 675 676 logicOhmicNeg->SetVisAttributes(yellow); 677 logicOhmicPos->SetVisAttributes(yellow); 678 679 logicWindow->SetVisAttributes(green); 680 681 } 682 logicSample->SetVisAttributes(simpleBoxVisAtt); 683 684 if (sampleGranularity) logicSample->SetVisAttributes(simpleBoxVisAtt); // mandatory 685 686 687 688 if (sampleGranularity) logicGrain->SetVisAttributes(grayc); 689 690 //always return the physical World 691 692 PrintApparateParameters(); 693 694 return physiWorld; 695 } 696 697 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 698 699 void XrayFluoDetectorConstruction::ConstructSDandField() 700 { 701 if (!phaseSpaceFlag) 702 { 703 704 // 705 // Sensitive Detectors 706 // 707 if (HPGeSD.Get() == 0) 708 { 709 XrayFluoSD* SD = new XrayFluoSD ("HPGeSD",this); 710 HPGeSD.Put( SD ); 711 } 712 G4SDManager::GetSDMpointer()->AddNewDetector(HPGeSD.Get()); 713 if (logicPixel) 714 SetSensitiveDetector(logicPixel,HPGeSD.Get()); 715 } 716 return; 717 } 718 719 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 720 721 void XrayFluoDetectorConstruction::PrintApparateParameters() 722 { 723 G4cout << "-----------------------------------------------------------------------" 724 << G4endl 725 << "The sample is a box whose size is: " 726 << G4endl 727 << SampleThickness/cm 728 << " cm * " 729 << SampleSizeXY/cm 730 << " cm * " 731 << SampleSizeXY/cm 732 << " cm" 733 << G4endl 734 <<" Material: " << logicSample->GetMaterial()->GetName() 735 <<G4endl; 736 if (!phaseSpaceFlag) { 737 G4cout <<"The Detector is a slice " << DeviceThickness/(1.e-6*m) << " micron thick of " << pixelMaterial->GetName() 738 <<G4endl 739 << "The Anode is a slice " << OhmicPosThickness/mm << "mm thick of "<< OhmicPosMaterial->GetName() 740 <<G4endl; 741 } 742 G4cout <<"-------------------------------------------------------------------------" 743 << G4endl; 744 } 745 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 746 747 void XrayFluoDetectorConstruction::UpdateGeometry() 748 { 749 G4GeometryManager::GetInstance()->OpenGeometry(); 750 G4PhysicalVolumeStore::Clean(); 751 G4LogicalVolumeStore::Clean(); 752 G4SolidStore::Clean(); 753 754 if (sampleRegion) 755 sampleRegion->RemoveRootLogicalVolume(logicSample); 756 757 zRotPhiHPGe.rotateX(-1.*PhiHPGe); 758 zRotPhiDia1.rotateX(-1.*AlphaDia1); 759 zRotPhiDia3.rotateX(-1.*AlphaDia3); 760 761 //Triggers a new call of Construct() and of all the geometry resets. 762 G4RunManager::GetRunManager()->ReinitializeGeometry(); 763 } 764 765 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 766 767 void XrayFluoDetectorConstruction::DeleteGrainObjects() 768 { 769 if (sampleGranularity) { 770 delete solidGrain; 771 delete logicGrain; 772 delete physiGrain; 773 } 774 775 } 776 777 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 778 779 G4ThreeVector XrayFluoDetectorConstruction::GetDetectorPosition() const 780 { 781 G4double z = DistDe * std::cos(ThetaHPGe); 782 G4double y = DistDe * std::sin(ThetaHPGe); 783 G4double x = 0.*cm; 784 785 G4ThreeVector position(x,y,z); 786 787 return position; 788 789 } 790 791 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 792 793 void XrayFluoDetectorConstruction::SetSampleMaterial(G4String newMaterial) 794 { 795 G4cout << "Material Change in Progress " << newMaterial << G4endl; 796 sampleMaterial = materials->GetMaterial(newMaterial); 797 logicSample->SetMaterial(sampleMaterial); 798 PrintApparateParameters(); 799 //GeometryHasBeenModified is called by the messenger 800 } 801 802 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 803 804 805 806 807 808 809 810 811 812 813 814