EDepSimSpillTimeFactory.cc
Go to the documentation of this file.
1 #include <sstream>
2 
3 #include <globals.hh>
4 
5 #include <EDepSimLog.hh>
6 
10 
13  : EDepSim::VTimeFactory("spill",parent),
14  fSpillTime(100*ns),
15  fBunchSeparation(582*ns),
16  fBunchLength(12.4*ns) {
17 
18  fSpillTimeCMD = new G4UIcmdWithADoubleAndUnit(CommandName("start"),this);
19  fSpillTimeCMD->SetGuidance("Set the start time of the spill.");
20  fSpillTimeCMD->SetParameterName("time",false);
21  fSpillTimeCMD->SetUnitCategory("Time");
22 
23  fBunchSepCMD = new G4UIcmdWithADoubleAndUnit(CommandName("bunchSep"),this);
24  fBunchSepCMD->SetGuidance("Set the time between bunch starts.");
25  fBunchSepCMD->SetParameterName("time",false);
26  fBunchSepCMD->SetUnitCategory("Time");
27 
28  fBunchLengthCMD = new G4UIcmdWithADoubleAndUnit(CommandName("bunchLength"),
29  this);
30  fBunchLengthCMD->SetGuidance("Set the length of a bunch.");
31  fBunchLengthCMD->SetParameterName("time",false);
32  fBunchLengthCMD->SetUnitCategory("Time");
33 
34  fBunchCountCMD = new G4UIcmdWithAnInteger(CommandName("bunchCount"),
35  this);
36  fBunchCountCMD->SetGuidance("Set the number of bunchs in a spill. "
37  "Reset bunch power to default.");
38  fBunchCountCMD->SetParameterName("count",false);
39 
40  fBunchPowerCMD = new G4UIcommand(CommandName("bunchPower"),this);
41  fBunchPowerCMD->SetGuidance("Set the power in a bunch "
42  "(bunchs are numbered from ONE)");
43  G4UIparameter* bunchPar = new G4UIparameter('i');
44  bunchPar->SetParameterName("bunch");
45  fBunchPowerCMD->SetParameter(bunchPar);
46  G4UIparameter* powerPar = new G4UIparameter('d');
47  powerPar->SetParameterName("power");
48  fBunchPowerCMD->SetParameter(powerPar);
49 
50  //Initialize the bunchs
51  SetBunchCount(6);
52 
53 }
54 
56  delete fSpillTimeCMD;
57  delete fBunchSepCMD;
58  delete fBunchLengthCMD;
59  delete fBunchCountCMD;
60  delete fBunchPowerCMD;
61 }
62 
64  G4String newValue) {
65  if (command == fSpillTimeCMD) {
66  SetSpillTime(fSpillTimeCMD->GetNewDoubleValue(newValue));
67  }
68  else if (command == fBunchSepCMD) {
69  SetBunchSeparation(fBunchSepCMD->GetNewDoubleValue(newValue));
70  }
71  else if (command == fBunchLengthCMD) {
72  SetBunchLength(fBunchLengthCMD->GetNewDoubleValue(newValue));
73  }
74  else if (command == fBunchCountCMD) {
75  SetBunchCount(fBunchCountCMD->GetNewIntValue(newValue));
76  }
77  else if (command == fBunchPowerCMD) {
78  std::istringstream input((char*)newValue.c_str());
79  int bunch;
80  double power;
81  input >> bunch >> power;
82  SetBunchPower(bunch,power);
83  }
84 }
85 
89  return time;
90 }
91 
93  fBunchPower.resize(bunchs);
95  b != fBunchPower.end();
96  ++b) {
97  *b = 1.0;
98  }
99 }
100 
101 void EDepSim::SpillTimeFactory::SetBunchPower(int bunch, double power) {
102  if (bunch<1 || (unsigned) bunch > fBunchPower.size()) {
103  EDepSimError("Illegal bunch number: " << bunch);
104  EDepSimError("Invalid bunch structure");
105  }
106  fBunchPower[bunch-1] = power;
107 }
intermediate_table::iterator iterator
SpillTimeFactory(EDepSim::UserPrimaryGeneratorMessenger *parent)
int command
EDepSim::VTimeGenerator * GetGenerator()
G4UIcmdWithAnInteger * fBunchCountCMD
double fBunchSeparation
The bunch separation.
G4UIcmdWithADoubleAndUnit * fBunchSepCMD
void SetNewValue(G4UIcommand *, G4String)
Handle messages from the UI processor.
void SetSpillTime(double spillTime)
static int input(void)
Definition: code.cpp:15695
Construct a module from components.
Definition: TG4HitSegment.h:10
G4UIcmdWithADoubleAndUnit * fSpillTimeCMD
G4String CommandName(G4String cmd)
Build a command name with the directory prefix.
G4UIcmdWithADoubleAndUnit * fBunchLengthCMD
#define EDepSimError(outStream)
Definition: EDepSimLog.hh:503
void SetBunchCount(int bunchs)
Set the number of bunchs (and reset the bunch power) in a spill.
static bool * b
Definition: config.cpp:1043
void SetBunchPower(int bunch, double power)
double fSpillTime
The start time of the spill.
std::vector< double > fBunchPower
The power in each bunch.
QAsciiDict< Entry > ns
def parent(G, child, parent_type)
Definition: graph.py:67
double fBunchLength
The bunch length.