change to Linux

This commit is contained in:
liuyihui 2022-10-16 17:13:21 +08:00
parent 06b92fd866
commit 5d6f2765e3
20 changed files with 615 additions and 618 deletions

View File

@ -1,212 +1,212 @@
---
Language: Cpp
# BasedOnStyle: Google
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignArrayOfStructures: None
AlignConsecutiveMacros: None
AlignConsecutiveAssignments: None
AlignConsecutiveBitFields: None
AlignConsecutiveDeclarations: None
AlignEscapedNewlines: Left
AlignOperands: Align
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortEnumsOnASingleLine: true
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
AttributeMacros:
- __capability
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeConceptDeclarations: true
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 120
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: true
DisableFormat: false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: LogicalBlock
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IfMacros:
- KJ_IF_MAYBE
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^<ext/.*\.h>'
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: '^<.*\.h>'
Priority: 1
SortPriority: 0
CaseSensitive: false
- Regex: '^<.*'
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: '.*'
Priority: 3
SortPriority: 0
CaseSensitive: false
IncludeIsMainRegex: '([-_](test|unittest))?$'
IncludeIsMainSourceRegex: ''
IndentAccessModifiers: false
IndentCaseLabels: true
IndentCaseBlocks: false
IndentGotoLabels: true
IndentPPDirectives: None
IndentExternBlock: AfterExternBlock
IndentRequires: false
IndentWidth: 4
IndentWrappedFunctionNames: false
InsertTrailingCommas: None
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
LambdaBodyIndentation: Signature
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Never
ObjCBlockIndentWidth: 2
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PenaltyIndentedWhitespace: 0
PointerAlignment: Left
PPIndentWidth: -1
RawStringFormats:
- Language: Cpp
Delimiters:
- cc
- CC
- cpp
- Cpp
- CPP
- 'c++'
- 'C++'
CanonicalDelimiter: ''
BasedOnStyle: google
- Language: TextProto
Delimiters:
- pb
- PB
- proto
- PROTO
EnclosingFunctions:
- EqualsProto
- EquivToProto
- PARSE_PARTIAL_TEXT_PROTO
- PARSE_TEST_PROTO
- PARSE_TEXT_PROTO
- ParseTextOrDie
- ParseTextProtoOrDie
- ParseTestProto
- ParsePartialTestProto
CanonicalDelimiter: pb
BasedOnStyle: google
ReferenceAlignment: Pointer
ReflowComments: true
ShortNamespaceLines: 1
SortIncludes: CaseSensitive
SortJavaStaticImport: Before
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceAroundPointerQualifiers: Default
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: Never
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
BitFieldColonSpacing: Both
Standard: Auto
StatementAttributeLikeMacros:
- Q_EMIT
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 8
UseCRLF: false
UseTab: Never
WhitespaceSensitiveMacros:
- STRINGIZE
- PP_STRINGIZE
- BOOST_PP_STRINGIZE
- NS_SWIFT_NAME
- CF_SWIFT_NAME
...
---
Language: Cpp
# BasedOnStyle: Google
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignArrayOfStructures: None
AlignConsecutiveMacros: None
AlignConsecutiveAssignments: None
AlignConsecutiveBitFields: None
AlignConsecutiveDeclarations: None
AlignEscapedNewlines: Left
AlignOperands: Align
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortEnumsOnASingleLine: true
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
AttributeMacros:
- __capability
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeConceptDeclarations: true
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 120
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: true
DisableFormat: false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: LogicalBlock
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IfMacros:
- KJ_IF_MAYBE
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^<ext/.*\.h>'
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: '^<.*\.h>'
Priority: 1
SortPriority: 0
CaseSensitive: false
- Regex: '^<.*'
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: '.*'
Priority: 3
SortPriority: 0
CaseSensitive: false
IncludeIsMainRegex: '([-_](test|unittest))?$'
IncludeIsMainSourceRegex: ''
IndentAccessModifiers: false
IndentCaseLabels: true
IndentCaseBlocks: false
IndentGotoLabels: true
IndentPPDirectives: None
IndentExternBlock: AfterExternBlock
IndentRequires: false
IndentWidth: 4
IndentWrappedFunctionNames: false
InsertTrailingCommas: None
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
LambdaBodyIndentation: Signature
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Never
ObjCBlockIndentWidth: 2
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PenaltyIndentedWhitespace: 0
PointerAlignment: Left
PPIndentWidth: -1
RawStringFormats:
- Language: Cpp
Delimiters:
- cc
- CC
- cpp
- Cpp
- CPP
- 'c++'
- 'C++'
CanonicalDelimiter: ''
BasedOnStyle: google
- Language: TextProto
Delimiters:
- pb
- PB
- proto
- PROTO
EnclosingFunctions:
- EqualsProto
- EquivToProto
- PARSE_PARTIAL_TEXT_PROTO
- PARSE_TEST_PROTO
- PARSE_TEXT_PROTO
- ParseTextOrDie
- ParseTextProtoOrDie
- ParseTestProto
- ParsePartialTestProto
CanonicalDelimiter: pb
BasedOnStyle: google
ReferenceAlignment: Pointer
ReflowComments: true
ShortNamespaceLines: 1
SortIncludes: CaseSensitive
SortJavaStaticImport: Before
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceAroundPointerQualifiers: Default
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: Never
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
BitFieldColonSpacing: Both
Standard: Auto
StatementAttributeLikeMacros:
- Q_EMIT
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 8
UseCRLF: false
UseTab: Never
WhitespaceSensitiveMacros:
- STRINGIZE
- PP_STRINGIZE
- BOOST_PP_STRINGIZE
- NS_SWIFT_NAME
- CF_SWIFT_NAME
...

