File indexing completed on 2024-09-27 07:02:49
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include "eASTPrimGenActionMessenger.hh"
0012
0013 #include "eASTPrimaryGeneratorAction.hh"
0014 #include "G4UIcommand.hh"
0015 #include "G4UIparameter.hh"
0016 #include "G4UnitsTable.hh"
0017
0018 eASTPrimGenActionMessenger::eASTPrimGenActionMessenger(eASTPrimaryGeneratorAction* pg)
0019 : pPG(pg)
0020 {
0021 G4UIparameter* para = nullptr;
0022
0023
0024
0025 setTimeCmd = new G4UIcommand("/eAST/generator/setTime",this);
0026 setTimeCmd->SetGuidance("Set the start time of each event");
0027 setTimeCmd->SetGuidance(" t = deltaT * eventID + T0");
0028 para = new G4UIparameter("deltaT",'d',false);
0029 setTimeCmd->SetParameter(para);
0030 para = new G4UIparameter("T0",'d',false);
0031 setTimeCmd->SetParameter(para);
0032 para = new G4UIparameter("unit",'s',true);
0033 para->SetDefaultUnit("microsecond");
0034 setTimeCmd->SetParameter(para);
0035 setTimeCmd->AvailableForStates(G4State_Init,G4State_Idle);
0036 }
0037
0038 eASTPrimGenActionMessenger::~eASTPrimGenActionMessenger()
0039 {
0040 delete setTimeCmd;
0041 }
0042
0043 #include "G4Tokenizer.hh"
0044
0045 void eASTPrimGenActionMessenger::SetNewValue(G4UIcommand* cmd, G4String val)
0046 {
0047 if(cmd==setTimeCmd)
0048 {
0049 G4Tokenizer next(val);
0050 G4double deltaT = StoD(next());
0051 G4double T0 = StoD(next());
0052 G4double uVal = G4UIcommand::ValueOf(next());
0053 pPG->SetT(deltaT*uVal,T0*uVal);
0054 }
0055 }
0056
0057 G4String eASTPrimGenActionMessenger::GetCurrentValue(G4UIcommand* cmd)
0058 {
0059 G4String val("");
0060 if(cmd==setTimeCmd)
0061 {
0062 G4double deltaT = 0.;
0063 G4double T0 = 0.;
0064 pPG->GetT(deltaT,T0);
0065 std::ostringstream os;
0066 os << "deltaT = " << G4BestUnit(deltaT,"Time") << " T0 = " << G4BestUnit(T0,"Time");
0067 val += os.str();
0068 }
0069 return val;
0070 }
0071
0072