File indexing completed on 2026-04-17 07:51:43
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 #include "DetectorConstruction.hh"
0035 #include "DetectorMessenger.hh"
0036
0037 #include "G4Material.hh"
0038 #include "G4NistManager.hh"
0039 #include "G4Box.hh"
0040 #include "G4LogicalVolume.hh"
0041 #include "G4PVPlacement.hh"
0042 #include "G4AutoDelete.hh"
0043 #include "G4GeometryManager.hh"
0044 #include "G4PhysicalVolumeStore.hh"
0045 #include "G4LogicalVolumeStore.hh"
0046 #include "G4SolidStore.hh"
0047 #include "G4SDManager.hh"
0048 #include "G4PhysicalConstants.hh"
0049 #include "G4SystemOfUnits.hh"
0050 #include "G4UnitsTable.hh"
0051 #include "G4SystemOfUnits.hh"
0052 #include "G4UserLimits.hh"
0053 #include "G4NistManager.hh"
0054 #include <vector>
0055 #include "G4ProductionCuts.hh"
0056 #include "G4Region.hh"
0057
0058
0059
0060
0061
0062
0063 DetectorConstruction::DetectorConstruction()
0064 :G4VUserDetectorConstruction(),World_Material(NULL), fSolidWorld(NULL), fLogicWorld(NULL), fPhysiWorld(NULL)
0065 , fLBox(0),fPBox(0), fMaterial(0),detectorMat(NULL), fDetectorMessenger(0)
0066 {
0067 fBoxSize = 1*mm;
0068 fBoxWidth = 1*mm;
0069 fBoxSizeSurface = 0.1*fBoxSize;
0070 fBoxSizeLayer1 = 0.1*fBoxSize;
0071 fBoxSizeLayer2 = 0.1*fBoxSize;
0072 fBoxSizeLayer3 = 0.1*fBoxSize;
0073 fBoxSizeLayer4 = 0.1*fBoxSize;
0074 fWorldSizeX = fBoxSize *5;
0075 fWorldSizeY = fBoxSize *5;
0076 fWorldSizeZ = (fBoxWidth + fBoxSizeLayer4 + fBoxSizeLayer3 + fBoxSizeLayer2 + fBoxSizeLayer1+ fBoxSizeSurface) * 5;
0077 WorldDim = std::max(fWorldSizeX, fWorldSizeZ);
0078 WorldRay = WorldDim / 2;
0079 DetectorRay = WorldRay*0.8;
0080
0081 DefineMaterials();
0082 SetMaterial("G4_Si");
0083 SetMaterialSurface("G4_Si");
0084 SetMaterialLayer1("G4_Si");
0085 SetMaterialLayer2("G4_Si");
0086 SetMaterialLayer3("G4_Si");
0087 SetMaterialLayer4("G4_Si");
0088
0089 fDetectorMessenger = new DetectorMessenger(this);
0090
0091
0092 }
0093
0094
0095
0096 DetectorConstruction::~DetectorConstruction()
0097 {
0098 delete fDetectorMessenger;
0099 }
0100
0101
0102
0103 G4VPhysicalVolume* DetectorConstruction::Construct()
0104 {
0105 DefineMaterials();
0106 return ConstructVolumes();
0107 }
0108
0109
0110
0111 void DetectorConstruction::DefineMaterials()
0112 {
0113 G4double a,z,density,fractionmass;
0114 G4double pressure, temperature;
0115 G4String name,symbol;
0116 G4int nel;
0117
0118 a=1.01*g/mole;
0119 G4Element *elH=new G4Element(name="Hydrogen",symbol="H",z=1.,a);
0120 a=12.01*g/mole;
0121 G4Element* elB = new G4Element(name = "Boron", symbol = "B", z = 5., a);
0122 a = 10.811 * g / mole;
0123 G4Element *elC=new G4Element(name="Carbon",symbol="C",z=6.,a);
0124 a=14.01*g/mole;
0125 G4Element *elN=new G4Element(name="Nitrogen",symbol="N",z=7.,a);
0126 a=16.*g/mole;
0127 G4Element *elO=new G4Element(name="Oxygen",symbol="O",z=8.,a);
0128 a=28.0855*g/mole;
0129 G4Element* elSi = new G4Element("Silicon", "Si", z=14., a);
0130 a = 47.9 * g / mole;
0131 G4Element* elTi = new G4Element(name = "Titanium", symbol = "Ti", z = 22., a);
0132
0133
0134
0135
0136 My_SiO2 = G4NistManager::Instance()->FindOrBuildMaterial("G4_SILICON_DIOXIDE");
0137 My_Kapton = G4NistManager::Instance()->FindOrBuildMaterial("G4_KAPTON");
0138 My_BN = G4NistManager::Instance()->FindOrBuildMaterial("G4_BORON_NITRIDE");
0139 My_TiN = G4NistManager::Instance()->FindOrBuildMaterial("G4_TITANIUM_NITRIDE");
0140
0141 if (!My_SiO2) {
0142 density = 2.32*g/cm3;
0143 My_SiO2 = new G4Material("G4_SILICON_DIOXIDE", density, 2);
0144 My_SiO2->AddElement(elSi, 1);
0145 My_SiO2->AddElement(elO , 2);
0146 }
0147 if (!My_Kapton) {
0148 density = 1.42*g/cm3;
0149 My_Kapton = new G4Material(name="G4_KAPTON",density, nel=4);
0150 My_Kapton->AddElement(elH, fractionmass = 0.0273);
0151 My_Kapton->AddElement(elC, fractionmass = 0.7213);
0152 My_Kapton->AddElement(elN, fractionmass = 0.0765);
0153 My_Kapton->AddElement(elO, fractionmass = 0.1749);
0154 }
0155 if (!My_BN) {
0156 density = 2.1 * g / cm3;
0157 My_BN = new G4Material(name = "G4_BORON_NITRIDE", density, nel = 2);
0158 My_BN->AddElement(elB, fractionmass = 0.436);
0159 My_BN->AddElement(elN, fractionmass = 0.564);
0160 }
0161 if (!My_TiN) {
0162 density = 5.4*g / cm3;
0163 My_TiN = new G4Material(name = "G4_TITANIUM_NITRIDE", density, nel = 2);
0164 My_TiN->AddElement(elTi, fractionmass = 0.7737);
0165 My_TiN->AddElement(elN, fractionmass = 0.2263);
0166 }
0167
0168
0169 a = 1.01*g / mole;
0170 pressure = 1.e-19*pascal;
0171 temperature = 0.1*kelvin;
0172 density = universe_mean_density;
0173
0174 G4Material* Vide = new G4Material(name = "Vacuum", z = 1., a, density, kStateGas, temperature, pressure);
0175
0176
0177 World_Material = Vide;
0178 detectorMat = Vide;
0179 DefaultMaterial = My_TiN;
0180 fMaterial = My_BN;
0181 fMaterialSurface = G4NistManager::Instance()->FindOrBuildMaterial("G4_Si");
0182 fMaterialLayer1 = G4NistManager::Instance()->FindOrBuildMaterial("G4_Si");
0183 fMaterialLayer2 = G4NistManager::Instance()->FindOrBuildMaterial("G4_Si");
0184 fMaterialLayer3 = G4NistManager::Instance()->FindOrBuildMaterial("G4_Si");
0185 fMaterialLayer4 = G4NistManager::Instance()->FindOrBuildMaterial("G4_Si");
0186
0187 G4cout << *(G4Material::GetMaterialTable()) << G4endl;
0188 }
0189
0190
0191
0192 G4VPhysicalVolume* DetectorConstruction::ConstructVolumes()
0193 {
0194
0195 G4GeometryManager::GetInstance()->OpenGeometry();
0196 G4PhysicalVolumeStore::GetInstance()->Clean();
0197 G4LogicalVolumeStore::GetInstance()->Clean();
0198 G4SolidStore::GetInstance()->Clean();
0199
0200 G4cout << "MicroELec - SEY modellling - Creating geometry" << G4endl;
0201
0202 fWorldSizeX = fBoxSize * 5;
0203 fWorldSizeY = fBoxSize * 5;
0204 fWorldSizeZ = (fBoxWidth + fBoxSizeLayer4 + fBoxSizeLayer3 + fBoxSizeLayer2 + fBoxSizeLayer1+ fBoxSizeSurface) * 5;
0205 WorldDim = std::max(fWorldSizeX, fWorldSizeZ);
0206 WorldRay = WorldDim / 2;
0207 DetectorRay = WorldRay * 0.8;
0208
0209 fSolidWorld = new G4Box("World", WorldDim/2.0, WorldDim / 2.0, WorldDim / 2.0);
0210
0211 fLogicWorld = new G4LogicalVolume(fSolidWorld, World_Material, "World");
0212 fPhysiWorld = new G4PVPlacement(0, G4ThreeVector(0.0, 0.0, 0.0), "World", fLogicWorld, 0, false, 0);
0213
0214
0215
0216
0217 fSBox = new G4Box("Substrate",
0218 fBoxSize , fBoxSize ,fBoxWidth/2);
0219
0220 fLBox = new G4LogicalVolume(fSBox,
0221 fMaterial,
0222 "Substrate");
0223
0224 fPBox = new G4PVPlacement(0,
0225 G4ThreeVector(0.0, (0*fBoxSize), fBoxSizeSurface + fBoxSizeLayer1 + fBoxSizeLayer2 + fBoxSizeLayer3 + fBoxSizeLayer4 + fBoxWidth / 2 ),
0226 "Substrate",
0227 fLBox,
0228 fPhysiWorld,
0229 false,
0230 0);
0231
0232
0233
0234 fSBoxSurface = new G4Box("Surface",
0235 fBoxSize , fBoxSize , fBoxSizeSurface / 2);
0236
0237 fLBoxSurface = new G4LogicalVolume(fSBoxSurface,
0238 fMaterialSurface,
0239 "Surface");
0240
0241 fPBoxSurface = new G4PVPlacement(0,
0242 G4ThreeVector(0.0, 0.0, fBoxSizeSurface/2),
0243 "Surface",
0244 fLBoxSurface,
0245 fPhysiWorld,
0246 false,
0247 0);
0248
0249
0250
0251
0252 fSBoxLayer1 = new G4Box("Layer1",
0253 fBoxSize, fBoxSize, fBoxSizeLayer1 / 2);
0254
0255 fLBoxLayer1 = new G4LogicalVolume(fSBoxLayer1,
0256 fMaterialLayer1,
0257 "Layer1");
0258
0259 fPBoxLayer1 = new G4PVPlacement(0,
0260 G4ThreeVector(0.0, 0.0, fBoxSizeSurface + fBoxSizeLayer1 / 2),
0261 "Layer1",
0262 fLBoxLayer1,
0263 fPhysiWorld,
0264 false,
0265 0);
0266
0267
0268 fSBoxLayer2 = new G4Box("Layer2",
0269 fBoxSize, fBoxSize, fBoxSizeLayer2 / 2);
0270
0271 fLBoxLayer2 = new G4LogicalVolume(fSBoxLayer2,
0272 fMaterialLayer2,
0273 "Layer2");
0274
0275 fPBoxLayer2 = new G4PVPlacement(0,
0276 G4ThreeVector(0.0, 0.0, fBoxSizeSurface + fBoxSizeLayer1 +fBoxSizeLayer2 / 2),
0277 "Layer2",
0278 fLBoxLayer2,
0279 fPhysiWorld,
0280 false,
0281 0);
0282
0283
0284
0285 fSBoxLayer3 = new G4Box("Layer3",
0286 fBoxSize, fBoxSize, fBoxSizeLayer3 / 2);
0287
0288 fLBoxLayer3 = new G4LogicalVolume(fSBoxLayer3,
0289 fMaterialLayer3,
0290 "Layer3");
0291
0292 fPBoxLayer3 = new G4PVPlacement(0,
0293 G4ThreeVector(0.0, 0.0, fBoxSizeSurface + fBoxSizeLayer1 + fBoxSizeLayer2 + fBoxSizeLayer3 / 2),
0294 "Layer3",
0295 fLBoxLayer3,
0296 fPhysiWorld,
0297 false,
0298 0);
0299
0300
0301
0302 fSBoxLayer4 = new G4Box("Layer4",
0303 fBoxSize, fBoxSize, fBoxSizeLayer4 / 2);
0304
0305 fLBoxLayer4 = new G4LogicalVolume(fSBoxLayer4,
0306 fMaterialLayer4,
0307 "Layer4");
0308
0309 fPBoxLayer4 = new G4PVPlacement(0,
0310 G4ThreeVector(0.0, 0.0, fBoxSizeSurface + fBoxSizeLayer1 + fBoxSizeLayer2 + fBoxSizeLayer3 + fBoxSizeLayer4 / 2),
0311 "Layer4",
0312 fLBoxLayer4,
0313 fPhysiWorld,
0314 false,
0315 0);
0316
0317
0318
0319
0320
0321
0322 Detector_1_box = new G4Sphere("Detector_1", DetectorRay, DetectorRay + 1*angstrom, 0.0, 2.0*3.1415, 0.0, 3.1415);
0323 Detector_1_log = new G4LogicalVolume(Detector_1_box, detectorMat, "Detector_1");
0324 Detector_1_phys = new G4PVPlacement(0, G4ThreeVector(0.0, 0.0, 0.0), "Detector_1", Detector_1_log, fPhysiWorld, false, 0);
0325
0326
0327 fRegion = new G4Region("Target");
0328 G4ProductionCuts* cuts = new G4ProductionCuts();
0329
0330
0331
0332 G4double defCut = 1 * nanometer;
0333 cuts->SetProductionCut(defCut, "gamma");
0334 cuts->SetProductionCut(defCut, "e-");
0335 cuts->SetProductionCut(defCut, "e+");
0336 cuts->SetProductionCut(defCut, "proton");
0337
0338 fRegion->SetProductionCuts(cuts);
0339 fRegion->AddRootLogicalVolume(fLBoxSurface);
0340 fRegion->AddRootLogicalVolume(fLBox);
0341 fRegion->AddRootLogicalVolume(fLBoxLayer1);
0342 fRegion->AddRootLogicalVolume(fLBoxLayer2);
0343 fRegion->AddRootLogicalVolume(fLBoxLayer3);
0344 fRegion->AddRootLogicalVolume(fLBoxLayer4);
0345
0346
0347 G4VisAttributes* subVisAtt = new G4VisAttributes(G4Colour(1, 0, 0));
0348 fLBoxSurface->SetVisAttributes(subVisAtt);
0349 fLBoxLayer1->SetVisAttributes(subVisAtt);
0350 fLBoxLayer2->SetVisAttributes(subVisAtt);
0351 fLBoxLayer3->SetVisAttributes(subVisAtt);
0352 fLBoxLayer4->SetVisAttributes(subVisAtt);
0353
0354
0355 G4VisAttributes* subVisAtt2 = new G4VisAttributes(G4Colour(0, 1, 0));
0356 fLBox->SetVisAttributes(subVisAtt2);
0357
0358 G4VisAttributes* subVisAtt3 = new G4VisAttributes(G4Colour(1.0, 1.0, 1.0));
0359 subVisAtt3->SetVisibility(true);
0360 Detector_1_log->SetVisAttributes(subVisAtt3);
0361
0362
0363 G4cout << "MicroELec - SEY modellling - End geometry creation " << G4endl;
0364 PrintParameters();
0365 G4cout << fPhysiWorld->GetLogicalVolume()->GetMaterial()->GetName() << G4endl;
0366 G4cout << fPhysiWorld->GetLogicalVolume()->GetDaughter(0)->GetLogicalVolume()->GetMaterial()->GetName() << G4endl;
0367 return fPhysiWorld;
0368
0369
0370 return fPhysiWorld;
0371 }
0372
0373
0374 void DetectorConstruction::ConstructSDandField()
0375 {
0376
0377 auto sdManager = G4SDManager::GetSDMpointer();
0378 G4String SDname;
0379
0380 auto MypMicroElecSdSey = new MicroElecSdSey(SDname = "/SdSey", "DetecteurMicroElecSdSey");
0381 sdManager->AddNewDetector(MypMicroElecSdSey);
0382 Detector_1_log->SetSensitiveDetector(MypMicroElecSdSey);
0383 G4cout<<"Sensitive Detector Name : "<<MypMicroElecSdSey->GetName()<<G4endl;
0384 }
0385
0386
0387
0388
0389
0390
0391
0392
0393
0394 void DetectorConstruction::PrintParameters()
0395 {
0396 G4cout << "\n The Box is " << G4BestUnit(fBoxSize,"Length")
0397 << " of " << fMaterial->GetName() << G4endl;
0398 }
0399
0400
0401
0402 #include "G4RunManager.hh"
0403
0404 void DetectorConstruction::SetMaterial(G4String materialChoice)
0405 {
0406 G4Material* pttoMaterial = nullptr;
0407
0408 if (materialChoice == "G4_SiO2"|| materialChoice == "G4_SILICON_DIOXIDE") {
0409 pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_SILICON_DIOXIDE");
0410 }
0411 else if (materialChoice == "G4_KAPTON"|| materialChoice == "G4_KAPTON_FILM"|| materialChoice == "Kapton") {
0412 pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_KAPTON");
0413 }
0414 else if (materialChoice == "G4_Al2O3"|| materialChoice == "G4_ALUMINUM_OXIDE") {
0415 pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_ALUMINUM_OXIDE");
0416 }
0417 else if (materialChoice == "G4_TiN" || materialChoice == "G4_TITANIUM_NITRIDE") {
0418 pttoMaterial = My_TiN;
0419 pttoMaterial->SetName("G4_TITANIUM_NITRIDE");
0420 }
0421 else if (materialChoice == "G4_BN" || materialChoice == "G4_BORON_NITRIDE") {
0422 pttoMaterial = My_BN;
0423 pttoMaterial->SetName("G4_BORON_NITRIDE");
0424 }
0425 else { pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial(materialChoice); }
0426
0427 if (pttoMaterial) {
0428 fMaterial = pttoMaterial;
0429 G4RunManager::GetRunManager()->PhysicsHasBeenModified();
0430 } else {
0431 G4String str = "Material ";
0432 str += materialChoice + " does not exist";
0433 G4Exception("DetectorConstruction::SetMaterial", "em0002", FatalException, str);
0434 }
0435 }
0436
0437 void DetectorConstruction::SetMaterialSurface(G4String materialChoice)
0438 {
0439 G4Material* pttoMaterial = nullptr;
0440
0441 if (materialChoice == "G4_SiO2"|| materialChoice == "G4_SILICON_DIOXIDE") {
0442 pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_SILICON_DIOXIDE");
0443 }
0444 else if (materialChoice == "G4_KAPTON" || materialChoice == "G4_KAPTON_FILM" || materialChoice == "Kapton") {
0445 pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_KAPTON");
0446 }
0447 else if (materialChoice == "G4_Al2O3"|| materialChoice == "G4_ALUMINUM_OXIDE") {
0448 pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_ALUMINUM_OXIDE");
0449 }
0450 else if (materialChoice == "G4_TiN" || materialChoice == "G4_TITANIUM_NITRIDE") {
0451 pttoMaterial = My_TiN;
0452 pttoMaterial->SetName("G4_TITANIUM_NITRIDE");
0453 }
0454 else if (materialChoice == "G4_BN" || materialChoice == "G4_BORON_NITRIDE") {
0455 pttoMaterial = My_BN;
0456 pttoMaterial->SetName("G4_BORON_NITRIDE");
0457 }
0458 else { pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial(materialChoice); }
0459
0460 if (pttoMaterial) {
0461 fMaterialSurface = pttoMaterial;
0462 G4RunManager::GetRunManager()->PhysicsHasBeenModified();
0463 }
0464 else {
0465 G4String str = "Material ";
0466 str += materialChoice + " does not exist";
0467 G4Exception("DetectorConstruction::SetMaterialSurface", "em0002", FatalException, str);
0468 }
0469 }
0470
0471 void DetectorConstruction::SetMaterialLayer1(G4String materialChoice)
0472 {
0473 G4Material* pttoMaterial = nullptr;
0474
0475 if (materialChoice == "G4_SiO2"|| materialChoice == "G4_SILICON_DIOXIDE") {
0476 pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_SILICON_DIOXIDE");
0477 }
0478 else if (materialChoice == "G4_KAPTON" || materialChoice == "G4_KAPTON_FILM" || materialChoice == "Kapton") {
0479 pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_KAPTON");
0480 }
0481 else if (materialChoice == "G4_Al2O3"|| materialChoice == "G4_ALUMINUM_OXIDE") {
0482 pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_ALUMINUM_OXIDE");
0483 }
0484 else if (materialChoice == "G4_TiN" || materialChoice == "G4_TITANIUM_NITRIDE") {
0485 pttoMaterial = My_TiN;
0486 pttoMaterial->SetName("G4_TITANIUM_NITRIDE");
0487 }
0488 else if (materialChoice == "G4_BN" || materialChoice == "G4_BORON_NITRIDE") {
0489 pttoMaterial = My_BN;
0490 pttoMaterial->SetName("G4_BORON_NITRIDE");
0491 }
0492 else { pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial(materialChoice); }
0493
0494 if (pttoMaterial) {
0495 fMaterialLayer1 = pttoMaterial;
0496 G4RunManager::GetRunManager()->PhysicsHasBeenModified();
0497 }
0498 else {
0499 G4String str = "Material ";
0500 str += materialChoice + " does not exist";
0501 G4Exception("DetectorConstruction::SetMaterialSurface", "em0002", FatalException, str);
0502 }
0503 }
0504
0505 void DetectorConstruction::SetMaterialLayer2(G4String materialChoice)
0506 {
0507 G4Material* pttoMaterial = nullptr;
0508
0509 if (materialChoice == "G4_SiO2"|| materialChoice == "G4_SILICON_DIOXIDE") {
0510 pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_SILICON_DIOXIDE");
0511 }
0512 else if (materialChoice == "G4_KAPTON" || materialChoice == "G4_KAPTON_FILM" || materialChoice == "Kapton") {
0513 pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_KAPTON");
0514 }
0515 else if (materialChoice == "G4_Al2O3"|| materialChoice == "G4_ALUMINUM_OXIDE") {
0516 pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_ALUMINUM_OXIDE");
0517 }
0518 else if (materialChoice == "G4_TiN" || materialChoice == "G4_TITANIUM_NITRIDE") {
0519 pttoMaterial = My_TiN;
0520 pttoMaterial->SetName("G4_TITANIUM_NITRIDE");
0521 }
0522 else if (materialChoice == "G4_BN" || materialChoice == "G4_BORON_NITRIDE") {
0523 pttoMaterial = My_BN;
0524 pttoMaterial->SetName("G4_BORON_NITRIDE");
0525 }
0526 else { pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial(materialChoice); }
0527
0528 if (pttoMaterial) {
0529 fMaterialLayer2 = pttoMaterial;
0530 G4RunManager::GetRunManager()->PhysicsHasBeenModified();
0531 }
0532 else {
0533 G4String str = "Material ";
0534 str += materialChoice + " does not exist";
0535 G4Exception("DetectorConstruction::SetMaterialSurface", "em0002", FatalException, str);
0536 }
0537 }
0538
0539 void DetectorConstruction::SetMaterialLayer3(G4String materialChoice)
0540 {
0541 G4Material* pttoMaterial = nullptr;
0542
0543 if (materialChoice == "G4_SiO2"|| materialChoice == "G4_SILICON_DIOXIDE") {
0544 pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_SILICON_DIOXIDE");
0545 }
0546 else if (materialChoice == "G4_KAPTON" || materialChoice == "G4_KAPTON_FILM" || materialChoice == "Kapton") {
0547 pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_KAPTON");
0548 }
0549 else if (materialChoice == "G4_Al2O3"|| materialChoice == "G4_ALUMINUM_OXIDE") {
0550 pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_ALUMINUM_OXIDE");
0551 }
0552 else if (materialChoice == "G4_TiN" || materialChoice == "G4_TITANIUM_NITRIDE") {
0553 pttoMaterial = My_TiN;
0554 pttoMaterial->SetName("G4_TITANIUM_NITRIDE");
0555 }
0556 else if (materialChoice == "G4_BN" || materialChoice == "G4_BORON_NITRIDE") {
0557 pttoMaterial = My_BN;
0558 pttoMaterial->SetName("G4_BORON_NITRIDE");
0559 }
0560 else { pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial(materialChoice); }
0561
0562 if (pttoMaterial) {
0563 fMaterialLayer3 = pttoMaterial;
0564 G4RunManager::GetRunManager()->PhysicsHasBeenModified();
0565 }
0566 else {
0567 G4String str = "Material ";
0568 str += materialChoice + " does not exist";
0569 G4Exception("DetectorConstruction::SetMaterialSurface", "em0002", FatalException, str);
0570 }
0571 }
0572
0573 void DetectorConstruction::SetMaterialLayer4(G4String materialChoice)
0574 {
0575 G4Material* pttoMaterial = nullptr;
0576
0577 if (materialChoice == "G4_SiO2"|| materialChoice == "G4_SILICON_DIOXIDE") {
0578 pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_SILICON_DIOXIDE");
0579 }
0580 else if (materialChoice == "G4_KAPTON" || materialChoice == "G4_KAPTON_FILM" || materialChoice == "Kapton") {
0581 pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_KAPTON");
0582 }
0583 else if (materialChoice == "G4_Al2O3"|| materialChoice == "G4_ALUMINUM_OXIDE") {
0584 pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_ALUMINUM_OXIDE");
0585 }
0586 else if (materialChoice == "G4_TiN" || materialChoice == "G4_TITANIUM_NITRIDE") {
0587 pttoMaterial = My_TiN;
0588 pttoMaterial->SetName("G4_TITANIUM_NITRIDE");
0589 }
0590 else if (materialChoice == "G4_BN" || materialChoice == "G4_BORON_NITRIDE") {
0591 pttoMaterial = My_BN;
0592 pttoMaterial->SetName("G4_BORON_NITRIDE");
0593 }
0594 else { pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial(materialChoice); }
0595
0596 if (pttoMaterial) {
0597 fMaterialLayer4 = pttoMaterial;
0598 G4RunManager::GetRunManager()->PhysicsHasBeenModified();
0599 }
0600 else {
0601 G4String str = "Material ";
0602 str += materialChoice + " does not exist";
0603 G4Exception("DetectorConstruction::SetMaterialSurface", "em0002", FatalException, str);
0604 }
0605 }
0606
0607
0608
0609
0610 void DetectorConstruction::UpdateGeometry()
0611 {
0612 G4cout << "UpdateGeometry Begin" << G4endl;
0613 G4GeometryManager::GetInstance()->OpenGeometry();
0614
0615 fWorldSizeX = fBoxSize * 5;
0616 fWorldSizeY = fBoxSize * 5;
0617 fWorldSizeZ = (fBoxWidth + fBoxSizeLayer4 + fBoxSizeLayer3 + fBoxSizeLayer2 + fBoxSizeLayer1+ fBoxSizeSurface) * 5;
0618 WorldDim = std::max(fWorldSizeX, fWorldSizeZ);
0619 WorldRay = WorldDim / 2;
0620 DetectorRay = WorldRay * 0.8;
0621
0622 if (fSolidWorld) {
0623 fSolidWorld->SetXHalfLength(WorldDim / 2);
0624 fSolidWorld->SetYHalfLength(WorldDim / 2);
0625 fSolidWorld->SetZHalfLength(WorldDim / 2);
0626 }
0627
0628 if (fLBox) { fLBox->SetMaterial(fMaterial);}
0629 if (fLBoxSurface) { fLBoxSurface->SetMaterial(fMaterialSurface); }
0630 if (fLBoxLayer1) { fLBoxLayer1->SetMaterial(fMaterialLayer1); }
0631 if (fLBoxLayer2) { fLBoxLayer2->SetMaterial(fMaterialLayer2); }
0632 if (fLBoxLayer3) { fLBoxLayer3->SetMaterial(fMaterialLayer3); }
0633 if (fLBoxLayer4) { fLBoxLayer4->SetMaterial(fMaterialLayer4); }
0634
0635 if (fSBox) {
0636 fSBox->SetZHalfLength(fBoxWidth / 2);
0637 fSBox->SetXHalfLength(fBoxSize / 2);
0638 fSBox->SetYHalfLength(fBoxSize / 2);
0639 fPBox->SetTranslation(G4ThreeVector(0.0, 0.0, fBoxSizeSurface + fBoxSizeLayer1 + fBoxSizeLayer2 + fBoxSizeLayer3 + fBoxSizeLayer4 + fBoxSize / 2));
0640 }
0641 if (fSBoxSurface) {
0642 fSBoxSurface->SetZHalfLength(fBoxSizeSurface / 2);
0643 fSBoxSurface->SetXHalfLength(fBoxSize / 2);
0644 fSBoxSurface->SetYHalfLength(fBoxSize / 2);
0645 fPBoxSurface->SetTranslation(G4ThreeVector(0.0, 0.0, fBoxSizeSurface / 2));
0646 }
0647 if (fSBoxLayer1) {
0648 fSBoxLayer1->SetZHalfLength(fBoxSizeLayer1 / 2);
0649 fSBoxLayer1->SetXHalfLength(fBoxSize / 2);
0650 fSBoxLayer1->SetYHalfLength(fBoxSize / 2);
0651 fPBoxLayer1->SetTranslation(G4ThreeVector(0.0, 0.0, fBoxSizeSurface + fBoxSizeLayer1 / 2));
0652 }
0653 if (fSBoxLayer2) {
0654 fSBoxLayer2->SetZHalfLength(fBoxSizeLayer2 / 2);
0655 fSBoxLayer2->SetXHalfLength(fBoxSize / 2);
0656 fSBoxLayer2->SetYHalfLength(fBoxSize / 2);
0657 fPBoxLayer2->SetTranslation(G4ThreeVector(0.0, 0.0, fBoxSizeSurface + fBoxSizeLayer1 + fBoxSizeLayer2 / 2));
0658 }
0659 if (fSBoxLayer3) {
0660 fSBoxLayer3->SetZHalfLength(fBoxSizeLayer3 / 2);
0661 fSBoxLayer3->SetXHalfLength(fBoxSize / 2);
0662 fSBoxLayer3->SetYHalfLength(fBoxSize / 2);
0663 fPBoxLayer3->SetTranslation(G4ThreeVector(0.0, 0.0, fBoxSizeSurface + fBoxSizeLayer1 + fBoxSizeLayer2 + fBoxSizeLayer3 / 2));
0664 }
0665 if (fSBoxLayer4) {
0666 fSBoxLayer4->SetZHalfLength(fBoxSizeLayer4 / 2);
0667 fSBoxLayer4->SetXHalfLength(fBoxSize / 2);
0668 fSBoxLayer4->SetYHalfLength(fBoxSize / 2);
0669 fPBoxLayer4->SetTranslation(G4ThreeVector(0.0, 0.0, fBoxSizeSurface + fBoxSizeLayer1 + fBoxSizeLayer2 + fBoxSizeLayer3 + fBoxSizeLayer4 / 2));
0670 }
0671
0672 if (Detector_1_box) {
0673 Detector_1_box->SetInnerRadius(DetectorRay);
0674 Detector_1_box->SetOuterRadius(DetectorRay + 1 * angstrom);
0675 }
0676 G4RunManager::GetRunManager()->PhysicsHasBeenModified();
0677 G4RunManager::GetRunManager()->GeometryHasBeenModified();
0678
0679
0680 G4cout << "Substrate:" << this->GetMaterial()->GetName()<< ", 4:" << this->GetMaterialLayer4()->GetName() << ", 3:" << this->GetMaterialLayer3()->GetName() << ", 2:" << this->GetMaterialLayer2()->GetName() << ", 1:" << this->GetMaterialLayer1()->GetName() << ", surf:" << this->GetMaterialSurface()->GetName() << G4endl;
0681 G4cout << "Substrate:" << this->GetSize() << ", 4:" << this->GetSizeLayer4()<< ", 3:" << this->GetSizeLayer3() << ", 2:" << this->GetSizeLayer2() << ", 1:" << this->GetSizeLayer1() << ", surf:" << this->GetSizeSurface()<< G4endl;
0682 G4cout << "UpdateGeometry End" << G4endl;
0683
0684 }
0685
0686
0687
0688 void DetectorConstruction::SetSize(G4double value)
0689 {
0690 fBoxSize = value;
0691 }
0692
0693 void DetectorConstruction::SetWidth(G4double value)
0694 {
0695 fBoxWidth = value;
0696
0697 }
0698
0699 void DetectorConstruction::SetSizeSurface(G4double value)
0700 {
0701 fBoxSizeSurface = value;
0702
0703 }
0704
0705 void DetectorConstruction::SetSizeLayer1(G4double value)
0706 {
0707 fBoxSizeLayer1 = value;
0708
0709 }
0710 void DetectorConstruction::SetSizeLayer2(G4double value)
0711 {
0712 fBoxSizeLayer2 = value;
0713
0714 }
0715 void DetectorConstruction::SetSizeLayer3(G4double value)
0716 {
0717 fBoxSizeLayer3 = value;
0718
0719 }
0720 void DetectorConstruction::SetSizeLayer4(G4double value)
0721 {
0722 fBoxSizeLayer4 = value;
0723
0724 }
0725