View File

@ -1,23 +1,22 @@
{
"configurations": [
{
"name": "Win32",
"name": "Linux",
"includePath": [
"${default}",
"${workspaceFolder}/include",
"D:/Geant4/dist/include/Geant4",
"D:/ROOT/include"
"/home/fox/G4Kit/Geant4/include",
"/home/fox/G4Kit/ROOT/include"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.19041.0",
"compilerPath": "D:/Microsoft/VisualStudio/2022/Community/VC/Tools/MSVC/14.31.31103/bin/Hostx64/x64/cl.exe",
"compilerPath": "/usr/bin/gcc",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "windows-msvc-x64",
"intelliSenseMode": "linux-gcc-x64",
"configurationProvider": "ms-vscode.cmake-tools"
}
],

View File

@ -1,5 +0,0 @@
{
"cmake.configureSettings": {
"CMAKE_TOOLCHAIN_FILE": "D:/Microsoft/vcpkg/scripts/buildsystems/vcpkg.cmake"
}
}

View File

@ -1,33 +1,36 @@
cmake_minimum_required(VERSION 3.16)
set(Geant4_DIR D:/Geant4/dist/lib/Geant4-11.0.1)
project(exampleB0)
option(WITH_GEANT4_UIVIS "Build example with Geant4 UI and Vis drivers" ON)
if(WITH_GEANT4_UIVIS)
find_package(Geant4 REQUIRED ui_all vis_all)
else()
find_package(Geant4 REQUIRED)
endif()
include(${Geant4_USE_FILE})
include_directories(${PROJECT_SOURCE_DIR}/include)
file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cpp)
file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.h)
add_executable(exampleB0 main.cpp ${sources} ${headers})
target_link_libraries(exampleB0 ${Geant4_LIBRARIES})
set(exampleB0_SCRIPTS
auto.mac
vis.mac
)
foreach(_script ${exampleB0_SCRIPTS})
configure_file(
${PROJECT_SOURCE_DIR}/${_script}
${PROJECT_BINARY_DIR}/Release/${_script}
COPYONLY
)
endforeach()
cmake_minimum_required(VERSION 3.16)
set(Geant4_DIR D:/Geant4/dist/lib/Geant4-11.0.1)
project(exampleB0)
set(Geant4_DIR ${Geant4_DIR})
option(WITH_GEANT4_UIVIS "Build example with Geant4 UI and Vis drivers" ON)
if(WITH_GEANT4_UIVIS)
find_package(Geant4 REQUIRED ui_all vis_all)
else()
find_package(Geant4 REQUIRED)
endif()
include(${Geant4_USE_FILE})
include_directories(${PROJECT_SOURCE_DIR}/include)
file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cpp)
file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.h)
add_executable(exampleB0 main.cpp ${sources} ${headers})
target_link_libraries(exampleB0 ${Geant4_LIBRARIES})
set(exampleB0_SCRIPTS
auto.mac
vis.mac
)
foreach(_script ${exampleB0_SCRIPTS})
configure_file(
${PROJECT_SOURCE_DIR}/${_script}
${PROJECT_BINARY_DIR}/${_script}
COPYONLY
)
endforeach()
install(TARGETS exampleB0 DESTINATION bin)

