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3 ] [ 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/G4MoleculeTable.cc (Version 11.3.0) and /processes/electromagnetic/dna/molecules/management/src/G4MoleculeTable.cc (Version 10.2)


  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  * G4MoleculeTable.cc                              27  * G4MoleculeTable.cc
 28  *                                                 28  *
 29  *  Created on: 23 oct. 2013                       29  *  Created on: 23 oct. 2013
 30  *      Author: kara                               30  *      Author: kara
 31  */                                                31  */
 32                                                    32 
 33 #include "G4MoleculeTable.hh"                      33 #include "G4MoleculeTable.hh"
 34 #include "G4MolecularConfiguration.hh"             34 #include "G4MolecularConfiguration.hh"
 35 #include "G4MoleculeDefinition.hh"                 35 #include "G4MoleculeDefinition.hh"
 36 #include "G4MoleculeTableMessenger.hh"         << 
 37                                                    36 
 38 G4MoleculeTable* G4MoleculeTable::fpgMoleculeT <<  37 G4MoleculeTable* G4MoleculeTable::fpgMoleculeTable(0);
 39                                                    38 
 40 //--------------------------------------------     39 //------------------------------------------------------------------------------
 41                                                    40 
 42 G4MoleculeTable::G4MoleculeTable()                 41 G4MoleculeTable::G4MoleculeTable()
 43   : fMoleculeDefTableMessenger(new G4MoleculeT << 
 44 {                                                  42 {
 45 }                                                  43 }
 46                                                    44 
 47 //--------------------------------------------     45 //------------------------------------------------------------------------------
 48                                                    46 
 49 G4MoleculeTable::~G4MoleculeTable()                47 G4MoleculeTable::~G4MoleculeTable()
 50 = default;                                     <<  48 {
                                                   >>  49 }
 51                                                    50 
 52 //--------------------------------------------     51 //------------------------------------------------------------------------------
 53                                                    52 
 54 G4MoleculeTable* G4MoleculeTable::Instance()       53 G4MoleculeTable* G4MoleculeTable::Instance()
 55 {                                                  54 {
 56   if (fpgMoleculeTable == nullptr) fpgMolecule <<  55   if (!fpgMoleculeTable) fpgMoleculeTable = new G4MoleculeTable;
 57   return fpgMoleculeTable;                         56   return fpgMoleculeTable;
 58 }                                                  57 }
 59                                                    58 
 60 //--------------------------------------------     59 //------------------------------------------------------------------------------
 61                                                    60 
 62 G4MoleculeTable* G4MoleculeTable::GetMoleculeT     61 G4MoleculeTable* G4MoleculeTable::GetMoleculeTable()
 63 {                                                  62 {
 64   return Instance();                               63   return Instance();
 65 }                                                  64 }
 66                                                    65 
 67 //--------------------------------------------     66 //------------------------------------------------------------------------------
 68                                                    67 
 69 G4MoleculeDefinition*                              68 G4MoleculeDefinition*
 70 G4MoleculeTable::CreateMoleculeDefinition(cons     69 G4MoleculeTable::CreateMoleculeDefinition(const G4String& name,
 71                                           doub     70                                           double diffusion_coefficient)
 72 {                                                  71 {
 73   return new G4MoleculeDefinition(name, -1 /*  <<  72   // TODO
 74                                   diffusion_co <<  73 
                                                   >>  74   MoleculeDefTable::iterator it = fMoleculeDefTable.find(name);
                                                   >>  75   G4MoleculeDefinition* definition(0);
                                                   >>  76   if (it == fMoleculeDefTable.end())
                                                   >>  77   {
                                                   >>  78     definition = new G4MoleculeDefinition(name, -1 /* mass*/,
                                                   >>  79                                           diffusion_coefficient);
                                                   >>  80     fMoleculeDefTable[name] = definition;
                                                   >>  81   }
                                                   >>  82   else
                                                   >>  83   {
                                                   >>  84     // exception
                                                   >>  85     G4ExceptionDescription description;
                                                   >>  86     description << "The molecule definition " << name
                                                   >>  87                 << " was already recorded in the table" << G4endl;
                                                   >>  88     G4Exception("G4MoleculeTable::CreateMoleculeDefinition",
                                                   >>  89                 "DEFINITION_ALREADY_CREATED", FatalException, description);
                                                   >>  90   }
                                                   >>  91   return definition;
 75 }                                                  92 }
 76                                                    93 
 77 //--------------------------------------------     94 //------------------------------------------------------------------------------
 78                                                    95 
 79 G4MoleculeDefinition*                              96 G4MoleculeDefinition*
 80 G4MoleculeTable::GetMoleculeDefinition(const G     97 G4MoleculeTable::GetMoleculeDefinition(const G4String& name,
 81                                        bool mu     98                                        bool mustExist)
 82 {                                                  99 {
 83   auto it = fMoleculeDefTable.find(name);      << 100   MoleculeDefTable::iterator it = fMoleculeDefTable.find(name);
 84   G4MoleculeDefinition* definition(nullptr);   << 101   G4MoleculeDefinition* definition(0);
 85   if (it != fMoleculeDefTable.end())              102   if (it != fMoleculeDefTable.end())
 86   {                                               103   {
 87     definition = it->second;                      104     definition = it->second;
 88   }                                               105   }
 89   else if(mustExist)                              106   else if(mustExist)
 90   {                                               107   {
 91     // exception                                  108     // exception
 92     G4ExceptionDescription description;           109     G4ExceptionDescription description;
 93     description << "The molecule definition "     110     description << "The molecule definition " << name
 94                 << " was NOT recorded in the t    111                 << " was NOT recorded in the table" << G4endl;
 95     G4Exception("G4MoleculeTable::CreateMolecu    112     G4Exception("G4MoleculeTable::CreateMoleculeModel",
 96                 "MOLECULE_DEFINITION_NOT_CREAT    113                 "MOLECULE_DEFINITION_NOT_CREATED",
 97                 FatalException,                   114                 FatalException,
 98                 description);                     115                 description);
 99   }                                               116   }
100   return definition;                              117   return definition;
101 }                                                 118 }
102                                                   119 
103 //--------------------------------------------    120 //------------------------------------------------------------------------------
104                                                   121 
105 G4MolecularConfiguration*                         122 G4MolecularConfiguration*
106 G4MoleculeTable::GetConfiguration(const G4Stri    123 G4MoleculeTable::GetConfiguration(const G4String& name, bool mustExist)
107 {                                                 124 {
108   G4MolecularConfiguration* species =             125   G4MolecularConfiguration* species =
109       G4MolecularConfiguration::GetMolecularCo    126       G4MolecularConfiguration::GetMolecularConfiguration(name);
110                                                   127 
111   if(species == nullptr && mustExist)          << 128   if(species == 0 && mustExist)
112   {                                               129   {
113     // exception                                  130     // exception
114     G4ExceptionDescription description;           131     G4ExceptionDescription description;
115     description << "The configuration " << nam    132     description << "The configuration " << name
116                 << " was not recorded in the t    133                 << " was not recorded in the table" << G4endl;
117     G4Exception("G4MoleculeTable::GetConfigura    134     G4Exception("G4MoleculeTable::GetConfiguration",
118                 "CONF_NOT_CREATED",               135                 "CONF_NOT_CREATED",
119                 FatalException,                   136                 FatalException,
120                 description);                     137                 description);
121   }                                               138   }
122                                                   139 
123   return species;                                 140   return species;
124 }                                                 141 }
125                                                   142 
126 //--------------------------------------------    143 //------------------------------------------------------------------------------
127                                                   144 
128 G4MolecularConfiguration*                         145 G4MolecularConfiguration*
129 G4MoleculeTable::GetConfiguration(G4int id)       146 G4MoleculeTable::GetConfiguration(G4int id)
130 {                                                 147 {
131   G4MolecularConfiguration* species =             148   G4MolecularConfiguration* species =
132         G4MolecularConfiguration::GetMolecular    149         G4MolecularConfiguration::GetMolecularConfiguration(id);
133                                                   150 
134   return species;                                 151   return species;
135 }                                                 152 }
136                                                   153 
137 //--------------------------------------------    154 //------------------------------------------------------------------------------
138                                                   155 
139 void G4MoleculeTable::Insert(G4MoleculeDefinit    156 void G4MoleculeTable::Insert(G4MoleculeDefinition* moleculeDefinition)
140 {                                                 157 {
141                                                   158 
142   const G4String& name = moleculeDefinition->G    159   const G4String& name = moleculeDefinition->GetName();
143   auto it = fMoleculeDefTable.find(name);      << 160   MoleculeDefTable::iterator it = fMoleculeDefTable.find(name);
144   if (it == fMoleculeDefTable.end())              161   if (it == fMoleculeDefTable.end())
145   {                                               162   {
146     fMoleculeDefTable[name] = moleculeDefiniti    163     fMoleculeDefTable[name] = moleculeDefinition;
147   }                                               164   }
148   else                                            165   else
149   {                                               166   {
150     // exception                                  167     // exception
151     G4ExceptionDescription description;           168     G4ExceptionDescription description;
152     description << "The molecule definition "     169     description << "The molecule definition " << name
153                 << " was already recorded in t    170                 << " was already recorded in the table" << G4endl;
154     G4Exception("G4MoleculeTable::CreateMolecu    171     G4Exception("G4MoleculeTable::CreateMoleculeDefinition",
155                 "DEFINITION_ALREADY_CREATED",     172                 "DEFINITION_ALREADY_CREATED", FatalException, description);
156   }                                               173   }
157 }                                                 174 }
158                                                   175 
159 //--------------------------------------------    176 //------------------------------------------------------------------------------
160                                                   177 
161 void G4MoleculeTable::PrepareMolecularConfigur    178 void G4MoleculeTable::PrepareMolecularConfiguration()
162 {                                                 179 {
163   auto it = fMoleculeDefTable.begin();         << 180   MoleculeDefTable::iterator it = fMoleculeDefTable.begin();
164                                                   181 
165   for(; it != fMoleculeDefTable.end() ; ++it)     182   for(; it != fMoleculeDefTable.end() ; ++it)
166   {                                               183   {
167     G4MolecularConfiguration::GetOrCreateMolec    184     G4MolecularConfiguration::GetOrCreateMolecularConfiguration(it->second);
168   }                                               185   }
169 }                                                 186 }
170                                                   187 
171 //--------------------------------------------    188 //------------------------------------------------------------------------------
172                                                   189 
173 G4MolecularConfiguration*                         190 G4MolecularConfiguration*
174 G4MoleculeTable::CreateConfiguration(const G4S    191 G4MoleculeTable::CreateConfiguration(const G4String& userIdentifier,
175                                      G4Molecul    192                                      G4MoleculeDefinition* molDef)
176 {                                                 193 {
177   bool alreadyCreated(false);                     194   bool alreadyCreated(false);
178                                                   195 
179   G4MolecularConfiguration* molConf =             196   G4MolecularConfiguration* molConf =
180       G4MolecularConfiguration::CreateMolecula    197       G4MolecularConfiguration::CreateMolecularConfiguration(userIdentifier,
181                                                   198                                                              molDef,
182                                                   199                                                              alreadyCreated);
183                                                   200 
184   return molConf;                                 201   return molConf;
185 }                                                 202 }
186                                                   203 
187 //--------------------------------------------    204 //------------------------------------------------------------------------------
188                                                   205 
189 G4MolecularConfiguration*                         206 G4MolecularConfiguration*
190 G4MoleculeTable::CreateConfiguration(const G4S    207 G4MoleculeTable::CreateConfiguration(const G4String& userIdentifier,
191                                      G4Molecul    208                                      G4MoleculeDefinition* molDef,
192                                      const G4S    209                                      const G4String& configurationLabel,
193                                      int charg    210                                      int charge)
194 {                                                 211 {
195   bool alreadyCreated(false);                     212   bool alreadyCreated(false);
196                                                   213 
197   G4MolecularConfiguration* molConf =             214   G4MolecularConfiguration* molConf =
198       G4MolecularConfiguration::CreateMolecula    215       G4MolecularConfiguration::CreateMolecularConfiguration(userIdentifier,
199                                                   216                                                              molDef,
200                                                   217                                                              charge,
201                                                   218                                                              configurationLabel,
202                                                   219                                                              alreadyCreated);
203                                                   220 
204   return molConf;                                 221   return molConf;
205 }                                                 222 }
206                                                   223 
207 //--------------------------------------------    224 //------------------------------------------------------------------------------
208                                                   225 
209 G4MolecularConfiguration*                         226 G4MolecularConfiguration*
210 G4MoleculeTable::CreateConfiguration(const G4S    227 G4MoleculeTable::CreateConfiguration(const G4String& userIdentifier,
211                                      G4Molecul    228                                      G4MoleculeDefinition* molDef,
212                                      int charg    229                                      int charge,
213                                      double di    230                                      double diffusion_coefficient)
214 {                                                 231 {
215   bool alreadyCreated(false);                     232   bool alreadyCreated(false);
216                                                   233 
217   G4MolecularConfiguration* molConf =             234   G4MolecularConfiguration* molConf =
218         G4MolecularConfiguration::CreateMolecu    235         G4MolecularConfiguration::CreateMolecularConfiguration(userIdentifier,
219                                                   236                                                                molDef,
220                                                   237                                                                charge,
221                                                   238                                                                userIdentifier,
222                                                   239                                                                alreadyCreated);
223                                                   240 
224   if(diffusion_coefficient!=-1) // TODO           241   if(diffusion_coefficient!=-1) // TODO
225   {                                               242   {
226     molConf->SetDiffusionCoefficient(diffusion    243     molConf->SetDiffusionCoefficient(diffusion_coefficient);
227   }                                               244   }
228   return molConf;                                 245   return molConf;
229 }                                                 246 }
230                                                   247 
231 //--------------------------------------------    248 //------------------------------------------------------------------------------
232                                                   249 
233 G4MolecularConfiguration*                         250 G4MolecularConfiguration*
234 G4MoleculeTable::CreateConfiguration(const G4S    251 G4MoleculeTable::CreateConfiguration(const G4String& userIdentifier,
235                                      const G4M    252                                      const G4MoleculeDefinition* molDef,
236                                      const G4S    253                                      const G4String& configurationLabel,
237                                      const G4E    254                                      const G4ElectronOccupancy& eOcc)
238 {                                                 255 {
239   bool alreadyCreated(false);                     256   bool alreadyCreated(false);
240                                                   257 
241   G4MolecularConfiguration* molConf =             258   G4MolecularConfiguration* molConf =
242       G4MolecularConfiguration::CreateMolecula    259       G4MolecularConfiguration::CreateMolecularConfiguration(userIdentifier,
243                                                   260                                                              molDef,
244                                                   261                                                              configurationLabel,
245                                                   262                                                              eOcc,
246                                                   263                                                              alreadyCreated);
247                                                   264 
248   return molConf;                                 265   return molConf;
249 }                                                 266 }
250                                                   267 
251 //--------------------------------------------    268 //------------------------------------------------------------------------------
252                                                   269 
253 void G4MoleculeTable::Finalize()                  270 void G4MoleculeTable::Finalize()
254 {                                                 271 {
255   G4MolecularConfiguration::FinalizeAll();        272   G4MolecularConfiguration::FinalizeAll();
256 }                                                 273 }
257                                                   274 
258 //-------------------------------------------- << 
259                                                << 
260 G4ConfigurationIterator G4MoleculeTable::GetCo    275 G4ConfigurationIterator G4MoleculeTable::GetConfigurationIterator()
261 {                                                 276 {
262   return G4ConfigurationIterator(G4MolecularCo    277   return G4ConfigurationIterator(G4MolecularConfiguration::GetUserIDTable());
263 }                                                 278 }
264                                                << 
265 //-------------------------------------------- << 
266                                                   279 
267 int G4MoleculeTable::GetNumberOfDefinedSpecies    280 int G4MoleculeTable::GetNumberOfDefinedSpecies()
268 {                                                 281 {
269   return G4MolecularConfiguration::GetNumberOf    282   return G4MolecularConfiguration::GetNumberOfSpecies();
270 }                                                 283 }
271                                                   284