BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
BesPrimaryGeneratorMessenger.cc
Go to the documentation of this file.
1//---------------------------------------------------------------------------//
2// BOOST --- BESIII Object_Oriented Simulation Tool //
3//---------------------------------------------------------------------------//
4// Description: passing parameters to Generator TESTER and GENBES
5// Author: Liuhm
6// Created: Jun. 5, 2003
7// Modified:
8// Comment:
9//---------------------------------------------------------------------------//
10
11#include "GenSim/BesPrimaryGeneratorMessenger.hh"
12#include "G4ParticleTable.hh"
13#include "G4UIcmdWithAString.hh"
14#include "G4UIcommand.hh"
15#include "G4UIdirectory.hh"
16#include "G4ios.hh"
17#include "GenSim/BesPrimaryGeneratorAction.hh"
18
20 : myAction( mpga ) {
21 G4UIparameter* parameter;
22 G4bool omittable;
23 particleTable = G4ParticleTable::GetParticleTable();
24
25 generatorDirectory = new G4UIdirectory( "/generator/" );
26 generatorDirectory->SetGuidance( "BESIII event gnerator" );
27
28 gennamCmd = new G4UIcmdWithAString( "/generator/name", this );
29 gennamCmd->SetGuidance( "Select your event gerator: genbes or tester" );
30 gennamCmd->SetGuidance( "The default generator is tester" );
31 gennamCmd->SetParameterName( "name", true );
32 gennamCmd->SetDefaultValue( "tester" );
33 gennamCmd->SetCandidates( "tester cosmic genbes" );
34
35 genbesCmd = new G4UIcmdWithAString( "/generator/genbes", this );
36 genbesCmd->SetGuidance( "The BES data file" );
37 genbesCmd->SetGuidance( "directory/filename" );
38 genbesCmd->SetParameterName( "name", false );
39
40 testerCmd = new G4UIcommand( "/generator/tester", this );
41 testerCmd->SetGuidance( "The BES TESTER generator" );
42 testerCmd->SetGuidance( "NP PID Cosmin Cosmax phimin phimax p delp" );
43
44 cosmicCmd = new G4UIcommand( "/generator/cosmic", this );
45 cosmicCmd->SetGuidance( "The cosmic generator" );
46 cosmicCmd->SetGuidance( "PID x y z" );
47
48 parameter = new G4UIparameter( "np", 'i', omittable = true );
49 parameter->SetGuidance( "Number of particles in an event" );
50 parameter->SetParameterRange( "np > 0" );
51 parameter->SetDefaultValue( 1 );
52 testerCmd->SetParameter( parameter );
53
54 parameter = new G4UIparameter( "pname", 's', omittable = true );
55 parameter->SetGuidance( "Particle name in Geant4" );
56 parameter->SetDefaultValue( "pi-" );
57 G4String candidatelist;
58 G4int nPtable = particleTable->entries();
59 for ( G4int i = 0; i < nPtable; i++ )
60 {
61 candidatelist += particleTable->GetParticleName( i );
62 candidatelist += " ";
63 }
64 parameter->SetParameterCandidates( candidatelist );
65 testerCmd->SetParameter( parameter );
66
67 parameter = new G4UIparameter( "cosmin", 'd', omittable = true );
68 parameter->SetGuidance( "Minimum cos(theta)" );
69 parameter->SetParameterRange( "cosmin >= -1. && cosmin <= 1." );
70 parameter->SetDefaultValue( -0.8 );
71 testerCmd->SetParameter( parameter );
72
73 parameter = new G4UIparameter( "cosmax", 'd', omittable = true );
74 parameter->SetGuidance( "Maximum cos(theta)" );
75 parameter->SetParameterRange( "cosmax >= -1. && cosmax <= 1." );
76 parameter->SetDefaultValue( 0.8 );
77 testerCmd->SetParameter( parameter );
78
79 parameter = new G4UIparameter( "phimin", 'd', omittable = true );
80 parameter->SetGuidance( "Minimum azimuthal angle in degree" );
81 parameter->SetParameterRange( "phimin >= 0. && phimin <= 360." );
82 parameter->SetDefaultValue( 0. );
83 testerCmd->SetParameter( parameter );
84
85 parameter = new G4UIparameter( "phimax", 'd', omittable = true );
86 parameter->SetGuidance( "Maximum azimuthal angle in degree" );
87 parameter->SetParameterRange( "phimax >= 0. && phimax <= 360." );
88 parameter->SetDefaultValue( 360. );
89 testerCmd->SetParameter( parameter );
90
91 parameter = new G4UIparameter( "pp", 'd', omittable = true );
92 parameter->SetGuidance( "Particle Momentum in GeV" );
93 parameter->SetParameterRange( "pp>=0." );
94 parameter->SetDefaultValue( 1.0 );
95 testerCmd->SetParameter( parameter );
96
97 parameter = new G4UIparameter( "dp", 'd', omittable = true );
98 parameter->SetGuidance( "Particle Momentum range in GeV" );
99 parameter->SetParameterRange( "dp>=0." );
100 parameter->SetDefaultValue( 0.0 );
101 testerCmd->SetParameter( parameter );
102
103 parameter = new G4UIparameter( "x", 'd', omittable = true );
104 parameter->SetGuidance( "Particle x position" );
105 parameter->SetParameterRange( "x >= -10000 && x <= 10000" );
106 parameter->SetDefaultValue( 0. );
107 testerCmd->SetParameter( parameter );
108
109 parameter = new G4UIparameter( "y", 'd', omittable = true );
110 parameter->SetGuidance( "Particle y position" );
111 parameter->SetParameterRange( "y >= -10000 && y <= 10000" );
112 parameter->SetDefaultValue( 0. );
113 testerCmd->SetParameter( parameter );
114
115 parameter = new G4UIparameter( "z", 'd', omittable = true );
116 parameter->SetGuidance( "Particle z position" );
117 parameter->SetParameterRange( "z >= -10000 && z <= 10000" );
118 parameter->SetDefaultValue( 0. );
119 testerCmd->SetParameter( parameter );
120
121 parameter = new G4UIparameter( "pname", 's', omittable = true );
122 parameter->SetGuidance( "Particle name in Geant4" );
123 parameter->SetDefaultValue( "mu-" );
124 cosmicCmd->SetParameter( parameter );
125
126 parameter = new G4UIparameter( "x", 'd', omittable = true );
127 parameter->SetGuidance( "Particle x position" );
128 parameter->SetParameterRange( "x >= -10000 && x <= 10000" );
129 parameter->SetDefaultValue( 0. );
130 cosmicCmd->SetParameter( parameter );
131
132 parameter = new G4UIparameter( "y", 'd', omittable = true );
133 parameter->SetGuidance( "Particle y position" );
134 parameter->SetParameterRange( "y >= -10000 && y <= 10000" );
135 parameter->SetDefaultValue( 0. );
136 cosmicCmd->SetParameter( parameter );
137
138 parameter = new G4UIparameter( "z", 'd', omittable = true );
139 parameter->SetGuidance( "Particle z position" );
140 parameter->SetParameterRange( "z >= -10000 && z <= 10000" );
141 parameter->SetDefaultValue( 0. );
142 cosmicCmd->SetParameter( parameter );
143}
144
146 delete generatorDirectory;
147 delete gennamCmd;
148 delete genbesCmd;
149 delete testerCmd;
150 delete cosmicCmd;
151}
152
153void BesPrimaryGeneratorMessenger::SetNewValue( G4UIcommand* command, G4String newValue ) {
154 if ( command == gennamCmd ) { myAction->SetGeneratorName( newValue ); }
155 else if ( command == genbesCmd ) { myAction->SetGenbesName( newValue ); }
156 else if ( command == testerCmd )
157 {
158 G4int np1;
159 G4String pname1;
160 G4double cosmin1, cosmax1, phimin1, phimax1, pp1, dp1, x, y, z;
161 std::istringstream is( (char*)newValue.data() );
162 is >> np1 >> pname1 >> cosmin1 >> cosmax1 >> phimin1 >> phimax1 >> pp1 >> dp1 >> x >> y >>
163 z;
164
165 myAction->SetNParticle( np1 );
166 myAction->SetParticleName( pname1 );
167 myAction->SetMinCos( cosmin1 );
168 myAction->SetMaxCos( cosmax1 );
169 myAction->SetPhiStart( phimin1 );
170 myAction->SetPhiEnd( phimax1 );
171 myAction->SetMomentum( pp1 );
172 myAction->SetDeltaP( dp1 );
173 myAction->SetPosX( x );
174 myAction->SetPosY( y );
175 myAction->SetPosZ( z );
176 }
177 else if ( command == cosmicCmd )
178 {
179 G4String pname;
180 G4double x, y, z;
181 std::istringstream is( (char*)newValue.data() );
182 is >> pname >> x >> y >> z;
183 myAction->SetParticleName( pname );
184 myAction->SetPosX( x );
185 myAction->SetPosY( y );
186 myAction->SetPosZ( z );
187 }
188}
189
190G4String BesPrimaryGeneratorMessenger::GetCurrentValue( G4UIcommand* command ) {
191 G4String cv;
192 if ( command == gennamCmd ) { cv = myAction->GetGeneratorName(); }
193 else if ( command == genbesCmd ) { cv = myAction->GetGenbesName(); }
194 return cv;
195}
G4String GetCurrentValue(G4UIcommand *command)
void SetNewValue(G4UIcommand *command, G4String newValues)
BesPrimaryGeneratorMessenger(BesPrimaryGeneratorAction *mpga)