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p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  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 
 33 #include "G4MoleculeGunMessenger.hh"
 34 
 35 #include "G4MoleculeGun.hh"
 36 #include "G4Tokenizer.hh"
 37 #include "G4UIcmdWith3VectorAndUnit.hh"
 38 #include "G4UIcmdWithADoubleAndUnit.hh"
 39 #include "G4UIcmdWithAString.hh"
 40 #include "G4UIcmdWithAnInteger.hh"
 41 #include "G4UIdirectory.hh"
 42 
 43 //------------------------------------------------------------------------------
 44 
 45 G4MoleculeGunMessenger::G4MoleculeGunMessenger(G4MoleculeGun* gun) :
 46   G4UImessenger("/chem/gun/", "")
 47 {
 48   fpGunNewGunType = new G4UIcmdWithAString("/chem/gun/newShoot",
 49                                            this);
 50   fpMoleculeGun = gun;
 51 }
 52 
 53 //------------------------------------------------------------------------------
 54 
 55 G4MoleculeGunMessenger::~G4MoleculeGunMessenger()
 56 {
 57   delete fpGunNewGunType;
 58 }
 59 
 60 //------------------------------------------------------------------------------
 61 
 62 G4String G4MoleculeGunMessenger::GetCurrentValue(G4UIcommand* /*command*/)
 63 {
 64   return "";
 65 }
 66 
 67 //------------------------------------------------------------------------------
 68 
 69 void G4MoleculeGunMessenger::SetNewValue(G4UIcommand* command,
 70                                          G4String newValue)
 71 {
 72   if (command == fpGunNewGunType)
 73   {
 74     std::istringstream iss (newValue);
 75     
 76     G4String shootName;
 77     iss >> shootName;
 78     
 79     G4String shootType;
 80     iss >> shootType;
 81         
 82     if(shootType.empty() || shootType.empty())
 83     {
 84       CreateNewType<G4Track>(shootName);
 85     }
 86     else
 87     {      
 88       CreateNewType<G4ContinuousMedium>(shootName);
 89     }
 90   }
 91 }
 92 
 93 //------------------------------------------------------------------------------
 94 
 95 G4MoleculeShootMessenger::G4MoleculeShootMessenger(const G4String& name,
 96                                                    G4MoleculeGunMessenger*,
 97                                                    G4shared_ptr<G4MoleculeShoot> shoot)
 98   : fpShoot(std::move(shoot))
 99 {
100   G4String dir("/chem/gun/");
101   dir += name;
102   CreateDirectory(dir, "");
103 
104   G4String tmp = dir;
105   tmp += "/species";
106   fpGunSpecies = new G4UIcmdWithAString(tmp, this);
107 
108   tmp = dir;
109   tmp += "/position";
110   fpGunPosition = new G4UIcmdWith3VectorAndUnit(tmp, this);
111 
112   tmp = dir;
113   tmp += "/time";
114   fpGunTime = new G4UIcmdWithADoubleAndUnit(tmp, this);
115 
116   tmp = dir;
117   tmp += "/number";
118   fpGunN = new G4UIcmdWithAnInteger(tmp, this);
119 
120   tmp = dir;
121   tmp += "/rndmPosition";
122   fpGunRdnmPosition = new G4UIcmdWith3VectorAndUnit(tmp, this);
123 
124   tmp = std::move(dir);
125   tmp += "/type";
126   fpGunType = new G4UIcmdWithAString(tmp, this);
127 
128 //  fpShoot.reset(new TG4MoleculeShoot<G4Track>());
129 }
130 
131 //------------------------------------------------------------------------------
132 
133 G4MoleculeShootMessenger::~G4MoleculeShootMessenger()
134 {
135   delete fpGunSpecies;
136   delete fpGunPosition;
137   delete fpGunTime;
138   delete fpGunN;
139 }
140 
141 //------------------------------------------------------------------------------
142 
143 void G4MoleculeShootMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
144 {
145   if (command == fpGunSpecies)
146   {
147     fpShoot->fMoleculeName = newValue;
148   }
149   else if (command == fpGunPosition)
150   {
151     fpShoot->fPosition = fpGunPosition->GetNew3VectorValue(newValue);
152   }
153   else if(command == fpGunRdnmPosition)
154   {
155     fpShoot->fBoxSize = new G4ThreeVector(fpGunRdnmPosition->GetNew3VectorValue(newValue));
156   }
157   else if (command == fpGunTime)
158   {
159     fpShoot->fTime = fpGunTime->GetNewDoubleValue(newValue);
160   }
161   else if (command == fpGunN)
162   {
163     fpShoot->fNumber = fpGunN->GetNewIntValue(newValue);
164   }
165   else if (command == fpGunType)
166   {
167     if(newValue == "CM")
168     {
169 //      G4cout << "**** Change type" << G4endl;
170 //      TG4MoleculeShoot<G4ContinuousMedium>* casted = static_cast<TG4MoleculeShoot<G4ContinuousMedium>*>(fpShoot.get());
171 //      fpShoot.reset(casted);
172       fpShoot = fpShoot.get()->ChangeType<G4ContinuousMedium>();
173     }
174   }
175 }
176 
177 //------------------------------------------------------------------------------
178 
179 G4String G4MoleculeShootMessenger::GetCurrentValue(G4UIcommand* command)
180 {
181   if (command == fpGunSpecies)
182   {
183     return fpShoot->fMoleculeName;
184   }
185   if (command == fpGunPosition)
186   {
187     return fpGunPosition->ConvertToStringWithBestUnit(fpShoot->fPosition);
188   }
189   if (command == fpGunRdnmPosition)
190   {
191     if(fpShoot->fBoxSize != nullptr)
192     {
193       return fpGunRdnmPosition->ConvertToStringWithBestUnit(*fpShoot->fBoxSize);
194     }
195     return fpGunRdnmPosition->ConvertToStringWithBestUnit(G4ThreeVector());
196   }
197   if (command == fpGunTime)
198   {
199     return fpGunTime->ConvertToStringWithBestUnit(fpShoot->fTime);
200   }
201   if (command == fpGunN)
202   {
203     return fpGunN->ConvertToString(fpShoot->fNumber);
204   }
205   return "";
206 }
207 
208 //------------------------------------------------------------------------------
209 
210