Geant4  10.01.p01
G4MoleculeGunMessenger.cc
Go to the documentation of this file.
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 /*
27  * MoleculeGunMessenger.cc
28  *
29  * Created on: 30 janv. 2014
30  * Author: kara
31  */
32 
34 #include "G4MoleculeGun.hh"
35 
36 #include "G4Tokenizer.hh"
37 
38 #include "G4UIdirectory.hh"
39 #include "G4UIcmdWithAString.hh"
40 #include "G4UIcmdWithAString.hh"
43 #include "G4UIcmdWithAnInteger.hh"
44 #include "G4UIdirectory.hh"
45 
47 {
48  fpGunDir = new G4UIdirectory("/process/em/dna/chem/gun/");
49  fpGunNewGunType = new G4UIcmdWithAString("/process/em/dna/chem/gun/newType",
50  this);
51 }
52 
54 {
55  if (fpGunDir) delete fpGunDir;
56  if (fpGunNewGunType) delete fpGunNewGunType;
57 }
58 
60 {
61  return "";
62 }
63 
65 {
66  MultipleGun* multiGun = new MultipleGun(name, this);
67  fMultipleGun.push_back(multiGun);
68  return multiGun;
69 }
70 
72  G4String newValue)
73 {
74  if (command == fpGunNewGunType)
75  {
76  CreateNewType(newValue);
77  }
78 }
79 
82 {
83  G4String dir("/process/em/dna/chem/gun/");
84  dir += name;
85  fpGunType = new G4UIdirectory(name);
86 
87  G4String tmp = dir;
88  tmp += "/moleculeModel";
89  fpGunMoleculeModel = new G4UIcmdWithAString(tmp, this);
90  tmp = dir;
91  tmp += "/position";
93  tmp = dir;
94  tmp += "/time";
95  fpGunTime = new G4UIcmdWithADoubleAndUnit(tmp, this);
96  tmp = dir;
97  tmp += "/number";
98  fpGunN = new G4UIcmdWithAnInteger(tmp, this);
99 
100  fMoleculeName = "";
101  fTime = 0;
102  fNumber = 0;
103 }
104 
106 {
107  if (fpGunMoleculeModel) delete fpGunMoleculeModel;
108  if (fpGunPosition) delete fpGunPosition;
109  if (fpGunTime) delete fpGunTime;
110  if (fpGunN) delete fpGunN;
111 }
112 
114  G4String newValue)
115 {
116 
117  if (command == fpGunMoleculeModel)
118  {
119  fMoleculeName = newValue;
120  }
121  else if (command == fpGunPosition)
122  {
123  fPosition = fpGunPosition->GetNew3VectorValue(newValue);
124  }
125  else if (command == fpGunTime)
126  {
127  fTime = fpGunTime->GetNewDoubleValue(newValue);
128  }
129  else if (command == fpGunN)
130  {
131  fNumber = fpGunN->GetNewIntValue(newValue);
132  }
133 }
134 
136 {
137 
138  if (command == fpGunMoleculeModel)
139  {
140  return fMoleculeName;
141  }
142  else if (command == fpGunPosition)
143  {
144  return fpGunPosition->ConvertToStringWithBestUnit(fPosition);
145  }
146  else if (command == fpGunTime)
147  {
148  return fpGunTime->ConvertToStringWithBestUnit(fTime);
149  }
150  else if (command == fpGunN)
151  {
152  return fpGunN->ConvertToString(fNumber);
153  }
154  return "";
155 }
156 
158 {
159  for (size_t i = 0; i < fMultipleGun.size(); i++)
160  {
161  fMultipleGun[i]->DefineTracks(gun);
162  }
163 }
164 
166 {
167  gun->AddNMolecules(fNumber, fMoleculeName, fPosition, fTime);
168 }
virtual G4String GetCurrentValue(G4UIcommand *command)
G4String name
Definition: TRTMaterials.hh:40
void DefineTracks(G4MoleculeGun *)
virtual void SetNewValue(G4UIcommand *command, G4String newValue)
MultipleGun * CreateNewType(const G4String &name)
virtual void SetNewValue(G4UIcommand *command, G4String newValue)
virtual G4String GetCurrentValue(G4UIcommand *command)
MultipleGun(const G4String &name, G4MoleculeGunMessenger *)
G4UIcmdWith3VectorAndUnit * fpGunPosition
void AddNMolecules(size_t n, const G4String &name, const G4ThreeVector &position, double time=0)
std::vector< MultipleGun * > fMultipleGun
G4UIcmdWithAString * fpGunNewGunType