Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4ElectronOccupancy.cc
이 파일의 문서화 페이지로 가기
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.cc 110257 2018-05-17 14:20:12Z gcosmo $
28 //
29 //
30 // ----------------------------------------------------------------------
31 // GEANT 4 class implementation file
32 //
33 // History: first implementation, based on object model of
34 // Hisaya Kurashige, 17 Aug 1999
35 // ----------------------------------------------------------------
36 // This class has information of occupation of electrons
37 // in atomic orbits
38 // ---------------------------------------------------------------
39 
40 #include "G4ElectronOccupancy.hh"
41 #include <sstream>
42 
44 {
46  return _instance;
47 }
48 
50  : theSizeOfOrbit(sizeOrbit)
51 {
52  // check size
53  if ( (theSizeOfOrbit <1 ) || (theSizeOfOrbit > MaxSizeOfOrbit) ) {
55  }
56 
57  // allocate and clear the array of theOccupancies
59  G4int index =0;
60  for (index = 0; index < theSizeOfOrbit; index++) {
61  theOccupancies[index] =0;
62  }
63 
65 }
66 
68 {
69  theSizeOfOrbit = -1;
70 
71  delete [] theOccupancies;
72  theOccupancies =0;
74 }
75 
77 {
79 
80  // allocate and clear the array of theOccupancies
82  G4int index =0;
83  for (index = 0; index < theSizeOfOrbit; index++) {
84  theOccupancies[index] = right.theOccupancies[index];
85  }
86 
88 }
89 
91 {
92  if ( this != &right) {
94 
95  // allocate and clear the array of theOccupancies
96  if ( theOccupancies != 0 ) delete [] theOccupancies;
98  G4int index =0;
99  for (index = 0; index < theSizeOfOrbit; index++) {
100  theOccupancies[index] = right.theOccupancies[index];
101  }
102 
104  }
105  return *this;
106 }
107 
109 {
110  G4int index;
111  G4bool value = true;
112  for (index = 0; index < MaxSizeOfOrbit; index++) {
113  if ( (index < theSizeOfOrbit ) && ( index < right.theSizeOfOrbit) ) {
114  value = value &&
115  (theOccupancies[index] == right.theOccupancies[index]) ;
116  } else if ((index < theSizeOfOrbit ) && ( index >= right.theSizeOfOrbit)) {
117  value = value && (theOccupancies[index] == 0);
118  } else if ((index >= theSizeOfOrbit ) && ( index <right.theSizeOfOrbit)) {
119  value = value && (right.theOccupancies[index] == 0);
120  }
121  }
122  return value;
123 }
124 
126 {
127  return !(*this == right);
128 }
129 
131 {
132  G4cout << " -- Electron Occupancy -- " << G4endl;
133  G4int index;
134  for (index = 0; index < theSizeOfOrbit; index++) {
135  G4cout << " " << index << "-th orbit "
136  << theOccupancies[index] << G4endl;
137  }
138 }
139 
141 {
142  G4int value =0;
143  if (orbit>=theSizeOfOrbit){
144  std::ostringstream smsg;
145  smsg<< "Orbit (" << orbit
146  <<") exceeds the maximum("
147  <<theSizeOfOrbit-1<<") ";
148  G4String msg = smsg.str();
149  G4Exception("G4ElectronOccupancy::AddElectron()","PART131",
150  JustWarning, msg);
151  } else if (orbit >=0) {
152  theOccupancies[orbit] += number;
153  theTotalOccupancy += number;
154  value = number;
155  }
156  return value;
157 }
158 
160 {
161  G4int value =0;
162  if (orbit>=theSizeOfOrbit){
163  std::ostringstream smsg;
164  smsg<< "Orbit (" << orbit
165  <<") exceeds the maximum("
166  <<theSizeOfOrbit-1 <<") ";
167  G4String msg = smsg.str();
168  G4Exception("G4ElectronOccupancy::RemoveElectron()","PART131",
169  JustWarning, msg);
170  } else if (orbit >=0) {
171  if ( theOccupancies[orbit] < number ) number = theOccupancies[orbit];
172  theOccupancies[orbit] -= number;
173  theTotalOccupancy -= number;
174  value = number;
175  }
176  return value;
177 }
G4PART_DLL G4Allocator< G4ElectronOccupancy > *& aElectronOccupancyAllocator()
#define G4endl
Definition: G4ios.hh:61
#define G4ThreadLocalStatic
Definition: tls.hh:68
G4int operator!=(const G4ElectronOccupancy &right) const
bool G4bool
Definition: G4Types.hh:79
const XML_Char int const XML_Char * value
Definition: expat.h:331
G4ElectronOccupancy(G4int sizeOrbit=MaxSizeOfOrbit)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.hh:65
int G4int
Definition: G4Types.hh:78
G4int AddElectron(G4int orbit, G4int number=1)
G4int RemoveElectron(G4int orbit, G4int number=1)
G4GLOB_DLL std::ostream G4cout
G4ElectronOccupancy & operator=(const G4ElectronOccupancy &right)
G4int operator==(const G4ElectronOccupancy &right) const