ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PrimaryGeneratorMessenger.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PrimaryGeneratorMessenger.cc
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
29 //
30 
31 //---------------------------------------------------------------------------
32 //
33 // ClassName: PrimaryGeneratorMessenger
34 //
35 // Description: Definition of physics list parameters
36 //
37 // Author: V.Ivanchenko 26/09/00
38 //
39 //----------------------------------------------------------------------------
40 //
41 
42 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
43 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
44 
45 #include "PrimaryGeneratorMessenger.hh"
46 #include "PrimaryGeneratorAction.hh"
47 #include "G4RunManager.hh"
48 #include "Run.hh"
49 #include "G4UImanager.hh"
50 
51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
52 
55  fGen(gen)
56 {
57  fVerbose = gen->GetVerbose();
58  if(fVerbose) G4cout << "PrimaryGeneratorMessenger: Construct " << G4endl;
59 
60  fBeamXCmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/beamX",this);
61  fBeamXCmd->SetGuidance("Set X position of the center of the beam.");
62  fBeamXCmd->SetParameterName("beamX",true);
63  fBeamXCmd->SetUnitCategory("Length");
65 
66  fBeamYCmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/beamY",this);
67  fBeamYCmd->SetGuidance("Set Y position of the center of the beam.");
68  fBeamYCmd->SetParameterName("beamY",true);
69  fBeamYCmd->SetUnitCategory("Length");
71 
72  fBeamZCmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/beamZ",this);
73  fBeamZCmd->SetGuidance("Set Z of the entry point of the beam.");
74  fBeamZCmd->SetParameterName("beamZ",true);
75  fBeamZCmd->SetUnitCategory("Length");
77 
78  fBeamECmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/beamE",this);
79  fBeamECmd->SetGuidance("Set the beam kinetic energy");
80  fBeamECmd->SetParameterName("beamE",false);
81  fBeamECmd->SetUnitCategory("Energy");
83 
84  fSigmaXCmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/sigmaX",this);
85  fSigmaXCmd->SetGuidance("Set the beam Gussian width for X");
86  fSigmaXCmd->SetParameterName("sigmaX",false);
87  fSigmaXCmd->SetUnitCategory("Length");
89 
90  fSigmaYCmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/sigmaY",this);
91  fSigmaYCmd->SetGuidance("Set the beam Gussian width for Y");
92  fSigmaYCmd->SetParameterName("sigmaY",false);
93  fSigmaYCmd->SetUnitCategory("Length");
95 
96  fSigmaZCmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/sigmaZ",this);
97  fSigmaZCmd->SetGuidance("Set the beam Gussian width for Y");
98  fSigmaZCmd->SetParameterName("sigmaZ",false);
99  fSigmaZCmd->SetUnitCategory("Length");
101 
102  fSigmaECmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/sigmaE",this);
103  fSigmaECmd->SetGuidance("Set the beam Gussian width for energy");
104  fSigmaECmd->SetParameterName("sigmaE",false);
105  fSigmaECmd->SetUnitCategory("Energy");
107 
108  fRandCmd = new G4UIcmdWithAString("/testem/gun",this);
109  fRandCmd->SetGuidance("Set the name of the random distribution (gauss,flat)");
110  fRandCmd->SetParameterName("rand",false);
112 
113  fMaxThetaCmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/maxTheta",this);
114  fMaxThetaCmd->SetGuidance("Set the beam maxTheta in degrees.");
115  fMaxThetaCmd->SetParameterName("maxTheta",false);
116  fMaxThetaCmd->SetUnitCategory("Angle");
118 
119  fThetaCmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/sigmaTheta",this);
120  fThetaCmd->SetGuidance("Set the beam sigmaTheta in degrees.");
121  fThetaCmd->SetParameterName("sigmaTheta",false);
122  fThetaCmd->SetUnitCategory("Angle");
124 }
125 
126 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
127 
129 {
130  delete fBeamXCmd;
131  delete fBeamYCmd;
132  delete fBeamZCmd;
133 
134  delete fSigmaXCmd;
135  delete fSigmaYCmd;
136  delete fSigmaZCmd;
137  delete fSigmaECmd;
138 
139  delete fBeamECmd;
140  delete fRandCmd;
141  delete fMaxThetaCmd;
142  delete fThetaCmd;
143 }
144 
145 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
146 
148  G4String newValue)
149 {
150  if(fVerbose)
151  G4cout << "PrimaryGeneratorMessenger: Next command value = "
152  << newValue << G4endl;
153 
154  if(command == fBeamXCmd)
155  {fGen->SetBeamX(fBeamXCmd->GetNewDoubleValue(newValue));}
156  if(command == fBeamYCmd)
157  {fGen->SetBeamY(fBeamYCmd->GetNewDoubleValue(newValue));}
158  if(command == fBeamZCmd)
159  {fGen->SetBeamZ(fBeamZCmd->GetNewDoubleValue(newValue));}
160  if(command == fSigmaXCmd)
162  if(command == fSigmaYCmd)
164  if(command == fSigmaZCmd)
166  if(command == fSigmaECmd)
168  if(command == fBeamECmd) {
169  G4double e = fBeamECmd->GetNewDoubleValue(newValue);
170  fGen->SetBeamEnergy(e);
171  }
172  if(command == fMaxThetaCmd)
174  std::cos(fMaxThetaCmd->GetNewDoubleValue(newValue)));}
175  if(command == fThetaCmd)
177  if(command == fRandCmd)
178  {fGen->SetRandom(newValue);}
179 
180 
181  if(fVerbose) G4cout << "PrimaryGeneratorMessenger: O'K " << G4endl;
182  }
183 
184 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
185