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