View File

@ -1,5 +1,5 @@
# G4 example B0
放疗水箱常用于放疗装置的剂量校准其尺寸为x=638mmy=630mmz=555mm。现假设一笔形束从x-y平面中心处自水箱外向下射入放疗水箱。
请用`Geant4`模拟计算不同能量的光子1MeV、5MeV、10MeV入射后在放疗水箱的z方向上的吸收剂量变化曲线。
# G4 example B0
放疗水箱常用于放疗装置的剂量校准其尺寸为x=638mmy=630mmz=555mm。现假设一笔形束从x-y平面中心处自水箱外向下射入放疗水箱。
请用`Geant4`模拟计算不同能量的光子1MeV、5MeV、10MeV入射后在放疗水箱的z方向上的吸收剂量变化曲线。

100
auto.mac
View File

@ -1,50 +1,50 @@
# 多线程设置
/run/numberOfThreads 12
# verbose
/control/verbose 1
/run/verbose 1
/event/verbose 0
/tracking/verbose 0
# 初始化
/run/initialize
# 定义 scoring 网格
/score/create/boxMesh water_box
/score/mesh/boxSize 319. 315. 277.5 mm
/score/mesh/nBin 1 1 555
# 定义需要获取的物理量与过滤器
# 过滤器,本例需要考虑次级粒子
/score/quantity/energyDeposit eDep
/score/quantity/doseDeposit Dose
# /score/filter/particle gammaFilter gamma
/score/close
# 发射粒子
/gun/particle gamma
/gun/energy 1 MeV
/run/beamOn 100000
# 保存数据
/score/dumpQuantityToFile water_box eDep eDep_1.txt
/score/dumpQuantityToFile water_box Dose Dose_1.txt
# 发射粒子
/gun/particle gamma
/gun/energy 5 MeV
/run/beamOn 100000
# 保存数据
/score/dumpQuantityToFile water_box eDep eDep_5.txt
/score/dumpQuantityToFile water_box Dose Dose_5.txt
# 发射粒子
/gun/particle gamma
/gun/energy 10 MeV
/run/beamOn 100000
# 保存数据
/score/dumpQuantityToFile water_box eDep eDep_10.txt
/score/dumpQuantityToFile water_box Dose Dose_10.txt
# 多线程设置
/run/numberOfThreads 12
# verbose
/control/verbose 1
/run/verbose 1
/event/verbose 0
/tracking/verbose 0
# 初始化
/run/initialize
# 定义 scoring 网格
/score/create/boxMesh water_box
/score/mesh/boxSize 319. 315. 277.5 mm
/score/mesh/nBin 1 1 555
# 定义需要获取的物理量与过滤器
# 过滤器,本例需要考虑次级粒子
/score/quantity/energyDeposit eDep
/score/quantity/doseDeposit Dose
# /score/filter/particle gammaFilter gamma
/score/close
# 发射粒子
/gun/particle gamma
/gun/energy 1 MeV
/run/beamOn 100000
# 保存数据
/score/dumpQuantityToFile water_box eDep eDep_1.txt
/score/dumpQuantityToFile water_box Dose Dose_1.txt
# 发射粒子
/gun/particle gamma
/gun/energy 5 MeV
/run/beamOn 100000
# 保存数据
/score/dumpQuantityToFile water_box eDep eDep_5.txt
/score/dumpQuantityToFile water_box Dose Dose_5.txt
# 发射粒子
/gun/particle gamma
/gun/energy 10 MeV
/run/beamOn 100000
# 保存数据
/score/dumpQuantityToFile water_box eDep eDep_10.txt
/score/dumpQuantityToFile water_box Dose Dose_10.txt

View File

@ -1,15 +1,15 @@
#ifndef B0ActionInitialization_h
#define B0ActionInitialization_h
#include "G4VUserActionInitialization.hh"
class ActionInitialization : public G4VUserActionInitialization {
public:
ActionInitialization();
~ActionInitialization() override;
void BuildForMaster() const override;
void Build() const override;
};
#ifndef B0ActionInitialization_h
#define B0ActionInitialization_h
#include "G4VUserActionInitialization.hh"
class ActionInitialization : public G4VUserActionInitialization {
public:
ActionInitialization();
~ActionInitialization() override;
void BuildForMaster() const override;
void Build() const override;
};
#endif

