Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/processes/electromagnetic/dna/molecules/management/src/G4Molecule.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.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/molecules/management/src/G4Molecule.cc (Version 11.3.0) and /processes/electromagnetic/dna/molecules/management/src/G4Molecule.cc (Version 10.7.p3)


  1 // *******************************************      1 // ********************************************************************
  2 // * License and Disclaimer                         2 // * License and Disclaimer                                           *
  3 // *                                                3 // *                                                                  *
  4 // * The  Geant4 software  is  copyright of th      4 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  5 // * the Geant4 Collaboration.  It is provided      5 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  6 // * conditions of the Geant4 Software License      6 // * conditions of the Geant4 Software License,  included in the file *
  7 // * LICENSE and available at  http://cern.ch/      7 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  8 // * include a list of copyright holders.           8 // * include a list of copyright holders.                             *
  9 // *                                                9 // *                                                                  *
 10 // * Neither the authors of this software syst     10 // * Neither the authors of this software system, nor their employing *
 11 // * institutes,nor the agencies providing fin     11 // * institutes,nor the agencies providing financial support for this *
 12 // * work  make  any representation or  warran     12 // * work  make  any representation or  warranty, express or implied, *
 13 // * regarding  this  software system or assum     13 // * regarding  this  software system or assume any liability for its *
 14 // * use.  Please see the license in the file      14 // * use.  Please see the license in the file  LICENSE  and URL above *
 15 // * for the full disclaimer and the limitatio     15 // * for the full disclaimer and the limitation of liability.         *
 16 // *                                               16 // *                                                                  *
 17 // * This  code  implementation is the result      17 // * This  code  implementation is the result of  the  scientific and *
 18 // * technical work of the GEANT4 collaboratio     18 // * technical work of the GEANT4 collaboration.                      *
 19 // * By using,  copying,  modifying or  distri     19 // * By using,  copying,  modifying or  distributing the software (or *
 20 // * any work based  on the software)  you  ag     20 // * any work based  on the software)  you  agree  to acknowledge its *
 21 // * use  in  resulting  scientific  publicati     21 // * use  in  resulting  scientific  publications,  and indicate your *
 22 // * acceptance of all terms of the Geant4 Sof     22 // * acceptance of all terms of the Geant4 Software license.          *
 23 // *******************************************     23 // ********************************************************************
 24 //                                                 24 //
 25 //                                                 25 //
 26 // -------------------------------------------     26 // ---------------------------------------------------------------------
 27 //  GEANT 4 class header file                      27 //  GEANT 4 class header file
 28 //                                                 28 //
 29 //  History: first implementation, based on G4     29 //  History: first implementation, based on G4DynamicParticle
 30 //           New dependency : G4VUserTrackInfo     30 //           New dependency : G4VUserTrackInformation
 31 //                                                 31 //
 32 //      ---------------- G4Molecule  ---------     32 //      ---------------- G4Molecule  ----------------
 33 //      first design&implementation by Alfonso     33 //      first design&implementation by Alfonso Mantero, 7 Apr 2009
 34 //      New developments Alfonso Mantero & Mat     34 //      New developments Alfonso Mantero & Mathieu Karamitros
 35 //      Oct/Nov 2009 Class Name changed to G4M     35 //      Oct/Nov 2009 Class Name changed to G4Molecule
 36 //                   Removed dependency from G     36 //                   Removed dependency from G4DynamicParticle
 37 //                   New constructors :            37 //                   New constructors :
 38 //                    copy constructor             38 //                    copy constructor
 39 //                    direct ionized/excited m     39 //                    direct ionized/excited molecule
 40 //                   New methods :                 40 //                   New methods :
 41 //                    Get : name,atoms' number     41 //                    Get : name,atoms' number,nb electrons,decayChannel
 42 //                    PrintState //To get the      42 //                    PrintState //To get the electronic level and the
 43 //                                 correspondi     43 //                                 corresponding name of the excitation
 44 //                    Kinematic :                  44 //                    Kinematic :
 45 //                    BuildTrack,GetKineticEne     45 //                    BuildTrack,GetKineticEnergy,GetDiffusionVelocity
 46 //                    Change the way dynCharge     46 //                    Change the way dynCharge and eNb is calculated
 47 // -------------------------------------------     47 // ---------------------------------------------------------------------
 48                                                    48 
 49 #include "G4Molecule.hh"                           49 #include "G4Molecule.hh"
 50 #include "G4MolecularConfiguration.hh"             50 #include "G4MolecularConfiguration.hh"
 51 #include "Randomize.hh"                            51 #include "Randomize.hh"
 52 #include "G4PhysicalConstants.hh"                  52 #include "G4PhysicalConstants.hh"
 53 #include "G4SystemOfUnits.hh"                      53 #include "G4SystemOfUnits.hh"
 54 #include "G4Track.hh"                              54 #include "G4Track.hh"
 55 #include "G4VMoleculeCounter.hh"                   55 #include "G4VMoleculeCounter.hh"
 56                                                    56 
 57 using namespace std;                               57 using namespace std;
 58                                                    58 
                                                   >>  59 ITImp(G4Molecule)
                                                   >>  60 
 59 G4Allocator<G4Molecule>*& aMoleculeAllocator()     61 G4Allocator<G4Molecule>*& aMoleculeAllocator()
 60 {                                                  62 {
 61     G4ThreadLocalStatic G4Allocator<G4Molecule     63     G4ThreadLocalStatic G4Allocator<G4Molecule>* _instance = nullptr;
 62     return _instance;                              64     return _instance;
 63 }                                                  65 }
 64                                                    66 
 65 //____________________________________________     67 //______________________________________________________________________________
 66                                                    68 
 67 template<>                                         69 template<>
 68 G4KDNode<G4Molecule>::~G4KDNode() {                70 G4KDNode<G4Molecule>::~G4KDNode() {
 69     fPoint->SetNode(nullptr);                      71     fPoint->SetNode(nullptr);
 70 }                                                  72 }
 71                                                    73 
 72 //____________________________________________     74 //______________________________________________________________________________
 73                                                    75 
 74 G4Molecule* GetMolecule(const G4Track& track)      76 G4Molecule* GetMolecule(const G4Track& track)
 75 {                                                  77 {
 76     return (G4Molecule*)(GetIT(track));            78     return (G4Molecule*)(GetIT(track));
 77 }                                                  79 }
 78                                                    80 
 79 //____________________________________________     81 //______________________________________________________________________________
 80                                                    82 
 81 G4Molecule* GetMolecule(const G4Track* track)      83 G4Molecule* GetMolecule(const G4Track* track)
 82 {                                                  84 {
 83     return (G4Molecule*)(GetIT(track));            85     return (G4Molecule*)(GetIT(track));
 84 }                                                  86 }
 85                                                    87 
 86 //____________________________________________     88 //______________________________________________________________________________
 87                                                    89 
 88 G4Molecule* G4Molecule::GetMolecule(const G4Tr     90 G4Molecule* G4Molecule::GetMolecule(const G4Track* track)
 89 {                                                  91 {
 90     return (G4Molecule*)(GetIT(track));            92     return (G4Molecule*)(GetIT(track));
 91 }                                                  93 }
 92                                                    94 
 93 //____________________________________________     95 //______________________________________________________________________________
 94                                                    96 
 95 void G4Molecule::Print() const                     97 void G4Molecule::Print() const
 96 {                                                  98 {
 97     G4cout << "The user track information is a     99     G4cout << "The user track information is a molecule" << G4endl;
 98 }                                                 100 }
 99                                                   101 
100 //____________________________________________    102 //______________________________________________________________________________
101                                                   103 
102 G4Molecule::G4Molecule(const G4Molecule& right    104 G4Molecule::G4Molecule(const G4Molecule& right)
103     : G4VUserTrackInformation("G4Molecule")       105     : G4VUserTrackInformation("G4Molecule")
104     , G4IT(right)                                 106     , G4IT(right)
105 {                                                 107 {
106     fpMolecularConfiguration = right.fpMolecul    108     fpMolecularConfiguration = right.fpMolecularConfiguration;
107 }                                                 109 }
108                                                   110 
109 //____________________________________________    111 //______________________________________________________________________________
110                                                   112 
111 G4Molecule& G4Molecule::operator=(const G4Mole    113 G4Molecule& G4Molecule::operator=(const G4Molecule& right)
112 {                                                 114 {
113     if (&right == this) return *this;             115     if (&right == this) return *this;
114     fpMolecularConfiguration = right.fpMolecul    116     fpMolecularConfiguration = right.fpMolecularConfiguration;
115     return *this;                                 117     return *this;
116 }                                                 118 }
117                                                   119 
118 //____________________________________________    120 //______________________________________________________________________________
119                                                   121 
120 G4bool G4Molecule::operator==(const G4Molecule    122 G4bool G4Molecule::operator==(const G4Molecule& right) const
121 {                                                 123 {
122     return fpMolecularConfiguration == right.f << 124     if (fpMolecularConfiguration == right.fpMolecularConfiguration)
                                                   >> 125     {
                                                   >> 126         return true;
                                                   >> 127     }
                                                   >> 128     return false;
123 }                                                 129 }
124                                                   130 
125 //____________________________________________    131 //______________________________________________________________________________
126                                                   132 
127 G4bool G4Molecule::operator!=(const G4Molecule    133 G4bool G4Molecule::operator!=(const G4Molecule& right) const
128 {                                                 134 {
129     return !(*this == right);                     135     return !(*this == right);
130 }                                                 136 }
131                                                   137 
132 //____________________________________________    138 //______________________________________________________________________________
133 /** The two methods below are the most called     139 /** The two methods below are the most called of the simulation :
134  *  compare molecules in the MoleculeStackMana    140  *  compare molecules in the MoleculeStackManager or in
135  *  the InteractionTable                          141  *  the InteractionTable
136  */                                               142  */
137                                                   143 
138 G4bool G4Molecule::operator<(const G4Molecule&    144 G4bool G4Molecule::operator<(const G4Molecule& right) const
139 {                                                 145 {
140     return fpMolecularConfiguration < right.fp    146     return fpMolecularConfiguration < right.fpMolecularConfiguration;
141 }                                                 147 }
142                                                   148 
143 //____________________________________________    149 //______________________________________________________________________________
144                                                   150 
145 G4Molecule::G4Molecule()                          151 G4Molecule::G4Molecule()
146     : G4VUserTrackInformation("G4Molecule")       152     : G4VUserTrackInformation("G4Molecule")
                                                   >> 153     , G4IT()
147 {                                                 154 {
148     fpMolecularConfiguration = nullptr;           155     fpMolecularConfiguration = nullptr;
149 }                                                 156 }
150                                                   157 
151 //____________________________________________    158 //______________________________________________________________________________
152                                                   159 
153 G4Molecule::~G4Molecule()                         160 G4Molecule::~G4Molecule()
154 {                                                 161 {
155     if (fpTrack != nullptr)                       162     if (fpTrack != nullptr)
156     {                                             163     {
157         if (G4VMoleculeCounter::Instance()->In    164         if (G4VMoleculeCounter::Instance()->InUse())
158         {                                         165         {
159             G4VMoleculeCounter::Instance()->      166             G4VMoleculeCounter::Instance()->
160                 RemoveAMoleculeAtTime(fpMolecu    167                 RemoveAMoleculeAtTime(fpMolecularConfiguration,
161                                       fpTrack-    168                                       fpTrack->GetGlobalTime(),
162                                       &(fpTrac    169                                       &(fpTrack->GetPosition()));
163         }                                         170         }
164         fpTrack = nullptr;                        171         fpTrack = nullptr;
165     }                                             172     }
166     fpMolecularConfiguration = nullptr;           173     fpMolecularConfiguration = nullptr;
167 }                                                 174 }
168                                                   175 
169 //____________________________________________    176 //______________________________________________________________________________
170 /** Build a molecule at ground state according    177 /** Build a molecule at ground state according to a given
171  *  G4MoleculeDefinition that can be obtained     178  *  G4MoleculeDefinition that can be obtained from G4GenericMoleculeManager
172  */                                               179  */
173 G4Molecule::G4Molecule(G4MoleculeDefinition* p    180 G4Molecule::G4Molecule(G4MoleculeDefinition* pMoleculeDefinition)
174     : G4VUserTrackInformation("G4Molecule")       181     : G4VUserTrackInformation("G4Molecule")
                                                   >> 182     , G4IT()
175 {                                                 183 {
176     fpMolecularConfiguration = G4MolecularConf    184     fpMolecularConfiguration = G4MolecularConfiguration::GetOrCreateMolecularConfiguration(pMoleculeDefinition);
177 }                                                 185 }
178                                                   186 
179 //____________________________________________    187 //______________________________________________________________________________
180                                                   188 
181 G4Molecule::G4Molecule(G4MoleculeDefinition* p    189 G4Molecule::G4Molecule(G4MoleculeDefinition* pMoleculeDefinition, int charge)
182 {                                                 190 {
183     fpMolecularConfiguration = G4MolecularConf    191     fpMolecularConfiguration = G4MolecularConfiguration::GetOrCreateMolecularConfiguration(pMoleculeDefinition,
184                                                   192                                                                                            charge);
185 }                                                 193 }
186                                                   194 
187 //____________________________________________    195 //______________________________________________________________________________
188 /** Build a molecule at a specific excitation/    196 /** Build a molecule at a specific excitation/ionisation state according
189  *  to a ground state that can be obtained fro    197  *  to a ground state that can be obtained from G4GenericMoleculeManager.
190  *  Put 0 in the second option if this is a io    198  *  Put 0 in the second option if this is a ionisation.
191  */                                               199  */
192 G4Molecule::G4Molecule(G4MoleculeDefinition* p    200 G4Molecule::G4Molecule(G4MoleculeDefinition* pMoleculeDefinition,
193                        G4int OrbitalToFree,       201                        G4int OrbitalToFree,
194                        G4int OrbitalToFill)       202                        G4int OrbitalToFill)
195    : G4VUserTrackInformation("G4Molecule")        203    : G4VUserTrackInformation("G4Molecule")
                                                   >> 204    , G4IT()
196 {                                                 205 {
197     if (pMoleculeDefinition->GetGroundStateEle << 206     if (pMoleculeDefinition->GetGroundStateElectronOccupancy())
198     {                                             207     {
199         G4ElectronOccupancy dynElectronOccupan    208         G4ElectronOccupancy dynElectronOccupancy(*pMoleculeDefinition->GetGroundStateElectronOccupancy());
200                                                   209 
201         if (OrbitalToFill != 0)                   210         if (OrbitalToFill != 0)
202         {                                         211         {
203             dynElectronOccupancy.RemoveElectro    212             dynElectronOccupancy.RemoveElectron(OrbitalToFree - 1, 1);
204             dynElectronOccupancy.AddElectron(O    213             dynElectronOccupancy.AddElectron(OrbitalToFill - 1, 1);
205             // dynElectronOccupancy.DumpInfo()    214             // dynElectronOccupancy.DumpInfo(); // DEBUG
206         }                                         215         }
207                                                   216 
208         if (OrbitalToFill == 0)                   217         if (OrbitalToFill == 0)
209         {                                         218         {
210             dynElectronOccupancy.RemoveElectro    219             dynElectronOccupancy.RemoveElectron(OrbitalToFree - 1, 1);
211             // dynElectronOccupancy.DumpInfo()    220             // dynElectronOccupancy.DumpInfo(); // DEBUG
212         }                                         221         }
213                                                   222 
214         fpMolecularConfiguration =                223         fpMolecularConfiguration =
215             G4MolecularConfiguration::GetOrCre    224             G4MolecularConfiguration::GetOrCreateMolecularConfiguration(
216                 pMoleculeDefinition, dynElectr    225                 pMoleculeDefinition, dynElectronOccupancy);
217     }                                             226     }
218     else                                          227     else
219     {                                             228     {
220         fpMolecularConfiguration = nullptr;       229         fpMolecularConfiguration = nullptr;
221         G4Exception(                              230         G4Exception(
222             "G4Molecule::G4Molecule(G4Molecule    231             "G4Molecule::G4Molecule(G4MoleculeDefinition* pMoleculeDefinition, "
223             "G4int OrbitalToFree, G4int Orbita    232             "G4int OrbitalToFree, G4int OrbitalToFill)",
224             "G4Molecule_wrong_usage_of_constru    233             "G4Molecule_wrong_usage_of_constructor",
225             FatalErrorInArgument,                 234             FatalErrorInArgument,
226             "If you want to use this construct    235             "If you want to use this constructor, the molecule definition has to be "
227             "first defined with electron occup    236             "first defined with electron occupancies");
228     }                                             237     }
229 }                                                 238 }
230                                                   239 
231 //____________________________________________    240 //______________________________________________________________________________
232 /** Specific builder for water molecules to be    241 /** Specific builder for water molecules to be used in Geant4-DNA,
233  * the last option Excitation is true if the m    242  * the last option Excitation is true if the molecule is excited, is
234  * false is the molecule is ionized.              243  * false is the molecule is ionized.
235  */                                               244  */
236 G4Molecule::G4Molecule(G4MoleculeDefinition* p    245 G4Molecule::G4Molecule(G4MoleculeDefinition* pMoleculeDefinition,
237                        G4int level,               246                        G4int level,
238                        G4bool excitation)         247                        G4bool excitation)
239     : G4VUserTrackInformation("G4Molecule")       248     : G4VUserTrackInformation("G4Molecule")
                                                   >> 249     , G4IT()
240 {                                                 250 {
241     if (pMoleculeDefinition->GetGroundStateEle << 251     if (pMoleculeDefinition->GetGroundStateElectronOccupancy())
242     {                                             252     {
243         G4ElectronOccupancy dynElectronOccupan    253         G4ElectronOccupancy dynElectronOccupancy(*pMoleculeDefinition->GetGroundStateElectronOccupancy());
244                                                   254 
245         if (excitation)                           255         if (excitation)
246         {                                         256         {
247             dynElectronOccupancy.RemoveElectro    257             dynElectronOccupancy.RemoveElectron(level, 1);
248             dynElectronOccupancy.AddElectron(5    258             dynElectronOccupancy.AddElectron(5, 1);
249             // dynElectronOccupancy.DumpInfo()    259             // dynElectronOccupancy.DumpInfo(); // DEBUG
250         }                                         260         }
251         else                                      261         else
252         {                                         262         {
253             dynElectronOccupancy.RemoveElectro    263             dynElectronOccupancy.RemoveElectron(level, 1);
254             // dynElectronOccupancy.DumpInfo()    264             // dynElectronOccupancy.DumpInfo(); // DEBUG
255         }                                         265         }
256                                                   266 
257         fpMolecularConfiguration = G4Molecular    267         fpMolecularConfiguration = G4MolecularConfiguration::GetOrCreateMolecularConfiguration(pMoleculeDefinition,
258                 dynElectronOccupancy);            268                 dynElectronOccupancy);
259     }                                             269     }
260     else                                          270     else
261     {                                             271     {
262         fpMolecularConfiguration = nullptr;       272         fpMolecularConfiguration = nullptr;
263         G4Exception(                              273         G4Exception(
264             "G4Molecule::G4Molecule(G4Molecule    274             "G4Molecule::G4Molecule(G4MoleculeDefinition* pMoleculeDefinition, "
265             "G4int OrbitalToFree, G4int Orbita    275             "G4int OrbitalToFree, G4int OrbitalToFill)",
266             "G4Molecule_wrong_usage_of_constru    276             "G4Molecule_wrong_usage_of_constructor",
267             FatalErrorInArgument,                 277             FatalErrorInArgument,
268             "If you want to use this construct    278             "If you want to use this constructor, the molecule definition has to be "
269             "first defined with electron occup    279             "first defined with electron occupancies");
270     }                                             280     }
271 }                                                 281 }
272                                                   282 
273 //____________________________________________    283 //______________________________________________________________________________
274                                                   284 
275 G4Molecule::G4Molecule(const G4MolecularConfig    285 G4Molecule::G4Molecule(const G4MolecularConfiguration* pMolecularConfiguration)
276 {                                                 286 {
277     fpMolecularConfiguration = pMolecularConfi    287     fpMolecularConfiguration = pMolecularConfiguration;
278 }                                                 288 }
279                                                   289 
280 //____________________________________________    290 //______________________________________________________________________________
281                                                   291 
282 void G4Molecule::SetElectronOccupancy(const G4    292 void G4Molecule::SetElectronOccupancy(const G4ElectronOccupancy* pElectronOcc)
283 {                                                 293 {
284     fpMolecularConfiguration =                    294     fpMolecularConfiguration = 
285         G4MolecularConfiguration::GetOrCreateM    295         G4MolecularConfiguration::GetOrCreateMolecularConfiguration(fpMolecularConfiguration->GetDefinition(),
286                                                   296                                                                     *pElectronOcc);
287 }                                                 297 }
288                                                   298 
289 //____________________________________________    299 //______________________________________________________________________________
290                                                   300 
291 void G4Molecule::ExciteMolecule(G4int excitati    301 void G4Molecule::ExciteMolecule(G4int excitationLevel)
292 {                                                 302 {
293     fpMolecularConfiguration = fpMolecularConf    303     fpMolecularConfiguration = fpMolecularConfiguration->ExciteMolecule(excitationLevel);
294 }                                                 304 }
295                                                   305 
296 //____________________________________________    306 //______________________________________________________________________________
297                                                   307 
298 void G4Molecule::IonizeMolecule(G4int ionizati    308 void G4Molecule::IonizeMolecule(G4int ionizationLevel)
299 {                                                 309 {
300     fpMolecularConfiguration = fpMolecularConf    310     fpMolecularConfiguration = fpMolecularConfiguration->IonizeMolecule(ionizationLevel);
301 }                                                 311 }
302                                                   312 
303 //____________________________________________    313 //______________________________________________________________________________
304                                                   314 
305 void G4Molecule::AddElectron(G4int orbit, G4in    315 void G4Molecule::AddElectron(G4int orbit, G4int number)
306 {                                                 316 {
307     fpMolecularConfiguration = fpMolecularConf    317     fpMolecularConfiguration = fpMolecularConfiguration->AddElectron(orbit, number);
308 }                                                 318 }
309                                                   319 
310 //____________________________________________    320 //______________________________________________________________________________
311                                                   321 
312 void G4Molecule::RemoveElectron(G4int orbit, G    322 void G4Molecule::RemoveElectron(G4int orbit, G4int number)
313 {                                                 323 {
314     fpMolecularConfiguration =                    324     fpMolecularConfiguration =
315         fpMolecularConfiguration->RemoveElectr    325         fpMolecularConfiguration->RemoveElectron(orbit, number);
316 }                                                 326 }
317                                                   327 
318 //____________________________________________    328 //______________________________________________________________________________
319                                                   329 
320 void G4Molecule::MoveOneElectron(G4int orbitTo    330 void G4Molecule::MoveOneElectron(G4int orbitToFree, G4int orbitToFill)
321 {                                                 331 {
322     fpMolecularConfiguration =                    332     fpMolecularConfiguration =
323         fpMolecularConfiguration->MoveOneElect    333         fpMolecularConfiguration->MoveOneElectron(orbitToFree, orbitToFill);
324 }                                                 334 }
325                                                   335 
326 //____________________________________________    336 //______________________________________________________________________________
327                                                   337 
328 const G4String& G4Molecule::GetName() const       338 const G4String& G4Molecule::GetName() const
329 {                                                 339 {
330     return fpMolecularConfiguration->GetName()    340     return fpMolecularConfiguration->GetName();
331 }                                                 341 }
332                                                   342 
333 //____________________________________________    343 //______________________________________________________________________________
334                                                   344 
335 const G4String& G4Molecule::GetFormatedName()     345 const G4String& G4Molecule::GetFormatedName() const
336 {                                                 346 {
337     return fpMolecularConfiguration->GetFormat    347     return fpMolecularConfiguration->GetFormatedName();
338 }                                                 348 }
339                                                   349 
340 //____________________________________________    350 //______________________________________________________________________________
341                                                   351 
342 G4int G4Molecule::GetAtomsNumber() const          352 G4int G4Molecule::GetAtomsNumber() const
343 {                                                 353 {
344     return fpMolecularConfiguration->GetAtomsN    354     return fpMolecularConfiguration->GetAtomsNumber();
345 }                                                 355 }
346                                                   356 
347 //____________________________________________    357 //______________________________________________________________________________
348                                                   358 
349 G4double G4Molecule::GetNbElectrons() const       359 G4double G4Molecule::GetNbElectrons() const
350 {                                                 360 {
351     return fpMolecularConfiguration->GetNbElec    361     return fpMolecularConfiguration->GetNbElectrons();
352 }                                                 362 }
353                                                   363 
354 //____________________________________________    364 //______________________________________________________________________________
355                                                   365 
356 void G4Molecule::PrintState() const               366 void G4Molecule::PrintState() const
357 {                                                 367 {
358     fpMolecularConfiguration->PrintState();       368     fpMolecularConfiguration->PrintState();
359 }                                                 369 }
360                                                   370 
361 //____________________________________________    371 //______________________________________________________________________________
362                                                   372 
363 G4Track* G4Molecule::BuildTrack(G4double globa    373 G4Track* G4Molecule::BuildTrack(G4double globalTime,
364                                  const G4Three    374                                  const G4ThreeVector& position)
365 {                                                 375 {
366     if (fpTrack != nullptr)                       376     if (fpTrack != nullptr)
367     {                                             377     {
368         G4Exception("G4Molecule::BuildTrack",     378         G4Exception("G4Molecule::BuildTrack", "Molecule001", FatalErrorInArgument,
369                     "A track was already assig    379                     "A track was already assigned to this molecule");
370     }                                             380     }
371                                                   381 
372     // Kinetic Values                             382     // Kinetic Values
373     // Set a random direction to the molecule     383     // Set a random direction to the molecule
374     G4double costheta = (2 * G4UniformRand() -    384     G4double costheta = (2 * G4UniformRand() - 1);
375     G4double theta = acos(costheta);              385     G4double theta = acos(costheta);
376     G4double phi = 2 * pi * G4UniformRand();      386     G4double phi = 2 * pi * G4UniformRand();
377                                                   387 
378     G4double xMomentum = cos(phi) * sin(theta)    388     G4double xMomentum = cos(phi) * sin(theta);
379     G4double yMomentum = sin(theta) * sin(phi)    389     G4double yMomentum = sin(theta) * sin(phi);
380     G4double zMomentum = costheta;                390     G4double zMomentum = costheta;
381                                                   391 
382     G4ThreeVector MomentumDirection(xMomentum,    392     G4ThreeVector MomentumDirection(xMomentum, yMomentum, zMomentum);
383     G4double KineticEnergy = GetKineticEnergy(    393     G4double KineticEnergy = GetKineticEnergy();
384                                                   394 
385     auto  dynamicParticle = new G4DynamicParti << 395     G4DynamicParticle* dynamicParticle = new G4DynamicParticle(
386         fpMolecularConfiguration->GetDefinitio    396         fpMolecularConfiguration->GetDefinition(), MomentumDirection,
387         KineticEnergy);                           397         KineticEnergy);
388                                                   398 
389     if (G4VMoleculeCounter::Instance()->InUse( << 399     if (G4VMoleculeCounter::InUse())
390     {                                             400     {
391         G4VMoleculeCounter::Instance()->          401         G4VMoleculeCounter::Instance()->
392             AddAMoleculeAtTime(fpMolecularConf    402             AddAMoleculeAtTime(fpMolecularConfiguration,
393                                globalTime,        403                                globalTime,
394                                &(fpTrack->GetP    404                                &(fpTrack->GetPosition()));
395     }                                             405     }
396                                                   406 
397     //Set the Track                               407     //Set the Track
398     fpTrack = new G4Track(dynamicParticle, glo    408     fpTrack = new G4Track(dynamicParticle, globalTime, position);
399     fpTrack->SetUserInformation(this);            409     fpTrack->SetUserInformation(this);
400                                                   410 
401     return fpTrack;                               411     return fpTrack;
402 }                                                 412 }
403                                                   413 
404 //____________________________________________    414 //______________________________________________________________________________
405                                                   415 
406 G4double G4Molecule::GetKineticEnergy() const     416 G4double G4Molecule::GetKineticEnergy() const
407 {                                                 417 {
408     ////                                          418     ////
409     // Ideal Gaz case                             419     // Ideal Gaz case
410     double v = GetDiffusionVelocity();            420     double v = GetDiffusionVelocity();
411     double E = (fpMolecularConfiguration->GetM    421     double E = (fpMolecularConfiguration->GetMass() / (c_squared)) * (v * v) / 2.;
412     ////                                          422     ////
413     return E;                                     423     return E;
414 }                                                 424 }
415                                                   425 
416 //____________________________________________    426 //______________________________________________________________________________
417                                                   427 
418 G4double G4Molecule::GetDiffusionVelocity() co    428 G4double G4Molecule::GetDiffusionVelocity() const
419 {                                                 429 {
420     double moleculeMass = fpMolecularConfigura    430     double moleculeMass = fpMolecularConfiguration->GetMass() / (c_squared);
421                                                   431 
422     ////                                          432     ////
423     // Different possibilities                    433     // Different possibilities
424     ////                                          434     ////
425     // Ideal Gaz case : Maxwell Boltzmann Dist    435     // Ideal Gaz case : Maxwell Boltzmann Distribution
426     //    double sigma = k_Boltzmann * fgTempe    436     //    double sigma = k_Boltzmann * fgTemperature / mass;
427     //    return G4RandGauss::shoot( 0, sigma     437     //    return G4RandGauss::shoot( 0, sigma );
428     ////                                          438     ////
429     // Ideal Gaz case : mean velocity from equ    439     // Ideal Gaz case : mean velocity from equipartition theorem
430     return sqrt(3 * k_Boltzmann *                 440     return sqrt(3 * k_Boltzmann *
431                 G4MolecularConfiguration::GetG    441                 G4MolecularConfiguration::GetGlobalTemperature() / moleculeMass);
432     ////                                          442     ////
433     // Using this approximation for liquid is     443     // Using this approximation for liquid is wrong
434     // However the brownian process avoid taki    444     // However the brownian process avoid taking
435     // care of energy consideration and plays     445     // care of energy consideration and plays only
436     // with positions                             446     // with positions
437 }                                                 447 }
438                                                   448 
439 //____________________________________________    449 //______________________________________________________________________________
440                                                   450 
441 // added - to be transformed in a "Decay metho    451 // added - to be transformed in a "Decay method"
442 const vector<const G4MolecularDissociationChan    452 const vector<const G4MolecularDissociationChannel*>*
443 G4Molecule::GetDissociationChannels() const       453 G4Molecule::GetDissociationChannels() const
444 {                                                 454 {
445     return fpMolecularConfiguration->GetDissoc    455     return fpMolecularConfiguration->GetDissociationChannels();
446 }                                                 456 }
447                                                   457 
448 //____________________________________________    458 //______________________________________________________________________________
449                                                   459 
450 G4int G4Molecule::GetFakeParticleID() const       460 G4int G4Molecule::GetFakeParticleID() const
451 {                                                 461 {
452     return fpMolecularConfiguration->GetFakePa    462     return fpMolecularConfiguration->GetFakeParticleID();
453 }                                                 463 }
454                                                   464 
455 //____________________________________________    465 //______________________________________________________________________________
456                                                   466 
457 G4int G4Molecule::GetMoleculeID() const           467 G4int G4Molecule::GetMoleculeID() const
458 {                                                 468 {
459     return fpMolecularConfiguration->GetMolecu    469     return fpMolecularConfiguration->GetMoleculeID();
460 }                                                 470 }
461                                                   471 
462 //____________________________________________    472 //______________________________________________________________________________
463                                                   473 
464 G4double G4Molecule::GetDecayTime() const         474 G4double G4Molecule::GetDecayTime() const
465 {                                                 475 {
466     return fpMolecularConfiguration->GetDecayT    476     return fpMolecularConfiguration->GetDecayTime();
467 }                                                 477 }
468                                                   478 
469 //____________________________________________    479 //______________________________________________________________________________
470                                                   480 
471 G4double G4Molecule::GetVanDerVaalsRadius() co    481 G4double G4Molecule::GetVanDerVaalsRadius() const
472 {                                                 482 {
473     return fpMolecularConfiguration->GetVanDer    483     return fpMolecularConfiguration->GetVanDerVaalsRadius();
474 }                                                 484 }
475                                                   485 
476 //____________________________________________    486 //______________________________________________________________________________
477                                                   487 
478 G4int G4Molecule::GetCharge() const               488 G4int G4Molecule::GetCharge() const
479 {                                                 489 {
480     return fpMolecularConfiguration->GetCharge    490     return fpMolecularConfiguration->GetCharge();
481 }                                                 491 }
482                                                   492 
483 //____________________________________________    493 //______________________________________________________________________________
484                                                   494 
485 G4double G4Molecule::GetMass() const              495 G4double G4Molecule::GetMass() const
486 {                                                 496 {
487     return fpMolecularConfiguration->GetMass()    497     return fpMolecularConfiguration->GetMass();
488 }                                                 498 }
489                                                   499 
490 //____________________________________________    500 //______________________________________________________________________________
491                                                   501 
492 const G4ElectronOccupancy* G4Molecule::GetElec    502 const G4ElectronOccupancy* G4Molecule::GetElectronOccupancy() const
493 {                                                 503 {
494     return fpMolecularConfiguration->GetElectr    504     return fpMolecularConfiguration->GetElectronOccupancy();
495 }                                                 505 }
496                                                   506 
497 //____________________________________________    507 //______________________________________________________________________________
498                                                   508 
499 const G4MoleculeDefinition* G4Molecule::GetDef    509 const G4MoleculeDefinition* G4Molecule::GetDefinition() const
500 {                                                 510 {
501     return fpMolecularConfiguration->GetDefini    511     return fpMolecularConfiguration->GetDefinition();
502 }                                                 512 }
503                                                   513 
504 //____________________________________________    514 //______________________________________________________________________________
505                                                   515 
506 G4double G4Molecule::GetDiffusionCoefficient()    516 G4double G4Molecule::GetDiffusionCoefficient() const
507 {                                                 517 {
508     return fpMolecularConfiguration->GetDiffus    518     return fpMolecularConfiguration->GetDiffusionCoefficient();
509 }                                                 519 }
510                                                   520 
511 //____________________________________________    521 //______________________________________________________________________________
512                                                   522 
513 G4double G4Molecule::GetDiffusionCoefficient(c    523 G4double G4Molecule::GetDiffusionCoefficient(const G4Material* pMaterial,
514                                              d    524                                              double temperature) const
515 {                                                 525 {
516     return fpMolecularConfiguration->GetDiffus    526     return fpMolecularConfiguration->GetDiffusionCoefficient(pMaterial,
517                                                   527                                                              temperature);
518 }                                                 528 }
519                                                   529 
520 //____________________________________________    530 //______________________________________________________________________________
521                                                   531 
522 const G4MolecularConfiguration* G4Molecule::Ge    532 const G4MolecularConfiguration* G4Molecule::GetMolecularConfiguration() const
523 {                                                 533 {
524     return fpMolecularConfiguration;              534     return fpMolecularConfiguration;
525 }                                                 535 }
526                                                   536 
527 //____________________________________________    537 //______________________________________________________________________________
528                                                   538 
529 const G4String& G4Molecule::GetLabel() const      539 const G4String& G4Molecule::GetLabel() const
530 {                                                 540 {
531     return fpMolecularConfiguration->GetLabel(    541     return fpMolecularConfiguration->GetLabel();
532 }                                                 542 }
533                                                   543 
534 //____________________________________________    544 //______________________________________________________________________________
535                                                   545 
536 void G4Molecule::ChangeConfigurationToLabel(co    546 void G4Molecule::ChangeConfigurationToLabel(const G4String& label)
537 {                                                 547 {
538     // TODO check fpMolecularConfiguration alr    548     // TODO check fpMolecularConfiguration already exists
539     // and new one as well                        549     // and new one as well
540     // TODO notify for stack change               550     // TODO notify for stack change
541     fpMolecularConfiguration = G4MolecularConf    551     fpMolecularConfiguration = G4MolecularConfiguration::GetMolecularConfiguration(
542         fpMolecularConfiguration->GetDefinitio    552         fpMolecularConfiguration->GetDefinition(), label);
543                                                   553 
544     assert(fpMolecularConfiguration != nullptr    554     assert(fpMolecularConfiguration != nullptr);
545 }                                                 555 }
546                                                   556