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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/molecules/management/src/G4MoleculeDefinition.cc (Version 11.3.0) and /processes/electromagnetic/dna/molecules/management/src/G4MoleculeDefinition.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 // -------------------------------------------     27 // ----------------------------------------------------------------------
 28 //      GEANT 4 class implementation file          28 //      GEANT 4 class implementation file
 29 //                                                 29 //
 30 //      21 Oct 2009 first implementation by A.     30 //      21 Oct 2009 first implementation by A. Mantero and M.Karamitros
 31 //                  Based on prototype of A.Ma     31 //                  Based on prototype of A.Mantero
 32 // *******************************************     32 // **********************************************************************
 33                                                    33 
 34 #include "G4MoleculeDefinition.hh"                 34 #include "G4MoleculeDefinition.hh"
 35 #include "G4MolecularConfiguration.hh"             35 #include "G4MolecularConfiguration.hh"
 36 #include "G4MoleculeTable.hh"                      36 #include "G4MoleculeTable.hh"
 37 #include "G4Serialize.hh"                          37 #include "G4Serialize.hh"
 38                                                    38 
 39 using namespace std;                               39 using namespace std;
 40                                                    40 
 41 // -------------------------------------------     41 // -----------------------------------------------------------------------------
 42 // ###                          MoleculeDefini     42 // ###                          MoleculeDefinition                           ###
 43 // -------------------------------------------     43 // -----------------------------------------------------------------------------
 44                                                    44 
 45 G4MoleculeDefinition::G4MoleculeDefinition(con     45 G4MoleculeDefinition::G4MoleculeDefinition(const G4String& name,
 46                                            G4d     46                                            G4double mass,
 47                                            G4d     47                                            G4double diffCoeff,
 48                                            G4i     48                                            G4int charge,
 49                                            G4i     49                                            G4int electronicLevels,
 50                                            G4d     50                                            G4double radius,
 51                                            G4i     51                                            G4int atomsNumber,
 52                                            G4d     52                                            G4double lifetime,
 53                                            con <<  53                                            G4String aType,
 54                                            G4F     54                                            G4FakeParticleID ID) :
 55     G4ParticleDefinition(name, mass, 0., charg     55     G4ParticleDefinition(name, mass, 0., charge, 0, 0, 0, 0, 0, 0, "Molecule",
 56                          0, 0, ID, false, life <<  56                          0, 0, ID, false, lifetime, NULL, false, aType, 0, 0.0),
 57     fDiffusionCoefficient(diffCoeff),              57     fDiffusionCoefficient(diffCoeff),
 58     fAtomsNb(atomsNumber),                         58     fAtomsNb(atomsNumber),
 59     fVanDerVaalsRadius(radius)                     59     fVanDerVaalsRadius(radius)
 60                                                    60 
 61 {                                                  61 {
 62   fCharge = charge;                                62   fCharge = charge;
 63   if(electronicLevels != 0)                    <<  63   if(electronicLevels)
 64   {                                                64   {
 65     fElectronOccupancy = new G4ElectronOccupan     65     fElectronOccupancy = new G4ElectronOccupancy(electronicLevels);
 66   }                                                66   }
 67   else                                             67   else
 68   {                                                68   {
 69     fElectronOccupancy = nullptr;              <<  69     fElectronOccupancy = 0;
 70   }                                                70   }
 71   fDecayTable = nullptr;                       <<  71   fDecayTable = NULL;
 72   G4MoleculeTable::Instance()->Insert(this);       72   G4MoleculeTable::Instance()->Insert(this);
 73 }                                                  73 }
 74                                                    74 
 75 G4MoleculeDefinition* G4MoleculeDefinition::Lo     75 G4MoleculeDefinition* G4MoleculeDefinition::Load(std::istream& in)
 76 {                                                  76 {
 77   G4String name;                                   77   G4String name;
 78   G4double mass;                                   78   G4double mass;
 79   G4double diffCoeff;                              79   G4double diffCoeff;
 80   G4int charge;                                    80   G4int charge;
 81   G4int electronicLevels;                          81   G4int electronicLevels;
 82   G4double radius;                                 82   G4double radius;
 83   G4int atomsNumber;                               83   G4int atomsNumber;
 84   G4double lifetime;                               84   G4double lifetime;
 85   G4String aType;                                  85   G4String aType;
 86                                                    86 
 87   READ(in,name);                                   87   READ(in,name);
 88   READ(in,mass);                                   88   READ(in,mass);
 89   READ(in,diffCoeff);                              89   READ(in,diffCoeff);
 90   READ(in,charge);                                 90   READ(in,charge);
 91   READ(in,electronicLevels);                       91   READ(in,electronicLevels);
 92   READ(in,radius);                                 92   READ(in,radius);
 93   READ(in,atomsNumber);                            93   READ(in,atomsNumber);
 94   READ(in,lifetime);                               94   READ(in,lifetime);
 95   READ(in,aType);                                  95   READ(in,aType);
 96                                                    96 
 97   return new G4MoleculeDefinition(name,            97   return new G4MoleculeDefinition(name,
 98                                   mass,            98                                   mass,
 99                                   diffCoeff,       99                                   diffCoeff,
100                                   charge,         100                                   charge,
101                                   electronicLe    101                                   electronicLevels,
102                                   radius,         102                                   radius,
103                                   atomsNumber,    103                                   atomsNumber,
104                                   lifetime,       104                                   lifetime,
105                                   aType);         105                                   aType);
106 }                                                 106 }
107                                                   107 
108 void G4MoleculeDefinition::Serialize(std::ostr    108 void G4MoleculeDefinition::Serialize(std::ostream& out)
109 {                                                 109 {
110   WRITE(out,this->G4ParticleDefinition::GetPar    110   WRITE(out,this->G4ParticleDefinition::GetParticleName());
111   WRITE(out,this->G4ParticleDefinition::GetPDG    111   WRITE(out,this->G4ParticleDefinition::GetPDGMass());
112   WRITE(out,this->G4ParticleDefinition::GetPDG    112   WRITE(out,this->G4ParticleDefinition::GetPDGLifeTime());
113   WRITE(out,this->G4ParticleDefinition::GetPar    113   WRITE(out,this->G4ParticleDefinition::GetParticleType());
114   WRITE(out,fDiffusionCoefficient);               114   WRITE(out,fDiffusionCoefficient);
115   WRITE(out,fCharge);                             115   WRITE(out,fCharge);
116   if(fElectronOccupancy != nullptr)            << 116   if(fElectronOccupancy)
117   {                                               117   {
118     WRITE(out,fElectronOccupancy->GetSizeOfOrb    118     WRITE(out,fElectronOccupancy->GetSizeOfOrbit());
119   }                                               119   }
120   else                                            120   else
121   {                                               121   {
122     WRITE(out,(G4int) 0);                      << 122     WRITE(out,(int) 0);
123   }                                               123   }
124   WRITE(out,fVanDerVaalsRadius);                  124   WRITE(out,fVanDerVaalsRadius);
125   WRITE(out,fAtomsNb);                            125   WRITE(out,fAtomsNb);
126 }                                                 126 }
127                                                   127 
128 //____________________________________________    128 //______________________________________________________________________________
129                                                   129 
130 G4MoleculeDefinition::~G4MoleculeDefinition()     130 G4MoleculeDefinition::~G4MoleculeDefinition()
131 {                                                 131 {
132   if (fElectronOccupancy != nullptr)           << 132   if (fElectronOccupancy)
133   {                                               133   {
134     delete fElectronOccupancy;                    134     delete fElectronOccupancy;
135     fElectronOccupancy = nullptr;              << 135     fElectronOccupancy = 0;
136   }                                               136   }
137   if (fDecayTable != nullptr)                  << 137   if (fDecayTable)
138   {                                               138   {
139     delete fDecayTable;                           139     delete fDecayTable;
140     fDecayTable = nullptr;                     << 140     fDecayTable = 0;
141   }                                               141   }
142 }                                                 142 }
143                                                   143 
144 //____________________________________________    144 //___________________________________________________________________________
145                                                   145 
146 G4MolecularConfiguration*                         146 G4MolecularConfiguration*
147  G4MoleculeDefinition::NewConfiguration(const     147  G4MoleculeDefinition::NewConfiguration(const G4String& molConfLabel)
148 {                                                 148 {
149   bool alreadyExist(false);                       149   bool alreadyExist(false);
150   return G4MolecularConfiguration::CreateMolec    150   return G4MolecularConfiguration::CreateMolecularConfiguration(GetName()+"_"+
151                                                   151                                                                 molConfLabel,
152                                                   152                                                                 this,
153                                                   153                                                                 molConfLabel,
154                                                   154                                                                 alreadyExist);
155 }                                                 155 }
156                                                   156 
157 //____________________________________________    157 //___________________________________________________________________________
158                                                   158 
159 G4MolecularConfiguration*                         159 G4MolecularConfiguration*
160 G4MoleculeDefinition::GetConfigurationWithLabe    160 G4MoleculeDefinition::GetConfigurationWithLabel(const G4String& molecularConfLabel)
161 {                                                 161 {
162   return G4MolecularConfiguration::GetMolecula    162   return G4MolecularConfiguration::GetMolecularConfiguration(this,
163                                                   163                                                              molecularConfLabel);
164 }                                                 164 }
165                                                   165 
166 //____________________________________________    166 //______________________________________________________________________________
167                                                   167 
168 G4MolecularConfiguration*                         168 G4MolecularConfiguration*
169 G4MoleculeDefinition::                            169 G4MoleculeDefinition::
170   NewConfigurationWithElectronOccupancy(const     170   NewConfigurationWithElectronOccupancy(const G4String& exStId,
171                                         const     171                                         const G4ElectronOccupancy& elecConf,
172                                         G4doub << 172                                         double decayTime)
173 {                                                 173 {
174   G4bool alreadyExist(false);                  << 174   bool alreadyExist(false);
175   G4MolecularConfiguration* conf =                175   G4MolecularConfiguration* conf =
176       G4MolecularConfiguration::CreateMolecula    176       G4MolecularConfiguration::CreateMolecularConfiguration(GetName()+"_"+
177                                                   177                                                              exStId,
178                                                   178                                                              this,
179                                                   179                                                              exStId,
180                                                   180                                                              elecConf,
181                                                   181                                                              alreadyExist);
182                                                   182 
183   conf->SetDecayTime(decayTime);                  183   conf->SetDecayTime(decayTime);
184                                                   184 
185   return conf;                                    185   return conf;
186 }                                                 186 }
187                                                   187 
188 //____________________________________________    188 //______________________________________________________________________________
189                                                   189 
190 void G4MoleculeDefinition::SetLevelOccupation(    190 void G4MoleculeDefinition::SetLevelOccupation(G4int shell, G4int eNb)
191 {                                                 191 {
192   if(fElectronOccupancy != nullptr)            << 192   if(fElectronOccupancy)
193   {                                               193   {
194     G4int levelOccupancy = fElectronOccupancy-    194     G4int levelOccupancy = fElectronOccupancy->GetOccupancy(shell);
195                                                   195 
196     if(levelOccupancy != 0)                    << 196     if(levelOccupancy)
197     {                                             197     {
198                                                   198 
199       fElectronOccupancy->RemoveElectron(shell    199       fElectronOccupancy->RemoveElectron(shell, levelOccupancy);
200     }                                             200     }
201                                                   201 
202     fElectronOccupancy->AddElectron(shell, eNb    202     fElectronOccupancy->AddElectron(shell, eNb);
203   }                                               203   }
204 }                                                 204 }
205                                                   205 
206 //____________________________________________    206 //______________________________________________________________________________
207                                                   207 
208 void G4MoleculeDefinition::AddDecayChannel(con    208 void G4MoleculeDefinition::AddDecayChannel(const G4String& molecularConfLabel,
209                                            con    209                                            const G4MolecularDissociationChannel* channel)
210 {                                                 210 {
211   if(fDecayTable == nullptr)                   << 211   if(!fDecayTable)
212   {                                               212   {
213     fDecayTable = new G4MolecularDissociationT    213     fDecayTable = new G4MolecularDissociationTable();
214   }                                               214   }
215                                                   215 
216   fDecayTable->AddChannel(G4MolecularConfigura    216   fDecayTable->AddChannel(G4MolecularConfiguration::GetMolecularConfiguration(this,
217                                                   217                                                                               molecularConfLabel),
218                           channel);               218                           channel);
219 }                                                 219 }
220                                                   220 
221 //____________________________________________    221 //______________________________________________________________________________
222                                                   222 
223 void G4MoleculeDefinition::AddDecayChannel(con    223 void G4MoleculeDefinition::AddDecayChannel(const G4MolecularConfiguration* molConf,
224                                            con    224                                            const G4MolecularDissociationChannel* channel)
225 {                                                 225 {
226   if (fDecayTable == nullptr)                  << 226   if (!fDecayTable)
227   {                                               227   {
228     fDecayTable = new G4MolecularDissociationT    228     fDecayTable = new G4MolecularDissociationTable();
229   }                                               229   }
230   fDecayTable->AddChannel(molConf, channel);      230   fDecayTable->AddChannel(molConf, channel);
231 }                                                 231 }
232                                                   232 
233 //____________________________________________    233 //___________________________________________________________________________
234                                                   234 
235 const vector<const G4MolecularDissociationChan    235 const vector<const G4MolecularDissociationChannel*>*
236 G4MoleculeDefinition::GetDecayChannels(const G    236 G4MoleculeDefinition::GetDecayChannels(const G4String& ExState) const
237 {                                                 237 {
238   if (fDecayTable != nullptr)                  << 238   if (fDecayTable)
239   {                                               239   {
240     const vector<const G4MolecularDissociation    240     const vector<const G4MolecularDissociationChannel*>* output =
241         fDecayTable->GetDecayChannels(ExState)    241         fDecayTable->GetDecayChannels(ExState);
242     return output;                                242     return output;
243   }                                               243   }
244                                                << 244   else
245   G4ExceptionDescription errMsg;               << 245   {
246   errMsg <<  ": no Excited States and Decays f << 246     G4ExceptionDescription errMsg;
247          << GetName()                          << 247     errMsg <<  ": no Excited States and Decays for"
248          << " are defined.";                   << 248            << GetName()
249   G4Exception("G4MoleculeDefinition::GetDecayC << 249            << " are defined.";
250               FatalErrorInArgument, errMsg);   << 250     G4Exception("G4MoleculeDefinition::GetDecayChannels", "",
251   return nullptr;                              << 251                 FatalErrorInArgument, errMsg);
                                                   >> 252   }
                                                   >> 253   return 0;
252 }                                                 254 }
253                                                   255 
254 //____________________________________________    256 //___________________________________________________________________________
255                                                   257 
256 const vector<const G4MolecularDissociationChan    258 const vector<const G4MolecularDissociationChannel*>*
257 G4MoleculeDefinition::GetDecayChannels(const G    259 G4MoleculeDefinition::GetDecayChannels(const G4MolecularConfiguration* conf)
258   const                                           260   const
259 {                                                 261 {
260   if(fDecayTable != nullptr)                   << 262   if(fDecayTable)
261   {                                               263   {
262     const vector<const G4MolecularDissociation    264     const vector<const G4MolecularDissociationChannel*>* output =
263         fDecayTable->GetDecayChannels(conf);      265         fDecayTable->GetDecayChannels(conf);
264     return output;                                266     return output;
265   }                                               267   }
266 //  else                                          268 //  else
267 //  {                                             269 //  {
268 //    G4ExceptionDescription errMsg;              270 //    G4ExceptionDescription errMsg;
269 //    errMsg << ": no Excited States and Decay    271 //    errMsg << ": no Excited States and Decays for"
270 //           << GetName()                         272 //           << GetName()
271 //           << " are defined.";                  273 //           << " are defined.";
272 //    G4Exception("G4MoleculeDefinition::GetDe    274 //    G4Exception("G4MoleculeDefinition::GetDecayChannels",
273 //                "",                             275 //                "",
274 //                FatalErrorInArgument,           276 //                FatalErrorInArgument,
275 //                errMsg);                        277 //                errMsg);
276 //  }                                             278 //  }
277   return nullptr;                              << 279   return 0;
278 }                                                 280 }
279                                                   281 
280 //____________________________________________    282 //___________________________________________________________________________
281                                                   283 
282 void G4MoleculeDefinition::Finalize()             284 void G4MoleculeDefinition::Finalize()
283 {                                                 285 {
284   G4MoleculeTable::Instance()->Finalize(this);    286   G4MoleculeTable::Instance()->Finalize(this);
285 }                                                 287 }
286                                                   288 
287 //____________________________________________    289 //___________________________________________________________________________
288                                                   290 
289                                                   291 
290                                                   292