File indexing completed on 2025-02-23 09:21:55
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 "DetectorConstruction.hh"
0032
0033 #include "G4Box.hh"
0034 #include "G4GeometryManager.hh"
0035 #include "G4LogicalVolume.hh"
0036 #include "G4Material.hh"
0037 #include "G4NistManager.hh"
0038 #include "G4PVPlacement.hh"
0039 #include "G4ProductionCuts.hh"
0040 #include "G4RunManager.hh"
0041 #include "G4SystemOfUnits.hh"
0042 #include "G4ThreeVector.hh"
0043 #include "G4Tubs.hh"
0044 #include "G4UnitsTable.hh"
0045 #include "G4VPhysicalVolume.hh"
0046 #include "G4VisAttributes.hh"
0047
0048 const bool check_intersections = true;
0049
0050
0051 const G4double ug = 1.e-6 * g;
0052
0053
0054
0055 G4VPhysicalVolume* DetectorConstruction::Construct()
0056 {
0057 auto man = G4NistManager::Instance();
0058
0059
0060 new G4UnitDefinition("microgram", "ug", "Mass", ug);
0061
0062
0063 G4double worldSize = 8 * cm;
0064 G4double worldDensity = 0.15 * mg / m3;
0065
0066 G4double IV_diameter = 10 * mm;
0067 G4double IV_height = 20 * mm;
0068 G4double IV_vertical_offset = -5 * mm;
0069 G4double IV_density = 0.45 * ug / cm3;
0070
0071 G4double wall_tot_mass_thickness = 0.98 * mg / cm2;
0072 G4double wall_inner_layer_mass_thickness =
0073 0.02 * mg / cm2;
0074
0075 fCollDiameter = 3 * mm;
0076 fCollLength = 23 * mm;
0077 fCollExitPosition = -5.5 * mm;
0078
0079 G4double enDet_diameter = 10 * mm;
0080 G4double enDet_thickness = 150 * um;
0081 G4double enDet_distance = 10 * mm;
0082
0083
0084 auto worldMaterial =
0085 man->BuildMaterialWithNewDensity("WORLD_WATER_VACUUM", "G4_WATER", worldDensity);
0086 auto targetMaterial = man->BuildMaterialWithNewDensity("TARGET_WATER", "G4_WATER", IV_density);
0087 auto wallMaterial = man->FindOrBuildMaterial("G4_MYLAR");
0088 auto collMaterial = man->FindOrBuildMaterial("G4_BRASS");
0089 auto enDetMaterial = man->FindOrBuildMaterial("G4_Si");
0090
0091
0092 G4ThreeVector origin(0, 0, 0);
0093 G4ThreeVector IV_centre(0, 0, IV_vertical_offset);
0094 G4ThreeVector enDet_centre(enDet_distance + IV_diameter / 2., 0, 0);
0095
0096 G4double mylarDensity = wallMaterial->GetDensity();
0097 G4double wall_total_thickness = wall_tot_mass_thickness / mylarDensity;
0098 G4double wall_inner_layer_thickness = wall_inner_layer_mass_thickness / mylarDensity;
0099
0100
0101 auto innerWallMaterial = man->BuildMaterialWithNewDensity("WALL_WATER", "G4_WATER", mylarDensity);
0102
0103
0104 auto filename = "SIM_GEOMETRY_SETTINGS.txt";
0105 std::ofstream TextFile;
0106 TextFile.open(filename, std::fstream::out);
0107 TextFile << "worldSize = " << worldSize / cm << " cm\n";
0108 TextFile << "worldDensity = " << worldDensity / (mg / m3) << " mg/m3\n";
0109 TextFile << "IV_diameter = " << IV_diameter / mm << " mm\n";
0110 TextFile << "IV_height = " << IV_height / mm << " mm\n";
0111 TextFile << "IV_vertical_offset = " << IV_vertical_offset / mm << " mm\n";
0112 TextFile << "IV_density = " << IV_density / (ug / cm3) << " ug/cm3\n";
0113 TextFile << "wall_tot_mass_thickness = " << wall_tot_mass_thickness / (mg / cm2) << " mg/cm2\n";
0114 TextFile << "wall_inner_layer_mass_thickness = " << wall_inner_layer_mass_thickness / (mg / cm2)
0115 << " mg/cm2\n";
0116 TextFile << "fCollDiameter = " << fCollDiameter / mm << " mm\n";
0117 TextFile << "fCollLength = " << fCollLength / mm << " mm\n";
0118 TextFile << "fCollExitPosition = " << fCollExitPosition / mm << " mm\n";
0119 TextFile << "enDet_diameter = " << enDet_diameter / mm << " mm\n";
0120 TextFile << "enDet_thickness = " << enDet_thickness / mm << " mm\n";
0121 TextFile << "enDet_distance = " << enDet_distance / mm << " mm\n";
0122 TextFile << "worldMaterial: " << worldMaterial->GetName() << "\n";
0123 TextFile << "targetMaterial: " << targetMaterial->GetName() << "\n";
0124 TextFile << "wallMaterial: " << wallMaterial->GetName() << "\n";
0125 TextFile << "collMaterial: " << collMaterial->GetName() << "\n";
0126 TextFile << "enDetMaterial: " << enDetMaterial->GetName() << "\n";
0127 TextFile << "innerWallMaterial: " << innerWallMaterial->GetName() << "\n";
0128
0129
0130
0131 auto worldSolid = new G4Box("worldSolid",
0132 worldSize / 2, worldSize / 2,
0133 worldSize / 2);
0134
0135 auto worldLogic = new G4LogicalVolume(worldSolid,
0136 worldMaterial,
0137 "worldLogic");
0138
0139 auto worldPhys = new G4PVPlacement(nullptr,
0140 G4ThreeVector(0, 0, 0),
0141 worldLogic,
0142 "worldPhys",
0143 nullptr,
0144 false,
0145 0,
0146 check_intersections);
0147
0148
0149 auto chamberSolid = new G4Tubs("chamberSolid",
0150 0,
0151 IV_diameter / 2.,
0152 IV_height / 2.,
0153 0 * deg,
0154 360 * deg);
0155
0156 auto chamberLogic = new G4LogicalVolume(chamberSolid,
0157 targetMaterial,
0158 "chamberLogic");
0159
0160 new G4PVPlacement(nullptr, IV_centre, chamberLogic, "chamberPhys", worldLogic, false, 0,
0161 check_intersections);
0162
0163
0164
0165
0166 auto targetSolid = new G4Tubs("targetSolid",
0167 0,
0168 IV_diameter / 2.,
0169 IV_height / 2.,
0170 0 * deg,
0171 360 * deg);
0172
0173 auto targetLogic = new G4LogicalVolume(targetSolid, targetMaterial, "targetLogic");
0174
0175 new G4PVPlacement(nullptr, origin, targetLogic, "targetPhys", chamberLogic, false, 0,
0176 check_intersections);
0177
0178
0179
0180
0181 auto wallSolid = new G4Tubs("wallSolid",
0182 IV_diameter / 2.,
0183 IV_diameter / 2. + wall_total_thickness,
0184 IV_height / 2.,
0185 0 * deg,
0186 360 * deg);
0187
0188 auto wallLogic = new G4LogicalVolume(wallSolid, wallMaterial, "wallSolid");
0189 new G4PVPlacement(nullptr, IV_centre, wallLogic, "wallPhys", worldLogic, false, 0,
0190 check_intersections);
0191
0192
0193 auto innerWallSolid = new G4Tubs("innerWallSolid",
0194 IV_diameter / 2.,
0195 IV_diameter / 2. + wall_inner_layer_thickness,
0196 IV_height / 2.,
0197 0 * deg,
0198 360 * deg);
0199
0200 auto innerWallLogic = new G4LogicalVolume(innerWallSolid, innerWallMaterial, "innerWallLogic");
0201 new G4PVPlacement(nullptr, origin, innerWallLogic, "innerWallPhys", wallLogic, false, 0,
0202 check_intersections);
0203
0204
0205 auto collSolid = new G4Tubs("collSolid",
0206 fCollDiameter / 2.,
0207 fCollDiameter,
0208 fCollLength / 2.,
0209 0 * deg,
0210 360 * deg);
0211
0212 auto collLogic = new G4LogicalVolume(collSolid, collMaterial, "collSolid");
0213
0214 auto rot = new G4RotationMatrix();
0215 rot->rotateY(90 * deg);
0216 new G4PVPlacement(rot, G4ThreeVector(-fCollLength / 2 + fCollExitPosition, 0, 0), collLogic,
0217 "collPhys", worldLogic, false, 0, check_intersections);
0218
0219
0220
0221 auto enDetSolid = new G4Tubs("enDetSolid",
0222 0,
0223 enDet_diameter / 2.,
0224 enDet_thickness / 2.,
0225 0 * deg, 360 * deg);
0226
0227 auto enDetLogic = new G4LogicalVolume(enDetSolid, enDetMaterial, "enDetLogic");
0228 new G4PVPlacement(rot, enDet_centre, enDetLogic, "enDetPhys", worldLogic, false, 0,
0229 check_intersections);
0230
0231
0232
0233 auto worldVisAtt = new G4VisAttributes(G4Colour(1, 1, 1, 0.1));
0234 worldLogic->SetVisAttributes(worldVisAtt);
0235
0236 auto targetVisAtt = new G4VisAttributes(G4Colour(0.1, 0.5, 1, 0.7));
0237 targetLogic->SetVisAttributes(targetVisAtt);
0238
0239 auto innerWallVisAtt = new G4VisAttributes(G4Colour(0, 1, 1, 0.7));
0240 innerWallLogic->SetVisAttributes(innerWallVisAtt);
0241
0242 auto collVisAtt = new G4VisAttributes(G4Colour(0.7, 0.65, .25, 0.5));
0243 collLogic->SetVisAttributes(collVisAtt);
0244
0245 auto enDetVisAtt = new G4VisAttributes(G4Colour(0.5, 0.7, .5, 1.));
0246 enDetLogic->SetVisAttributes(enDetVisAtt);
0247
0248
0249
0250 auto region = new G4Region("Target");
0251
0252 auto cuts = new G4ProductionCuts();
0253
0254 G4double defCut = 1 * nanometer;
0255 cuts->SetProductionCut(defCut, "gamma");
0256 cuts->SetProductionCut(defCut, "e-");
0257 cuts->SetProductionCut(defCut, "e+");
0258 cuts->SetProductionCut(defCut, "proton");
0259
0260 region->SetProductionCuts(cuts);
0261 region->AddRootLogicalVolume(chamberLogic);
0262 region->AddRootLogicalVolume(targetLogic);
0263 region->AddRootLogicalVolume(innerWallLogic);
0264
0265 return worldPhys;
0266 }
0267