File indexing completed on 2025-01-31 09:22:03
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 #include "FlashDetectorConstruction.hh"
0032
0033 #include "G4RunManager.hh"
0034
0035 #include "G4Material.hh"
0036 #include "G4NistManager.hh"
0037 #include "G4Region.hh"
0038 #include "G4SDManager.hh"
0039
0040 #include "G4AutoDelete.hh"
0041 #include "G4Box.hh"
0042 #include "G4GlobalMagFieldMessenger.hh"
0043 #include "G4LogicalVolume.hh"
0044 #include "G4PVParameterised.hh"
0045 #include "G4PVPlacement.hh"
0046 #include "G4Tubs.hh"
0047
0048 #include "G4GeometryManager.hh"
0049 #include "G4GeometryTolerance.hh"
0050
0051 #include "G4UserLimits.hh"
0052
0053 #include "G4Colour.hh"
0054 #include "G4VisAttributes.hh"
0055
0056 #include "G4SystemOfUnits.hh"
0057
0058 #include "FlashApplicator.hh"
0059
0060
0061 #include "G4MaterialPropertiesTable.hh"
0062
0063 #include "G4PSEnergyDeposit.hh"
0064 #include "G4PhysicalConstants.hh"
0065 #include "G4SystemOfUnits.hh"
0066 #include "G4VPrimitiveScorer.hh"
0067 #include "G4VisAttributes.hh"
0068 #include "FlashDetectorMessenger.hh"
0069
0070
0071
0072 FlashDetectorConstruction::FlashDetectorConstruction()
0073 : G4VUserDetectorConstruction(), physicalTreatmentRoom(0),logicTreatmentRoom(0), Collimator(0), fPhantom(0),
0074 fPhantomLogicalVolume(0),fPhant_phys(0),
0075 fCheckOverlaps(true) {
0076
0077 DefineMaterials();
0078 fDetectorMessenger = new FlashDetectorMessenger(this);
0079
0080 SetPhantomSize(30. *cm, 30. *cm, 30. *cm);
0081 SetAirGap(0*cm);
0082 SetDetectorThickness(10*um);
0083 SetDetector_subThickness(370*um);
0084 SetDetectorWidth(5*mm);
0085 SetAirGap_water_detector(0*cm);
0086
0087
0088
0089 }
0090
0091
0092
0093 FlashDetectorConstruction::~FlashDetectorConstruction() {
0094
0095 delete fDetectorMessenger;
0096 }
0097
0098
0099
0100 void FlashDetectorConstruction::DefineMaterials() {
0101 nist = G4NistManager::Instance();
0102
0103 G4bool isotopes = false;
0104 Si = nist->FindOrBuildElement("Si", isotopes);
0105 C = nist->FindOrBuildElement("C", isotopes);
0106
0107 }
0108
0109
0110
0111 G4VPhysicalVolume *
0112 FlashDetectorConstruction::ConstructPhantom(G4double CollPos) {
0113
0114
0115 fPhantomMaterial = nist->FindOrBuildMaterial("G4_WATER");
0116
0117 fPosition_coefficient = CollPos;
0118
0119 fPhantom_coordinateX = (fPosition_coefficient * mm + fPhantomSizeX / 2);
0120
0121 fPhantomPosition = G4ThreeVector(fPhantom_coordinateX, 0. * mm, 0. * mm);
0122
0123
0124
0125 fPhantom = new G4Box("Phantom", fPhantomSizeX / 2, fPhantomSizeY / 2,
0126 fPhantomSizeZ / 2);
0127
0128
0129 fPhantomLogicalVolume =
0130 new G4LogicalVolume(fPhantom, fPhantomMaterial, "phantomLog", 0, 0, 0);
0131
0132
0133 fPhant_phys =
0134 new G4PVPlacement(0, fPhantomPosition, "phantomPhys", fPhantomLogicalVolume,
0135 physicalTreatmentRoom, false, 0);
0136
0137 G4Region *PhantomRegion = new G4Region("Phantom_reg");
0138 fPhantomLogicalVolume->SetRegion(PhantomRegion);
0139 PhantomRegion->AddRootLogicalVolume(fPhantomLogicalVolume);
0140
0141
0142 red = new G4VisAttributes(G4Colour(0 / 255., 255 / 255., 0 / 255.));
0143 red->SetVisibility(true);
0144
0145 blue = new G4VisAttributes(G4Colour(0 / 255., 0. / 255., 255. / 255.));
0146 blue->SetVisibility(true);
0147
0148 fPhantomLogicalVolume->SetVisAttributes(red);
0149
0150 G4double maxStep = 0.1 * mm;
0151 fStepLimit = new G4UserLimits(maxStep);
0152 fPhantomLogicalVolume->SetUserLimits(fStepLimit);
0153
0154 return fPhant_phys;
0155 }
0156
0157 G4VPhysicalVolume *
0158 FlashDetectorConstruction::ConstructDetector(){
0159
0160
0161
0162 G4double fDensity_SiC=3.22*g/cm3;
0163
0164 SiC=new G4Material("SiC", fDensity_SiC,2);
0165 SiC->AddElement(Si,1);
0166 SiC->AddElement(C,1);
0167
0168 fDetectorMaterial=SiC;
0169
0170
0171 fDetectorPosition=fPhantom_coordinateX+fAirGap+fPhantomSizeX/2+fDet_thickness/2+fAirGap_phantom_det;
0172
0173 fDet_box = new G4Box("Detector",fDet_thickness/2,fDet_width/2,fDet_width/2);
0174
0175
0176 fDetLogicalVolume =
0177 new G4LogicalVolume(fDet_box, fDetectorMaterial, "DetectorLog", 0, 0, 0);
0178 fDet_phys = new G4PVPlacement(0,G4ThreeVector(fDetectorPosition, 0. * mm, 0. * mm), "DetPhys",fDetLogicalVolume,physicalTreatmentRoom,false, 0, fCheckOverlaps);
0179
0180
0181 fDet_sub = new G4Box("Det_sub",fDet_sub_thickness/2,fDet_width/2,fDet_width/2);
0182
0183
0184 fDet_sub_LogicalVolume =
0185 new G4LogicalVolume(fDet_sub, fDetectorMaterial, "Det_sub_Log", 0, 0, 0);
0186 fDet_sub_phys = new G4PVPlacement(0,G4ThreeVector(fDetectorPosition+fDet_thickness+fDet_sub_thickness/2, 0. * mm, 0. * mm), "Det_sub_Phys",fDet_sub_LogicalVolume,physicalTreatmentRoom,false, 0, fCheckOverlaps);
0187
0188
0189 return fDet_phys;
0190
0191 }
0192
0193 G4VPhysicalVolume *FlashDetectorConstruction::Construct() {
0194
0195
0196
0197
0198 const G4double worldX = 400.0 * cm;
0199 const G4double worldY = 400.0 * cm;
0200 const G4double worldZ = 400.0 * cm;
0201 G4bool isotopes = false;
0202
0203 airNist = G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR", isotopes);
0204
0205
0206
0207 G4Box *treatmentRoom = new G4Box("TreatmentRoom", worldX, worldY, worldZ);
0208 logicTreatmentRoom = new G4LogicalVolume(treatmentRoom, airNist,
0209 "logicTreatmentRoom", 0, 0, 0);
0210 physicalTreatmentRoom =
0211 new G4PVPlacement(0, G4ThreeVector(), "physicalTreatmentRoom",
0212 logicTreatmentRoom, 0, false, 0);
0213
0214
0215 logicTreatmentRoom->SetVisAttributes(G4VisAttributes::GetInvisible());
0216
0217
0218
0219
0220
0221
0222
0223
0224 Collimator = new FlashApplicator(physicalTreatmentRoom);
0225
0226
0227
0228 fPhantom_physical =
0229 ConstructPhantom(Collimator->fFinalApplicatorXPositionFlash +
0230 Collimator->fHightFinalApplicatorFlash+fAirGap);
0231 ConstructDetector();
0232
0233
0234 return physicalTreatmentRoom;
0235 }
0236
0237
0238
0239 void FlashDetectorConstruction::ConstructSDandField() {
0240
0241 }
0242
0243
0244
0245
0246 G4bool FlashDetectorConstruction::SetPhantomMaterial(G4String material)
0247 {
0248
0249 if (G4Material* pMat = G4NistManager::Instance()->FindOrBuildMaterial(material, false) )
0250 {
0251 fPhantomMaterial = pMat;
0252
0253 if (fPhantomLogicalVolume)
0254 {
0255
0256 fPhantomLogicalVolume -> SetMaterial(pMat);
0257
0258 G4RunManager::GetRunManager() -> PhysicsHasBeenModified();
0259 G4RunManager::GetRunManager() -> GeometryHasBeenModified();
0260 G4cout << "The material of Phantom/Detector has been changed to " << material << G4endl;
0261 }
0262 }
0263 else
0264 {
0265 G4cout << "WARNING: material \"" << material << "\" doesn't exist in NIST elements/materials"
0266 " table [located in $G4INSTALL/source/materials/src/G4NistMaterialBuilder.cc]" << G4endl;
0267 G4cout << "Use command \"/parameter/nist\" to see full materials list!" << G4endl;
0268 return false;
0269 }
0270
0271 return true;
0272 }
0273
0274
0275 void FlashDetectorConstruction::SetPhantomSize(G4double sizeX, G4double sizeY, G4double sizeZ)
0276 {
0277 if (sizeX > 0.) fPhantomSizeX = sizeX;
0278 if (sizeY > 0.) fPhantomSizeY = sizeY;
0279 if (sizeZ > 0.) fPhantomSizeZ = sizeZ;
0280 }
0281
0282 void FlashDetectorConstruction::SetAirGap(G4double displ)
0283 {
0284
0285 fAirGap=displ;
0286 }
0287
0288 G4bool FlashDetectorConstruction::SetDetectorMaterial(G4String material)
0289 {
0290
0291 if (G4Material* pMat = G4NistManager::Instance()->FindOrBuildMaterial(material, false) )
0292 {
0293 fDetectorMaterial = pMat;
0294
0295 if (fDetLogicalVolume)
0296 {
0297
0298 fDetLogicalVolume -> SetMaterial(pMat);
0299
0300 G4RunManager::GetRunManager() -> PhysicsHasBeenModified();
0301 G4RunManager::GetRunManager() -> GeometryHasBeenModified();
0302 G4cout << "The material of Phantom/Detector has been changed to " << material << G4endl;
0303 }
0304 }
0305 else
0306 {
0307 G4cout << "WARNING: material \"" << material << "\" doesn't exist in NIST elements/materials"
0308 " table [located in $G4INSTALL/source/materials/src/G4NistMaterialBuilder.cc]" << G4endl;
0309 G4cout << "Use command \"/parameter/nist\" to see full materials list!" << G4endl;
0310 return false;
0311 }
0312
0313 return true;
0314 }
0315
0316
0317
0318
0319 void FlashDetectorConstruction::SetDetectorThickness(G4double thickness)
0320 {
0321
0322 fDet_thickness=thickness;
0323 }
0324
0325 void FlashDetectorConstruction::SetDetectorWidth(G4double width)
0326 {
0327
0328 fDet_width=width;
0329 }
0330
0331 void FlashDetectorConstruction::SetDetector_subThickness(G4double thickness_sub)
0332 {
0333
0334 fDet_sub_thickness= thickness_sub;
0335 }
0336
0337
0338
0339
0340
0341 void FlashDetectorConstruction::SetAirGap_water_detector(G4double spost)
0342 {
0343
0344 fAirGap_phantom_det=spost;
0345 }
0346
0347
0348 void FlashDetectorConstruction::SetDetectorPosition(G4double position)
0349 {
0350
0351 fDetectorPosition=position;
0352 }