Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4ElectronOccupancy.hh
Go to the documentation of this file.
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 // $Id$
28 //
29 //
30 // ------------------------------------------------------------
31 // GEANT 4 class header file
32 //
33 // History: first implementation, based on object model of
34 // Hisaya Kurashige, 17 Aug 1999
35 // ----------------------------------------------------------------
36 // Class Description
37 // This class has information of occupation of electrons
38 // in atomic orbits
39 // -
40 // GetOccupancy(N) gives the number of electron
41 // in N-th orbit
42 // For example : Carbon atom should be
43 // GetOccupancy(0) --> 2
44 // GetOccupancy(1) --> 4
45 // GetOccupancy(2..7) --> 0
46 // -
47 // GetTotalOccupancy() gives the total number of electrons
48 //
49 // ---------------------------------------------------------------
50 
51 
52 
53 #ifndef G4ElectronOccupancy_h
54 #define G4ElectronOccupancy_h 1
55 
56 #include "globals.hh"
57 #include "G4Allocator.hh"
58 #include "G4ios.hh"
59 
61 {
62  public:
63  enum { MaxSizeOfOrbit = 10};
64 
65  public: // With Description
68 
69  public:
70  virtual ~G4ElectronOccupancy();
71 
72  // new/delete operators are oberloded to use G4Allocator
73  inline void *operator new(size_t);
74  inline void operator delete(void *aElectronOccupancy);
75 
76 
77  //- operators
81 
82  public: // With Description
83  // The following methods returns
84  // 0: if the orbit(atom) is vacant
85  // >0: number of electrons in orbit
86  G4int GetTotalOccupancy() const;
87  G4int GetOccupancy(G4int orbit) const;
88 
89  //
90  G4int AddElectron(G4int orbit, G4int number = 1);
91  G4int RemoveElectron(G4int orbit, G4int number = 1);
92 
93  G4int GetSizeOfOrbit() const;
94  void DumpInfo() const;
95 
96  private:
97  G4int theSizeOfOrbit;
98  G4int theTotalOccupancy;
99  G4int* theOccupancies;
100 
101 };
102 
103 #if defined G4PARTICLES_ALLOC_EXPORT
105 #else
107 #endif
108 
109 // ------------------------
110 // Inlined operators
111 // ------------------------
112 
113 inline void * G4ElectronOccupancy::operator new(size_t)
114 {
115  void * aElectronOccupancy;
116  aElectronOccupancy = (void *) aElectronOccupancyAllocator.MallocSingle();
117  return aElectronOccupancy;
118 }
119 
120 inline void G4ElectronOccupancy::operator delete(void * aElectronOccupancy)
121 {
122  aElectronOccupancyAllocator.FreeSingle((G4ElectronOccupancy *) aElectronOccupancy);
123 }
124 
125 inline
127 {
128  return theSizeOfOrbit;
129 }
130 
131 inline
133 {
134  return theTotalOccupancy;
135 }
136 
137 inline
139 {
140  G4int value = 0;
141  if ((orbit >=0)&&(orbit<theSizeOfOrbit)){
142  value = theOccupancies[orbit];
143  }
144  return value;
145 }
146 
147 inline
149 {
150  G4int value =0;
151  if ((orbit >=0)&&(orbit<theSizeOfOrbit)){
152  theOccupancies[orbit] += number;
153  theTotalOccupancy += number;
154  value = number;
155  }
156  return value;
157 }
158 
159 inline
161 {
162  G4int value =0;
163  if ((orbit >=0)&&(orbit<theSizeOfOrbit) ){
164  if ( theOccupancies[orbit] < number ) number = theOccupancies[orbit];
165  theOccupancies[orbit] -= number;
166  theTotalOccupancy -= number;
167  value = number;
168  }
169  return value;
170 }
171 #endif
172 
173 
174 
175 
176 
177