Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4ElectronOccupancy Class Reference

#include <G4ElectronOccupancy.hh>

Public Types

enum  { MaxSizeOfOrbit = 20 }
 

Public Member Functions

 G4ElectronOccupancy (G4int sizeOrbit=MaxSizeOfOrbit)
 
 G4ElectronOccupancy (const G4ElectronOccupancy &right)
 
virtual ~G4ElectronOccupancy ()
 
voidoperator new (size_t)
 
void operator delete (void *aElectronOccupancy)
 
G4ElectronOccupancyoperator= (const G4ElectronOccupancy &right)
 
G4int operator== (const G4ElectronOccupancy &right) const
 
G4int operator!= (const G4ElectronOccupancy &right) const
 
G4int GetTotalOccupancy () const
 
G4int GetOccupancy (G4int orbit) const
 
G4int AddElectron (G4int orbit, G4int number=1)
 
G4int RemoveElectron (G4int orbit, G4int number=1)
 
G4int GetSizeOfOrbit () const
 
void DumpInfo () const
 

Detailed Description

Definition at line 62 of file G4ElectronOccupancy.hh.

Member Enumeration Documentation

anonymous enum
Enumerator
MaxSizeOfOrbit 

Definition at line 65 of file G4ElectronOccupancy.hh.

Constructor & Destructor Documentation

G4ElectronOccupancy::G4ElectronOccupancy ( G4int  sizeOrbit = MaxSizeOfOrbit)

Definition at line 45 of file G4ElectronOccupancy.cc.

46  : theSizeOfOrbit(sizeOrbit)
47 {
48  // check size
49  if ( (theSizeOfOrbit <1 ) || (theSizeOfOrbit > MaxSizeOfOrbit) ) {
50  theSizeOfOrbit = MaxSizeOfOrbit;
51  }
52 
53  // allocate and clear the array of theOccupancies
54  theOccupancies = new G4int[theSizeOfOrbit];
55  G4int index =0;
56  for (index = 0; index < theSizeOfOrbit; index++) {
57  theOccupancies[index] =0;
58  }
59 
60  theTotalOccupancy =0;
61 }
int G4int
Definition: G4Types.hh:78
G4ElectronOccupancy::G4ElectronOccupancy ( const G4ElectronOccupancy right)

Definition at line 72 of file G4ElectronOccupancy.cc.

73 {
74  theSizeOfOrbit = right.theSizeOfOrbit;
75 
76  // allocate and clear the array of theOccupancies
77  theOccupancies = new G4int[theSizeOfOrbit];
78  G4int index =0;
79  for (index = 0; index < theSizeOfOrbit; index++) {
80  theOccupancies[index] = right.theOccupancies[index];
81  }
82 
83  theTotalOccupancy = right.theTotalOccupancy;
84 }
int G4int
Definition: G4Types.hh:78
G4ElectronOccupancy::~G4ElectronOccupancy ( )
virtual

Definition at line 63 of file G4ElectronOccupancy.cc.

64 {
65  theSizeOfOrbit = -1;
66 
67  delete [] theOccupancies;
68  theOccupancies =0;
69  theTotalOccupancy =0;
70 }

Member Function Documentation

G4int G4ElectronOccupancy::AddElectron ( G4int  orbit,
G4int  number = 1 
)

Definition at line 136 of file G4ElectronOccupancy.cc.

137 {
138  G4int value =0;
139  if (orbit>=theSizeOfOrbit){
140  std::ostringstream smsg;
141  smsg<< "Orbit (" << orbit
142  <<") exceeds the maximum("
143  <<theSizeOfOrbit-1<<") ";
144  G4String msg = smsg.str();
145  G4Exception("G4ElectronOccupancy::AddElectron()","PART131",
146  JustWarning, msg);
147  } else if (orbit >=0) {
148  theOccupancies[orbit] += number;
149  theTotalOccupancy += number;
150  value = number;
151  }
152  return value;
153 }
int G4int
Definition: G4Types.hh:78
const XML_Char int const XML_Char * value
Definition: expat.h:331
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

Here is the call graph for this function:

Here is the caller graph for this function:

void G4ElectronOccupancy::DumpInfo ( ) const

Definition at line 126 of file G4ElectronOccupancy.cc.

127 {
128  G4cout << " -- Electron Occupancy -- " << G4endl;
129  G4int index;
130  for (index = 0; index < theSizeOfOrbit; index++) {
131  G4cout << " " << index << "-th orbit "
132  << theOccupancies[index] << G4endl;
133  }
134 }
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
G4int G4ElectronOccupancy::GetOccupancy ( G4int  orbit) const
inline

Definition at line 138 of file G4ElectronOccupancy.hh.

