source: trunk/source/particles/management/include/G4ElectronOccupancy.hh@ 1192

Last change on this file since 1192 was 992, checked in by garnier, 17 years ago

fichiers oublies

File size: 5.4 KB
RevLine 
[824]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: G4ElectronOccupancy.hh,v 1.9 2006/06/29 19:23:08 gunter Exp $
[992]28// GEANT4 tag $Name: geant4-09-02-ref-02 $
[824]29//
30//
31// ------------------------------------------------------------
32// GEANT 4 class header file
33//
34// History: first implementation, based on object model of
35// Hisaya Kurashige, 17 Aug 1999
36// ----------------------------------------------------------------
37// Class Description
38// This class has information of occupation of electrons
39// in atomic orbits
40// -
41// GetOccupancy(N) gives the number of electron
42// in N-th orbit
43// For example : Carbon atom should be
44// GetOccupancy(0) --> 2
45// GetOccupancy(1) --> 4
46// GetOccupancy(2..7) --> 0
47// -
48// GetTotalOccupancy() gives the total number of electrons
49//
50// ---------------------------------------------------------------
51
52
53
54#ifndef G4ElectronOccupancy_h
55#define G4ElectronOccupancy_h 1
56
57#include "globals.hh"
58#include "G4Allocator.hh"
59#include "G4ios.hh"
60
61class G4ElectronOccupancy
62{
63 public:
64 enum { MaxSizeOfOrbit = 7};
65
66 public: // With Description
67 G4ElectronOccupancy( G4int sizeOrbit = MaxSizeOfOrbit );
68 G4ElectronOccupancy( const G4ElectronOccupancy& right );
69
70 public:
71 virtual ~G4ElectronOccupancy();
72
73 // new/delete operators are oberloded to use G4Allocator
74 inline void *operator new(size_t);
75 inline void operator delete(void *aElectronOccupancy);
76
77
78 //- operators
79 G4ElectronOccupancy & operator=(const G4ElectronOccupancy &right);
80 G4int operator==(const G4ElectronOccupancy &right) const;
81 G4int operator!=(const G4ElectronOccupancy &right) const;
82
83 public: // With Description
84 // The following methods returns
85 // 0: if the orbit(atom) is vacant
86 // >0: number of electrons in orbit
87 G4int GetTotalOccupancy() const;
88 G4int GetOccupancy(G4int orbit) const;
89
90 //
91 G4int AddElectron(G4int orbit, G4int number = 1);
92 G4int RemoveElectron(G4int orbit, G4int number = 1);
93
94 G4int GetSizeOfOrbit() const;
95 void DumpInfo() const;
96
97 private:
98 G4int theSizeOfOrbit;
99 G4int theTotalOccupancy;
100 G4int* theOccupancies;
101
102};
103
104#if defined G4PARTICLES_ALLOC_EXPORT
105 extern G4DLLEXPORT G4Allocator<G4ElectronOccupancy> aElectronOccupancyAllocator;
106#else
107 extern G4DLLIMPORT G4Allocator<G4ElectronOccupancy> aElectronOccupancyAllocator;
108#endif
109
110// ------------------------
111// Inlined operators
112// ------------------------
113
114inline void * G4ElectronOccupancy::operator new(size_t)
115{
116 void * aElectronOccupancy;
117 aElectronOccupancy = (void *) aElectronOccupancyAllocator.MallocSingle();
118 return aElectronOccupancy;
119}
120
121inline void G4ElectronOccupancy::operator delete(void * aElectronOccupancy)
122{
123 aElectronOccupancyAllocator.FreeSingle((G4ElectronOccupancy *) aElectronOccupancy);
124}
125
126inline
127 G4int G4ElectronOccupancy::GetSizeOfOrbit() const
128{
129 return theSizeOfOrbit;
130}
131
132inline
133 G4int G4ElectronOccupancy::GetTotalOccupancy() const
134{
135 return theTotalOccupancy;
136}
137
138inline
139 G4int G4ElectronOccupancy::GetOccupancy(G4int orbit) const
140{
141 G4int value = 0;
142 if ((orbit >=0)&&(orbit<theSizeOfOrbit)){
143 value = theOccupancies[orbit];
144 }
145 return value;
146}
147
148inline
149 G4int G4ElectronOccupancy::AddElectron(G4int orbit, G4int number)
150{
151 G4int value =0;
152 if ((orbit >=0)&&(orbit<theSizeOfOrbit)){
153 theOccupancies[orbit] += number;
154 theTotalOccupancy += number;
155 value = number;
156 }
157 return value;
158}
159
160inline
161 G4int G4ElectronOccupancy::RemoveElectron(G4int orbit, G4int number)
162{
163 G4int value =0;
164 if ((orbit >=0)&&(orbit<theSizeOfOrbit) ){
165 if ( theOccupancies[orbit] < number ) number = theOccupancies[orbit];
166 theOccupancies[orbit] -= number;
167 theTotalOccupancy -= number;
168 value = number;
169 }
170 return value;
171}
172#endif
173
174
175
176
177
178
Note: See TracBrowser for help on using the repository browser.