View File

@ -1,18 +1,18 @@
#ifndef B0DetectorConstruction_h
#define B0DetectorConstruction_h
#include "G4VUserDetectorConstruction.hh"
#include "globals.hh"
class G4VPhysicalVolume;
class G4LogicalVolume;
class DetectorConstruction : public G4VUserDetectorConstruction {
public:
DetectorConstruction();
~DetectorConstruction() override;
G4VPhysicalVolume* Construct() override;
};
#endif
#ifndef B0DetectorConstruction_h
#define B0DetectorConstruction_h
#include "G4VUserDetectorConstruction.hh"
#include "globals.hh"
class G4VPhysicalVolume;
class G4LogicalVolume;
class DetectorConstruction : public G4VUserDetectorConstruction {
public:
DetectorConstruction();
~DetectorConstruction() override;
G4VPhysicalVolume* Construct() override;
};
#endif

View File

@ -1,21 +1,21 @@
#ifndef B0EventAction_h
#define B0EventAction_h
#include "G4UserEventAction.hh"
#include "globals.hh"
class RunAction;
class EventAction : public G4UserEventAction {
public:
EventAction(RunAction* r);
~EventAction() override;
void BeginOfEventAction(const G4Event*) override;
void EndOfEventAction(const G4Event*) override;
private:
RunAction* fRunAction = nullptr;
};
#endif
#ifndef B0EventAction_h
#define B0EventAction_h
#include "G4UserEventAction.hh"
#include "globals.hh"
class RunAction;
class EventAction : public G4UserEventAction {
public:
EventAction(RunAction* r);
~EventAction() override;
void BeginOfEventAction(const G4Event*) override;
void EndOfEventAction(const G4Event*) override;
private:
RunAction* fRunAction = nullptr;
};
#endif

View File

@ -1,23 +1,23 @@
#ifndef B0PrimaryGeneratorAction_h
#define B0PrimaryGeneratorAction_h
#include "G4ParticleGun.hh"
#include "G4VUserPrimaryGeneratorAction.hh"
#include "globals.hh"
class G4ParticleGun;
class G4Event;
class G4Box;
class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction {
public:
PrimaryGeneratorAction();
~PrimaryGeneratorAction();
virtual void GeneratePrimaries(G4Event*);
const G4ParticleGun* GetParticleGun() const { return fParticleGun; }
private:
G4ParticleGun* fParticleGun;
};
#endif
#ifndef B0PrimaryGeneratorAction_h
#define B0PrimaryGeneratorAction_h
#include "G4ParticleGun.hh"
#include "G4VUserPrimaryGeneratorAction.hh"
#include "globals.hh"
class G4ParticleGun;
class G4Event;
class G4Box;
class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction {
public:
PrimaryGeneratorAction();
~PrimaryGeneratorAction();
virtual void GeneratePrimaries(G4Event*);
const G4ParticleGun* GetParticleGun() const { return fParticleGun; }
private:
G4ParticleGun* fParticleGun;
};
#endif

View File

@ -1,19 +1,19 @@
#ifndef B0RunAction_h
#define B0RunAction_h
#include "G4Accumulable.hh"
#include "G4UserRunAction.hh"
#include "globals.hh"
class G4Run;
class RunAction : public G4UserRunAction {
public:
RunAction();
~RunAction() override;
void BeginOfRunAction(const G4Run*) override;
void EndOfRunAction(const G4Run*) override;
};
#endif
#ifndef B0RunAction_h
#define B0RunAction_h
#include "G4Accumulable.hh"
#include "G4UserRunAction.hh"
#include "globals.hh"
class G4Run;
class RunAction : public G4UserRunAction {
public:
RunAction();
~RunAction() override;
void BeginOfRunAction(const G4Run*) override;
void EndOfRunAction(const G4Run*) override;
};
#endif

View File

@ -1,21 +1,21 @@
#ifndef B0SteppingAction_h
#define B0SteppingAction_h
#include "G4UserSteppingAction.hh"
#include "globals.hh"
class G4LogicalVolume;
class EventAction;
class SteppingAction : public G4UserSteppingAction {
public:
SteppingAction(EventAction* e);
~SteppingAction() override;
void UserSteppingAction(const G4Step*) override;
private:
EventAction* fEventAction = nullptr;
};
#ifndef B0SteppingAction_h
#define B0SteppingAction_h
#include "G4UserSteppingAction.hh"
#include "globals.hh"
class G4LogicalVolume;
class EventAction;
class SteppingAction : public G4UserSteppingAction {
public:
SteppingAction(EventAction* e);
~SteppingAction() override;
void UserSteppingAction(const G4Step*) override;
private:
EventAction* fEventAction = nullptr;
};
#endif

