00001 // 00002 // ******************************************************************** 00003 // * License and Disclaimer * 00004 // * * 00005 // * The Geant4 software is copyright of the Copyright Holders of * 00006 // * the Geant4 Collaboration. It is provided under the terms and * 00007 // * conditions of the Geant4 Software License, included in the file * 00008 // * LICENSE and available at http://cern.ch/geant4/license . These * 00009 // * include a list of copyright holders. * 00010 // * * 00011 // * Neither the authors of this software system, nor their employing * 00012 // * institutes,nor the agencies providing financial support for this * 00013 // * work make any representation or warranty, express or implied, * 00014 // * regarding this software system or assume any liability for its * 00015 // * use. Please see the license in the file LICENSE and URL above * 00016 // * for the full disclaimer and the limitation of liability. * 00017 // * * 00018 // * This code implementation is the result of the scientific and * 00019 // * technical work of the GEANT4 collaboration. * 00020 // * By using, copying, modifying or distributing the software (or * 00021 // * any work based on the software) you agree to acknowledge its * 00022 // * use in resulting scientific publications, and indicate your * 00023 // * acceptance of all terms of the Geant4 Software license. * 00024 // ******************************************************************** 00025 // 00026 // 00027 // Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr) 00028 // 00029 // WARNING : This class is released as a prototype. 00030 // It might strongly evolve or even disapear in the next releases. 00031 // 00032 // History: 00033 // ----------- 00034 // 10 Oct 2011 M.Karamitros created 00035 // 00036 // ------------------------------------------------------------------- 00037 00038 00039 #ifndef G4MolecularConfiguration_ 00040 #define G4MolecularConfiguration_ 1 00041 #include <G4MoleculeDefinition.hh> 00042 #include <map> 00043 #include <vector> 00044 #include <CLHEP/Utility/memory.h> 00045 00046 struct comparator; 00047 00048 class G4MolecularConfiguration; 00049 class G4MoleculeDefinition; 00050 class G4ElectronOccupancy; 00051 class G4MolecularDecayChannel; 00052 00059 class G4MolecularConfiguration 00060 { 00061 public : 00062 00064 // Static methods 00065 00066 // Get for a given moleculeDefinition and a given electronic configuration, the mol conf 00067 static G4MolecularConfiguration* GetMolecularConfiguration(const G4MoleculeDefinition*, 00068 const G4ElectronOccupancy& electronOccupancy); 00069 00070 // Get ground state electronic configuration 00071 static G4MolecularConfiguration* GetMolecularConfiguration(const G4MoleculeDefinition*); 00072 00073 // Release memory of the mol conf manager 00074 static void DeleteManager(); 00076 00077 // Methods 00078 const G4MoleculeDefinition* GetDefinition() const; 00079 00082 const G4String& GetName() const; 00083 00086 G4int GetAtomsNumber() const; 00087 00090 G4MolecularConfiguration* ExciteMolecule(G4int); 00091 00094 G4MolecularConfiguration* IonizeMolecule(G4int); 00095 00100 G4MolecularConfiguration* AddElectron(G4int orbit, G4int n =1); 00101 00104 G4MolecularConfiguration* RemoveElectron(G4int,G4int number=1); 00105 00108 G4MolecularConfiguration* MoveOneElectron(G4int /*orbit*/,G4int /*orbit*/); 00109 00112 G4double GetNbElectrons() const; 00113 00116 void PrintState() const; 00117 00118 const std::vector <const G4MolecularDecayChannel*>* GetDecayChannel() const; 00119 00120 G4int GetMoleculeID() const; 00121 00127 inline void SetDiffusionCoefficient(G4double); 00128 00131 inline G4double GetDiffusionCoefficient() const; 00132 00135 inline void SetDecayTime(G4double); 00136 00139 inline G4double GetDecayTime() const; 00140 00143 inline void SetVanDerVaalsRadius(G4double); 00144 inline G4double GetVanDerVaalsRadius() const ; 00145 00149 inline const G4ElectronOccupancy* GetElectronOccupancy() const; 00150 00153 inline G4int GetCharge() const; 00154 00157 inline void SetMass(G4double); 00158 00161 inline G4double GetMass() const; 00162 00163 protected : 00164 G4MolecularConfiguration(const G4MoleculeDefinition*, const G4ElectronOccupancy&); 00165 G4MolecularConfiguration(const G4MolecularConfiguration&); 00166 G4MolecularConfiguration & operator=(G4MolecularConfiguration &right); 00167 ~G4MolecularConfiguration(); 00168 G4MolecularConfiguration* ChangeConfiguration(const G4ElectronOccupancy& newElectronOccupancy); 00169 00170 const G4MoleculeDefinition* fMoleculeDefinition; 00171 const G4ElectronOccupancy* fElectronOccupancy; 00172 00173 struct G4MolecularConfigurationManager 00174 { 00175 G4MolecularConfigurationManager(){;} 00176 ~G4MolecularConfigurationManager(); 00177 00178 typedef std::map<const G4MoleculeDefinition*, std::map<G4ElectronOccupancy, G4MolecularConfiguration*, comparator> > MolecularConfigurationTable; 00179 MolecularConfigurationTable fTable; 00180 }; 00181 00182 static G4MolecularConfigurationManager* fgManager; 00183 00184 static G4MolecularConfigurationManager* GetManager(); 00185 00186 G4double fDynDiffusionCoefficient; 00187 G4double fDynVanDerVaalsRadius; 00188 G4double fDynDecayTime; 00189 G4double fDynMass; 00190 G4int fDynCharge; 00191 mutable G4String fName; // mutable allowed this member to be changed in const methods 00192 }; 00193 00194 struct comparator 00195 { 00196 bool operator() (const G4ElectronOccupancy& occ1, const G4ElectronOccupancy& occ2) const 00197 { 00198 // Since this method is called a lot of time, 00199 // we retrieve only once the totOcc 00200 G4int totalOcc1 = occ1.GetTotalOccupancy() ; 00201 G4int totalOcc2 = occ2.GetTotalOccupancy() ; 00202 if ( totalOcc1!= totalOcc2) 00203 { 00204 return totalOcc1<totalOcc2; 00205 } 00206 else 00207 { 00208 G4int occupancy1 = -1 ; 00209 G4int occupancy2 = -1 ; 00210 const G4int sizeOrbit = occ1.GetSizeOfOrbit() ; 00211 for (G4int i=0; i<occ1.GetSizeOfOrbit();) 00212 { 00213 // Since this method is called a lot of time, 00214 // we retrieve only once the Occ 00215 00216 occupancy1 = occ1.GetOccupancy(i); 00217 occupancy2 = occ2.GetOccupancy(i); 00218 00219 if (occupancy1 != occupancy2) 00220 { 00221 return occupancy1 < occupancy2; 00222 } 00223 else 00224 { 00225 i++; 00226 if (i >= sizeOrbit) return false; 00227 } 00228 } 00229 } 00230 return false; 00231 } 00232 }; 00233 00234 00235 inline const G4MoleculeDefinition* G4MolecularConfiguration::GetDefinition() const 00236 { 00237 return fMoleculeDefinition; 00238 } 00239 00240 inline const G4ElectronOccupancy* G4MolecularConfiguration::GetElectronOccupancy() const 00241 { 00242 return fElectronOccupancy ; 00243 } 00244 00245 inline void G4MolecularConfiguration::SetDiffusionCoefficient(G4double dynDiffusionCoefficient) 00246 { 00247 fDynDiffusionCoefficient = dynDiffusionCoefficient ; 00248 } 00249 00250 inline G4double G4MolecularConfiguration::GetDiffusionCoefficient() const 00251 { 00252 return fDynDiffusionCoefficient; 00253 } 00254 00255 inline void G4MolecularConfiguration::SetDecayTime(G4double dynDecayTime) 00256 { 00257 fDynDecayTime = dynDecayTime; 00258 } 00259 00260 inline G4double G4MolecularConfiguration::GetDecayTime() const 00261 { 00262 return fDynDecayTime; 00263 } 00264 00265 inline void G4MolecularConfiguration::SetVanDerVaalsRadius(G4double dynVanDerVaalsRadius) 00266 { 00267 fDynVanDerVaalsRadius = dynVanDerVaalsRadius ; 00268 } 00269 00270 inline G4double G4MolecularConfiguration::GetVanDerVaalsRadius() const 00271 { 00272 return fDynVanDerVaalsRadius; 00273 } 00274 00275 inline G4int G4MolecularConfiguration::GetCharge() const 00276 { 00277 return fDynCharge ; 00278 } 00279 00280 inline void G4MolecularConfiguration::SetMass(G4double aMass) 00281 { 00282 fDynMass = aMass ; 00283 } 00284 00285 inline G4double G4MolecularConfiguration::GetMass() const 00286 { 00287 return fDynMass; 00288 } 00289 #endif