refactor: introduce PhysicalVolume class and update Geant scene hierarchy to use logical and physical volumes
This commit is contained in:
@@ -15,7 +15,7 @@ using namespace uLib;
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
||||
int nEvents = 10000;
|
||||
int nEvents = 100;
|
||||
if (argc > 1) {
|
||||
nEvents = std::stoi(argv[1]);
|
||||
}
|
||||
@@ -24,13 +24,16 @@ int main(int argc, char** argv) {
|
||||
Geant::Scene scene;
|
||||
scene.ConstructWorldBox(Vector3f(30_m, 30_m, 30_m), "G4_AIR");
|
||||
|
||||
ContainerBox iron_box;
|
||||
iron_box.Scale(Vector3f(18_m, 10_cm, 18_m));
|
||||
iron_box.SetPosition(Vector3f(-9_m, -5_cm, -9_m));
|
||||
Geant::BoxSolid* iron_cube = new Geant::BoxSolid("IronCube", &iron_box);
|
||||
iron_cube->SetNistMaterial("G4_Fe");
|
||||
iron_cube->Update();
|
||||
scene.AddSolid(iron_cube);
|
||||
ContainerBox *iron_box = new ContainerBox();
|
||||
iron_box->Scale(Vector3f(18_m, 10_cm, 18_m));
|
||||
iron_box->SetPosition(Vector3f(-9_m, -5_cm, -9_m));
|
||||
Geant::BoxSolid *iron_cube = new Geant::BoxSolid("IronCube", iron_box);
|
||||
Geant::Material *iron_mat = new Geant::Material("G4_Fe");
|
||||
Geant::LogicalVolume *iron_lv = new Geant::LogicalVolume("IronCube_lv");
|
||||
iron_lv->SetSolid(iron_cube);
|
||||
iron_lv->SetMaterial(iron_mat);
|
||||
iron_lv->Update();
|
||||
scene.AddVolume(new Geant::PhysicalVolume("IronCube", iron_lv));
|
||||
|
||||
// Top Detector Chamber (along Y axis)
|
||||
DetectorChamber* top_chamber_box = new DetectorChamber();
|
||||
@@ -38,9 +41,12 @@ int main(int argc, char** argv) {
|
||||
top_chamber_box->Rotate(90_deg, Vector3f(1, 0, 0));
|
||||
top_chamber_box->SetPosition(Vector3f(-10_m, 12_m, -10_m));
|
||||
Geant::BoxSolid* top_chamber = new Geant::BoxSolid("TopChamber", top_chamber_box);
|
||||
top_chamber->SetNistMaterial("G4_AIR");
|
||||
top_chamber->Update();
|
||||
scene.AddSolid(top_chamber);
|
||||
SmartPointer<Geant::Material> air_mat(new Geant::Material("G4_AIR"));
|
||||
Geant::LogicalVolume* top_chamber_lv = new Geant::LogicalVolume("TopChamber_lv");
|
||||
top_chamber_lv->SetSolid(top_chamber);
|
||||
top_chamber_lv->SetMaterial(air_mat);
|
||||
top_chamber_lv->Update();
|
||||
scene.AddVolume(new Geant::PhysicalVolume("TopChamber", top_chamber_lv));
|
||||
|
||||
// Bottom Detector Chamber (along Y axis)
|
||||
DetectorChamber* bottom_chamber_box = new DetectorChamber();
|
||||
@@ -48,9 +54,11 @@ int main(int argc, char** argv) {
|
||||
bottom_chamber_box->Rotate(90_deg, Vector3f(1, 0, 0));
|
||||
bottom_chamber_box->SetPosition(Vector3f(-10_m, -12_m, -10_m));
|
||||
Geant::BoxSolid* bottom_chamber = new Geant::BoxSolid("BottomChamber", bottom_chamber_box);
|
||||
bottom_chamber->SetNistMaterial("G4_AIR");
|
||||
bottom_chamber->Update();
|
||||
scene.AddSolid(bottom_chamber);
|
||||
Geant::LogicalVolume* bottom_chamber_lv = new Geant::LogicalVolume("BottomChamber_lv");
|
||||
bottom_chamber_lv->SetSolid(bottom_chamber);
|
||||
bottom_chamber_lv->SetMaterial(air_mat);
|
||||
bottom_chamber_lv->Update();
|
||||
scene.AddVolume(new Geant::PhysicalVolume("BottomChamber", bottom_chamber_lv));
|
||||
|
||||
// Setup SkyPlaneEmitterPrimary
|
||||
Geant::SkyPlaneEmitterPrimary* emitter = new Geant::SkyPlaneEmitterPrimary();
|
||||
|
||||
Reference in New Issue
Block a user