File indexing completed on 2026-05-18 07:54:51
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 #include "ActionInitialization.hh"
0030
0031 #include "ChemistryWorld.hh"
0032 #include "DetectorConstruction.hh"
0033 #include "InterPulseAction.hh"
0034 #include "PrimaryGeneratorAction.hh"
0035 #include "PulseAction.hh"
0036 #include "RunAction.hh"
0037 #include "StackingAction.hh"
0038 #include "TimeStepAction.hh"
0039
0040 #include "G4DNAChemistryManager.hh"
0041 #include "G4DNAEventScheduler.hh"
0042 #include "G4DNAScavengerMaterial.hh"
0043 #include "G4H2O.hh"
0044 #include "G4Molecule.hh"
0045 #include "G4MoleculeGun.hh"
0046 #include "G4Scheduler.hh"
0047 #include "G4RunManager.hh"
0048
0049
0050 ActionInitialization::ActionInitialization()
0051 : G4VUserActionInitialization()
0052 {
0053 DefineCommands();
0054 }
0055
0056
0057
0058 void ActionInitialization::BuildForMaster() const
0059 {
0060 SetUserAction(new RunAction());
0061 }
0062
0063
0064
0065 void ActionInitialization::Build() const
0066 {
0067 PulseAction* pPulseAction = nullptr;
0068 if (fActivePulse) {
0069 if (fUseInterPulse) {
0070 pPulseAction =
0071 new InterPulseAction(fPulseStructure, fUseHistoInput, fPulsePeriod, fNumberOfPulse);
0072 }
0073 else {
0074 pPulseAction = new PulseAction(fPulseStructure, fUseHistoInput);
0075 }
0076
0077 pPulseAction->SetPulse(fActivePulse);
0078 SetUserAction(pPulseAction);
0079 }
0080
0081 SetUserAction(new PrimaryGeneratorAction());
0082 auto pRunAction = new RunAction();
0083 SetUserAction(pRunAction);
0084
0085 if (G4DNAChemistryManager::IsActivated()) {
0086 SetUserAction(new StackingAction());
0087 const auto* fpDetector = dynamic_cast<const DetectorConstruction*>(
0088 G4RunManager::GetRunManager()->GetUserDetectorConstruction());
0089 auto pChemWorld = fpDetector->GetChemistryWorld();
0090 auto pScavenger = std::make_unique<G4DNAScavengerMaterial>(pChemWorld);
0091
0092 dynamic_cast<G4DNAScavengerMaterial*>(pScavenger.get())->SetCounterAgainstTime();
0093 G4Scheduler::Instance()->SetScavengerMaterial(std::move(pScavenger));
0094 auto timeStepAction = new TimeStepAction(pChemWorld, pPulseAction);
0095 auto eventScheduler = timeStepAction->GetEventScheduler();
0096 pRunAction->SetEventScheduler(eventScheduler);
0097 G4Scheduler::Instance()->SetUserAction(timeStepAction);
0098 }
0099 }
0100
0101
0102
0103 void ActionInitialization::DefineCommands()
0104 {
0105
0106 fMessenger = std::make_unique<G4GenericMessenger>(this, "/UHDR/pulse/", "Pulse control");
0107 auto& filenameCmd =
0108 fMessenger->DeclareMethod("pulseFile", &ActionInitialization::SetPulseStructureInput);
0109 filenameCmd.SetParameterName("filenamePulse", true);
0110 filenameCmd.SetDefaultValue("");
0111
0112 auto& activePulseCmd = fMessenger->DeclareProperty("pulseOn", fActivePulse);
0113 activePulseCmd.SetParameterName("activatePulse", true);
0114 activePulseCmd.SetDefaultValue("false");
0115
0116 auto& filenameCmdHisto =
0117 fMessenger->DeclareMethod("pulseInHisto", &ActionInitialization::SetPulseStructureHistoInput);
0118 filenameCmdHisto.SetParameterName("filenameInHisto", true);
0119 filenameCmdHisto.SetDefaultValue("");
0120
0121 auto& interPulseCmd = fMessenger->DeclareProperty("multiPulse", fUseInterPulse);
0122 interPulseCmd.SetParameterName("activateInterPulse", true);
0123 interPulseCmd.SetDefaultValue("false");
0124
0125 auto& pulsePeriodCmd =
0126 fMessenger->DeclareMethodWithUnit("pulsePeriod", "us", &ActionInitialization::SetPulsePeriod);
0127 pulsePeriodCmd.SetParameterName("pulsePeriod", true);
0128 pulsePeriodCmd.SetDefaultValue("0");
0129 pulsePeriodCmd.SetRange("pulsePeriod >= 0");
0130
0131 auto& nPulseCmd =
0132 fMessenger->DeclareMethod("numberOfPulse", &ActionInitialization::SetNumberOfPulse);
0133 nPulseCmd.SetParameterName("numberOfPulse", true);
0134 nPulseCmd.SetDefaultValue("1");
0135 nPulseCmd.SetRange("numberOfPulse >= 1");
0136 }
0137
0138
0139 void ActionInitialization::SetPulseStructureHistoInput(G4String fn)
0140 {
0141
0142 fPulseStructure = fn;
0143 fUseHistoInput = true;
0144 }
0145
0146
0147 void ActionInitialization::SetPulseStructureInput(G4String fn)
0148 {
0149
0150 fPulseStructure = fn;
0151 fUseHistoInput = false;
0152 }