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] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /particles/management/src/G4ElectronOccupancy.cc (Version 11.3.0) and /particles/management/src/G4ElectronOccupancy.cc (Version 10.2.p3)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 // G4ElectronOccupancy class implementation    << 
 27 //                                                 26 //
 28 // Author: Hisaya Kurashige, 17 Aug 1999       <<  27 // $Id: G4ElectronOccupancy.cc 79357 2014-02-25 10:06:54Z 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
 29 // -------------------------------------------     38 // ---------------------------------------------------------------
 30                                                    39 
 31 #include "G4ElectronOccupancy.hh"                  40 #include "G4ElectronOccupancy.hh"
 32                                                << 
 33 #include <sstream>                                 41 #include <sstream>
 34                                                    42 
 35 G4Allocator<G4ElectronOccupancy>*& aElectronOc <<  43 G4ThreadLocal G4Allocator<G4ElectronOccupancy> *aElectronOccupancyAllocator = 0;
 36 {                                              << 
 37   G4ThreadLocalStatic G4Allocator<G4ElectronOc << 
 38   return _instance;                            << 
 39 }                                              << 
 40                                                    44 
 41 G4ElectronOccupancy::G4ElectronOccupancy(G4int <<  45 G4ElectronOccupancy::G4ElectronOccupancy(G4int sizeOrbit )
                                                   >>  46   : theSizeOfOrbit(sizeOrbit)
 42 {                                                  47 {
 43   // check size                                    48   // check size
 44   if ((theSizeOfOrbit < 1) || (theSizeOfOrbit  <<  49   if  ( (theSizeOfOrbit <1 ) || (theSizeOfOrbit > MaxSizeOfOrbit) ) {
 45     theSizeOfOrbit = MaxSizeOfOrbit;               50     theSizeOfOrbit = MaxSizeOfOrbit;
 46   }                                                51   }
 47                                                    52 
 48   // allocate and clear the array of theOccupa <<  53   // allocate and clear the array of theOccupancies 
 49   theOccupancies = new G4int[theSizeOfOrbit];      54   theOccupancies = new G4int[theSizeOfOrbit];
 50   for (G4int index = 0; index < theSizeOfOrbit <<  55   G4int   index =0;
 51     theOccupancies[index] = 0;                 <<  56   for (index = 0; index <  theSizeOfOrbit; index++) {
                                                   >>  57     theOccupancies[index] =0;
 52   }                                                58   }
 53                                                    59 
 54   theTotalOccupancy = 0;                       <<  60    theTotalOccupancy =0;
 55 }                                                  61 }
 56                                                    62 
 57 G4ElectronOccupancy::~G4ElectronOccupancy()        63 G4ElectronOccupancy::~G4ElectronOccupancy()
 58 {                                                  64 {
 59   theSizeOfOrbit = -1;                         <<  65    theSizeOfOrbit = -1;
 60                                                    66 
 61   delete[] theOccupancies;                     <<  67    delete [] theOccupancies;
 62   theOccupancies = nullptr;                    <<  68    theOccupancies =0;
 63   theTotalOccupancy = 0;                       <<  69    theTotalOccupancy =0;
 64 }                                                  70 }
 65                                                    71 
 66 G4ElectronOccupancy::G4ElectronOccupancy(const     72 G4ElectronOccupancy::G4ElectronOccupancy(const G4ElectronOccupancy& right)
 67 {                                                  73 {
 68   theSizeOfOrbit = right.theSizeOfOrbit;           74   theSizeOfOrbit = right.theSizeOfOrbit;
 69                                                    75 
 70   // allocate and clear the array of theOccupa <<  76   // allocate and clear the array of theOccupancies 
 71   theOccupancies = new G4int[theSizeOfOrbit];      77   theOccupancies = new G4int[theSizeOfOrbit];
 72   for (G4int index = 0; index < theSizeOfOrbit <<  78   G4int   index =0;
                                                   >>  79   for (index = 0; index <  theSizeOfOrbit; index++) {
 73     theOccupancies[index] = right.theOccupanci     80     theOccupancies[index] = right.theOccupancies[index];
 74   }                                                81   }
 75                                                    82 
 76   theTotalOccupancy = right.theTotalOccupancy;     83   theTotalOccupancy = right.theTotalOccupancy;
 77 }                                                  84 }
 78                                                    85 
 79 G4ElectronOccupancy& G4ElectronOccupancy::oper     86 G4ElectronOccupancy& G4ElectronOccupancy::operator=(const G4ElectronOccupancy& right)
 80 {                                                  87 {
 81   if (this != &right) {                        <<  88   if ( this != &right) {
 82     theSizeOfOrbit = right.theSizeOfOrbit;         89     theSizeOfOrbit = right.theSizeOfOrbit;
 83                                                <<  90     
 84     // allocate and clear the array of theOccu <<  91     // allocate and clear the array of theOccupancies 
 85     delete[] theOccupancies;                   <<  92     if ( theOccupancies != 0 ) delete [] theOccupancies;
 86     theOccupancies = new G4int[theSizeOfOrbit]     93     theOccupancies = new G4int[theSizeOfOrbit];
 87     for (G4int index = 0; index < theSizeOfOrb <<  94     G4int   index =0;
                                                   >>  95     for (index = 0; index <  theSizeOfOrbit; index++) {
 88       theOccupancies[index] = right.theOccupan     96       theOccupancies[index] = right.theOccupancies[index];
 89     }                                              97     }
 90                                                <<  98     
 91     theTotalOccupancy = right.theTotalOccupanc     99     theTotalOccupancy = right.theTotalOccupancy;
 92   }                                               100   }
 93   return *this;                                   101   return *this;
 94 }                                                 102 }
 95                                                   103 
 96 G4bool G4ElectronOccupancy::operator==(const G << 104 G4int G4ElectronOccupancy::operator==(const G4ElectronOccupancy& right) const
 97 {                                                 105 {
                                                   >> 106   G4int index;
 98   G4bool value = true;                            107   G4bool value = true;
 99   for (G4int index = 0; index < MaxSizeOfOrbit << 108   for (index = 0; index < MaxSizeOfOrbit; index++) {
100     if ((index < theSizeOfOrbit) && (index < r << 109     if ( (index < theSizeOfOrbit ) && ( index < right.theSizeOfOrbit) ) {
101       value = value && (theOccupancies[index]  << 110       value = value && 
102     }                                          << 111          (theOccupancies[index] == right.theOccupancies[index]) ;
103     else if ((index < theSizeOfOrbit) && (inde << 112     } else if ((index < theSizeOfOrbit ) && ( index >= right.theSizeOfOrbit)) {
104       value = value && (!static_cast<G4bool>(t << 113       value = value && (theOccupancies[index] == 0);
105     }                                          << 114     } else if ((index >= theSizeOfOrbit ) && ( index <right.theSizeOfOrbit)) {
106     else if ((index >= theSizeOfOrbit) && (ind << 115       value = value && (right.theOccupancies[index] == 0);
107       value = value && (!static_cast<G4bool>(r << 
108     }                                             116     }
109   }                                               117   }
110   return value;                                   118   return value;
111 }                                                 119 }
112                                                   120 
113 G4bool G4ElectronOccupancy::operator!=(const G << 121 G4int G4ElectronOccupancy::operator!=(const G4ElectronOccupancy& right) const
114 {                                                 122 {
115   return !(*this == right);                       123   return !(*this == right);
116 }                                                 124 }
117                                                   125 
118 void G4ElectronOccupancy::DumpInfo() const        126 void G4ElectronOccupancy::DumpInfo() const
119 {                                                 127 {
120   G4cout << "  -- Electron Occupancy -- " << G    128   G4cout << "  -- Electron Occupancy -- " << G4endl;
121   for (G4int index = 0; index < theSizeOfOrbit << 129   G4int index;
122     G4cout << "   " << index << "-th orbit     << 130   for (index = 0; index < theSizeOfOrbit; index++) {
                                                   >> 131     G4cout << "   " << index << "-th orbit       " 
                                                   >> 132            <<  theOccupancies[index] << G4endl;
123   }                                               133   }
124 }                                                 134 }
125                                                   135 
126 G4int G4ElectronOccupancy::AddElectron(G4int o << 136 G4int  G4ElectronOccupancy::AddElectron(G4int orbit, G4int number)
127 {                                                 137 {
128   G4int value = 0;                             << 138   G4int value =0;
129   if (orbit >= theSizeOfOrbit) {               << 139   if (orbit>=theSizeOfOrbit){
130     std::ostringstream smsg;                      140     std::ostringstream smsg;
131     smsg << "Orbit (" << orbit << ") exceeds t << 141     smsg<<  "Orbit (" << orbit 
                                                   >> 142   <<") exceeds the maximum("
                                                   >> 143   <<theSizeOfOrbit-1<<")  ";
132     G4String msg = smsg.str();                    144     G4String msg = smsg.str();
133     G4Exception("G4ElectronOccupancy::AddElect << 145     G4Exception("G4ElectronOccupancy::AddElectron()","PART131",
134   }                                            << 146     JustWarning, msg);
135   else if (orbit >= 0) {                       << 147   } else if (orbit >=0) {
136     theOccupancies[orbit] += number;              148     theOccupancies[orbit] += number;
137     theTotalOccupancy += number;               << 149     theTotalOccupancy += number; 
138     value = number;                            << 150     value = number;   
139   }                                               151   }
140   return value;                                   152   return value;
141 }                                                 153 }
142                                                   154 
143 G4int G4ElectronOccupancy::RemoveElectron(G4in << 155 G4int  G4ElectronOccupancy::RemoveElectron(G4int orbit, G4int number)
144 {                                                 156 {
145   G4int value = 0;                             << 157   G4int value =0;
146   if (orbit >= theSizeOfOrbit) {               << 158   if (orbit>=theSizeOfOrbit){
147     std::ostringstream smsg;                      159     std::ostringstream smsg;
148     smsg << "Orbit (" << orbit << ") exceeds t << 160     smsg<<  "Orbit (" << orbit 
                                                   >> 161   <<") exceeds the maximum("
                                                   >> 162   <<theSizeOfOrbit-1 <<") ";
149     G4String msg = smsg.str();                    163     G4String msg = smsg.str();
150     G4Exception("G4ElectronOccupancy::RemoveEl << 164     G4Exception("G4ElectronOccupancy::RemoveElectron()","PART131",
151   }                                            << 165     JustWarning, msg);
152   else if (orbit >= 0) {                       << 166   } else if (orbit >=0) {
153     if (theOccupancies[orbit] < number) number << 167     if ( theOccupancies[orbit] < number ) number = theOccupancies[orbit];
154     theOccupancies[orbit] -= number;              168     theOccupancies[orbit] -= number;
155     theTotalOccupancy -= number;               << 169     theTotalOccupancy -= number;    
156     value = number;                               170     value = number;
157   }                                               171   }
158   return value;                                   172   return value;
159 }                                                 173 }
160                                                   174