View File

@ -1,38 +1,38 @@
#include "ActionInitialization.h"
#include "DetectorConstruction.h"
#include "G4MTRunManager.hh"
#include "G4ScoringManager.hh"
#include "G4UIExecutive.hh"
#include "G4UImanager.hh"
#include "G4VisExecutive.hh"
#include "PrimaryGeneratorAction.h"
#include "QBBC.hh"
int main(int argc, char** argv) {
G4UIExecutive* ui = nullptr;
if (argc == 1) ui = new G4UIExecutive(argc, argv);
G4MTRunManager* runManager = new G4MTRunManager;
G4VisExecutive* visManager = new G4VisExecutive;
G4UImanager* UIManager = G4UImanager::GetUIpointer();
G4ScoringManager::GetScoringManager();
runManager->SetUserInitialization(new DetectorConstruction());
runManager->SetUserInitialization(new QBBC);
runManager->SetUserInitialization(new ActionInitialization());
visManager->Initialize();
if (!ui) {
G4String command = "/control/execute ";
G4String fileName = argv[1];
UIManager->ApplyCommand(command + fileName);
} else {
UIManager->ApplyCommand("/control/execute vis.mac");
ui->SessionStart();
delete ui;
}
delete runManager;
delete visManager;
return 0;
#include "ActionInitialization.h"
#include "DetectorConstruction.h"
#include "G4MTRunManager.hh"
#include "G4ScoringManager.hh"
#include "G4UIExecutive.hh"
#include "G4UImanager.hh"
#include "G4VisExecutive.hh"
#include "PrimaryGeneratorAction.h"
#include "QBBC.hh"
int main(int argc, char** argv) {
G4UIExecutive* ui = nullptr;
if (argc == 1) ui = new G4UIExecutive(argc, argv);
G4MTRunManager* runManager = new G4MTRunManager;
G4VisExecutive* visManager = new G4VisExecutive;
G4UImanager* UIManager = G4UImanager::GetUIpointer();
G4ScoringManager::GetScoringManager();
runManager->SetUserInitialization(new DetectorConstruction());
runManager->SetUserInitialization(new QBBC);
runManager->SetUserInitialization(new ActionInitialization());
visManager->Initialize();
if (!ui) {
G4String command = "/control/execute ";
G4String fileName = argv[1];
UIManager->ApplyCommand(command + fileName);
} else {
UIManager->ApplyCommand("/control/execute vis.mac");
ui->SessionStart();
delete ui;
}
delete runManager;
delete visManager;
return 0;
}

View File

@ -1,27 +1,27 @@
#include "ActionInitialization.h"
#include "EventAction.h"
#include "PrimaryGeneratorAction.h"
#include "RunAction.h"
#include "SteppingAction.h"
ActionInitialization::ActionInitialization() {}
ActionInitialization::~ActionInitialization() {}
void ActionInitialization::BuildForMaster() const {
RunAction* runAction = new RunAction;
SetUserAction(runAction);
}
void ActionInitialization::Build() const {
SetUserAction(new PrimaryGeneratorAction);
RunAction* runAction = new RunAction;
SetUserAction(runAction);
EventAction* eventAction = new EventAction(runAction);
SetUserAction(eventAction);
SetUserAction(new SteppingAction(eventAction));
#include "ActionInitialization.h"
#include "EventAction.h"
#include "PrimaryGeneratorAction.h"
#include "RunAction.h"
#include "SteppingAction.h"
ActionInitialization::ActionInitialization() {}
ActionInitialization::~ActionInitialization() {}
void ActionInitialization::BuildForMaster() const {
RunAction* runAction = new RunAction;
SetUserAction(runAction);
}
void ActionInitialization::Build() const {
SetUserAction(new PrimaryGeneratorAction);
RunAction* runAction = new RunAction;
SetUserAction(runAction);
EventAction* eventAction = new EventAction(runAction);
SetUserAction(eventAction);
SetUserAction(new SteppingAction(eventAction));
}

View File

@ -1,22 +1,22 @@
#include "DetectorConstruction.h"
#include "G4Box.hh"
#include "G4LogicalVolume.hh"
#include "G4NistManager.hh"
#include "G4PVPlacement.hh"
#include "G4SystemOfUnits.hh"
DetectorConstruction::DetectorConstruction() {}
DetectorConstruction::~DetectorConstruction() {}
G4VPhysicalVolume* DetectorConstruction::Construct() {
G4NistManager* nist = G4NistManager::Instance();
G4Box* solid_world = new G4Box("world", 638 / 2 * mm, 630 / 2 * mm, 555. / 2 * mm);
G4LogicalVolume* logic_world = new G4LogicalVolume(solid_world, nist->FindOrBuildMaterial("G4_WATER"), "world");
G4VPhysicalVolume* physics_world =
new G4PVPlacement(0, G4ThreeVector(0, 0, 0), logic_world, "world", 0, false, 0, true);
return physics_world;
}
#include "DetectorConstruction.h"
#include "G4Box.hh"
#include "G4LogicalVolume.hh"
#include "G4NistManager.hh"
#include "G4PVPlacement.hh"
#include "G4SystemOfUnits.hh"
DetectorConstruction::DetectorConstruction() {}
DetectorConstruction::~DetectorConstruction() {}
G4VPhysicalVolume* DetectorConstruction::Construct() {
G4NistManager* nist = G4NistManager::Instance();
G4Box* solid_world = new G4Box("world", 638 / 2 * mm, 630 / 2 * mm, 555. / 2 * mm);
G4LogicalVolume* logic_world = new G4LogicalVolume(solid_world, nist->FindOrBuildMaterial("G4_WATER"), "world");
G4VPhysicalVolume* physics_world =
new G4PVPlacement(0, G4ThreeVector(0, 0, 0), logic_world, "world", 0, false, 0, true);
return physics_world;
}

View File

@ -1,13 +1,13 @@
#include "EventAction.h"
#include "G4Event.hh"
#include "G4RunManager.hh"
#include "RunAction.h"
EventAction::EventAction(RunAction* r) : fRunAction(r) {}
EventAction::~EventAction() {}
void EventAction::BeginOfEventAction(const G4Event* event) { }
void EventAction::EndOfEventAction(const G4Event* event) { }
#include "EventAction.h"
#include "G4Event.hh"
#include "G4RunManager.hh"
#include "RunAction.h"
EventAction::EventAction(RunAction* r) : fRunAction(r) {}
EventAction::~EventAction() {}
void EventAction::BeginOfEventAction(const G4Event* event) { }
void EventAction::EndOfEventAction(const G4Event* event) { }

View File

@ -1,18 +1,18 @@
#include "PrimaryGeneratorAction.h"
#include "G4ParticleTable.hh"
#include "G4SystemOfUnits.hh"
PrimaryGeneratorAction::PrimaryGeneratorAction() {
auto table = G4ParticleTable::GetParticleTable();
fParticleGun = new G4ParticleGun(1);
fParticleGun->SetParticleDefinition(table->FindParticle("gamma"));
fParticleGun->SetParticlePosition(G4ThreeVector(0, 0, 555. / 2 * mm));
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0, 0, -1));
fParticleGun->SetParticleEnergy(1 * MeV);
}
PrimaryGeneratorAction::~PrimaryGeneratorAction() { delete fParticleGun; }
void PrimaryGeneratorAction::GeneratePrimaries(G4Event* e) { fParticleGun->GeneratePrimaryVertex(e); }
#include "PrimaryGeneratorAction.h"
#include "G4ParticleTable.hh"
#include "G4SystemOfUnits.hh"
PrimaryGeneratorAction::PrimaryGeneratorAction() {
auto table = G4ParticleTable::GetParticleTable();
fParticleGun = new G4ParticleGun(1);
fParticleGun->SetParticleDefinition(table->FindParticle("gamma"));
fParticleGun->SetParticlePosition(G4ThreeVector(0, 0, 555. / 2 * mm));
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0, 0, -1));
fParticleGun->SetParticleEnergy(1 * MeV);
}
PrimaryGeneratorAction::~PrimaryGeneratorAction() { delete fParticleGun; }
void PrimaryGeneratorAction::GeneratePrimaries(G4Event* e) { fParticleGun->GeneratePrimaryVertex(e); }

