[824] | 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,v 1.9 2006/06/29 19:25:24 gunter Exp $ |
---|
[850] | 28 | // GEANT4 tag $Name: HEAD $ |
---|
[824] | 29 | // |
---|
| 30 | // |
---|
| 31 | // ---------------------------------------------------------------------- |
---|
| 32 | // GEANT 4 class implementation file |
---|
| 33 | // |
---|
| 34 | // History: first implementation, based on object model of |
---|
| 35 | // Hisaya Kurashige, 17 Aug 1999 |
---|
| 36 | // ---------------------------------------------------------------- |
---|
| 37 | // This class has information of occupation of electrons |
---|
| 38 | // in atomic orbits |
---|
| 39 | // --------------------------------------------------------------- |
---|
| 40 | |
---|
| 41 | #include "G4ElectronOccupancy.hh" |
---|
| 42 | |
---|
| 43 | G4Allocator<G4ElectronOccupancy> aElectronOccupancyAllocator; |
---|
| 44 | |
---|
| 45 | G4ElectronOccupancy::G4ElectronOccupancy(G4int sizeOrbit ): |
---|
| 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 | } |
---|
| 62 | |
---|
| 63 | G4ElectronOccupancy::~G4ElectronOccupancy() |
---|
| 64 | { |
---|
| 65 | theSizeOfOrbit = -1; |
---|
| 66 | |
---|
| 67 | delete [] theOccupancies; |
---|
| 68 | theOccupancies =0; |
---|
| 69 | theTotalOccupancy =0; |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | |
---|
| 73 | G4ElectronOccupancy::G4ElectronOccupancy(const G4ElectronOccupancy& right) |
---|
| 74 | { |
---|
| 75 | theSizeOfOrbit = right.theSizeOfOrbit; |
---|
| 76 | |
---|
| 77 | // allocate and clear the array of theOccupancies |
---|
| 78 | theOccupancies = new G4int[theSizeOfOrbit]; |
---|
| 79 | G4int index =0; |
---|
| 80 | for (index = 0; index < theSizeOfOrbit; index++) { |
---|
| 81 | theOccupancies[index] = right.theOccupancies[index]; |
---|
| 82 | } |
---|
| 83 | |
---|
| 84 | theTotalOccupancy = right.theTotalOccupancy; |
---|
| 85 | } |
---|
| 86 | |
---|
| 87 | G4ElectronOccupancy& G4ElectronOccupancy::operator=(const G4ElectronOccupancy& right) |
---|
| 88 | { |
---|
| 89 | if ( this != &right) { |
---|
| 90 | theSizeOfOrbit = right.theSizeOfOrbit; |
---|
| 91 | |
---|
| 92 | // allocate and clear the array of theOccupancies |
---|
| 93 | if ( theOccupancies != 0 ) delete [] theOccupancies; |
---|
| 94 | theOccupancies = new G4int[theSizeOfOrbit]; |
---|
| 95 | G4int index =0; |
---|
| 96 | for (index = 0; index < theSizeOfOrbit; index++) { |
---|
| 97 | theOccupancies[index] = right.theOccupancies[index]; |
---|
| 98 | } |
---|
| 99 | |
---|
| 100 | theTotalOccupancy = right.theTotalOccupancy; |
---|
| 101 | } |
---|
| 102 | return *this; |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | G4int G4ElectronOccupancy::operator==(const G4ElectronOccupancy& right) const |
---|
| 106 | { |
---|
| 107 | G4int index; |
---|
| 108 | G4bool value = true; |
---|
| 109 | for (index = 0; index < MaxSizeOfOrbit; index++) { |
---|
| 110 | if ( (index < theSizeOfOrbit ) && ( index < right.theSizeOfOrbit) ) { |
---|
| 111 | value = value && |
---|
| 112 | (theOccupancies[index] == right.theOccupancies[index]) ; |
---|
| 113 | } else if ((index < theSizeOfOrbit ) && ( index >= right.theSizeOfOrbit)) { |
---|
| 114 | value = value && (theOccupancies[index] == 0); |
---|
| 115 | } else if ((index >= theSizeOfOrbit ) && ( index <right.theSizeOfOrbit)) { |
---|
| 116 | value = value && (right.theOccupancies[index] == 0); |
---|
| 117 | } |
---|
| 118 | } |
---|
| 119 | return value; |
---|
| 120 | } |
---|
| 121 | |
---|
| 122 | G4int G4ElectronOccupancy::operator!=(const G4ElectronOccupancy& right) const |
---|
| 123 | { |
---|
| 124 | return !(*this == right); |
---|
| 125 | } |
---|
| 126 | |
---|
| 127 | |
---|
| 128 | void G4ElectronOccupancy::DumpInfo() const |
---|
| 129 | { |
---|
| 130 | G4cout << " -- Electron Occupancy -- " << G4endl; |
---|
| 131 | G4int index; |
---|
| 132 | for (index = 0; index < theSizeOfOrbit; index++) { |
---|
| 133 | G4cout << " " << index << "-th orbit " |
---|
| 134 | << theOccupancies[index] << G4endl; |
---|
| 135 | } |
---|
| 136 | } |
---|