#include "G4Electron.hh" #include "DetectorConstruction.hh" #include "SipmSD.hh" #include "SipmHit.hh" #include "G4RunManager.hh" #include "G4RunManager.hh" #include "G4NistManager.hh" #include "G4SDManager.hh" #include "G4Box.hh" #include "G4Cons.hh" #include "G4Orb.hh" #include "G4Sphere.hh" #include "G4Trd.hh" #include "G4LogicalVolume.hh" #include "G4PVPlacement.hh" #include "G4SystemOfUnits.hh" #include "G4VisAttributes.hh" #include "G4SystemOfUnits.hh" //ok #include "G4RotationMatrix.hh" #include "G4Tubs.hh" #include "G4Types.hh" #include "G4UnionSolid.hh" #include "G4SubtractionSolid.hh" #include "G4LogicalBorderSurface.hh" #include "G4OpticalSurface.hh" #include "G4OpBoundaryProcess.hh" #include "G4LogicalSkinSurface.hh" #include #include #include namespace B1 { //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4VPhysicalVolume* DetectorConstruction::Construct() { // Get nist material manager G4NistManager* nist = G4NistManager::Instance(); // Envelope parameters // G4double env_sizeXY = 20.0*cm, env_sizeZ = 20.0*cm; G4Material* env_mat = nist->FindOrBuildMaterial("G4_AIR"); std::vector photonEnergy = { 2.00 * eV, 2.03 * eV, 2.06 * eV, 2.09 * eV, 2.12 * eV, 2.15 * eV, 2.18 * eV, 2.21 * eV, 2.24 * eV, 2.27 * eV, 2.30 * eV, 2.33 * eV, 2.36 * eV, 2.39 * eV, 2.42 * eV, 2.45 * eV, 2.48 * eV, 2.51 * eV, 2.54 * eV, 2.57 * eV, 2.60 * eV, 2.63 * eV, 2.66 * eV, 2.69 * eV, 2.72 * eV, 2.75 * eV, 2.78 * eV, 2.81 * eV, 2.84 * eV, 2.87 * eV, 2.90 * eV, 2.93 * eV, 2.96 * eV, 2.99 * eV, 3.02 * eV, 3.05 * eV, 3.08 * eV, 3.11 * eV, 3.14 * eV, 3.17 * eV, 3.20 * eV, 3.23 * eV, 3.26 * eV, 3.29 * eV, 3.32 * eV, 3.35 * eV, 3.38 * eV, 3.41 * eV, 3.44 * eV, 3.47 * eV }; std::vector refractiveIndex = { 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00}; G4MaterialPropertiesTable* mpt = new G4MaterialPropertiesTable(); mpt->AddProperty("RINDEX", photonEnergy, refractiveIndex); env_mat->SetMaterialPropertiesTable(mpt); // Option to switch on/off checking of volumes overlaps // G4bool checkOverlaps = true; // // World // G4double world_sizeXY = env_sizeXY; G4double world_sizeZ = env_sizeZ; G4Material* world_mat = nist->FindOrBuildMaterial("G4_AIR"); auto solidWorld = new G4Box("World", // its name world_sizeXY, world_sizeXY, world_sizeZ); // its size auto logicWorld = new G4LogicalVolume(solidWorld, // its solid world_mat, // its material "World"); // its name auto physWorld = new G4PVPlacement(nullptr, // no rotation G4ThreeVector(), // at (0,0,0) logicWorld, // its logical volume "World", // its name nullptr, // its mother volume false, // no boolean operation 0, // copy number checkOverlaps); // overlaps checking // Envelope // auto solidEnv = new G4Box("Envelope", // its name env_sizeXY, env_sizeXY, env_sizeZ); // its size auto logicEnv = new G4LogicalVolume(solidEnv, // its solid env_mat, // its material "Envelope"); // its name new G4PVPlacement(nullptr, // no rotation G4ThreeVector(), // at (0,0,0) logicEnv, // its logical volume "Envelope", // its name logicWorld, // its mother volume false, // no boolean operation 0, // copy number checkOverlaps); // overlaps checking /* Detectors */ //this is where I arrange the size, position and materials of the physical objects G4Material* scintillator = nist->FindOrBuildMaterial("G4_PLASTIC_SC_VINYLTOLUENE"); G4Material* Shield_mat = nist->FindOrBuildMaterial("G4_Al"); G4Material* Si= nist->FindOrBuildMaterial("G4_Si"); G4ThreeVector pos1 = G4ThreeVector(0.0*m, 0.0*m, 0.0*cm); //rotasyon G4RotationMatrix* rotationMatrix = new G4RotationMatrix(); rotationMatrix->rotateY(CLHEP::pi/2. ); //sizes of the scintillatır G4double x_scint = 30.0 * mm; G4double y_scint = 30.0 * mm; G4double z_scint = 30.0 * mm; /* Scintillator Properties*/ //opening the file that contains the wavelength values of emission spectrum std::ifstream file("BC-408_emission20.csv"); // A guide on how to open files in c++: // https://stackoverflow.com/questions/68386415/in-c-opening-a-csv-file-with-ifstream if (!file.is_open()) { G4cout << "404 file not found!" < em_wavelengths; double wavelength; G4cout << "Wavelength Values:" << G4endl; while (file >> wavelength) { em_wavelengths.push_back(wavelength); G4cout << wavelength << G4endl; } file.close(); //opening the file that contains the Intensity values (y axis of emission spectrum graph) std::ifstream file1("BC-408_intensity20.csv"); // A guide on how to open files in c++: // https://stackoverflow.com/questions/68386415/in-c-opening-a-csv-file-with-ifstream // I make this file opening twice because it turns out that analyzing a csv file line by line is great source of misery if (!file1.is_open()) { G4cout << "404 file not found!" < em_intensities; double intensity; G4cout << "Intensity Values:" << G4endl; while (file1 >> intensity) { em_intensities.push_back(intensity); G4cout << intensity << G4endl; } file1.close(); std::vector BC408_abs = {210*cm, 210*cm, 210*cm, 210*cm, 210*cm, 210*cm, 210*cm, 210*cm, 210*cm, 210*cm, 210*cm, 210*cm, 210*cm, 210*cm, 210*cm, 210*cm, 210*cm, 210*cm, 210*cm, 210*cm}; // datasheet of saint gobain gives the Light Attenuation Length as 210cm for BC-408 and examples specifically for BC-408 uses this value as ABSORPTION_Bc408 so I geuss they are the same thing std::vector BC408_rindex = {1.58, 1.58, 1.58, 1.58, 1.58, 1.58, 1.58, 1.58, 1.58, 1.58, 1.58, 1.58, 1.58, 1.58, 1.58, 1.58, 1.58, 1.58, 1.58, 1.58}; //again datasheet of bc408 simply says Reflective index = 1.58 G4int NUMENTRIES = 20; G4MaterialPropertiesTable *Bc408_mt = new G4MaterialPropertiesTable(); Bc408_mt->AddProperty("RINDEX", em_wavelengths, BC408_rindex, NUMENTRIES); Bc408_mt->AddProperty("ABSLENGTH", em_wavelengths, BC408_abs, NUMENTRIES); Bc408_mt->AddProperty("SCINTILLATIONCOMPONENT1", em_wavelengths, em_intensities, NUMENTRIES); Bc408_mt->AddConstProperty("SCINTILLATIONYIELD",500./MeV); Bc408_mt->AddConstProperty("RESOLUTIONSCALE",1.0); Bc408_mt->AddConstProperty("SCINTILLATIONTIMECONSTANT1", 1.*ns); //Bc408_mt->AddConstProperty("SLOWTIMECONSTANT",1.*ns); //Bc408_mt->AddConstProperty("YIELDRATIO",1.); scintillator->SetMaterialPropertiesTable(Bc408_mt); /*1.Sintilatör*/ //PMT1 G4VSolid* SiPM1_hole = new G4Box("SiPM1_hole", 6.0*mm, 6.0*mm, 0.42*mm); G4ThreeVector holePosition(0., 0.0, 30.075*mm); G4VSolid* scint1 = new G4Box("det1", //name x_scint, y_scint, z_scint); // segment angles //wrap for scint1 G4VSolid* scint1_wrap_1 = new G4Box("scint1_wrap_thick", //name x_scint + 0.075*mm, y_scint + 0.075*mm, z_scint + 0.075*mm); G4VSolid* scint1_wrap_2 = new G4Box("scint1_wrap_thin", //name x_scint, y_scint, z_scint); G4VSolid * scint1_wrap0 = new G4SubtractionSolid("scint1_wrap_0", scint1_wrap_1, scint1_wrap_2); G4VSolid * scint1_wrap = new G4SubtractionSolid("scint1_wrap", scint1_wrap0, SiPM1_hole, 0, holePosition); G4LogicalVolume* logic_scint1_wrap = new G4LogicalVolume(scint1_wrap, Shield_mat, "logic_scint1_wrap"); G4Colour wrap_color(0, 1, 1, 1); G4VisAttributes* wrap1_color = new G4VisAttributes(wrap_color); wrap1_color->SetVisibility(true); logic_scint1_wrap->SetVisAttributes(wrap1_color); G4VPhysicalVolume* phys_surface_scint1 = new G4PVPlacement(rotationMatrix, // no rotation pos1, // at position logic_scint1_wrap, // its logical volume "PVscint1_wrap", // its name logicEnv, // its mother volume false, // no boolean operation 0, // copy number checkOverlaps); //end of scint1's wrapping G4LogicalVolume* logic_scint1 = new G4LogicalVolume(scint1, scintillator, "logic_scint1"); G4Colour color(1, 0, 0, 0.3); G4VisAttributes* scint1_color = new G4VisAttributes(color); scint1_color->SetVisibility(true); logic_scint1->SetVisAttributes(scint1_color); G4VPhysicalVolume* phys_scint1 = new G4PVPlacement(rotationMatrix, // no rotation pos1, // at position logic_scint1, // its logical volume "PVscint1", // its name logicEnv, // its mother volume false, // no boolean operation 0, // copy number checkOverlaps); // overlaps checking /* 1. SiPm */ G4ThreeVector sipmPosition(-30.210*mm, 0.0, 0.0); G4VSolid* sipm1 = new G4Box("Sipm1", 0.21*mm, 6.0*mm, 6.0*mm); G4LogicalVolume* logic_sipm1 = new G4LogicalVolume(sipm1, Si, "logic_sipm1"); G4Colour color_of_sipm(1, 1, 1, 0.4); G4VisAttributes* sipm1_color = new G4VisAttributes(color_of_sipm); sipm1_color->SetVisibility(true); logic_sipm1->SetVisAttributes(sipm1_color); G4VPhysicalVolume* phys_sipm1 = new G4PVPlacement(nullptr, sipmPosition, // at position logic_sipm1, // its logical volume "PVsipm1", // its name logicEnv, // its mother volume false, // no boolean operation 0, // copy number checkOverlaps); // overlaps checking //------------------------------Optical Surface of alu-scint------------------ G4OpticalSurface* OpSurface = new G4OpticalSurface("scintillatorSurface1"); OpSurface->SetType(dielectric_metal); //OpSurface->SetFinish(polishedfrontpainted); OpSurface->SetFinish(polished); OpSurface->SetModel(unified); OpSurface->SetSigmaAlpha(0.1*deg); std::vector pp = { 1.856 * eV, 7.79 * eV }; std::vector rindex = {1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835, 1.6835}; std::vector reflectivity = { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}; std::vector efficiency = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, }; G4MaterialPropertiesTable* opSurfaceProperty = new G4MaterialPropertiesTable(); opSurfaceProperty->AddProperty("REFLECTIVITY", photonEnergy, reflectivity); opSurfaceProperty->AddProperty("EFFICIENCY", photonEnergy, efficiency); opSurfaceProperty->AddProperty("RINDEX", photonEnergy, rindex); OpSurface->SetMaterialPropertiesTable(opSurfaceProperty); G4LogicalBorderSurface* Surface = new G4LogicalBorderSurface("Scint1Surface", phys_scint1, phys_surface_scint1, OpSurface); //------------------------------End of Optical Surface of alu-scint------------------ //------------------------------Optical Surface of sipm-scint------------------ G4OpticalSurface* OpSurface_for_sipm = new G4OpticalSurface("scintillator_sipm_Surface"); //G4LogicalBorderSurface* Surface = new G4LogicalBorderSurface("Scint1Surface", phys_scint1, phys_surface_scint1, OpSurface); OpSurface_for_sipm->SetType(dielectric_dielectric); //OpSurface->SetFinish(polishedfrontpainted); OpSurface_for_sipm->SetFinish(polished); OpSurface_for_sipm->SetModel(unified); OpSurface_for_sipm->SetSigmaAlpha(0.1*deg); // no known std::vector pp_of_Si = { 2.0 * eV, 3.47 * eV };//taken from: /examples/extended/optical/wls/src/WLSMaterials.cc std::vector rindex_of_Si = {1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46, 1.46 }; // taken from: /examples/extended/optical/wls/src/WLSMaterials.cc //std::vector reflectivity = { 1.0, 1.0 }; //std::vector efficiency = { 0.1, 0.8 }; G4MaterialPropertiesTable* opSurfaceProperty_for_sipm = new G4MaterialPropertiesTable(); //opSurfaceProperty->AddProperty("REFLECTIVITY", pp, reflectivity); //opSurfaceProperty->AddProperty("EFFICIENCY", pp, efficiency); opSurfaceProperty_for_sipm->AddProperty("RINDEX", photonEnergy, rindex_of_Si); //opSurfaceProperty_for_sipm->AddProperty("ABSLENGTH", pp_of_Si, absClad); OpSurface_for_sipm->SetMaterialPropertiesTable(opSurfaceProperty_for_sipm); G4LogicalBorderSurface* Surface_sipm = new G4LogicalBorderSurface("Scint1Surface", phys_scint1, phys_sipm1, OpSurface_for_sipm); //------------------------------End of Optical Surface of Simp-scint------------------------- //end of scint1 fScoringVolume = logic_sipm1; //son return physWorld; } void DetectorConstruction::ConstructSDandField() { // Sensitive detectors G4String SipmChamberSD1name = "/SipmSD1"; auto aSipmSD1 = new SipmSD(SipmChamberSD1name, "DetCollection1"); G4SDManager::GetSDMpointer()->AddNewDetector(aSipmSD1); SetSensitiveDetector("logic_sipm1", aSipmSD1, true); } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......