00001
00002
00003
00004
00005
00006
00007
00008 #include "PrimaryGeneratorMessenger.hh"
00009
00010 #include "PrimaryGeneratorAction.hh"
00011 #include "G4UIdirectory.hh"
00012 #include "G4UIcmdWithAString.hh"
00013 #include "G4UIcmdWithADouble.hh"
00014 #include "G4UIcmdWithAnInteger.hh"
00015 #include "G4UIcmdWithoutParameter.hh"
00016
00017
00018
00019 PrimaryGeneratorMessenger::PrimaryGeneratorMessenger(
00020 PrimaryGeneratorAction* Gun)
00021 :Action(Gun)
00022 {
00023 gunDir = new G4UIdirectory("/g4sim/gun/");
00024 gunDir->SetGuidance("PrimaryGenerator control");
00025
00026 InitializeCmd = new G4UIcmdWithoutParameter("/g4sim/gun/initialize",this);
00027 InitializeCmd->SetGuidance("Initialize PrimaryGeneratorAction.");
00028 InitializeCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
00029 InitializeCmd->SetGuidance("if you changed geometrical value(s).");
00030 InitializeCmd->AvailableForStates(G4State_Idle);
00031
00032 ResetGenCmd = new G4UIcmdWithAString("/g4sim/gun/ResetGen",this);
00033 ResetGenCmd->SetGuidance("Reset PrimaryGeneratorAction according to given file.");
00034 ResetGenCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00035
00036 ReadCardCmd = new G4UIcmdWithAString("/g4sim/gun/ReadCard",this);
00037 ReadCardCmd->SetGuidance("Read PrimaryGeneratorAction file.");
00038 ReadCardCmd->SetGuidance("You have to call update before you start a new run.");
00039 ReadCardCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00040
00041 EnergyMode_cmd = new G4UIcmdWithAString("/g4sim/gun/EnergyMode",this);
00042 EnergyMode_cmd->SetGuidance("Choose energy model:");
00043 EnergyMode_cmd->SetGuidance(" Choice : none(default), histo");
00044 EnergyMode_cmd->SetParameterName("choice",true);
00045 EnergyMode_cmd->SetDefaultValue("none");
00046 EnergyMode_cmd->SetCandidates("none histo txt root");
00047 EnergyMode_cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00048
00049 DirectionMode_cmd = new G4UIcmdWithAString("/g4sim/gun/DirectionMode",this);
00050 DirectionMode_cmd->SetGuidance("Choose direction model:");
00051 DirectionMode_cmd->SetGuidance(" Choice : none(default), uniform");
00052 DirectionMode_cmd->SetParameterName("choice",true);
00053 DirectionMode_cmd->SetDefaultValue("none");
00054 DirectionMode_cmd->SetCandidates("none uniform");
00055 DirectionMode_cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00056
00057 PositionMode_cmd = new G4UIcmdWithAString("/g4sim/gun/PositionMode",this);
00058 PositionMode_cmd->SetGuidance("Choose position model:");
00059 PositionMode_cmd->SetGuidance(" Choice : none(default), uniform");
00060 PositionMode_cmd->SetParameterName("choice",true);
00061 PositionMode_cmd->SetDefaultValue("none");
00062 PositionMode_cmd->SetCandidates("none uniform");
00063 PositionMode_cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00064
00065 EM_hist_filename_cmd = new G4UIcmdWithAString("/g4sim/gun/EM_hist_filename",this);
00066 EM_hist_filename_cmd->SetGuidance("Choose name of input file for histogram to generate momentum amplitude:");
00067 EM_hist_filename_cmd->SetGuidance(" default name: default_file_for_mom");
00068 EM_hist_filename_cmd->SetParameterName("name",true);
00069 EM_hist_filename_cmd->SetDefaultValue("default_file_for_mom");
00070 EM_hist_filename_cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00071
00072 EM_hist_histname_cmd = new G4UIcmdWithAString("/g4sim/gun/EM_hist_histname",this);
00073 EM_hist_histname_cmd->SetGuidance("Choose name of input hist for histogram to generate momentum amplitude:");
00074 EM_hist_histname_cmd->SetGuidance(" default name: default_hist_for_mom");
00075 EM_hist_histname_cmd->SetParameterName("name",true);
00076 EM_hist_histname_cmd->SetDefaultValue("default_hist_for_mom");
00077 EM_hist_histname_cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00078
00079 DM_hist_filename_cmd = new G4UIcmdWithAString("/g4sim/gun/DM_hist_filename",this);
00080 DM_hist_filename_cmd->SetGuidance("Choose name of input file for histogram to generate momentum direction (theta):");
00081 DM_hist_filename_cmd->SetGuidance(" default name: default_file_for_mom");
00082 DM_hist_filename_cmd->SetParameterName("name",true);
00083 DM_hist_filename_cmd->SetDefaultValue("default_file_for_mom");
00084 DM_hist_filename_cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00085
00086 DM_hist_histname_cmd = new G4UIcmdWithAString("/g4sim/gun/DM_hist_histname",this);
00087 DM_hist_histname_cmd->SetGuidance("Choose name of input hist for histogram to generate momentum direction (theta):");
00088 DM_hist_histname_cmd->SetGuidance(" default name: default_hist_for_mom");
00089 DM_hist_histname_cmd->SetParameterName("name",true);
00090 DM_hist_histname_cmd->SetDefaultValue("default_hist_for_mom");
00091 DM_hist_histname_cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00092
00093 root_filename_cmd = new G4UIcmdWithAString("/g4sim/gun/root_filename",this);
00094 root_filename_cmd->SetGuidance("root_filename");
00095 root_filename_cmd->SetParameterName("root_filename",false);
00096 root_filename_cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00097
00098 root_index_cmd = new G4UIcmdWithAnInteger("/g4sim/gun/root_index",this);
00099 root_index_cmd->SetGuidance("root_index");
00100 root_index_cmd->SetParameterName("root_index",false);
00101 root_index_cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00102
00103 histo_build_cmd = new G4UIcmdWithoutParameter("/g4sim/gun/histo_build",this);
00104 histo_build_cmd->SetGuidance("update histogram for momentum.");
00105 histo_build_cmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
00106 histo_build_cmd->SetGuidance("if you use energy model histo and changed input file.");
00107 histo_build_cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00108
00109 root_build_cmd = new G4UIcmdWithoutParameter("/g4sim/gun/root_build",this);
00110 root_build_cmd->SetGuidance("build TChain for root mode.");
00111 root_build_cmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
00112 root_build_cmd->SetGuidance("if you use energy model root and changed input file.");
00113 root_build_cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00114
00115
00116 }
00117
00118
00119
00120 PrimaryGeneratorMessenger::~PrimaryGeneratorMessenger()
00121 {
00122 delete InitializeCmd;
00123 delete ResetGenCmd;
00124 delete ReadCardCmd;
00125 delete EnergyMode_cmd;
00126 delete DirectionMode_cmd;
00127 delete PositionMode_cmd;
00128 delete EM_hist_filename_cmd;
00129 delete EM_hist_histname_cmd;
00130 delete DM_hist_filename_cmd;
00131 delete DM_hist_histname_cmd;
00132 delete root_filename_cmd;
00133 delete root_index_cmd;
00134 delete histo_build_cmd;
00135 delete root_build_cmd;
00136 delete gunDir;
00137 }
00138
00139
00140
00141 void PrimaryGeneratorMessenger::SetNewValue(
00142 G4UIcommand* command, G4String newValue)
00143 {
00144 if( command == EnergyMode_cmd ) { Action->set_EnergyMode(newValue);}
00145 if( command == DirectionMode_cmd ) { Action->set_DirectionMode(newValue);}
00146 if( command == PositionMode_cmd ) { Action->set_PositionMode(newValue);}
00147 if( command == root_filename_cmd ) { Action->set_root_filename(newValue);}
00148 if( command == root_index_cmd ) { Action->set_root_index(root_index_cmd->GetNewIntValue(newValue));}
00149 if( command == EM_hist_filename_cmd ) { Action->set_EM_hist_filename(newValue);}
00150 if( command == EM_hist_histname_cmd ) { Action->set_EM_hist_histname(newValue);}
00151 if( command == DM_hist_filename_cmd ) { Action->set_DM_hist_filename(newValue);}
00152 if( command == DM_hist_histname_cmd ) { Action->set_DM_hist_histname(newValue);}
00153 if( command == histo_build_cmd) { Action->BuildHistoFromFile();}
00154 if( command == root_build_cmd) { Action->root_build();}
00155 if( command == ResetGenCmd ) { Action->ResetGen(newValue); }
00156 if( command == ReadCardCmd ) { Action->ReadCard(newValue); }
00157 if( command == InitializeCmd ) { Action->Initialize(); }
00158 }
00159
00160
00161