File indexing completed on 2025-10-17 08:04:49
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 #include "FlashSensitiveDetector.hh"
0071
0072
0073
0074 FlashDetectorConstruction::FlashDetectorConstruction()
0075 : G4VUserDetectorConstruction(), physicalTreatmentRoom(0),logicTreatmentRoom(0), Collimator(0), fPhantom(0),
0076 fPhantomLogicalVolume(0),fPhant_phys(0),
0077 fCheckOverlaps(true),
0078 fActivateDet(false)
0079 {
0080
0081 DefineMaterials();
0082 fDetectorMessenger = new FlashDetectorMessenger(this);
0083
0084 SetPhantomSize(30. *cm, 30. *cm, 30. *cm);
0085 SetAirGap(0*cm);
0086 SetDetectorThickness(10*um);
0087 SetDetector_subThickness(370*um);
0088 SetDetectorWidth(2*mm);
0089 SetDetectorPosition(13*mm);
0090
0091
0092 nDet = 40;
0093 fDet_ctc = 3 * mm;
0094
0095 }
0096
0097
0098
0099 FlashDetectorConstruction::~FlashDetectorConstruction() {
0100
0101 delete fDetectorMessenger;
0102 }
0103
0104
0105
0106 void FlashDetectorConstruction::DefineMaterials() {
0107 nist = G4NistManager::Instance();
0108
0109 G4bool isotopes = false;
0110 Si = nist->FindOrBuildElement("Si", isotopes);
0111 C = nist->FindOrBuildElement("C", isotopes);
0112
0113 }
0114
0115
0116
0117 G4VPhysicalVolume *
0118 FlashDetectorConstruction::ConstructPhantom(G4double CollPos) {
0119
0120
0121 fPhantomMaterial = nist->FindOrBuildMaterial("G4_WATER");
0122
0123 fPosition_coefficient = CollPos;
0124
0125 fPhantom_coordinateX = (fPosition_coefficient * mm + fPhantomSizeX / 2);
0126
0127 fPhantomPosition = G4ThreeVector(fPhantom_coordinateX, 0. * mm, 0. * mm);
0128
0129
0130
0131 fPhantom = new G4Box("Phantom", fPhantomSizeX / 2, fPhantomSizeY / 2,
0132 fPhantomSizeZ / 2);
0133
0134
0135 fPhantomLogicalVolume =
0136 new G4LogicalVolume(fPhantom, fPhantomMaterial, "phantomLog", 0, 0, 0);
0137
0138
0139 fPhant_phys =
0140 new G4PVPlacement(0, fPhantomPosition, "phantomPhys", fPhantomLogicalVolume,
0141 physicalTreatmentRoom, false, 0);
0142
0143 G4Region *PhantomRegion = new G4Region("Phantom_reg");
0144 fPhantomLogicalVolume->SetRegion(PhantomRegion);
0145 PhantomRegion->AddRootLogicalVolume(fPhantomLogicalVolume);
0146
0147
0148 red = new G4VisAttributes(G4Colour(0 / 255., 255 / 255., 0 / 255.));
0149 red->SetVisibility(true);
0150
0151 blue = new G4VisAttributes(G4Colour(0 / 255., 0. / 255., 255. / 255.));
0152 blue->SetVisibility(true);
0153
0154 fPhantomLogicalVolume->SetVisAttributes(red);
0155
0156 G4double maxStep = 0.1 * mm;
0157 fStepLimit = new G4UserLimits(maxStep);
0158 fPhantomLogicalVolume->SetUserLimits(fStepLimit);
0159
0160 return fPhant_phys;
0161 }
0162
0163
0164 void FlashDetectorConstruction::ConstructDetector(){
0165
0166
0167
0168 G4double fDensity_SiC=3.22*g/cm3;
0169
0170 SiC=new G4Material("SiC", fDensity_SiC,2);
0171 SiC->AddElement(Si,1);
0172 SiC->AddElement(C,1);
0173
0174 fDetectorMaterial=SiC;
0175
0176
0177
0178 fDet_box = new G4Box("Detector",fDet_thickness/2,fDet_width/2,fDet_width/2);
0179
0180
0181 fDetLogicalVolume =
0182 new G4LogicalVolume(fDet_box, fDetectorMaterial, "DetectorLog", 0, 0, 0);
0183
0184
0185 fDet_sub = new G4Box("Det_sub",fDet_sub_thickness/2,fDet_width/2,fDet_width/2);
0186
0187
0188 fDet_sub_LogicalVolume =
0189 new G4LogicalVolume(fDet_sub, fDetectorMaterial, "Det_sub_Log", 0, 0, 0);
0190
0191
0192 G4double posInit = (nDet - 1) * fDet_ctc / 2;
0193
0194
0195 if (fActivateDet) {
0196
0197 for (int i = 0; i < nDet; i++){
0198
0199 std::ostringstream os;
0200 os << "Det_Phys_";
0201 if (i < 10)
0202 {
0203 os << "00";
0204 } else if (i < 100){
0205 os << "0";
0206 }
0207 os << i ;
0208 G4String name = os.str();
0209
0210 G4cout << "Position: " << -posInit + fDet_ctc * i << G4endl;
0211
0212 fDet_phys.push_back(new G4PVPlacement(
0213 0,
0214
0215 G4ThreeVector(-fPhantomSizeX/2+fDetectorPosition, 0, -posInit + fDet_ctc * i),
0216 name,
0217 fDetLogicalVolume,
0218 fPhant_phys,
0219 false,
0220 i,
0221 fCheckOverlaps
0222 ));
0223
0224
0225 fDet_sub_phys.push_back (new G4PVPlacement
0226 (0,
0227 G4ThreeVector(-fPhantomSizeX/2+fDetectorPosition+fDet_thickness/2+fDet_sub_thickness/2, 0. * mm, -posInit + fDet_ctc * i),
0228 "Det_sub_Phys",
0229 fDet_sub_LogicalVolume,
0230 fPhant_phys,
0231 false,
0232 i,
0233 fCheckOverlaps));
0234
0235
0236
0237 }
0238 }
0239
0240 }
0241
0242 G4VPhysicalVolume *FlashDetectorConstruction::Construct() {
0243
0244
0245
0246
0247 const G4double worldX = 400.0 * cm;
0248 const G4double worldY = 400.0 * cm;
0249 const G4double worldZ = 400.0 * cm;
0250 G4bool isotopes = false;
0251
0252 airNist = G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR", isotopes);
0253
0254
0255
0256 G4Box *treatmentRoom = new G4Box("TreatmentRoom", worldX, worldY, worldZ);
0257 logicTreatmentRoom = new G4LogicalVolume(treatmentRoom, airNist,
0258 "logicTreatmentRoom", 0, 0, 0);
0259 physicalTreatmentRoom =
0260 new G4PVPlacement(0, G4ThreeVector(), "physicalTreatmentRoom",
0261 logicTreatmentRoom, 0, false, 0);
0262
0263
0264 logicTreatmentRoom->SetVisAttributes(G4VisAttributes::GetInvisible());
0265
0266
0267
0268
0269
0270
0271
0272
0273 Collimator = new FlashApplicator(physicalTreatmentRoom);
0274
0275
0276
0277 fPhantom_physical =
0278 ConstructPhantom(Collimator->fFinalApplicatorXPositionFlash +
0279 Collimator->fHightFinalApplicatorFlash+fAirGap);
0280
0281
0282 ConstructDetector();
0283
0284 return physicalTreatmentRoom;
0285 }
0286
0287
0288
0289 void FlashDetectorConstruction::ConstructSDandField() {
0290 if (fActivateDet){
0291
0292 G4SDManager * SDman = G4SDManager::GetSDMpointer();
0293
0294
0295 FlashSensitiveDetector *fSensDet = new FlashSensitiveDetector("fSensitiveDetector");
0296
0297 SDman->AddNewDetector(fSensDet);
0298 fDetLogicalVolume->SetSensitiveDetector(fSensDet);
0299
0300 }
0301
0302 }
0303
0304
0305
0306
0307 G4bool FlashDetectorConstruction::SetPhantomMaterial(G4String material)
0308 {
0309
0310 if (G4Material* pMat = G4NistManager::Instance()->FindOrBuildMaterial(material, false) )
0311 {
0312 fPhantomMaterial = pMat;
0313
0314 if (fPhantomLogicalVolume)
0315 {
0316
0317 fPhantomLogicalVolume -> SetMaterial(pMat);
0318
0319 G4RunManager::GetRunManager() -> PhysicsHasBeenModified();
0320 G4RunManager::GetRunManager() -> GeometryHasBeenModified();
0321 G4cout << "The material of Phantom/Detector has been changed to " << material << G4endl;
0322 }
0323 }
0324 else
0325 {
0326 G4cout << "WARNING: material \"" << material << "\" doesn't exist in NIST elements/materials"
0327 " table [located in $G4INSTALL/source/materials/src/G4NistMaterialBuilder.cc]" << G4endl;
0328 G4cout << "Use command \"/parameter/nist\" to see full materials list!" << G4endl;
0329 return false;
0330 }
0331
0332 return true;
0333 }
0334
0335
0336 void FlashDetectorConstruction::SetPhantomSize(G4double sizeX, G4double sizeY, G4double sizeZ)
0337 {
0338 if (sizeX > 0.) fPhantomSizeX = sizeX;
0339 if (sizeY > 0.) fPhantomSizeY = sizeY;
0340 if (sizeZ > 0.) fPhantomSizeZ = sizeZ;
0341 }
0342
0343 void FlashDetectorConstruction::SetAirGap(G4double displ)
0344 {
0345
0346 fAirGap=displ;
0347 }
0348
0349 G4bool FlashDetectorConstruction::SetDetectorMaterial(G4String material)
0350 {
0351
0352 if (G4Material* pMat = G4NistManager::Instance()->FindOrBuildMaterial(material, false) )
0353 {
0354 fDetectorMaterial = pMat;
0355
0356 if (fDetLogicalVolume)
0357 {
0358
0359 fDetLogicalVolume -> SetMaterial(pMat);
0360
0361 G4RunManager::GetRunManager() -> PhysicsHasBeenModified();
0362 G4RunManager::GetRunManager() -> GeometryHasBeenModified();
0363 G4cout << "The material of Phantom/Detector has been changed to " << material << G4endl;
0364 }
0365 }
0366 else
0367 {
0368 G4cout << "WARNING: material \"" << material << "\" doesn't exist in NIST elements/materials"
0369 " table [located in $G4INSTALL/source/materials/src/G4NistMaterialBuilder.cc]" << G4endl;
0370 G4cout << "Use command \"/parameter/nist\" to see full materials list!" << G4endl;
0371 return false;
0372 }
0373
0374 return true;
0375 }
0376
0377
0378
0379
0380 void FlashDetectorConstruction::SetDetectorThickness(G4double thickness)
0381 {
0382
0383 fDet_thickness=thickness;
0384 }
0385
0386 void FlashDetectorConstruction::SetDetectorWidth(G4double width)
0387 {
0388
0389 fDet_width=width;
0390 }
0391
0392 void FlashDetectorConstruction::SetDetector_subThickness(G4double thickness_sub)
0393 {
0394
0395 fDet_sub_thickness= thickness_sub;
0396 }
0397
0398
0399 void FlashDetectorConstruction::SetDetectorPosition(G4double position)
0400 {
0401
0402 fDetectorPosition=position;
0403 }
0404
0405 void FlashDetectorConstruction::ActivateDetArray(G4bool fbool){
0406 fActivateDet = fbool;
0407 }