Thank you for your response. Here are the files:
#include "PMDetectorConstruction.hh"
#include "G4VUserDetectorConstruction.hh"
#include "G4VPhysicalVolume.hh"
#include "G4LogicalVolume.hh"
#include "G4Box.hh"
#include "G4Tubs.hh"
#include "G4PVPlacement.hh"
#include "G4NistManager.hh"
#include "G4SystemOfUnits.hh"
#include "G4VisAttributes.hh"
#include "G4Colour.hh"
PMDetectorConstruction::PMDetectorConstruction()
{
}
PMDetectorConstruction::~PMDetectorConstruction()
{
}
G4VPhysicalVolume *PMDetectorConstruction::Construct()
{
// Define materials
G4NistManager* nist = G4NistManager::Instance();
G4Material* worldMat = nist->FindOrBuildMaterial("G4_AIR");
G4Material* leadMat = nist->FindOrBuildMaterial("G4_Pb");
G4Material* NaIMat = nist->FindOrBuildMaterial("G4_SODIUM_IODIDE");
G4Material* CrBi = new G4Material("CrBi", 8.55 * g / cm3, 2);
CrBi->AddElement(nist->FindOrBuildElement("Cr"), 1);
CrBi->AddElement(nist->FindOrBuildElement("Bi"), 1);
// World volume
G4Box* solidWorld = new G4Box("solidWorld", 0.25 * m, 0.25 * m, 0.25 * m); //World volume
G4LogicalVolume* logicWorld = new G4LogicalVolume(solidWorld, worldMat, "logicWorld"); //Mother volume
G4VPhysicalVolume* physWorld = new G4PVPlacement(0, G4ThreeVector(0., 0., 0.), logicWorld, "physWorld", 0, false, 0, true); //Daughter volume
// Set visibility of the world volume to false
//logicWorld->SetVisAttributes(G4VisAttributes::GetInvisible());
// Collimator 1 next to source
G4double collimatorInnerRadius = 1. * cm;
G4double collimatorOuterRadius = 10 * cm; // 20 cm / 2
G4double collimatorHalfLengthZ = 2.5 * cm; // 5 cm / 2
G4Tubs* solidCollimator = new G4Tubs("solidCollimator", collimatorInnerRadius, collimatorOuterRadius, collimatorHalfLengthZ, 0., 2 * 3.14159265359);
G4ThreeVector collimatorPos(0., 0., -0.10 * m);
G4LogicalVolume* logicCollimator = new G4LogicalVolume(solidCollimator, leadMat, "logicCollimator");
new G4PVPlacement(0, collimatorPos, logicCollimator, "physCollimator", logicWorld, false, 0, true);
// Set visualization attributes for the Collimator1
G4VisAttributes* CollAttr = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5));
CollAttr->SetVisibility(true);
//CollAttr->SetForceWireframe(false);
CollAttr->SetForceSolid(true); // Render as solid
logicCollimator->SetVisAttributes(CollAttr);
// Sample
G4double sampleInnerRadius = 0.0 * cm;
G4double sampleOuterRadius = 5. * cm;
G4double sampleThickness = 1. * cm;
G4Tubs* solidSample = new G4Tubs("solidSample", sampleInnerRadius, sampleOuterRadius, sampleThickness, 0., 2 * 3.14159265359);
G4ThreeVector samplePos(0., 0., 0.);
G4LogicalVolume* logicSample = new G4LogicalVolume(solidSample, CrBi, "logicSample");
new G4PVPlacement(0, samplePos, logicSample, "physSample", logicWorld, false, 0, true);
// Set visualization attributes for the Sample
G4VisAttributes* SampleAttr = new G4VisAttributes(G4Colour(0., 1., 0.));
SampleAttr->SetVisibility(true);
//SampleAttr->SetForceWireframe(false);
SampleAttr->SetForceSolid(true); // Render as solid
logicSample->SetVisAttributes(SampleAttr);
// Collimator 2 next to the detector
G4double collimatorInnerRadius2 = 7.5 * cm;
G4double collimatorOuterRadius2 = 10 * cm; // 20 cm / 2
G4double collimatorHalfLengthZ2 = 2.5 * cm; // 5 cm / 2
G4Tubs* solidCollimator2 = new G4Tubs("solidCollimator2", collimatorInnerRadius2, collimatorOuterRadius2, collimatorHalfLengthZ2, 0., 2 * 3.14159265359);
G4ThreeVector collimatorPos2(0., 0., 0.225 * m);
G4LogicalVolume* logicCollimator2 = new G4LogicalVolume(solidCollimator2, leadMat, "logicCollimator2");
new G4PVPlacement(0, collimatorPos2, logicCollimator2, "physCollimator2", logicWorld, false, 0, true);
// Set visualization attributes for the Collimator2
G4VisAttributes* CollyAttr2 = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5));
CollyAttr2->SetVisibility(true);
//CollyAttr->SetForceWireframe(false);
CollyAttr2->SetForceSolid(true);
logicCollimator2->SetVisAttributes(CollyAttr2);
// NaI Detector
G4double NaIRadius = 7.5 * cm;
G4double NaIHalfLengthZ = 2.5 * cm;
G4Tubs* solidNaI = new G4Tubs("solidNaI", 0., NaIRadius, NaIHalfLengthZ, 0., 2 * 3.14159265359);
G4ThreeVector NaIPos(0., 0., 0.225 * m);
G4LogicalVolume* logicNaI = new G4LogicalVolume(solidNaI, NaIMat, "logicNaI");
new G4PVPlacement(0, NaIPos, logicNaI, "physNaI", logicWorld, false, 0, true);
// Set visualization attributes for the NaI Detector
G4VisAttributes* DetectorAttr = new G4VisAttributes(G4Colour(1., 0., 0.)); //The order is Red, green, blue
DetectorAttr->SetVisibility(true);
//DetectorAttr->SetForceWireframe(false);
DetectorAttr->SetForceSolid(true);
logicNaI->SetVisAttributes(DetectorAttr);
// Source
G4double SourceRadius = 2. * cm;
G4double SourceHalfLengthZ = 2. * cm;
G4Tubs* solidSource = new G4Tubs("soliSource", 0., SourceRadius, SourceHalfLengthZ, 0., 2 * 3.14159265359);
G4ThreeVector SourcePos(0., 0., -0.225 * m);
G4LogicalVolume* logicSource = new G4LogicalVolume(solidSource, worldMat, "logicSource");
new G4PVPlacement(0, SourcePos, logicSource, "physSource", logicWorld, false, 0, true);
// Set visualization attributes for the Source
G4VisAttributes* SourceAttr = new G4VisAttributes(G4Colour(0., 0., 1.)); //The order is Red, green, blue
SourceAttr->SetVisibility(true);
//DetectorAttr->SetForceWireframe(false);
SourceAttr->SetForceSolid(true);
logicSource->SetVisAttributes(SourceAttr);
return physWorld;
}
#ifndef PMDETECTORCONSTRUCTION_HH
#define PMDETECTORCONSTRUCTION_HH
#include "G4VUserDetectorConstruction.hh"
class PMDetectorConstruction : public G4VUserDetectorConstruction
{
public:
PMDetectorConstruction();
virtual ~PMDetectorConstruction();
virtual G4VPhysicalVolume *Construct();
};
#endif
#include "PMActionInitialization.hh"
PMActionInitialization::PMActionInitialization()
{}
PMActionInitialization::~PMActionInitialization()
{}
void PMActionInitialization::BuildForMaster() const
{}
void PMActionInitialization::Build() const
{
PMPrimaryGenerator *generator = new PMPrimaryGenerator();
SetUserAction(generator);
}
#ifndef PMACTIONINITIALIZATION_HH
#define PMACTIONINITIALIZATION_HH
#include "G4VUserActionInitialization.hh"
#include "PMPrimaryGenerator.hh"
class PMActionInitialization : public G4VUserActionInitialization
{
public:
PMActionInitialization();
~PMActionInitialization();
virtual void BuildForMaster() const;
virtual void Build() const;
};
#endif