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 10.5 ] [ 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/utils/src/G4IsotopeMagneticMomentTable.cc (Version 11.3.0) and /particles/utils/src/G4IsotopeMagneticMomentTable.cc (Version 10.0)


  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 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     26 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 27 //                                                 27 //
 28 // MODULE:              G4IsotopeMagneticMomen     28 // MODULE:              G4IsotopeMagneticMomentTable.cc
 29 //                                                 29 //
 30 // Date:                16/03/07                   30 // Date:                16/03/07
 31 // Author:              H.Kurashige                31 // Author:              H.Kurashige
 32 //                                                 32 //
 33 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     33 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 34 //                                                 34 //
 35 // HISTORY                                         35 // HISTORY
 36 ////////////////////////////////////////////// <<  36 ////////////////////////////////////////////////////////////////////////////////// IsomerLevel is added                         30 Apr. 2013  H.Kurashige
 37 /// added                         30 Apr. 2013 << 
 38                                                    37 
                                                   >>  38 //
 39 #include "G4IsotopeMagneticMomentTable.hh"         39 #include "G4IsotopeMagneticMomentTable.hh"
 40                                                    40 
 41 #include "G4PhysicalConstants.hh"              << 
 42 #include "G4SystemOfUnits.hh"                  << 
 43 #include "G4ios.hh"                                41 #include "G4ios.hh"
 44 #include "globals.hh"                              42 #include "globals.hh"
 45                                                <<  43 #include "G4PhysicalConstants.hh"
                                                   >>  44 #include "G4SystemOfUnits.hh"
                                                   >>  45 #include <iomanip>
 46 #include <fstream>                                 46 #include <fstream>
                                                   >>  47 #include <sstream>
 47                                                    48 
                                                   >>  49 const G4double G4IsotopeMagneticMomentTable::levelTolerance = 2.0*keV;
 48 // 0.1% torelance for excitation energy            50 // 0.1% torelance for excitation energy
 49 const G4double G4IsotopeMagneticMomentTable::l <<  51   
 50                                                <<  52 const G4double G4IsotopeMagneticMomentTable::nuclearMagneton = eplus*hbar_Planck/2./(proton_mass_c2 /c_squared);
 51 // Nuclear Magneton                                53 // Nuclear Magneton
 52 const G4double G4IsotopeMagneticMomentTable::n <<  54  
 53   eplus * hbar_Planck / 2. / (proton_mass_c2 / <<  55 ///////////////////////////////////////////////////////////////////////////////
 54                                                <<  56 G4IsotopeMagneticMomentTable::G4IsotopeMagneticMomentTable()
 55 G4IsotopeMagneticMomentTable::G4IsotopeMagneti <<  57   :G4VIsotopeTable("MagneticMoment")
 56 {                                                  58 {
 57   if (std::getenv("G4IONMAGNETICMOMENT") == nu <<  59   if ( !getenv("G4IONMAGNETICMOMENT")) {
 58 #ifdef G4VERBOSE                                   60 #ifdef G4VERBOSE
 59     if (GetVerboseLevel() > 1) {               <<  61     if (GetVerboseLevel()>1) {
 60       G4cout << "G4IsotopeMagneticMomentTable: <<  62       G4cout << "G4IsotopeMagneticMomentTable::G4IsotopeMagneticMomentTable():  " 
 61              << "Please setenv G4IONMAGNETICMO <<  63        <<  "Please setenv G4IONMAGNETICMOMENT for the magnetic moment data." 
 62       G4Exception("G4IsotopeMagneticMomentTabl <<  64        << G4endl;
 63                   "Please setenv G4IONMAGNETIC <<  65       G4Exception( "G4IsotopeMagneticMomentTable",
                                                   >>  66        "File Not Found",
                                                   >>  67        JustWarning, 
                                                   >>  68        "Please setenv G4IONMAGNETICMOMENT");
 64     }                                              69     }
 65 #endif                                             70 #endif
 66     G4Exception("G4IsotopeMagneticMomentTable" <<  71     G4Exception( "G4IsotopeMagneticMomentTable",
 67                 "Please setenv G4IONMAGNETICMO <<  72      "File Not Found",
                                                   >>  73      JustWarning, 
                                                   >>  74      "Please setenv G4IONMAGNETICMOMENT");
 68     return;                                        75     return;
 69   }                                                76   }
 70                                                <<  77   
 71   G4String file = std::getenv("G4IONMAGNETICMO <<  78   G4String file = getenv("G4IONMAGNETICMOMENT");
 72   std::ifstream DataFile(file);                    79   std::ifstream DataFile(file);
 73                                                    80 
 74   if (!DataFile) {                             <<  81   if (!DataFile ) {
 75 #ifdef G4VERBOSE                                   82 #ifdef G4VERBOSE
 76     if (GetVerboseLevel() > 0) {               <<  83     if (GetVerboseLevel()>0) {
 77       G4cout << "G4IsotopeMagneticMomentTable: <<  84       G4cout << "G4IsotopeMagneticMomentTable::G4IsotopeMagneticMomentTable():  " 
 78              << " is not found " << G4endl;    <<  85       << file << " is not found " << G4endl;
 79     }                                              86     }
 80 #endif                                             87 #endif
 81     G4Exception("G4IsotopeMagneticMomentTable" <<  88     G4Exception( "G4IsotopeMagneticMomentTable",
 82                 "Can not open G4IONMAGNETICMOM <<  89      "File Not Found",
                                                   >>  90      JustWarning, 
                                                   >>  91      "Can not open G4IONMAGNETICMOMENT file");
 83     return;                                        92     return;
 84   }                                                93   }
 85                                                <<  94   
 86   char inputChars[80] = {' '};                 <<  95   char inputChars[80]={' '};
 87                                                <<  96    
 88   while (!DataFile.eof()) {  // Loop checking, <<  97   while ( !DataFile.eof() ) {
 89     DataFile.getline(inputChars, 80);              98     DataFile.getline(inputChars, 80);
 90     G4String inputLine = inputChars;               99     G4String inputLine = inputChars;
 91     G4int ionA, ionZ, ionJ, isomer;               100     G4int ionA, ionZ, ionJ, isomer;
 92     G4double ionE, ionMu, ionLife;                101     G4double ionE, ionMu, ionLife;
 93     G4String ionName, ionLifeUnit;                102     G4String ionName, ionLifeUnit;
 94                                                << 103  
 95     if (inputChars[0] != '#' && inputLine.leng    104     if (inputChars[0] != '#' && inputLine.length() != 0) {
 96       std::istringstream tmpstream(inputLine);    105       std::istringstream tmpstream(inputLine);
 97       tmpstream >> ionZ >> ionName >> ionA >>  << 106       tmpstream >> ionZ >>  ionName >> ionA 
 98         >> ionMu;                              << 107     >> isomer >>  ionE 
 99                                                << 108     >> ionLife >> ionLifeUnit
100       auto fProperty = new G4IsotopeProperty() << 109     >> ionJ >> ionMu;
                                                   >> 110           
                                                   >> 111       G4IsotopeProperty* fProperty = new G4IsotopeProperty();   
101       // Set Isotope Property                     112       // Set Isotope Property
102       fProperty->SetAtomicNumber(ionZ);           113       fProperty->SetAtomicNumber(ionZ);
103       fProperty->SetAtomicMass(ionA);             114       fProperty->SetAtomicMass(ionA);
104       fProperty->SetIsomerLevel(isomer);          115       fProperty->SetIsomerLevel(isomer);
105       fProperty->SetEnergy(ionE * MeV);           116       fProperty->SetEnergy(ionE * MeV);
106       fProperty->SetiSpin(ionJ);                  117       fProperty->SetiSpin(ionJ);
107       fProperty->SetMagneticMoment(ionMu * nuc << 118       fProperty->SetMagneticMoment(ionMu*nuclearMagneton);
108                                                << 119       
109       fIsotopeList.push_back(fProperty);          120       fIsotopeList.push_back(fProperty);
110                                                   121 
111       // if (GetVerboseLevel()>2) {            << 122       //if (GetVerboseLevel()>2) {
112       //  fProperty->DumpInfo();               << 123       // fProperty->DumpInfo();
113       // }                                     << 124       //}
                                                   >> 125   
114     }                                             126     }
115   }                                               127   }
116                                                   128 
117   DataFile.close();                               129   DataFile.close();
118 }                                                 130 }
119                                                   131 
                                                   >> 132 ///////////////////////////////////////////////////////////////////////////////
120 G4IsotopeMagneticMomentTable::~G4IsotopeMagnet    133 G4IsotopeMagneticMomentTable::~G4IsotopeMagneticMomentTable()
121 {                                                 134 {
122   for (const auto& i : fIsotopeList) {         << 135   for (size_t i = 0 ; i< fIsotopeList.size(); i++) {
123     delete i;                                  << 136     delete fIsotopeList[i];
124   }                                               137   }
125   fIsotopeList.clear();                           138   fIsotopeList.clear();
126 }                                                 139 }
127                                                   140 
128 G4IsotopeMagneticMomentTable::G4IsotopeMagneti << 141 ///////////////////////////////////////////////////////////////////////////////
129   const G4IsotopeMagneticMomentTable& right)   << 142 G4IsotopeMagneticMomentTable::G4IsotopeMagneticMomentTable(const  G4IsotopeMagneticMomentTable & right)   
130   : G4VIsotopeTable(right), fIsotopeList(0)    << 143   :G4VIsotopeTable(right),
131 {}                                             << 144    fIsotopeList(0)
                                                   >> 145 {
                                                   >> 146 }
132                                                   147 
133 G4IsotopeMagneticMomentTable&                  << 148 ///////////////////////////////////////////////////////////////////////////////
134 G4IsotopeMagneticMomentTable::operator=(const  << 149 G4IsotopeMagneticMomentTable & G4IsotopeMagneticMomentTable::operator= (const  G4IsotopeMagneticMomentTable &)
135 {                                                 150 {
136   return *this;                                   151   return *this;
137 }                                                 152 }
138                                                   153 
                                                   >> 154 ///////////////////////////////////////////////////////////////////////////////
139 G4bool G4IsotopeMagneticMomentTable::FindIsoto    155 G4bool G4IsotopeMagneticMomentTable::FindIsotope(G4IsotopeProperty* pP)
140 {                                                 156 {
141   for (const auto fP : fIsotopeList) {         << 157   for (size_t i = 0 ; i< fIsotopeList.size(); ++i) {
                                                   >> 158     G4IsotopeProperty*  fP = fIsotopeList[i];
                                                   >> 159     
142     // check Z                                    160     // check Z
143     if (fP->GetAtomicNumber() > pP->GetAtomicN << 161     if ( fP->GetAtomicNumber() > pP->GetAtomicNumber()) {
144       // Not Found                                162       // Not Found
145       break;                                      163       break;
146     }                                             164     }
147     if (fP->GetAtomicNumber() < pP->GetAtomicN << 165     if ( fP->GetAtomicNumber() < pP->GetAtomicNumber()) {
148       // next                                     166       // next
149       continue;                                   167       continue;
150     }                                             168     }
151                                                << 169     
152     // check A                                    170     // check A
153     if (fP->GetAtomicMass() != pP->GetAtomicMa << 171     if ( fP->GetAtomicMass() != pP->GetAtomicMass()) {
154       // next                                     172       // next
155       continue;                                   173       continue;
156     }                                             174     }
157                                                << 175     
158     // check isomerLevel                       << 176     //check isomerLevel
159     if (fP->GetIsomerLevel() != pP->GetIsomerL    177     if (fP->GetIsomerLevel() != pP->GetIsomerLevel()) {
160       // next                                     178       // next
161       continue;                                << 179       continue;     
162     }                                             180     }
163                                                   181 
164     // check E                                 << 182     //check E
165     if (std::fabs(fP->GetEnergy() - pP->GetEne    183     if (std::fabs(fP->GetEnergy() - pP->GetEnergy()) < levelTolerance) {
166       // Found                                    184       // Found
167       return true;                             << 185       return true;     
168     }                                             186     }
                                                   >> 187     
169   }                                               188   }
170   return false;                                   189   return false;
171 }                                                 190 }
172                                                << 191 ///////////////////////////////////////////////////////////////////////////////
173 G4IsotopeProperty* G4IsotopeMagneticMomentTabl << 192 //
174                                                << 193 G4IsotopeProperty* 
175 {                                              << 194  G4IsotopeMagneticMomentTable::GetIsotope(G4int Z, G4int A, G4double E)
176   G4IsotopeProperty* fProperty = nullptr;      << 195 {
177   for (const auto fP : fIsotopeList) {         << 196   G4IsotopeProperty* fProperty = 0;
178     // check Z                                 << 197   for (size_t i = 0 ; i< fIsotopeList.size(); ++i) {
179     if (fP->GetAtomicNumber() > Z) {           << 198     G4IsotopeProperty*  fP = fIsotopeList[i];
                                                   >> 199  
                                                   >> 200      // check Z
                                                   >> 201     if ( fP->GetAtomicNumber() > Z) {
180       // Not Found                                202       // Not Found
181       break;                                      203       break;
182     }                                             204     }
183     if (fP->GetAtomicNumber() < Z) {           << 205     if ( fP->GetAtomicNumber() < Z) {
184       // next                                     206       // next
185       continue;                                   207       continue;
186     }                                             208     }
187                                                << 209     
188     // check A                                    210     // check A
189     if (fP->GetAtomicMass() != A) {            << 211     if ( fP->GetAtomicMass() != A ) {
190       // next                                     212       // next
191       continue;                                   213       continue;
192     }                                             214     }
193                                                << 215     
194     // check E                                 << 216     //check E
195     if (std::fabs(fP->GetEnergy() - E) < level    217     if (std::fabs(fP->GetEnergy() - E) < levelTolerance) {
196       // Found                                    218       // Found
197       fProperty = fP;                             219       fProperty = fP;
198       // fP->DumpInfo();                          220       // fP->DumpInfo();
199       break;                                   << 221       break;     
200     }                                             222     }
                                                   >> 223     
201   }                                               224   }
202                                                   225 
203   return fProperty;                               226   return fProperty;
                                                   >> 227   
204 }                                                 228 }
205                                                   229 
206 G4IsotopeProperty* G4IsotopeMagneticMomentTabl << 230 ///////////////////////////////////////////////////////////////////////
207 {                                              << 231 G4IsotopeProperty* 
208   G4IsotopeProperty* fProperty = nullptr;      << 232  G4IsotopeMagneticMomentTable::GetIsotopeByIsoLvl(G4int Z, G4int A, G4int lvl)
209   for (const auto fP : fIsotopeList) {         << 233 {
210     // check Z                                 << 234   G4IsotopeProperty* fProperty = 0;
211     if (fP->GetAtomicNumber() > Z) {           << 235   for (size_t i = 0 ; i< fIsotopeList.size(); ++i) {
                                                   >> 236     G4IsotopeProperty*  fP = fIsotopeList[i];
                                                   >> 237  
                                                   >> 238      // check Z
                                                   >> 239     if ( fP->GetAtomicNumber() > Z) {
212       // Not Found                                240       // Not Found
213       break;                                      241       break;
214     }                                             242     }
215     if (fP->GetAtomicNumber() < Z) {           << 243     if ( fP->GetAtomicNumber() < Z) {
216       // next                                     244       // next
217       continue;                                   245       continue;
218     }                                             246     }
219     // check A                                    247     // check A
220     if (fP->GetAtomicMass() != A) {            << 248     if ( fP->GetAtomicMass() != A ) {
221       // next                                     249       // next
222       continue;                                   250       continue;
223     }                                             251     }
224                                                << 252     
225     // check isomerLevel                       << 253     
                                                   >> 254     //check isomerLevel
226     if (fP->GetIsomerLevel() == lvl) {            255     if (fP->GetIsomerLevel() == lvl) {
227       // Found                                    256       // Found
228       fProperty = fP;                             257       fProperty = fP;
229       // fP->DumpInfo();                       << 258       //fP->DumpInfo();
230       break;                                   << 259       break;     
231     }                                             260     }
                                                   >> 261     
232   }                                               262   }
233                                                   263 
234   return fProperty;                               264   return fProperty;
                                                   >> 265   
235 }                                                 266 }
236                                                   267