ECCE @ EIC Software
 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 
43 {
45  return _instance;
46 }
47 
49  : theSizeOfOrbit(sizeOrbit)
50 {
51  // check size
52  if ( (theSizeOfOrbit <1 ) || (theSizeOfOrbit > MaxSizeOfOrbit) ) {
54  }
55 
56  // allocate and clear the array of theOccupancies
58  G4int index =0;
59  for (index = 0; index < theSizeOfOrbit; index++) {
60  theOccupancies[index] =0;
61  }
62 
64 }
65 
67 {
68  theSizeOfOrbit = -1;
69 
70  delete [] theOccupancies;
71  theOccupancies =0;
73 }
74 
76 {
78 
79  // allocate and clear the array of theOccupancies
81  G4int index =0;
82  for (index = 0; index < theSizeOfOrbit; index++) {
83  theOccupancies[index] = right.theOccupancies[index];
84  }
85 
87 }
88 
90 {
91  if ( this != &right) {
93 
94  // allocate and clear the array of theOccupancies
95  if ( theOccupancies != 0 ) delete [] theOccupancies;
97  G4int index =0;
98  for (index = 0; index < theSizeOfOrbit; index++) {
99  theOccupancies[index] = right.theOccupancies[index];
100  }
101 
103  }
104  return *this;
105 }
106 
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 
125 {
126  return !(*this == right);
127 }
128 
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 
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 
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 }