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

  1 //
  2 // ********************************************************************
  3 // * License and Disclaimer                                           *
  4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.                             *
 10 // *                                                                  *
 11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                                                  *
 18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // ********************************************************************
 25 //
 26 //
 27 // ----------------------------------------------------------------------
 28 //      GEANT 4 class implementation file
 29 //
 30 //      21 Oct 2009 first implementation by A. Mantero and M.Karamitros
 31 //                  Based on prototype of A.Mantero
 32 // **********************************************************************
 33 
 34 #include "G4MoleculeDefinition.hh"
 35 #include "G4MolecularConfiguration.hh"
 36 #include "G4MoleculeTable.hh"
 37 #include "G4Serialize.hh"
 38 
 39 using namespace std;
 40 
 41 // -----------------------------------------------------------------------------
 42 // ###                          MoleculeDefinition                           ###
 43 // -----------------------------------------------------------------------------
 44 
 45 G4MoleculeDefinition::G4MoleculeDefinition(const G4String& name,
 46                                            G4double mass,
 47                                            G4double diffCoeff,
 48                                            G4int charge,
 49                                            G4int electronicLevels,
 50                                            G4double radius,
 51                                            G4int atomsNumber,
 52                                            G4double lifetime,
 53                                            const G4String& aType,
 54                                            G4FakeParticleID ID) :
 55     G4ParticleDefinition(name, mass, 0., charge, 0, 0, 0, 0, 0, 0, "Molecule",
 56                          0, 0, ID, false, lifetime, nullptr, false, aType, 0, 0.0),
 57     fDiffusionCoefficient(diffCoeff),
 58     fAtomsNb(atomsNumber),
 59     fVanDerVaalsRadius(radius)
 60 
 61 {
 62   fCharge = charge;
 63   if(electronicLevels != 0)
 64   {
 65     fElectronOccupancy = new G4ElectronOccupancy(electronicLevels);
 66   }
 67   else
 68   {
 69     fElectronOccupancy = nullptr;
 70   }
 71   fDecayTable = nullptr;
 72   G4MoleculeTable::Instance()->Insert(this);
 73 }
 74 
 75 G4MoleculeDefinition* G4MoleculeDefinition::Load(std::istream& in)
 76 {
 77   G4String name;
 78   G4double mass;
 79   G4double diffCoeff;
 80   G4int charge;
 81   G4int electronicLevels;
 82   G4double radius;
 83   G4int atomsNumber;
 84   G4double lifetime;
 85   G4String aType;
 86 
 87   READ(in,name);
 88   READ(in,mass);
 89   READ(in,diffCoeff);
 90   READ(in,charge);
 91   READ(in,electronicLevels);
 92   READ(in,radius);
 93   READ(in,atomsNumber);
 94   READ(in,lifetime);
 95   READ(in,aType);
 96 
 97   return new G4MoleculeDefinition(name,
 98                                   mass,
 99                                   diffCoeff,
100                                   charge,
101                                   electronicLevels,
102                                   radius,
103                                   atomsNumber,
104                                   lifetime,
105                                   aType);
106 }
107 
108 void G4MoleculeDefinition::Serialize(std::ostream& out)
109 {
110   WRITE(out,this->G4ParticleDefinition::GetParticleName());
111   WRITE(out,this->G4ParticleDefinition::GetPDGMass());
112   WRITE(out,this->G4ParticleDefinition::GetPDGLifeTime());
113   WRITE(out,this->G4ParticleDefinition::GetParticleType());
114   WRITE(out,fDiffusionCoefficient);
115   WRITE(out,fCharge);
116   if(fElectronOccupancy != nullptr)
117   {
118     WRITE(out,fElectronOccupancy->GetSizeOfOrbit());
119   }
120   else
121   {
122     WRITE(out,(G4int) 0);
123   }
124   WRITE(out,fVanDerVaalsRadius);
125   WRITE(out,fAtomsNb);
126 }
127 
128 //______________________________________________________________________________
129 
130 G4MoleculeDefinition::~G4MoleculeDefinition()
131 {
132   if (fElectronOccupancy != nullptr)
133   {
134     delete fElectronOccupancy;
135     fElectronOccupancy = nullptr;
136   }
137   if (fDecayTable != nullptr)
138   {
139     delete fDecayTable;
140     fDecayTable = nullptr;
141   }
142 }
143 
144 //___________________________________________________________________________
145 
146 G4MolecularConfiguration*
147  G4MoleculeDefinition::NewConfiguration(const G4String& molConfLabel)
148 {
149   bool alreadyExist(false);
150   return G4MolecularConfiguration::CreateMolecularConfiguration(GetName()+"_"+
151                                                                 molConfLabel,
152                                                                 this,
153                                                                 molConfLabel,
154                                                                 alreadyExist);
155 }
156 
157 //___________________________________________________________________________
158 
159 G4MolecularConfiguration*
160 G4MoleculeDefinition::GetConfigurationWithLabel(const G4String& molecularConfLabel)
161 {
162   return G4MolecularConfiguration::GetMolecularConfiguration(this,
163                                                              molecularConfLabel);
164 }
165 
166 //______________________________________________________________________________
167 
168 G4MolecularConfiguration*
169 G4MoleculeDefinition::
170   NewConfigurationWithElectronOccupancy(const G4String& exStId,
171                                         const G4ElectronOccupancy& elecConf,
172                                         G4double decayTime)
173 {
174   G4bool alreadyExist(false);
175   G4MolecularConfiguration* conf =
176       G4MolecularConfiguration::CreateMolecularConfiguration(GetName()+"_"+
177                                                              exStId,
178                                                              this,
179                                                              exStId,
180                                                              elecConf,
181                                                              alreadyExist);
182 
183   conf->SetDecayTime(decayTime);
184 
185   return conf;
186 }
187 
188 //______________________________________________________________________________
189 
190 void G4MoleculeDefinition::SetLevelOccupation(G4int shell, G4int eNb)
191 {
192   if(fElectronOccupancy != nullptr)
193   {
194     G4int levelOccupancy = fElectronOccupancy->GetOccupancy(shell);
195 
196     if(levelOccupancy != 0)
197     {
198 
199       fElectronOccupancy->RemoveElectron(shell, levelOccupancy);
200     }
201 
202     fElectronOccupancy->AddElectron(shell, eNb);
203   }
204 }
205 
206 //______________________________________________________________________________
207 
208 void G4MoleculeDefinition::AddDecayChannel(const G4String& molecularConfLabel,
209                                            const G4MolecularDissociationChannel* channel)
210 {
211   if(fDecayTable == nullptr)
212   {
213     fDecayTable = new G4MolecularDissociationTable();
214   }
215 
216   fDecayTable->AddChannel(G4MolecularConfiguration::GetMolecularConfiguration(this,
217                                                                               molecularConfLabel),
218                           channel);
219 }
220 
221 //______________________________________________________________________________
222 
223 void G4MoleculeDefinition::AddDecayChannel(const G4MolecularConfiguration* molConf,
224                                            const G4MolecularDissociationChannel* channel)
225 {
226   if (fDecayTable == nullptr)
227   {
228     fDecayTable = new G4MolecularDissociationTable();
229   }
230   fDecayTable->AddChannel(molConf, channel);
231 }
232 
233 //___________________________________________________________________________
234 
235 const vector<const G4MolecularDissociationChannel*>*
236 G4MoleculeDefinition::GetDecayChannels(const G4String& ExState) const
237 {
238   if (fDecayTable != nullptr)
239   {
240     const vector<const G4MolecularDissociationChannel*>* output =
241         fDecayTable->GetDecayChannels(ExState);
242     return output;
243   }
244   
245   G4ExceptionDescription errMsg;
246   errMsg <<  ": no Excited States and Decays for"
247          << GetName()
248          << " are defined.";
249   G4Exception("G4MoleculeDefinition::GetDecayChannels", "",
250               FatalErrorInArgument, errMsg);
251   return nullptr;
252 }
253 
254 //___________________________________________________________________________
255 
256 const vector<const G4MolecularDissociationChannel*>*
257 G4MoleculeDefinition::GetDecayChannels(const G4MolecularConfiguration* conf)
258   const
259 {
260   if(fDecayTable != nullptr)
261   {
262     const vector<const G4MolecularDissociationChannel*>* output =
263         fDecayTable->GetDecayChannels(conf);
264     return output;
265   }
266 //  else
267 //  {
268 //    G4ExceptionDescription errMsg;
269 //    errMsg << ": no Excited States and Decays for"
270 //           << GetName()
271 //           << " are defined.";
272 //    G4Exception("G4MoleculeDefinition::GetDecayChannels",
273 //                "",
274 //                FatalErrorInArgument,
275 //                errMsg);
276 //  }
277   return nullptr;
278 }
279 
280 //___________________________________________________________________________
281 
282 void G4MoleculeDefinition::Finalize()
283 {
284   G4MoleculeTable::Instance()->Finalize(this);
285 }
286 
287 //___________________________________________________________________________
288 
289 
290