View File

@ -1,22 +1,22 @@
#include "RunAction.h"
#include "DetectorConstruction.h"
#include "G4AccumulableManager.hh"
#include "G4LogicalVolume.hh"
#include "G4LogicalVolumeStore.hh"
#include "G4Run.hh"
#include "G4RunManager.hh"
#include "G4SystemOfUnits.hh"
#include "G4UnitsTable.hh"
#include "PrimaryGeneratorAction.h"
RunAction::RunAction() {
}
RunAction::~RunAction() {}
void RunAction::BeginOfRunAction(const G4Run*) {
}
void RunAction::EndOfRunAction(const G4Run* run) {
}
#include "RunAction.h"
#include "DetectorConstruction.h"
#include "G4AccumulableManager.hh"
#include "G4LogicalVolume.hh"
#include "G4LogicalVolumeStore.hh"
#include "G4Run.hh"
#include "G4RunManager.hh"
#include "G4SystemOfUnits.hh"
#include "G4UnitsTable.hh"
#include "PrimaryGeneratorAction.h"
RunAction::RunAction() {
}
RunAction::~RunAction() {}
void RunAction::BeginOfRunAction(const G4Run*) {
}
void RunAction::EndOfRunAction(const G4Run* run) {
}

View File

@ -1,15 +1,15 @@
#include "SteppingAction.h"
#include "DetectorConstruction.h"
#include "EventAction.h"
#include "G4Event.hh"
#include "G4LogicalVolume.hh"
#include "G4RunManager.hh"
#include "G4Step.hh"
SteppingAction::SteppingAction(EventAction* e) : fEventAction(e) {}
SteppingAction::~SteppingAction() {}
void SteppingAction::UserSteppingAction(const G4Step* step) {
}
#include "SteppingAction.h"
#include "DetectorConstruction.h"
#include "EventAction.h"
#include "G4Event.hh"
#include "G4LogicalVolume.hh"
#include "G4RunManager.hh"
#include "G4Step.hh"
SteppingAction::SteppingAction(EventAction* e) : fEventAction(e) {}
SteppingAction::~SteppingAction() {}
void SteppingAction::UserSteppingAction(const G4Step* step) {
}

