Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/Geant4/G4ElectronOccupancy.hh was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // G4ElectronOccupancy
0027 //
0028 // Class description:
0029 //
0030 // This class has information of occupation of electrons in atomic orbits.
0031 // GetOccupancy(N) gives the number of electron in N-th orbit
0032 //    For example : Carbon atom should be
0033 //          GetOccupancy(0)      --> 2
0034 //          GetOccupancy(1)      --> 4
0035 //          GetOccupancy(2..7)   --> 0
0036 //
0037 // GetTotalOccupancy() gives the total number of electrons
0038 
0039 // Author: Hisaya Kurashige, 17 Aug 1999
0040 // --------------------------------------------------------------------
0041 #ifndef G4ElectronOccupancy_hh
0042 #define G4ElectronOccupancy_hh 1
0043 
0044 #include "G4Allocator.hh"
0045 #include "G4ios.hh"
0046 #include "globals.hh"
0047 
0048 #include "pwdefs.hh"
0049 
0050 class G4ElectronOccupancy
0051 {
0052   public:
0053     enum
0054     {
0055       MaxSizeOfOrbit = 20
0056     };
0057 
0058     G4ElectronOccupancy(G4int sizeOrbit = MaxSizeOfOrbit);
0059     G4ElectronOccupancy(const G4ElectronOccupancy& right);
0060 
0061     virtual ~G4ElectronOccupancy();
0062 
0063     // new/delete operators are overloaded to use G4Allocator
0064     inline void* operator new(size_t);
0065     inline void operator delete(void* aElectronOccupancy);
0066 
0067     G4ElectronOccupancy& operator=(const G4ElectronOccupancy& right);
0068     G4bool operator==(const G4ElectronOccupancy& right) const;
0069     G4bool operator!=(const G4ElectronOccupancy& right) const;
0070 
0071     inline G4int GetTotalOccupancy() const;
0072     inline G4int GetOccupancy(G4int orbit) const;
0073     // The following methods returns
0074     //     0:  if the orbit(atom) is vacant
0075     //    >0:  number of electrons in orbit
0076 
0077     G4int AddElectron(G4int orbit, G4int number = 1);
0078     G4int RemoveElectron(G4int orbit, G4int number = 1);
0079 
0080     inline G4int GetSizeOfOrbit() const;
0081     void DumpInfo() const;
0082 
0083   private:
0084     G4int theSizeOfOrbit = 0;
0085     G4int theTotalOccupancy = 0;
0086     G4int* theOccupancies = nullptr;
0087 };
0088 
0089 extern G4PART_DLL G4Allocator<G4ElectronOccupancy>*& aElectronOccupancyAllocator();
0090 
0091 // ------------------------
0092 // Inline methods
0093 // ------------------------
0094 
0095 inline void* G4ElectronOccupancy::operator new(size_t)
0096 {
0097   if (aElectronOccupancyAllocator() == nullptr) {
0098     aElectronOccupancyAllocator() = new G4Allocator<G4ElectronOccupancy>;
0099   }
0100   return (void*)aElectronOccupancyAllocator()->MallocSingle();
0101 }
0102 
0103 inline void G4ElectronOccupancy::operator delete(void* aElectronOccupancy)
0104 {
0105   aElectronOccupancyAllocator()->FreeSingle((G4ElectronOccupancy*)aElectronOccupancy);
0106 }
0107 
0108 inline G4int G4ElectronOccupancy::GetSizeOfOrbit() const
0109 {
0110   return theSizeOfOrbit;
0111 }
0112 
0113 inline G4int G4ElectronOccupancy::GetTotalOccupancy() const
0114 {
0115   return theTotalOccupancy;
0116 }
0117 
0118 inline G4int G4ElectronOccupancy::GetOccupancy(G4int orbit) const
0119 {
0120   G4int value = 0;
0121   if ((orbit >= 0) && (orbit < theSizeOfOrbit)) {
0122     value = theOccupancies[orbit];
0123   }
0124   return value;
0125 }
0126 
0127 #endif