139 {
140  G4int value = 0;
141  if ((orbit >=0)&&(orbit<theSizeOfOrbit)){
142  value = theOccupancies[orbit];
143  }
144  return value;
145 }
int G4int
Definition: G4Types.hh:78
const XML_Char int const XML_Char * value
Definition: expat.h:331

Here is the caller graph for this function:

G4int G4ElectronOccupancy::GetSizeOfOrbit ( ) const
inline

Definition at line 126 of file G4ElectronOccupancy.hh.

127 {
128  return theSizeOfOrbit;
129 }

Here is the caller graph for this function:

G4int G4ElectronOccupancy::GetTotalOccupancy ( ) const
inline

Definition at line 132 of file G4ElectronOccupancy.hh.

133 {
134  return theTotalOccupancy;
135 }

Here is the caller graph for this function:

void G4ElectronOccupancy::operator delete ( void aElectronOccupancy)
inline

Definition at line 120 of file G4ElectronOccupancy.hh.

121 {
122  aElectronOccupancyAllocator->FreeSingle((G4ElectronOccupancy *) aElectronOccupancy);
123 }
G4PART_DLL G4ThreadLocal G4Allocator< G4ElectronOccupancy > * aElectronOccupancyAllocator
void * G4ElectronOccupancy::operator new ( size_t  )
inline

Definition at line 111 of file G4ElectronOccupancy.hh.

112 {
114  {
116  }
117  return (void *) aElectronOccupancyAllocator->MallocSingle();
118 }
G4PART_DLL G4ThreadLocal G4Allocator< G4ElectronOccupancy > * aElectronOccupancyAllocator
G4int G4ElectronOccupancy::operator!= ( const G4ElectronOccupancy right) const

Definition at line 121 of file G4ElectronOccupancy.cc.

122 {
123  return !(*this == right);
124 }
G4ElectronOccupancy & G4ElectronOccupancy::operator= ( const G4ElectronOccupancy right)

Definition at line 86 of file G4ElectronOccupancy.cc.

87 {
88  if ( this != &right) {
89  theSizeOfOrbit = right.theSizeOfOrbit;
90 
91  // allocate and clear the array of theOccupancies
92  if ( theOccupancies != 0 ) delete [] theOccupancies;
93  theOccupancies = new G4int[theSizeOfOrbit];
94  G4int index =0;
95  for (index = 0; index < theSizeOfOrbit; index++) {
96  theOccupancies[index] = right.theOccupancies[index];
97  }
98 
99  theTotalOccupancy = right.theTotalOccupancy;
100  }
101  return *this;
102 }
int G4int
Definition: G4Types.hh:78
G4int G4ElectronOccupancy::operator== ( const G4ElectronOccupancy right) const

Definition at line 104 of file G4ElectronOccupancy.cc.

105 {
106  G4int index;
107  G4bool value = true;
108  for (index = 0; index < MaxSizeOfOrbit; index++) {
109  if ( (index < theSizeOfOrbit ) && ( index < right.theSizeOfOrbit) ) {
110  value = value &&
111  (theOccupancies[index] == right.theOccupancies[index]) ;
112  } else if ((index < theSizeOfOrbit ) && ( index >= right.theSizeOfOrbit)) {
113  value = value && (theOccupancies[index] == 0);
114  } else if ((index >= theSizeOfOrbit ) && ( index <right.theSizeOfOrbit)) {
115  value = value && (right.theOccupancies[index] == 0);
116  }
117  }
118  return value;
119 }
int G4int
Definition: G4Types.hh:78
const XML_Char int const XML_Char * value
Definition: expat.h:331
bool G4bool
Definition: G4Types.hh:79
G4int G4ElectronOccupancy::RemoveElectron ( G4int  orbit,
G4int  number = 1 
)

Definition at line 155 of file G4ElectronOccupancy.cc.

156 {
157  G4int value =0;
158  if (orbit>=theSizeOfOrbit){
159  std::ostringstream smsg;
160  smsg<< "Orbit (" << orbit
161  <<") exceeds the maximum("
162  <<theSizeOfOrbit-1 <<") ";
163  G4String msg = smsg.str();
164  G4Exception("G4ElectronOccupancy::RemoveElectron()","PART131",
165  JustWarning, msg);
166  } else if (orbit >=0) {
167  if ( theOccupancies[orbit] < number ) number = theOccupancies[orbit];
168  theOccupancies[orbit] -= number;
169  theTotalOccupancy -= number;
170  value = number;
171  }
172  return value;
173 }
int G4int
Definition: G4Types.hh:78
const XML_Char int const XML_Char * value
Definition: expat.h:331
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following files: