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