78
vis.mac
View File

@ -1,40 +1,40 @@
# 多线程设置
/run/numberOfThreads 4
# verbose
/control/saveHistory
/control/verbose 2
/run/verbose 1
/event/verbose 0
/tracking/verbose 0
# 初始化
/run/initialize
# 设置视图使用OpenGL
/vis/open OGL 800x800-0+0
# 禁止自动刷新,消息静音(除错误外)
/vis/viewer/set/autoRefresh false
/vis/verbose errors
# 绘制几何体
/vis/drawVolume
# 绘制轨迹 类型为平滑
/vis/scene/add/trajectories smooth
# 根据粒子ID进行绘制
/vis/modeling/trajectories/create/drawByParticleID
# 以2px的宽度绘制节点
/vis/modeling/trajectories/drawByParticleID-0/default/setDrawStepPts true
/vis/modeling/trajectories/drawByParticleID-0/default/setStepPtsSize 2
# 保留、叠加所有事例
/vis/scene/endOfEventAction accumulate
# 设置颜色
/vis/geometry/set/colour world 0 0 0 1 .3
/vis/viewer/set/style surface
# 坐标轴
/vis/scene/add/scale # Simple scale line
# 多线程设置
/run/numberOfThreads 4
# verbose
/control/saveHistory
/control/verbose 2
/run/verbose 1
/event/verbose 0
/tracking/verbose 0
# 初始化
/run/initialize
# 设置视图使用OpenGL
/vis/open OGL 800x800-0+0
# 禁止自动刷新,消息静音(除错误外)
/vis/viewer/set/autoRefresh false
/vis/verbose errors
# 绘制几何体
/vis/drawVolume
# 绘制轨迹 类型为平滑
/vis/scene/add/trajectories smooth
# 根据粒子ID进行绘制
/vis/modeling/trajectories/create/drawByParticleID
# 以2px的宽度绘制节点
/vis/modeling/trajectories/drawByParticleID-0/default/setDrawStepPts true
/vis/modeling/trajectories/drawByParticleID-0/default/setStepPtsSize 2
# 保留、叠加所有事例
/vis/scene/endOfEventAction accumulate
# 设置颜色
/vis/geometry/set/colour world 0 0 0 1 .3
/vis/viewer/set/style surface
# 坐标轴
/vis/scene/add/scale # Simple scale line
/vis/scene/add/axes # Simple axes: x=red, y=green, z=blue.