測定器を作りたい(G4VUserDetectorConstruction
)
1// include/MYDetectorConstruction.hh
2
3#ifndef MYDetectorConstruction_h
4#define MYDetectorConstruction_h 1
5
6#include "G4VUserDetectorConstruction.hh"
7
8#include "G4VPhysicalVolume.hh"
9#include "G4LogicalVolume.hh"
10
11class MYDetectorConstruction : public G4VUserDetectorConstruction
12{
13 public:
14 DetectorConstruction() = default;
15 ~DetectorConstruction() override = default;
16
17 G4VPhysicalVolume* Construct() override;
18
19 private:
20 G4LogicalVolume *fWorldL
21 G4LogicalVolume *fTankL
22 G4LogicalVolume *fPmtL
23
24}
25#endif
1// src/MYDetectorConstruction.cc
2
3#include "MYDetectorConstruction.hh"
4
5G4VPhysicalVolume* DetectorConstruction::Construct()
6{
7 // ワールド
8 G4Material *fAir = new G4Material(...);
9 G4Box *fWorldS = new G4Box("worldS", ...);
10 G4LogicalVolume *fWorldL = new G4LogicalVolume(fWorldS, fAir, "worldL");
11 G4Transform3D location = G4Transform3D(nullptr, nullptr);
12 G4VPhysicalVolume *fWorldP = new G4PVPlacement(location, fWorldL, "worldP", nullptr, ...);
13
14 // 測定器(例:水タンク)
15 G4LogicalVolume *fTankL = new G4LogicalVolume(...);
16 new G4PVPlacement(...);
17
18 // 検出器(例:光電子増倍管)
19 G4LogicalVolume *fPmtL = new G4LogicalVolume(...);
20 new G4PVPlacement(...);
21
22 // 必ずワールドをリターンする
23 return fWorldP
24}
MYDetectorConstruction
クラスは、G4VUserDetectorConstruction
を継承して作成します。
G4VSolid
、G4LogicalVolume
、G4VPhysicalVolume
を使って、Geant4の中に構造物を配置できます。