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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 ]

Diff markup

Differences between /processes/electromagnetic/dna/utils/src/G4MoleculeGunMessenger.cc (Version 11.3.0) and /processes/electromagnetic/dna/utils/src/G4MoleculeGunMessenger.cc (Version 10.7.p1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 /*                                                 26 /*
 27  * MoleculeGunMessenger.cc                         27  * MoleculeGunMessenger.cc
 28  *                                                 28  *
 29  *  Created on: 30 janv. 2014                      29  *  Created on: 30 janv. 2014
 30  *      Author: kara                               30  *      Author: kara
 31  */                                                31  */
 32                                                    32 
 33 #include "G4MoleculeGunMessenger.hh"               33 #include "G4MoleculeGunMessenger.hh"
 34                                                << 
 35 #include "G4MoleculeGun.hh"                        34 #include "G4MoleculeGun.hh"
                                                   >>  35 
 36 #include "G4Tokenizer.hh"                          36 #include "G4Tokenizer.hh"
                                                   >>  37 
                                                   >>  38 #include "G4UIdirectory.hh"
                                                   >>  39 #include "G4UIcmdWithAString.hh"
                                                   >>  40 #include "G4UIcmdWithAString.hh"
 37 #include "G4UIcmdWith3VectorAndUnit.hh"            41 #include "G4UIcmdWith3VectorAndUnit.hh"
 38 #include "G4UIcmdWithADoubleAndUnit.hh"            42 #include "G4UIcmdWithADoubleAndUnit.hh"
 39 #include "G4UIcmdWithAString.hh"               << 
 40 #include "G4UIcmdWithAnInteger.hh"                 43 #include "G4UIcmdWithAnInteger.hh"
 41 #include "G4UIdirectory.hh"                        44 #include "G4UIdirectory.hh"
 42                                                    45 
 43 //--------------------------------------------     46 //------------------------------------------------------------------------------
 44                                                    47 
 45 G4MoleculeGunMessenger::G4MoleculeGunMessenger     48 G4MoleculeGunMessenger::G4MoleculeGunMessenger(G4MoleculeGun* gun) :
 46   G4UImessenger("/chem/gun/", "")                  49   G4UImessenger("/chem/gun/", "")
 47 {                                                  50 {
 48   fpGunNewGunType = new G4UIcmdWithAString("/c     51   fpGunNewGunType = new G4UIcmdWithAString("/chem/gun/newShoot",
 49                                            thi     52                                            this);
 50   fpMoleculeGun = gun;                             53   fpMoleculeGun = gun;
 51 }                                                  54 }
 52                                                    55 
 53 //--------------------------------------------     56 //------------------------------------------------------------------------------
 54                                                    57 
 55 G4MoleculeGunMessenger::~G4MoleculeGunMessenge     58 G4MoleculeGunMessenger::~G4MoleculeGunMessenger()
 56 {                                                  59 {
 57   delete fpGunNewGunType;                      <<  60   if (fpGunNewGunType) delete fpGunNewGunType;
 58 }                                                  61 }
 59                                                    62 
 60 //--------------------------------------------     63 //------------------------------------------------------------------------------
 61                                                    64 
 62 G4String G4MoleculeGunMessenger::GetCurrentVal     65 G4String G4MoleculeGunMessenger::GetCurrentValue(G4UIcommand* /*command*/)
 63 {                                                  66 {
 64   return "";                                       67   return "";
 65 }                                                  68 }
 66                                                    69 
 67 //--------------------------------------------     70 //------------------------------------------------------------------------------
 68                                                    71 
 69 void G4MoleculeGunMessenger::SetNewValue(G4UIc     72 void G4MoleculeGunMessenger::SetNewValue(G4UIcommand* command,
 70                                          G4Str     73                                          G4String newValue)
 71 {                                                  74 {
 72   if (command == fpGunNewGunType)                  75   if (command == fpGunNewGunType)
 73   {                                                76   {
 74     std::istringstream iss (newValue);             77     std::istringstream iss (newValue);
 75                                                    78     
 76     G4String shootName;                            79     G4String shootName;
 77     iss >> shootName;                              80     iss >> shootName;
 78                                                    81     
 79     G4String shootType;                            82     G4String shootType;
 80     iss >> shootType;                              83     iss >> shootType;
 81                                                    84         
 82     if(shootType.empty() || shootType.empty()) <<  85     if(shootType == "" || shootType.empty())
 83     {                                              86     {
 84       CreateNewType<G4Track>(shootName);           87       CreateNewType<G4Track>(shootName);
 85     }                                              88     }
 86     else                                           89     else
 87     {                                              90     {      
 88       CreateNewType<G4ContinuousMedium>(shootN     91       CreateNewType<G4ContinuousMedium>(shootName);
 89     }                                              92     }
 90   }                                                93   }
 91 }                                                  94 }
 92                                                    95 
 93 //--------------------------------------------     96 //------------------------------------------------------------------------------
 94                                                    97 
 95 G4MoleculeShootMessenger::G4MoleculeShootMesse     98 G4MoleculeShootMessenger::G4MoleculeShootMessenger(const G4String& name,
 96                                                    99                                                    G4MoleculeGunMessenger*,
 97                                                << 100                                                    G4shared_ptr<G4MoleculeShoot>
 98   : fpShoot(std::move(shoot))                  << 101                                                       shoot) :
                                                   >> 102     G4UImessenger(), fpShoot(shoot)
 99 {                                                 103 {
100   G4String dir("/chem/gun/");                     104   G4String dir("/chem/gun/");
101   dir += name;                                    105   dir += name;
102   CreateDirectory(dir, "");                       106   CreateDirectory(dir, "");
103                                                   107 
104   G4String tmp = dir;                             108   G4String tmp = dir;
105   tmp += "/species";                              109   tmp += "/species";
106   fpGunSpecies = new G4UIcmdWithAString(tmp, t    110   fpGunSpecies = new G4UIcmdWithAString(tmp, this);
107                                                   111 
108   tmp = dir;                                      112   tmp = dir;
109   tmp += "/position";                             113   tmp += "/position";
110   fpGunPosition = new G4UIcmdWith3VectorAndUni    114   fpGunPosition = new G4UIcmdWith3VectorAndUnit(tmp, this);
111                                                   115 
112   tmp = dir;                                      116   tmp = dir;
113   tmp += "/time";                                 117   tmp += "/time";
114   fpGunTime = new G4UIcmdWithADoubleAndUnit(tm    118   fpGunTime = new G4UIcmdWithADoubleAndUnit(tmp, this);
115                                                   119 
116   tmp = dir;                                      120   tmp = dir;
117   tmp += "/number";                               121   tmp += "/number";
118   fpGunN = new G4UIcmdWithAnInteger(tmp, this)    122   fpGunN = new G4UIcmdWithAnInteger(tmp, this);
119                                                   123 
120   tmp = dir;                                      124   tmp = dir;
121   tmp += "/rndmPosition";                         125   tmp += "/rndmPosition";
122   fpGunRdnmPosition = new G4UIcmdWith3VectorAn    126   fpGunRdnmPosition = new G4UIcmdWith3VectorAndUnit(tmp, this);
123                                                   127 
124   tmp = std::move(dir);                        << 128   tmp = dir;
125   tmp += "/type";                                 129   tmp += "/type";
126   fpGunType = new G4UIcmdWithAString(tmp, this    130   fpGunType = new G4UIcmdWithAString(tmp, this);
127                                                   131 
128 //  fpShoot.reset(new TG4MoleculeShoot<G4Track    132 //  fpShoot.reset(new TG4MoleculeShoot<G4Track>());
129 }                                                 133 }
130                                                   134 
131 //--------------------------------------------    135 //------------------------------------------------------------------------------
132                                                   136 
133 G4MoleculeShootMessenger::~G4MoleculeShootMess    137 G4MoleculeShootMessenger::~G4MoleculeShootMessenger()
134 {                                                 138 {
135   delete fpGunSpecies;                         << 139   if (fpGunSpecies) delete fpGunSpecies;
136   delete fpGunPosition;                        << 140   if (fpGunPosition) delete fpGunPosition;
137   delete fpGunTime;                            << 141   if (fpGunTime) delete fpGunTime;
138   delete fpGunN;                               << 142   if (fpGunN) delete fpGunN;
139 }                                                 143 }
140                                                   144 
141 //--------------------------------------------    145 //------------------------------------------------------------------------------
142                                                   146 
143 void G4MoleculeShootMessenger::SetNewValue(G4U    147 void G4MoleculeShootMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
144 {                                                 148 {
145   if (command == fpGunSpecies)                    149   if (command == fpGunSpecies)
146   {                                               150   {
147     fpShoot->fMoleculeName = newValue;            151     fpShoot->fMoleculeName = newValue;
148   }                                               152   }
149   else if (command == fpGunPosition)              153   else if (command == fpGunPosition)
150   {                                               154   {
151     fpShoot->fPosition = fpGunPosition->GetNew    155     fpShoot->fPosition = fpGunPosition->GetNew3VectorValue(newValue);
152   }                                               156   }
153   else if(command == fpGunRdnmPosition)           157   else if(command == fpGunRdnmPosition)
154   {                                               158   {
155     fpShoot->fBoxSize = new G4ThreeVector(fpGu    159     fpShoot->fBoxSize = new G4ThreeVector(fpGunRdnmPosition->GetNew3VectorValue(newValue));
156   }                                               160   }
157   else if (command == fpGunTime)                  161   else if (command == fpGunTime)
158   {                                               162   {
159     fpShoot->fTime = fpGunTime->GetNewDoubleVa    163     fpShoot->fTime = fpGunTime->GetNewDoubleValue(newValue);
160   }                                               164   }
161   else if (command == fpGunN)                     165   else if (command == fpGunN)
162   {                                               166   {
163     fpShoot->fNumber = fpGunN->GetNewIntValue(    167     fpShoot->fNumber = fpGunN->GetNewIntValue(newValue);
164   }                                               168   }
165   else if (command == fpGunType)                  169   else if (command == fpGunType)
166   {                                               170   {
167     if(newValue == "CM")                          171     if(newValue == "CM")
168     {                                             172     {
169 //      G4cout << "**** Change type" << G4endl    173 //      G4cout << "**** Change type" << G4endl;
170 //      TG4MoleculeShoot<G4ContinuousMedium>*  << 174 //      TG4MoleculeShoot<G4ContinuousMedium>* casted = reinterpret_cast<TG4MoleculeShoot<G4ContinuousMedium>*>(fpShoot.get());
171 //      fpShoot.reset(casted);                    175 //      fpShoot.reset(casted);
172       fpShoot = fpShoot.get()->ChangeType<G4Co    176       fpShoot = fpShoot.get()->ChangeType<G4ContinuousMedium>();
173     }                                             177     }
174   }                                               178   }
175 }                                                 179 }
176                                                   180 
177 //--------------------------------------------    181 //------------------------------------------------------------------------------
178                                                   182 
179 G4String G4MoleculeShootMessenger::GetCurrentV    183 G4String G4MoleculeShootMessenger::GetCurrentValue(G4UIcommand* command)
180 {                                                 184 {
181   if (command == fpGunSpecies)                    185   if (command == fpGunSpecies)
182   {                                               186   {
183     return fpShoot->fMoleculeName;                187     return fpShoot->fMoleculeName;
184   }                                               188   }
185   if (command == fpGunPosition)                << 189   else if (command == fpGunPosition)
186   {                                               190   {
187     return fpGunPosition->ConvertToStringWithB    191     return fpGunPosition->ConvertToStringWithBestUnit(fpShoot->fPosition);
188   }                                               192   }
189   if (command == fpGunRdnmPosition)            << 193   else if (command == fpGunRdnmPosition)
190   {                                               194   {
191     if(fpShoot->fBoxSize != nullptr)           << 195     if(fpShoot->fBoxSize)
192     {                                             196     {
193       return fpGunRdnmPosition->ConvertToStrin    197       return fpGunRdnmPosition->ConvertToStringWithBestUnit(*fpShoot->fBoxSize);
194     }                                             198     }
195     return fpGunRdnmPosition->ConvertToStringW    199     return fpGunRdnmPosition->ConvertToStringWithBestUnit(G4ThreeVector());
196   }                                               200   }
197   if (command == fpGunTime)                    << 201   else if (command == fpGunTime)
198   {                                               202   {
199     return fpGunTime->ConvertToStringWithBestU    203     return fpGunTime->ConvertToStringWithBestUnit(fpShoot->fTime);
200   }                                               204   }
201   if (command == fpGunN)                       << 205   else if (command == fpGunN)
202   {                                               206   {
203     return fpGunN->ConvertToString(fpShoot->fN    207     return fpGunN->ConvertToString(fpShoot->fNumber);
204   }                                               208   }
205   return "";                                      209   return "";
206 }                                                 210 }
207                                                   211 
208 //--------------------------------------------    212 //------------------------------------------------------------------------------
209                                                   213 
210                                                   214