ECCE @ EIC Software
Reference for
ECCE @ EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
G4ElectronOccupancy.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file 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
//
28
//
29
// ----------------------------------------------------------------------
30
// GEANT 4 class implementation file
31
//
32
// History: first implementation, based on object model of
33
// Hisaya Kurashige, 17 Aug 1999
34
// ----------------------------------------------------------------
35
// This class has information of occupation of electrons
36
// in atomic orbits
37
// ---------------------------------------------------------------
38
39
#include "
G4ElectronOccupancy.hh
"
40
#include <sstream>
41
42
G4Allocator<G4ElectronOccupancy>
*&
aElectronOccupancyAllocator
()
43
{
44
G4ThreadLocalStatic
G4Allocator<G4ElectronOccupancy>
* _instance =
nullptr
;
45
return
_instance;
46
}
47
48
G4ElectronOccupancy::G4ElectronOccupancy
(
G4int
sizeOrbit )
49
: theSizeOfOrbit(sizeOrbit)
50
{
51
// check size
52
if
( (
theSizeOfOrbit
<1 ) || (
theSizeOfOrbit
>
MaxSizeOfOrbit
) ) {
53
theSizeOfOrbit
=
MaxSizeOfOrbit
;
54
}
55
56
// allocate and clear the array of theOccupancies
57
theOccupancies
=
new
G4int
[
theSizeOfOrbit
];
58
G4int
index =0;
59
for
(index = 0; index <
theSizeOfOrbit
; index++) {
60
theOccupancies
[index] =0;
61
}
62
63
theTotalOccupancy
=0;
64
}
65
66
G4ElectronOccupancy::~G4ElectronOccupancy
()
67
{
68
theSizeOfOrbit
= -1;
69
70
delete
[]
theOccupancies
;
71
theOccupancies
=0;
72
theTotalOccupancy
=0;
73
}
74
75
G4ElectronOccupancy::G4ElectronOccupancy
(
const
G4ElectronOccupancy
&
right
)
76
{
77
theSizeOfOrbit
= right.
theSizeOfOrbit
;
78
79
// allocate and clear the array of theOccupancies
80
theOccupancies
=
new
G4int
[
theSizeOfOrbit
];
81
G4int
index =0;
82
for
(index = 0; index <
theSizeOfOrbit
; index++) {
83
theOccupancies
[index] = right.
theOccupancies
[index];
84
}
85
86
theTotalOccupancy
= right.
theTotalOccupancy
;
87
}
88
89
G4ElectronOccupancy
&
G4ElectronOccupancy::operator=
(
const
G4ElectronOccupancy
&
right
)
90
{
91
if
(
this
!= &right) {
92
theSizeOfOrbit
= right.
theSizeOfOrbit
;
93
94
// allocate and clear the array of theOccupancies
95
if
(
theOccupancies
!= 0 )
delete
[]
theOccupancies
;
96
theOccupancies
=
new
G4int
[
theSizeOfOrbit
];
97
G4int
index =0;
98
for
(index = 0; index <
theSizeOfOrbit
; index++) {
99
theOccupancies
[index] = right.
theOccupancies
[index];
100
}
101
102
theTotalOccupancy
= right.
theTotalOccupancy
;
103
}
104
return
*
this
;
105
}
106
107
G4bool
G4ElectronOccupancy::operator==
(
const
G4ElectronOccupancy
&
right
)
const
108
{
109
G4int
index;
110
G4bool
value
=
true
;
111
for
(index = 0; index <
MaxSizeOfOrbit
; index++) {
112
if
( (index <
theSizeOfOrbit
) && ( index < right.
theSizeOfOrbit
) ) {
113
value = value &&
114
(
theOccupancies
[index] == right.
theOccupancies
[index]) ;
115
}
else
if
((index <
theSizeOfOrbit
) && ( index >= right.
theSizeOfOrbit
)) {
116
value = value && (
theOccupancies
[index] ==
false
);
117
}
else
if
((index >=
theSizeOfOrbit
) && ( index <right.
theSizeOfOrbit
)) {
118
value = value && (right.
theOccupancies
[index] ==
false
);
119
}
120
}
121
return
value
;
122
}
123
124
G4bool
G4ElectronOccupancy::operator!=
(
const
G4ElectronOccupancy
&
right
)
const
125
{
126
return
!(*
this
==
right
);
127
}
128
129
void
G4ElectronOccupancy::DumpInfo
()
const
130
{
131
G4cout
<<
" -- Electron Occupancy -- "
<<
G4endl
;
132
G4int
index;
133
for
(index = 0; index <
theSizeOfOrbit
; index++) {
134
G4cout
<<
" "
<< index <<
"-th orbit "
135
<<
theOccupancies
[index] <<
G4endl
;
136
}
137
}
138
139
G4int
G4ElectronOccupancy::AddElectron
(
G4int
orbit,
G4int
number)
140
{
141
G4int
value
=0;
142
if
(orbit>=
theSizeOfOrbit
){
143
std::ostringstream smsg;
144
smsg<<
"Orbit ("
<< orbit
145
<<
") exceeds the maximum("
146
<<
theSizeOfOrbit
-1<<
") "
;
147
G4String
msg = smsg.str();
148
G4Exception
(
"G4ElectronOccupancy::AddElectron()"
,
"PART131"
,
149
JustWarning
, msg);
150
}
else
if
(orbit >=0) {
151
theOccupancies
[orbit] += number;
152
theTotalOccupancy
+= number;
153
value = number;
154
}
155
return
value
;
156
}
157
158
G4int
G4ElectronOccupancy::RemoveElectron
(
G4int
orbit,
G4int
number)
159
{
160
G4int
value
=0;
161
if
(orbit>=
theSizeOfOrbit
){
162
std::ostringstream smsg;
163
smsg<<
"Orbit ("
<< orbit
164
<<
") exceeds the maximum("
165
<<
theSizeOfOrbit
-1 <<
") "
;
166
G4String
msg = smsg.str();
167
G4Exception
(
"G4ElectronOccupancy::RemoveElectron()"
,
"PART131"
,
168
JustWarning
, msg);
169
}
else
if
(orbit >=0) {
170
if
(
theOccupancies
[orbit] < number ) number =
theOccupancies
[orbit];
171
theOccupancies
[orbit] -= number;
172
theTotalOccupancy
-= number;
173
value = number;
174
}
175
return
value
;
176
}
geant4
tree
geant4-10.6-release
source
particles
management
src
G4ElectronOccupancy.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:24
using
1.8.2 with
ECCE GitHub integration