QwGeant4
QweakSimPrimaryGeneratorActionMessenger.cc
Go to the documentation of this file.
1 //=============================================================================
2 //
3 // ---------------------------
4 // | Doxygen File Information |
5 // ---------------------------
6 //
7 /**
8 
9  \file QweakSimPrimaryGeneratorActionMessenger.cc
10 
11  $Revision: 1.3 $
12  $Date: 2006/05/05 21:33:44 $
13 
14  \author Klaus Hans Grimm
15 
16 */
17 //=============================================================================
18 
19 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
20 
22 
23 // user includes
26 
27 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
28 
30 :pPrimaryGeneratorAction(pPhys)
31 {
32  Xmin = -2.0*mm;
33  Xmax = 2.0*mm;
34  Ymin = -2.0*mm;
35  Ymax = 2.0*mm;
36 
37  Dir = new G4UIdirectory("/PrimaryEvent/");
38  Dir->SetGuidance("Primary event control");
39 
40  verboseCmd = new G4UIcmdWithAnInteger("/PrimaryEvent/verbose",this);
41  verboseCmd->SetGuidance("set verbose for primary generator");
42  verboseCmd->SetParameterName("verbose",true);
43  verboseCmd->SetDefaultValue(1);
44  verboseCmd->SetRange("verbose>=0");
45  verboseCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
46 
47  resetCmd = new G4UIcmdWithoutParameter("/PrimaryEvent/ResetNtupleEventCounter",this);
48  resetCmd->SetGuidance("resets Neven's Ntuple Event Counter");
49  //resetCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
50  resetCmd->AvailableForStates(G4State_Idle);
51 
52  SetParticleType_Cmd = new G4UIcmdWithAString("/PrimaryEvent/SetParticleType",this);
53  SetParticleType_Cmd->SetGuidance("set particle type for primary generator");
54  SetParticleType_Cmd->SetParameterName("type",true);
55  SetParticleType_Cmd->SetDefaultValue("e-");
56  SetParticleType_Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
57 
58  SetBeamParticleType_Cmd = new G4UIcmdWithAString("/PrimaryEvent/SetBeamParticleType",this);
59  SetBeamParticleType_Cmd->SetGuidance("set beam particle type for primary generator");
60  SetBeamParticleType_Cmd->SetParameterName("type",true);
61  SetBeamParticleType_Cmd->SetDefaultValue("e-");
62  SetBeamParticleType_Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
63 
64  SetScatteredParticleType_Cmd = new G4UIcmdWithAString("/PrimaryEvent/SetScatteredParticleType",this);
65  SetScatteredParticleType_Cmd->SetGuidance("set scattered particle type for primary generator");
66  SetScatteredParticleType_Cmd->SetParameterName("type",true);
67  SetScatteredParticleType_Cmd->SetDefaultValue("e-");
68  SetScatteredParticleType_Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
69 
70  SetPolarization_Cmd = new G4UIcmdWithAString("/PrimaryEvent/SetPolarization",this);
71  SetPolarization_Cmd->SetGuidance("set particle polarization for primary generator (L, H, V)");
72  SetPolarization_Cmd->SetParameterName("polarization",true);
73  SetPolarization_Cmd->SetDefaultValue("L");
74  SetPolarization_Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
75 
76  InitEventCounterCmd = new G4UIcmdWithAnInteger("/PrimaryEvent/StartingEvent",this);
77  InitEventCounterCmd->SetGuidance("set starting event count for primary generator");
78  InitEventCounterCmd->SetParameterName("StartingEvent",true);
79  InitEventCounterCmd->SetDefaultValue(1);
80  InitEventCounterCmd->SetRange("StartingEvent>=0");
81  InitEventCounterCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
82 
83 
84  SetPositionX_Cmd = new G4UIcmdWithADoubleAndUnit("/PrimaryEvent/SetBeamPositionX",this);
85  SetPositionX_Cmd->SetGuidance("Set beam position in x");
86  SetPositionX_Cmd->SetParameterName("x",true);
87  SetPositionX_Cmd->SetUnitCategory("Length");
88  SetPositionX_Cmd->SetDefaultValue(0.0*mm);
89  SetPositionX_Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
90 
91  SetPositionY_Cmd = new G4UIcmdWithADoubleAndUnit("/PrimaryEvent/SetBeamPositionY",this);
92  SetPositionY_Cmd->SetGuidance("Set beam position in y");
93  SetPositionY_Cmd->SetParameterName("y",true);
94  SetPositionY_Cmd->SetUnitCategory("Length");
95  SetPositionY_Cmd->SetDefaultValue(0.0*mm);
96  SetPositionY_Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
97 
98  SetPositionZ_Cmd = new G4UIcmdWithADoubleAndUnit("/PrimaryEvent/SetBeamPositionZ",this);
99  SetPositionZ_Cmd->SetGuidance("Set beam position in z");
100  SetPositionZ_Cmd->SetParameterName("z",true);
101  SetPositionZ_Cmd->SetUnitCategory("Length");
102  SetPositionZ_Cmd->SetDefaultValue(0.0*mm);
103  SetPositionZ_Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
104 
105  SetDirectionX_Cmd = new G4UIcmdWithADoubleAndUnit("/PrimaryEvent/SetBeamDirectionX",this);
106  SetDirectionX_Cmd->SetGuidance("Set beam direction in x");
107  SetDirectionX_Cmd->SetParameterName("x",true);
108  SetDirectionX_Cmd->SetUnitCategory("Angle");
109  SetDirectionX_Cmd->SetDefaultValue(0.0*mrad);
110  SetDirectionX_Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
111 
112  SetDirectionY_Cmd = new G4UIcmdWithADoubleAndUnit("/PrimaryEvent/SetBeamDirectionY",this);
113  SetDirectionY_Cmd->SetGuidance("Set beam direction in y");
114  SetDirectionY_Cmd->SetParameterName("y",true);
115  SetDirectionY_Cmd->SetUnitCategory("Angle");
116  SetDirectionY_Cmd->SetDefaultValue(0.0*mrad);
117  SetDirectionY_Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
118 
119 
120  SetRasterSize_Cmd = new G4UIcmdWithADoubleAndUnit("/PrimaryEvent/SetRasterSize",this);
121  SetRasterSize_Cmd->SetGuidance("Select full raster size for square raster.");
122  SetRasterSize_Cmd->SetGuidance("Example options:");
123  SetRasterSize_Cmd->SetGuidance("- 0 mm -> 0 mm x 0 mm");
124  SetRasterSize_Cmd->SetGuidance("- 1 mm -> 1 mm x 1 mm");
125  SetRasterSize_Cmd->SetGuidance("- 2 mm -> 2 mm x 2 mm");
126  SetRasterSize_Cmd->SetGuidance("- 3 mm -> 3 mm x 3 mm");
127  SetRasterSize_Cmd->SetGuidance("- 4 mm -> 4 mm x 4 mm");
128  SetRasterSize_Cmd->SetParameterName("size",true);
129  SetRasterSize_Cmd->SetDefaultValue(4.0*mm);
130  SetRasterSize_Cmd->SetUnitCategory("Length");
131  SetRasterSize_Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
132 
133  SetRasterXmin_Cmd = new G4UIcmdWithADoubleAndUnit("/PrimaryEvent/SetRasterXmin",this);
134  SetRasterXmin_Cmd->SetGuidance("Set beam rastering region (x min.)");
135  SetRasterXmin_Cmd->SetParameterName("Xmin",true);
136  SetRasterXmin_Cmd->SetUnitCategory("Length");
137  SetRasterXmin_Cmd->SetDefaultValue(Xmin);
138  SetRasterXmin_Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
139 
140  SetRasterXmax_Cmd = new G4UIcmdWithADoubleAndUnit("/PrimaryEvent/SetRasterXmax",this);
141  SetRasterXmax_Cmd->SetGuidance("Set beam rastering region (x max.)");
142  SetRasterXmax_Cmd->SetParameterName("Xmax",true);
143  SetRasterXmax_Cmd->SetUnitCategory("Length");
144  SetRasterXmax_Cmd->SetDefaultValue(Xmax);
145  SetRasterXmax_Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
146 
147  SetRasterYmin_Cmd = new G4UIcmdWithADoubleAndUnit("/PrimaryEvent/SetRasterYmin",this);
148  SetRasterYmin_Cmd->SetGuidance("Set beam rastering region (y min.)");
149  SetRasterYmin_Cmd->SetParameterName("Ymin",true);
150  SetRasterYmin_Cmd->SetUnitCategory("Length");
151  SetRasterYmin_Cmd->SetDefaultValue(Ymin);
152  SetRasterYmin_Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
153 
154  SetRasterYmax_Cmd = new G4UIcmdWithADoubleAndUnit("/PrimaryEvent/SetRasterYmax",this);
155  SetRasterYmax_Cmd->SetGuidance("Set beam rastering region (y max.)");
156  SetRasterYmax_Cmd->SetParameterName("Ymax",true);
157  SetRasterYmax_Cmd->SetUnitCategory("Length");
158  SetRasterYmax_Cmd->SetDefaultValue(Ymax);
159  SetRasterYmax_Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
160 
161 }
162 
163 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
164 
166 {
167  delete SetRasterSize_Cmd;
168  delete SetRasterXmin_Cmd;
169  delete SetRasterXmax_Cmd;
170  delete SetRasterYmin_Cmd;
171  delete SetRasterYmax_Cmd;
172  delete InitEventCounterCmd;
173  delete SetParticleType_Cmd;
176  delete SetPolarization_Cmd;
177  delete verboseCmd;
178  delete resetCmd;
179  delete Dir;
180 }
181 
182 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
183 
184 void QweakSimPrimaryGeneratorActionMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
185 {
186  //if( command == verboseCmd )
187  //{ pPrimaryGeneratorAction->SetVerbose(verboseCmd->GetNewIntValue(newValue));}
188 
189  if( command == resetCmd )
191 
192  if( command == InitEventCounterCmd )
193  { pPrimaryGeneratorAction->SetNtupleEventCounter(InitEventCounterCmd->GetNewIntValue(newValue)); }
194 
195  if( command == SetParticleType_Cmd )
197 
198  if( command == SetBeamParticleType_Cmd )
200 
201  if( command == SetScatteredParticleType_Cmd )
203 
204  if( command == SetPolarization_Cmd )
206 
207  if( command == SetPositionX_Cmd )
208  {
209  G4cout << "#### Messenger: Setting Beam Position in X to " << newValue << G4endl;
210  G4double x = SetPositionX_Cmd->GetNewDoubleValue(newValue);
212  }
213  if( command == SetPositionY_Cmd )
214  {
215  G4cout << "#### Messenger: Setting Beam Position in Y to " << newValue << G4endl;
216  G4double y = SetPositionY_Cmd->GetNewDoubleValue(newValue);
218  }
219  if( command == SetPositionZ_Cmd )
220  {
221  G4cout << "#### Messenger: Setting Beam Position in Z to " << newValue << G4endl;
222  G4double z = SetPositionZ_Cmd->GetNewDoubleValue(newValue);
224  }
225  if( command == SetDirectionX_Cmd )
226  {
227  G4cout << "#### Messenger: Setting Beam Direction in X to " << newValue << G4endl;
228  G4double x = SetPositionX_Cmd->GetNewDoubleValue(newValue);
230  }
231  if( command == SetDirectionY_Cmd )
232  {
233  G4cout << "#### Messenger: Setting Beam Direction in Y to " << newValue << G4endl;
234  G4double y = SetPositionX_Cmd->GetNewDoubleValue(newValue);
236  }
237 
238 
239  if( command == SetRasterSize_Cmd )
240  {
241  G4double size = SetRasterSize_Cmd->GetNewDoubleValue(newValue);
242  G4cout << "#### Messenger: Setting Raster size to " << size/mm << " mm x " << size/mm << " mm." << G4endl;
243  pPrimaryGeneratorAction->SetBeamRasteringRegion(size, size, size, size);
244  }
245  if( command == SetRasterXmin_Cmd )
246  {
247  Xmin = SetRasterXmin_Cmd->GetNewDoubleValue(newValue);
248  G4cout << "#### Messenger: Setting Raster min. X to " << Xmin/mm << " mm." << G4endl;
250  }
251  if( command == SetRasterXmax_Cmd )
252  {
253  Xmax = SetRasterXmax_Cmd->GetNewDoubleValue(newValue);
254  G4cout << "#### Messenger: Setting Raster max. X to " << Xmax/mm << " mm." << G4endl;
256  }
257  if( command == SetRasterYmin_Cmd )
258  {
259  Ymin = SetRasterYmin_Cmd->GetNewDoubleValue(newValue);
260  G4cout << "#### Messenger: Setting Raster min. Y to " << Ymin/mm << " mm." << G4endl;
262  }
263  if( command == SetRasterYmax_Cmd )
264  {
265  Ymax = SetRasterYmax_Cmd->GetNewDoubleValue(newValue);
266  G4cout << "#### Messenger: Setting Raster max. Y to " << Ymax/mm << " mm." << G4endl;
268  }
269 
270 }
271 
272 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
273 
QweakSimUserInformation * GetUserInfo() const
Deal with primary particle generation and inject it in the detector.
void SetBeamRasteringRegion(G4double X_min=-2.0 *mm, G4double X_max=2.0 *mm, G4double Y_min=-2.0 *mm, G4double Y_max=2.0 *mm)
QweakSimPrimaryGeneratorActionMessenger(QweakSimPrimaryGeneratorAction *)