G4ElectronOccupancy.hh

Go to the documentation of this file.
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 // $Id$
00028 //
00029 // 
00030 // ------------------------------------------------------------
00031 //      GEANT 4 class header file
00032 //
00033 //      History: first implementation, based on object model of
00034 //      Hisaya Kurashige, 17 Aug 1999
00035 // ----------------------------------------------------------------
00036 // Class Description
00037 //     This class has information of occupation of electrons 
00038 //     in atomic orbits
00039 // -  
00040 //     GetOccupancy(N) gives the number of electron
00041 //     in N-th orbit
00042 //       For example : Carbon atom should be 
00043 //          GetOccupancy(0)      --> 2
00044 //          GetOccupancy(1)      --> 4
00045 //          GetOccupancy(2..7)   --> 0
00046 // -
00047 //     GetTotalOccupancy() gives the total number of electrons
00048 //
00049 // --------------------------------------------------------------- 
00050 
00051 
00052 
00053 #ifndef G4ElectronOccupancy_h
00054 #define G4ElectronOccupancy_h 1
00055 
00056 #include "globals.hh"
00057 #include "G4Allocator.hh"
00058 #include "G4ios.hh"
00059 
00060 class G4ElectronOccupancy 
00061 {
00062  public:
00063    enum { MaxSizeOfOrbit = 10};
00064 
00065  public: // With Description
00066    G4ElectronOccupancy( G4int sizeOrbit = MaxSizeOfOrbit   );
00067    G4ElectronOccupancy( const G4ElectronOccupancy& right );
00068 
00069  public:
00070    virtual             ~G4ElectronOccupancy();
00071 
00072   //  new/delete operators are oberloded to use G4Allocator
00073      inline void *operator new(size_t);
00074      inline void operator delete(void *aElectronOccupancy);
00075 
00076  
00077   //- operators
00078      G4ElectronOccupancy & operator=(const G4ElectronOccupancy &right);
00079      G4int operator==(const G4ElectronOccupancy &right) const;
00080      G4int operator!=(const G4ElectronOccupancy &right) const;
00081    
00082  public: // With Description
00083    // The following methods returns
00084    //     0:  if the orbit(atom) is vacant 
00085    //    >0:  number of electrons in orbit
00086    G4int  GetTotalOccupancy() const;
00087    G4int  GetOccupancy(G4int orbit) const;
00088  
00089    //
00090    G4int  AddElectron(G4int orbit, G4int number = 1);
00091    G4int  RemoveElectron(G4int orbit, G4int number = 1);
00092    
00093    G4int  GetSizeOfOrbit() const;
00094    void   DumpInfo() const;
00095 
00096  private:
00097    G4int  theSizeOfOrbit;
00098    G4int  theTotalOccupancy;
00099    G4int* theOccupancies;
00100 
00101 };
00102 
00103 #if defined G4PARTICLES_ALLOC_EXPORT
00104   extern G4DLLEXPORT G4Allocator<G4ElectronOccupancy> aElectronOccupancyAllocator;
00105 #else
00106   extern G4DLLIMPORT G4Allocator<G4ElectronOccupancy> aElectronOccupancyAllocator;
00107 #endif
00108 
00109 // ------------------------
00110 // Inlined operators
00111 // ------------------------
00112 
00113 inline void * G4ElectronOccupancy::operator new(size_t)
00114 {
00115   void * aElectronOccupancy;
00116   aElectronOccupancy = (void *) aElectronOccupancyAllocator.MallocSingle();
00117   return aElectronOccupancy;
00118 }
00119 
00120 inline void G4ElectronOccupancy::operator delete(void * aElectronOccupancy)
00121 {
00122   aElectronOccupancyAllocator.FreeSingle((G4ElectronOccupancy *) aElectronOccupancy);
00123 }
00124 
00125 inline
00126  G4int  G4ElectronOccupancy::GetSizeOfOrbit() const
00127 {
00128   return  theSizeOfOrbit;
00129 }
00130 
00131 inline
00132  G4int G4ElectronOccupancy::GetTotalOccupancy() const
00133 {
00134   return  theTotalOccupancy;
00135 }
00136 
00137 inline
00138  G4int  G4ElectronOccupancy::GetOccupancy(G4int orbit) const
00139 {
00140   G4int value = 0;
00141   if ((orbit >=0)&&(orbit<theSizeOfOrbit)){
00142     value = theOccupancies[orbit];
00143   }
00144   return value;  
00145 }
00146 
00147 inline 
00148  G4int  G4ElectronOccupancy::AddElectron(G4int orbit, G4int number)
00149 {
00150   G4int value =0;
00151   if ((orbit >=0)&&(orbit<theSizeOfOrbit)){
00152     theOccupancies[orbit] += number;
00153     theTotalOccupancy += number; 
00154     value = number;   
00155   }
00156   return value;
00157 }
00158 
00159 inline 
00160  G4int  G4ElectronOccupancy::RemoveElectron(G4int orbit, G4int number)
00161 {
00162   G4int value =0;
00163   if ((orbit >=0)&&(orbit<theSizeOfOrbit) ){
00164     if ( theOccupancies[orbit] < number ) number = theOccupancies[orbit];
00165     theOccupancies[orbit] -= number;
00166     theTotalOccupancy -= number;    
00167     value = number;
00168   }
00169   return value;
00170 }
00171 #endif
00172 
00173 
00174 
00175 
00176 
00177 

Generated on Mon May 27 17:48:07 2013 for Geant4 by  doxygen 1.4.7