B3したい(examples/basic/B3

B3の題材はPETです。 患者の頭を円柱とし、その周りをLSO結晶で作ったガンマ線検出器で取り囲んでいます。

ビルドしたい

$ cd examples/basic/B3/B3a
(B3/B3a/) $ mkdir build
(B3/B3a/) $ cd build
(B3/B3a/build/) $ cmake ..
(B3/B3a/build/) $ make -j8
(B3/B3a/build/) $ ./exampleB3a

examples/basic/B3/の中にはB3aB3bのディレクトリがあります。

患者の頭部を作成する

 1G4LogicalVolume* DefinePatientVolume(const G4String &aName)
 2{
 3    // 脳の組織を取得する
 4    G4NistManager *nm = new G4NistManager::Instance()
 5    auto material = nm->FindOrBuildMaterial("G4_BRAIN_ICMP");
 6
 7    // 円柱を作成する
 8    // 半径 : 8 cm
 9    // 長さ : 10cm
10    auto solid = new G4Tubs(
11        "Patient",
12        0.,
13        8 * cm,    // 半径
14        5 * cm,    // 長さ
15        0. * deg,
16        360. * deg
17    )
18
19    // 論理物体を作成する
20    auto logical = new G4LogicalVolume(
21        solid,
22        material,
23        aName,
24    )
25
26    return logical;
27}
 1// 物理物体を配置する
 2auto logicPatient = DefinePatientVolume("PatientLV");
 3new G4PVPlacement(
 4    nullptr,
 5    G4ThreeVector(),
 6    logicPatient,
 7    "Patient",
 8    logicWorld,
 9    false,
10    0,
11    fCheckOverlaps,
12)

放射線源を作成する

 1void PrimaryGneneratorAction::GeneratePrimaries(G4Event *aEvent)
 2{
 3    G4int numberOfParticles = 1;
 4    auto fParticleGun = new G4ParticleGun(numberOfParticles);
 5
 6    // Fluorine
 7    G4int Z = 9
 8    G4int A = 18;
 9    G4double ionCharge = 0. * eplus;
10    G4double exciteEnergy = 0. * keV;
11
12    G4ParticleDefinition* ion = G4IonTable::GetIonTable()->GetIon(Z, A, exciteEnergy);
13
14    fParticleGun->SetParticleDefinition(ion);
15    fParticleGun->SetParticleCharge(ionCharge);
16
17    // 入射位置の初期値
18    G4double x0 = 4. * cm;
19    G4double y0 = 4. * cm;
20    G4double z0 = 4. * cm;
21
22    G4double dx0 = 1. * cm;
23    G4double dy0 = 1. * cm;
24    G4double dz0 = 1. * cm;
25
26    // 入射位置をランダムにする
27    x0 += dx0 * (G4UniformRand() - 0.5);
28    y0 += dy0 * (G4UniformRand() - 0.5);
29    z0 += dz0 * (G4UniformRand() - 0.5);
30
31    auto vertex = G4ThreeVector(x0, y0, z0);
32    fParticleGun->SetParticlePosition(vertex);
33    fParticleGun->GeneratePrimaryVertex(aEvent);
34}

リファレンス