EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
eASTPrimGenActionMessenger.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file eASTPrimGenActionMessenger.cc
1 // ********************************************************************
2 //
3 // eASTPrimGenActionMessenger.cc
4 // messenger class that sets primary vertex parameters
5 //
6 // History
7 // Dec 28th, 2021 : first implementation - M. Asai (JLab)
8 //
9 // ********************************************************************
10 
12 
14 #include "G4UIcommand.hh"
15 #include "G4UIparameter.hh"
16 #include "G4UnitsTable.hh"
17 
19 : pPG(pg)
20 {
21  G4UIparameter* para = nullptr;
22 
23  // note: /eAST/generator/ directory has already been created
24 
25  setTimeCmd = new G4UIcommand("/eAST/generator/setTime",this);
26  setTimeCmd->SetGuidance("Set the start time of each event");
27  setTimeCmd->SetGuidance(" t = deltaT * eventID + T0");
28  para = new G4UIparameter("deltaT",'d',false);
29  setTimeCmd->SetParameter(para);
30  para = new G4UIparameter("T0",'d',false);
31  setTimeCmd->SetParameter(para);
32  para = new G4UIparameter("unit",'s',true);
33  para->SetDefaultUnit("microsecond");
34  setTimeCmd->SetParameter(para);
35  setTimeCmd->AvailableForStates(G4State_Init,G4State_Idle);
36 }
37 
39 {
40  delete setTimeCmd;
41 }
42 
43 #include "G4Tokenizer.hh"
44 
45 void eASTPrimGenActionMessenger::SetNewValue(G4UIcommand* cmd, G4String val)
46 {
47  if(cmd==setTimeCmd)
48  {
49  G4Tokenizer next(val);
50  G4double deltaT = StoD(next());
51  G4double T0 = StoD(next());
52  G4double uVal = G4UIcommand::ValueOf(next());
53  pPG->SetT(deltaT*uVal,T0*uVal);
54  }
55 }
56 
58 {
59  G4String val("");
60  if(cmd==setTimeCmd)
61  {
62  G4double deltaT = 0.;
63  G4double T0 = 0.;
64  pPG->GetT(deltaT,T0);
65  std::ostringstream os;
66  os << "deltaT = " << G4BestUnit(deltaT,"Time") << " T0 = " << G4BestUnit(T0,"Time");
67  val += os.str();
68  }
69  return val;
70 }
71 
72