00001 // 00002 // ******************************************************************** 00003 // * License and Disclaimer * 00004 // * * 00005 // * The Geant4 software is copyright of the Copyright Holders of * 00006 // * the Geant4 Collaboration. It is provided under the terms and * 00007 // * conditions of the Geant4 Software License, included in the file * 00008 // * LICENSE and available at http://cern.ch/geant4/license . These * 00009 // * include a list of copyright holders. * 00010 // * * 00011 // * Neither the authors of this software system, nor their employing * 00012 // * institutes,nor the agencies providing financial support for this * 00013 // * work make any representation or warranty, express or implied, * 00014 // * regarding this software system or assume any liability for its * 00015 // * use. Please see the license in the file LICENSE and URL above * 00016 // * for the full disclaimer and the limitation of liability. * 00017 // * * 00018 // * This code implementation is the result of the scientific and * 00019 // * technical work of the GEANT4 collaboration. * 00020 // * By using, copying, modifying or distributing the software (or * 00021 // * any work based on the software) you agree to acknowledge its * 00022 // * use in resulting scientific publications, and indicate your * 00023 // * acceptance of all terms of the Geant4 Software license. * 00024 // ******************************************************************** 00025 // 00026 // 00027 // $Id$ 00028 // 00029 // 00030 // ---------------------------------------------------------------------- 00031 // GEANT 4 class implementation file 00032 // 00033 // History: first implementation, based on object model of 00034 // Hisaya Kurashige, 17 Aug 1999 00035 // ---------------------------------------------------------------- 00036 // This class has information of occupation of electrons 00037 // in atomic orbits 00038 // --------------------------------------------------------------- 00039 00040 #include "G4ElectronOccupancy.hh" 00041 00042 G4Allocator<G4ElectronOccupancy> aElectronOccupancyAllocator; 00043 00044 G4ElectronOccupancy::G4ElectronOccupancy(G4int sizeOrbit ): 00045 theSizeOfOrbit(sizeOrbit) 00046 { 00047 // check size 00048 if ( (theSizeOfOrbit <1 ) || (theSizeOfOrbit > MaxSizeOfOrbit) ) { 00049 theSizeOfOrbit = MaxSizeOfOrbit; 00050 } 00051 00052 // allocate and clear the array of theOccupancies 00053 theOccupancies = new G4int[theSizeOfOrbit]; 00054 G4int index =0; 00055 for (index = 0; index < theSizeOfOrbit; index++) { 00056 theOccupancies[index] =0; 00057 } 00058 00059 theTotalOccupancy =0; 00060 } 00061 00062 G4ElectronOccupancy::~G4ElectronOccupancy() 00063 { 00064 theSizeOfOrbit = -1; 00065 00066 delete [] theOccupancies; 00067 theOccupancies =0; 00068 theTotalOccupancy =0; 00069 } 00070 00071 00072 G4ElectronOccupancy::G4ElectronOccupancy(const G4ElectronOccupancy& right) 00073 { 00074 theSizeOfOrbit = right.theSizeOfOrbit; 00075 00076 // allocate and clear the array of theOccupancies 00077 theOccupancies = new G4int[theSizeOfOrbit]; 00078 G4int index =0; 00079 for (index = 0; index < theSizeOfOrbit; index++) { 00080 theOccupancies[index] = right.theOccupancies[index]; 00081 } 00082 00083 theTotalOccupancy = right.theTotalOccupancy; 00084 } 00085 00086 G4ElectronOccupancy& G4ElectronOccupancy::operator=(const G4ElectronOccupancy& right) 00087 { 00088 if ( this != &right) { 00089 theSizeOfOrbit = right.theSizeOfOrbit; 00090 00091 // allocate and clear the array of theOccupancies 00092 if ( theOccupancies != 0 ) delete [] theOccupancies; 00093 theOccupancies = new G4int[theSizeOfOrbit]; 00094 G4int index =0; 00095 for (index = 0; index < theSizeOfOrbit; index++) { 00096 theOccupancies[index] = right.theOccupancies[index]; 00097 } 00098 00099 theTotalOccupancy = right.theTotalOccupancy; 00100 } 00101 return *this; 00102 } 00103 00104 G4int G4ElectronOccupancy::operator==(const G4ElectronOccupancy& right) const 00105 { 00106 G4int index; 00107 G4bool value = true; 00108 for (index = 0; index < MaxSizeOfOrbit; index++) { 00109 if ( (index < theSizeOfOrbit ) && ( index < right.theSizeOfOrbit) ) { 00110 value = value && 00111 (theOccupancies[index] == right.theOccupancies[index]) ; 00112 } else if ((index < theSizeOfOrbit ) && ( index >= right.theSizeOfOrbit)) { 00113 value = value && (theOccupancies[index] == 0); 00114 } else if ((index >= theSizeOfOrbit ) && ( index <right.theSizeOfOrbit)) { 00115 value = value && (right.theOccupancies[index] == 0); 00116 } 00117 } 00118 return value; 00119 } 00120 00121 G4int G4ElectronOccupancy::operator!=(const G4ElectronOccupancy& right) const 00122 { 00123 return !(*this == right); 00124 } 00125 00126 00127 void G4ElectronOccupancy::DumpInfo() const 00128 { 00129 G4cout << " -- Electron Occupancy -- " << G4endl; 00130 G4int index; 00131 for (index = 0; index < theSizeOfOrbit; index++) { 00132 G4cout << " " << index << "-th orbit " 00133 << theOccupancies[index] << G4endl; 00134 } 00135 }